@jsenv/core 39.5.23 → 39.5.24
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/jsenv_core.js +30 -19
- package/package.json +2 -2
- package/src/kitchen/fetched_content_compliance.js +5 -4
- package/src/kitchen/kitchen.js +11 -10
- package/src/kitchen/url_graph/url_graph.js +1 -0
- package/src/plugins/html_syntax_error_fallback/jsenv_plugin_html_syntax_error_fallback.js +6 -2
- package/src/plugins/protocol_file/jsenv_plugin_protocol_file.js +8 -4
package/dist/jsenv_core.js
CHANGED
|
@@ -10875,7 +10875,7 @@ const jsenvPluginImportAttributes = ({
|
|
|
10875
10875
|
const originalUrlInfo = urlInfo.getWithoutSearchParam(
|
|
10876
10876
|
`as_${type}_module`,
|
|
10877
10877
|
{
|
|
10878
|
-
expectedType:
|
|
10878
|
+
expectedType: type,
|
|
10879
10879
|
},
|
|
10880
10880
|
);
|
|
10881
10881
|
if (!originalUrlInfo) {
|
|
@@ -11172,6 +11172,10 @@ const generateHtmlForSyntaxError = (
|
|
|
11172
11172
|
const htmlForSyntaxError = String(readFileSync(htmlSyntaxErrorFileUrl));
|
|
11173
11173
|
const htmlRelativeUrl = urlToRelativeUrl(htmlUrl, rootDirectoryUrl);
|
|
11174
11174
|
const { line, column } = htmlSyntaxError;
|
|
11175
|
+
if (htmlUrl.startsWith(jsenvCoreDirectoryUrl.href)) {
|
|
11176
|
+
htmlUrl = urlToRelativeUrl(htmlUrl, jsenvCoreDirectoryUrl);
|
|
11177
|
+
htmlUrl = `@jsenv/core/${htmlUrl}`;
|
|
11178
|
+
}
|
|
11175
11179
|
const urlWithLineAndColumn = `${htmlUrl}:${line}:${column}`;
|
|
11176
11180
|
const replacers = {
|
|
11177
11181
|
fileRelativeUrl: htmlRelativeUrl,
|
|
@@ -12046,17 +12050,18 @@ const isResponseEligibleForIntegrityValidation = (response) => {
|
|
|
12046
12050
|
};
|
|
12047
12051
|
|
|
12048
12052
|
const assertFetchedContentCompliance = ({ urlInfo, content }) => {
|
|
12053
|
+
if (urlInfo.status === 404) {
|
|
12054
|
+
return;
|
|
12055
|
+
}
|
|
12049
12056
|
const { expectedContentType } = urlInfo.firstReference;
|
|
12050
12057
|
if (expectedContentType && urlInfo.contentType !== expectedContentType) {
|
|
12051
12058
|
throw new Error(
|
|
12052
|
-
`
|
|
12059
|
+
`content-type must be "${expectedContentType}", got "${urlInfo.contentType}`,
|
|
12053
12060
|
);
|
|
12054
12061
|
}
|
|
12055
12062
|
const { expectedType } = urlInfo.firstReference;
|
|
12056
12063
|
if (expectedType && urlInfo.type !== expectedType) {
|
|
12057
|
-
throw new Error(
|
|
12058
|
-
`Unexpected type on url: "${expectedType}" was expect but got "${urlInfo.type}"`,
|
|
12059
|
-
);
|
|
12064
|
+
throw new Error(`type must be "${expectedType}", got "${urlInfo.type}"`);
|
|
12060
12065
|
}
|
|
12061
12066
|
const { integrity } = urlInfo.firstReference;
|
|
12062
12067
|
if (integrity) {
|
|
@@ -13433,6 +13438,7 @@ const createUrlInfo = (url, context) => {
|
|
|
13433
13438
|
jsQuote: null, // maybe move to inlineUrlSite?
|
|
13434
13439
|
|
|
13435
13440
|
timing: {},
|
|
13441
|
+
status: 200,
|
|
13436
13442
|
headers: {},
|
|
13437
13443
|
debug: false,
|
|
13438
13444
|
};
|
|
@@ -14500,21 +14506,16 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
14500
14506
|
body,
|
|
14501
14507
|
isEntryPoint,
|
|
14502
14508
|
} = fetchUrlContentReturnValue;
|
|
14503
|
-
if (status !== 200) {
|
|
14504
|
-
throw new Error(`unexpected status, ${status}`);
|
|
14505
|
-
}
|
|
14506
14509
|
if (content === undefined) {
|
|
14507
14510
|
content = body;
|
|
14508
14511
|
}
|
|
14509
14512
|
if (contentType === undefined) {
|
|
14510
14513
|
contentType = headers["content-type"] || "application/octet-stream";
|
|
14511
14514
|
}
|
|
14515
|
+
urlInfo.status = status;
|
|
14512
14516
|
urlInfo.contentType = contentType;
|
|
14513
14517
|
urlInfo.headers = headers;
|
|
14514
|
-
urlInfo.type =
|
|
14515
|
-
type ||
|
|
14516
|
-
urlInfo.firstReference.expectedType ||
|
|
14517
|
-
inferUrlInfoType(urlInfo);
|
|
14518
|
+
urlInfo.type = type || inferUrlInfoType(urlInfo);
|
|
14518
14519
|
urlInfo.subtype =
|
|
14519
14520
|
subtype ||
|
|
14520
14521
|
urlInfo.firstReference.expectedSubtype ||
|
|
@@ -14838,10 +14839,11 @@ const memoizeIsSupported = (runtimeCompat) => {
|
|
|
14838
14839
|
|
|
14839
14840
|
const inferUrlInfoType = (urlInfo) => {
|
|
14840
14841
|
const { type, typeHint } = urlInfo;
|
|
14842
|
+
const { contentType } = urlInfo;
|
|
14843
|
+
const { expectedType } = urlInfo.firstReference;
|
|
14841
14844
|
if (type === "sourcemap" || typeHint === "sourcemap") {
|
|
14842
14845
|
return "sourcemap";
|
|
14843
14846
|
}
|
|
14844
|
-
const { contentType } = urlInfo;
|
|
14845
14847
|
if (contentType === "text/html") {
|
|
14846
14848
|
return "html";
|
|
14847
14849
|
}
|
|
@@ -14849,7 +14851,12 @@ const inferUrlInfoType = (urlInfo) => {
|
|
|
14849
14851
|
return "css";
|
|
14850
14852
|
}
|
|
14851
14853
|
if (contentType === "text/javascript") {
|
|
14852
|
-
if (
|
|
14854
|
+
if (expectedType === "js_classic") {
|
|
14855
|
+
return "js_classic";
|
|
14856
|
+
}
|
|
14857
|
+
if (typeHint === "js_classic") {
|
|
14858
|
+
return "js_classic";
|
|
14859
|
+
}
|
|
14853
14860
|
return "js_module";
|
|
14854
14861
|
}
|
|
14855
14862
|
if (contentType === "application/importmap+json") {
|
|
@@ -14867,7 +14874,7 @@ const inferUrlInfoType = (urlInfo) => {
|
|
|
14867
14874
|
if (CONTENT_TYPE.isTextual(contentType)) {
|
|
14868
14875
|
return "text";
|
|
14869
14876
|
}
|
|
14870
|
-
return "other";
|
|
14877
|
+
return expectedType || "other";
|
|
14871
14878
|
};
|
|
14872
14879
|
|
|
14873
14880
|
const createUrlGraphSummary = (
|
|
@@ -18852,10 +18859,13 @@ const jsenvPluginProtocolFile = ({
|
|
|
18852
18859
|
};
|
|
18853
18860
|
}
|
|
18854
18861
|
const contentType = CONTENT_TYPE.fromUrlExtension(urlInfo.url);
|
|
18855
|
-
|
|
18862
|
+
const request = urlInfo.context.request;
|
|
18863
|
+
if (request && request.headers["sec-fetch-dest"] === "document") {
|
|
18856
18864
|
try {
|
|
18857
18865
|
const fileBuffer = readFileSync(urlObject);
|
|
18858
|
-
const content =
|
|
18866
|
+
const content = CONTENT_TYPE.isTextual(contentType)
|
|
18867
|
+
? String(fileBuffer)
|
|
18868
|
+
: fileBuffer;
|
|
18859
18869
|
return {
|
|
18860
18870
|
content,
|
|
18861
18871
|
contentType,
|
|
@@ -18872,7 +18882,7 @@ const jsenvPluginProtocolFile = ({
|
|
|
18872
18882
|
const parentDirectoryContentArray = readdirSync(
|
|
18873
18883
|
new URL(parentDirectoryUrl),
|
|
18874
18884
|
);
|
|
18875
|
-
const html =
|
|
18885
|
+
const html = generateHtmlForENOENT(
|
|
18876
18886
|
urlInfo.url,
|
|
18877
18887
|
parentDirectoryContentArray,
|
|
18878
18888
|
parentDirectoryUrl,
|
|
@@ -18880,6 +18890,7 @@ const jsenvPluginProtocolFile = ({
|
|
|
18880
18890
|
directoryListingUrlMocks,
|
|
18881
18891
|
);
|
|
18882
18892
|
return {
|
|
18893
|
+
status: 404,
|
|
18883
18894
|
contentType: "text/html",
|
|
18884
18895
|
content: html,
|
|
18885
18896
|
headers: {
|
|
@@ -18925,7 +18936,7 @@ const generateHtmlForDirectory = (
|
|
|
18925
18936
|
const html = replacePlaceholders$1(htmlForDirectory, replacers);
|
|
18926
18937
|
return html;
|
|
18927
18938
|
};
|
|
18928
|
-
const
|
|
18939
|
+
const generateHtmlForENOENT = (
|
|
18929
18940
|
url,
|
|
18930
18941
|
parentDirectoryContentArray,
|
|
18931
18942
|
parentDirectoryUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "39.5.
|
|
3
|
+
"version": "39.5.24",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@jsenv/node-esm-resolution": "1.0.6",
|
|
79
79
|
"@jsenv/plugin-bundling": "2.7.16",
|
|
80
80
|
"@jsenv/plugin-minification": "1.5.10",
|
|
81
|
-
"@jsenv/plugin-supervisor": "1.5.
|
|
81
|
+
"@jsenv/plugin-supervisor": "1.5.28",
|
|
82
82
|
"@jsenv/plugin-transpilation": "1.4.84",
|
|
83
83
|
"@jsenv/runtime-compat": "1.3.1",
|
|
84
84
|
"@jsenv/server": "15.3.3",
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { validateResponseIntegrity } from "@jsenv/integrity";
|
|
2
2
|
|
|
3
3
|
export const assertFetchedContentCompliance = ({ urlInfo, content }) => {
|
|
4
|
+
if (urlInfo.status === 404) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
4
7
|
const { expectedContentType } = urlInfo.firstReference;
|
|
5
8
|
if (expectedContentType && urlInfo.contentType !== expectedContentType) {
|
|
6
9
|
throw new Error(
|
|
7
|
-
`
|
|
10
|
+
`content-type must be "${expectedContentType}", got "${urlInfo.contentType}`,
|
|
8
11
|
);
|
|
9
12
|
}
|
|
10
13
|
const { expectedType } = urlInfo.firstReference;
|
|
11
14
|
if (expectedType && urlInfo.type !== expectedType) {
|
|
12
|
-
throw new Error(
|
|
13
|
-
`Unexpected type on url: "${expectedType}" was expect but got "${urlInfo.type}"`,
|
|
14
|
-
);
|
|
15
|
+
throw new Error(`type must be "${expectedType}", got "${urlInfo.type}"`);
|
|
15
16
|
}
|
|
16
17
|
const { integrity } = urlInfo.firstReference;
|
|
17
18
|
if (integrity) {
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -342,21 +342,16 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
342
342
|
body,
|
|
343
343
|
isEntryPoint,
|
|
344
344
|
} = fetchUrlContentReturnValue;
|
|
345
|
-
if (status !== 200) {
|
|
346
|
-
throw new Error(`unexpected status, ${status}`);
|
|
347
|
-
}
|
|
348
345
|
if (content === undefined) {
|
|
349
346
|
content = body;
|
|
350
347
|
}
|
|
351
348
|
if (contentType === undefined) {
|
|
352
349
|
contentType = headers["content-type"] || "application/octet-stream";
|
|
353
350
|
}
|
|
351
|
+
urlInfo.status = status;
|
|
354
352
|
urlInfo.contentType = contentType;
|
|
355
353
|
urlInfo.headers = headers;
|
|
356
|
-
urlInfo.type =
|
|
357
|
-
type ||
|
|
358
|
-
urlInfo.firstReference.expectedType ||
|
|
359
|
-
inferUrlInfoType(urlInfo);
|
|
354
|
+
urlInfo.type = type || inferUrlInfoType(urlInfo);
|
|
360
355
|
urlInfo.subtype =
|
|
361
356
|
subtype ||
|
|
362
357
|
urlInfo.firstReference.expectedSubtype ||
|
|
@@ -680,10 +675,11 @@ const memoizeIsSupported = (runtimeCompat) => {
|
|
|
680
675
|
|
|
681
676
|
const inferUrlInfoType = (urlInfo) => {
|
|
682
677
|
const { type, typeHint } = urlInfo;
|
|
678
|
+
const { contentType } = urlInfo;
|
|
679
|
+
const { expectedType } = urlInfo.firstReference;
|
|
683
680
|
if (type === "sourcemap" || typeHint === "sourcemap") {
|
|
684
681
|
return "sourcemap";
|
|
685
682
|
}
|
|
686
|
-
const { contentType } = urlInfo;
|
|
687
683
|
if (contentType === "text/html") {
|
|
688
684
|
return "html";
|
|
689
685
|
}
|
|
@@ -691,7 +687,12 @@ const inferUrlInfoType = (urlInfo) => {
|
|
|
691
687
|
return "css";
|
|
692
688
|
}
|
|
693
689
|
if (contentType === "text/javascript") {
|
|
694
|
-
if (
|
|
690
|
+
if (expectedType === "js_classic") {
|
|
691
|
+
return "js_classic";
|
|
692
|
+
}
|
|
693
|
+
if (typeHint === "js_classic") {
|
|
694
|
+
return "js_classic";
|
|
695
|
+
}
|
|
695
696
|
return "js_module";
|
|
696
697
|
}
|
|
697
698
|
if (contentType === "application/importmap+json") {
|
|
@@ -709,5 +710,5 @@ const inferUrlInfoType = (urlInfo) => {
|
|
|
709
710
|
if (CONTENT_TYPE.isTextual(contentType)) {
|
|
710
711
|
return "text";
|
|
711
712
|
}
|
|
712
|
-
return "other";
|
|
713
|
+
return expectedType || "other";
|
|
713
714
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseHtml } from "@jsenv/ast";
|
|
2
|
+
import { generateContentFrame } from "@jsenv/humanize";
|
|
2
3
|
import { urlToRelativeUrl } from "@jsenv/urls";
|
|
3
4
|
import { readFileSync } from "node:fs";
|
|
4
|
-
|
|
5
|
-
import { generateContentFrame } from "@jsenv/humanize";
|
|
5
|
+
import { jsenvCoreDirectoryUrl } from "../../jsenv_core_directory_url.js";
|
|
6
6
|
|
|
7
7
|
export const jsenvPluginHtmlSyntaxErrorFallback = () => {
|
|
8
8
|
const htmlSyntaxErrorFileUrl = new URL(
|
|
@@ -58,6 +58,10 @@ const generateHtmlForSyntaxError = (
|
|
|
58
58
|
const htmlForSyntaxError = String(readFileSync(htmlSyntaxErrorFileUrl));
|
|
59
59
|
const htmlRelativeUrl = urlToRelativeUrl(htmlUrl, rootDirectoryUrl);
|
|
60
60
|
const { line, column } = htmlSyntaxError;
|
|
61
|
+
if (htmlUrl.startsWith(jsenvCoreDirectoryUrl.href)) {
|
|
62
|
+
htmlUrl = urlToRelativeUrl(htmlUrl, jsenvCoreDirectoryUrl);
|
|
63
|
+
htmlUrl = `@jsenv/core/${htmlUrl}`;
|
|
64
|
+
}
|
|
61
65
|
const urlWithLineAndColumn = `${htmlUrl}:${line}:${column}`;
|
|
62
66
|
const replacers = {
|
|
63
67
|
fileRelativeUrl: htmlRelativeUrl,
|
|
@@ -118,10 +118,13 @@ export const jsenvPluginProtocolFile = ({
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
const contentType = CONTENT_TYPE.fromUrlExtension(urlInfo.url);
|
|
121
|
-
|
|
121
|
+
const request = urlInfo.context.request;
|
|
122
|
+
if (request && request.headers["sec-fetch-dest"] === "document") {
|
|
122
123
|
try {
|
|
123
124
|
const fileBuffer = readFileSync(urlObject);
|
|
124
|
-
const content =
|
|
125
|
+
const content = CONTENT_TYPE.isTextual(contentType)
|
|
126
|
+
? String(fileBuffer)
|
|
127
|
+
: fileBuffer;
|
|
125
128
|
return {
|
|
126
129
|
content,
|
|
127
130
|
contentType,
|
|
@@ -138,7 +141,7 @@ export const jsenvPluginProtocolFile = ({
|
|
|
138
141
|
const parentDirectoryContentArray = readdirSync(
|
|
139
142
|
new URL(parentDirectoryUrl),
|
|
140
143
|
);
|
|
141
|
-
const html =
|
|
144
|
+
const html = generateHtmlForENOENT(
|
|
142
145
|
urlInfo.url,
|
|
143
146
|
parentDirectoryContentArray,
|
|
144
147
|
parentDirectoryUrl,
|
|
@@ -146,6 +149,7 @@ export const jsenvPluginProtocolFile = ({
|
|
|
146
149
|
directoryListingUrlMocks,
|
|
147
150
|
);
|
|
148
151
|
return {
|
|
152
|
+
status: 404,
|
|
149
153
|
contentType: "text/html",
|
|
150
154
|
content: html,
|
|
151
155
|
headers: {
|
|
@@ -191,7 +195,7 @@ const generateHtmlForDirectory = (
|
|
|
191
195
|
const html = replacePlaceholders(htmlForDirectory, replacers);
|
|
192
196
|
return html;
|
|
193
197
|
};
|
|
194
|
-
const
|
|
198
|
+
const generateHtmlForENOENT = (
|
|
195
199
|
url,
|
|
196
200
|
parentDirectoryContentArray,
|
|
197
201
|
parentDirectoryUrl,
|