@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, 06:00 UTC

main
ts 70 lines 2.11 KB
Raw
1 import * as Effect from "effect/Effect";
2 import * as FrameworkCore from "../core/index.ts";
3 import {
4 makeWakuSourceProvider,
5 SourceProviderError,
6 type SourceProvider,
7 type WakuBuildChildConfig,
8 type WakuSourceOptions,
9 } from "../waku/source.ts";
10 import vocsCloudflareTarget from "./cloudflare.ts";
11 import { make as vocsFrameworkLayer } from "./Vocs.ts";
12
13 const PROVIDER = "@alchemy.run/frontend-frameworks/vocs/source";
14
15 export interface VocsSourceOptions {
16 readonly rootDir?: string;
17 /** Vocs build output directory, used to exclude generated files from the input hash. */
18 readonly outDir?: string;
19 readonly memo?: WakuSourceOptions["memo"];
20 }
21
22 export const buildInChild = (config: WakuBuildChildConfig) =>
23 Effect.gen(function* () {
24 const framework = yield* FrameworkCore.Framework;
25 return yield* framework.build({ root: config.rootDir });
26 }).pipe(
27 Effect.provide(
28 vocsFrameworkLayer({
29 root: config.rootDir,
30 target: vocsCloudflareTarget({
31 worker: {
32 compatibilityDate: config.compatibilityDate,
33 compatibilityFlags: config.compatibilityFlags,
34 },
35 }),
36 }),
37 ),
38 );
39
40 export const makeVocsSourceProvider = (options: VocsSourceOptions): SourceProvider =>
41 makeWakuSourceProvider(
42 { ...options, distDir: options.outDir },
43 {
44 provider: PROVIDER,
45 framework: "vocs",
46 displayName: "Vocs",
47 buildModule: import.meta.url,
48 layer: ({ root, target }) =>
49 vocsFrameworkLayer({
50 root,
51 target: vocsCloudflareTarget({ worker: target.config }),
52 }),
53 },
54 );
55
56 const sourceModule = {
57 make: (options: unknown): Effect.Effect<SourceProvider, SourceProviderError> => {
58 if (options !== undefined && (typeof options !== "object" || options === null)) {
59 return Effect.fail(
60 new SourceProviderError({
61 provider: PROVIDER,
62 message: `Invalid options for ${PROVIDER}: expected an object, got ${typeof options}`,
63 }),
64 );
65 }
66 return Effect.succeed(makeVocsSourceProvider((options ?? {}) as VocsSourceOptions));
67 },
68 };
69
70 export default sourceModule;