@jsenv/plugin-supervisor 1.5.28 → 1.5.29

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 { fileURLToPath, pathToFileURL } from "node:url";
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,24 @@ 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 urlString;
603
+ if (urlObject.hash) {
604
+ const origin = urlObject.protocol === "file:" ? "file://" : urlObject.origin;
605
+ urlString = "".concat(origin).concat(urlObject.pathname).concat(urlObject.search, "%23").concat(urlObject.hash.slice(1));
606
+ } else {
607
+ urlString = urlObject.href;
608
+ }
609
+ const fileSystemPath = fileURLToPath(urlString);
610
+ if (fileSystemPath[fileSystemPath.length - 1] === "/") {
611
+ // remove trailing / so that nodejs path becomes predictable otherwise it logs
612
+ // the trailing slash on linux but does not on windows
613
+ return fileSystemPath.slice(0, -1);
614
+ }
615
+ return fileSystemPath;
616
+ };
617
+
574
618
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
575
619
  const intToChar = new Uint8Array(64); // 64 possible chars.
576
620
  const charToInt = new Uint8Array(128); // z is 122 in ASCII
@@ -2054,6 +2098,31 @@ const resolvePackageSymlink = packageDirectoryUrl => {
2054
2098
  return "".concat(packageDirectoryResolvedUrl, "/");
2055
2099
  };
2056
2100
 
2101
+ process.platform === "win32";
2102
+ fileSystemPathToUrl(process.cwd());
2103
+
2104
+ /*
2105
+ * - stats object documentation on Node.js
2106
+ * https://nodejs.org/docs/latest-v13.x/api/fs.html#fs_class_fs_stats
2107
+ */
2108
+
2109
+ process.platform === "win32";
2110
+
2111
+ /*
2112
+ * - stats object documentation on Node.js
2113
+ * https://nodejs.org/docs/latest-v13.x/api/fs.html#fs_class_fs_stats
2114
+ */
2115
+
2116
+ process.platform === "win32";
2117
+
2118
+ process.platform === "win32";
2119
+
2120
+ process.platform === "win32";
2121
+
2122
+ process.platform === "win32";
2123
+
2124
+ process.platform === "linux";
2125
+
2057
2126
  /*
2058
2127
  * This plugin provides a way for jsenv to supervisor js execution:
2059
2128
  * - Know how many js are executed, when they are done, collect errors, etc...
@@ -2242,7 +2311,7 @@ const jsenvPluginSupervisor = ({
2242
2311
  };
2243
2312
  }
2244
2313
  const fileUrl = new URL(file, serveInfo.rootDirectoryUrl);
2245
- const filePath = fileURLToPath(fileUrl);
2314
+ const filePath = urlToFileSystemPath(fileUrl);
2246
2315
  const require = createRequire(import.meta.url);
2247
2316
  const launch = require("launch-editor");
2248
2317
  launch(filePath, () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-supervisor",
3
- "version": "1.5.28",
3
+ "version": "1.5.29",
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.5",
30
- "@jsenv/urls": "2.5.2",
31
- "@jsenv/sourcemap": "1.2.25",
29
+ "@jsenv/ast": "6.3.6",
30
+ "@jsenv/urls": "2.5.3",
31
+ "@jsenv/sourcemap": "1.2.26",
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 = fileURLToPath(fileUrl);
214
+ const filePath = urlToFileSystemPath(fileUrl);
216
215
  const require = createRequire(import.meta.url);
217
216
  const launch = require("launch-editor");
218
217
  launch(filePath, () => {