module

Vow::Codegen::JavaScript

Emits the JavaScript runtime for a client: the VowError class, a createClient(transport) ES-module function, and the batteries-included createHttpClient(url, options?) default โ€” all with no type annotations, so a browser can import and run them with no build step. Types live in the companion .d.ts (TypeScript.emit_dts) sitting next to it, which an editor picks up automatically โ€” so the buildless consumer still gets full autocomplete.

The function names, namespace nesting, and dispatch ids are byte-identical to the .d.ts (both derive from the same manifest), so the declaration describes this runtime exactly.

Constants

HTTP_CLIENT = "export function createHttpClient(url, options = {}) {\n return createClient(async (name, args, opts) => {\n const path = `${url}/${name.replaceAll(\".\", \"/\")}`;\n const method = options.method?.(opts) ?? \"POST\";\n const res = method === \"GET\"\n ? await fetch(\n Object.keys(args).length\n ? `${path}?input=${encodeURIComponent(JSON.stringify(args))}`\n : path,\n { method: \"GET\", headers: { ...(options.headers?.() ?? {}) } },\n )\n : await fetch(path, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...(options.headers?.() ?? {}) },\n body: JSON.stringify(args),\n });\n const data = await res.json();\n if (!res.ok) throw new VowError(data.error, data.message, data.hint ?? null);\n return data;\n });\n}"

The runtime twin of TypeScript::HTTP_CLIENT โ€” same behaviour, no types. Reads no opt itself: options.method (you supply it) maps the opts bag to a verb, so you decide which key marks a read; with none, every call POSTs.

VOW_ERROR = "export class VowError extends Error {\n constructor(code, message, hint = null) {\n super(message);\n this.name = \"VowError\";\n this.code = code;\n this.hint = hint;\n }\n}"

The runtime twin of TypeScript::VOW_ERROR: the same class, sans type annotations. The .d.ts beside it carries the typed code/hint.

Class methods

emit(manifest : Manifest) : String
Source