public ChakraCoreJavaScriptGenerator(ResourceScriptFactory resourceScriptFactory)
        {
            _resourceScriptFactory       = resourceScriptFactory;
            _promiseContinuationCallback = PromiseContinuationCallback;

            _dispatcher.Invoke(() =>
            {
                _runtime             = JavaScriptRuntime.Create(JavaScriptRuntimeAttributes.EnableExperimentalFeatures);
                _runtime.MemoryLimit = ChakraCoreSettings.MemoryLimit;
            });
        }
Exemplo n.º 2
0
        public void AddPreload(string specifier, string code)
        {
            if (!RootModule.IsValid)
            {
                throw new InvalidOperationException("No root module set");
            }

            var module = JavaScriptModuleRecord.Initialize(RootModule, specifier);

            module.HostUrl = specifier; // Only for debugging
            _moduleLeases.Add(specifier, new ModuleLease(module));

            _dispatcher.Invoke(() =>
            {
                using (_context.GetScope())
                {
                    module.ParseSource(code);
                }
            });
        }