@devries-cameron20 / t3code Mirror · read-only
Fork 0

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, 04:45 UTC

main
ts 42 lines 1.25 KB
Raw
1 import * as Effect from "effect/Effect";
2 import * as Layer from "effect/Layer";
3
4 // Intentionally duplicated from alchemy's Util/PlatformServices.ts: this
5 // package must not depend on "alchemy", and the message names this package.
6 const importPlatformPeer = <A>(
7 peerDependency: "@effect/platform-bun" | "@effect/platform-node",
8 load: () => Promise<A>,
9 ): Promise<A> =>
10 load().catch(() => {
11 console.error(
12 [
13 `"@alchemy.run/cloudflare-frameworks" could not load its peer dependency "${peerDependency}".`,
14 `Install a compatible version of "${peerDependency}" alongside "@alchemy.run/cloudflare-frameworks".`,
15 ].join("\n"),
16 );
17 process.exit(1);
18 });
19
20 const BunServices = {
21 layer: Layer.unwrap(
22 Effect.promise(() =>
23 importPlatformPeer(
24 "@effect/platform-bun",
25 () => import("@effect/platform-bun/BunServices"),
26 ).then((module) => module.layer),
27 ),
28 ),
29 };
30
31 const NodeServices = {
32 layer: Layer.unwrap(
33 Effect.promise(() =>
34 importPlatformPeer(
35 "@effect/platform-node",
36 () => import("@effect/platform-node/NodeServices"),
37 ).then((module) => module.layer),
38 ),
39 ),
40 };
41
42 export const PlatformServices = typeof Bun === "undefined" ? NodeServices.layer : BunServices.layer;