@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
|
@@ -1,20 +1,49 @@
|
|
|
1
1
|
const installImportMetaCssBuild = (importMeta) => {
|
|
2
|
-
const
|
|
2
|
+
const IMPORT_META_CSS_BUILD = "jsenv_import_meta_css_build";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
if (importMeta.css === IMPORT_META_CSS_BUILD) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const stylesheetMap = new Map();
|
|
9
|
+
const adopt = (url, value) => {
|
|
10
|
+
const stylesheet = new CSSStyleSheet({ baseUrl: importMeta.url });
|
|
11
|
+
stylesheet.replaceSync(value);
|
|
12
|
+
stylesheetMap.set(url, stylesheet);
|
|
13
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
|
|
14
|
+
};
|
|
15
|
+
const update = (url, value) => {
|
|
16
|
+
stylesheetMap.get(url).replaceSync(value);
|
|
17
|
+
};
|
|
18
|
+
const remove = (url) => {
|
|
19
|
+
const stylesheet = stylesheetMap.get(url);
|
|
20
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
|
|
21
|
+
(s) => s !== stylesheet,
|
|
22
|
+
);
|
|
23
|
+
stylesheetMap.delete(url);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const currentCssSourceMap = new Map();
|
|
6
27
|
Object.defineProperty(importMeta, "css", {
|
|
7
28
|
configurable: true,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
29
|
+
get() {
|
|
30
|
+
return IMPORT_META_CSS_BUILD;
|
|
31
|
+
},
|
|
32
|
+
set([value, url]) {
|
|
33
|
+
if (value === undefined) {
|
|
34
|
+
if (stylesheetMap.has(url)) {
|
|
35
|
+
remove(url);
|
|
36
|
+
currentCssSourceMap.delete(url);
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!stylesheetMap.has(url)) {
|
|
41
|
+
adopt(url, value);
|
|
42
|
+
currentCssSourceMap.set(url, value);
|
|
43
|
+
} else if (currentCssSourceMap.get(url) !== value) {
|
|
44
|
+
update(url, value);
|
|
45
|
+
currentCssSourceMap.set(url, value);
|
|
11
46
|
}
|
|
12
|
-
called = true;
|
|
13
|
-
stylesheet.replaceSync(value);
|
|
14
|
-
document.adoptedStyleSheets = [
|
|
15
|
-
...document.adoptedStyleSheets,
|
|
16
|
-
stylesheet,
|
|
17
|
-
];
|
|
18
47
|
},
|
|
19
48
|
});
|
|
20
49
|
};
|
|
@@ -1,48 +1,60 @@
|
|
|
1
1
|
const installImportMetaCssDev = (importMeta) => {
|
|
2
|
-
|
|
3
|
-
let stylesheet = new CSSStyleSheet({ baseUrl: importMeta.url });
|
|
4
|
-
let adopted = false;
|
|
2
|
+
const IMPORT_META_CSS_DEV = "jsenv_import_meta_css_dev";
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
cssText += `
|
|
4
|
+
// useless today but browser might catch up to display it in devtools
|
|
5
|
+
const addUrlInfo = (cssText) => {
|
|
6
|
+
let cssTextWithUrlInfo = cssText;
|
|
7
|
+
cssTextWithUrlInfo += `
|
|
11
8
|
/* sourceURL=${importMeta.url} */
|
|
12
9
|
/* inlined from ${importMeta.url} */`;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
adopted = false;
|
|
30
|
-
}
|
|
31
|
-
},
|
|
10
|
+
return cssTextWithUrlInfo;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let stylesheet;
|
|
14
|
+
const adopt = (value) => {
|
|
15
|
+
stylesheet = new CSSStyleSheet({ baseUrl: importMeta.url });
|
|
16
|
+
stylesheet.replaceSync(addUrlInfo(value));
|
|
17
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
|
|
18
|
+
};
|
|
19
|
+
const update = (value) => {
|
|
20
|
+
stylesheet.replaceSync(addUrlInfo(value));
|
|
21
|
+
};
|
|
22
|
+
const remove = () => {
|
|
23
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
|
|
24
|
+
(s) => s !== stylesheet,
|
|
25
|
+
);
|
|
32
26
|
};
|
|
33
27
|
|
|
28
|
+
let currentCssSource;
|
|
34
29
|
Object.defineProperty(importMeta, "css", {
|
|
35
30
|
configurable: true,
|
|
36
31
|
get() {
|
|
37
|
-
return
|
|
32
|
+
return IMPORT_META_CSS_DEV;
|
|
38
33
|
},
|
|
39
34
|
set(value) {
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
if (value === undefined) {
|
|
36
|
+
if (stylesheet) {
|
|
37
|
+
remove();
|
|
38
|
+
stylesheet = undefined;
|
|
39
|
+
currentCssSource = undefined;
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!stylesheet) {
|
|
44
|
+
adopt(value);
|
|
45
|
+
currentCssSource = value;
|
|
46
|
+
} else if (currentCssSource !== value) {
|
|
47
|
+
update(value);
|
|
48
|
+
currentCssSource = value;
|
|
49
|
+
}
|
|
42
50
|
},
|
|
43
51
|
});
|
|
44
52
|
|
|
45
|
-
return
|
|
53
|
+
return () => {
|
|
54
|
+
remove();
|
|
55
|
+
stylesheet = undefined;
|
|
56
|
+
currentCssSource = undefined;
|
|
57
|
+
};
|
|
46
58
|
};
|
|
47
59
|
|
|
48
60
|
export { installImportMetaCssDev };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { startServer,
|
|
1
|
+
import { startServer, serverPluginCORS, jsenvAccessControlAllowedHeaders, serverPluginStaticFiles, serverPluginErrorHandler } from "@jsenv/server";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { assertAndNormalizeDirectoryUrl, createLogger, Abort, raceProcessTeardownEvents, createTaskLog } from "./jsenv_core_packages.js";
|
|
4
4
|
import "./jsenv_core_node_modules.js";
|
|
@@ -35,7 +35,7 @@ const startBuildServer = async ({
|
|
|
35
35
|
buildMainFilePath = "index.html",
|
|
36
36
|
port = 9779,
|
|
37
37
|
routes,
|
|
38
|
-
|
|
38
|
+
serverPlugins = [],
|
|
39
39
|
acceptAnyIp,
|
|
40
40
|
hostname,
|
|
41
41
|
https,
|
|
@@ -119,8 +119,8 @@ const startBuildServer = async ({
|
|
|
119
119
|
serverTiming: true,
|
|
120
120
|
requestWaitingMs: 60_000,
|
|
121
121
|
routes,
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
plugins: [
|
|
123
|
+
serverPluginCORS({
|
|
124
124
|
accessControlAllowRequestOrigin: true,
|
|
125
125
|
accessControlAllowRequestMethod: true,
|
|
126
126
|
accessControlAllowRequestHeaders: true,
|
|
@@ -128,12 +128,12 @@ const startBuildServer = async ({
|
|
|
128
128
|
accessControlAllowCredentials: true,
|
|
129
129
|
timingAllowOrigin: true,
|
|
130
130
|
}),
|
|
131
|
-
...
|
|
132
|
-
|
|
131
|
+
...serverPlugins,
|
|
132
|
+
serverPluginStaticFiles({
|
|
133
133
|
directoryUrl: buildDirectoryUrl,
|
|
134
134
|
mainFilePath: buildMainFilePath,
|
|
135
135
|
}),
|
|
136
|
-
|
|
136
|
+
serverPluginErrorHandler({
|
|
137
137
|
sendErrorDetails: false,
|
|
138
138
|
}),
|
|
139
139
|
],
|