@jsenv/core 25.1.1 → 25.2.0
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/browser_runtime_91c5a3b8.js.map +2 -2
- package/dist/build_manifest.js +4 -4
- package/dist/compile_proxy/asset-manifest.json +2 -2
- package/dist/compile_proxy/{compile_proxy_e3b0c442_809f35f7.js.map → compile_proxy.html__inline__20_809f35f7.js.map} +0 -0
- package/dist/compile_proxy/{compile_proxy_7ad5faa6.html → compile_proxy_8dfaee51.html} +3 -4
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/{redirector_e3b0c442_e391410e.js.map → redirector.html__inline__15_e391410e.js.map} +0 -0
- package/dist/redirector/{redirector_eb92e8a7.html → redirector_3e9a97b9.html} +3 -4
- package/dist/toolbar/asset-manifest.json +1 -1
- package/dist/toolbar/{toolbar_f7b8a263.html → toolbar_361afb84.html} +2 -3
- package/dist/toolbar_injector/asset-manifest.json +2 -2
- package/dist/toolbar_injector/{toolbar_injector_49e4756e.js → toolbar_injector_fac1e995.js} +2 -2
- package/dist/toolbar_injector/{toolbar_injector_49e4756e.js.map → toolbar_injector_fac1e995.js.map} +2 -2
- package/package.json +7 -7
- package/readme.md +43 -49
- package/src/buildProject.js +21 -13
- package/src/commonJsToJavaScriptModule.js +8 -7
- package/src/execute.js +2 -0
- package/src/executeTestPlan.js +4 -1
- package/src/internal/building/buildUsingRollup.js +4 -2
- package/src/internal/building/build_stats.js +3 -0
- package/src/internal/building/build_url_generator.js +153 -0
- package/src/internal/building/css/parseCssRessource.js +32 -26
- package/src/internal/building/html/parseHtmlRessource.js +92 -68
- package/src/internal/building/js/parseJsRessource.js +4 -7
- package/src/internal/building/parseRessource.js +3 -0
- package/src/internal/building/ressource_builder.js +64 -62
- package/src/internal/building/ressource_builder_util.js +17 -5
- package/src/internal/building/rollup_plugin_jsenv.js +259 -189
- package/src/internal/building/url_fetcher.js +16 -7
- package/src/internal/building/url_loader.js +1 -5
- package/src/internal/building/url_versioning.js +0 -173
- package/src/internal/compiling/babel_plugin_import_metadata.js +7 -11
- package/src/internal/compiling/babel_plugin_proxy_external_imports.js +31 -0
- package/src/internal/compiling/compile-directory/compile-asset.js +8 -4
- package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +43 -8
- package/src/internal/compiling/compile-directory/updateMeta.js +2 -8
- package/src/internal/compiling/compile-directory/validateCache.js +1 -2
- package/src/internal/compiling/compileFile.js +22 -10
- package/src/internal/compiling/createCompiledFileService.js +22 -24
- package/src/internal/compiling/html_source_file_service.js +9 -9
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +14 -4
- package/src/internal/compiling/js-compilation-service/transformJs.js +9 -5
- package/src/internal/compiling/jsenvCompilerForHtml.js +221 -182
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +15 -11
- package/src/internal/compiling/startCompileServer.js +79 -19
- package/src/internal/compiling/transformResultToCompilationResult.js +47 -25
- package/src/internal/executing/executePlan.js +2 -0
- package/src/internal/fetchUrl.js +3 -2
- package/src/internal/integrity/integrity_algorithms.js +26 -0
- package/src/internal/integrity/integrity_parsing.js +50 -0
- package/src/internal/integrity/integrity_update.js +23 -0
- package/src/internal/integrity/integrity_validation.js +49 -0
- package/src/internal/jsenv_remote_directory.js +156 -0
- package/src/internal/origin_directory_converter.js +62 -0
- package/src/internal/response_validation.js +11 -24
- package/src/internal/sourceMappingURLUtils.js +10 -0
- package/src/internal/url_conversion.js +1 -0
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
stringifySrcset,
|
|
33
33
|
getHtmlNodeLocation,
|
|
34
34
|
removeHtmlNode,
|
|
35
|
+
addHtmlNodeAttribute,
|
|
35
36
|
} from "@jsenv/core/src/internal/compiling/compileHtml.js"
|
|
36
37
|
import {
|
|
37
38
|
getJavaScriptSourceMappingUrl,
|
|
@@ -47,6 +48,7 @@ import { collectNodesMutations } from "../parsing.utils.js"
|
|
|
47
48
|
|
|
48
49
|
import { collectSvgMutations } from "../svg/parseSvgRessource.js"
|
|
49
50
|
import { moveCssUrls } from "../css/moveCssUrls.js"
|
|
51
|
+
import { applyAlgoToRepresentationData } from "../../integrity/integrity_algorithms.js"
|
|
50
52
|
|
|
51
53
|
export const parseHtmlRessource = async (
|
|
52
54
|
htmlRessource,
|
|
@@ -172,20 +174,21 @@ const regularScriptSrcVisitor = (
|
|
|
172
174
|
if (!srcAttribute) {
|
|
173
175
|
return null
|
|
174
176
|
}
|
|
175
|
-
|
|
177
|
+
const integrityAttribute = getHtmlNodeAttributeByName(script, "integrity")
|
|
178
|
+
const integrity = integrityAttribute ? integrityAttribute.value : ""
|
|
176
179
|
const remoteScriptReference = notifyReferenceFound({
|
|
177
180
|
referenceLabel: "html script",
|
|
178
181
|
contentTypeExpected: "application/javascript",
|
|
179
182
|
ressourceSpecifier: srcAttribute.value,
|
|
183
|
+
integrity,
|
|
184
|
+
...crossoriginFromHtmlNode(script),
|
|
180
185
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
181
186
|
})
|
|
182
187
|
return ({ getUrlRelativeToImporter }) => {
|
|
183
188
|
const ressource = remoteScriptReference.ressource
|
|
184
|
-
|
|
185
189
|
if (ressource.isExternal) {
|
|
186
190
|
return
|
|
187
191
|
}
|
|
188
|
-
|
|
189
192
|
if (shouldInline({ ressource, htmlNode: script })) {
|
|
190
193
|
removeHtmlNodeAttribute(script, srcAttribute)
|
|
191
194
|
const { bufferAfterBuild } = ressource
|
|
@@ -200,14 +203,19 @@ const regularScriptSrcVisitor = (
|
|
|
200
203
|
const sourcemapInlineUrl = urlToRelativeUrl(sourcemapBuildUrl, htmlUrl)
|
|
201
204
|
jsString = setJavaScriptSourceMappingUrl(jsString, sourcemapInlineUrl)
|
|
202
205
|
}
|
|
203
|
-
|
|
204
206
|
setHtmlNodeText(script, jsString)
|
|
205
207
|
remoteScriptReference.inlinedCallback()
|
|
206
208
|
return
|
|
207
209
|
}
|
|
208
|
-
|
|
209
210
|
const urlRelativeToImporter = getUrlRelativeToImporter(ressource)
|
|
210
211
|
srcAttribute.value = urlRelativeToImporter
|
|
212
|
+
if (integrityAttribute) {
|
|
213
|
+
const base64Value = applyAlgoToRepresentationData(
|
|
214
|
+
"sha256",
|
|
215
|
+
ressource.bufferAfterBuild,
|
|
216
|
+
)
|
|
217
|
+
integrityAttribute.value = `sha256-${base64Value}`
|
|
218
|
+
}
|
|
211
219
|
}
|
|
212
220
|
}
|
|
213
221
|
|
|
@@ -233,7 +241,6 @@ const regularScriptTextNodeVisitor = (
|
|
|
233
241
|
if (!textNode) {
|
|
234
242
|
return null
|
|
235
243
|
}
|
|
236
|
-
|
|
237
244
|
const scriptId = getIdForInlineHtmlNode(script, scripts)
|
|
238
245
|
const ressourceSpecifier = `${urlToFilename(
|
|
239
246
|
htmlRessource.url,
|
|
@@ -265,25 +272,25 @@ const moduleScriptSrcVisitor = (script, { format, notifyReferenceFound }) => {
|
|
|
265
272
|
if (!srcAttribute) {
|
|
266
273
|
return null
|
|
267
274
|
}
|
|
268
|
-
|
|
275
|
+
const integrityAttribute = getHtmlNodeAttributeByName(script, "integrity")
|
|
276
|
+
const integrity = integrityAttribute ? integrityAttribute.value : ""
|
|
269
277
|
const remoteScriptReference = notifyReferenceFound({
|
|
270
278
|
referenceLabel: "html module script",
|
|
271
279
|
contentTypeExpected: "application/javascript",
|
|
272
280
|
ressourceSpecifier: srcAttribute.value,
|
|
281
|
+
integrity,
|
|
282
|
+
...crossoriginFromHtmlNode(script),
|
|
273
283
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
274
284
|
isJsModule: true,
|
|
275
285
|
})
|
|
276
286
|
return ({ getUrlRelativeToImporter }) => {
|
|
277
287
|
const { ressource } = remoteScriptReference
|
|
278
|
-
|
|
279
288
|
if (format === "systemjs") {
|
|
280
289
|
removeHtmlNodeAttribute(script, typeAttribute)
|
|
281
290
|
}
|
|
282
|
-
|
|
283
291
|
if (ressource.isExternal) {
|
|
284
292
|
return
|
|
285
293
|
}
|
|
286
|
-
|
|
287
294
|
if (shouldInline({ ressource, htmlNode: script })) {
|
|
288
295
|
// here put a warning if we cannot inline importmap because it would mess
|
|
289
296
|
// the remapping (note that it's feasible) but not yet supported
|
|
@@ -298,15 +305,20 @@ const moduleScriptSrcVisitor = (script, { format, notifyReferenceFound }) => {
|
|
|
298
305
|
// with these assumptions we can force the sourcemap url
|
|
299
306
|
const sourcemapUrl = `${ressource.buildRelativeUrl}.map`
|
|
300
307
|
jsString = setJavaScriptSourceMappingUrl(jsString, sourcemapUrl)
|
|
301
|
-
|
|
302
308
|
setHtmlNodeText(script, jsString)
|
|
303
309
|
remoteScriptReference.inlinedCallback()
|
|
304
310
|
return
|
|
305
311
|
}
|
|
306
|
-
|
|
307
312
|
const urlRelativeToImporter = getUrlRelativeToImporter(ressource)
|
|
308
313
|
const relativeUrlNotation = ensureRelativeUrlNotation(urlRelativeToImporter)
|
|
309
314
|
srcAttribute.value = relativeUrlNotation
|
|
315
|
+
if (integrityAttribute) {
|
|
316
|
+
const base64Value = applyAlgoToRepresentationData(
|
|
317
|
+
"sha256",
|
|
318
|
+
ressource.bufferAfterBuild,
|
|
319
|
+
)
|
|
320
|
+
integrityAttribute.value = `sha256-${base64Value}`
|
|
321
|
+
}
|
|
310
322
|
}
|
|
311
323
|
}
|
|
312
324
|
|
|
@@ -331,7 +343,6 @@ const moduleScriptTextNodeVisitor = (
|
|
|
331
343
|
if (!textNode) {
|
|
332
344
|
return null
|
|
333
345
|
}
|
|
334
|
-
|
|
335
346
|
const scriptId = getIdForInlineHtmlNode(script, scripts)
|
|
336
347
|
const ressourceSpecifier = `${urlToFilename(
|
|
337
348
|
htmlRessource.url,
|
|
@@ -371,24 +382,24 @@ const importmapScriptSrcVisitor = (
|
|
|
371
382
|
if (!srcAttribute) {
|
|
372
383
|
return null
|
|
373
384
|
}
|
|
374
|
-
|
|
385
|
+
const integrityAttribute = getHtmlNodeAttributeByName(script, "integrity")
|
|
386
|
+
const integrity = integrityAttribute ? integrityAttribute.value : ""
|
|
375
387
|
const importmapReference = notifyReferenceFound({
|
|
376
388
|
referenceLabel: "html importmap",
|
|
377
389
|
contentTypeExpected: "application/importmap+json",
|
|
378
390
|
ressourceSpecifier: srcAttribute.value,
|
|
391
|
+
integrity,
|
|
392
|
+
...crossoriginFromHtmlNode(script),
|
|
379
393
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
380
394
|
})
|
|
381
395
|
return ({ getUrlRelativeToImporter }) => {
|
|
382
396
|
const { ressource } = importmapReference
|
|
383
|
-
|
|
384
397
|
if (format === "systemjs") {
|
|
385
398
|
typeAttribute.value = "systemjs-importmap"
|
|
386
399
|
}
|
|
387
|
-
|
|
388
400
|
if (ressource.isExternal) {
|
|
389
401
|
return
|
|
390
402
|
}
|
|
391
|
-
|
|
392
403
|
if (
|
|
393
404
|
// for esmodule we always inline the importmap
|
|
394
405
|
// as it's the only thing supported by Chrome
|
|
@@ -402,22 +413,22 @@ const importmapScriptSrcVisitor = (
|
|
|
402
413
|
// here put a warning if we cannot inline importmap because it would mess
|
|
403
414
|
// the remapping (note that it's feasible) but not yet supported
|
|
404
415
|
const { bufferAfterBuild } = ressource
|
|
405
|
-
|
|
406
416
|
const importmapString = String(bufferAfterBuild)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
${importmapString}</script>`,
|
|
411
|
-
{
|
|
412
|
-
attributesToIgnore: ["src"],
|
|
413
|
-
},
|
|
414
|
-
)
|
|
417
|
+
removeHtmlNodeAttribute(script, srcAttribute)
|
|
418
|
+
setHtmlNodeText(script, importmapString)
|
|
419
|
+
removeHtmlNodeAttribute(script, integrityAttribute)
|
|
415
420
|
importmapReference.inlinedCallback()
|
|
416
421
|
return
|
|
417
422
|
}
|
|
418
|
-
|
|
419
423
|
const urlRelativeToImporter = getUrlRelativeToImporter(ressource)
|
|
420
424
|
srcAttribute.value = urlRelativeToImporter
|
|
425
|
+
if (integrityAttribute) {
|
|
426
|
+
const base64Value = applyAlgoToRepresentationData(
|
|
427
|
+
"sha256",
|
|
428
|
+
ressource.bufferAfterBuild,
|
|
429
|
+
)
|
|
430
|
+
integrityAttribute.value = `sha256-${base64Value}`
|
|
431
|
+
}
|
|
421
432
|
}
|
|
422
433
|
}
|
|
423
434
|
|
|
@@ -442,7 +453,6 @@ const importmapScriptTextNodeVisitor = (
|
|
|
442
453
|
if (!textNode) {
|
|
443
454
|
return null
|
|
444
455
|
}
|
|
445
|
-
|
|
446
456
|
const importmapScriptId = getIdForInlineHtmlNode(script, scripts)
|
|
447
457
|
const importmapReference = notifyReferenceFound({
|
|
448
458
|
referenceLabel: "html inline importmap",
|
|
@@ -459,7 +469,6 @@ const importmapScriptTextNodeVisitor = (
|
|
|
459
469
|
if (format === "systemjs") {
|
|
460
470
|
typeAttribute.value = "systemjs-importmap"
|
|
461
471
|
}
|
|
462
|
-
|
|
463
472
|
const { bufferAfterBuild } = importmapReference.ressource
|
|
464
473
|
textNode.value = bufferAfterBuild
|
|
465
474
|
}
|
|
@@ -481,38 +490,34 @@ const linkStylesheetHrefVisitor = (
|
|
|
481
490
|
if (relAttribute.value !== "stylesheet") {
|
|
482
491
|
return null
|
|
483
492
|
}
|
|
484
|
-
|
|
493
|
+
const integrityAttribute = getHtmlNodeAttributeByName(link, "integrity")
|
|
494
|
+
const integrity = integrityAttribute ? integrityAttribute.value : ""
|
|
485
495
|
const cssReference = notifyReferenceFound({
|
|
486
496
|
referenceLabel: "html stylesheet link",
|
|
487
497
|
contentTypeExpected: "text/css",
|
|
488
498
|
ressourceSpecifier: hrefAttribute.value,
|
|
499
|
+
integrity,
|
|
500
|
+
...crossoriginFromHtmlNode(link),
|
|
489
501
|
...referenceLocationFromHtmlNode(link, "href"),
|
|
490
502
|
})
|
|
491
|
-
return async ({
|
|
492
|
-
getUrlRelativeToImporter,
|
|
493
|
-
precomputeBuildRelativeUrl,
|
|
494
|
-
buildDirectoryUrl,
|
|
495
|
-
}) => {
|
|
503
|
+
return async ({ getUrlRelativeToImporter, buildDirectoryUrl }) => {
|
|
496
504
|
const { ressource } = cssReference
|
|
497
|
-
|
|
498
505
|
if (ressource.isExternal) {
|
|
499
506
|
return
|
|
500
507
|
}
|
|
501
|
-
|
|
502
508
|
if (shouldInline({ ressource, htmlNode: link })) {
|
|
503
509
|
const { bufferAfterBuild } = ressource
|
|
504
510
|
let code = String(bufferAfterBuild)
|
|
505
511
|
const { buildRelativeUrl } = ressource
|
|
506
512
|
const cssBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
|
|
507
|
-
const
|
|
508
|
-
|
|
513
|
+
const htmlBuildUrl = resolveUrl(
|
|
514
|
+
htmlRessource.buildRelativeUrlWithoutHash,
|
|
509
515
|
buildDirectoryUrl,
|
|
510
516
|
)
|
|
511
|
-
|
|
512
517
|
const moveResult = await moveCssUrls({
|
|
513
518
|
code,
|
|
514
519
|
from: cssBuildUrl,
|
|
515
|
-
to:
|
|
520
|
+
to: htmlBuildUrl,
|
|
516
521
|
// moveCssUrls will change the css source code
|
|
517
522
|
// Ideally we should update the sourcemap referenced by css
|
|
518
523
|
// to target the one after css urls are moved.
|
|
@@ -523,24 +528,38 @@ const linkStylesheetHrefVisitor = (
|
|
|
523
528
|
sourcemapMethod: null,
|
|
524
529
|
})
|
|
525
530
|
code = moveResult.code
|
|
526
|
-
|
|
527
531
|
const sourcemapRelativeUrl = getCssSourceMappingUrl(code)
|
|
528
532
|
if (sourcemapRelativeUrl) {
|
|
529
533
|
const cssBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
|
|
530
534
|
const sourcemapBuildUrl = resolveUrl(sourcemapRelativeUrl, cssBuildUrl)
|
|
531
|
-
const sourcemapInlineUrl = urlToRelativeUrl(
|
|
535
|
+
const sourcemapInlineUrl = urlToRelativeUrl(
|
|
536
|
+
sourcemapBuildUrl,
|
|
537
|
+
htmlBuildUrl,
|
|
538
|
+
)
|
|
532
539
|
code = setCssSourceMappingUrl(code, sourcemapInlineUrl)
|
|
533
540
|
}
|
|
534
|
-
|
|
535
541
|
replaceHtmlNode(link, `<style>${code}</style>`, {
|
|
536
|
-
attributesToIgnore: [
|
|
542
|
+
attributesToIgnore: [
|
|
543
|
+
"href",
|
|
544
|
+
"rel",
|
|
545
|
+
"as",
|
|
546
|
+
"crossorigin",
|
|
547
|
+
"type",
|
|
548
|
+
"integrity",
|
|
549
|
+
],
|
|
537
550
|
})
|
|
538
551
|
cssReference.inlinedCallback()
|
|
539
552
|
return
|
|
540
553
|
}
|
|
541
|
-
|
|
542
554
|
const urlRelativeToImporter = getUrlRelativeToImporter(ressource)
|
|
543
555
|
hrefAttribute.value = urlRelativeToImporter
|
|
556
|
+
if (integrityAttribute) {
|
|
557
|
+
const base64Value = applyAlgoToRepresentationData(
|
|
558
|
+
"sha256",
|
|
559
|
+
ressource.bufferAfterBuild,
|
|
560
|
+
)
|
|
561
|
+
integrityAttribute.value = `sha256-${base64Value}`
|
|
562
|
+
}
|
|
544
563
|
}
|
|
545
564
|
}
|
|
546
565
|
|
|
@@ -552,7 +571,6 @@ const linkHrefVisitor = (
|
|
|
552
571
|
if (!hrefAttribute) {
|
|
553
572
|
return null
|
|
554
573
|
}
|
|
555
|
-
|
|
556
574
|
const href = hrefAttribute.value
|
|
557
575
|
const relAttribute = getHtmlNodeAttributeByName(link, "rel")
|
|
558
576
|
const rel = relAttribute ? relAttribute.value : undefined
|
|
@@ -563,7 +581,6 @@ const linkHrefVisitor = (
|
|
|
563
581
|
"preload",
|
|
564
582
|
"modulepreload",
|
|
565
583
|
].includes(rel)
|
|
566
|
-
|
|
567
584
|
let contentTypeExpected
|
|
568
585
|
const typeAttribute = getHtmlNodeAttributeByName(link, "type")
|
|
569
586
|
const type = typeAttribute ? typeAttribute.value : ""
|
|
@@ -576,19 +593,21 @@ const linkHrefVisitor = (
|
|
|
576
593
|
contentTypeExpected = "application/javascript"
|
|
577
594
|
isJsModule = true
|
|
578
595
|
}
|
|
579
|
-
|
|
596
|
+
const integrityAttribute = getHtmlNodeAttributeByName(link, "integrity")
|
|
597
|
+
const integrity = integrityAttribute ? integrityAttribute.value : ""
|
|
580
598
|
const linkReference = notifyReferenceFound({
|
|
581
599
|
referenceLabel: rel ? `html ${rel} link href` : `html link href`,
|
|
582
600
|
isRessourceHint,
|
|
583
601
|
contentTypeExpected,
|
|
584
602
|
ressourceSpecifier: href,
|
|
603
|
+
integrity,
|
|
604
|
+
...crossoriginFromHtmlNode(link),
|
|
585
605
|
...referenceLocationFromHtmlNode(link, "href"),
|
|
586
606
|
urlVersioningDisabled: contentTypeExpected === "application/manifest+json",
|
|
587
607
|
isJsModule,
|
|
588
608
|
})
|
|
589
609
|
return ({ getUrlRelativeToImporter }) => {
|
|
590
610
|
const { ressource } = linkReference
|
|
591
|
-
|
|
592
611
|
if (isRessourceHint) {
|
|
593
612
|
if (isReferencedOnlyByRessourceHint(ressource)) {
|
|
594
613
|
ressourceHintNeverUsedCallback({
|
|
@@ -600,36 +619,34 @@ const linkHrefVisitor = (
|
|
|
600
619
|
// we could remove the HTML node but better keep it untouched and let user decide what to do
|
|
601
620
|
return
|
|
602
621
|
}
|
|
603
|
-
|
|
604
622
|
ressource.inlinedCallbacks.push(() => {
|
|
605
623
|
removeHtmlNode(link)
|
|
606
624
|
})
|
|
607
625
|
}
|
|
608
|
-
|
|
609
626
|
if (ressource.isExternal) {
|
|
610
627
|
return
|
|
611
628
|
}
|
|
612
|
-
|
|
613
629
|
if (format === "systemjs" && rel === "modulepreload") {
|
|
614
630
|
const urlRelativeToImporter = getUrlRelativeToImporter(ressource)
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
)
|
|
631
|
+
relAttribute.value = "preload"
|
|
632
|
+
hrefAttribute.value = urlRelativeToImporter
|
|
633
|
+
addHtmlNodeAttribute(link, { name: "as", value: "script" })
|
|
619
634
|
return
|
|
620
635
|
}
|
|
621
|
-
|
|
622
636
|
if (shouldInline({ ressource, htmlNode: link })) {
|
|
623
|
-
|
|
624
|
-
link,
|
|
625
|
-
`<link href="${getRessourceAsBase64Url(ressource)}" />`,
|
|
626
|
-
)
|
|
637
|
+
removeHtmlNode(link)
|
|
627
638
|
linkReference.inlinedCallback()
|
|
628
639
|
return
|
|
629
640
|
}
|
|
630
|
-
|
|
631
641
|
const urlRelativeToImporter = getUrlRelativeToImporter(ressource)
|
|
632
642
|
hrefAttribute.value = urlRelativeToImporter
|
|
643
|
+
if (integrityAttribute) {
|
|
644
|
+
const base64Value = applyAlgoToRepresentationData(
|
|
645
|
+
"sha256",
|
|
646
|
+
ressource.bufferAfterBuild,
|
|
647
|
+
)
|
|
648
|
+
integrityAttribute.value = `sha256-${base64Value}`
|
|
649
|
+
}
|
|
633
650
|
}
|
|
634
651
|
}
|
|
635
652
|
|
|
@@ -643,7 +660,6 @@ const styleTextNodeVisitor = (
|
|
|
643
660
|
if (!textNode) {
|
|
644
661
|
return null
|
|
645
662
|
}
|
|
646
|
-
|
|
647
663
|
const styleId = getIdForInlineHtmlNode(style, styles)
|
|
648
664
|
const inlineStyleReference = notifyReferenceFound({
|
|
649
665
|
referenceLabel: "html style",
|
|
@@ -667,10 +683,10 @@ const imgSrcVisitor = (img, { notifyReferenceFound }) => {
|
|
|
667
683
|
if (!srcAttribute) {
|
|
668
684
|
return null
|
|
669
685
|
}
|
|
670
|
-
|
|
671
686
|
const srcReference = notifyReferenceFound({
|
|
672
687
|
referenceLabel: "html img src",
|
|
673
688
|
ressourceSpecifier: srcAttribute.value,
|
|
689
|
+
...crossoriginFromHtmlNode(img),
|
|
674
690
|
...referenceLocationFromHtmlNode(img, "src"),
|
|
675
691
|
})
|
|
676
692
|
return ({ getUrlRelativeToImporter }) => {
|
|
@@ -688,19 +704,18 @@ const srcsetVisitor = (htmlNode, { notifyReferenceFound }) => {
|
|
|
688
704
|
if (!srcsetAttribute) {
|
|
689
705
|
return null
|
|
690
706
|
}
|
|
691
|
-
|
|
692
707
|
const srcsetParts = parseSrcset(srcsetAttribute.value)
|
|
693
708
|
const srcsetPartsReferences = srcsetParts.map(({ specifier }, index) =>
|
|
694
709
|
notifyReferenceFound({
|
|
695
710
|
referenceLabel: `html srcset ${index}`,
|
|
696
711
|
ressourceSpecifier: specifier,
|
|
712
|
+
...crossoriginFromHtmlNode(htmlNode),
|
|
697
713
|
...referenceLocationFromHtmlNode(htmlNode, "srcset"),
|
|
698
714
|
}),
|
|
699
715
|
)
|
|
700
716
|
if (srcsetParts.length === 0) {
|
|
701
717
|
return null
|
|
702
718
|
}
|
|
703
|
-
|
|
704
719
|
return ({ getUrlRelativeToImporter }) => {
|
|
705
720
|
srcsetParts.forEach((srcsetPart, index) => {
|
|
706
721
|
const reference = srcsetPartsReferences[index]
|
|
@@ -721,12 +736,12 @@ const sourceSrcVisitor = (source, { notifyReferenceFound }) => {
|
|
|
721
736
|
if (!srcAttribute) {
|
|
722
737
|
return null
|
|
723
738
|
}
|
|
724
|
-
|
|
725
739
|
const typeAttribute = getHtmlNodeAttributeByName(source, "type")
|
|
726
740
|
const srcReference = notifyReferenceFound({
|
|
727
741
|
referenceLabel: "html source",
|
|
728
742
|
contentTypeExpected: typeAttribute ? typeAttribute.value : undefined,
|
|
729
743
|
ressourceSpecifier: srcAttribute.value,
|
|
744
|
+
...crossoriginFromHtmlNode(source),
|
|
730
745
|
...referenceLocationFromHtmlNode(source, "src"),
|
|
731
746
|
})
|
|
732
747
|
return ({ getUrlRelativeToImporter }) => {
|
|
@@ -751,6 +766,15 @@ const referenceToUrl = ({ reference, htmlNode, getUrlRelativeToImporter }) => {
|
|
|
751
766
|
return getUrlRelativeToImporter(ressource)
|
|
752
767
|
}
|
|
753
768
|
|
|
769
|
+
const crossoriginFromHtmlNode = (htmlNode) => {
|
|
770
|
+
const crossOriginAttribute = getHtmlNodeAttributeByName(
|
|
771
|
+
htmlNode,
|
|
772
|
+
"crossorigin",
|
|
773
|
+
)
|
|
774
|
+
const crossorigin = crossOriginAttribute ? crossOriginAttribute.value : ""
|
|
775
|
+
return { crossorigin }
|
|
776
|
+
}
|
|
777
|
+
|
|
754
778
|
const referenceLocationFromHtmlNode = (htmlNode, htmlAttributeName) => {
|
|
755
779
|
const locInfo = getHtmlNodeLocation(htmlNode, htmlAttributeName)
|
|
756
780
|
return locInfo
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { urlToFilename, resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
generateSourcemapUrl,
|
|
4
5
|
getJavaScriptSourceMappingUrl,
|
|
5
6
|
setJavaScriptSourceMappingUrl,
|
|
6
7
|
} from "@jsenv/core/src/internal/sourceMappingURLUtils.js"
|
|
@@ -32,7 +33,7 @@ export const parseJsRessource = async (
|
|
|
32
33
|
sourcemapReference = notifyReferenceFound({
|
|
33
34
|
referenceLabel: "js sourcemapping comment",
|
|
34
35
|
contentType: "application/octet-stream",
|
|
35
|
-
ressourceSpecifier:
|
|
36
|
+
ressourceSpecifier: urlToRelativeUrl(generateSourcemapUrl(jsUrl), jsUrl),
|
|
36
37
|
isPlaceholder: true,
|
|
37
38
|
isSourcemap: true,
|
|
38
39
|
})
|
|
@@ -40,7 +41,6 @@ export const parseJsRessource = async (
|
|
|
40
41
|
|
|
41
42
|
return async ({ buildDirectoryUrl }) => {
|
|
42
43
|
const sourcemapRessource = sourcemapReference.ressource
|
|
43
|
-
|
|
44
44
|
let code
|
|
45
45
|
let map
|
|
46
46
|
if (!sourcemapRessource.isPlaceholder) {
|
|
@@ -92,15 +92,12 @@ export const parseJsRessource = async (
|
|
|
92
92
|
jsRessource.buildRelativeUrl,
|
|
93
93
|
buildDirectoryUrl,
|
|
94
94
|
)
|
|
95
|
-
const sourcemapPrecomputedBuildUrl =
|
|
96
|
-
`${urlToFilename(jsBuildUrl)}.map`,
|
|
97
|
-
jsBuildUrl,
|
|
98
|
-
)
|
|
95
|
+
const sourcemapPrecomputedBuildUrl = generateSourcemapUrl(jsBuildUrl)
|
|
99
96
|
map.file = urlToFilename(jsBuildUrl)
|
|
100
97
|
if (map.sources) {
|
|
101
98
|
map.sources = map.sources.map((source) => {
|
|
102
99
|
const sourceUrl = resolveUrl(source, jsUrl)
|
|
103
|
-
const sourceOriginalUrl = asOriginalUrl(sourceUrl)
|
|
100
|
+
const sourceOriginalUrl = asOriginalUrl(sourceUrl) || sourceUrl
|
|
104
101
|
const sourceUrlRelativeToSourceMap = urlToRelativeUrl(
|
|
105
102
|
sourceOriginalUrl,
|
|
106
103
|
sourcemapPrecomputedBuildUrl,
|
|
@@ -27,6 +27,7 @@ export const parseRessource = async (
|
|
|
27
27
|
notifiers,
|
|
28
28
|
{
|
|
29
29
|
projectDirectoryUrl,
|
|
30
|
+
jsenvRemoteDirectory,
|
|
30
31
|
format,
|
|
31
32
|
systemJsUrl,
|
|
32
33
|
asProjectUrl,
|
|
@@ -125,6 +126,7 @@ export const parseRessource = async (
|
|
|
125
126
|
|
|
126
127
|
if (contentType === "text/css") {
|
|
127
128
|
return parseCssRessource(ressource, notifiers, {
|
|
129
|
+
jsenvRemoteDirectory,
|
|
128
130
|
asProjectUrl,
|
|
129
131
|
asOriginalUrl,
|
|
130
132
|
asOriginalServerUrl,
|
|
@@ -156,6 +158,7 @@ export const parseRessource = async (
|
|
|
156
158
|
) {
|
|
157
159
|
return parseJsRessource(ressource, notifiers, {
|
|
158
160
|
projectDirectoryUrl,
|
|
161
|
+
jsenvRemoteDirectory,
|
|
159
162
|
asProjectUrl,
|
|
160
163
|
asOriginalUrl,
|
|
161
164
|
asOriginalServerUrl,
|