@opencode/browse 0.0.17-dev.180 → 0.0.17-dev.181
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/{Runtime-jrg7sc9p.mjs → Runtime-xss8qan1.mjs} +1 -1
- package/dist/{cli-dbb5bjne.mjs → cli-1bdh4p0a.mjs} +37 -38
- package/dist/cli.mjs +14 -14
- package/dist/{helpers-mbetgbwv.mjs → helpers-bbaa1vjs.mjs} +1 -3
- package/dist/{index-j79y2me1.mjs → index-gjq7chrk.mjs} +2 -2
- package/dist/{legacy-runtime-eky6yenx.mjs → legacy-runtime-yjsm0xpg.mjs} +30 -17
- package/dist/{main-44rp8pxg.mjs → main-32bwyqja.mjs} +4 -4
- package/dist/{main-f98q5tcf.mjs → main-6hvv25x8.mjs} +27 -29
- package/dist/{main-v2a390e1.mjs → main-6qfvnjxc.mjs} +7 -9
- package/dist/{main-3mhynene.mjs → main-9frwnsnf.mjs} +3 -5
- package/dist/{main-048kx59h.mjs → main-akpa411k.mjs} +6 -8
- package/dist/main-bt237ys7.mjs +1012 -0
- package/dist/main-d5ke1bpm.mjs +4 -0
- package/dist/{main-s3g4jwx5.mjs → main-jeta10c6.mjs} +23 -25
- package/dist/{main-wpt5ha44.mjs → main-m45zegrn.mjs} +371 -167
- package/dist/{main-fpn564ph.mjs → main-pq962g72.mjs} +7 -4
- package/dist/main-q4typx7c.mjs +213 -0
- package/dist/{main-r8g3xydm.mjs → main-qccyxwg8.mjs} +3 -5
- package/dist/{main-awaqqre9.mjs → main-rb7dermc.mjs} +117 -4
- package/dist/{main-46wtkfsd.mjs → main-reh7k0hv.mjs} +199 -989
- package/dist/{main-jwss6gk9.mjs → main-rvn834gn.mjs} +2 -2
- package/dist/{main-wfmad10p.mjs → main-sfxkq31s.mjs} +16 -18
- package/dist/{main-q2d5bd1e.mjs → main-tg0r67xj.mjs} +8 -10
- package/dist/{main-g1frnq76.mjs → main-tk2thty0.mjs} +8 -7
- package/dist/{mcp-amxrbrbd.mjs → mcp-rjpmt73q.mjs} +31 -32
- package/dist/{migrate-07f3f3yp.mjs → migrate-hggn66v2.mjs} +5 -6
- package/dist/{relay-e7fx469h.mjs → relay-fm6q9hnx.mjs} +87 -60
- package/dist/{runtime-update-xt7x7j6c.mjs → runtime-update-vdw1eajx.mjs} +9 -9
- package/dist/{setup-m85mamg6.mjs → setup-wyrpwq4c.mjs} +196 -129
- package/dist/{supervisor-6zbwkkpt.mjs → supervisor-nbce8yhg.mjs} +10 -6
- package/dist/{update-drswqt2m.mjs → update-be8dfw51.mjs} +3 -4
- package/dist/{version-v3heqz8b.mjs → version-6j8cdg2k.mjs} +1 -1
- package/package.json +1 -1
- package/dist/main-4h7rfhhr.mjs +0 -61
- package/dist/main-amkq7v9m.mjs +0 -4
- package/dist/main-gg7f12gg.mjs +0 -114
- package/dist/main-qazf3bhk.mjs +0 -223
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writePrivateJsonFileSync,
|
|
3
|
+
defaultPort2
|
|
4
|
+
} from "./main-bt237ys7.mjs";
|
|
5
|
+
import {
|
|
6
|
+
stateRoot
|
|
7
|
+
} from "./main-rb7dermc.mjs";
|
|
8
|
+
|
|
9
|
+
// src/relay/port.ts
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import net from "node:net";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
var fallbackPorts = [19990, 19991, 19992, 19993, 19994, 19995, 19996, 19997];
|
|
14
|
+
var endpointForPort = (port) => `http://127.0.0.1:${port}`;
|
|
15
|
+
function envPort(env = process.env) {
|
|
16
|
+
const raw = env.OPENCODE_BROWSER_PORT;
|
|
17
|
+
if (raw === undefined || raw.trim() === "")
|
|
18
|
+
return;
|
|
19
|
+
const port = Number(raw);
|
|
20
|
+
return Number.isSafeInteger(port) && port > 0 && port < 65536 ? port : undefined;
|
|
21
|
+
}
|
|
22
|
+
var configuredRelayPort = (env = process.env) => envPort(env) ?? defaultPort2;
|
|
23
|
+
var relayPortPinned = (env = process.env) => envPort(env) !== undefined;
|
|
24
|
+
var isPort = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value < 65536;
|
|
25
|
+
var isPositiveInt = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
26
|
+
var relayStatePath = (root = stateRoot(), configuredPort = configuredRelayPort()) => path.join(root, "relays", String(configuredPort), "relay.json");
|
|
27
|
+
var lastRelayPortPath = (root = stateRoot(), configuredPort = configuredRelayPort()) => path.join(root, "relays", String(configuredPort), "last-port.json");
|
|
28
|
+
function readLastRelayPort(root = stateRoot(), configuredPort = configuredRelayPort()) {
|
|
29
|
+
try {
|
|
30
|
+
const value = JSON.parse(fs.readFileSync(lastRelayPortPath(root, configuredPort), "utf8"));
|
|
31
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && isPort(value.port) ? value.port : undefined;
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function writeLastRelayPort(port, root = stateRoot(), configuredPort = configuredRelayPort()) {
|
|
37
|
+
writePrivateJsonFileSync(lastRelayPortPath(root, configuredPort), { port }, { ensureParent: true });
|
|
38
|
+
}
|
|
39
|
+
function readRelayState(root = stateRoot(), configuredPort = configuredRelayPort()) {
|
|
40
|
+
try {
|
|
41
|
+
const value = JSON.parse(fs.readFileSync(relayStatePath(root, configuredPort), "utf8"));
|
|
42
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
43
|
+
return;
|
|
44
|
+
if (!isPort(value.port) || value.configuredPort !== configuredPort || !isPositiveInt(value.pid))
|
|
45
|
+
return;
|
|
46
|
+
if (typeof value.instanceId !== "string" || value.instanceId === "" || typeof value.startedAt !== "string")
|
|
47
|
+
return;
|
|
48
|
+
return {
|
|
49
|
+
port: value.port,
|
|
50
|
+
configuredPort: value.configuredPort,
|
|
51
|
+
pid: value.pid,
|
|
52
|
+
instanceId: value.instanceId,
|
|
53
|
+
startedAt: value.startedAt
|
|
54
|
+
};
|
|
55
|
+
} catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function writeRelayState(state, root = stateRoot()) {
|
|
60
|
+
writePrivateJsonFileSync(relayStatePath(root, state.configuredPort), state, { ensureParent: true });
|
|
61
|
+
}
|
|
62
|
+
function removeRelayState(instanceId, root = stateRoot(), configuredPort = configuredRelayPort()) {
|
|
63
|
+
const state = readRelayState(root, configuredPort);
|
|
64
|
+
if (!state || state.instanceId !== instanceId)
|
|
65
|
+
return;
|
|
66
|
+
try {
|
|
67
|
+
fs.rmSync(relayStatePath(root, state.configuredPort), { force: true });
|
|
68
|
+
} catch {}
|
|
69
|
+
}
|
|
70
|
+
function processAlive(pid) {
|
|
71
|
+
try {
|
|
72
|
+
process.kill(pid, 0);
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function resolveRelayPort(root = stateRoot()) {
|
|
79
|
+
const pinned = envPort();
|
|
80
|
+
if (pinned !== undefined)
|
|
81
|
+
return pinned;
|
|
82
|
+
const state = readRelayState(root);
|
|
83
|
+
if (state && state.configuredPort === configuredRelayPort() && processAlive(state.pid))
|
|
84
|
+
return state.port;
|
|
85
|
+
return defaultPort2;
|
|
86
|
+
}
|
|
87
|
+
function relayPortCandidates(configuredPort = configuredRelayPort()) {
|
|
88
|
+
return [...new Set([configuredPort, ...fallbackPorts])];
|
|
89
|
+
}
|
|
90
|
+
var browseVersion = (body) => typeof body === "object" && body !== null && typeof body.version === "string" && typeof body.instanceId === "string";
|
|
91
|
+
var relayStarting = (body) => typeof body === "object" && body !== null && body.code === "relay-starting";
|
|
92
|
+
async function probeRelayPort(port, timeoutMs = 500) {
|
|
93
|
+
try {
|
|
94
|
+
const response = await fetch(`${endpointForPort(port)}/version`, {
|
|
95
|
+
redirect: "manual",
|
|
96
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
97
|
+
});
|
|
98
|
+
const body = await response.json().catch(() => {
|
|
99
|
+
return;
|
|
100
|
+
});
|
|
101
|
+
if (response.status === 200 && browseVersion(body))
|
|
102
|
+
return "browse";
|
|
103
|
+
if (response.status === 503 && relayStarting(body))
|
|
104
|
+
return "browse";
|
|
105
|
+
return "other";
|
|
106
|
+
} catch {
|
|
107
|
+
return "nobody";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function browseVersionAt(port, timeoutMs) {
|
|
111
|
+
try {
|
|
112
|
+
const response = await fetch(`${endpointForPort(port)}/version`, {
|
|
113
|
+
redirect: "manual",
|
|
114
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
115
|
+
});
|
|
116
|
+
if (response.status !== 200)
|
|
117
|
+
return;
|
|
118
|
+
const body = await response.json().catch(() => {
|
|
119
|
+
return;
|
|
120
|
+
});
|
|
121
|
+
return browseVersion(body) ? body : undefined;
|
|
122
|
+
} catch {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function verifiedRelay(options = {}) {
|
|
127
|
+
const root = options.root ?? stateRoot();
|
|
128
|
+
const configuredPort = configuredRelayPort();
|
|
129
|
+
const state = readRelayState(root, configuredPort);
|
|
130
|
+
const live = state !== undefined && state.configuredPort === configuredPort && processAlive(state.pid) ? state : undefined;
|
|
131
|
+
const port = envPort() ?? live?.port ?? defaultPort2;
|
|
132
|
+
const version = await browseVersionAt(port, options.timeoutMs ?? 3000);
|
|
133
|
+
if (!version)
|
|
134
|
+
return;
|
|
135
|
+
const reread = readRelayState(root, configuredPort);
|
|
136
|
+
const after = reread !== undefined && reread.configuredPort === configuredPort && processAlive(reread.pid) ? reread : undefined;
|
|
137
|
+
const same = live === undefined ? true : after !== undefined && after.port === live.port && after.instanceId === live.instanceId;
|
|
138
|
+
if (!same)
|
|
139
|
+
return;
|
|
140
|
+
if (after && (after.port !== port || version.instanceId !== after.instanceId))
|
|
141
|
+
return;
|
|
142
|
+
return { endpoint: endpointForPort(port), instanceId: version.instanceId };
|
|
143
|
+
}
|
|
144
|
+
async function verifiedRelayEndpoint(options = {}) {
|
|
145
|
+
return (await verifiedRelay(options))?.endpoint;
|
|
146
|
+
}
|
|
147
|
+
async function liveRecordedRelay(configuredPort, root, timeoutMs) {
|
|
148
|
+
const state = readRelayState(root, configuredPort);
|
|
149
|
+
if (!state || state.configuredPort !== configuredPort || !processAlive(state.pid))
|
|
150
|
+
return;
|
|
151
|
+
const version = await browseVersionAt(state.port, timeoutMs);
|
|
152
|
+
return version?.instanceId === state.instanceId ? state : undefined;
|
|
153
|
+
}
|
|
154
|
+
async function liveRelayPort(options = {}) {
|
|
155
|
+
const root = options.root ?? stateRoot();
|
|
156
|
+
const state = await liveRecordedRelay(configuredRelayPort(), root, options.timeoutMs ?? 800);
|
|
157
|
+
return state?.port;
|
|
158
|
+
}
|
|
159
|
+
function portListText(ports) {
|
|
160
|
+
const groups = [];
|
|
161
|
+
const sorted = [...ports].sort((left, right) => left - right);
|
|
162
|
+
for (let index = 0;index < sorted.length; index++) {
|
|
163
|
+
const first = sorted[index];
|
|
164
|
+
let last = first;
|
|
165
|
+
while (sorted[index + 1] === last + 1)
|
|
166
|
+
last = sorted[++index];
|
|
167
|
+
groups.push(first === last ? String(first) : `${first}-${last}`);
|
|
168
|
+
}
|
|
169
|
+
return groups.join(", ");
|
|
170
|
+
}
|
|
171
|
+
function canBind(host, port) {
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
const server = net.createServer();
|
|
174
|
+
server.unref();
|
|
175
|
+
server.once("error", (error) => resolve(error.code !== "EADDRINUSE"));
|
|
176
|
+
server.listen({ host, port, exclusive: true }, () => server.close(() => resolve(true)));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
async function canListen(host, port) {
|
|
180
|
+
if (!await canBind(host, port))
|
|
181
|
+
return false;
|
|
182
|
+
return loopbackHost(host) || canBind("127.0.0.1", port);
|
|
183
|
+
}
|
|
184
|
+
var alreadyInUse = (host, port) => new Error(`listen EADDRINUSE: address already in use ${host}:${port}`);
|
|
185
|
+
var loopbackHost = (host) => host === "localhost" || host === "::1" || host === "[::1]" || /^127\./.test(host);
|
|
186
|
+
async function chooseRelayPort(options = {}) {
|
|
187
|
+
const configuredPort = options.configuredPort ?? configuredRelayPort();
|
|
188
|
+
const pinned = options.pinned ?? relayPortPinned();
|
|
189
|
+
if (pinned)
|
|
190
|
+
return configuredPort;
|
|
191
|
+
const host = options.host ?? "127.0.0.1";
|
|
192
|
+
const root = options.root ?? stateRoot();
|
|
193
|
+
const candidates = options.candidates ?? relayPortCandidates(configuredPort);
|
|
194
|
+
const probeTimeoutMs = options.probeTimeoutMs ?? 500;
|
|
195
|
+
const recorded = await liveRecordedRelay(configuredPort, root, probeTimeoutMs);
|
|
196
|
+
if (recorded)
|
|
197
|
+
throw alreadyInUse(host, recorded.port);
|
|
198
|
+
const last = !loopbackHost(host) ? readLastRelayPort(root, configuredPort) : undefined;
|
|
199
|
+
if (last !== undefined && await canListen(host, last))
|
|
200
|
+
return last;
|
|
201
|
+
for (const port of candidates) {
|
|
202
|
+
if (await canListen(host, port))
|
|
203
|
+
return port;
|
|
204
|
+
const owner = await probeRelayPort(port, probeTimeoutMs);
|
|
205
|
+
if (owner === "browse")
|
|
206
|
+
throw alreadyInUse(host, port);
|
|
207
|
+
if (owner === "nobody")
|
|
208
|
+
throw alreadyInUse(host, port);
|
|
209
|
+
}
|
|
210
|
+
throw new Error(`browse relay ports ${portListText(candidates)} are all in use. Set OPENCODE_BROWSER_PORT to a free port, or stop the program holding them.`);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export { endpointForPort, configuredRelayPort, relayPortPinned, writeLastRelayPort, readRelayState, writeRelayState, removeRelayState, processAlive, resolveRelayPort, probeRelayPort, verifiedRelay, verifiedRelayEndpoint, liveRelayPort, chooseRelayPort };
|
|
@@ -3,13 +3,11 @@ import {
|
|
|
3
3
|
compiledBinary,
|
|
4
4
|
checkoutRoot,
|
|
5
5
|
cliCommand,
|
|
6
|
+
unpackedReloadAdvice,
|
|
6
7
|
installedRuntime2,
|
|
7
8
|
autoUpdateStatus,
|
|
8
9
|
updateAvailable
|
|
9
|
-
} from "./main-
|
|
10
|
-
import {
|
|
11
|
-
unpackedReloadAdvice
|
|
12
|
-
} from "./main-gg7f12gg.mjs";
|
|
10
|
+
} from "./main-rb7dermc.mjs";
|
|
13
11
|
|
|
14
12
|
// src/update.ts
|
|
15
13
|
import { execFile, spawnSync } from "node:child_process";
|
|
@@ -315,7 +313,7 @@ function runUpdate(args, deps) {
|
|
|
315
313
|
async function runUpdateCommand2(args) {
|
|
316
314
|
const log = (line) => process.stdout.write(line + `
|
|
317
315
|
`);
|
|
318
|
-
const { runInstalledUpdate } = await import("./runtime-update-
|
|
316
|
+
const { runInstalledUpdate } = await import("./runtime-update-vdw1eajx.mjs");
|
|
319
317
|
if (await runInstalledUpdate(args))
|
|
320
318
|
return;
|
|
321
319
|
if (compiledBinary()) {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./main-pmfd055v.mjs";
|
|
5
5
|
import {
|
|
6
6
|
opencodeBrowserVersion2
|
|
7
|
-
} from "./main-
|
|
7
|
+
} from "./main-d5ke1bpm.mjs";
|
|
8
8
|
|
|
9
9
|
// src/paths.ts
|
|
10
10
|
import fs from "node:fs";
|
|
@@ -114,7 +114,7 @@ function cliInstall() {
|
|
|
114
114
|
return { kind: "binary", binary: installedBinary() ?? process.execPath, pathEnv: process.env.PATH };
|
|
115
115
|
if (fromCheckout())
|
|
116
116
|
return { kind: "checkout", bundle: path.join(packageRoot(), "dist", "cli.mjs") };
|
|
117
|
-
return { kind: "npm", version: "0.0.17-dev.
|
|
117
|
+
return { kind: "npm", version: "0.0.17-dev.181", npx: /[/\\]_npx[/\\]/.test(process.argv[1] ?? "") };
|
|
118
118
|
}
|
|
119
119
|
function cliPrefix(install = cliInstall()) {
|
|
120
120
|
if (install.kind === "binary") {
|
|
@@ -136,7 +136,7 @@ function storeConfig(env = process.env, baked = { id: "mfnicocicmmlkpjnaffgihfjh
|
|
|
136
136
|
return id ? { id } : {};
|
|
137
137
|
}
|
|
138
138
|
var RELEASE_SERVICE = "https://anoma.ly/release";
|
|
139
|
-
function devExtension(baked = { file: "browse-extension-0.0.17-dev.
|
|
139
|
+
function devExtension(baked = { file: "browse-extension-0.0.17-dev.181.zip", sha256: "b9275dcd45fb9ddd7e271cf7ecb6e13e9928f5265776576deb17a5f5d2b98c8b", size: 187301 }) {
|
|
140
140
|
return baked && /^[0-9a-f]{64}$/.test(baked.sha256) && /^[\w.-]+\.zip$/.test(baked.file) ? baked : undefined;
|
|
141
141
|
}
|
|
142
142
|
var devExtensionUrl = (extension, env = process.env) => `${(env.OPENCODE_BROWSER_RELEASE_SERVICE || RELEASE_SERVICE).replace(/\/+$/, "")}/browse/files/${extension.sha256}/${extension.file}`;
|
|
@@ -146,6 +146,119 @@ function installCommand() {
|
|
|
146
146
|
return fromCheckout() ? `cd ${quoted(path.dirname(packageRoot()))} && bun run setup` : cliCommand("install");
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
// src/protocol.ts
|
|
150
|
+
var extensionProtocolVersion = 3;
|
|
151
|
+
var minExtensionProtocolVersion = 3;
|
|
152
|
+
var unpackedExtensionId = "afeafocngkodbmaipcngoamamfmekgfo";
|
|
153
|
+
var browserUnresponsive = "The browser isn't answering (asleep, frozen or very busy?). Wake it or wait a moment, then try again.";
|
|
154
|
+
var browserReloading = "browse stopped answering in this browser for over a minute, so the relay asked it to reload. Try again in a few seconds.";
|
|
155
|
+
var unpackedReloadAdvice = "Reload browse on your browser's extensions page (↻).";
|
|
156
|
+
var checkoutReloadPrefix = "Extension protocol incompatible: extension-older; reload ";
|
|
157
|
+
var extensionReconnectAlarmPeriodMs = 30000;
|
|
158
|
+
var legacyExtensionProtocolVersion = 1;
|
|
159
|
+
function extensionProtocolCompatibility(value) {
|
|
160
|
+
const legacy = value === undefined;
|
|
161
|
+
const valid = typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
162
|
+
const version = valid ? value : legacy ? legacyExtensionProtocolVersion : null;
|
|
163
|
+
return { version, compatible: version !== null && version >= minExtensionProtocolVersion && version <= extensionProtocolVersion, legacy };
|
|
164
|
+
}
|
|
165
|
+
function extensionProtocolSkew(version) {
|
|
166
|
+
if (typeof version !== "number")
|
|
167
|
+
return;
|
|
168
|
+
if (version > extensionProtocolVersion)
|
|
169
|
+
return "extension-newer";
|
|
170
|
+
if (version < minExtensionProtocolVersion)
|
|
171
|
+
return "extension-older";
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
function extensionProtocolAdvice(version, commands, distribution) {
|
|
175
|
+
const skew = extensionProtocolSkew(version);
|
|
176
|
+
const versions = `extension protocol ${version ?? "unknown"}, this relay speaks ${minExtensionProtocolVersion === extensionProtocolVersion ? extensionProtocolVersion : `${minExtensionProtocolVersion} to ${extensionProtocolVersion}`}`;
|
|
177
|
+
if (skew === "extension-newer")
|
|
178
|
+
return `The browse extension is newer than this browse CLI (${versions}). Update the CLI: run \`${commands.install}\` (an npm install with automatic updates also catches up by itself within a day), then restart opencode.`;
|
|
179
|
+
if (skew === "extension-older") {
|
|
180
|
+
const store = "The Chrome Web Store updates it within a few hours (to update now, open chrome://extensions, turn on Developer mode and click Update).";
|
|
181
|
+
const next = distribution === "unpacked" ? unpackedReloadAdvice : distribution === "store" ? store : `For an unpacked extension: ${unpackedReloadAdvice} For a store extension: ${store}`;
|
|
182
|
+
return `The browse extension is older than this browse CLI (${versions}). ${next}`;
|
|
183
|
+
}
|
|
184
|
+
return `The browse extension and this browse CLI don't speak the same protocol (${versions}). Run \`${commands.install}\` again and update the extension.`;
|
|
185
|
+
}
|
|
186
|
+
function makePageStatus(options) {
|
|
187
|
+
return {
|
|
188
|
+
state: options.state,
|
|
189
|
+
owner: options.targetOwner === "user" ? "user" : "session",
|
|
190
|
+
...options.sessionId ? { sessionId: options.sessionId } : {},
|
|
191
|
+
...options.sessionId && options.readOnly ? { readOnly: true } : {},
|
|
192
|
+
...options.message ? { message: options.message } : {},
|
|
193
|
+
...options.handoffId ? { handoffId: options.handoffId } : {},
|
|
194
|
+
...options.recording ? { recording: true } : {}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
var extensionCommandMethodValues = [
|
|
198
|
+
"ping",
|
|
199
|
+
"debugger.attach",
|
|
200
|
+
"debugger.detach",
|
|
201
|
+
"debugger.sendCommand",
|
|
202
|
+
"tabs.create",
|
|
203
|
+
"tabs.remove",
|
|
204
|
+
"tabs.group",
|
|
205
|
+
"tabs.ungroup",
|
|
206
|
+
"action.setAttached",
|
|
207
|
+
"action.setBadge",
|
|
208
|
+
"pageStatus.set",
|
|
209
|
+
"pageStatus.clear",
|
|
210
|
+
"runtime.reload",
|
|
211
|
+
"recording.start",
|
|
212
|
+
"recording.stop",
|
|
213
|
+
"recording.status",
|
|
214
|
+
"recording.cancel",
|
|
215
|
+
"tabs.cleanup",
|
|
216
|
+
"update.notice",
|
|
217
|
+
"relay.settings",
|
|
218
|
+
"settings.get",
|
|
219
|
+
"settings.set"
|
|
220
|
+
];
|
|
221
|
+
var extensionEventMethodValues = [
|
|
222
|
+
"protocol",
|
|
223
|
+
"hello",
|
|
224
|
+
"auth.code",
|
|
225
|
+
"auth.response",
|
|
226
|
+
"ready",
|
|
227
|
+
"toolbar.clicked",
|
|
228
|
+
"handoff.completed",
|
|
229
|
+
"debugger.event",
|
|
230
|
+
"debugger.attached",
|
|
231
|
+
"debugger.detached",
|
|
232
|
+
"tabs.removed",
|
|
233
|
+
"tabs.opened",
|
|
234
|
+
"pong",
|
|
235
|
+
"log",
|
|
236
|
+
"recording.cancelled",
|
|
237
|
+
"pageStatus.requested",
|
|
238
|
+
"settings"
|
|
239
|
+
];
|
|
240
|
+
function parseJsonObject(input) {
|
|
241
|
+
const parsed = JSON.parse(input);
|
|
242
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
243
|
+
throw new Error("Expected JSON object");
|
|
244
|
+
}
|
|
245
|
+
return parsed;
|
|
246
|
+
}
|
|
247
|
+
var extensionCommandMethods = new Set(extensionCommandMethodValues);
|
|
248
|
+
var extensionEventMethods = new Set(extensionEventMethodValues);
|
|
249
|
+
function isCdpRequest(input) {
|
|
250
|
+
return typeof input.id === "number" && typeof input.method === "string" && (input.params === undefined || isJsonObject(input.params)) && (input.sessionId === undefined || typeof input.sessionId === "string");
|
|
251
|
+
}
|
|
252
|
+
function isExtensionResponse(input) {
|
|
253
|
+
return typeof input.id === "number" && (input.result === undefined || isJsonObject(input.result)) && (input.error === undefined || typeof input.error === "string") && !(input.result !== undefined && input.error !== undefined);
|
|
254
|
+
}
|
|
255
|
+
function isExtensionEvent(input) {
|
|
256
|
+
return typeof input.method === "string" && extensionEventMethods.has(input.method) && (input.params === undefined || isJsonObject(input.params));
|
|
257
|
+
}
|
|
258
|
+
function isJsonObject(value) {
|
|
259
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
260
|
+
}
|
|
261
|
+
|
|
149
262
|
// src/update/auto-update.ts
|
|
150
263
|
import { spawn, spawnSync } from "node:child_process";
|
|
151
264
|
import { chmodSync as chmodSync2, closeSync, existsSync, mkdirSync as mkdirSync2, mkdtempSync, openSync, readFileSync as readFileSync2, renameSync, rmSync, realpathSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -807,4 +920,4 @@ function spawnRuntimeChild(runtime, args, onExit, env = process.env) {
|
|
|
807
920
|
}
|
|
808
921
|
}
|
|
809
922
|
|
|
810
|
-
export { defaultRoots, configRoot2, dataRoot, stateRoot, cacheRoot, binRoot, installedBinaryPath, installerBinaryPath, defaultSettingsPath, oldStoreMarker, fromCheckout, compiledBinary, binaryPackage, binaryName, scriptEntry, entryCommand, resolveWindowsShim, entrySpawnCommand, runningEntry, checkoutRoot, cliCommand, PUBLIC_STORE_ID, storeConfig, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand, runningServiceTarget, releaseChannel, checkRelease, autoUpdateModes, UPDATE_VERSION, channelOf, compareVersions, installedRuntime2, updateTarget, npmGlobalRoot, installedVersion, updateState, autoUpdateOverride, storedMode, effectiveMode, setStoredMode, autoUpdateStatus, describeAutoUpdate, updateAvailable, runCommand, registryUrl, fetchPublished, runInstaller, createAutoUpdater };
|
|
923
|
+
export { defaultRoots, configRoot2, dataRoot, stateRoot, cacheRoot, binRoot, installedBinaryPath, installerBinaryPath, defaultSettingsPath, oldStoreMarker, fromCheckout, compiledBinary, binaryPackage, binaryName, scriptEntry, entryCommand, resolveWindowsShim, entrySpawnCommand, runningEntry, checkoutRoot, cliCommand, PUBLIC_STORE_ID, storeConfig, devExtension, devExtensionUrl, devExtensionFolder, storeUrl, installCommand, extensionProtocolVersion, minExtensionProtocolVersion, unpackedExtensionId, browserUnresponsive, browserReloading, unpackedReloadAdvice, checkoutReloadPrefix, extensionReconnectAlarmPeriodMs, extensionProtocolCompatibility, extensionProtocolSkew, extensionProtocolAdvice, makePageStatus, parseJsonObject, isCdpRequest, isExtensionResponse, isExtensionEvent, isJsonObject, runningServiceTarget, releaseChannel, checkRelease, autoUpdateModes, UPDATE_VERSION, channelOf, compareVersions, installedRuntime2, updateTarget, npmGlobalRoot, installedVersion, updateState, autoUpdateOverride, storedMode, effectiveMode, setStoredMode, autoUpdateStatus, describeAutoUpdate, updateAvailable, runCommand, registryUrl, fetchPublished, runInstaller, createAutoUpdater };
|