@jsenv/core 24.3.3 → 24.4.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.
Files changed (39) hide show
  1. package/dist/browser_runtime/asset-manifest.json +3 -0
  2. package/dist/browser_runtime/{browser_runtime-fbd309a1.js → browser_runtime-75fe4f45.js} +41 -2
  3. package/dist/browser_runtime/{browser_runtime-fbd309a1.js.map → browser_runtime-75fe4f45.js.map} +6 -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-6192a06c.map} +8 -4
  7. package/dist/compile_proxy/{compile_proxy-405777e6.html → compile_proxy-58947390.html} +46 -5
  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-6192a06c.map} +8 -4
  12. package/dist/redirector/{redirector-237cd168.html → redirector-3c40c078.html} +46 -5
  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-6192a06c.map} +8 -4
  16. package/dist/toolbar/{toolbar-29e91dcd.html → toolbar-37d80823.html} +41 -2
  17. package/dist/toolbar_injector/asset-manifest.json +4 -0
  18. package/dist/toolbar_injector/{toolbar_injector-0af91b43.js → toolbar_injector-b162830d.js} +2 -2
  19. package/dist/toolbar_injector/{toolbar_injector-0af91b43.js.map → toolbar_injector-b162830d.js.map} +2 -2
  20. package/package.json +11 -18
  21. package/src/executeTestPlan.js +7 -1
  22. package/src/internal/browser_launcher/from_playwright.js +314 -0
  23. package/src/internal/building/buildUsingRollup.js +2 -2
  24. package/src/internal/building/createJsenvRollupPlugin.js +67 -41
  25. package/src/internal/building/css/parseCssRessource.js +4 -1
  26. package/src/internal/building/html/parseHtmlRessource.js +16 -3
  27. package/src/internal/building/js/parseJsRessource.js +2 -0
  28. package/src/internal/building/ressource_builder.js +27 -37
  29. package/src/internal/building/ressource_builder_util.js +10 -137
  30. package/src/internal/building/svg/parseSvgRessource.js +2 -0
  31. package/src/internal/building/url_loader.js +3 -1
  32. package/src/internal/building/webmanifest/parseWebmanifestRessource.js +2 -1
  33. package/src/internal/executing/executeConcurrently.js +15 -9
  34. package/src/internal/executing/executePlan.js +2 -0
  35. package/src/internal/runtime/s.js +39 -1
  36. package/src/launchBrowser.js +33 -501
  37. package/dist/browser_system/browser_system-29eda202.js +0 -5160
  38. package/dist/browser_system/browser_system-29eda202.js.map +0 -1065
  39. package/src/internal/browser_launcher/createSharing.js +0 -70
