@jsenv/core 40.12.13 → 41.0.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/build/build.js +267 -469
- package/dist/client/import_meta_css/import_meta_css_build.js +41 -12
- package/dist/client/import_meta_css/import_meta_css_dev.js +43 -31
- package/dist/start_build_server/start_build_server.js +7 -7
- package/dist/start_dev_server/start_dev_server.js +255 -448
- package/package.json +2 -2
- package/src/build/build.js +16 -15
- package/src/build/build_specifier_manager.js +11 -10
- package/src/build/mappings_injection.js +12 -11
- package/src/build/start_build_server.js +9 -9
- package/src/dev/start_dev_server.js +26 -26
- package/src/kitchen/errors.js +11 -11
- package/src/kitchen/kitchen.js +29 -21
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +1 -1
- package/src/plugins/autoreload_on_server_restart/jsenv_plugin_autoreload_on_server_restart.js +1 -1
- package/src/plugins/chrome_devtools_json/jsenv_plugin_chrome_devtools_json.js +1 -1
- package/src/plugins/import_meta_css/client/import_meta_css_build.js +41 -12
- package/src/plugins/import_meta_css/client/import_meta_css_dev.js +43 -31
- package/src/plugins/import_meta_css/jsenv_plugin_import_meta_css.js +78 -17
- package/src/plugins/jsenv_plugins_controller.js +197 -0
- package/src/plugins/protocol_file/jsenv_plugin_directory_listing.js +1 -1
- package/src/plugins/server_events/jsenv_plugin_server_events.js +1 -1
- package/src/plugins/plugin_controller.js +0 -458
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "41.0.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@jsenv/plugin-minification": "1.7.3",
|
|
82
82
|
"@jsenv/plugin-supervisor": "1.7.15",
|
|
83
83
|
"@jsenv/plugin-transpilation": "1.5.70",
|
|
84
|
-
"@jsenv/server": "
|
|
84
|
+
"@jsenv/server": "17.0.0",
|
|
85
85
|
"@jsenv/sourcemap": "1.3.17",
|
|
86
86
|
"react-table": "7.8.0"
|
|
87
87
|
},
|
package/src/build/build.js
CHANGED
|
@@ -66,9 +66,9 @@ import { GRAPH_VISITOR } from "../kitchen/url_graph/url_graph_visitor.js";
|
|
|
66
66
|
import { jsenvPluginDirectoryReferenceEffect } from "../plugins/directory_reference_effect/jsenv_plugin_directory_reference_effect.js";
|
|
67
67
|
import { jsenvPluginInlining } from "../plugins/inlining/jsenv_plugin_inlining.js";
|
|
68
68
|
import {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} from "../plugins/
|
|
69
|
+
createJsenvPluginsController,
|
|
70
|
+
createJsenvPluginStore,
|
|
71
|
+
} from "../plugins/jsenv_plugins_controller.js";
|
|
72
72
|
import { getCorePlugins } from "../plugins/plugins.js";
|
|
73
73
|
import { jsenvPluginReferenceAnalysis } from "../plugins/reference_analysis/jsenv_plugin_reference_analysis.js";
|
|
74
74
|
import { renderBuildDoneLog } from "./build_content_report.js";
|
|
@@ -1109,7 +1109,7 @@ const prepareEntryPointBuild = async (
|
|
|
1109
1109
|
});
|
|
1110
1110
|
|
|
1111
1111
|
let _getOtherEntryBuildInfo;
|
|
1112
|
-
const
|
|
1112
|
+
const rawJsenvPluginStore = await createJsenvPluginStore([
|
|
1113
1113
|
...(mappings ? [jsenvPluginMappings(mappings)] : []),
|
|
1114
1114
|
{
|
|
1115
1115
|
name: "jsenv:other_entry_point_build_during_craft",
|
|
@@ -1155,11 +1155,11 @@ const prepareEntryPointBuild = async (
|
|
|
1155
1155
|
packageSideEffects,
|
|
1156
1156
|
}),
|
|
1157
1157
|
]);
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1158
|
+
const rawJsenvPluginsController = await createJsenvPluginsController(
|
|
1159
|
+
rawJsenvPluginStore,
|
|
1160
1160
|
rawKitchen,
|
|
1161
1161
|
);
|
|
1162
|
-
rawKitchen.
|
|
1162
|
+
rawKitchen.setJsenvPluginsController(rawJsenvPluginsController);
|
|
1163
1163
|
|
|
1164
1164
|
const rawRootUrlInfo = rawKitchen.graph.rootUrlInfo;
|
|
1165
1165
|
let entryReference;
|
|
@@ -1227,7 +1227,7 @@ const prepareEntryPointBuild = async (
|
|
|
1227
1227
|
rawKitchen.graph.getUrlInfo(entryReference.url).type === "html" &&
|
|
1228
1228
|
rawKitchen.context.isSupportedOnCurrentClients("importmap"),
|
|
1229
1229
|
});
|
|
1230
|
-
const
|
|
1230
|
+
const finalJsenvPluginStore = await createJsenvPluginStore([
|
|
1231
1231
|
jsenvPluginReferenceAnalysis({
|
|
1232
1232
|
...referenceAnalysis,
|
|
1233
1233
|
fetchInlineUrls: false,
|
|
@@ -1249,7 +1249,7 @@ const prepareEntryPointBuild = async (
|
|
|
1249
1249
|
name: "jsenv:optimize",
|
|
1250
1250
|
appliesDuring: "build",
|
|
1251
1251
|
transformUrlContent: async (urlInfo) => {
|
|
1252
|
-
await rawKitchen.
|
|
1252
|
+
await rawKitchen.jsenvPluginsController.callAsyncHooks(
|
|
1253
1253
|
"optimizeBuildUrlContent",
|
|
1254
1254
|
urlInfo,
|
|
1255
1255
|
(optimizeReturnValue) => {
|
|
@@ -1260,18 +1260,18 @@ const prepareEntryPointBuild = async (
|
|
|
1260
1260
|
},
|
|
1261
1261
|
buildSpecifierManager.jsenvPluginMoveToBuildDirectory,
|
|
1262
1262
|
]);
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1263
|
+
const finalJsenvPluginsController = await createJsenvPluginsController(
|
|
1264
|
+
finalJsenvPluginStore,
|
|
1265
1265
|
finalKitchen,
|
|
1266
1266
|
{
|
|
1267
|
-
|
|
1267
|
+
meta: rawKitchen.jsenvPluginsController.getMeta(),
|
|
1268
1268
|
},
|
|
1269
1269
|
);
|
|
1270
|
-
finalKitchen.
|
|
1270
|
+
finalKitchen.setJsenvPluginsController(finalJsenvPluginsController);
|
|
1271
1271
|
|
|
1272
1272
|
bundle: {
|
|
1273
1273
|
const bundlerMap = new Map();
|
|
1274
|
-
for (const plugin of rawKitchen.
|
|
1274
|
+
for (const plugin of rawKitchen.jsenvPluginsController.activePlugins) {
|
|
1275
1275
|
const bundle = plugin.bundle;
|
|
1276
1276
|
if (!bundle) {
|
|
1277
1277
|
continue;
|
|
@@ -1483,7 +1483,8 @@ const prepareEntryPointBuild = async (
|
|
|
1483
1483
|
refine_hook: {
|
|
1484
1484
|
const refineBuildUrlContentCallbackSet = new Set();
|
|
1485
1485
|
const refineBuildCallbackSet = new Set();
|
|
1486
|
-
for (const plugin of rawKitchen.
|
|
1486
|
+
for (const plugin of rawKitchen.jsenvPluginsController
|
|
1487
|
+
.activePlugins) {
|
|
1487
1488
|
const refineBuildUrlContent = plugin.refineBuildUrlContent;
|
|
1488
1489
|
if (refineBuildUrlContent) {
|
|
1489
1490
|
refineBuildUrlContentCallbackSet.add(refineBuildUrlContent);
|
|
@@ -117,14 +117,15 @@ export const createBuildSpecifierManager = ({
|
|
|
117
117
|
const bundleInfoMap = new Map();
|
|
118
118
|
|
|
119
119
|
const applyBundling = async ({ bundler, urlInfosToBundle }) => {
|
|
120
|
-
const urlInfosBundled =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
const urlInfosBundled =
|
|
121
|
+
await rawKitchen.jsenvPluginsController.callAsyncHook(
|
|
122
|
+
{
|
|
123
|
+
plugin: bundler.plugin,
|
|
124
|
+
hookName: "bundle",
|
|
125
|
+
value: bundler.bundleFunction,
|
|
126
|
+
},
|
|
127
|
+
urlInfosToBundle,
|
|
128
|
+
);
|
|
128
129
|
for (const url of Object.keys(urlInfosBundled)) {
|
|
129
130
|
const urlInfoBundled = urlInfosBundled[url];
|
|
130
131
|
const contentSideEffects = [];
|
|
@@ -1315,9 +1316,9 @@ const isWrappedByQuote = (content, start, end) => {
|
|
|
1315
1316
|
// https://github.com/rollup/rollup/blob/5a5391971d695c808eed0c5d7d2c6ccb594fc689/src/Chunk.ts#L870
|
|
1316
1317
|
const generateVersion = (parts, length) => {
|
|
1317
1318
|
const hash = createHash("sha256");
|
|
1318
|
-
|
|
1319
|
+
for (const part of parts) {
|
|
1319
1320
|
hash.update(part);
|
|
1320
|
-
}
|
|
1321
|
+
}
|
|
1321
1322
|
return hash.digest("hex").slice(0, length);
|
|
1322
1323
|
};
|
|
1323
1324
|
|
|
@@ -15,25 +15,27 @@ import {
|
|
|
15
15
|
import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js";
|
|
16
16
|
import { prependContent } from "../kitchen/prepend_content.js";
|
|
17
17
|
|
|
18
|
+
// we nevery minify those because they are already very small
|
|
19
|
+
// and would hurt the readability of something that can be critical to debug
|
|
18
20
|
export const injectGlobalMappings = async (urlInfo, mappings) => {
|
|
19
21
|
if (urlInfo.type === "html") {
|
|
20
|
-
const minification = Boolean(
|
|
21
|
-
|
|
22
|
-
);
|
|
22
|
+
// const minification = Boolean(
|
|
23
|
+
// urlInfo.context.getPluginMeta("willMinifyJsClassic"),
|
|
24
|
+
// );
|
|
23
25
|
const content = generateClientCodeForMappings(mappings, {
|
|
24
26
|
globalName: "window",
|
|
25
|
-
minification,
|
|
27
|
+
minification: false,
|
|
26
28
|
});
|
|
27
29
|
await prependContent(urlInfo, { type: "js_classic", content });
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
32
|
if (urlInfo.type === "js_classic" || urlInfo.type === "js_module") {
|
|
31
|
-
const minification = Boolean(
|
|
32
|
-
|
|
33
|
-
);
|
|
33
|
+
// const minification = Boolean(
|
|
34
|
+
// urlInfo.context.getPluginMeta("willMinifyJsClassic"),
|
|
35
|
+
// );
|
|
34
36
|
const content = generateClientCodeForMappings(mappings, {
|
|
35
37
|
globalName: isWebWorkerUrlInfo(urlInfo) ? "self" : "window",
|
|
36
|
-
minification,
|
|
38
|
+
minification: false,
|
|
37
39
|
});
|
|
38
40
|
await prependContent(urlInfo, { type: "js_classic", content });
|
|
39
41
|
return;
|
|
@@ -68,9 +70,8 @@ export const injectImportmapMappings = (urlInfo, getMappings) => {
|
|
|
68
70
|
// jsenv_plugin_importmap.js is removing importmap during build
|
|
69
71
|
// it means at this point we know HTML has no importmap in it
|
|
70
72
|
// we can safely inject one
|
|
71
|
-
const importmapMinification =
|
|
72
|
-
|
|
73
|
-
);
|
|
73
|
+
const importmapMinification = false;
|
|
74
|
+
// Boolean(urlInfo.context.getPluginMeta("willMinifyJson"));
|
|
74
75
|
const importmapNode = findHtmlNode(htmlAst, (node) => {
|
|
75
76
|
return (
|
|
76
77
|
node.tagName === "script" &&
|
|
@@ -18,9 +18,9 @@ import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
|
18
18
|
import { createLogger, createTaskLog } from "@jsenv/humanize";
|
|
19
19
|
import {
|
|
20
20
|
jsenvAccessControlAllowedHeaders,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
serverPluginCORS,
|
|
22
|
+
serverPluginErrorHandler,
|
|
23
|
+
serverPluginStaticFiles,
|
|
24
24
|
startServer,
|
|
25
25
|
} from "@jsenv/server";
|
|
26
26
|
import { existsSync } from "node:fs";
|
|
@@ -36,7 +36,7 @@ export const startBuildServer = async ({
|
|
|
36
36
|
buildMainFilePath = "index.html",
|
|
37
37
|
port = 9779,
|
|
38
38
|
routes,
|
|
39
|
-
|
|
39
|
+
serverPlugins = [],
|
|
40
40
|
acceptAnyIp,
|
|
41
41
|
hostname,
|
|
42
42
|
https,
|
|
@@ -121,8 +121,8 @@ export const startBuildServer = async ({
|
|
|
121
121
|
serverTiming: true,
|
|
122
122
|
requestWaitingMs: 60_000,
|
|
123
123
|
routes,
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
plugins: [
|
|
125
|
+
serverPluginCORS({
|
|
126
126
|
accessControlAllowRequestOrigin: true,
|
|
127
127
|
accessControlAllowRequestMethod: true,
|
|
128
128
|
accessControlAllowRequestHeaders: true,
|
|
@@ -130,12 +130,12 @@ export const startBuildServer = async ({
|
|
|
130
130
|
accessControlAllowCredentials: true,
|
|
131
131
|
timingAllowOrigin: true,
|
|
132
132
|
}),
|
|
133
|
-
...
|
|
134
|
-
|
|
133
|
+
...serverPlugins,
|
|
134
|
+
serverPluginStaticFiles({
|
|
135
135
|
directoryUrl: buildDirectoryUrl,
|
|
136
136
|
mainFilePath: buildMainFilePath,
|
|
137
137
|
}),
|
|
138
|
-
|
|
138
|
+
serverPluginErrorHandler({
|
|
139
139
|
sendErrorDetails: false,
|
|
140
140
|
}),
|
|
141
141
|
],
|
|
@@ -7,12 +7,12 @@ import { createLogger, createTaskLog, formatError } from "@jsenv/humanize";
|
|
|
7
7
|
import {
|
|
8
8
|
composeTwoResponses,
|
|
9
9
|
jsenvAccessControlAllowedHeaders,
|
|
10
|
-
jsenvServiceCORS,
|
|
11
|
-
jsenvServiceErrorHandler,
|
|
12
10
|
serveDirectory,
|
|
11
|
+
serverPluginCORS,
|
|
12
|
+
serverPluginErrorHandler,
|
|
13
13
|
startServer,
|
|
14
14
|
} from "@jsenv/server";
|
|
15
|
-
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/
|
|
15
|
+
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/plugins/filesystem/filesystem_error_to_response.js";
|
|
16
16
|
import { URL_META } from "@jsenv/url-meta";
|
|
17
17
|
import { urlIsOrIsInsideOf, urlToRelativeUrl } from "@jsenv/urls";
|
|
18
18
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -24,9 +24,9 @@ import { jsenvCoreDirectoryUrl } from "../jsenv_core_directory_url.js";
|
|
|
24
24
|
import { createKitchen } from "../kitchen/kitchen.js";
|
|
25
25
|
import { createPackageDirectory } from "../kitchen/package_directory.js";
|
|
26
26
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from "../plugins/
|
|
27
|
+
createJsenvPluginsController,
|
|
28
|
+
createJsenvPluginStore,
|
|
29
|
+
} from "../plugins/jsenv_plugins_controller.js";
|
|
30
30
|
import { getCorePlugins } from "../plugins/plugins.js";
|
|
31
31
|
import { jsenvPluginServerEvents } from "../plugins/server_events/jsenv_plugin_server_events.js";
|
|
32
32
|
import { parseUserAgentHeader } from "./user_agent.js";
|
|
@@ -69,7 +69,7 @@ export const startDevServer = async ({
|
|
|
69
69
|
logLevel = EXECUTED_BY_TEST_PLAN ? "warn" : "info",
|
|
70
70
|
serverLogLevel = "warn",
|
|
71
71
|
serverRouterLogLevel = "warn",
|
|
72
|
-
|
|
72
|
+
serverPlugins = [],
|
|
73
73
|
|
|
74
74
|
signal = new AbortController().signal,
|
|
75
75
|
handleSIGINT = true,
|
|
@@ -176,10 +176,10 @@ export const startDevServer = async ({
|
|
|
176
176
|
const serverStopAbortSignal = serverStopAbortController.signal;
|
|
177
177
|
const kitchenCache = new Map();
|
|
178
178
|
|
|
179
|
-
const
|
|
179
|
+
const finalServerPlugins = [];
|
|
180
180
|
// x-server-inspect service
|
|
181
181
|
{
|
|
182
|
-
|
|
182
|
+
finalServerPlugins.push({
|
|
183
183
|
name: "jsenv:server_header",
|
|
184
184
|
routes: [
|
|
185
185
|
{
|
|
@@ -205,8 +205,8 @@ export const startDevServer = async ({
|
|
|
205
205
|
}
|
|
206
206
|
// cors service
|
|
207
207
|
{
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
finalServerPlugins.push(
|
|
209
|
+
serverPluginCORS({
|
|
210
210
|
accessControlAllowRequestOrigin: true,
|
|
211
211
|
accessControlAllowRequestMethod: true,
|
|
212
212
|
accessControlAllowRequestHeaders: true,
|
|
@@ -219,9 +219,9 @@ export const startDevServer = async ({
|
|
|
219
219
|
}),
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
|
-
// custom
|
|
222
|
+
// custom server plugins
|
|
223
223
|
{
|
|
224
|
-
|
|
224
|
+
finalServerPlugins.push(...serverPlugins);
|
|
225
225
|
}
|
|
226
226
|
// file_service
|
|
227
227
|
{
|
|
@@ -251,7 +251,7 @@ export const startDevServer = async ({
|
|
|
251
251
|
sourceDirectoryUrl,
|
|
252
252
|
});
|
|
253
253
|
|
|
254
|
-
const
|
|
254
|
+
const devServerJsenvPluginStore = await createJsenvPluginStore([
|
|
255
255
|
jsenvPluginServerEvents({ clientAutoreload }),
|
|
256
256
|
...plugins,
|
|
257
257
|
...getCorePlugins({
|
|
@@ -411,28 +411,28 @@ export const startDevServer = async ({
|
|
|
411
411
|
);
|
|
412
412
|
},
|
|
413
413
|
);
|
|
414
|
-
const
|
|
415
|
-
|
|
414
|
+
const devServerJsenvPluginController = await createJsenvPluginsController(
|
|
415
|
+
devServerJsenvPluginStore,
|
|
416
416
|
kitchen,
|
|
417
417
|
);
|
|
418
|
-
kitchen.
|
|
418
|
+
kitchen.setJsenvPluginsController(devServerJsenvPluginController);
|
|
419
419
|
|
|
420
420
|
serverStopCallbackSet.add(() => {
|
|
421
|
-
|
|
421
|
+
devServerJsenvPluginController.callHooks("destroy", kitchen.context);
|
|
422
422
|
});
|
|
423
423
|
kitchenCache.set(runtimeId, kitchen);
|
|
424
424
|
onKitchenCreated(kitchen);
|
|
425
425
|
return kitchen;
|
|
426
426
|
};
|
|
427
427
|
|
|
428
|
-
|
|
428
|
+
finalServerPlugins.push({
|
|
429
429
|
name: "jsenv:dev_server_routes",
|
|
430
430
|
augmentRouteFetchSecondArg: async (request) => {
|
|
431
431
|
const kitchen = await getOrCreateKitchen(request);
|
|
432
432
|
return { kitchen };
|
|
433
433
|
},
|
|
434
434
|
routes: [
|
|
435
|
-
...
|
|
435
|
+
...devServerJsenvPluginStore.allServerRoutes,
|
|
436
436
|
{
|
|
437
437
|
endpoint: "GET *",
|
|
438
438
|
description: "Serve project files.",
|
|
@@ -545,7 +545,7 @@ export const startDevServer = async ({
|
|
|
545
545
|
reference,
|
|
546
546
|
urlInfo,
|
|
547
547
|
};
|
|
548
|
-
kitchen.
|
|
548
|
+
kitchen.jsenvPluginsController.callHooks(
|
|
549
549
|
"augmentResponse",
|
|
550
550
|
augmentResponseInfo,
|
|
551
551
|
(returnValue) => {
|
|
@@ -632,11 +632,11 @@ export const startDevServer = async ({
|
|
|
632
632
|
},
|
|
633
633
|
],
|
|
634
634
|
});
|
|
635
|
-
|
|
635
|
+
finalServerPlugins.push(...devServerJsenvPluginStore.allServerPlugins);
|
|
636
636
|
}
|
|
637
637
|
// jsenv error handler service
|
|
638
638
|
{
|
|
639
|
-
|
|
639
|
+
finalServerPlugins.push({
|
|
640
640
|
name: "jsenv:omega_error_handler",
|
|
641
641
|
handleError: (error) => {
|
|
642
642
|
const getResponseForError = () => {
|
|
@@ -673,8 +673,8 @@ export const startDevServer = async ({
|
|
|
673
673
|
}
|
|
674
674
|
// default error handler
|
|
675
675
|
{
|
|
676
|
-
|
|
677
|
-
|
|
676
|
+
finalServerPlugins.push(
|
|
677
|
+
serverPluginErrorHandler({
|
|
678
678
|
sendErrorDetails: true,
|
|
679
679
|
}),
|
|
680
680
|
);
|
|
@@ -696,7 +696,7 @@ export const startDevServer = async ({
|
|
|
696
696
|
hostname,
|
|
697
697
|
port,
|
|
698
698
|
requestWaitingMs: 60_000,
|
|
699
|
-
|
|
699
|
+
plugins: finalServerPlugins,
|
|
700
700
|
});
|
|
701
701
|
server.stoppedPromise.then((reason) => {
|
|
702
702
|
onStop();
|
package/src/kitchen/errors.js
CHANGED
|
@@ -3,7 +3,7 @@ import { stringifyUrlSite } from "@jsenv/urls";
|
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
|
|
5
5
|
export const createResolveUrlError = ({
|
|
6
|
-
|
|
6
|
+
jsenvPluginsController,
|
|
7
7
|
reference,
|
|
8
8
|
error,
|
|
9
9
|
}) => {
|
|
@@ -21,7 +21,7 @@ ${reason}`,
|
|
|
21
21
|
{
|
|
22
22
|
...detailsFromFirstReference(reference),
|
|
23
23
|
...details,
|
|
24
|
-
...detailsFromPluginController(
|
|
24
|
+
...detailsFromPluginController(jsenvPluginsController),
|
|
25
25
|
},
|
|
26
26
|
),
|
|
27
27
|
);
|
|
@@ -66,7 +66,7 @@ ${reason}`,
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export const createFetchUrlContentError = ({
|
|
69
|
-
|
|
69
|
+
jsenvPluginsController,
|
|
70
70
|
urlInfo,
|
|
71
71
|
error,
|
|
72
72
|
}) => {
|
|
@@ -85,7 +85,7 @@ ${reason}`,
|
|
|
85
85
|
{
|
|
86
86
|
...detailsFromFirstReference(reference),
|
|
87
87
|
...details,
|
|
88
|
-
...detailsFromPluginController(
|
|
88
|
+
...detailsFromPluginController(jsenvPluginsController),
|
|
89
89
|
},
|
|
90
90
|
),
|
|
91
91
|
);
|
|
@@ -141,7 +141,7 @@ ${reason}`,
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
export const createTransformUrlContentError = ({
|
|
144
|
-
|
|
144
|
+
jsenvPluginsController,
|
|
145
145
|
urlInfo,
|
|
146
146
|
error,
|
|
147
147
|
}) => {
|
|
@@ -170,7 +170,7 @@ ${error.message}`,
|
|
|
170
170
|
? `${reference.trace.url}:${reference.trace.line}:${reference.trace.column}`
|
|
171
171
|
: reference.trace.message,
|
|
172
172
|
...detailsFromFirstReference(reference),
|
|
173
|
-
...detailsFromPluginController(
|
|
173
|
+
...detailsFromPluginController(jsenvPluginsController),
|
|
174
174
|
},
|
|
175
175
|
),
|
|
176
176
|
);
|
|
@@ -202,7 +202,7 @@ ${reason}`,
|
|
|
202
202
|
{
|
|
203
203
|
...detailsFromFirstReference(reference),
|
|
204
204
|
...details,
|
|
205
|
-
...detailsFromPluginController(
|
|
205
|
+
...detailsFromPluginController(jsenvPluginsController),
|
|
206
206
|
},
|
|
207
207
|
),
|
|
208
208
|
);
|
|
@@ -226,7 +226,7 @@ ${reason}`,
|
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
export const createFinalizeUrlContentError = ({
|
|
229
|
-
|
|
229
|
+
jsenvPluginsController,
|
|
230
230
|
urlInfo,
|
|
231
231
|
error,
|
|
232
232
|
}) => {
|
|
@@ -238,7 +238,7 @@ ${reference.trace.message}`,
|
|
|
238
238
|
{
|
|
239
239
|
...detailsFromFirstReference(reference),
|
|
240
240
|
...detailsFromValueThrown(error),
|
|
241
|
-
...detailsFromPluginController(
|
|
241
|
+
...detailsFromPluginController(jsenvPluginsController),
|
|
242
242
|
},
|
|
243
243
|
),
|
|
244
244
|
);
|
|
@@ -328,8 +328,8 @@ const getFirstReferenceInProject = (reference) => {
|
|
|
328
328
|
return getFirstReferenceInProject(firstReference);
|
|
329
329
|
};
|
|
330
330
|
|
|
331
|
-
const detailsFromPluginController = (
|
|
332
|
-
const currentPlugin =
|
|
331
|
+
const detailsFromPluginController = (jsenvPluginsController) => {
|
|
332
|
+
const currentPlugin = jsenvPluginsController.getCurrentPlugin();
|
|
333
333
|
if (!currentPlugin) {
|
|
334
334
|
return null;
|
|
335
335
|
}
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -132,14 +132,14 @@ export const createKitchen = ({
|
|
|
132
132
|
},
|
|
133
133
|
graph: null,
|
|
134
134
|
urlInfoTransformer: null,
|
|
135
|
-
|
|
135
|
+
jsenvPluginsController: null,
|
|
136
136
|
};
|
|
137
137
|
const kitchenContext = kitchen.context;
|
|
138
138
|
kitchenContext.kitchen = kitchen;
|
|
139
139
|
|
|
140
|
-
let
|
|
141
|
-
kitchen.
|
|
142
|
-
|
|
140
|
+
let jsenvPluginsController;
|
|
141
|
+
kitchen.setJsenvPluginsController = (value) => {
|
|
142
|
+
jsenvPluginsController = kitchen.jsenvPluginsController = value;
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
const graph = createUrlGraph({
|
|
@@ -148,7 +148,11 @@ export const createKitchen = ({
|
|
|
148
148
|
kitchen,
|
|
149
149
|
});
|
|
150
150
|
graph.urlInfoCreatedEventEmitter.on((urlInfoCreated) => {
|
|
151
|
-
|
|
151
|
+
jsenvPluginsController.callHooks(
|
|
152
|
+
"urlInfoCreated",
|
|
153
|
+
urlInfoCreated,
|
|
154
|
+
() => {},
|
|
155
|
+
);
|
|
152
156
|
});
|
|
153
157
|
kitchen.graph = graph;
|
|
154
158
|
|
|
@@ -322,7 +326,7 @@ export const createKitchen = ({
|
|
|
322
326
|
setReferenceUrl(reference.url);
|
|
323
327
|
break resolve;
|
|
324
328
|
}
|
|
325
|
-
const resolvedUrl =
|
|
329
|
+
const resolvedUrl = jsenvPluginsController.callHooksUntil(
|
|
326
330
|
"resolveReference",
|
|
327
331
|
reference,
|
|
328
332
|
);
|
|
@@ -336,7 +340,7 @@ export const createKitchen = ({
|
|
|
336
340
|
setReferenceUrl(normalizedUrl);
|
|
337
341
|
if (reference.debug) {
|
|
338
342
|
logger.debug(`url resolved by "${
|
|
339
|
-
|
|
343
|
+
jsenvPluginsController.getLastPluginUsed().name
|
|
340
344
|
}"
|
|
341
345
|
${ANSI.color(reference.specifier, ANSI.GREY)} ->
|
|
342
346
|
${ANSI.color(reference.url, ANSI.YELLOW)}
|
|
@@ -350,7 +354,7 @@ ${ANSI.color(reference.url, ANSI.YELLOW)}
|
|
|
350
354
|
// - side_effect_file references injected in entry points or at the top of files
|
|
351
355
|
break redirect;
|
|
352
356
|
}
|
|
353
|
-
|
|
357
|
+
jsenvPluginsController.callHooks(
|
|
354
358
|
"redirectReference",
|
|
355
359
|
reference,
|
|
356
360
|
(returnValue, plugin, setReference) => {
|
|
@@ -395,7 +399,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
395
399
|
return reference;
|
|
396
400
|
} catch (error) {
|
|
397
401
|
throw createResolveUrlError({
|
|
398
|
-
|
|
402
|
+
jsenvPluginsController,
|
|
399
403
|
reference,
|
|
400
404
|
error,
|
|
401
405
|
});
|
|
@@ -422,7 +426,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
422
426
|
// But do not represent an other resource, it is considered as
|
|
423
427
|
// the same resource under the hood
|
|
424
428
|
const searchParamTransformationMap = new Map();
|
|
425
|
-
|
|
429
|
+
jsenvPluginsController.callHooks(
|
|
426
430
|
"transformReferenceSearchParams",
|
|
427
431
|
reference,
|
|
428
432
|
(returnValue) => {
|
|
@@ -450,7 +454,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
450
454
|
}
|
|
451
455
|
}
|
|
452
456
|
format: {
|
|
453
|
-
const returnValue =
|
|
457
|
+
const returnValue = jsenvPluginsController.callHooksUntil(
|
|
454
458
|
"formatReference",
|
|
455
459
|
reference,
|
|
456
460
|
);
|
|
@@ -471,7 +475,10 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
471
475
|
const fetchUrlContent = async (urlInfo) => {
|
|
472
476
|
try {
|
|
473
477
|
const fetchUrlContentReturnValue =
|
|
474
|
-
await
|
|
478
|
+
await jsenvPluginsController.callAsyncHooksUntil(
|
|
479
|
+
"fetchUrlContent",
|
|
480
|
+
urlInfo,
|
|
481
|
+
);
|
|
475
482
|
if (!fetchUrlContentReturnValue) {
|
|
476
483
|
logger.warn(
|
|
477
484
|
createDetailedMessage(
|
|
@@ -570,7 +577,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
570
577
|
});
|
|
571
578
|
} catch (error) {
|
|
572
579
|
throw createFetchUrlContentError({
|
|
573
|
-
|
|
580
|
+
jsenvPluginsController,
|
|
574
581
|
urlInfo,
|
|
575
582
|
error,
|
|
576
583
|
});
|
|
@@ -580,7 +587,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
580
587
|
|
|
581
588
|
const transformUrlContent = async (urlInfo) => {
|
|
582
589
|
try {
|
|
583
|
-
await
|
|
590
|
+
await jsenvPluginsController.callAsyncHooks(
|
|
584
591
|
"transformUrlContent",
|
|
585
592
|
urlInfo,
|
|
586
593
|
(transformReturnValue) => {
|
|
@@ -592,7 +599,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
592
599
|
);
|
|
593
600
|
} catch (error) {
|
|
594
601
|
const transformError = createTransformUrlContentError({
|
|
595
|
-
|
|
602
|
+
jsenvPluginsController,
|
|
596
603
|
urlInfo,
|
|
597
604
|
error,
|
|
598
605
|
});
|
|
@@ -604,14 +611,15 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
604
611
|
const finalizeUrlContent = async (urlInfo) => {
|
|
605
612
|
try {
|
|
606
613
|
await urlInfo.applyContentTransformationCallbacks();
|
|
607
|
-
const finalizeReturnValue =
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
614
|
+
const finalizeReturnValue =
|
|
615
|
+
await jsenvPluginsController.callAsyncHooksUntil(
|
|
616
|
+
"finalizeUrlContent",
|
|
617
|
+
urlInfo,
|
|
618
|
+
);
|
|
611
619
|
urlInfoTransformer.endTransformations(urlInfo, finalizeReturnValue);
|
|
612
620
|
} catch (error) {
|
|
613
621
|
throw createFinalizeUrlContentError({
|
|
614
|
-
|
|
622
|
+
jsenvPluginsController,
|
|
615
623
|
urlInfo,
|
|
616
624
|
error,
|
|
617
625
|
});
|
|
@@ -692,7 +700,7 @@ ${urlInfo.firstReference.trace.message}`;
|
|
|
692
700
|
}
|
|
693
701
|
|
|
694
702
|
// "cooked" hook
|
|
695
|
-
|
|
703
|
+
jsenvPluginsController.callHooks("cooked", urlInfo, (cookedReturnValue) => {
|
|
696
704
|
if (typeof cookedReturnValue === "function") {
|
|
697
705
|
const removeCallback = urlInfo.graph.urlInfoDereferencedEventEmitter.on(
|
|
698
706
|
(urlInfoDereferenced, lastReferenceFromOther) => {
|
package/src/plugins/autoreload_on_server_restart/jsenv_plugin_autoreload_on_server_restart.js
CHANGED
|
@@ -2,7 +2,7 @@ import { injectJsenvScript, parseHtml, stringifyHtmlAst } from "@jsenv/ast";
|
|
|
2
2
|
|
|
3
3
|
export const jsenvPluginAutoreloadOnServerRestart = () => {
|
|
4
4
|
const autoreloadOnRestartClientFileUrl = import.meta
|
|
5
|
-
.resolve("@jsenv/server/src/
|
|
5
|
+
.resolve("@jsenv/server/src/plugins/autoreload_on_server_restart/client/autoreload_on_server_restart.js");
|
|
6
6
|
|
|
7
7
|
return {
|
|
8
8
|
name: "jsenv:autoreload_on_server_restart",
|
|
@@ -25,7 +25,7 @@ export const jsenvPluginChromeDevtoolsJson = () => {
|
|
|
25
25
|
return {
|
|
26
26
|
name: "jsenv_plugin_chrome_devtools_json",
|
|
27
27
|
appliesDuring: "dev",
|
|
28
|
-
|
|
28
|
+
serverRoutes: [
|
|
29
29
|
{
|
|
30
30
|
endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
|
|
31
31
|
declarationSource: import.meta.url,
|