/// <summary>
        /// Initialize a <code>JsModuleRecord</code> from host
        /// </summary>
        /// <remarks>Bootstrap the module loading process by creating a new module record</remarks>
        /// <param name="referencingModule">The parent module of the new module - invalid module record
        /// for a root module</param>
        /// <param name="specifier">The specifier coming from the module source code</param>
        /// <param name="normalizedSpecifier">The normalized specifier for the module</param>
        /// <returns>The new module record. The host should not try to call this API twice with the same
        /// <paramref name="normalizedSpecifier"/></returns>
        public static JsModuleRecord Create(JsModuleRecord referencingModule, string specifier,
                                            string normalizedSpecifier)
        {
            JsValue specifierValue = JsValue.FromString(specifier);

            specifierValue.AddRef();

            JsValue normalizedSpecifierValue = JsValue.FromString(normalizedSpecifier);

            normalizedSpecifierValue.AddRef();

            JsModuleRecord moduleRecord;

            try
            {
                JsErrorHelpers.ThrowIfError(NativeMethods.JsInitializeModuleRecord(referencingModule,
                                                                                   normalizedSpecifierValue, out moduleRecord));
                moduleRecord.Specifier = specifierValue;
                moduleRecord.Url       = normalizedSpecifierValue;
            }
            finally
            {
                specifierValue.Release();
                normalizedSpecifierValue.Release();
            }

            return(moduleRecord);
        }
Esempio n. 2
0
 internal static extern JsErrorCode JsModuleRecordRelease(JsModuleRecord reference, out uint count);
Esempio n. 3
0
 internal static extern JsErrorCode JsGetModuleNamespace(JsModuleRecord requestModule, out JsValue moduleNamespace);
Esempio n. 4
0
 internal static extern JsErrorCode JsGetModuleHostInfo(JsModuleRecord requestModule,
                                                        JsModuleHostInfoKind moduleHostInfo, out IntPtr hostInfo);
Esempio n. 5
0
 internal static extern JsErrorCode JsModuleEvaluation(JsModuleRecord requestModule, out JsValue result);
Esempio n. 6
0
 internal static extern JsErrorCode JsParseModuleSource(JsModuleRecord requestModule, JsSourceContext sourceContext,
                                                        byte[] script, uint scriptLength, JsParseModuleSourceFlags sourceFlag, out JsValue exception);
Esempio n. 7
0
 internal static extern JsErrorCode JsInitializeModuleRecord(JsModuleRecord referencingModule,
                                                             JsValue normalizedSpecifier, out JsModuleRecord moduleRecord);