The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as Effect from "effect/Effect"; |
| 2 | |
| 3 | // Start the import at module evaluation (legal since workerd's 2025-03 |
| 4 | // importable-env change) so the isolate-lifetime layer build that awaits it |
| 5 | // only ever sees an already-settled promise. This keeps the first event's |
| 6 | // build free of I/O-backed awaits: everything after this is pure layer |
| 7 | // assembly plus scheduler microtasks. Outside workerd (deploy/plan in Node, |
| 8 | // vitest) the import rejects and the fallback stub is used; the `.catch` is |
| 9 | // attached immediately so the rejection is always handled. |
| 10 | // Type the import before chaining to avoid expanding the full module namespace |
| 11 | // while TypeScript infers the catch result. |
| 12 | const moduleImport: Promise<typeof import("cloudflare:workers")> = import("cloudflare:workers"); |
| 13 | const modulePromise: Promise<typeof import("cloudflare:workers")> = moduleImport.catch( |
| 14 | () => |
| 15 | ({ |
| 16 | env: {}, |
| 17 | DurableObject: class {}, |
| 18 | WorkflowEntrypoint: class { |
| 19 | async run() {} |
| 20 | }, |
| 21 | }) as any, |
| 22 | ); |
| 23 | |
| 24 | const cloudflare_workers: Effect.Effect<typeof import("cloudflare:workers")> = Effect.promise( |
| 25 | () => modulePromise, |
| 26 | ); |
| 27 | |
| 28 | export default cloudflare_workers; |