@jsenv/core 40.1.5 → 40.1.7
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 +76 -2
- package/dist/start_dev_server/start_dev_server.js +76 -1
- package/package.json +4 -4
- package/src/build/build.js +0 -1
- package/src/plugins/autoreload_on_server_restart/jsenv_plugin_autoreload_on_server_restart.js +34 -0
- package/src/plugins/chrome_devtools_json/jsenv_plugin_chrome_devtools_json.js +43 -0
- package/src/plugins/plugins.js +4 -0
package/dist/build/build.js
CHANGED
|
@@ -7,7 +7,7 @@ import { generateSourcemapFileUrl, createMagicSource, composeTwoSourcemaps, gene
|
|
|
7
7
|
import { performance } from "node:perf_hooks";
|
|
8
8
|
import { jsenvPluginSupervisor } from "@jsenv/plugin-supervisor";
|
|
9
9
|
import { WebSocketResponse, pickContentType } from "@jsenv/server";
|
|
10
|
-
import { createHash } from "node:crypto";
|
|
10
|
+
import { randomUUID, createHash } from "node:crypto";
|
|
11
11
|
import "strip-ansi";
|
|
12
12
|
import "../jsenv_core_node_modules.js";
|
|
13
13
|
import "node:os";
|
|
@@ -8097,6 +8097,79 @@ const jsenvPluginCleanHTML = () => {
|
|
|
8097
8097
|
};
|
|
8098
8098
|
};
|
|
8099
8099
|
|
|
8100
|
+
/**
|
|
8101
|
+
* https://docs.google.com/document/d/1rfKPnxsNuXhnF7AiQZhu9kIwdiMS5hnAI05HBwFuBSM/edit?tab=t.0#heading=h.7nki9mck5t64
|
|
8102
|
+
* https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md
|
|
8103
|
+
* https://github.com/ChromeDevTools/vite-plugin-devtools-json
|
|
8104
|
+
*/
|
|
8105
|
+
|
|
8106
|
+
|
|
8107
|
+
const jsenvPluginChromeDevtoolsJson = () => {
|
|
8108
|
+
const getOrCreateUUID = (kitchen) => {
|
|
8109
|
+
const { outDirectoryUrl } = kitchen.context;
|
|
8110
|
+
const uuidFileUrl = new URL("./uuid.json", outDirectoryUrl);
|
|
8111
|
+
if (existsSync(uuidFileUrl)) {
|
|
8112
|
+
const { uuid } = JSON.parse(readFileSync(uuidFileUrl, "utf8"));
|
|
8113
|
+
return uuid;
|
|
8114
|
+
}
|
|
8115
|
+
const uuid = randomUUID();
|
|
8116
|
+
writeFileSync(uuidFileUrl, JSON.stringify({ uuid }), { });
|
|
8117
|
+
return uuid;
|
|
8118
|
+
};
|
|
8119
|
+
|
|
8120
|
+
return {
|
|
8121
|
+
name: "jsenv_plugin_chrome_devtools_json",
|
|
8122
|
+
appliesDuring: "dev",
|
|
8123
|
+
devServerRoutes: [
|
|
8124
|
+
{
|
|
8125
|
+
endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
|
|
8126
|
+
fetch: (request, { kitchen }) => {
|
|
8127
|
+
const { rootDirectoryUrl } = kitchen.context;
|
|
8128
|
+
return Response.json({
|
|
8129
|
+
workspace: {
|
|
8130
|
+
root: urlToFileSystemPath(rootDirectoryUrl),
|
|
8131
|
+
uuid: getOrCreateUUID(kitchen),
|
|
8132
|
+
},
|
|
8133
|
+
});
|
|
8134
|
+
},
|
|
8135
|
+
},
|
|
8136
|
+
],
|
|
8137
|
+
};
|
|
8138
|
+
};
|
|
8139
|
+
|
|
8140
|
+
const jsenvPluginAutoreloadOnServerRestart = () => {
|
|
8141
|
+
const autoreloadOnRestartClientFileUrl = import.meta.resolve(
|
|
8142
|
+
"@jsenv/server/src/services/autoreload_on_server_restart/client/autoreload_on_server_restart.js",
|
|
8143
|
+
);
|
|
8144
|
+
|
|
8145
|
+
return {
|
|
8146
|
+
name: "jsenv:autoreload_on_server_restart",
|
|
8147
|
+
appliesDuring: "dev",
|
|
8148
|
+
transformUrlContent: {
|
|
8149
|
+
html: (urlInfo) => {
|
|
8150
|
+
// we should not do this for inspector and 4xx.html
|
|
8151
|
+
const htmlAst = parseHtml({
|
|
8152
|
+
html: urlInfo.content,
|
|
8153
|
+
url: urlInfo.url,
|
|
8154
|
+
});
|
|
8155
|
+
const autoreloadOnRestartClientFileReference =
|
|
8156
|
+
urlInfo.dependencies.inject({
|
|
8157
|
+
type: "script",
|
|
8158
|
+
subtype: "js_classic",
|
|
8159
|
+
expectedType: "js_classic",
|
|
8160
|
+
specifier: autoreloadOnRestartClientFileUrl,
|
|
8161
|
+
});
|
|
8162
|
+
injectJsenvScript(htmlAst, {
|
|
8163
|
+
"src": autoreloadOnRestartClientFileReference.generatedSpecifier,
|
|
8164
|
+
"pluginName": "jsenv:autoreload_on_server_restart",
|
|
8165
|
+
"data-ws-endpoint": "/.internal/events.websocket",
|
|
8166
|
+
});
|
|
8167
|
+
return stringifyHtmlAst(htmlAst);
|
|
8168
|
+
},
|
|
8169
|
+
},
|
|
8170
|
+
};
|
|
8171
|
+
};
|
|
8172
|
+
|
|
8100
8173
|
// tslint:disable:ordered-imports
|
|
8101
8174
|
|
|
8102
8175
|
|
|
@@ -8189,6 +8262,7 @@ const getCorePlugins = ({
|
|
|
8189
8262
|
|
|
8190
8263
|
// "jsenvPluginSupervisor" MUST be after "jsenvPluginInlining" as it needs inline script to be cooked
|
|
8191
8264
|
...(supervisor ? [jsenvPluginSupervisor(supervisor)] : []),
|
|
8265
|
+
jsenvPluginAutoreloadOnServerRestart(),
|
|
8192
8266
|
|
|
8193
8267
|
jsenvPluginCommonJsGlobals(),
|
|
8194
8268
|
jsenvPluginImportMetaScenarios(),
|
|
@@ -8202,6 +8276,7 @@ const getCorePlugins = ({
|
|
|
8202
8276
|
...(cacheControl ? [jsenvPluginCacheControl(cacheControl)] : []),
|
|
8203
8277
|
...(ribbon ? [jsenvPluginRibbon({ rootDirectoryUrl, ...ribbon })] : []),
|
|
8204
8278
|
jsenvPluginCleanHTML(),
|
|
8279
|
+
jsenvPluginChromeDevtoolsJson(),
|
|
8205
8280
|
];
|
|
8206
8281
|
};
|
|
8207
8282
|
|
|
@@ -10618,7 +10693,6 @@ const build = async ({
|
|
|
10618
10693
|
};
|
|
10619
10694
|
},
|
|
10620
10695
|
onBuildEnd: ({ buildFileContents, duration }) => {
|
|
10621
|
-
logger.info("");
|
|
10622
10696
|
logger.info(renderBuildEndLog({ duration, buildFileContents }));
|
|
10623
10697
|
},
|
|
10624
10698
|
};
|
|
@@ -7,6 +7,7 @@ import { generateSourcemapFileUrl, createMagicSource, composeTwoSourcemaps, gene
|
|
|
7
7
|
import { parseHtml, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, stringifyHtmlAst, applyBabelPlugins, generateUrlForInlineContent, parseJsWithAcorn, parseCssUrls, getHtmlNodeAttribute, getHtmlNodePosition, getHtmlNodeAttributePosition, setHtmlNodeAttributes, parseSrcSet, getUrlForContentInsideHtml, removeHtmlNodeText, setHtmlNodeText, getHtmlNodeText, analyzeScriptNode, visitHtmlNodes, parseJsUrls, getUrlForContentInsideJs, analyzeLinkNode, injectJsenvScript } from "@jsenv/ast";
|
|
8
8
|
import { performance } from "node:perf_hooks";
|
|
9
9
|
import { jsenvPluginSupervisor } from "@jsenv/plugin-supervisor";
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
10
11
|
import { createRequire } from "node:module";
|
|
11
12
|
import "strip-ansi";
|
|
12
13
|
import "../jsenv_core_node_modules.js";
|
|
@@ -15,7 +16,6 @@ import "node:os";
|
|
|
15
16
|
import "node:tty";
|
|
16
17
|
import "node:util";
|
|
17
18
|
import "node:path";
|
|
18
|
-
import "node:crypto";
|
|
19
19
|
import "@jsenv/js-module-fallback";
|
|
20
20
|
|
|
21
21
|
// default runtimeCompat corresponds to
|
|
@@ -8138,6 +8138,79 @@ const jsenvPluginCleanHTML = () => {
|
|
|
8138
8138
|
};
|
|
8139
8139
|
};
|
|
8140
8140
|
|
|
8141
|
+
/**
|
|
8142
|
+
* https://docs.google.com/document/d/1rfKPnxsNuXhnF7AiQZhu9kIwdiMS5hnAI05HBwFuBSM/edit?tab=t.0#heading=h.7nki9mck5t64
|
|
8143
|
+
* https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md
|
|
8144
|
+
* https://github.com/ChromeDevTools/vite-plugin-devtools-json
|
|
8145
|
+
*/
|
|
8146
|
+
|
|
8147
|
+
|
|
8148
|
+
const jsenvPluginChromeDevtoolsJson = () => {
|
|
8149
|
+
const getOrCreateUUID = (kitchen) => {
|
|
8150
|
+
const { outDirectoryUrl } = kitchen.context;
|
|
8151
|
+
const uuidFileUrl = new URL("./uuid.json", outDirectoryUrl);
|
|
8152
|
+
if (existsSync(uuidFileUrl)) {
|
|
8153
|
+
const { uuid } = JSON.parse(readFileSync(uuidFileUrl, "utf8"));
|
|
8154
|
+
return uuid;
|
|
8155
|
+
}
|
|
8156
|
+
const uuid = randomUUID();
|
|
8157
|
+
writeFileSync(uuidFileUrl, JSON.stringify({ uuid }), { });
|
|
8158
|
+
return uuid;
|
|
8159
|
+
};
|
|
8160
|
+
|
|
8161
|
+
return {
|
|
8162
|
+
name: "jsenv_plugin_chrome_devtools_json",
|
|
8163
|
+
appliesDuring: "dev",
|
|
8164
|
+
devServerRoutes: [
|
|
8165
|
+
{
|
|
8166
|
+
endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
|
|
8167
|
+
fetch: (request, { kitchen }) => {
|
|
8168
|
+
const { rootDirectoryUrl } = kitchen.context;
|
|
8169
|
+
return Response.json({
|
|
8170
|
+
workspace: {
|
|
8171
|
+
root: urlToFileSystemPath(rootDirectoryUrl),
|
|
8172
|
+
uuid: getOrCreateUUID(kitchen),
|
|
8173
|
+
},
|
|
8174
|
+
});
|
|
8175
|
+
},
|
|
8176
|
+
},
|
|
8177
|
+
],
|
|
8178
|
+
};
|
|
8179
|
+
};
|
|
8180
|
+
|
|
8181
|
+
const jsenvPluginAutoreloadOnServerRestart = () => {
|
|
8182
|
+
const autoreloadOnRestartClientFileUrl = import.meta.resolve(
|
|
8183
|
+
"@jsenv/server/src/services/autoreload_on_server_restart/client/autoreload_on_server_restart.js",
|
|
8184
|
+
);
|
|
8185
|
+
|
|
8186
|
+
return {
|
|
8187
|
+
name: "jsenv:autoreload_on_server_restart",
|
|
8188
|
+
appliesDuring: "dev",
|
|
8189
|
+
transformUrlContent: {
|
|
8190
|
+
html: (urlInfo) => {
|
|
8191
|
+
// we should not do this for inspector and 4xx.html
|
|
8192
|
+
const htmlAst = parseHtml({
|
|
8193
|
+
html: urlInfo.content,
|
|
8194
|
+
url: urlInfo.url,
|
|
8195
|
+
});
|
|
8196
|
+
const autoreloadOnRestartClientFileReference =
|
|
8197
|
+
urlInfo.dependencies.inject({
|
|
8198
|
+
type: "script",
|
|
8199
|
+
subtype: "js_classic",
|
|
8200
|
+
expectedType: "js_classic",
|
|
8201
|
+
specifier: autoreloadOnRestartClientFileUrl,
|
|
8202
|
+
});
|
|
8203
|
+
injectJsenvScript(htmlAst, {
|
|
8204
|
+
"src": autoreloadOnRestartClientFileReference.generatedSpecifier,
|
|
8205
|
+
"pluginName": "jsenv:autoreload_on_server_restart",
|
|
8206
|
+
"data-ws-endpoint": "/.internal/events.websocket",
|
|
8207
|
+
});
|
|
8208
|
+
return stringifyHtmlAst(htmlAst);
|
|
8209
|
+
},
|
|
8210
|
+
},
|
|
8211
|
+
};
|
|
8212
|
+
};
|
|
8213
|
+
|
|
8141
8214
|
// tslint:disable:ordered-imports
|
|
8142
8215
|
|
|
8143
8216
|
|
|
@@ -8230,6 +8303,7 @@ const getCorePlugins = ({
|
|
|
8230
8303
|
|
|
8231
8304
|
// "jsenvPluginSupervisor" MUST be after "jsenvPluginInlining" as it needs inline script to be cooked
|
|
8232
8305
|
...(supervisor ? [jsenvPluginSupervisor(supervisor)] : []),
|
|
8306
|
+
jsenvPluginAutoreloadOnServerRestart(),
|
|
8233
8307
|
|
|
8234
8308
|
jsenvPluginCommonJsGlobals(),
|
|
8235
8309
|
jsenvPluginImportMetaScenarios(),
|
|
@@ -8243,6 +8317,7 @@ const getCorePlugins = ({
|
|
|
8243
8317
|
...(cacheControl ? [jsenvPluginCacheControl(cacheControl)] : []),
|
|
8244
8318
|
...(ribbon ? [jsenvPluginRibbon({ rootDirectoryUrl, ...ribbon })] : []),
|
|
8245
8319
|
jsenvPluginCleanHTML(),
|
|
8320
|
+
jsenvPluginChromeDevtoolsJson(),
|
|
8246
8321
|
];
|
|
8247
8322
|
};
|
|
8248
8323
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "40.1.
|
|
3
|
+
"version": "40.1.7",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"/src/"
|
|
35
35
|
],
|
|
36
36
|
"volta": {
|
|
37
|
-
"node": "
|
|
37
|
+
"node": "23.11.0"
|
|
38
38
|
},
|
|
39
|
-
"packageManager": "npm@
|
|
39
|
+
"packageManager": "npm@11.2.0",
|
|
40
40
|
"workspaces": [
|
|
41
41
|
"./packages/independent/*",
|
|
42
42
|
"./packages/independent/backend/*",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@jsenv/plugin-minification": "1.6.2",
|
|
91
91
|
"@jsenv/plugin-supervisor": "1.6.12",
|
|
92
92
|
"@jsenv/plugin-transpilation": "1.5.9",
|
|
93
|
-
"@jsenv/server": "16.0.
|
|
93
|
+
"@jsenv/server": "16.0.7",
|
|
94
94
|
"@jsenv/sourcemap": "1.3.4",
|
|
95
95
|
"@jsenv/url-meta": "8.5.6",
|
|
96
96
|
"@jsenv/urls": "2.7.1",
|
package/src/build/build.js
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { injectJsenvScript, parseHtml, stringifyHtmlAst } from "@jsenv/ast";
|
|
2
|
+
|
|
3
|
+
export const jsenvPluginAutoreloadOnServerRestart = () => {
|
|
4
|
+
const autoreloadOnRestartClientFileUrl = import.meta.resolve(
|
|
5
|
+
"@jsenv/server/src/services/autoreload_on_server_restart/client/autoreload_on_server_restart.js",
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
name: "jsenv:autoreload_on_server_restart",
|
|
10
|
+
appliesDuring: "dev",
|
|
11
|
+
transformUrlContent: {
|
|
12
|
+
html: (urlInfo) => {
|
|
13
|
+
// we should not do this for inspector and 4xx.html
|
|
14
|
+
const htmlAst = parseHtml({
|
|
15
|
+
html: urlInfo.content,
|
|
16
|
+
url: urlInfo.url,
|
|
17
|
+
});
|
|
18
|
+
const autoreloadOnRestartClientFileReference =
|
|
19
|
+
urlInfo.dependencies.inject({
|
|
20
|
+
type: "script",
|
|
21
|
+
subtype: "js_classic",
|
|
22
|
+
expectedType: "js_classic",
|
|
23
|
+
specifier: autoreloadOnRestartClientFileUrl,
|
|
24
|
+
});
|
|
25
|
+
injectJsenvScript(htmlAst, {
|
|
26
|
+
"src": autoreloadOnRestartClientFileReference.generatedSpecifier,
|
|
27
|
+
"pluginName": "jsenv:autoreload_on_server_restart",
|
|
28
|
+
"data-ws-endpoint": "/.internal/events.websocket",
|
|
29
|
+
});
|
|
30
|
+
return stringifyHtmlAst(htmlAst);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://docs.google.com/document/d/1rfKPnxsNuXhnF7AiQZhu9kIwdiMS5hnAI05HBwFuBSM/edit?tab=t.0#heading=h.7nki9mck5t64
|
|
3
|
+
* https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md
|
|
4
|
+
* https://github.com/ChromeDevTools/vite-plugin-devtools-json
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { writeFileSync } from "@jsenv/filesystem";
|
|
8
|
+
import { urlToFileSystemPath } from "@jsenv/urls";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11
|
+
|
|
12
|
+
export const jsenvPluginChromeDevtoolsJson = () => {
|
|
13
|
+
const getOrCreateUUID = (kitchen) => {
|
|
14
|
+
const { outDirectoryUrl } = kitchen.context;
|
|
15
|
+
const uuidFileUrl = new URL("./uuid.json", outDirectoryUrl);
|
|
16
|
+
if (existsSync(uuidFileUrl)) {
|
|
17
|
+
const { uuid } = JSON.parse(readFileSync(uuidFileUrl, "utf8"));
|
|
18
|
+
return uuid;
|
|
19
|
+
}
|
|
20
|
+
const uuid = randomUUID();
|
|
21
|
+
writeFileSync(uuidFileUrl, JSON.stringify({ uuid }), { encoding: "utf8" });
|
|
22
|
+
return uuid;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
name: "jsenv_plugin_chrome_devtools_json",
|
|
27
|
+
appliesDuring: "dev",
|
|
28
|
+
devServerRoutes: [
|
|
29
|
+
{
|
|
30
|
+
endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
|
|
31
|
+
fetch: (request, { kitchen }) => {
|
|
32
|
+
const { rootDirectoryUrl } = kitchen.context;
|
|
33
|
+
return Response.json({
|
|
34
|
+
workspace: {
|
|
35
|
+
root: urlToFileSystemPath(rootDirectoryUrl),
|
|
36
|
+
uuid: getOrCreateUUID(kitchen),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
};
|
package/src/plugins/plugins.js
CHANGED
|
@@ -23,6 +23,8 @@ import { jsenvPluginCacheControl } from "./cache_control/jsenv_plugin_cache_cont
|
|
|
23
23
|
// other
|
|
24
24
|
import { jsenvPluginRibbon } from "./ribbon/jsenv_plugin_ribbon.js";
|
|
25
25
|
import { jsenvPluginCleanHTML } from "./clean_html/jsenv_plugin_clean_html.js";
|
|
26
|
+
import { jsenvPluginChromeDevtoolsJson } from "./chrome_devtools_json/jsenv_plugin_chrome_devtools_json.js";
|
|
27
|
+
import { jsenvPluginAutoreloadOnServerRestart } from "./autoreload_on_server_restart/jsenv_plugin_autoreload_on_server_restart.js";
|
|
26
28
|
|
|
27
29
|
export const getCorePlugins = ({
|
|
28
30
|
rootDirectoryUrl,
|
|
@@ -113,6 +115,7 @@ export const getCorePlugins = ({
|
|
|
113
115
|
|
|
114
116
|
// "jsenvPluginSupervisor" MUST be after "jsenvPluginInlining" as it needs inline script to be cooked
|
|
115
117
|
...(supervisor ? [jsenvPluginSupervisor(supervisor)] : []),
|
|
118
|
+
jsenvPluginAutoreloadOnServerRestart(),
|
|
116
119
|
|
|
117
120
|
jsenvPluginCommonJsGlobals(),
|
|
118
121
|
jsenvPluginImportMetaScenarios(),
|
|
@@ -126,5 +129,6 @@ export const getCorePlugins = ({
|
|
|
126
129
|
...(cacheControl ? [jsenvPluginCacheControl(cacheControl)] : []),
|
|
127
130
|
...(ribbon ? [jsenvPluginRibbon({ rootDirectoryUrl, ...ribbon })] : []),
|
|
128
131
|
jsenvPluginCleanHTML(),
|
|
132
|
+
jsenvPluginChromeDevtoolsJson(),
|
|
129
133
|
];
|
|
130
134
|
};
|