@jsenv/core 25.0.0-alpha.0 → 25.0.0-alpha.1

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.
Files changed (57) hide show
  1. package/dist/browser_runtime/asset-manifest.json +2 -2
  2. package/dist/browser_runtime/{browser_runtime_a8097085.js → browser_runtime_91c5a3b8.js} +137 -26
  3. package/dist/browser_runtime/browser_runtime_91c5a3b8.js.map +1089 -0
  4. package/dist/build_manifest.js +5 -5
  5. package/dist/compile_proxy/asset-manifest.json +2 -2
  6. package/dist/compile_proxy/{compile_proxy_e16d7de8.html → compile_proxy_7ad5faa6.html} +119 -26
  7. package/dist/compile_proxy/{compile_proxy_e3b0c442_9e168143.js.map → compile_proxy_e3b0c442_809f35f7.js.map} +6 -6
  8. package/dist/redirector/asset-manifest.json +2 -2
  9. package/dist/redirector/{redirector_e3b0c442_3a34a156.js.map → redirector_e3b0c442_e391410e.js.map} +6 -6
  10. package/dist/redirector/{redirector_2e0c8abe.html → redirector_eb92e8a7.html} +119 -26
  11. package/dist/toolbar/asset-manifest.json +11 -11
  12. package/dist/toolbar/{toolbar.main_a5ef2c60.js.map → toolbar.main2_6c1b3d82.js.map} +8 -8
  13. package/dist/toolbar/{toolbar_412abb83.html → toolbar_04ba410c.html} +127 -32
  14. package/dist/toolbar_injector/asset-manifest.json +2 -2
  15. package/dist/toolbar_injector/{toolbar_injector_4f9c19e5.js → toolbar_injector_4a48bc53.js} +2 -2
  16. package/dist/toolbar_injector/{toolbar_injector_4f9c19e5.js.map → toolbar_injector_4a48bc53.js.map} +2 -2
  17. package/package.json +5 -4
  18. package/readme.md +22 -89
  19. package/src/buildProject.js +28 -15
  20. package/src/dev_server.js +8 -2
  21. package/src/execute.js +7 -1
  22. package/src/executeTestPlan.js +6 -0
  23. package/src/internal/browser_feature_detection/browser_feature_detection.js +18 -25
  24. package/src/internal/browser_runtime/browser_runtime.js +2 -2
  25. package/src/internal/browser_runtime/createBrowserRuntime.js +1 -1
  26. package/src/internal/browser_runtime/displayErrorInDocument.js +2 -0
  27. package/src/internal/browser_runtime/displayErrorNotification.js +1 -1
  28. package/src/internal/building/buildUsingRollup.js +3 -8
  29. package/src/internal/building/ressource_builder.js +35 -42
  30. package/src/internal/building/rollup_plugin_jsenv.js +195 -186
  31. package/src/internal/building/url_versioning.js +36 -42
  32. package/src/internal/compiling/createCompiledFileService.js +28 -40
  33. package/src/internal/compiling/html_source_file_service.js +66 -51
  34. package/src/internal/compiling/js-compilation-service/babel_plugin_systemjs_prepend.js +23 -0
  35. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +16 -12
  36. package/src/internal/compiling/js-compilation-service/transformJs.js +2 -0
  37. package/src/internal/compiling/jsenvCompilerForHtml.js +43 -44
  38. package/src/internal/compiling/jsenvCompilerForImportmap.js +15 -76
  39. package/src/internal/compiling/jsenvCompilerForJavaScript.js +9 -0
  40. package/src/internal/compiling/startCompileServer.js +29 -5
  41. package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +9 -9
  42. package/src/internal/executing/executePlan.js +6 -0
  43. package/src/internal/generateGroupMap/{jsenvBabelPluginCompatMap.js → babel_plugins_compatibility.js} +0 -0
  44. package/src/internal/generateGroupMap/{featuresCompatMap.js → features_compatibility.js} +9 -1
  45. package/src/internal/generateGroupMap/generateGroupMap.js +6 -35
  46. package/src/internal/generateGroupMap/one_runtime_compat.js +9 -12
  47. package/src/internal/generateGroupMap/runtime_compat.js +10 -15
  48. package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -2
  49. package/src/internal/generateGroupMap/shake_babel_plugin_map.js +21 -0
  50. package/src/internal/import-resolution/importmap_default.js +52 -0
  51. package/src/internal/node_feature_detection/node_feature_detection.js +25 -19
  52. package/src/internal/runtime/s.js +101 -6
  53. package/src/internal/unevalException.js +1 -1
  54. package/src/jsenvServiceWorkerFinalizer.js +3 -1
  55. package/dist/browser_runtime/browser_runtime_a8097085.js.map +0 -1067
  56. package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -1
  57. package/src/internal/import-resolution/importmap-default.js +0 -34
