Preserve the primary Hopper startup failure and launcher diagnostics while retaining resources when cleanup cannot be confirmed. Reauthenticate matching external application sessions before document cleanup, keep the Python bridge available for bounded reconnects, and expose the provider-owned Hopper startup deadline. Real headless Linux Hopper semantic analysis and 65 focused configuration, handshake, cleanup, and bridge tests passed. macOS authorization/crash causes and saved-HOP behavior require their own real-provider verification. Refs #1808 Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
import { readFile, writeFile } from "node:fs/promises";
|
|
|
|
// Model the native helper's external GUI handoff independently of its lifetime.
|
|
const [modePath, receiptPath] = process.argv.slice(2, 4);
|
|
const mode = await readFile(modePath, "utf8");
|
|
const bootstrapIndex = process.argv.indexOf("-Y") + 1;
|
|
if (bootstrapIndex === 0) throw new Error("Missing Hopper bootstrap argument");
|
|
const bootstrapPath = process.argv[bootstrapIndex];
|
|
await writeFile(receiptPath, bootstrapPath);
|
|
if (mode === "denied" || mode === "denied-after-handoff") {
|
|
process.stderr.write(
|
|
"Cannot launch Hopper!\nNot authorized to send Apple events to Hopper Disassembler.\n",
|
|
async () => {
|
|
if (mode === "denied-after-handoff") {
|
|
// A real native helper can create a document before emitting this same
|
|
// diagnostic when caller literals alter its AppleScript construction.
|
|
await writeFile(`${receiptPath}.document-created`, "unconfirmed");
|
|
}
|
|
process.exit(2);
|
|
},
|
|
);
|
|
} else if (mode === "handoff") {
|
|
process.exit(0);
|
|
} else if (mode === "bridge") {
|
|
await import("./fakeLauncher.mjs");
|
|
} else {
|
|
throw new Error(`Unknown Hopper launch admission fixture mode: ${mode}`);
|
|
}
|