@jsenv/core 24.3.2 → 24.4.3

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 (42) hide show
  1. package/dist/browser_runtime/asset-manifest.json +3 -0
  2. package/dist/browser_runtime/{browser_runtime-fbd309a1.js → browser_runtime-015d0fc5.js} +94 -1
  3. package/dist/browser_runtime/{browser_runtime-fbd309a1.js.map → browser_runtime-015d0fc5.js.map} +11 -3
  4. package/dist/build_manifest.js +5 -5
  5. package/dist/compile_proxy/asset-manifest.json +4 -0
  6. package/dist/compile_proxy/assets/{s.js-749702e8.map → s.js-55849eca.map} +14 -4
  7. package/dist/compile_proxy/{compile_proxy-405777e6.html → compile_proxy-2eabd1f7.html} +99 -4
  8. package/dist/compile_proxy/{compile_proxy.html__inline__20-39c0801c.js.map → compile_proxy.html__inline__20-672ba17c.js.map} +0 -0
  9. package/dist/event_source_client/asset-manifest.json +3 -0
  10. package/dist/redirector/asset-manifest.json +4 -0
  11. package/dist/{toolbar/assets/s.js-749702e8.map → redirector/assets/s.js-55849eca.map} +14 -4
  12. package/dist/redirector/{redirector-237cd168.html → redirector-3029c4d3.html} +99 -4
  13. package/dist/redirector/{redirector.html__inline__15-33acb0b9.js.map → redirector.html__inline__15-4d453af0.js.map} +0 -0
  14. package/dist/toolbar/asset-manifest.json +13 -0
  15. package/dist/{redirector/assets/s.js-749702e8.map → toolbar/assets/s.js-55849eca.map} +14 -4
  16. package/dist/toolbar/{toolbar-d3d98c2e.html → toolbar-40bcd3a0.html} +104 -10
  17. package/dist/toolbar/{toolbar.main-cab36c15.js.map → toolbar.main-53e1ab2b.js.map} +2 -2
  18. package/dist/toolbar_injector/asset-manifest.json +4 -0
  19. package/dist/toolbar_injector/{toolbar_injector-01f71ce3.js → toolbar_injector-0a9d5d4c.js} +5 -3
  20. package/dist/toolbar_injector/{toolbar_injector-01f71ce3.js.map → toolbar_injector-0a9d5d4c.js.map} +3 -3
  21. package/package.json +10 -18
  22. package/src/executeTestPlan.js +7 -1
  23. package/src/internal/browser_launcher/from_playwright.js +314 -0
  24. package/src/internal/building/buildUsingRollup.js +2 -2
  25. package/src/internal/building/createJsenvRollupPlugin.js +67 -41
  26. package/src/internal/building/css/parseCssRessource.js +4 -1
  27. package/src/internal/building/html/parseHtmlRessource.js +16 -3
  28. package/src/internal/building/js/parseJsRessource.js +2 -0
  29. package/src/internal/building/ressource_builder.js +27 -37
  30. package/src/internal/building/ressource_builder_util.js +10 -137
  31. package/src/internal/building/svg/parseSvgRessource.js +2 -0
  32. package/src/internal/building/url_loader.js +3 -1
  33. package/src/internal/building/webmanifest/parseWebmanifestRessource.js +2 -1
  34. package/src/internal/dev_server/toolbar/toolbar.injector.js +3 -1
  35. package/src/internal/dev_server/toolbar/toolbar.main.js +7 -6
  36. package/src/internal/executing/executeConcurrently.js +15 -9
  37. package/src/internal/executing/executePlan.js +2 -0
  38. package/src/internal/runtime/s.js +83 -1
  39. package/src/launchBrowser.js +33 -501
  40. package/dist/browser_system/browser_system-29eda202.js +0 -5160
  41. package/dist/browser_system/browser_system-29eda202.js.map +0 -1065
  42. package/src/internal/browser_launcher/createSharing.js +0 -70