@@ -1,4 +1,4 @@
1
1
  {
2
- "browser_runtime.js": "browser_runtime_a8097085.js",
3
- "browser_runtime.js.map": "browser_runtime_a8097085.js.map"
2
+ "browser_runtime.js": "browser_runtime_91c5a3b8.js",
3
+ "browser_runtime.js.map": "browser_runtime_91c5a3b8.js.map"
4
4
  }
@@ -1,6 +1,16 @@
1
1
  (function () {
2
2
  'use strict';
3
3
 
4
+ var nativeTypeOf = function nativeTypeOf(obj) {
5
+ return typeof obj;
6
+ };
7
+
8
+ var customTypeOf = function customTypeOf(obj) {
9
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
10
+ };
11
+
12
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? nativeTypeOf : customTypeOf;
13
+
4
14
  var _defineProperty = (function (obj, key, value) {
5
15
  // Shortcircuit the slow defineProperty path when possible.
6
16
  // We are trying to avoid issues where setters defined on the
@@ -118,16 +128,6 @@
118
128
  return "".concat(name, ": ").concat(message).concat(stackString);
119
129
  };
120
130
 
121
- var nativeTypeOf = function nativeTypeOf(obj) {
122
- return typeof obj;
123
- };
124
-
125
- var customTypeOf = function customTypeOf(obj) {
126
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
127
- };
128
-
129
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? nativeTypeOf : customTypeOf;
130
-
131
131
  /* eslint-env browser, node */
132
132
  var parseDataUrl = function parseDataUrl(dataUrl) {
133
133
  var afterDataProtocol = dataUrl.slice("data:".length);
@@ -2500,7 +2500,7 @@
2500
2500
  };
2501
2501
 
2502
2502
  var unevalException = function unevalException(value) {
2503
- if (value.hasOwnProperty("toString")) {
2503
+ if (value && value.hasOwnProperty("toString")) {
2504
2504
  delete value.toString;
2505
2505
  }
2506
2506
 
@@ -2576,6 +2576,8 @@
2576
2576
  }
2577
2577
  } else if (typeof error === "string") {
2578
2578
  html = error;
2579
+ } else if (error === undefined) {
2580
+ html = "undefined";
2579
2581
  } else {
2580
2582
  html = JSON.stringify(error);
2581
2583
  }
@@ -2721,7 +2723,7 @@
2721
2723
  if (Notification.permission === "granted") {
2722
2724
  var notification = new Notification("An error occured", {
2723
2725
  lang: "en",
2724
- body: error.stack,
2726
+ body: error ? error.stack : "undefined",
2725
2727
  icon: icon
2726
2728
  });
2727
2729
 
@@ -4029,7 +4031,9 @@
4029
4031
  scopes: {},
4030
4032
  depcache: {},
4031
4033
  integrity: {}
4032
- }; // Scripts are processed immediately, on the first System.import, and on DOMReady.
4034
+ };
4035
+ systemJSPrototype.importMap = importMap;
4036
+ systemJSPrototype.baseUrl = baseUrl; // Scripts are processed immediately, on the first System.import, and on DOMReady.
4033
4037
  // Import map scripts are processed only once (by being marked) and in order for each phase.
4034
4038
  // This is to avoid using DOM mutation observers in core, although that would be an alternative.
4035
4039
 
@@ -4089,6 +4093,7 @@
4089
4093
  return fetchPromise;
4090
4094
  }).then(function (text) {
4091
4095
  extendImportMap(importMap, text, script.src || baseUrl);
4096
+ return importMap;
4092
4097
  });
