| 1 | // @effect-diagnostics nodeBuiltinImport:off - The synchronous signed bootstrap runs before Effect services exist. |
| 2 | import * as NodeOS from "node:os"; |
| 3 | import * as NodePath from "node:path"; |
| 4 | import * as Option from "effect/Option"; |
| 5 | |
| 6 | import { resolveDesktopBaseDir, resolveDesktopStateDir } from "./app/DesktopStatePaths.ts"; |
| 7 | import { readActiveForkRuntime } from "./updates/forkRuntime.ts"; |
| 8 | |
| 9 | delete process.env.T3CODE_DESKTOP_PAYLOAD; |
| 10 | let entry = __dirname; |
| 11 | const app = process.versions.electron |
| 12 | ? (require("electron") as typeof import("electron")).app |
| 13 | : undefined; |
| 14 | if (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 | } |
| 33 | require(NodePath.join(entry, "compileCache.cjs")); |
| 34 | require(NodePath.join(entry, "main.cjs")); |