@jsenv/core 39.13.0 → 39.13.2
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/js/directory_listing.js +1 -1
- package/dist/jsenv_core.js +66 -48
- package/package.json +5 -5
- package/src/build/build_urls_generator.js +0 -1
- package/src/dev/start_dev_server.js +27 -3
- package/src/kitchen/kitchen.js +0 -19
- package/src/kitchen/url_graph/references.js +0 -2
- package/src/plugins/plugins.js +5 -2
- package/src/plugins/protocol_file/jsenv_plugin_directory_listing.js +12 -7
- package/src/plugins/protocol_file/jsenv_plugin_protocol_file.js +9 -7
- package/src/plugins/reference_analysis/jsenv_plugin_reference_analysis.js +1 -1
|
@@ -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,
|
package/dist/jsenv_core.js
CHANGED
|
@@ -2717,12 +2717,18 @@ const applyMatching = (pattern, string) => {
|
|
|
2717
2717
|
}
|
|
2718
2718
|
};
|
|
2719
2719
|
const matchOne = () => {
|
|
2720
|
-
// pattern consumed
|
|
2721
|
-
if (remainingPattern === ""
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2720
|
+
// pattern consumed
|
|
2721
|
+
if (remainingPattern === "") {
|
|
2722
|
+
if (remainingString === "") {
|
|
2723
|
+
return true; // string fully matched pattern
|
|
2724
|
+
}
|
|
2725
|
+
if (remainingString[0] === "?") {
|
|
2726
|
+
// match search params
|
|
2727
|
+
consumeRemainingString();
|
|
2728
|
+
|
|
2729
|
+
return true;
|
|
2730
|
+
}
|
|
2731
|
+
// if remainingString
|
|
2726
2732
|
return false; // fails because string longer than expect
|
|
2727
2733
|
}
|
|
2728
2734
|
// -- from this point pattern is not consumed --
|
|
@@ -13158,7 +13164,6 @@ const createReference = ({
|
|
|
13158
13164
|
specifierColumn,
|
|
13159
13165
|
baseUrl,
|
|
13160
13166
|
isOriginalPosition,
|
|
13161
|
-
isDirectRequest = false,
|
|
13162
13167
|
isEntryPoint = false,
|
|
13163
13168
|
isResourceHint = false,
|
|
13164
13169
|
// implicit references are not real references
|
|
@@ -13233,7 +13238,6 @@ const createReference = ({
|
|
|
13233
13238
|
specifierColumn,
|
|
13234
13239
|
isOriginalPosition,
|
|
13235
13240
|
baseUrl,
|
|
13236
|
-
isDirectRequest,
|
|
13237
13241
|
isEntryPoint,
|
|
13238
13242
|
isResourceHint,
|
|
13239
13243
|
isImplicit,
|
|
@@ -15012,25 +15016,6 @@ ${ANSI.color(reference.url, ANSI.YELLOW)}
|
|
|
15012
15016
|
`);
|
|
15013
15017
|
}
|
|
15014
15018
|
}
|
|
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
15019
|
redirect: {
|
|
15035
15020
|
if (reference.isImplicit && reference.isWeak) {
|
|
15036
15021
|
// not needed for implicit references that are not rendered anywhere
|
|
@@ -17857,7 +17842,7 @@ const jsenvPluginInlineContentFetcher = () => {
|
|
|
17857
17842
|
if (!urlInfo.isInline) {
|
|
17858
17843
|
return null;
|
|
17859
17844
|
}
|
|
17860
|
-
const
|
|
17845
|
+
const isDirectRequest = urlInfo.context.requestedUrl === urlInfo.url;
|
|
17861
17846
|
/*
|
|
17862
17847
|
* We want to find inline content but it's not straightforward
|
|
17863
17848
|
*
|
|
@@ -19430,6 +19415,11 @@ return {
|
|
|
19430
19415
|
/*
|
|
19431
19416
|
* NICE TO HAVE:
|
|
19432
19417
|
*
|
|
19418
|
+
* - when clicking the server root directory from the root directory
|
|
19419
|
+
* we should see "/..." in the url bar
|
|
19420
|
+
* instead we ses "@fs/"
|
|
19421
|
+
* everything still works but that would be cleaner
|
|
19422
|
+
*
|
|
19433
19423
|
* - when visiting urls outside server root directory the UI is messed up
|
|
19434
19424
|
*
|
|
19435
19425
|
* Let's say I visit file outside the server root directory that is in 404
|
|
@@ -19453,9 +19443,9 @@ const htmlFileUrlForDirectory = new URL(
|
|
|
19453
19443
|
);
|
|
19454
19444
|
|
|
19455
19445
|
const jsenvPluginDirectoryListing = ({
|
|
19456
|
-
|
|
19457
|
-
directoryListingUrlMocks,
|
|
19446
|
+
urlMocks = false,
|
|
19458
19447
|
autoreload = true,
|
|
19448
|
+
directoryContentMagicName,
|
|
19459
19449
|
}) => {
|
|
19460
19450
|
return {
|
|
19461
19451
|
name: "jsenv:directory_listing",
|
|
@@ -19473,10 +19463,10 @@ const jsenvPluginDirectoryListing = ({
|
|
|
19473
19463
|
fsStat = readEntryStatSync(url, { nullIfNotFound: true });
|
|
19474
19464
|
reference.fsStat = fsStat;
|
|
19475
19465
|
}
|
|
19476
|
-
const { request } = reference.ownerUrlInfo.context;
|
|
19466
|
+
const { request, requestedUrl } = reference.ownerUrlInfo.context;
|
|
19477
19467
|
if (!fsStat) {
|
|
19478
19468
|
if (
|
|
19479
|
-
|
|
19469
|
+
requestedUrl === url &&
|
|
19480
19470
|
request &&
|
|
19481
19471
|
request.headers["sec-fetch-dest"] === "document"
|
|
19482
19472
|
) {
|
|
@@ -19526,7 +19516,7 @@ const jsenvPluginDirectoryListing = ({
|
|
|
19526
19516
|
...generateDirectoryListingInjection(requestedUrl, {
|
|
19527
19517
|
autoreload,
|
|
19528
19518
|
request,
|
|
19529
|
-
|
|
19519
|
+
urlMocks,
|
|
19530
19520
|
directoryContentMagicName,
|
|
19531
19521
|
rootDirectoryUrl,
|
|
19532
19522
|
mainFilePath,
|
|
@@ -19605,7 +19595,7 @@ const generateDirectoryListingInjection = (
|
|
|
19605
19595
|
rootDirectoryUrl,
|
|
19606
19596
|
mainFilePath,
|
|
19607
19597
|
request,
|
|
19608
|
-
|
|
19598
|
+
urlMocks,
|
|
19609
19599
|
directoryContentMagicName,
|
|
19610
19600
|
autoreload,
|
|
19611
19601
|
enoent,
|
|
@@ -19744,7 +19734,7 @@ const generateDirectoryListingInjection = (
|
|
|
19744
19734
|
__DIRECTORY_LISTING__: {
|
|
19745
19735
|
enoentDetails,
|
|
19746
19736
|
navItems,
|
|
19747
|
-
|
|
19737
|
+
urlMocks,
|
|
19748
19738
|
directoryContentMagicName,
|
|
19749
19739
|
directoryUrl: firstExistingDirectoryUrl,
|
|
19750
19740
|
serverRootDirectoryUrl,
|
|
@@ -19946,11 +19936,10 @@ const resolveSymlink = (fileUrl) => {
|
|
|
19946
19936
|
const directoryContentMagicName = "...";
|
|
19947
19937
|
|
|
19948
19938
|
const jsenvPluginProtocolFile = ({
|
|
19949
|
-
supervisorEnabled,
|
|
19950
19939
|
magicExtensions,
|
|
19951
19940
|
magicDirectoryIndex,
|
|
19952
19941
|
preserveSymlinks,
|
|
19953
|
-
|
|
19942
|
+
directoryListing,
|
|
19954
19943
|
}) => {
|
|
19955
19944
|
return [
|
|
19956
19945
|
jsenvPluginFsRedirection({
|
|
@@ -20006,11 +19995,14 @@ const jsenvPluginProtocolFile = ({
|
|
|
20006
19995
|
);
|
|
20007
19996
|
},
|
|
20008
19997
|
},
|
|
20009
|
-
|
|
20010
|
-
|
|
20011
|
-
|
|
20012
|
-
|
|
20013
|
-
|
|
19998
|
+
...(directoryListing
|
|
19999
|
+
? [
|
|
20000
|
+
jsenvPluginDirectoryListing({
|
|
20001
|
+
...directoryListing,
|
|
20002
|
+
directoryContentMagicName,
|
|
20003
|
+
}),
|
|
20004
|
+
]
|
|
20005
|
+
: []),
|
|
20014
20006
|
{
|
|
20015
20007
|
name: "jsenv:directory_as_json",
|
|
20016
20008
|
appliesDuring: "*",
|
|
@@ -21446,7 +21438,7 @@ const getCorePlugins = ({
|
|
|
21446
21438
|
nodeEsmResolution = {},
|
|
21447
21439
|
magicExtensions,
|
|
21448
21440
|
magicDirectoryIndex,
|
|
21449
|
-
|
|
21441
|
+
directoryListing = true,
|
|
21450
21442
|
directoryReferenceEffect,
|
|
21451
21443
|
supervisor,
|
|
21452
21444
|
injections,
|
|
@@ -21474,6 +21466,9 @@ const getCorePlugins = ({
|
|
|
21474
21466
|
if (http === false) {
|
|
21475
21467
|
http = { include: false };
|
|
21476
21468
|
}
|
|
21469
|
+
if (directoryListing === true) {
|
|
21470
|
+
directoryListing = {};
|
|
21471
|
+
}
|
|
21477
21472
|
|
|
21478
21473
|
return [
|
|
21479
21474
|
jsenvPluginReferenceAnalysis(referenceAnalysis),
|
|
@@ -21492,7 +21487,7 @@ const getCorePlugins = ({
|
|
|
21492
21487
|
jsenvPluginProtocolFile({
|
|
21493
21488
|
magicExtensions,
|
|
21494
21489
|
magicDirectoryIndex,
|
|
21495
|
-
|
|
21490
|
+
directoryListing,
|
|
21496
21491
|
}),
|
|
21497
21492
|
{
|
|
21498
21493
|
name: "jsenv:resolve_root_as_main",
|
|
@@ -21653,7 +21648,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21653
21648
|
integer++;
|
|
21654
21649
|
nameCandidate = `${basename}${integer}${extension}`;
|
|
21655
21650
|
}
|
|
21656
|
-
hash = "";
|
|
21657
21651
|
const buildUrl = `${buildDirectoryUrl}${directoryPath}${nameCandidate}${search}${hash}`;
|
|
21658
21652
|
associateBuildUrl(url, buildUrl);
|
|
21659
21653
|
return buildUrl;
|
|
@@ -24151,7 +24145,7 @@ const startDevServer = async ({
|
|
|
24151
24145
|
supervisor = true,
|
|
24152
24146
|
magicExtensions,
|
|
24153
24147
|
magicDirectoryIndex,
|
|
24154
|
-
|
|
24148
|
+
directoryListing,
|
|
24155
24149
|
injections,
|
|
24156
24150
|
transpilation,
|
|
24157
24151
|
cacheControl = true,
|
|
@@ -24350,7 +24344,7 @@ const startDevServer = async ({
|
|
|
24350
24344
|
nodeEsmResolution,
|
|
24351
24345
|
magicExtensions,
|
|
24352
24346
|
magicDirectoryIndex,
|
|
24353
|
-
|
|
24347
|
+
directoryListing,
|
|
24354
24348
|
supervisor,
|
|
24355
24349
|
injections,
|
|
24356
24350
|
transpilation,
|
|
@@ -24424,6 +24418,11 @@ const startDevServer = async ({
|
|
|
24424
24418
|
// - it creates an implicit url info to the url without params
|
|
24425
24419
|
// - we never explicitely request the url without search param so it has no content
|
|
24426
24420
|
// in that case the underlying urlInfo cannot be invalidate by the implicit
|
|
24421
|
+
// we use modifiedTimestamp to detect if the url was loaded once
|
|
24422
|
+
// or is just here to be used later
|
|
24423
|
+
if (implicitUrlInfo.modifiedTimestamp) {
|
|
24424
|
+
return false;
|
|
24425
|
+
}
|
|
24427
24426
|
continue;
|
|
24428
24427
|
}
|
|
24429
24428
|
if (!implicitUrlInfo.isValid()) {
|
|
@@ -24466,6 +24465,20 @@ const startDevServer = async ({
|
|
|
24466
24465
|
if (responseFromPlugin) {
|
|
24467
24466
|
return responseFromPlugin;
|
|
24468
24467
|
}
|
|
24468
|
+
const { rootDirectoryUrl, mainFilePath } = kitchen.context;
|
|
24469
|
+
let requestResource = request.resource;
|
|
24470
|
+
let requestedUrl;
|
|
24471
|
+
if (requestResource.startsWith("/@fs/")) {
|
|
24472
|
+
const fsRootRelativeUrl = requestResource.slice("/@fs/".length);
|
|
24473
|
+
requestedUrl = `file:///${fsRootRelativeUrl}`;
|
|
24474
|
+
} else {
|
|
24475
|
+
const requestedUrlObject = new URL(
|
|
24476
|
+
requestResource === "/" ? mainFilePath : requestResource.slice(1),
|
|
24477
|
+
rootDirectoryUrl,
|
|
24478
|
+
);
|
|
24479
|
+
requestedUrlObject.searchParams.delete("hot");
|
|
24480
|
+
requestedUrl = requestedUrlObject.href;
|
|
24481
|
+
}
|
|
24469
24482
|
const { referer } = request.headers;
|
|
24470
24483
|
const parentUrl = referer
|
|
24471
24484
|
? WEB_URL_CONVERTER.asFileUrl(referer, {
|
|
@@ -24477,15 +24490,20 @@ const startDevServer = async ({
|
|
|
24477
24490
|
request.resource,
|
|
24478
24491
|
parentUrl,
|
|
24479
24492
|
);
|
|
24480
|
-
if (
|
|
24493
|
+
if (reference) {
|
|
24494
|
+
reference.urlInfo.context.request = request;
|
|
24495
|
+
reference.urlInfo.context.requestedUrl = requestedUrl;
|
|
24496
|
+
} else {
|
|
24481
24497
|
const rootUrlInfo = kitchen.graph.rootUrlInfo;
|
|
24482
24498
|
rootUrlInfo.context.request = request;
|
|
24499
|
+
rootUrlInfo.context.requestedUrl = requestedUrl;
|
|
24483
24500
|
reference = rootUrlInfo.dependencies.createResolveAndFinalize({
|
|
24484
24501
|
trace: { message: parentUrl },
|
|
24485
24502
|
type: "http_request",
|
|
24486
24503
|
specifier: request.resource,
|
|
24487
24504
|
});
|
|
24488
24505
|
rootUrlInfo.context.request = null;
|
|
24506
|
+
rootUrlInfo.context.requestedUrl = null;
|
|
24489
24507
|
}
|
|
24490
24508
|
const urlInfo = reference.urlInfo;
|
|
24491
24509
|
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.
|
|
3
|
+
"version": "39.13.2",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -70,20 +70,20 @@
|
|
|
70
70
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
71
71
|
"@jsenv/abort": "4.3.0",
|
|
72
72
|
"@jsenv/ast": "6.5.0",
|
|
73
|
-
"@jsenv/filesystem": "4.13.
|
|
73
|
+
"@jsenv/filesystem": "4.13.3",
|
|
74
74
|
"@jsenv/humanize": "1.2.8",
|
|
75
75
|
"@jsenv/importmap": "1.2.1",
|
|
76
76
|
"@jsenv/integrity": "0.0.2",
|
|
77
77
|
"@jsenv/js-module-fallback": "1.3.57",
|
|
78
78
|
"@jsenv/node-esm-resolution": "1.0.6",
|
|
79
|
-
"@jsenv/plugin-bundling": "2.7.
|
|
79
|
+
"@jsenv/plugin-bundling": "2.7.25",
|
|
80
80
|
"@jsenv/plugin-minification": "1.5.13",
|
|
81
81
|
"@jsenv/plugin-supervisor": "1.6.4",
|
|
82
82
|
"@jsenv/plugin-transpilation": "1.4.93",
|
|
83
83
|
"@jsenv/runtime-compat": "1.3.1",
|
|
84
|
-
"@jsenv/server": "15.5.
|
|
84
|
+
"@jsenv/server": "15.5.1",
|
|
85
85
|
"@jsenv/sourcemap": "1.2.30",
|
|
86
|
-
"@jsenv/url-meta": "8.5.
|
|
86
|
+
"@jsenv/url-meta": "8.5.3",
|
|
87
87
|
"@jsenv/urls": "2.6.0",
|
|
88
88
|
"@jsenv/utils": "2.1.2",
|
|
89
89
|
"string-width": "7.2.0"
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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 (
|
|
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"];
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -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,
|
package/src/plugins/plugins.js
CHANGED
|
@@ -32,7 +32,7 @@ export const getCorePlugins = ({
|
|
|
32
32
|
nodeEsmResolution = {},
|
|
33
33
|
magicExtensions,
|
|
34
34
|
magicDirectoryIndex,
|
|
35
|
-
|
|
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
|
-
|
|
84
|
+
directoryListing,
|
|
82
85
|
}),
|
|
83
86
|
{
|
|
84
87
|
name: "jsenv:resolve_root_as_main",
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* NICE TO HAVE:
|
|
3
3
|
*
|
|
4
|
+
* - when clicking the server root directory from the root directory
|
|
5
|
+
* we should see "/..." in the url bar
|
|
6
|
+
* instead we ses "@fs/"
|
|
7
|
+
* everything still works but that would be cleaner
|
|
8
|
+
*
|
|
4
9
|
* - when visiting urls outside server root directory the UI is messed up
|
|
5
10
|
*
|
|
6
11
|
* Let's say I visit file outside the server root directory that is in 404
|
|
@@ -41,9 +46,9 @@ const htmlFileUrlForDirectory = new URL(
|
|
|
41
46
|
);
|
|
42
47
|
|
|
43
48
|
export const jsenvPluginDirectoryListing = ({
|
|
44
|
-
|
|
45
|
-
directoryListingUrlMocks,
|
|
49
|
+
urlMocks = false,
|
|
46
50
|
autoreload = true,
|
|
51
|
+
directoryContentMagicName,
|
|
47
52
|
}) => {
|
|
48
53
|
return {
|
|
49
54
|
name: "jsenv:directory_listing",
|
|
@@ -61,10 +66,10 @@ export const jsenvPluginDirectoryListing = ({
|
|
|
61
66
|
fsStat = readEntryStatSync(url, { nullIfNotFound: true });
|
|
62
67
|
reference.fsStat = fsStat;
|
|
63
68
|
}
|
|
64
|
-
const { request } = reference.ownerUrlInfo.context;
|
|
69
|
+
const { request, requestedUrl } = reference.ownerUrlInfo.context;
|
|
65
70
|
if (!fsStat) {
|
|
66
71
|
if (
|
|
67
|
-
|
|
72
|
+
requestedUrl === url &&
|
|
68
73
|
request &&
|
|
69
74
|
request.headers["sec-fetch-dest"] === "document"
|
|
70
75
|
) {
|
|
@@ -114,7 +119,7 @@ export const jsenvPluginDirectoryListing = ({
|
|
|
114
119
|
...generateDirectoryListingInjection(requestedUrl, {
|
|
115
120
|
autoreload,
|
|
116
121
|
request,
|
|
117
|
-
|
|
122
|
+
urlMocks,
|
|
118
123
|
directoryContentMagicName,
|
|
119
124
|
rootDirectoryUrl,
|
|
120
125
|
mainFilePath,
|
|
@@ -193,7 +198,7 @@ const generateDirectoryListingInjection = (
|
|
|
193
198
|
rootDirectoryUrl,
|
|
194
199
|
mainFilePath,
|
|
195
200
|
request,
|
|
196
|
-
|
|
201
|
+
urlMocks,
|
|
197
202
|
directoryContentMagicName,
|
|
198
203
|
autoreload,
|
|
199
204
|
enoent,
|
|
@@ -332,7 +337,7 @@ const generateDirectoryListingInjection = (
|
|
|
332
337
|
__DIRECTORY_LISTING__: {
|
|
333
338
|
enoentDetails,
|
|
334
339
|
navItems,
|
|
335
|
-
|
|
340
|
+
urlMocks,
|
|
336
341
|
directoryContentMagicName,
|
|
337
342
|
directoryUrl: firstExistingDirectoryUrl,
|
|
338
343
|
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
|
-
|
|
15
|
+
directoryListing,
|
|
17
16
|
}) => {
|
|
18
17
|
return [
|
|
19
18
|
jsenvPluginFsRedirection({
|
|
@@ -69,11 +68,14 @@ export const jsenvPluginProtocolFile = ({
|
|
|
69
68
|
);
|
|
70
69
|
},
|
|
71
70
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
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
|
*
|