@monotykamary/localterm-server 2.33.0 → 2.34.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/caffeinate-battery.d.ts +5 -0
- package/dist/caffeinate-battery.d.ts.map +1 -1
- package/dist/caffeinate-battery.js +69 -1
- package/dist/caffeinate-battery.js.map +1 -1
- package/dist/caffeinate-controller.d.ts.map +1 -1
- package/dist/caffeinate-controller.js +3 -18
- package/dist/caffeinate-controller.js.map +1 -1
- package/dist/caffeinate-manager.js +5 -5
- package/dist/caffeinate-manager.js.map +1 -1
- package/dist/caffeinate-platform.d.ts +10 -0
- package/dist/caffeinate-platform.d.ts.map +1 -0
- package/dist/caffeinate-platform.js +73 -0
- package/dist/caffeinate-platform.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +30 -8
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +3 -2
- package/dist/schemas.js.map +1 -1
- package/dist/utils/find-binary-on-path.d.ts +2 -0
- package/dist/utils/find-binary-on-path.d.ts.map +1 -0
- package/dist/utils/find-binary-on-path.js +24 -0
- package/dist/utils/find-binary-on-path.js.map +1 -0
- package/dist/utils/open-chrome-inspect.d.ts.map +1 -1
- package/dist/utils/open-chrome-inspect.js +55 -5
- package/dist/utils/open-chrome-inspect.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { accessSync, constants } from "node:fs";
|
|
2
|
+
import { delimiter, join } from "node:path";
|
|
3
|
+
// Walks PATH for an executable named `name`, returning the first absolute path
|
|
4
|
+
// that's executable or null when nothing matches. Sync because the keep-awake
|
|
5
|
+
// controller reads `supported` at construction (a handful of stat calls scoped
|
|
6
|
+
// to the few PATH dirs, microseconds) and the browser launcher calls it inside
|
|
7
|
+
// a best-effort async handler where brief sync fs is harmless. No shell-out to
|
|
8
|
+
// `which`/`command -v`, so it works without a POSIX shell on PATH.
|
|
9
|
+
export const findBinaryOnPath = (name, envPath = process.env.PATH ?? "") => {
|
|
10
|
+
for (const dir of envPath.split(delimiter)) {
|
|
11
|
+
if (!dir)
|
|
12
|
+
continue;
|
|
13
|
+
const candidate = join(dir, name);
|
|
14
|
+
try {
|
|
15
|
+
accessSync(candidate, constants.X_OK);
|
|
16
|
+
return candidate;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=find-binary-on-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-binary-on-path.js","sourceRoot":"","sources":["../../src/utils/find-binary-on-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,UAAkB,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EACzB,EAAE;IACjB,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3C,IAAI,CAAC,GAAG;YAAE,SAAS;QACnB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC;YACH,UAAU,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;YACtC,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-chrome-inspect.d.ts","sourceRoot":"","sources":["../../src/utils/open-chrome-inspect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"open-chrome-inspect.d.ts","sourceRoot":"","sources":["../../src/utils/open-chrome-inspect.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,IAAI,CAoBtD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import open from "open";
|
|
3
3
|
import { getBrowserCandidates } from "../cdp/detect-chromium.js";
|
|
4
|
+
import { findBinaryOnPath } from "./find-binary-on-path.js";
|
|
4
5
|
// chrome://inspect with the #remote-debugging fragment jumps straight to the
|
|
5
6
|
// "Discover network targets" section the user needs to toggle.
|
|
6
7
|
const CHROME_INSPECT_URL = "chrome://inspect/#remote-debugging";
|
|
@@ -10,13 +11,18 @@ const darwinAppName = (candidateName) => candidateName === "Brave" ? "Brave Brow
|
|
|
10
11
|
// Open chrome://inspect in the user's browser. This is the bootstrap path for
|
|
11
12
|
// users who haven't enabled remote debugging yet, so it must NOT go through CDP.
|
|
12
13
|
// chrome:// URLs can't be navigated to from a web page and have no registered
|
|
13
|
-
// URL-scheme handler on the OS, so the daemon targets a
|
|
14
|
-
//
|
|
15
|
-
//
|
|
14
|
+
// URL-scheme handler on the OS, so the daemon targets a Chromium app — picked
|
|
15
|
+
// dynamically (never assumed): the frontmost one (the browser the user is
|
|
16
|
+
// viewing localterm in), falling back to the first running candidate.
|
|
16
17
|
//
|
|
17
18
|
// macOS: AppleScript `open location` addressed to the chosen app reuses its
|
|
18
|
-
// current profile (avoids the profile picker that `open -a` triggers).
|
|
19
|
-
//
|
|
19
|
+
// current profile (avoids the profile picker that `open -a` triggers).
|
|
20
|
+
// Linux: xdg-open has no chrome:// handler, so invoke the browser binary
|
|
21
|
+
// directly with the URL — a running Chromium reuses the existing instance's
|
|
22
|
+
// profile and opens a new tab (the same profile-reuse behavior the macOS
|
|
23
|
+
// AppleScript buys us). The first installed candidate wins; priority order
|
|
24
|
+
// matches the DevToolsActivePort scan.
|
|
25
|
+
// Elsewhere we fall back to the OS opener. Best-effort — never throws.
|
|
20
26
|
export const openChromeInspect = async () => {
|
|
21
27
|
try {
|
|
22
28
|
if (process.platform === "darwin") {
|
|
@@ -24,12 +30,56 @@ export const openChromeInspect = async () => {
|
|
|
24
30
|
await runOsascript(darwinOpenInspectScript(CHROME_INSPECT_URL, apps));
|
|
25
31
|
return;
|
|
26
32
|
}
|
|
33
|
+
if (process.platform === "linux") {
|
|
34
|
+
const binary = findInstalledLinuxBrowserBinary();
|
|
35
|
+
if (binary !== null) {
|
|
36
|
+
// Fire-and-forget: the browser owns its own lifecycle and must outlive
|
|
37
|
+
// the daemon. detached + unref lets the daemon exit without waiting.
|
|
38
|
+
spawn(binary, [CHROME_INSPECT_URL], { stdio: "ignore", detached: true }).unref();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
await open(CHROME_INSPECT_URL);
|
|
28
43
|
}
|
|
29
44
|
catch {
|
|
30
45
|
/* best-effort — the user can open the page manually */
|
|
31
46
|
}
|
|
32
47
|
};
|
|
48
|
+
// Candidate browser name -> the binary names it ships as on Linux, in the
|
|
49
|
+
// order to prefer (stable over canary, non-suffixed over -stable where both
|
|
50
|
+
// exist). Names align with the linux branch of getBrowserCandidates so the
|
|
51
|
+
// DevToolsActivePort scan and the launcher agree on which browsers localterm
|
|
52
|
+
// looks for.
|
|
53
|
+
const LINUX_BROWSER_BINARIES = {
|
|
54
|
+
"Google Chrome": ["google-chrome-stable", "google-chrome"],
|
|
55
|
+
"Google Chrome Canary": ["google-chrome-unstable", "google-chrome-canary"],
|
|
56
|
+
Chromium: ["chromium", "chromium-browser"],
|
|
57
|
+
"Microsoft Edge": ["microsoft-edge", "microsoft-edge-stable"],
|
|
58
|
+
Brave: ["brave-browser", "brave"],
|
|
59
|
+
Dia: ["dia"],
|
|
60
|
+
Vivaldi: ["vivaldi"],
|
|
61
|
+
Opera: ["opera", "opera-stable"],
|
|
62
|
+
Aside: ["aside"],
|
|
63
|
+
};
|
|
64
|
+
// First candidate browser binary that's executable on PATH, scanning browsers
|
|
65
|
+
// in DevToolsActivePort-scan priority order. Resolves to the absolute path so
|
|
66
|
+
// the spawn isn't PATH-dependent at exec time. Null when no Chromium binary is
|
|
67
|
+
// installed (the caller then falls back to the OS opener).
|
|
68
|
+
const findInstalledLinuxBrowserBinary = () => {
|
|
69
|
+
const binaries = [];
|
|
70
|
+
for (const candidate of getBrowserCandidates()) {
|
|
71
|
+
for (const binary of LINUX_BROWSER_BINARIES[candidate.name] ?? []) {
|
|
72
|
+
if (!binaries.includes(binary))
|
|
73
|
+
binaries.push(binary);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const binary of binaries) {
|
|
77
|
+
const resolved = findBinaryOnPath(binary);
|
|
78
|
+
if (resolved !== null)
|
|
79
|
+
return resolved;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
33
83
|
const darwinOpenInspectScript = (url, apps) => `
|
|
34
84
|
set inspectURL to "${url}"
|
|
35
85
|
set browserApps to {${apps.map((app) => `"${app}"`).join(", ")}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-chrome-inspect.js","sourceRoot":"","sources":["../../src/utils/open-chrome-inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"open-chrome-inspect.js","sourceRoot":"","sources":["../../src/utils/open-chrome-inspect.ts"],"names":[],"mappings":"AAA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