@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 51 lines 2 KB
Raw
1 import { isDeployTarget, type DeployTargetInput } from "../core/index.ts";
2 import type { WakuTarget } from "../waku/Waku.ts";
3
4 /**
5 * A deploy target capable of hosting Vocs' Waku/RSC runtime.
6 *
7 * Vocs uses Waku's adapter and environment topology, so its target contract
8 * deliberately extends the existing Waku target hooks. The distinct type and
9 * module boundary keep Vocs target selection independent from the Waku
10 * framework integration.
11 */
12 export interface VocsTarget<Config = unknown> extends WakuTarget<Config> {}
13
14 /** Target-scoped configuration carried by the shared E2E harness. */
15 export interface VocsHarnessTargetOptions {
16 readonly name?: string | undefined;
17 readonly cloudflare?: { readonly worker?: unknown } | undefined;
18 }
19
20 export type VocsTargetOption = DeployTargetInput<VocsTarget, unknown> | VocsHarnessTargetOptions;
21
22 /** The default target is Vocs' own Cloudflare target module. */
23 export const DEFAULT_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/vocs/cloudflare";
24
25 const isDeployTargetInput = (value: unknown): value is DeployTargetInput<VocsTarget, unknown> =>
26 typeof value === "string" || typeof value === "function" || isDeployTarget(value);
27
28 export interface VocsTargetInputSelection {
29 readonly input: DeployTargetInput<VocsTarget, unknown>;
30 readonly config: unknown;
31 }
32
33 /** Normalize direct target inputs and the E2E harness's target carriage. */
34 export const selectVocsTargetInput = (options?: {
35 readonly target?: VocsTargetOption | undefined;
36 readonly vite?: unknown;
37 }): VocsTargetInputSelection => {
38 const raw = options?.target;
39 if (raw !== undefined && isDeployTargetInput(raw)) {
40 return { input: raw, config: options?.vite };
41 }
42 return {
43 input: DEFAULT_TARGET_SPECIFIER,
44 config: raw?.cloudflare?.worker ?? options?.vite,
45 };
46 };
47
48 export const isVocsTarget = (value: unknown): value is VocsTarget =>
49 isDeployTarget(value) &&
50 typeof (value as { adapter?: unknown }).adapter === "function" &&
51 typeof (value as { vitePlugins?: unknown }).vitePlugins === "function";