4093
4098
  }
4094
4099
  });
@@ -4105,11 +4110,12 @@
4105
4110
 
4106
4111
  resolveAndComposeImportMap(newMap, newMapUrl, importMap);
4107
4112
  }
4113
+
4114
+ System.extendImportMap = extendImportMap;
4108
4115
  /*
4109
4116
  * Script instantiation loading
4110
4117
  */
4111
4118
 
4112
-
4113
4119
  if (hasDocument) {
4114
4120
  window.addEventListener('error', function (evt) {
4115
4121
  lastWindowErrorUrl = evt.filename;
@@ -4258,20 +4264,32 @@
4258
4264
  */
4259
4265
 
4260
4266
 
4261
- if (hasSelf && typeof importScripts === 'function') systemJSPrototype.instantiate = function (url) {
4262
- var loader = this;
4263
- return Promise.resolve().then(function () {
4264
- importScripts(url);
4265
- return loader.getRegister(url);
4266
- });
4267
- };
4267
+ if (hasSelf && typeof importScripts === 'function') {
4268
+ systemJSPrototype.instantiate = function (url) {
4269
+ var loader = this;
4270
+ return self.fetch(url, {
4271
+ credentials: 'same-origin'
4272
+ }).then(function (response) {
4273
+ if (!response.ok) {
4274
+ throw Error(errMsg(7, [response.status, response.statusText, url].join(', ')));
4275
+ }
4276
+
4277
+ return response.text();
4278
+ }).then(function (source) {
4279
+ if (source.indexOf('//# sourceURL=') < 0) source += '\n//# sourceURL=' + url;
4280
+ (0, eval)(source);
4281
+ return loader.getRegister(url);
4282
+ });
4283
+ };
4284
+ }
4268
4285
  })();
4269
4286
 
4270
4287
  (function () {
4271
4288
  var envGlobal = typeof self !== 'undefined' ? self : global;
4272
4289
  var System = envGlobal.System;
4273
- var register = System.register;
4274
4290
  var registerRegistry = Object.create(null);
4291
+ var register = System.register;
4292
+ System.registerRegistry = registerRegistry;
4275
4293
 
4276
4294
  System.register = function (name, deps, declare) {
4277
4295
  if (typeof name !== 'string') return register.apply(this, arguments);
@@ -4306,6 +4324,99 @@
4306
4324
  };
4307
4325
  })();
4308
4326
 
4327
+ (function () {
4328
+ // worker or service worker
4329
+ if (typeof WorkerGlobalScope === 'function' && self instanceof WorkerGlobalScope) {
4330
+ var importMapFromParentPromise = new Promise(function (resolve) {
4331
+ var importmapMessageCallback = function importmapMessageCallback(e) {
4332
+ if (e.data === "__importmap_init__") {
4333
+ self.removeEventListener("message", importmapMessageCallback);
4334
+
4335
+ e.ports[0].onmessage = function (message) {
4336
+ resolve(message.data);
4337
+ };
4338
+
4339
+ e.ports[0].postMessage('__importmap_request__');
4340
+ }
4341
+ };
4342
+
4343
+ self.addEventListener("message", importmapMessageCallback);
4344
+ }); // var prepareImport = System.prepareImport
4345
+
4346
+ System.prepareImport = function () {
4347
+ return importMapFromParentPromise.then(function (importmap) {
4348
+ System.extendImportMap(System.importMap, JSON.stringify(importmap), System.baseUrl);
4349
+ });
4350
+ }; // auto import first register
4351
+
4352
+
4353
+ var messageEvents = [];
4354
+
4355
+ var messageCallback = function messageCallback(event) {
4356
+ messageEvents.push(event);
4357
+ };
4358
+
4359
+ self.addEventListener('message', messageCallback);
4360
+ var register = System.register;
4361
+
4362
+ System.register = function (deps, declare) {
4363
+ System.register = register;
4364
+ System.registerRegistry[self.location.href] = [deps, declare];
4365
+ System.import(self.location.href).then(function () {
4366
+ self.removeEventListener('message', messageCallback);
4367
+ messageEvents.forEach(function (messageEvent) {
4368
+ self.dispatchEvent(messageEvent);
4369
+ });
4370
+ messageEvents = null;
4371
+ });
4372
+ };
4373
+ } else if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
4374
+ var WorkerConstructor = window.Worker;
4375
+
4376
+ if (typeof WorkerConstructor === 'function') {
4377
+ window.Worker = function (url, options) {
4378
+ var worker = new WorkerConstructor(url, options);
4379
+ var importmapChannel = new MessageChannel();
4380
+
4381
+ importmapChannel.port1.onmessage = function (message) {
4382
+ System.prepareImport().then(function (importmap) {
4383
+ message.target.postMessage(importmap);
4384
+ });
4385
+ };
4386
+
4387
+ worker.postMessage('__importmap_init__', [importmapChannel.port2]);
4388
+ return worker;
4389
+ };
4390
+ }
4391
+
4392
+ var serviceWorker = navigator.serviceWorker;
4393
+
4394
+ if (serviceWorker) {
4395
+ var register = serviceWorker.register;
4396
+
4397
+ serviceWorker.register = function (url, options) {
4398
+ var registrationPromise = register.call(this, url, options);
4399
+ registrationPromise.then(function (registration) {
4400
+ var installing = registration.installing;
4401
+ var waiting = registration.waiting;
4402
+ var active = registration.active;
4403
+ var worker = installing || waiting || active;
4404
+ var importmapChannel = new MessageChannel();
4405
+
4406
+ importmapChannel.port1.onmessage = function (message) {
4407
+ System.prepareImport().then(function (importmap) {
4408
+ message.target.postMessage(importmap);
4409
+ });
4410
+ };
4411
+
4412
+ worker.postMessage('__importmap_init__', [importmapChannel.port2]);
4413
+ });
4414
+ return registrationPromise;
4415
+ };
4416
+ }
4417
+ }
4418
+ })();
4419
+
4309
4420
  /* eslint-env browser */
