@jsenv/core 25.0.0-alpha.0 → 25.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser_runtime/asset-manifest.json +2 -2
- package/dist/browser_runtime/{browser_runtime_a8097085.js → browser_runtime_91c5a3b8.js} +137 -26
- package/dist/browser_runtime/browser_runtime_91c5a3b8.js.map +1089 -0
- package/dist/build_manifest.js +6 -6
- package/dist/compile_proxy/asset-manifest.json +2 -2
- package/dist/compile_proxy/{compile_proxy_e16d7de8.html → compile_proxy_7ad5faa6.html} +119 -26
- package/dist/compile_proxy/{compile_proxy_e3b0c442_9e168143.js.map → compile_proxy_e3b0c442_809f35f7.js.map} +6 -6
- package/dist/event_source_client/asset-manifest.json +2 -2
- package/dist/event_source_client/{event_source_client_620fbc2c.js → event_source_client_80644aee.js} +2 -2
- package/dist/event_source_client/{event_source_client_620fbc2c.js.map → event_source_client_80644aee.js.map} +4 -3
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/{redirector_e3b0c442_3a34a156.js.map → redirector_e3b0c442_e391410e.js.map} +6 -6
- package/dist/redirector/{redirector_2e0c8abe.html → redirector_eb92e8a7.html} +119 -26
- package/dist/toolbar/asset-manifest.json +2 -2
- package/dist/toolbar/{toolbar.main_a5ef2c60.js.map → toolbar.main_6c1b3d82.js.map} +8 -8
- package/dist/toolbar/{toolbar_412abb83.html → toolbar_f7b8a263.html} +127 -32
- package/dist/toolbar_injector/asset-manifest.json +3 -3
- package/dist/toolbar_injector/{toolbar_injector_4f9c19e5.js → toolbar_injector_49e4756e.js} +2 -2
- package/dist/toolbar_injector/{toolbar_injector_4f9c19e5.js.map → toolbar_injector_49e4756e.js.map} +2 -2
- package/package.json +5 -4
- package/readme.md +22 -89
- package/src/buildProject.js +37 -15
- package/src/dev_server.js +8 -2
- package/src/execute.js +7 -1
- package/src/executeTestPlan.js +17 -0
- package/src/internal/browser_feature_detection/browser_feature_detection.js +18 -25
- package/src/internal/browser_runtime/browser_runtime.js +2 -2
- package/src/internal/browser_runtime/createBrowserRuntime.js +1 -1
- package/src/internal/browser_runtime/displayErrorInDocument.js +2 -0
- package/src/internal/browser_runtime/displayErrorNotification.js +1 -1
- package/src/internal/building/buildUsingRollup.js +3 -8
- package/src/internal/building/ressource_builder.js +35 -42
- package/src/internal/building/rollup_plugin_jsenv.js +226 -206
- package/src/internal/building/url_versioning.js +54 -42
- package/src/internal/compiling/createCompiledFileService.js +28 -40
- package/src/internal/compiling/html_source_file_service.js +66 -51
- package/src/internal/compiling/js-compilation-service/babel_plugin_systemjs_prepend.js +23 -0
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +16 -12
- package/src/internal/compiling/js-compilation-service/transformJs.js +2 -0
- package/src/internal/compiling/jsenvCompilerForHtml.js +43 -44
- package/src/internal/compiling/jsenvCompilerForImportmap.js +15 -76
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +9 -0
- package/src/internal/compiling/startCompileServer.js +29 -5
- package/src/internal/dev_server/event_source_client/livereload_preference.js +1 -1
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +9 -9
- package/src/internal/executing/executePlan.js +6 -0
- package/src/internal/generateGroupMap/{jsenvBabelPluginCompatMap.js → babel_plugins_compatibility.js} +0 -0
- package/src/internal/generateGroupMap/{featuresCompatMap.js → features_compatibility.js} +9 -1
- package/src/internal/generateGroupMap/generateGroupMap.js +6 -35
- package/src/internal/generateGroupMap/one_runtime_compat.js +9 -12
- package/src/internal/generateGroupMap/runtime_compat.js +10 -15
- package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -2
- package/src/internal/generateGroupMap/shake_babel_plugin_map.js +21 -0
- package/src/internal/import-resolution/importmap_default.js +52 -0
- package/src/internal/node_feature_detection/node_feature_detection.js +25 -19
- package/src/internal/runtime/s.js +101 -6
- package/src/internal/unevalException.js +1 -1
- package/src/jsenvServiceWorkerFinalizer.js +6 -10
- package/dist/browser_runtime/browser_runtime_a8097085.js.map +0 -1067
- package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -1
- package/src/internal/import-resolution/importmap-default.js +0 -34
|
@@ -497,6 +497,8 @@
|
|
|
497
497
|
|
|
498
498
|
var importMapPromise = Promise.resolve();
|
|
499
499
|
var importMap = { imports: {}, scopes: {}, depcache: {}, integrity: {} };
|
|
500
|
+
systemJSPrototype.importMap = importMap;
|
|
501
|
+
systemJSPrototype.baseUrl = baseUrl;
|
|
500
502
|
|
|
501
503
|
// Scripts are processed immediately, on the first System.import, and on DOMReady.
|
|
502
504
|
// Import map scripts are processed only once (by being marked) and in order for each phase.
|
|
@@ -552,6 +554,7 @@
|
|
|
552
554
|
return fetchPromise;
|
|
553
555
|
}).then(function (text) {
|
|
554
556
|
extendImportMap(importMap, text, script.src || baseUrl);
|
|
557
|
+
return importMap
|
|
555
558
|
});
|
|
556
559
|
}
|
|
557
560
|
});
|
|
@@ -566,6 +569,7 @@
|
|
|
566
569
|
}
|
|
567
570
|
resolveAndComposeImportMap(newMap, newMapUrl, importMap);
|
|
568
571
|
}
|
|
572
|
+
System.extendImportMap = extendImportMap
|
|
569
573
|
|
|
570
574
|
/*
|
|
571
575
|
* Script instantiation loading
|
|
@@ -719,23 +723,33 @@
|
|
|
719
723
|
* Supports loading System.register in workers
|
|
720
724
|
*/
|
|
721
725
|
|
|
722
|
-
if (hasSelf && typeof importScripts === 'function')
|
|
726
|
+
if (hasSelf && typeof importScripts === 'function') {
|
|
723
727
|
systemJSPrototype.instantiate = function (url) {
|
|
724
728
|
var loader = this;
|
|
725
|
-
return
|
|
726
|
-
|
|
729
|
+
return self.fetch(url, {
|
|
730
|
+
credentials: 'same-origin',
|
|
731
|
+
}).then(function (response) {
|
|
732
|
+
if (!response.ok) {
|
|
733
|
+
throw Error(errMsg(7, [response.status, response.statusText, url].join(', ') ));
|
|
734
|
+
}
|
|
735
|
+
return response.text()
|
|
736
|
+
}).then(function (source) {
|
|
737
|
+
if (source.indexOf('//# sourceURL=') < 0) source += '\n//# sourceURL=' + url;
|
|
738
|
+
(0, eval)(source);
|
|
727
739
|
return loader.getRegister(url);
|
|
728
|
-
})
|
|
740
|
+
})
|
|
729
741
|
};
|
|
742
|
+
}
|
|
730
743
|
|
|
731
744
|
}());
|
|
732
745
|
|
|
733
746
|
(function(){
|
|
734
747
|
var envGlobal = typeof self !== 'undefined' ? self : global;
|
|
735
748
|
var System = envGlobal.System;
|
|
736
|
-
var register = System.register;
|
|
737
|
-
var registerRegistry = Object.create(null)
|
|
738
749
|
|
|
750
|
+
var registerRegistry = Object.create(null)
|
|
751
|
+
var register = System.register;
|
|
752
|
+
System.registerRegistry = registerRegistry;
|
|
739
753
|
System.register = function (name, deps, declare) {
|
|
740
754
|
if (typeof name !== 'string') return register.apply(this, arguments);
|
|
741
755
|
var define = [deps, declare];
|
|
@@ -765,4 +779,85 @@
|
|
|
765
779
|
var result = registerRegistry[url] || register;
|
|
766
780
|
return result;
|
|
767
781
|
};
|
|
782
|
+
}());
|
|
783
|
+
|
|
784
|
+
(function () {
|
|
785
|
+
// worker or service worker
|
|
786
|
+
if (typeof WorkerGlobalScope === 'function' && self instanceof WorkerGlobalScope) {
|
|
787
|
+
var importMapFromParentPromise = new Promise((resolve) => {
|
|
788
|
+
var importmapMessageCallback = function (e) {
|
|
789
|
+
if (e.data === "__importmap_init__") {
|
|
790
|
+
self.removeEventListener("message", importmapMessageCallback)
|
|
791
|
+
e.ports[0].onmessage = (message) => {
|
|
792
|
+
resolve(message.data)
|
|
793
|
+
}
|
|
794
|
+
e.ports[0].postMessage('__importmap_request__')
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
self.addEventListener("message", importmapMessageCallback)
|
|
798
|
+
})
|
|
799
|
+
// var prepareImport = System.prepareImport
|
|
800
|
+
System.prepareImport = function () {
|
|
801
|
+
return importMapFromParentPromise.then(function (importmap) {
|
|
802
|
+
System.extendImportMap(System.importMap, JSON.stringify(importmap), System.baseUrl)
|
|
803
|
+
})
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// auto import first register
|
|
807
|
+
var messageEvents = []
|
|
808
|
+
var messageCallback = (event) => {
|
|
809
|
+
messageEvents.push(event)
|
|
810
|
+
}
|
|
811
|
+
self.addEventListener('message', messageCallback)
|
|
812
|
+
var register = System.register;
|
|
813
|
+
System.register = function(deps, declare) {
|
|
814
|
+
System.register = register;
|
|
815
|
+
System.registerRegistry[self.location.href] = [deps, declare];
|
|
816
|
+
System.import(self.location.href).then(() => {
|
|
817
|
+
self.removeEventListener('message', messageCallback)
|
|
818
|
+
messageEvents.forEach((messageEvent) => {
|
|
819
|
+
self.dispatchEvent(messageEvent)
|
|
820
|
+
})
|
|
821
|
+
messageEvents = null
|
|
822
|
+
})
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
else if (typeof window === 'object') {
|
|
826
|
+
var WorkerConstructor = window.Worker;
|
|
827
|
+
if (typeof WorkerConstructor === 'function') {
|
|
828
|
+
window.Worker = function (url, options) {
|
|
829
|
+
var worker = new WorkerConstructor(url, options);
|
|
830
|
+
var importmapChannel = new MessageChannel();
|
|
831
|
+
importmapChannel.port1.onmessage = function (message) {
|
|
832
|
+
System.prepareImport().then(function (importmap) {
|
|
833
|
+
message.target.postMessage(importmap);
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
worker.postMessage('__importmap_init__', [importmapChannel.port2]);
|
|
837
|
+
return worker
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
var serviceWorker = navigator.serviceWorker;
|
|
842
|
+
if (serviceWorker) {
|
|
843
|
+
var register = serviceWorker.register;
|
|
844
|
+
serviceWorker.register = function(url, options) {
|
|
845
|
+
var registrationPromise = register.call(this, url, options);
|
|
846
|
+
registrationPromise.then(function(registration) {
|
|
847
|
+
var installing = registration.installing;
|
|
848
|
+
var waiting = registration.waiting;
|
|
849
|
+
var active = registration.active;
|
|
850
|
+
var worker = installing || waiting || active;
|
|
851
|
+
var importmapChannel = new MessageChannel();
|
|
852
|
+
importmapChannel.port1.onmessage = function (message) {
|
|
853
|
+
System.prepareImport().then(function (importmap) {
|
|
854
|
+
message.target.postMessage(importmap)
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
worker.postMessage('__importmap_init__', [importmapChannel.port2]);
|
|
858
|
+
})
|
|
859
|
+
return registrationPromise
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
768
863
|
}());
|
|
@@ -4,20 +4,14 @@ import { generateContentHash } from "./internal/building/url_versioning.js"
|
|
|
4
4
|
|
|
5
5
|
export const jsenvServiceWorkerFinalizer = (
|
|
6
6
|
code,
|
|
7
|
-
{
|
|
8
|
-
serviceWorkerBuildRelativeUrl,
|
|
9
|
-
buildManifest,
|
|
10
|
-
buildFileContents,
|
|
11
|
-
lineBreakNormalization,
|
|
12
|
-
},
|
|
7
|
+
{ serviceWorkerBuildRelativeUrl, buildFileContents, lineBreakNormalization },
|
|
13
8
|
) => {
|
|
14
9
|
const generatedUrlsConfig = {}
|
|
15
|
-
Object.keys(
|
|
16
|
-
if (
|
|
10
|
+
Object.keys(buildFileContents).forEach((buildRelativeUrl) => {
|
|
11
|
+
if (buildRelativeUrl.endsWith(".map")) {
|
|
17
12
|
return
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
const buildRelativeUrl = buildManifest[projectRelativeUrl]
|
|
21
15
|
const buildUrl = resolveUrl(buildRelativeUrl, "file://")
|
|
22
16
|
const serviceWorkerBuildUrl = resolveUrl(
|
|
23
17
|
serviceWorkerBuildRelativeUrl,
|
|
@@ -48,9 +42,11 @@ export const jsenvServiceWorkerFinalizer = (
|
|
|
48
42
|
}),
|
|
49
43
|
}
|
|
50
44
|
})
|
|
45
|
+
// TODO: ideally should use magic string to prepend code
|
|
46
|
+
// but it means composing 2 source maps, something not already available in jsenv codebase
|
|
51
47
|
|
|
52
48
|
return `
|
|
53
|
-
self.generatedUrlsConfig = ${JSON.stringify(generatedUrlsConfig, null, " ")}
|
|
49
|
+
self.generatedUrlsConfig = ${JSON.stringify(generatedUrlsConfig, null, " ")};
|
|
54
50
|
${code}
|
|
55
51
|
`
|
|
56
52
|
}
|