1// @effect-diagnostics nodeBuiltinImport:off - The synchronous signed bootstrap runs before Effect services exist.
2import * as NodeOS from "node:os";
3import * as NodePath from "node:path";
4import * as Option from "effect/Option";
5
6import { resolveDesktopBaseDir, resolveDesktopStateDir } from "./app/DesktopStatePaths.ts";
7import { readActiveForkRuntime } from "./updates/forkRuntime.ts";
8
9delete process.env.T3CODE_DESKTOP_PAYLOAD;
10let entry = __dirname;
11const app = process.versions.electron
12 ? (require("electron") as typeof import("electron")).app
13 : undefined;
14if (app?.isPackaged) {
15 const t3Home = Option.fromNullishOr(process.env.T3CODE_HOME);
16 const baseDir = resolveDesktopBaseDir({
17 homeDirectory: NodeOS.homedir(),
18 joinPath: NodePath.join,
19 t3Home,
20 });
21 const stateDir = resolveDesktopStateDir({
22 baseDir,
23 isDevelopment: false,
24 joinPath: NodePath.join,
25 t3Home,
26 });
27 const active = readActiveForkRuntime(stateDir, NodePath.resolve(__dirname, "../../.."));
28 if (active !== undefined) {
29 process.env.T3CODE_DESKTOP_PAYLOAD = JSON.stringify(active);
30 entry = NodePath.join(active.directory, "apps/desktop/dist-electron");
31 }
32}
33require(NodePath.join(entry, "compileCache.cjs"));
34require(NodePath.join(entry, "main.cjs"));