@@ -120,156 +120,29 @@ export const formatFoundReference = ({
120
120
  reference,
121
121
  showReferenceSourceLocation,
122
122
  referenceEffects,
123
+ shortenUrl,
123
124
  }) => {
124
- const { isRessourceHint } = reference
125
- if (isRessourceHint) {
126
- return formatFoundRessourceHint({
127
- reference,
128
- showReferenceSourceLocation,
129
- referenceEffects,
130
- })
131
- }
132
-
133
125
  const { ressource } = reference
134
126
  const { isEntryPoint } = ressource
135
127
  if (isEntryPoint) {
136
- return formatCreateReferenceForEntry({
137
- reference,
138
- showReferenceSourceLocation,
139
- referenceEffects,
140
- })
141
- }
142
-
143
- const { isExternal } = ressource
144
- if (isExternal) {
145
- return formatFoundReferenceToExternalRessource({
146
- reference,
147
- showReferenceSourceLocation,
128
+ return `
129
+ Start from entry file ${reference.ressource.relativeUrl}${appendEffects(
148
130
  referenceEffects,
149
- })
131
+ )}`
150
132
  }
151
133
 
152
134
  const { isPlaceholder } = ressource
153
135
  if (isPlaceholder) {
154
- return formatCreateRessourcePlaceholder({
155
- reference,
156
- showReferenceSourceLocation,
157
- referenceEffects,
158
- })
159
- }
160
-
161
- const { isInline, isJsModule } = ressource
162
- if (isInline && !isJsModule) {
163
- return formatFoundReferenceToInlineRessource({
164
- reference,
165
- showReferenceSourceLocation,
136
+ return `
137
+ Create placeholder for ${showReferenceSourceLocation(reference)}${appendEffects(
166
138
  referenceEffects,
167
- })
139
+ )}`
168
140
  }
169
141
 
170
- if (isInline && isJsModule) {
171
- return formatFoundReferenceToInlineModule({
172
- reference,
173
- showReferenceSourceLocation,
174
- referenceEffects,
175
- })
176
- }
177
-
178
- if (!isJsModule) {
179
- return formatFoundReferenceToRessource({
180
- reference,
181
- showReferenceSourceLocation,
182
- referenceEffects,
183
- })
184
- }
185
-
186
- return formatFoundReferenceToModule({
187
- reference,
188
- showReferenceSourceLocation,
189
- referenceEffects,
190
- })
191
- }
192
-
193
- const formatCreateReferenceForEntry = ({ reference, referenceEffects }) => {
194
- return `
195
- Start from entry file ${reference.ressource.relativeUrl}${appendEffects(
196
- referenceEffects,
197
- )}`
198
- }
199
-
200
- const formatFoundRessourceHint = ({
201
- reference,
202
- showReferenceSourceLocation,
203
- referenceEffects,
204
- }) => {
205
- return `
206
- Found ressource hint in ${showReferenceSourceLocation(
207
- reference,
208
- )}${appendEffects(referenceEffects)}`
209
- }
210
-
211
- const formatFoundReferenceToExternalRessource = ({
212
- reference,
213
- showReferenceSourceLocation,
214
- referenceEffects,
215
- }) => {
216
- return `
217
- Found external url in ${showReferenceSourceLocation(reference)}${appendEffects(
218
- referenceEffects,
219
- )}`
220
- }
221
-
222
- const formatCreateRessourcePlaceholder = ({
223
- reference,
224
- showReferenceSourceLocation,
225
- referenceEffects,
226
- }) => {
227
- return `
228
- Create placeholder for ressource in ${showReferenceSourceLocation(
229
- reference,
230
- )}${appendEffects(referenceEffects)}`
231
- }
232
-
233
- const formatFoundReferenceToInlineRessource = ({
234
- reference,
235
- showReferenceSourceLocation,
236
- referenceEffects,
237
- }) => {
238
- return `
239
- Found inline ressource in ${showReferenceSourceLocation(
240
- reference,
241
- )}${appendEffects(referenceEffects)}`
242
- }
243
-
244
- const formatFoundReferenceToInlineModule = ({
245
- reference,
246
- showReferenceSourceLocation,
247
- referenceEffects,
248
- }) => {
249
- return `
250
- Found inline module in ${showReferenceSourceLocation(reference)}${appendEffects(
251
- referenceEffects,
252
- )}`
253
- }
254
-
255
- const formatFoundReferenceToRessource = ({
256
- reference,
257
- showReferenceSourceLocation,
258
- referenceEffects,
259
- }) => {
260
- return `
261
- Found ressource in ${showReferenceSourceLocation(reference)}${appendEffects(
262
- referenceEffects,
263
- )}`
264
- }
265
-
266
- const formatFoundReferenceToModule = ({
267
- reference,
268
- showReferenceSourceLocation,
269
- referenceEffects,
270
- }) => {
142
+ const { referenceLabel = "unlabelled reference" } = reference
271
143
  return `
272
- Found module script in ${showReferenceSourceLocation(reference)}${appendEffects(
144
+ Found "${referenceLabel}" referencing "${shortenUrl(reference.ressource.url)}"
145
+ in ${showReferenceSourceLocation(reference)}${appendEffects(
273
146
  referenceEffects,
274
147
  )}`
275
148
  }
@@ -60,6 +60,7 @@ const imageHrefVisitor = (image, { notifyReferenceFound }) => {
60
60
  }
61
61
 
62
62
  const hrefReference = notifyReferenceFound({
63
+ referenceLabel: "svg image href",
63
64
  ressourceSpecifier: hrefAttribute.value,
64
65
  ...referenceLocationFromHtmlNode(image, "href"),
65
66
  })
@@ -81,6 +82,7 @@ const useHrefVisitor = (use, { notifyReferenceFound }) => {
81
82
 
82
83
  const { hash } = new URL(href, "file://")
83
84
  const hrefReference = notifyReferenceFound({
85
+ referenceLabel: "svg use href",
84
86
  ressourceSpecifier: href,
85
87
  ...referenceLocationFromHtmlNode(use, "href"),
86
88
  })
@@ -30,6 +30,7 @@ export const createUrlLoader = ({
30
30
  const importer = urlImporterMap[url]
31
31
  const cssReference =
32
32
  await ressourceBuilder.createReferenceFoundInJsModule({
33
+ referenceLabel: "css import assertion",
33
34
  // If all references to a ressource are only import assertions
34
35
  // the file referenced do not need to be written on filesystem
35
36
  // as it was converted to a js file
@@ -84,6 +85,7 @@ export const createUrlLoader = ({
84
85
  const importer = urlImporterMap[url]
85
86
  const jsonReference =
86
87
  await ressourceBuilder.createReferenceFoundInJsModule({
88
+ referenceLabel: "json import assertion",
87
89
  // If all references to a ressource are only import assertions
88
90
  // the file referenced do not need to be written on filesystem
89
91
  // as it was converted to a js file
@@ -114,7 +116,7 @@ export const createUrlLoader = ({
114
116
 
115
117
  if (url in inlineModuleScripts) {
116
118
  const transformResult = await transformJs({
117
- code: inlineModuleScripts[url],
119
+ code: String(inlineModuleScripts[url].bufferBeforeBuild),
118
120
  url: asOriginalUrl(url), // transformJs expect a file:// url
119
121
  projectDirectoryUrl,
120
122
  babelPluginMap,
@@ -9,8 +9,9 @@ export const parseWebmanifestRessource = (
9
9
  const manifest = JSON.parse(manifestString)
10
10
  const { icons = [] } = manifest
11
11
 
12
- const iconReferences = icons.map((icon) => {
12
+ const iconReferences = icons.map((icon, index) => {
13
13
  const iconReference = notifyReferenceFound({
14
+ referenceLabel: `web manifest icon ${index}`,
14
15
  ressourceSpecifier: icon.src,
15
16
  })
16
17
  return iconReference
@@ -150,7 +150,9 @@ const injectToolbar = async () => {
150
150
  showToolbarTrigger()
151
151
  }
152
152
  })
153
- sendCommandToToolbar(iframe, "renderToolbar")
153
+ addToolbarEventCallback(iframe, "toolbar_ready", () => {
154
+ sendCommandToToolbar(iframe, "renderToolbar")
155
+ })
154
156
 
155
157
  return iframe
156
158
  }
@@ -223,6 +223,12 @@ const sendEventToParent = (name, data) => {
223
223
  )
224
224
  }
225
225
 
226
+ window.toolbar = {
227
+ render: renderToolbar,
228
+ show: showToolbar,
229
+ hide: () => hideToolbar(),
230
+ }
231
+
226
232
  addExternalCommandCallback("renderToolbar", () => {
227
233
  renderToolbar()
228
234
  })
@@ -232,9 +238,4 @@ addExternalCommandCallback("showToolbar", () => {
232
238
  addExternalCommandCallback("hideToolbar", () => {
233
239
  hideToolbar()
234
240
  })
235
-
236
- window.toolbar = {
237
- render: renderToolbar,
238
- show: showToolbar,
239
- hide: () => hideToolbar(),
240
- }
241
+ sendEventToParent("toolbar_ready")
@@ -11,7 +11,7 @@ import {
11
11
  normalizeStructuredMetaMap,
12
12
  urlToMeta,
13
13
  } from "@jsenv/filesystem"
14
- import { Abort } from "@jsenv/abort"
14
+ import { Abort, createCallbackListNotifiedOnce } from "@jsenv/abort"
15
15
 
16
16
  import { launchAndExecute } from "../executing/launchAndExecute.js"
17
17
  import { reportToCoverage } from "./coverage/reportToCoverage.js"
@@ -34,6 +34,7 @@ export const executeConcurrently = async (
34
34
  defaultMsAllocatedPerExecution = 30000,
35
35
  cooldownBetweenExecutions = 0,
36
36
  maxExecutionsInParallel = 1,
37
+ stopAfterExecute,
37
38
  completedExecutionLogMerging,
38
39
  completedExecutionLogAbbreviation,
39
40
 
@@ -132,11 +133,13 @@ export const executeConcurrently = async (
132
133
  }
133
134
  }
134
135
 
135
- let executionLog = createLog({ newLine: "around" })
136
+ let executionLog = createLog({ newLine: "" })
136
137
  let abortedCount = 0
137
138
  let timedoutCount = 0
138
139
  let erroredCount = 0
139
140
  let completedCount = 0
141
+ const stopAfterAllExecutionCallbackList = createCallbackListNotifiedOnce()
142
+
140
143
  const executionsDone = await executeInParallel({
141
144
  multipleExecutionsOperation,
142
145
  maxExecutionsInParallel,
@@ -153,12 +156,7 @@ export const executeConcurrently = async (
153
156
  measurePerformance: false,
154
157
  collectPerformance: false,
155
158
  captureConsole: true,
156
- // stopAfterExecute: true to ensure runtime is stopped once executed
157
- // because we have what we wants: execution is completed and
158
- // we have associated coverage and capturedConsole
159
- // passsing false means all node process and browsers launched stays opened
160
- // (can eventually be used for debug)
161
- stopAfterExecute: true,
159
+ stopAfterExecute,
162
160
  stopAfterExecuteReason: "execution-done",
163
161
  allocatedMs: defaultMsAllocatedPerExecution,
164
162
  ...paramsFromStep,
@@ -212,6 +210,7 @@ export const executeConcurrently = async (
212
210
  collectCoverage: coverage,
213
211
  coverageIgnorePredicate,
214
212
  coverageForceIstanbul,
213
+ stopAfterAllExecutionCallbackList,
215
214
  ...executionParams.runtimeParams,
216
215
  },
217
216
  executeParams: {
@@ -258,6 +257,9 @@ export const executeConcurrently = async (
258
257
  erroredCount,
259
258
  completedCount,
260
259
  })
260
+ log = `${log}
261
+
262
+ `
261
263
  const { columns = 80 } = process.stdout
262
264
  log = wrapAnsi(log, columns, {
263
265
  trim: false,
@@ -277,12 +279,16 @@ export const executeConcurrently = async (
277
279
  // nothing to do, we reuse the current executionLog object
278
280
  } else {
279
281
  executionLog.destroy()
280
- executionLog = createLog({ newLine: "around" })
282
+ executionLog = createLog({ newLine: "" })
281
283
  }
282
284
  }
283
285
  },
284
286
  })
285
287
 
288
+ if (stopAfterExecute) {
289
+ stopAfterAllExecutionCallbackList.notify()
290
+ }
291
+
286
292
  const summaryCounts = reportToSummary(report)
287
293
 
288
294
  const summary = {
@@ -26,6 +26,7 @@ export const executePlan = async (
26
26
 
27
27
  defaultMsAllocatedPerExecution,
28
28
  maxExecutionsInParallel,
29
+ stopAfterExecute,
29
30
  cooldownBetweenExecutions,
30
31
  completedExecutionLogMerging,
31
32
  completedExecutionLogAbbreviation,
@@ -156,6 +157,7 @@ export const executePlan = async (
156
157
 
157
158
  defaultMsAllocatedPerExecution,
158
159
  maxExecutionsInParallel,
160
+ stopAfterExecute,
159
161
  cooldownBetweenExecutions,
160
162
  completedExecutionLogMerging,
161
163
  completedExecutionLogAbbreviation,
@@ -725,4 +725,86 @@
725
725
  });
726
726
  };
727
727
 
728
- }());
728
+ }());
729
+
730
+ (function(){/*
731
+ * SystemJS named register extension
732
+ * Supports System.register('name', [..deps..], function (_export, _context) { ... })
733
+ *
734
+ * Names are written to the registry as-is
735
+ * System.register('x', ...) can be imported as System.import('x')
736
+ */
737
+ (function (global) {
738
+ var System = global.System;
739
+ setRegisterRegistry(System);
740
+ var systemJSPrototype = System.constructor.prototype;
741
+ var constructor = System.constructor;
742
+ var SystemJS = function () {
743
+ constructor.call(this);
744
+ setRegisterRegistry(this);
745
+ };
746
+ SystemJS.prototype = systemJSPrototype;
747
+ System.constructor = SystemJS;
748
+
749
+ var firstNamedDefine, firstName;
750
+
751
+ function setRegisterRegistry(systemInstance) {
752
+ systemInstance.registerRegistry = Object.create(null);
753
+ systemInstance.namedRegisterAliases = Object.create(null);
754
+ }
755
+
756
+ var register = systemJSPrototype.register;
757
+ systemJSPrototype.register = function (name, deps, declare) {
758
+ if (typeof name !== 'string')
759
+ return register.apply(this, arguments);
760
+ var define = [deps, declare];
761
+ this.registerRegistry[name] = define;
762
+ if (!firstNamedDefine) {
763
+ firstNamedDefine = define;
764
+ firstName = name;
765
+ }
766
+ Promise.resolve().then(function () {
767
+ firstNamedDefine = null;
768
+ firstName = null;
769
+ });
770
+ return register.apply(this, [deps, declare]);
771
+ };
772
+
773
+ var resolve = systemJSPrototype.resolve;
774
+ systemJSPrototype.resolve = function (id, parentURL) {
775
+ try {
776
+ // Prefer import map (or other existing) resolution over the registerRegistry
777
+ return resolve.call(this, id, parentURL);
778
+ } catch (err) {
779
+ if (id in this.registerRegistry) {
780
+ return this.namedRegisterAliases[id] || id;
781
+ }
782
+ throw err;
783
+ }
784
+ };
785
+
786
+ var instantiate = systemJSPrototype.instantiate;
787
+ systemJSPrototype.instantiate = function (url, firstParentUrl) {
788
+ var result = this.registerRegistry[url];
789
+ if (result) {
790
+ this.registerRegistry[url] = null;
791
+ return result;
792
+ } else {
793
+ return instantiate.call(this, url, firstParentUrl);
794
+ }
795
+ };
796
+
797
+ var getRegister = systemJSPrototype.getRegister;
798
+ systemJSPrototype.getRegister = function (url) {
799
+ // Calling getRegister() because other extras need to know it was called so they can perform side effects
800
+ var register = getRegister.call(this, url);
801
+
802
+ if (firstName && url) {
803
+ this.namedRegisterAliases[firstName] = url;
804
+ }
805
+ var result = firstNamedDefine || register;
806
+ firstNamedDefine = null;
807
+ firstName = null;
808
+ return result;
809
+ };
810
+ })(typeof self !== 'undefined' ? self : global);}());