rechrome 1.10.1 → 1.10.2
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/package.json +1 -1
- package/rech.js +6 -1
- package/rech.ts +6 -1
- package/serve.js +20 -13
- package/serve.ts +20 -13
package/package.json
CHANGED
package/rech.js
CHANGED
|
@@ -381,6 +381,11 @@ async function run(url: string, args: string[]) {
|
|
|
381
381
|
const resolvedEnv = await getClientEnv({ extensionId, extensionToken, profileDirectory, userDataDir });
|
|
382
382
|
const { status, stdout, stderr, files, existingSession } = await callServe(url, args);
|
|
383
383
|
|
|
384
|
+
const isOpenWithUrl = args[0] === "open" && args.length > 1;
|
|
385
|
+
if (existingSession && isOpenWithUrl) {
|
|
386
|
+
return run(url, ["goto", ...args.slice(1)]);
|
|
387
|
+
}
|
|
388
|
+
|
|
384
389
|
if (existingSession)
|
|
385
390
|
console.error(`[rech] session already has open tabs — listing existing tabs instead of opening a new window`);
|
|
386
391
|
if (stderr) {
|
|
@@ -406,7 +411,7 @@ async function run(url: string, args: string[]) {
|
|
|
406
411
|
});
|
|
407
412
|
if (!fileRes.ok) continue;
|
|
408
413
|
const dest = join(dlDir, basename(name));
|
|
409
|
-
await Bun.write(dest, fileRes);
|
|
414
|
+
await Bun.write(dest, await fileRes.arrayBuffer());
|
|
410
415
|
console.error(`[rech] downloaded: ${dest}`);
|
|
411
416
|
}
|
|
412
417
|
}
|
package/rech.ts
CHANGED
|
@@ -381,6 +381,11 @@ async function run(url: string, args: string[]) {
|
|
|
381
381
|
const resolvedEnv = await getClientEnv({ extensionId, extensionToken, profileDirectory, userDataDir });
|
|
382
382
|
const { status, stdout, stderr, files, existingSession } = await callServe(url, args);
|
|
383
383
|
|
|
384
|
+
const isOpenWithUrl = args[0] === "open" && args.length > 1;
|
|
385
|
+
if (existingSession && isOpenWithUrl) {
|
|
386
|
+
return run(url, ["goto", ...args.slice(1)]);
|
|
387
|
+
}
|
|
388
|
+
|
|
384
389
|
if (existingSession)
|
|
385
390
|
console.error(`[rech] session already has open tabs — listing existing tabs instead of opening a new window`);
|
|
386
391
|
if (stderr) {
|
|
@@ -406,7 +411,7 @@ async function run(url: string, args: string[]) {
|
|
|
406
411
|
});
|
|
407
412
|
if (!fileRes.ok) continue;
|
|
408
413
|
const dest = join(dlDir, basename(name));
|
|
409
|
-
await Bun.write(dest, fileRes);
|
|
414
|
+
await Bun.write(dest, await fileRes.arrayBuffer());
|
|
410
415
|
console.error(`[rech] downloaded: ${dest}`);
|
|
411
416
|
}
|
|
412
417
|
}
|
package/serve.js
CHANGED
|
@@ -173,8 +173,8 @@ export async function serve() {
|
|
|
173
173
|
|
|
174
174
|
// For open commands, default to about:blank to avoid leaving connect.html visible
|
|
175
175
|
const isOpenCmd = filteredArgs[0] === "open";
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
const isOpenNoUrl = isOpenCmd && filteredArgs.length === 1;
|
|
177
|
+
if (isOpenNoUrl) filteredArgs.push("about:blank");
|
|
178
178
|
|
|
179
179
|
// bare `rech open` with no URL: warn if session already has tabs
|
|
180
180
|
if (isOpenCmd && filteredArgs.length === 1) {
|
|
@@ -186,19 +186,26 @@ export async function serve() {
|
|
|
186
186
|
stderr: "pipe",
|
|
187
187
|
env: { PATH: process.env.PATH, HOME: process.env.HOME },
|
|
188
188
|
});
|
|
189
|
-
const [listStatus, listOut] = await Promise.
|
|
190
|
-
listProc.exited,
|
|
191
|
-
new
|
|
189
|
+
const [listStatus, listOut] = await Promise.race([
|
|
190
|
+
Promise.all([listProc.exited, new Response(listProc.stdout).text()]),
|
|
191
|
+
new Promise<[number, string]>((resolve) =>
|
|
192
|
+
setTimeout(() => { listProc.kill(); resolve([1, ""]); }, 5000)
|
|
193
|
+
),
|
|
192
194
|
]);
|
|
193
195
|
if (listStatus === 0 && listOut.trim()) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
if (isOpenNoUrl) {
|
|
197
|
+
log(`session ${namespacedSession} already has tabs, returning tab-list hint`);
|
|
198
|
+
return Response.json({
|
|
199
|
+
status: 0,
|
|
200
|
+
stdout: listOut,
|
|
201
|
+
stderr: `[rech] session "${namespacedSession}" already has open tabs:\n`,
|
|
202
|
+
files: [],
|
|
203
|
+
existingSession: true,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// URL specified: navigate to it instead of returning tab-list
|
|
207
|
+
log(`session ${namespacedSession} already has tabs, converting open to goto`);
|
|
208
|
+
filteredArgs[0] = "goto";
|
|
202
209
|
}
|
|
203
210
|
} catch (e) {
|
|
204
211
|
log(`tab-list check failed: ${e}`);
|
package/serve.ts
CHANGED
|
@@ -173,8 +173,8 @@ export async function serve() {
|
|
|
173
173
|
|
|
174
174
|
// For open commands, default to about:blank to avoid leaving connect.html visible
|
|
175
175
|
const isOpenCmd = filteredArgs[0] === "open";
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
const isOpenNoUrl = isOpenCmd && filteredArgs.length === 1;
|
|
177
|
+
if (isOpenNoUrl) filteredArgs.push("about:blank");
|
|
178
178
|
|
|
179
179
|
// bare `rech open` with no URL: warn if session already has tabs
|
|
180
180
|
if (isOpenCmd && filteredArgs.length === 1) {
|
|
@@ -186,19 +186,26 @@ export async function serve() {
|
|
|
186
186
|
stderr: "pipe",
|
|
187
187
|
env: { PATH: process.env.PATH, HOME: process.env.HOME },
|
|
188
188
|
});
|
|
189
|
-
const [listStatus, listOut] = await Promise.
|
|
190
|
-
listProc.exited,
|
|
191
|
-
new
|
|
189
|
+
const [listStatus, listOut] = await Promise.race([
|
|
190
|
+
Promise.all([listProc.exited, new Response(listProc.stdout).text()]),
|
|
191
|
+
new Promise<[number, string]>((resolve) =>
|
|
192
|
+
setTimeout(() => { listProc.kill(); resolve([1, ""]); }, 5000)
|
|
193
|
+
),
|
|
192
194
|
]);
|
|
193
195
|
if (listStatus === 0 && listOut.trim()) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
if (isOpenNoUrl) {
|
|
197
|
+
log(`session ${namespacedSession} already has tabs, returning tab-list hint`);
|
|
198
|
+
return Response.json({
|
|
199
|
+
status: 0,
|
|
200
|
+
stdout: listOut,
|
|
201
|
+
stderr: `[rech] session "${namespacedSession}" already has open tabs:\n`,
|
|
202
|
+
files: [],
|
|
203
|
+
existingSession: true,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// URL specified: navigate to it instead of returning tab-list
|
|
207
|
+
log(`session ${namespacedSession} already has tabs, converting open to goto`);
|
|
208
|
+
filteredArgs[0] = "goto";
|
|
202
209
|
}
|
|
203
210
|
} catch (e) {
|
|
204
211
|
log(`tab-list check failed: ${e}`);
|