@@ -18,6 +18,7 @@ export const parseJsRessource = async (
18
18
 
19
19
  if (jsSourcemapUrl) {
20
20
  sourcemapReference = notifyReferenceFound({
21
+ referenceLabel: "js sourcemapping comment",
21
22
  contentTypeExpected: ["application/json", "application/octet-stream"],
22
23
  ressourceSpecifier: jsSourcemapUrl,
23
24
  // we don't really know the line or column
@@ -29,6 +30,7 @@ export const parseJsRessource = async (
29
30
  })
30
31
  } else {
31
32
  sourcemapReference = notifyReferenceFound({
33
+ referenceLabel: "js sourcemapping comment",
32
34
  contentType: "application/octet-stream",
33
35
  ressourceSpecifier: `${urlToFilename(jsUrl)}.map`,
34
36
  isPlaceholder: true,
@@ -3,7 +3,6 @@ import {
3
3
  urlToRelativeUrl,
4
4
  urlIsInsideOf,
5
5
  urlToParentUrl,
6
- urlToBasename,
7
6
  urlToFilename,
8
7
  } from "@jsenv/filesystem"
9
8
  import { createLogger } from "@jsenv/logger"
@@ -34,10 +33,9 @@ export const createRessourceBuilder = (
34
33
  asOriginalServerUrl,
35
34
  urlToHumanUrl,
36
35
 
37
- emitChunk,
38
36
  emitAsset,
39
37
  setAssetSource,
40
- onJsModuleReference = () => {},
38
+ onJsModule,
41
39
  resolveRessourceUrl,
42
40
  lineBreakNormalization,
43
41
  },
@@ -122,6 +120,7 @@ export const createRessourceBuilder = (
122
120
  }
123
121
 
124
122
  const createReferenceFoundInJsModule = async ({
123
+ referenceLabel,
125
124
  jsUrl,
126
125
  jsLine,
127
126
  jsColumn,
@@ -136,6 +135,7 @@ export const createRessourceBuilder = (
136
135
  isImportAssertion,
137
136
  ressourceSpecifier,
138
137
  contentTypeExpected,
138
+ referenceLabel,
139
139
  referenceUrl: jsUrl,
140
140
  referenceLine: jsLine,
141
141
  referenceColumn: jsColumn,
@@ -168,6 +168,7 @@ export const createRessourceBuilder = (
168
168
  isImportAssertion,
169
169
  contentTypeExpected,
170
170
  ressourceSpecifier,
171
+ referenceLabel,
171
172
  referenceUrl,
172
173
  referenceColumn,
173
174
  referenceLine,
@@ -302,6 +303,7 @@ export const createRessourceBuilder = (
302
303
  isRessourceHint,
303
304
  isImportAssertion,
304
305
  contentTypeExpected,
306
+ referenceLabel,
305
307
  referenceUrl,
306
308
  referenceColumn,
307
309
  referenceLine,
@@ -321,12 +323,21 @@ export const createRessourceBuilder = (
321
323
 
322
324
  reference.ressource = ressource
323
325
  if (fromRollup && ressourceImporter.isEntryPoint) {
324
- // do not add that reference, it's already know and would duplicate the html referencing a js file
325
- // but do apply its effects
326
- ressource.applyReferenceEffects(reference, { isJsModule })
326
+ // When HTML references JS, ressource builder has emitted the js chunk.
327
+ // so it already knows it exists and is part of references
328
+ // -> no need to push into reference (would incorrectly consider html references js twice)
329
+ // -> no need to log the js ressource (already logged during the HTML parsing)
327
330
  } else {
328
331
  ressource.references.push(reference)
329
- ressource.applyReferenceEffects(reference, { isJsModule })
332
+ const effects = ressource.applyReferenceEffects(reference, { isJsModule })
333
+ logger.debug(
334
+ formatFoundReference({
335
+ reference,
336
+ referenceEffects: effects,
337
+ showReferenceSourceLocation,
338
+ shortenUrl,
339
+ }),
340
+ )
330
341
  }
331
342
 
332
343
  return reference
@@ -452,6 +463,7 @@ export const createRessourceBuilder = (
452
463
  isRessourceHint,
453
464
  contentTypeExpected,
454
465
  ressourceSpecifier,
466
+ referenceLabel,
455
467
  referenceLine,
456
468
  referenceColumn,
457
469
 
@@ -472,6 +484,7 @@ export const createRessourceBuilder = (
472
484
 
473
485
  const dependencyReference = createReference({
474
486
  ressourceSpecifier,
487
+ referenceLabel,
475
488
  referenceUrl: ressource.url,
476
489
  referenceLine,
477
490
  referenceColumn,
@@ -648,18 +661,12 @@ export const createRessourceBuilder = (
648
661
  }
649
662
  }
650
663
 
651
- const onReference = (reference, infoFromReference) => {
664
+ const applyReferenceEffects = (reference, infoFromReference) => {
652
665
  const effects = []
653
666
  if (ressource.isEntryPoint) {
654
667
  if (ressource.contentType === "text/html") {
655
668
  effects.push(`parse html to find references`)
656
669
  }
657
- } else {
658
- effects.push(
659
- `mark ${urlToHumanUrl(
660
- ressource.url,
661
- )} as referenced by ${urlToHumanUrl(reference.referenceUrl)}`,
662
- )
663
670
  }
664
671
 
665
672
  if (reference.isRessourceHint) {
@@ -708,22 +715,18 @@ export const createRessourceBuilder = (
708
715
  }
709
716
 
710
717
  const jsModuleUrl = ressource.url
711
-
712
- onJsModuleReference({
718
+ const rollupChunk = onJsModule({
719
+ ressource,
713
720
  jsModuleUrl,
714
721
  jsModuleIsInline: ressource.isInline,
715
722
  jsModuleSource: String(bufferBeforeBuild),
716
723
  line: reference.referenceLine,
717
724
  column: reference.referenceColumn,
718
725
  })
719
-
720
- const name = urlToBasename(jsModuleUrl)
721
- const rollupReferenceId = emitChunk({
722
- id: jsModuleUrl,
723
- name,
724
- })
725
- ressource.rollupReferenceId = rollupReferenceId
726
- effects.push(`emit rollup chunk "${name}" (${rollupReferenceId})`)
726
+ ressource.rollupReferenceId = rollupChunk.rollupReferenceId
727
+ effects.push(
728
+ `emit rollup chunk "${rollupChunk.name}" (${rollupChunk.rollupReferenceId})`,
729
+ )
727
730
  return effects
728
731
  }
729
732
 
@@ -739,22 +742,9 @@ export const createRessourceBuilder = (
739
742
  effects.push(
740
743
  `emit rollup asset "${ressource.relativeUrl}" (${rollupReferenceId})`,
741
744
  )
742
-
743
745
  return effects
744
746
  }
745
747
 
746
- const applyReferenceEffects = (reference, infoFromReference) => {
747
- const referenceEffects = onReference(reference, infoFromReference)
748
-
749
- logger.debug(
750
- formatFoundReference({
751
- reference,
752
- referenceEffects,
753
- showReferenceSourceLocation,
754
- }),
755
- )
756
- }
757
-
758
748
  Object.assign(ressource, {
759
749
  applyReferenceEffects,
760
750
  getBufferAvailablePromise,
@@ -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
@@ -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,
@@ -599,7 +599,7 @@
599
599
  var autoImportCandidates = {};
600
600
  var systemRegister = systemJSPrototype.register;
601
601
  var inlineScriptCount = 0;
602
- systemJSPrototype.register = function (deps, declare) {
602
+ systemJSPrototype.register = function (deps, declare, autoUrl) {
603
603
  if (hasDocument && document.readyState === 'loading' && typeof deps !== 'string') {
604
604
  var scripts = document.querySelectorAll('script[src]');
605
605
  var lastScript = scripts[scripts.length - 1];
@@ -608,6 +608,9 @@
608
608
  if (lastScript) {
609
609
  lastAutoImportUrl = lastScript.src;
610
610
  }
611
+ else if (autoUrl) {
612
+ lastAutoImportUrl = autoUrl
613
+ }
611
614
  else {
612
615
  inlineScriptCount++
613
616
  lastAutoImportUrl = document.location.href + "__inline_script__" + inlineScriptCount;
@@ -725,4 +728,39 @@
725
728
  });
726
729
  };
727
730
 
731
+ }());
732
+
733
+ (function(){
734
+ var envGlobal = typeof self !== 'undefined' ? self : global;
735
+ var System = envGlobal.System;
736
+ var register = System.register;
737
+ var registerRegistry = Object.create(null)
738
+
739
+ System.register = function (name, deps, declare) {
740
+ if (typeof name !== 'string') return register.apply(this, arguments);
741
+ var define = [deps, declare];
742
+ var url = System.resolve(`./${name}`);
743
+ registerRegistry[url] = define;
744
+ return register.call(this, deps, declare, url);
745
+ };
746
+
747
+ var instantiate = System.instantiate;
748
+ System.instantiate = function (url, firstParentUrl) {
749
+ var result = registerRegistry[url];
750
+
751
+ if (result) {
752
+ registerRegistry[url] = null;
753
+ return result;
754
+ } else {
755
+ return instantiate.call(this, url, firstParentUrl);
756
+ }
757
+ };
758
+
759
+ var getRegister = System.getRegister;
760
+ System.getRegister = function (url) {
761
+ // Calling getRegister() because other extras need to know it was called so they can perform side effects
762
+ var register = getRegister.call(this, url);
763
+ var result = registerRegistry[url] || register;
764
+ return result;
765
+ };
728
766
  }());