4310
4421
 
4311
4422
  function _await$2(value, then, direct) {
@@ -4763,7 +4874,7 @@
4763
4874
  var compileDirectoryRelativeUrl = "".concat(outDirectoryRelativeUrl).concat(compileId, "/"); // if there is an importmap in the document we use it instead of fetching.
4764
4875
  // systemjs style with systemjs-importmap
4765
4876
 
4766
- var importmapScript = document.querySelector("script[type=\"jsenv-importmap\"]");
4877
+ var importmapScript = document.querySelector("script[type=\"systemjs-importmap\"]");
4767
4878
  var importMap;
4768
4879
  var importMapUrl;
4769
4880
  return _invoke$1(function () {
@@ -5076,12 +5187,12 @@
5076
5187
  errorExposureInDocument = _ref$errorExposureInD === void 0 ? true : _ref$errorExposureInD;
5077
5188
  var error = executionResult.error;
5078
5189
 
5079
- if (error.code === "NETWORK_FAILURE") {
5190
+ if (error && error.code === "NETWORK_FAILURE") {
5080
5191
  if (currentScript) {
5081
5192
  var errorEvent = new Event("error");
5082
5193
  currentScript.dispatchEvent(errorEvent);
5083
5194
  }
5084
- } else {
5195
+ } else if (_typeof(error) === "object") {
5085
5196
  var parsingError = error.parsingError;
5086
5197
  var globalErrorEvent = new Event("error");
5087
5198
 
@@ -5185,4 +5296,4 @@
5185
5296
 
5186
5297
  })();
5187
5298
 
5188
- //# sourceMappingURL=browser_runtime_a8097085.js.map
5299
+ //# sourceMappingURL=browser_runtime_91c5a3b8.js.map