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