@jsenv/core 41.4.20 → 41.4.22

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.
@@ -6619,7 +6619,6 @@ const browserDefaultRuntimeCompat = {
6619
6619
  chrome: "64",
6620
6620
  edge: "79",
6621
6621
  firefox: "67",
6622
- ios: "12",
6623
6622
  ios_safari: "12",
6624
6623
  opera: "51",
6625
6624
  safari: "11.3",
@@ -6721,7 +6720,6 @@ const featuresCompatMap = {
6721
6720
  chrome: "61",
6722
6721
  safari: "10.1",
6723
6722
  opera: "48",
6724
- ios: "10.3",
6725
6723
  ios_safari: "10.3",
6726
6724
  android: "61",
6727
6725
  samsung: "8.2",
@@ -6741,7 +6739,6 @@ const featuresCompatMap = {
6741
6739
  chrome: "64",
6742
6740
  edge: "79",
6743
6741
  firefox: "62",
6744
- ios: "12",
6745
6742
  ios_safari: "12",
6746
6743
  opera: "51",
6747
6744
  safari: "11.1",
@@ -6759,7 +6756,6 @@ const featuresCompatMap = {
6759
6756
  chrome: "63",
6760
6757
  edge: "79",
6761
6758
  firefox: "67",
6762
- ios: "11.3",
6763
6759
  ios_safari: "11.3",
6764
6760
  opera: "50",
6765
6761
  safari: "11.3",
@@ -6773,7 +6769,6 @@ const featuresCompatMap = {
6773
6769
  opera: "75",
6774
6770
  safari: "15",
6775
6771
  samsung: "15",
6776
- ios: "15",
6777
6772
  ios_safari: "15",
6778
6773
  node: "14.8",
6779
6774
  },
@@ -6809,7 +6804,6 @@ const featuresCompatMap = {
6809
6804
  chrome: "4",
6810
6805
  opera: "11.5",
6811
6806
  safari: "4",
6812
- ios: "5",
6813
6807
  ios_safari: "5",
6814
6808
  android: "4.4",
6815
6809
  },
@@ -6827,7 +6821,6 @@ const featuresCompatMap = {
6827
6821
  chrome: "40",
6828
6822
  safari: "11.1",
6829
6823
  opera: "27",
6830
- ios: "11.3",
6831
6824
  ios_safari: "11.3",
6832
6825
  android: "12.12",
6833
6826
  },
@@ -6857,7 +6850,6 @@ const featuresCompatMap = {
6857
6850
  chrome: "71",
6858
6851
  safari: "12.1",
6859
6852
  opera: "58",
6860
- ios: "12.2",
6861
6853
  ios_safari: "12.2",
6862
6854
  android: "94",
6863
6855
  node: "12",
@@ -6869,7 +6861,6 @@ const featuresCompatMap = {
6869
6861
  firefox: "57",
6870
6862
  safari: "12",
6871
6863
  node: "10",
6872
- ios: "12",
6873
6864
  ios_safari: "12",
6874
6865
  samsung: "8",
6875
6866
  electron: "3",
@@ -6881,7 +6872,6 @@ const featuresCompatMap = {
6881
6872
  firefox: "34",
6882
6873
  opera: "28",
6883
6874
  safari: "9",
6884
- ios: "9",
6885
6875
  ios_safari: "9",
6886
6876
  android: "4",
6887
6877
  node: "4",
@@ -6893,7 +6883,6 @@ const featuresCompatMap = {
6893
6883
  firefox: "45",
6894
6884
  safari: "10",
6895
6885
  node: "6",
6896
- ios: "10",
6897
6886
  ios_safari: "10",
6898
6887
  samsung: "5",
6899
6888
  electron: "0.36",
@@ -6906,7 +6895,6 @@ const featuresCompatMap = {
6906
6895
  safari: "10",
6907
6896
  node: "4",
6908
6897
  ie: "11",
6909
- ios: "10",
6910
6898
  ios_safari: "10",
6911
6899
  samsung: "3.4",
6912
6900
  electron: "0.22",
@@ -6918,7 +6906,6 @@ const featuresCompatMap = {
6918
6906
  firefox: "33",
6919
6907
  safari: "9",
6920
6908
  node: "4",
6921
- ios: "9",
6922
6909
  ios_safari: "9",
6923
6910
  samsung: "4",
6924
6911
  electron: "0.28",
@@ -6932,7 +6919,6 @@ const featuresCompatMap = {
6932
6919
  node: "0.10",
6933
6920
  ie: "9",
6934
6921
  android: "4.4",
6935
- ios: "6",
6936
6922
  ios_safari: "6",
6937
6923
  phantom: "2",
6938
6924
  samsung: "1",
@@ -6944,7 +6930,6 @@ const featuresCompatMap = {
6944
6930
  edge: "12",
6945
6931
  firefox: "36",
6946
6932
  safari: "9",
6947
- ios: "9",
6948
6933
  ios_safari: "9",
6949
6934
  samsung: "4",
6950
6935
  node: "0.12",
@@ -6958,7 +6958,6 @@ const featuresCompatMap = {
6958
6958
  chrome: "61",
6959
6959
  safari: "10.1",
6960
6960
  opera: "48",
6961
- ios: "10.3",
6962
6961
  ios_safari: "10.3",
6963
6962
  android: "61",
6964
6963
  samsung: "8.2",
@@ -6978,7 +6977,6 @@ const featuresCompatMap = {
6978
6977
  chrome: "64",
6979
6978
  edge: "79",
6980
6979
  firefox: "62",
6981
- ios: "12",
6982
6980
  ios_safari: "12",
6983
6981
  opera: "51",
6984
6982
  safari: "11.1",
@@ -6996,7 +6994,6 @@ const featuresCompatMap = {
6996
6994
  chrome: "63",
6997
6995
  edge: "79",
6998
6996
  firefox: "67",
6999
- ios: "11.3",
7000
6997
  ios_safari: "11.3",
7001
6998
  opera: "50",
7002
6999
  safari: "11.3",
@@ -7010,7 +7007,6 @@ const featuresCompatMap = {
7010
7007
  opera: "75",
7011
7008
  safari: "15",
7012
7009
  samsung: "15",
7013
- ios: "15",
7014
7010
  ios_safari: "15",
7015
7011
  node: "14.8",
7016
7012
  },
@@ -7046,7 +7042,6 @@ const featuresCompatMap = {
7046
7042
  chrome: "4",
7047
7043
  opera: "11.5",
7048
7044
  safari: "4",
7049
- ios: "5",
7050
7045
  ios_safari: "5",
7051
7046
  android: "4.4",
7052
7047
  },
@@ -7064,7 +7059,6 @@ const featuresCompatMap = {
7064
7059
  chrome: "40",
7065
7060
  safari: "11.1",
7066
7061
  opera: "27",
7067
- ios: "11.3",
7068
7062
  ios_safari: "11.3",
7069
7063
  android: "12.12",
7070
7064
  },
@@ -7094,7 +7088,6 @@ const featuresCompatMap = {
7094
7088
  chrome: "71",
7095
7089
  safari: "12.1",
7096
7090
  opera: "58",
7097
- ios: "12.2",
7098
7091
  ios_safari: "12.2",
7099
7092
  android: "94",
7100
7093
  node: "12",
@@ -7106,7 +7099,6 @@ const featuresCompatMap = {
7106
7099
  firefox: "57",
7107
7100
  safari: "12",
7108
7101
  node: "10",
7109
- ios: "12",
7110
7102
  ios_safari: "12",
7111
7103
  samsung: "8",
7112
7104
  electron: "3",
@@ -7118,7 +7110,6 @@ const featuresCompatMap = {
7118
7110
  firefox: "34",
7119
7111
  opera: "28",
7120
7112
  safari: "9",
7121
- ios: "9",
7122
7113
  ios_safari: "9",
7123
7114
  android: "4",
7124
7115
  node: "4",
@@ -7130,7 +7121,6 @@ const featuresCompatMap = {
7130
7121
  firefox: "45",
7131
7122
  safari: "10",
7132
7123
  node: "6",
7133
- ios: "10",
7134
7124
  ios_safari: "10",
7135
7125
  samsung: "5",
7136
7126
  electron: "0.36",
@@ -7143,7 +7133,6 @@ const featuresCompatMap = {
7143
7133
  safari: "10",
7144
7134
  node: "4",
7145
7135
  ie: "11",
7146
- ios: "10",
7147
7136
  ios_safari: "10",
7148
7137
  samsung: "3.4",
7149
7138
  electron: "0.22",
@@ -7155,7 +7144,6 @@ const featuresCompatMap = {
7155
7144
  firefox: "33",
7156
7145
  safari: "9",
7157
7146
  node: "4",
7158
- ios: "9",
7159
7147
  ios_safari: "9",
7160
7148
  samsung: "4",
7161
7149
  electron: "0.28",
@@ -7169,7 +7157,6 @@ const featuresCompatMap = {
7169
7157
  node: "0.10",
7170
7158
  ie: "9",
7171
7159
  android: "4.4",
7172
- ios: "6",
7173
7160
  ios_safari: "6",
7174
7161
  phantom: "2",
7175
7162
  samsung: "1",
@@ -7181,7 +7168,6 @@ const featuresCompatMap = {
7181
7168
  edge: "12",
7182
7169
  firefox: "36",
7183
7170
  safari: "9",
7184
- ios: "9",
7185
7171
  ios_safari: "9",
7186
7172
  samsung: "4",
7187
7173
  node: "0.12",
@@ -11361,6 +11361,11 @@ const inferUrlInfoType = (urlInfo) => {
11361
11361
  return expectedType || "other";
11362
11362
  };
11363
11363
 
11364
+ // What the newest browser supports, and nothing less: the source untouched.
11365
+ // A version no browser has, so that every feature known to runtime-compat
11366
+ // counts as supported.
11367
+ const UNKNOWN_CLIENT_RUNTIME_COMPAT = { chrome: "9999.0.0" };
11368
+
11364
11369
  const devServerPluginServeSourceFiles = ({
11365
11370
  packageDirectory,
11366
11371
  sourceDirectoryUrl,
@@ -11421,14 +11426,16 @@ const devServerPluginServeSourceFiles = ({
11421
11426
  }
11422
11427
  });
11423
11428
  // A client we cannot identify (curl, fetch, a healthcheck, a proxy dropping
11424
- // the user agent) is assumed to be one of the runtimes the project targets.
11425
- // Treating it as a runtime supporting nothing would serve it the js module
11426
- // fallback, breaking tooling perfectly capable of ES modules; an actual
11427
- // ancient browser hiding its identity fails loudly instead, which is the
11428
- // cheaper of the two mistakes.
11429
+ // the user agent, the WebKit inspector re-requesting a page's resources
11430
+ // under its own agent) is served the source as it is written. Taking the
11431
+ // build targets instead would hand it the js module fallback and a heavy
11432
+ // transpilation — and, when the same page mixes identified and
11433
+ // unidentified requests, two incompatible versions of one module. An
11434
+ // actual ancient browser hiding its identity fails loudly instead, which
11435
+ // is the right failure for dev.
11429
11436
  const clientRuntimeCompat =
11430
11437
  runtimeName === "unknown"
11431
- ? runtimeCompat
11438
+ ? UNKNOWN_CLIENT_RUNTIME_COMPAT
11432
11439
  : { [runtimeName]: runtimeVersion };
11433
11440
 
11434
11441
  kitchen = createKitchen({
@@ -11622,6 +11629,41 @@ const devServerPluginServeSourceFiles = ({
11622
11629
  request.resource,
11623
11630
  parentUrl,
11624
11631
  );
11632
+ if (!reference) {
11633
+ // Inline content ("page.html@L10C7-L14C16.js") has no file of its
11634
+ // own: it is served from the reference its parent creates when it
11635
+ // is cooked. Without a usable referer the parent is not known —
11636
+ // devtools re-fetching a resource on its own, a second kitchen for
11637
+ // the same page (the WebKit inspector sends its own user agent) —
11638
+ // so it is derived from the url and cooked first.
11639
+ const inlineParentUrl = getInlineContentParentUrl(requestedUrl);
11640
+ if (inlineParentUrl) {
11641
+ if (!kitchen.graph.getUrlInfo(inlineParentUrl)) {
11642
+ const rootUrlInfo = kitchen.graph.rootUrlInfo;
11643
+ const inlineParentWebUrl = WEB_URL_CONVERTER.asWebUrl(
11644
+ inlineParentUrl,
11645
+ {
11646
+ origin: request.origin,
11647
+ rootDirectoryUrl: sourceDirectoryUrl,
11648
+ },
11649
+ );
11650
+ const parentReference =
11651
+ rootUrlInfo.dependencies.createResolveAndFinalize({
11652
+ trace: { message: parentUrl },
11653
+ type: "http_request",
11654
+ specifier: inlineParentWebUrl.slice(request.origin.length),
11655
+ });
11656
+ await parentReference.urlInfo.cook({
11657
+ request,
11658
+ reference: parentReference,
11659
+ });
11660
+ }
11661
+ reference = kitchen.graph.inferReference(
11662
+ request.resource,
11663
+ inlineParentUrl,
11664
+ );
11665
+ }
11666
+ }
11625
11667
  if (reference) {
11626
11668
  reference.urlInfo.context.request = request;
11627
11669
  reference.urlInfo.context.requestedUrl = requestedUrl;
@@ -11907,6 +11949,21 @@ const cacheIsDisabledInResponseHeader = (urlInfo) => {
11907
11949
  );
11908
11950
  };
11909
11951
 
11952
+ // "dir/page.html@L10C7-L14C16.js" -> "dir/page.html" (search kept: it is the
11953
+ // parent's). Null for anything else — the inline url grammar is the one
11954
+ // generateUrlForInlineContent writes (@jsenv/ast).
11955
+ const getInlineContentParentUrl = (url) => {
11956
+ const urlObject = new URL(url);
11957
+ const match = /^(.+)@[^@/]*?L\d+C\d+(?:-L\d+C\d+)?\.[a-z0-9]+$/.exec(
11958
+ urlObject.pathname,
11959
+ );
11960
+ if (!match) {
11961
+ return null;
11962
+ }
11963
+ urlObject.pathname = match[1];
11964
+ return urlObject.href;
11965
+ };
11966
+
11910
11967
  const EXECUTED_BY_TEST_PLAN = process.argv.includes("--jsenv-test");
11911
11968
 
11912
11969
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "41.4.20",
3
+ "version": "41.4.22",
4
4
  "type": "module",
5
5
  "description": "Tool to develop, test and build js projects",
6
6
  "repository": {
@@ -52,6 +52,7 @@
52
52
  "database:stop": "npx @jsenv/database stop",
53
53
  "dev": "node --watch --conditions=dev:jsenv ./scripts/dev/dev.mjs",
54
54
  "dev:route-inspector": "node --watch --conditions=dev:jsenv ./packages/backend/server/tests/route_inspector/start_server.js",
55
+ "dev:webkit": "node ./scripts/dev/webkit.mjs",
55
56
  "eslint": "npx eslint .",
56
57
  "https:setup": "npx @jsenv/https-local setup",
57
58
  "md:build": "node ./docs/build.js",
@@ -77,7 +78,7 @@
77
78
  "@jsenv/plugin-bundling": "2.10.18",
78
79
  "@jsenv/plugin-minification": "1.7.10",
79
80
  "@jsenv/plugin-supervisor": "1.8.13",
80
- "@jsenv/plugin-transpilation": "1.6.1",
81
+ "@jsenv/plugin-transpilation": "1.6.2",
81
82
  "@jsenv/server": "17.6.3",
82
83
  "@jsenv/sourcemap": "1.4.2",
83
84
  "react-table": "7.8.0"
@@ -10,6 +10,11 @@ import { createKitchen } from "../../kitchen/kitchen.js";
10
10
  import { createJsenvPluginsController } from "../../plugins/jsenv_plugins_controller.js";
11
11
  import { getRuntimeFromRequest } from "./runtime_from_request.js";
12
12
 
13
+ // What the newest browser supports, and nothing less: the source untouched.
14
+ // A version no browser has, so that every feature known to runtime-compat
15
+ // counts as supported.
16
+ const UNKNOWN_CLIENT_RUNTIME_COMPAT = { chrome: "9999.0.0" };
17
+
13
18
  export const devServerPluginServeSourceFiles = ({
14
19
  packageDirectory,
15
20
  sourceDirectoryUrl,
@@ -70,14 +75,16 @@ export const devServerPluginServeSourceFiles = ({
70
75
  }
71
76
  });
72
77
  // A client we cannot identify (curl, fetch, a healthcheck, a proxy dropping
73
- // the user agent) is assumed to be one of the runtimes the project targets.
74
- // Treating it as a runtime supporting nothing would serve it the js module
75
- // fallback, breaking tooling perfectly capable of ES modules; an actual
76
- // ancient browser hiding its identity fails loudly instead, which is the
77
- // cheaper of the two mistakes.
78
+ // the user agent, the WebKit inspector re-requesting a page's resources
79
+ // under its own agent) is served the source as it is written. Taking the
80
+ // build targets instead would hand it the js module fallback and a heavy
81
+ // transpilation — and, when the same page mixes identified and
82
+ // unidentified requests, two incompatible versions of one module. An
83
+ // actual ancient browser hiding its identity fails loudly instead, which
84
+ // is the right failure for dev.
78
85
  const clientRuntimeCompat =
79
86
  runtimeName === "unknown"
80
- ? runtimeCompat
87
+ ? UNKNOWN_CLIENT_RUNTIME_COMPAT
81
88
  : { [runtimeName]: runtimeVersion };
82
89
 
83
90
  kitchen = createKitchen({
@@ -271,6 +278,41 @@ export const devServerPluginServeSourceFiles = ({
271
278
  request.resource,
272
279
  parentUrl,
273
280
  );
281
+ if (!reference) {
282
+ // Inline content ("page.html@L10C7-L14C16.js") has no file of its
283
+ // own: it is served from the reference its parent creates when it
284
+ // is cooked. Without a usable referer the parent is not known —
285
+ // devtools re-fetching a resource on its own, a second kitchen for
286
+ // the same page (the WebKit inspector sends its own user agent) —
287
+ // so it is derived from the url and cooked first.
288
+ const inlineParentUrl = getInlineContentParentUrl(requestedUrl);
289
+ if (inlineParentUrl) {
290
+ if (!kitchen.graph.getUrlInfo(inlineParentUrl)) {
291
+ const rootUrlInfo = kitchen.graph.rootUrlInfo;
292
+ const inlineParentWebUrl = WEB_URL_CONVERTER.asWebUrl(
293
+ inlineParentUrl,
294
+ {
295
+ origin: request.origin,
296
+ rootDirectoryUrl: sourceDirectoryUrl,
297
+ },
298
+ );
299
+ const parentReference =
300
+ rootUrlInfo.dependencies.createResolveAndFinalize({
301
+ trace: { message: parentUrl },
302
+ type: "http_request",
303
+ specifier: inlineParentWebUrl.slice(request.origin.length),
304
+ });
305
+ await parentReference.urlInfo.cook({
306
+ request,
307
+ reference: parentReference,
308
+ });
309
+ }
310
+ reference = kitchen.graph.inferReference(
311
+ request.resource,
312
+ inlineParentUrl,
313
+ );
314
+ }
315
+ }
274
316
  if (reference) {
275
317
  reference.urlInfo.context.request = request;
276
318
  reference.urlInfo.context.requestedUrl = requestedUrl;
@@ -555,3 +597,18 @@ const cacheIsDisabledInResponseHeader = (urlInfo) => {
555
597
  urlInfo.headers["cache-control"] === "no-cache"
556
598
  );
557
599
  };
600
+
601
+ // "dir/page.html@L10C7-L14C16.js" -> "dir/page.html" (search kept: it is the
602
+ // parent's). Null for anything else — the inline url grammar is the one
603
+ // generateUrlForInlineContent writes (@jsenv/ast).
604
+ const getInlineContentParentUrl = (url) => {
605
+ const urlObject = new URL(url);
606
+ const match = /^(.+)@[^@/]*?L\d+C\d+(?:-L\d+C\d+)?\.[a-z0-9]+$/.exec(
607
+ urlObject.pathname,
608
+ );
609
+ if (!match) {
610
+ return null;
611
+ }
612
+ urlObject.pathname = match[1];
613
+ return urlObject.href;
614
+ };