@jsenv/core 39.13.0 → 39.13.1

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.
@@ -8,7 +8,7 @@ var f=0;function u(e,t,n,o,i,u){t||(t={});var a,c,p=t;if("ref"in p)for(c in p={}
8
8
 
9
9
  const directoryIconUrl = new URL("../other/dir.png", import.meta.url).href;
10
10
  const fileIconUrl = new URL("../other/file.png", import.meta.url).href;
11
- const homeIconUrl = new URL("../other/home.svg", import.meta.url).href;
11
+ const homeIconUrl = new URL("../other/home.svg#root", import.meta.url).href;
12
12
  let {
13
13
  navItems,
14
14
  mainFilePath,
@@ -13158,7 +13158,6 @@ const createReference = ({
13158
13158
  specifierColumn,
13159
13159
  baseUrl,
13160
13160
  isOriginalPosition,
13161
- isDirectRequest = false,
13162
13161
  isEntryPoint = false,
13163
13162
  isResourceHint = false,
13164
13163
  // implicit references are not real references
@@ -13233,7 +13232,6 @@ const createReference = ({
13233
13232
  specifierColumn,
13234
13233
  isOriginalPosition,
13235
13234
  baseUrl,
13236
- isDirectRequest,
13237
13235
  isEntryPoint,
13238
13236
  isResourceHint,
13239
13237
  isImplicit,
@@ -15012,25 +15010,6 @@ ${ANSI.color(reference.url, ANSI.YELLOW)}
15012
15010
  `);
15013
15011
  }
15014
15012
  }
15015
- const request = kitchen.context.request;
15016
- if (request) {
15017
- let requestResource = request.resource;
15018
- let requestedUrl;
15019
- if (requestResource.startsWith("/@fs/")) {
15020
- const fsRootRelativeUrl = requestResource.slice("/@fs/".length);
15021
- requestedUrl = `file:///${fsRootRelativeUrl}`;
15022
- } else {
15023
- const requestedUrlObject = new URL(
15024
- requestResource === "/" ? mainFilePath : requestResource.slice(1),
15025
- rootDirectoryUrl,
15026
- );
15027
- requestedUrlObject.searchParams.delete("hot");
15028
- requestedUrl = requestedUrlObject.href;
15029
- }
15030
- if (requestedUrl === reference.url) {
15031
- reference.isDirectRequest = true;
15032
- }
15033
- }
15034
15013
  redirect: {
15035
15014
  if (reference.isImplicit && reference.isWeak) {
15036
15015
  // not needed for implicit references that are not rendered anywhere
@@ -17857,7 +17836,7 @@ const jsenvPluginInlineContentFetcher = () => {
17857
17836
  if (!urlInfo.isInline) {
17858
17837
  return null;
17859
17838
  }
17860
- const { isDirectRequest } = urlInfo.lastReference;
17839
+ const isDirectRequest = urlInfo.context.requestedUrl === urlInfo.url;
17861
17840
  /*
17862
17841
  * We want to find inline content but it's not straightforward
17863
17842
  *
@@ -19453,9 +19432,9 @@ const htmlFileUrlForDirectory = new URL(
19453
19432
  );
19454
19433
 
19455
19434
  const jsenvPluginDirectoryListing = ({
19456
- directoryContentMagicName,
19457
- directoryListingUrlMocks,
19435
+ urlMocks = false,
19458
19436
  autoreload = true,
19437
+ directoryContentMagicName,
19459
19438
  }) => {
19460
19439
  return {
19461
19440
  name: "jsenv:directory_listing",
@@ -19473,10 +19452,10 @@ const jsenvPluginDirectoryListing = ({
19473
19452
  fsStat = readEntryStatSync(url, { nullIfNotFound: true });
19474
19453
  reference.fsStat = fsStat;
19475
19454
  }
19476
- const { request } = reference.ownerUrlInfo.context;
19455
+ const { request, requestedUrl } = reference.ownerUrlInfo.context;
19477
19456
  if (!fsStat) {
19478
19457
  if (
19479
- reference.isDirectRequest &&
19458
+ requestedUrl === url &&
19480
19459
  request &&
19481
19460
  request.headers["sec-fetch-dest"] === "document"
19482
19461
  ) {
@@ -19526,7 +19505,7 @@ const jsenvPluginDirectoryListing = ({
19526
19505
  ...generateDirectoryListingInjection(requestedUrl, {
19527
19506
  autoreload,
19528
19507
  request,
19529
- directoryListingUrlMocks,
19508
+ urlMocks,
19530
19509
  directoryContentMagicName,
19531
19510
  rootDirectoryUrl,
19532
19511
  mainFilePath,
@@ -19605,7 +19584,7 @@ const generateDirectoryListingInjection = (
19605
19584
  rootDirectoryUrl,
19606
19585
  mainFilePath,
19607
19586
  request,
19608
- directoryListingUrlMocks,
19587
+ urlMocks,
19609
19588
  directoryContentMagicName,
19610
19589
  autoreload,
19611
19590
  enoent,
@@ -19744,7 +19723,7 @@ const generateDirectoryListingInjection = (
19744
19723
  __DIRECTORY_LISTING__: {
19745
19724
  enoentDetails,
19746
19725
  navItems,
19747
- directoryListingUrlMocks,
19726
+ urlMocks,
19748
19727
  directoryContentMagicName,
19749
19728
  directoryUrl: firstExistingDirectoryUrl,
19750
19729
  serverRootDirectoryUrl,
@@ -19946,11 +19925,10 @@ const resolveSymlink = (fileUrl) => {
19946
19925
  const directoryContentMagicName = "...";
19947
19926
 
19948
19927
  const jsenvPluginProtocolFile = ({
19949
- supervisorEnabled,
19950
19928
  magicExtensions,
19951
19929
  magicDirectoryIndex,
19952
19930
  preserveSymlinks,
19953
- directoryListingUrlMocks,
19931
+ directoryListing,
19954
19932
  }) => {
19955
19933
  return [
19956
19934
  jsenvPluginFsRedirection({
@@ -20006,11 +19984,14 @@ const jsenvPluginProtocolFile = ({
20006
19984
  );
20007
19985
  },
20008
19986
  },
20009
- jsenvPluginDirectoryListing({
20010
- supervisorEnabled,
20011
- directoryContentMagicName,
20012
- directoryListingUrlMocks,
20013
- }),
19987
+ ...(directoryListing
19988
+ ? [
19989
+ jsenvPluginDirectoryListing({
19990
+ ...directoryListing,
19991
+ directoryContentMagicName,
19992
+ }),
19993
+ ]
19994
+ : []),
20014
19995
  {
20015
19996
  name: "jsenv:directory_as_json",
20016
19997
  appliesDuring: "*",
@@ -21446,7 +21427,7 @@ const getCorePlugins = ({
21446
21427
  nodeEsmResolution = {},
21447
21428
  magicExtensions,
21448
21429
  magicDirectoryIndex,
21449
- directoryListingUrlMocks,
21430
+ directoryListing = true,
21450
21431
  directoryReferenceEffect,
21451
21432
  supervisor,
21452
21433
  injections,
@@ -21474,6 +21455,9 @@ const getCorePlugins = ({
21474
21455
  if (http === false) {
21475
21456
  http = { include: false };
21476
21457
  }
21458
+ if (directoryListing === true) {
21459
+ directoryListing = {};
21460
+ }
21477
21461
 
21478
21462
  return [
21479
21463
  jsenvPluginReferenceAnalysis(referenceAnalysis),
@@ -21492,7 +21476,7 @@ const getCorePlugins = ({
21492
21476
  jsenvPluginProtocolFile({
21493
21477
  magicExtensions,
21494
21478
  magicDirectoryIndex,
21495
- directoryListingUrlMocks,
21479
+ directoryListing,
21496
21480
  }),
21497
21481
  {
21498
21482
  name: "jsenv:resolve_root_as_main",
@@ -21653,7 +21637,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
21653
21637
  integer++;
21654
21638
  nameCandidate = `${basename}${integer}${extension}`;
21655
21639
  }
21656
- hash = "";
21657
21640
  const buildUrl = `${buildDirectoryUrl}${directoryPath}${nameCandidate}${search}${hash}`;
21658
21641
  associateBuildUrl(url, buildUrl);
21659
21642
  return buildUrl;
@@ -24151,7 +24134,7 @@ const startDevServer = async ({
24151
24134
  supervisor = true,
24152
24135
  magicExtensions,
24153
24136
  magicDirectoryIndex,
24154
- directoryListingUrlMocks,
24137
+ directoryListing,
24155
24138
  injections,
24156
24139
  transpilation,
24157
24140
  cacheControl = true,
@@ -24350,7 +24333,7 @@ const startDevServer = async ({
24350
24333
  nodeEsmResolution,
24351
24334
  magicExtensions,
24352
24335
  magicDirectoryIndex,
24353
- directoryListingUrlMocks,
24336
+ directoryListing,
24354
24337
  supervisor,
24355
24338
  injections,
24356
24339
  transpilation,
@@ -24424,6 +24407,11 @@ const startDevServer = async ({
24424
24407
  // - it creates an implicit url info to the url without params
24425
24408
  // - we never explicitely request the url without search param so it has no content
24426
24409
  // in that case the underlying urlInfo cannot be invalidate by the implicit
24410
+ // we use modifiedTimestamp to detect if the url was loaded once
24411
+ // or is just here to be used later
24412
+ if (implicitUrlInfo.modifiedTimestamp) {
24413
+ return false;
24414
+ }
24427
24415
  continue;
24428
24416
  }
24429
24417
  if (!implicitUrlInfo.isValid()) {
@@ -24466,6 +24454,20 @@ const startDevServer = async ({
24466
24454
  if (responseFromPlugin) {
24467
24455
  return responseFromPlugin;
24468
24456
  }
24457
+ const { rootDirectoryUrl, mainFilePath } = kitchen.context;
24458
+ let requestResource = request.resource;
24459
+ let requestedUrl;
24460
+ if (requestResource.startsWith("/@fs/")) {
24461
+ const fsRootRelativeUrl = requestResource.slice("/@fs/".length);
24462
+ requestedUrl = `file:///${fsRootRelativeUrl}`;
24463
+ } else {
24464
+ const requestedUrlObject = new URL(
24465
+ requestResource === "/" ? mainFilePath : requestResource.slice(1),
24466
+ rootDirectoryUrl,
24467
+ );
24468
+ requestedUrlObject.searchParams.delete("hot");
24469
+ requestedUrl = requestedUrlObject.href;
24470
+ }
24469
24471
  const { referer } = request.headers;
24470
24472
  const parentUrl = referer
24471
24473
  ? WEB_URL_CONVERTER.asFileUrl(referer, {
@@ -24477,15 +24479,20 @@ const startDevServer = async ({
24477
24479
  request.resource,
24478
24480
  parentUrl,
24479
24481
  );
24480
- if (!reference) {
24482
+ if (reference) {
24483
+ reference.urlInfo.context.request = request;
24484
+ reference.urlInfo.context.requestedUrl = requestedUrl;
24485
+ } else {
24481
24486
  const rootUrlInfo = kitchen.graph.rootUrlInfo;
24482
24487
  rootUrlInfo.context.request = request;
24488
+ rootUrlInfo.context.requestedUrl = requestedUrl;
24483
24489
  reference = rootUrlInfo.dependencies.createResolveAndFinalize({
24484
24490
  trace: { message: parentUrl },
24485
24491
  type: "http_request",
24486
24492
  specifier: request.resource,
24487
24493
  });
24488
24494
  rootUrlInfo.context.request = null;
24495
+ rootUrlInfo.context.requestedUrl = null;
24489
24496
  }
24490
24497
  const urlInfo = reference.urlInfo;
24491
24498
  const ifNoneMatch = request.headers["if-none-match"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "39.13.0",
3
+ "version": "39.13.1",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -77,7 +77,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
77
77
  integer++;
78
78
  nameCandidate = `${basename}${integer}${extension}`;
79
79
  }
80
- hash = "";
81
80
  const buildUrl = `${buildDirectoryUrl}${directoryPath}${nameCandidate}${search}${hash}`;
82
81
  associateBuildUrl(url, buildUrl);
83
82
  return buildUrl;
@@ -69,7 +69,7 @@ export const startDevServer = async ({
69
69
  supervisor = true,
70
70
  magicExtensions,
71
71
  magicDirectoryIndex,
72
- directoryListingUrlMocks,
72
+ directoryListing,
73
73
  injections,
74
74
  transpilation,
75
75
  cacheControl = true,
@@ -269,7 +269,7 @@ export const startDevServer = async ({
269
269
  nodeEsmResolution,
270
270
  magicExtensions,
271
271
  magicDirectoryIndex,
272
- directoryListingUrlMocks,
272
+ directoryListing,
273
273
  supervisor,
274
274
  injections,
275
275
  transpilation,
@@ -343,6 +343,11 @@ export const startDevServer = async ({
343
343
  // - it creates an implicit url info to the url without params
344
344
  // - we never explicitely request the url without search param so it has no content
345
345
  // in that case the underlying urlInfo cannot be invalidate by the implicit
346
+ // we use modifiedTimestamp to detect if the url was loaded once
347
+ // or is just here to be used later
348
+ if (implicitUrlInfo.modifiedTimestamp) {
349
+ return false;
350
+ }
346
351
  continue;
347
352
  }
348
353
  if (!implicitUrlInfo.isValid()) {
@@ -385,6 +390,20 @@ export const startDevServer = async ({
385
390
  if (responseFromPlugin) {
386
391
  return responseFromPlugin;
387
392
  }
393
+ const { rootDirectoryUrl, mainFilePath } = kitchen.context;
394
+ let requestResource = request.resource;
395
+ let requestedUrl;
396
+ if (requestResource.startsWith("/@fs/")) {
397
+ const fsRootRelativeUrl = requestResource.slice("/@fs/".length);
398
+ requestedUrl = `file:///${fsRootRelativeUrl}`;
399
+ } else {
400
+ const requestedUrlObject = new URL(
401
+ requestResource === "/" ? mainFilePath : requestResource.slice(1),
402
+ rootDirectoryUrl,
403
+ );
404
+ requestedUrlObject.searchParams.delete("hot");
405
+ requestedUrl = requestedUrlObject.href;
406
+ }
388
407
  const { referer } = request.headers;
389
408
  const parentUrl = referer
390
409
  ? WEB_URL_CONVERTER.asFileUrl(referer, {
@@ -396,15 +415,20 @@ export const startDevServer = async ({
396
415
  request.resource,
397
416
  parentUrl,
398
417
  );
399
- if (!reference) {
418
+ if (reference) {
419
+ reference.urlInfo.context.request = request;
420
+ reference.urlInfo.context.requestedUrl = requestedUrl;
421
+ } else {
400
422
  const rootUrlInfo = kitchen.graph.rootUrlInfo;
401
423
  rootUrlInfo.context.request = request;
424
+ rootUrlInfo.context.requestedUrl = requestedUrl;
402
425
  reference = rootUrlInfo.dependencies.createResolveAndFinalize({
403
426
  trace: { message: parentUrl },
404
427
  type: "http_request",
405
428
  specifier: request.resource,
406
429
  });
407
430
  rootUrlInfo.context.request = null;
431
+ rootUrlInfo.context.requestedUrl = null;
408
432
  }
409
433
  const urlInfo = reference.urlInfo;
410
434
  const ifNoneMatch = request.headers["if-none-match"];
@@ -198,25 +198,6 @@ ${ANSI.color(reference.url, ANSI.YELLOW)}
198
198
  `);
199
199
  }
200
200
  }
201
- const request = kitchen.context.request;
202
- if (request) {
203
- let requestResource = request.resource;
204
- let requestedUrl;
205
- if (requestResource.startsWith("/@fs/")) {
206
- const fsRootRelativeUrl = requestResource.slice("/@fs/".length);
207
- requestedUrl = `file:///${fsRootRelativeUrl}`;
208
- } else {
209
- const requestedUrlObject = new URL(
210
- requestResource === "/" ? mainFilePath : requestResource.slice(1),
211
- rootDirectoryUrl,
212
- );
213
- requestedUrlObject.searchParams.delete("hot");
214
- requestedUrl = requestedUrlObject.href;
215
- }
216
- if (requestedUrl === reference.url) {
217
- reference.isDirectRequest = true;
218
- }
219
- }
220
201
  redirect: {
221
202
  if (reference.isImplicit && reference.isWeak) {
222
203
  // not needed for implicit references that are not rendered anywhere
@@ -274,7 +274,6 @@ const createReference = ({
274
274
  specifierColumn,
275
275
  baseUrl,
276
276
  isOriginalPosition,
277
- isDirectRequest = false,
278
277
  isEntryPoint = false,
279
278
  isResourceHint = false,
280
279
  // implicit references are not real references
@@ -349,7 +348,6 @@ const createReference = ({
349
348
  specifierColumn,
350
349
  isOriginalPosition,
351
350
  baseUrl,
352
- isDirectRequest,
353
351
  isEntryPoint,
354
352
  isResourceHint,
355
353
  isImplicit,
@@ -32,7 +32,7 @@ export const getCorePlugins = ({
32
32
  nodeEsmResolution = {},
33
33
  magicExtensions,
34
34
  magicDirectoryIndex,
35
- directoryListingUrlMocks,
35
+ directoryListing = true,
36
36
  directoryReferenceEffect,
37
37
  supervisor,
38
38
  injections,
@@ -60,6 +60,9 @@ export const getCorePlugins = ({
60
60
  if (http === false) {
61
61
  http = { include: false };
62
62
  }
63
+ if (directoryListing === true) {
64
+ directoryListing = {};
65
+ }
63
66
 
64
67
  return [
65
68
  jsenvPluginReferenceAnalysis(referenceAnalysis),
@@ -78,7 +81,7 @@ export const getCorePlugins = ({
78
81
  jsenvPluginProtocolFile({
79
82
  magicExtensions,
80
83
  magicDirectoryIndex,
81
- directoryListingUrlMocks,
84
+ directoryListing,
82
85
  }),
83
86
  {
84
87
  name: "jsenv:resolve_root_as_main",
@@ -41,9 +41,9 @@ const htmlFileUrlForDirectory = new URL(
41
41
  );
42
42
 
43
43
  export const jsenvPluginDirectoryListing = ({
44
- directoryContentMagicName,
45
- directoryListingUrlMocks,
44
+ urlMocks = false,
46
45
  autoreload = true,
46
+ directoryContentMagicName,
47
47
  }) => {
48
48
  return {
49
49
  name: "jsenv:directory_listing",
@@ -61,10 +61,10 @@ export const jsenvPluginDirectoryListing = ({
61
61
  fsStat = readEntryStatSync(url, { nullIfNotFound: true });
62
62
  reference.fsStat = fsStat;
63
63
  }
64
- const { request } = reference.ownerUrlInfo.context;
64
+ const { request, requestedUrl } = reference.ownerUrlInfo.context;
65
65
  if (!fsStat) {
66
66
  if (
67
- reference.isDirectRequest &&
67
+ requestedUrl === url &&
68
68
  request &&
69
69
  request.headers["sec-fetch-dest"] === "document"
70
70
  ) {
@@ -114,7 +114,7 @@ export const jsenvPluginDirectoryListing = ({
114
114
  ...generateDirectoryListingInjection(requestedUrl, {
115
115
  autoreload,
116
116
  request,
117
- directoryListingUrlMocks,
117
+ urlMocks,
118
118
  directoryContentMagicName,
119
119
  rootDirectoryUrl,
120
120
  mainFilePath,
@@ -193,7 +193,7 @@ const generateDirectoryListingInjection = (
193
193
  rootDirectoryUrl,
194
194
  mainFilePath,
195
195
  request,
196
- directoryListingUrlMocks,
196
+ urlMocks,
197
197
  directoryContentMagicName,
198
198
  autoreload,
199
199
  enoent,
@@ -332,7 +332,7 @@ const generateDirectoryListingInjection = (
332
332
  __DIRECTORY_LISTING__: {
333
333
  enoentDetails,
334
334
  navItems,
335
- directoryListingUrlMocks,
335
+ urlMocks,
336
336
  directoryContentMagicName,
337
337
  directoryUrl: firstExistingDirectoryUrl,
338
338
  serverRootDirectoryUrl,
@@ -9,11 +9,10 @@ import { jsenvPluginFsRedirection } from "./jsenv_plugin_fs_redirection.js";
9
9
  const directoryContentMagicName = "...";
10
10
 
11
11
  export const jsenvPluginProtocolFile = ({
12
- supervisorEnabled,
13
12
  magicExtensions,
14
13
  magicDirectoryIndex,
15
14
  preserveSymlinks,
16
- directoryListingUrlMocks,
15
+ directoryListing,
17
16
  }) => {
18
17
  return [
19
18
  jsenvPluginFsRedirection({
@@ -69,11 +68,14 @@ export const jsenvPluginProtocolFile = ({
69
68
  );
70
69
  },
71
70
  },
72
- jsenvPluginDirectoryListing({
73
- supervisorEnabled,
74
- directoryContentMagicName,
75
- directoryListingUrlMocks,
76
- }),
71
+ ...(directoryListing
72
+ ? [
73
+ jsenvPluginDirectoryListing({
74
+ ...directoryListing,
75
+ directoryContentMagicName,
76
+ }),
77
+ ]
78
+ : []),
77
79
  {
78
80
  name: "jsenv:directory_as_json",
79
81
  appliesDuring: "*",
@@ -41,7 +41,7 @@ const jsenvPluginInlineContentFetcher = () => {
41
41
  if (!urlInfo.isInline) {
42
42
  return null;
43
43
  }
44
- const { isDirectRequest } = urlInfo.lastReference;
44
+ const isDirectRequest = urlInfo.context.requestedUrl === urlInfo.url;
45
45
  /*
46
46
  * We want to find inline content but it's not straightforward
47
47
  *