@jsenv/plugin-supervisor 1.5.4 → 1.5.6
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.
|
@@ -1,52 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
1
|
+
import { applyBabelPlugins, parseHtml, visitHtmlNodes, analyzeScriptNode, getHtmlNodeAttribute, getHtmlNodeText, injectJsenvScript, stringifyHtmlAst, getHtmlNodePosition, getUrlForContentInsideHtml, setHtmlNodeText, setHtmlNodeAttributes } from "@jsenv/ast";
|
|
3
2
|
import process$1 from "node:process";
|
|
4
3
|
import os from "node:os";
|
|
5
4
|
import tty from "node:tty";
|
|
6
5
|
import "string-width";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
10
|
-
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
11
|
-
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
|
12
|
-
for (let i = 0; i < chars.length; i++) {
|
|
13
|
-
const c = chars.charCodeAt(i);
|
|
14
|
-
intToChar[i] = c;
|
|
15
|
-
charToInt[c] = i;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const require = createRequire(import.meta.url);
|
|
19
|
-
// consider using https://github.com/7rulnik/source-map-js
|
|
20
|
-
|
|
21
|
-
const requireSourcemap = () => {
|
|
22
|
-
const namespace = require("source-map-js");
|
|
23
|
-
return namespace;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
* https://github.com/mozilla/source-map#sourcemapgenerator
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
requireSourcemap();
|
|
31
|
-
|
|
32
|
-
// https://github.com/mozilla/source-map#sourcemapconsumerprototypeoriginalpositionforgeneratedposition
|
|
33
|
-
const getOriginalPosition = ({
|
|
34
|
-
sourcemap,
|
|
35
|
-
line,
|
|
36
|
-
column,
|
|
37
|
-
bias
|
|
38
|
-
}) => {
|
|
39
|
-
const {
|
|
40
|
-
SourceMapConsumer
|
|
41
|
-
} = requireSourcemap();
|
|
42
|
-
const sourceMapConsumer = new SourceMapConsumer(sourcemap);
|
|
43
|
-
const originalPosition = sourceMapConsumer.originalPositionFor({
|
|
44
|
-
line,
|
|
45
|
-
column,
|
|
46
|
-
bias
|
|
47
|
-
});
|
|
48
|
-
return originalPosition;
|
|
49
|
-
};
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
50
8
|
|
|
51
9
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
52
10
|
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
@@ -571,6 +529,48 @@ const pathnameToParentPathname = pathname => {
|
|
|
571
529
|
return pathname.slice(0, slashLastIndex + 1);
|
|
572
530
|
};
|
|
573
531
|
|
|
532
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
533
|
+
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
534
|
+
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
|
535
|
+
for (let i = 0; i < chars.length; i++) {
|
|
536
|
+
const c = chars.charCodeAt(i);
|
|
537
|
+
intToChar[i] = c;
|
|
538
|
+
charToInt[c] = i;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const require = createRequire(import.meta.url);
|
|
542
|
+
// consider using https://github.com/7rulnik/source-map-js
|
|
543
|
+
|
|
544
|
+
const requireSourcemap = () => {
|
|
545
|
+
const namespace = require("source-map-js");
|
|
546
|
+
return namespace;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
/*
|
|
550
|
+
* https://github.com/mozilla/source-map#sourcemapgenerator
|
|
551
|
+
*/
|
|
552
|
+
|
|
553
|
+
requireSourcemap();
|
|
554
|
+
|
|
555
|
+
// https://github.com/mozilla/source-map#sourcemapconsumerprototypeoriginalpositionforgeneratedposition
|
|
556
|
+
const getOriginalPosition = ({
|
|
557
|
+
sourcemap,
|
|
558
|
+
line,
|
|
559
|
+
column,
|
|
560
|
+
bias
|
|
561
|
+
}) => {
|
|
562
|
+
const {
|
|
563
|
+
SourceMapConsumer
|
|
564
|
+
} = requireSourcemap();
|
|
565
|
+
const sourceMapConsumer = new SourceMapConsumer(sourcemap);
|
|
566
|
+
const originalPosition = sourceMapConsumer.originalPositionFor({
|
|
567
|
+
line,
|
|
568
|
+
column,
|
|
569
|
+
bias
|
|
570
|
+
});
|
|
571
|
+
return originalPosition;
|
|
572
|
+
};
|
|
573
|
+
|
|
574
574
|
const generateSourcemapDataUrl = sourcemap => {
|
|
575
575
|
const asBase64 = Buffer.from(JSON.stringify(sourcemap)).toString("base64");
|
|
576
576
|
return "data:application/json;charset=utf-8;base64,".concat(asBase64);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-supervisor",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
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.2.
|
|
30
|
-
"@jsenv/urls": "2.3.
|
|
31
|
-
"@jsenv/sourcemap": "1.2.
|
|
29
|
+
"@jsenv/ast": "6.2.5",
|
|
30
|
+
"@jsenv/urls": "2.3.1",
|
|
31
|
+
"@jsenv/sourcemap": "1.2.16",
|
|
32
32
|
"launch-editor": "2.8.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
package/src/html_supervisor.js
CHANGED
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
import {
|
|
49
|
-
parseHtml,
|
|
50
|
-
stringifyHtmlAst,
|
|
51
|
-
visitHtmlNodes,
|
|
52
|
-
getHtmlNodeAttribute,
|
|
53
|
-
setHtmlNodeAttributes,
|
|
54
49
|
analyzeScriptNode,
|
|
55
|
-
|
|
50
|
+
getHtmlNodeAttribute,
|
|
56
51
|
getHtmlNodePosition,
|
|
57
52
|
getHtmlNodeText,
|
|
58
|
-
setHtmlNodeText,
|
|
59
53
|
getUrlForContentInsideHtml,
|
|
54
|
+
injectJsenvScript,
|
|
55
|
+
parseHtml,
|
|
56
|
+
setHtmlNodeAttributes,
|
|
57
|
+
setHtmlNodeText,
|
|
58
|
+
stringifyHtmlAst,
|
|
59
|
+
visitHtmlNodes,
|
|
60
60
|
} from "@jsenv/ast";
|
|
61
61
|
import { urlToRelativeUrl } from "@jsenv/urls";
|
|
62
62
|
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* - Know how many js are executed, when they are done, collect errors, etc...
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { generateContentFrame } from "@jsenv/humanize";
|
|
7
|
+
import { getOriginalPosition } from "@jsenv/sourcemap";
|
|
6
8
|
import { createRequire } from "node:module";
|
|
7
9
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
import { getOriginalPosition } from "@jsenv/sourcemap";
|
|
9
|
-
import { generateContentFrame } from "@jsenv/humanize";
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
supervisorFileUrl,
|
|
13
12
|
injectSupervisorIntoHTML,
|
|
13
|
+
supervisorFileUrl,
|
|
14
14
|
} from "./html_supervisor.js";
|
|
15
15
|
|
|
16
16
|
export const jsenvPluginSupervisor = ({
|
package/src/main.js
CHANGED