@jsenv/plugin-supervisor 1.4.15 → 1.5.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/jsenv_plugin_supervisor.js +15 -28
- package/package.json +4 -4
- package/src/html_supervisor.js +13 -41
|
@@ -4,7 +4,7 @@ import process$1 from "node:process";
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import tty from "node:tty";
|
|
6
6
|
import "string-width";
|
|
7
|
-
import { applyBabelPlugins, parseHtml, visitHtmlNodes, analyzeScriptNode, getHtmlNodeAttribute, getHtmlNodeText,
|
|
7
|
+
import { applyBabelPlugins, parseHtml, visitHtmlNodes, analyzeScriptNode, getHtmlNodeAttribute, getHtmlNodeText, injectJsenvScript, stringifyHtmlAst, getHtmlNodePosition, getUrlForContentInsideHtml, setHtmlNodeText, setHtmlNodeAttributes } from "@jsenv/ast";
|
|
8
8
|
|
|
9
9
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
10
10
|
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
@@ -210,7 +210,7 @@ const createAnsi = ({
|
|
|
210
210
|
if (!color) {
|
|
211
211
|
return text;
|
|
212
212
|
}
|
|
213
|
-
if (text.trim() === "") {
|
|
213
|
+
if (typeof text === "string" && text.trim() === "") {
|
|
214
214
|
// cannot set color of blank chars
|
|
215
215
|
return text;
|
|
216
216
|
}
|
|
@@ -1140,20 +1140,19 @@ const injectSupervisorIntoHTML = async ({
|
|
|
1140
1140
|
}
|
|
1141
1141
|
// 2. Inject supervisor js file + setup call
|
|
1142
1142
|
{
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
}), "jsenv:supervisor");
|
|
1143
|
+
injectJsenvScript(htmlAst, {
|
|
1144
|
+
src: supervisorScriptSrc,
|
|
1145
|
+
initCall: {
|
|
1146
|
+
callee: "window.__supervisor__.setup",
|
|
1147
|
+
params: {
|
|
1148
|
+
...supervisorOptions,
|
|
1149
|
+
serverIsJsenvDevServer: webServer.isJsenvDevServer,
|
|
1150
|
+
rootDirectoryUrl: webServer.rootDirectoryUrl,
|
|
1151
|
+
scriptInfos
|
|
1152
|
+
}
|
|
1153
|
+
},
|
|
1154
|
+
pluginName: "jsenv:supervisor"
|
|
1155
|
+
});
|
|
1157
1156
|
}
|
|
1158
1157
|
// 3. Perform actions (transforming inline script content) and html mutations
|
|
1159
1158
|
if (actions.length > 0) {
|
|
@@ -1165,18 +1164,6 @@ const injectSupervisorIntoHTML = async ({
|
|
|
1165
1164
|
content: htmlModified
|
|
1166
1165
|
};
|
|
1167
1166
|
};
|
|
1168
|
-
const stringifyParams = (params, prefix = "") => {
|
|
1169
|
-
const source = JSON.stringify(params, null, prefix);
|
|
1170
|
-
if (prefix.length) {
|
|
1171
|
-
// remove leading "{\n"
|
|
1172
|
-
// remove leading prefix
|
|
1173
|
-
// remove trailing "\n}"
|
|
1174
|
-
return source.slice(2 + prefix.length, -2);
|
|
1175
|
-
}
|
|
1176
|
-
// remove leading "{"
|
|
1177
|
-
// remove trailing "}"
|
|
1178
|
-
return source.slice(1, -1);
|
|
1179
|
-
};
|
|
1180
1167
|
const generateCodeToSuperviseScriptWithSrc = ({
|
|
1181
1168
|
type,
|
|
1182
1169
|
src
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-supervisor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"/dist/"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@jsenv/ast": "6.1
|
|
30
|
-
"@jsenv/urls": "2.2.
|
|
31
|
-
"@jsenv/sourcemap": "1.2.
|
|
29
|
+
"@jsenv/ast": "6.2.1",
|
|
30
|
+
"@jsenv/urls": "2.2.10",
|
|
31
|
+
"@jsenv/sourcemap": "1.2.13",
|
|
32
32
|
"launch-editor": "2.8.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
package/src/html_supervisor.js
CHANGED
|
@@ -52,8 +52,7 @@ import {
|
|
|
52
52
|
getHtmlNodeAttribute,
|
|
53
53
|
setHtmlNodeAttributes,
|
|
54
54
|
analyzeScriptNode,
|
|
55
|
-
|
|
56
|
-
createHtmlNode,
|
|
55
|
+
injectJsenvScript,
|
|
57
56
|
getHtmlNodePosition,
|
|
58
57
|
getHtmlNodeText,
|
|
59
58
|
setHtmlNodeText,
|
|
@@ -224,33 +223,19 @@ export const injectSupervisorIntoHTML = async (
|
|
|
224
223
|
}
|
|
225
224
|
// 2. Inject supervisor js file + setup call
|
|
226
225
|
{
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
226
|
+
injectJsenvScript(htmlAst, {
|
|
227
|
+
src: supervisorScriptSrc,
|
|
228
|
+
initCall: {
|
|
229
|
+
callee: "window.__supervisor__.setup",
|
|
230
|
+
params: {
|
|
231
|
+
...supervisorOptions,
|
|
232
|
+
serverIsJsenvDevServer: webServer.isJsenvDevServer,
|
|
233
|
+
rootDirectoryUrl: webServer.rootDirectoryUrl,
|
|
234
|
+
scriptInfos,
|
|
235
|
+
},
|
|
233
236
|
},
|
|
234
|
-
"
|
|
235
|
-
);
|
|
236
|
-
injectHtmlNodeAsEarlyAsPossible(
|
|
237
|
-
htmlAst,
|
|
238
|
-
createHtmlNode({
|
|
239
|
-
tagName: "script",
|
|
240
|
-
textContent: `window.__supervisor__.setup({
|
|
241
|
-
${setupParamsSource}
|
|
242
|
-
});`,
|
|
243
|
-
}),
|
|
244
|
-
"jsenv:supervisor",
|
|
245
|
-
);
|
|
246
|
-
injectHtmlNodeAsEarlyAsPossible(
|
|
247
|
-
htmlAst,
|
|
248
|
-
createHtmlNode({
|
|
249
|
-
tagName: "script",
|
|
250
|
-
src: supervisorScriptSrc,
|
|
251
|
-
}),
|
|
252
|
-
"jsenv:supervisor",
|
|
253
|
-
);
|
|
237
|
+
pluginName: "jsenv:supervisor",
|
|
238
|
+
});
|
|
254
239
|
}
|
|
255
240
|
// 3. Perform actions (transforming inline script content) and html mutations
|
|
256
241
|
if (actions.length > 0) {
|
|
@@ -263,19 +248,6 @@ export const injectSupervisorIntoHTML = async (
|
|
|
263
248
|
};
|
|
264
249
|
};
|
|
265
250
|
|
|
266
|
-
const stringifyParams = (params, prefix = "") => {
|
|
267
|
-
const source = JSON.stringify(params, null, prefix);
|
|
268
|
-
if (prefix.length) {
|
|
269
|
-
// remove leading "{\n"
|
|
270
|
-
// remove leading prefix
|
|
271
|
-
// remove trailing "\n}"
|
|
272
|
-
return source.slice(2 + prefix.length, -2);
|
|
273
|
-
}
|
|
274
|
-
// remove leading "{"
|
|
275
|
-
// remove trailing "}"
|
|
276
|
-
return source.slice(1, -1);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
251
|
const generateCodeToSuperviseScriptWithSrc = ({ type, src }) => {
|
|
280
252
|
const srcEncoded = JSON.stringify(src);
|
|
281
253
|
if (type === "js_module") {
|