@jsenv/plugin-supervisor 1.5.28 → 1.5.30
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.
|
@@ -3,9 +3,11 @@ import process$1 from "node:process";
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import tty from "node:tty";
|
|
5
5
|
import "string-width";
|
|
6
|
-
import {
|
|
6
|
+
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
9
|
+
import "node:path";
|
|
10
|
+
import "node:crypto";
|
|
9
11
|
|
|
10
12
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
11
13
|
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
@@ -487,6 +489,30 @@ const injectQueryParams = (url, params) => {
|
|
|
487
489
|
return normalizeUrl(urlWithParams);
|
|
488
490
|
};
|
|
489
491
|
|
|
492
|
+
const isFileSystemPath = value => {
|
|
493
|
+
if (typeof value !== "string") {
|
|
494
|
+
throw new TypeError("isFileSystemPath first arg must be a string, got ".concat(value));
|
|
495
|
+
}
|
|
496
|
+
if (value[0] === "/") {
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
return startsWithWindowsDriveLetter(value);
|
|
500
|
+
};
|
|
501
|
+
const startsWithWindowsDriveLetter = string => {
|
|
502
|
+
const firstChar = string[0];
|
|
503
|
+
if (!/[a-zA-Z]/.test(firstChar)) return false;
|
|
504
|
+
const secondChar = string[1];
|
|
505
|
+
if (secondChar !== ":") return false;
|
|
506
|
+
return true;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const fileSystemPathToUrl = value => {
|
|
510
|
+
if (!isFileSystemPath(value)) {
|
|
511
|
+
throw new Error("value must be a filesystem path, got ".concat(value));
|
|
512
|
+
}
|
|
513
|
+
return String(pathToFileURL(value));
|
|
514
|
+
};
|
|
515
|
+
|
|
490
516
|
const getCommonPathname = (pathname, otherPathname) => {
|
|
491
517
|
if (pathname === otherPathname) {
|
|
492
518
|
return pathname;
|
|
@@ -571,6 +597,32 @@ const pathnameToParentPathname = pathname => {
|
|
|
571
597
|
return pathname.slice(0, slashLastIndex + 1);
|
|
572
598
|
};
|
|
573
599
|
|
|
600
|
+
const urlToFileSystemPath = url => {
|
|
601
|
+
const urlObject = new URL(url);
|
|
602
|
+
let {
|
|
603
|
+
origin,
|
|
604
|
+
pathname,
|
|
605
|
+
hash
|
|
606
|
+
} = urlObject;
|
|
607
|
+
if (urlObject.protocol === "file:") {
|
|
608
|
+
origin = "file://";
|
|
609
|
+
}
|
|
610
|
+
pathname = pathname.split("/").map(part => {
|
|
611
|
+
return part.replace(/%(?![0-9A-F][0-9A-F])/g, "%25");
|
|
612
|
+
}).join("/");
|
|
613
|
+
if (hash) {
|
|
614
|
+
pathname += "%23".concat(encodeURIComponent(hash.slice(1)));
|
|
615
|
+
}
|
|
616
|
+
const urlString = "".concat(origin).concat(pathname);
|
|
617
|
+
const fileSystemPath = fileURLToPath(urlString);
|
|
618
|
+
if (fileSystemPath[fileSystemPath.length - 1] === "/") {
|
|
619
|
+
// remove trailing / so that nodejs path becomes predictable otherwise it logs
|
|
620
|
+
// the trailing slash on linux but does not on windows
|
|
621
|
+
return fileSystemPath.slice(0, -1);
|
|
622
|
+
}
|
|
623
|
+
return fileSystemPath;
|
|
624
|
+
};
|
|
625
|
+
|
|
574
626
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
575
627
|
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
576
628
|
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
|
@@ -2054,6 +2106,31 @@ const resolvePackageSymlink = packageDirectoryUrl => {
|
|
|
2054
2106
|
return "".concat(packageDirectoryResolvedUrl, "/");
|
|
2055
2107
|
};
|
|
2056
2108
|
|
|
2109
|
+
process.platform === "win32";
|
|
2110
|
+
fileSystemPathToUrl(process.cwd());
|
|
2111
|
+
|
|
2112
|
+
/*
|
|
2113
|
+
* - stats object documentation on Node.js
|
|
2114
|
+
* https://nodejs.org/docs/latest-v13.x/api/fs.html#fs_class_fs_stats
|
|
2115
|
+
*/
|
|
2116
|
+
|
|
2117
|
+
process.platform === "win32";
|
|
2118
|
+
|
|
2119
|
+
/*
|
|
2120
|
+
* - stats object documentation on Node.js
|
|
2121
|
+
* https://nodejs.org/docs/latest-v13.x/api/fs.html#fs_class_fs_stats
|
|
2122
|
+
*/
|
|
2123
|
+
|
|
2124
|
+
process.platform === "win32";
|
|
2125
|
+
|
|
2126
|
+
process.platform === "win32";
|
|
2127
|
+
|
|
2128
|
+
process.platform === "win32";
|
|
2129
|
+
|
|
2130
|
+
process.platform === "win32";
|
|
2131
|
+
|
|
2132
|
+
process.platform === "linux";
|
|
2133
|
+
|
|
2057
2134
|
/*
|
|
2058
2135
|
* This plugin provides a way for jsenv to supervisor js execution:
|
|
2059
2136
|
* - Know how many js are executed, when they are done, collect errors, etc...
|
|
@@ -2242,7 +2319,7 @@ const jsenvPluginSupervisor = ({
|
|
|
2242
2319
|
};
|
|
2243
2320
|
}
|
|
2244
2321
|
const fileUrl = new URL(file, serveInfo.rootDirectoryUrl);
|
|
2245
|
-
const filePath =
|
|
2322
|
+
const filePath = urlToFileSystemPath(fileUrl);
|
|
2246
2323
|
const require = createRequire(import.meta.url);
|
|
2247
2324
|
const launch = require("launch-editor");
|
|
2248
2325
|
launch(filePath, () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-supervisor",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.30",
|
|
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.3.
|
|
30
|
-
"@jsenv/urls": "2.5.
|
|
31
|
-
"@jsenv/sourcemap": "1.2.
|
|
29
|
+
"@jsenv/ast": "6.3.7",
|
|
30
|
+
"@jsenv/urls": "2.5.4",
|
|
31
|
+
"@jsenv/sourcemap": "1.2.27",
|
|
32
32
|
"launch-editor": "2.9.1"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
import { generateContentFrame } from "@jsenv/humanize";
|
|
7
7
|
import { applyNodeEsmResolution } from "@jsenv/node-esm-resolution";
|
|
8
8
|
import { getOriginalPosition } from "@jsenv/sourcemap";
|
|
9
|
-
import { injectQueryParams } from "@jsenv/urls";
|
|
9
|
+
import { injectQueryParams, urlToFileSystemPath } from "@jsenv/urls";
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
12
11
|
import {
|
|
13
12
|
injectSupervisorIntoHTML,
|
|
14
13
|
supervisorFileUrl,
|
|
@@ -212,7 +211,7 @@ export const jsenvPluginSupervisor = ({
|
|
|
212
211
|
};
|
|
213
212
|
}
|
|
214
213
|
const fileUrl = new URL(file, serveInfo.rootDirectoryUrl);
|
|
215
|
-
const filePath =
|
|
214
|
+
const filePath = urlToFileSystemPath(fileUrl);
|
|
216
215
|
const require = createRequire(import.meta.url);
|
|
217
216
|
const launch = require("launch-editor");
|
|
218
217
|
launch(filePath, () => {
|