theokit 0.68.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/{actions-virtual-module-SE44BKR4.js → actions-virtual-module-ICWX5PZ2.js} +8 -8
- package/dist/{actions-virtual-module-3OPYLD76.js → actions-virtual-module-LY6VGJZ2.js} +5 -5
- package/dist/adapters/agent-mount.d.ts +191 -3
- package/dist/adapters/agent-mount.js +19 -4
- package/dist/adapters/security-headers.d.ts +17 -1
- package/dist/adapters/security-headers.js +7 -0
- package/dist/adapters/security-headers.js.map +1 -1
- package/dist/{agent-UBDDP2L5.js → agent-7DQ3TKJY.js} +4 -4
- package/dist/agent-scan-BLXaFL6R.d.ts +12 -0
- package/dist/{app-typed-client-BE3PV3JY.js → app-typed-client-2S76VTMB.js} +5 -5
- package/dist/{app-typed-client-RAFEBA7S.js → app-typed-client-6YQREFRS.js} +8 -8
- package/dist/{aws-lambda-R76PWR27.js → aws-lambda-OCJM5YGB.js} +35 -23
- package/dist/aws-lambda-OCJM5YGB.js.map +1 -0
- package/dist/{build-U4HVYY6F.js → build-NIHGHPYS.js} +12 -7
- package/dist/build-NIHGHPYS.js.map +1 -0
- package/dist/{bun-NPBIAWSU.js → bun-KRUAWYRW.js} +51 -39
- package/dist/bun-KRUAWYRW.js.map +1 -0
- package/dist/{chunk-GQNBZDYK.js → chunk-2FHNJ7LI.js} +1 -1
- package/dist/{chunk-GQNBZDYK.js.map → chunk-2FHNJ7LI.js.map} +1 -1
- package/dist/chunk-3NAKOWTX.js +573 -0
- package/dist/chunk-3NAKOWTX.js.map +1 -0
- package/dist/chunk-4D4YVXHR.js +816 -0
- package/dist/chunk-4D4YVXHR.js.map +1 -0
- package/dist/{chunk-G2NWAVGG.js → chunk-5XXXJ6DT.js} +65 -6
- package/dist/chunk-5XXXJ6DT.js.map +1 -0
- package/dist/{chunk-CO7Q75IS.js → chunk-6SK4MX2N.js} +10 -10
- package/dist/{chunk-UETVDZBE.js → chunk-BINRCILF.js} +4 -1
- package/dist/{chunk-UETVDZBE.js.map → chunk-BINRCILF.js.map} +1 -1
- package/dist/{chunk-AROOYXI5.js → chunk-BTDTHXUI.js} +2 -2
- package/dist/{chunk-GP6OJBXP.js → chunk-CPXIYCAY.js} +2 -2
- package/dist/chunk-FFGP2LGQ.js +465 -0
- package/dist/chunk-FFGP2LGQ.js.map +1 -0
- package/dist/{chunk-KDP2HURW.js → chunk-FHQP23Z5.js} +10 -2
- package/dist/{chunk-KDP2HURW.js.map → chunk-FHQP23Z5.js.map} +1 -1
- package/dist/{chunk-BCFA6LHL.js → chunk-GVJFVBCJ.js} +2 -2
- package/dist/{chunk-LADTWXOB.js → chunk-H5KSRGRS.js} +43 -554
- package/dist/chunk-H5KSRGRS.js.map +1 -0
- package/dist/{chunk-ENRT6DAU.js → chunk-IDWN2OSG.js} +15 -2
- package/dist/chunk-IDWN2OSG.js.map +1 -0
- package/dist/{chunk-GDF2XQOO.js → chunk-JMN4COMK.js} +5 -3
- package/dist/chunk-JMN4COMK.js.map +1 -0
- package/dist/{chunk-Q7T3UQ4L.js → chunk-KOG5K26V.js} +16 -738
- package/dist/chunk-KOG5K26V.js.map +1 -0
- package/dist/{chunk-FYYKMPST.js → chunk-MLF25NC4.js} +4 -4
- package/dist/{chunk-7THO4PRL.js → chunk-PGDBSK2L.js} +33 -11
- package/dist/chunk-PGDBSK2L.js.map +1 -0
- package/dist/{chunk-5NNFO7R7.js → chunk-R7G2B2WH.js} +10 -2
- package/dist/chunk-R7G2B2WH.js.map +1 -0
- package/dist/{chunk-GAJOZJWD.js → chunk-SX7ZAHNE.js} +15 -2
- package/dist/chunk-SX7ZAHNE.js.map +1 -0
- package/dist/chunk-V5SSTT3C.js +52 -0
- package/dist/chunk-V5SSTT3C.js.map +1 -0
- package/dist/chunk-XG6SQUEP.js +27 -0
- package/dist/chunk-XG6SQUEP.js.map +1 -0
- package/dist/{chunk-QGNSZ2ZK.js → chunk-YWWMYEAC.js} +3 -3
- package/dist/cli/index.js +7 -7
- package/dist/client/index.d.ts +20 -0
- package/dist/client/index.js.map +1 -1
- package/dist/{cloudflare-5HU56XIH.js → cloudflare-GK4VD3EU.js} +36 -13
- package/dist/cloudflare-GK4VD3EU.js.map +1 -0
- package/dist/{define-middleware-D2n71Svm.d.ts → define-middleware-BOHpPOBs.d.ts} +1 -1
- package/dist/{deno-deploy-BXOQ45LD.js → deno-deploy-WMNXRVGL.js} +37 -36
- package/dist/deno-deploy-WMNXRVGL.js.map +1 -0
- package/dist/{dev-E3USPAWQ.js → dev-KKO3JIN7.js} +7 -7
- package/dist/{dev-emit-ZLB2J5ME.js → dev-emit-23AA3V64.js} +3 -3
- package/dist/{dev-emit-7RT624PM.js → dev-emit-UJJXY3ET.js} +3 -3
- package/dist/{index-B9iVBHJI.d.ts → index-inRdhi59.d.ts} +39 -4
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{internal-api-OOTVIOH2.js → internal-api-HUIBRF2X.js} +5 -5
- package/dist/{internal-api-VAKXXW6F.js → internal-api-S72T2XKD.js} +10 -9
- package/dist/match-DaKsL73w.d.ts +28 -0
- package/dist/{mcp-7UOQM4FW.js → mcp-I6MCW6KX.js} +4 -4
- package/dist/{match-Dw4CNXJH.d.ts → module-loader-DCip7NoL.d.ts} +1 -28
- package/dist/{netlify-LPJAPMQ2.js → netlify-VOL54SC7.js} +23 -20
- package/dist/netlify-VOL54SC7.js.map +1 -0
- package/dist/{openapi-SKKXWFX4.js → openapi-24PTE7P6.js} +3 -3
- package/dist/{preview-GPMF43QX.js → preview-EOL3LMK7.js} +3 -3
- package/dist/{registry-UOWTDUFL.js → registry-DDBXDHJ2.js} +7 -7
- package/dist/server/cost/index.d.ts +14 -1
- package/dist/server/cost/index.js +1 -1
- package/dist/server/define/index.d.ts +1 -1
- package/dist/server/define/index.js +2 -3
- package/dist/server/http/index.d.ts +4 -3
- package/dist/server/http/index.js +13 -8
- package/dist/server/index.d.ts +6 -5
- package/dist/server/index.js +17 -12
- package/dist/server/index.js.map +1 -1
- package/dist/server/scan/index.d.ts +4 -3
- package/dist/server/scan/index.js +2 -2
- package/dist/{server-boundary-A3HW27C7.js → server-boundary-ERBSHRHT.js} +5 -5
- package/dist/{server-boundary-V6PCM22J.js → server-boundary-I5XWYINJ.js} +8 -8
- package/dist/{start-6WEPXA3X.js → start-OD4DG4C6.js} +6 -6
- package/dist/{vercel-YUZADKGV.js → vercel-LZTDSDJF.js} +42 -28
- package/dist/vercel-LZTDSDJF.js.map +1 -0
- package/dist/vite-plugin/index.js +9 -8
- package/dist/{vite-plugin-WBF5NXGW.js → vite-plugin-SH3VGQEE.js} +7 -7
- package/package.json +4 -4
- package/dist/agent-scan-BZa-pagG.d.ts +0 -16
- package/dist/aws-lambda-R76PWR27.js.map +0 -1
- package/dist/build-U4HVYY6F.js.map +0 -1
- package/dist/bun-NPBIAWSU.js.map +0 -1
- package/dist/chunk-5NNFO7R7.js.map +0 -1
- package/dist/chunk-6B3CMPE4.js +0 -192
- package/dist/chunk-6B3CMPE4.js.map +0 -1
- package/dist/chunk-7L7LQ2GU.js +0 -16
- package/dist/chunk-7L7LQ2GU.js.map +0 -1
- package/dist/chunk-7THO4PRL.js.map +0 -1
- package/dist/chunk-ENRT6DAU.js.map +0 -1
- package/dist/chunk-G2NWAVGG.js.map +0 -1
- package/dist/chunk-GAJOZJWD.js.map +0 -1
- package/dist/chunk-GDF2XQOO.js.map +0 -1
- package/dist/chunk-LADTWXOB.js.map +0 -1
- package/dist/chunk-O55RLSGG.js +0 -127
- package/dist/chunk-O55RLSGG.js.map +0 -1
- package/dist/chunk-Q7T3UQ4L.js.map +0 -1
- package/dist/cloudflare-5HU56XIH.js.map +0 -1
- package/dist/deno-deploy-BXOQ45LD.js.map +0 -1
- package/dist/netlify-LPJAPMQ2.js.map +0 -1
- package/dist/vercel-YUZADKGV.js.map +0 -1
- /package/dist/{actions-virtual-module-SE44BKR4.js.map → actions-virtual-module-ICWX5PZ2.js.map} +0 -0
- /package/dist/{actions-virtual-module-3OPYLD76.js.map → actions-virtual-module-LY6VGJZ2.js.map} +0 -0
- /package/dist/{agent-UBDDP2L5.js.map → agent-7DQ3TKJY.js.map} +0 -0
- /package/dist/{app-typed-client-BE3PV3JY.js.map → app-typed-client-2S76VTMB.js.map} +0 -0
- /package/dist/{app-typed-client-RAFEBA7S.js.map → app-typed-client-6YQREFRS.js.map} +0 -0
- /package/dist/{chunk-CO7Q75IS.js.map → chunk-6SK4MX2N.js.map} +0 -0
- /package/dist/{chunk-AROOYXI5.js.map → chunk-BTDTHXUI.js.map} +0 -0
- /package/dist/{chunk-GP6OJBXP.js.map → chunk-CPXIYCAY.js.map} +0 -0
- /package/dist/{chunk-BCFA6LHL.js.map → chunk-GVJFVBCJ.js.map} +0 -0
- /package/dist/{chunk-FYYKMPST.js.map → chunk-MLF25NC4.js.map} +0 -0
- /package/dist/{chunk-QGNSZ2ZK.js.map → chunk-YWWMYEAC.js.map} +0 -0
- /package/dist/{dev-E3USPAWQ.js.map → dev-KKO3JIN7.js.map} +0 -0
- /package/dist/{dev-emit-ZLB2J5ME.js.map → dev-emit-23AA3V64.js.map} +0 -0
- /package/dist/{dev-emit-7RT624PM.js.map → dev-emit-UJJXY3ET.js.map} +0 -0
- /package/dist/{internal-api-OOTVIOH2.js.map → internal-api-HUIBRF2X.js.map} +0 -0
- /package/dist/{internal-api-VAKXXW6F.js.map → internal-api-S72T2XKD.js.map} +0 -0
- /package/dist/{mcp-7UOQM4FW.js.map → mcp-I6MCW6KX.js.map} +0 -0
- /package/dist/{openapi-SKKXWFX4.js.map → openapi-24PTE7P6.js.map} +0 -0
- /package/dist/{preview-GPMF43QX.js.map → preview-EOL3LMK7.js.map} +0 -0
- /package/dist/{registry-UOWTDUFL.js.map → registry-DDBXDHJ2.js.map} +0 -0
- /package/dist/{server-boundary-A3HW27C7.js.map → server-boundary-ERBSHRHT.js.map} +0 -0
- /package/dist/{server-boundary-V6PCM22J.js.map → server-boundary-I5XWYINJ.js.map} +0 -0
- /package/dist/{start-6WEPXA3X.js.map → start-OD4DG4C6.js.map} +0 -0
- /package/dist/{vite-plugin-WBF5NXGW.js.map → vite-plugin-SH3VGQEE.js.map} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "tsx/esm";
|
|
3
|
+
|
|
4
|
+
// src/adapters/deployed-plugins-module.ts
|
|
5
|
+
var UnbakeablePluginError = class extends Error {
|
|
6
|
+
constructor(index, name, target) {
|
|
7
|
+
super(
|
|
8
|
+
`plugins[${index}] ("${name}") cannot be carried to the ${target} target: it is a constructed plugin, and a closure has no literal a generated entry could hold. Declare it by module specifier instead \u2014 plugins: ['./src/plugins/${name}.ts'] \u2014 so the build can emit a static import for it. Both forms work locally; only the specifier survives a deploy.`
|
|
9
|
+
);
|
|
10
|
+
this.name = "UnbakeablePluginError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var MODULE_FILENAME = "theo.plugins.mjs";
|
|
14
|
+
function planDeployedPlugins(plugins, target) {
|
|
15
|
+
if (plugins === void 0 || plugins.length === 0) return void 0;
|
|
16
|
+
const specifiers = plugins.map((entry, index) => {
|
|
17
|
+
if (typeof entry === "string") return entry;
|
|
18
|
+
throw new UnbakeablePluginError(index, nameOf(entry), target);
|
|
19
|
+
});
|
|
20
|
+
const vars = specifiers.map((_, i) => `__theoPlugin${String(i)}`);
|
|
21
|
+
return {
|
|
22
|
+
moduleSpecifier: `./${MODULE_FILENAME}`,
|
|
23
|
+
specifiers,
|
|
24
|
+
source: [
|
|
25
|
+
`// Generated by Theo \u2014 the plugins the deployed entry registers (usetheokit/theokit#425).`,
|
|
26
|
+
`//`,
|
|
27
|
+
`// Static imports, resolved on the build machine. A constructed plugin has no literal, which`,
|
|
28
|
+
`// is why the config declares these by module specifier and why this file can exist at all.`,
|
|
29
|
+
...specifiers.map((s, i) => `import ${vars[i]} from '${entrySpecifier(s)}'`),
|
|
30
|
+
``,
|
|
31
|
+
`// Order is DECLARED order, because plugin order is hook order.`,
|
|
32
|
+
`export default { plugins: [${vars.join(", ")}] }`,
|
|
33
|
+
``
|
|
34
|
+
].join("\n")
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function entrySpecifier(specifier) {
|
|
38
|
+
if (!specifier.startsWith(".")) return specifier;
|
|
39
|
+
return `../../${specifier.replace(/^\.\/+/, "")}`;
|
|
40
|
+
}
|
|
41
|
+
function nameOf(entry) {
|
|
42
|
+
if (entry != null && typeof entry === "object") {
|
|
43
|
+
const named = entry.name;
|
|
44
|
+
if (typeof named === "string" && named.length > 0) return named;
|
|
45
|
+
}
|
|
46
|
+
return "unnamed";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
planDeployedPlugins
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-V5SSTT3C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/deployed-plugins-module.ts"],"sourcesContent":["/**\n * The plugins module a build writes beside a deployed entry (usetheokit/theokit#425).\n *\n * ## What it is for\n *\n * `config.plugins` used to reach no deployed target at all, so `onRequest`, `preHandler`,\n * `onResponse` and `onError` were dead on every Web-standards deployment while firing locally. The\n * reason was never the hook loop — `executeRoute` has always run it — but that a constructed\n * plugin closes over state, and there is no literal for a closure.\n *\n * A plugin declared as a module SPECIFIER can be carried, because the build can emit a static\n * import for it. That is the road `renderBakedRoutes` already takes for route modules (#369):\n * resolve on the build machine, emit a static specifier, let the target's bundler see through it.\n *\n * ## Why the specifier is `../../`\n *\n * Every target that can carry plugins writes its entry two levels below the project root —\n * `.theokit/cloudflare/`, `.theokit/bun/`, `.theokit/deno/` — and a declared specifier is relative\n * to that root. The same arithmetic `renderBakedRoutes` does for routes, for the same reason.\n *\n * ## Which targets can carry them at all\n *\n * Only the ones whose output is BUNDLED from the project: Cloudflare (wrangler), Bun and Deno all\n * resolve the emitted import against the app's own source tree. Vercel, Netlify and AWS Lambda\n * receive a standalone function directory and never see the app's modules, so for them a named\n * refusal — which `findUnappliedConfig` already prints — remains the honest answer, and this module\n * is not called.\n */\n\n/**\n * A plugin the build was asked to carry and cannot.\n *\n * Its own type because the alternative is the defect this whole issue is: hooks that do not fire\n * and nothing that says so. A target that CAN carry a named module but was handed a closure has\n * something actionable to say, so it says it at build time rather than at the first request\n * (`rules/three-target-parity.md` § 3 — refuse by name).\n */\nexport class UnbakeablePluginError extends Error {\n constructor(index: number, name: string, target: string) {\n super(\n `plugins[${index}] (\"${name}\") cannot be carried to the ${target} target: it is a constructed ` +\n `plugin, and a closure has no literal a generated entry could hold. Declare it by module ` +\n `specifier instead — plugins: ['./src/plugins/${name}.ts'] — so the build can emit a ` +\n `static import for it. Both forms work locally; only the specifier survives a deploy.`,\n )\n this.name = 'UnbakeablePluginError'\n }\n}\n\nexport interface DeployedPluginsPlan {\n /** The module source to write beside the entry. */\n readonly source: string\n /** What the entry imports it as — a sibling, because both are written to the same directory. */\n readonly moduleSpecifier: string\n /** The declared specifiers, in order, for the build to report. */\n readonly specifiers: readonly string[]\n}\n\nconst MODULE_FILENAME = 'theo.plugins.mjs'\n\n/**\n * Plan the plugins module for a target that can carry one.\n *\n * @param plugins - the raw `config.plugins` array.\n * @param target - the deploy target, named in the refusal so the message says where it applies.\n * @returns `undefined` when the app declares no plugins, so an app carrying none emits nothing.\n * @throws UnbakeablePluginError when an entry is a constructed plugin rather than a specifier.\n */\nexport function planDeployedPlugins(\n plugins: readonly unknown[] | undefined,\n target: string,\n): DeployedPluginsPlan | undefined {\n if (plugins === undefined || plugins.length === 0) return undefined\n\n const specifiers = plugins.map((entry, index) => {\n if (typeof entry === 'string') return entry\n throw new UnbakeablePluginError(index, nameOf(entry), target)\n })\n\n const vars = specifiers.map((_, i) => `__theoPlugin${String(i)}`)\n\n return {\n moduleSpecifier: `./${MODULE_FILENAME}`,\n specifiers,\n source: [\n `// Generated by Theo — the plugins the deployed entry registers (usetheokit/theokit#425).`,\n `//`,\n `// Static imports, resolved on the build machine. A constructed plugin has no literal, which`,\n `// is why the config declares these by module specifier and why this file can exist at all.`,\n ...specifiers.map((s, i) => `import ${vars[i]} from '${entrySpecifier(s)}'`),\n ``,\n `// Order is DECLARED order, because plugin order is hook order.`,\n `export default { plugins: [${vars.join(', ')}] }`,\n ``,\n ].join('\\n'),\n }\n}\n\n/**\n * How the emitted module names a declared specifier.\n *\n * A RELATIVE specifier is relative to the project root, and the module sits two levels below it, so\n * it is re-based — the arithmetic `renderBakedRoutes` does for routes. A BARE specifier is a package\n * and must be left alone: `../../my-plugin-pkg` is a path that does not exist, where\n * `my-plugin-pkg` is a dependency the target's bundler resolves from `node_modules` like any other.\n */\nfunction entrySpecifier(specifier: string): string {\n if (!specifier.startsWith('.')) return specifier\n return `../../${specifier.replace(/^\\.\\/+/, '')}`\n}\n\n/** The plugin's own name when it has one, so the refusal names the thing the author wrote. */\nfunction nameOf(entry: unknown): string {\n if (entry != null && typeof entry === 'object') {\n const named = (entry as { name?: unknown }).name\n if (typeof named === 'string' && named.length > 0) return named\n }\n return 'unnamed'\n}\n"],"mappings":";;;;AAqCO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,YAAY,OAAe,MAAc,QAAgB;AACvD;AAAA,MACE,WAAW,KAAK,OAAO,IAAI,+BAA+B,MAAM,0KAEd,IAAI;AAAA,IAExD;AACA,SAAK,OAAO;AAAA,EACd;AACF;AAWA,IAAM,kBAAkB;AAUjB,SAAS,oBACd,SACA,QACiC;AACjC,MAAI,YAAY,UAAa,QAAQ,WAAW,EAAG,QAAO;AAE1D,QAAM,aAAa,QAAQ,IAAI,CAAC,OAAO,UAAU;AAC/C,QAAI,OAAO,UAAU,SAAU,QAAO;AACtC,UAAM,IAAI,sBAAsB,OAAO,OAAO,KAAK,GAAG,MAAM;AAAA,EAC9D,CAAC;AAED,QAAM,OAAO,WAAW,IAAI,CAAC,GAAG,MAAM,eAAe,OAAO,CAAC,CAAC,EAAE;AAEhE,SAAO;AAAA,IACL,iBAAiB,KAAK,eAAe;AAAA,IACrC;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG,WAAW,IAAI,CAAC,GAAG,MAAM,UAAU,KAAK,CAAC,CAAC,UAAU,eAAe,CAAC,CAAC,GAAG;AAAA,MAC3E;AAAA,MACA;AAAA,MACA,8BAA8B,KAAK,KAAK,IAAI,CAAC;AAAA,MAC7C;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAUA,SAAS,eAAe,WAA2B;AACjD,MAAI,CAAC,UAAU,WAAW,GAAG,EAAG,QAAO;AACvC,SAAO,SAAS,UAAU,QAAQ,UAAU,EAAE,CAAC;AACjD;AAGA,SAAS,OAAO,OAAwB;AACtC,MAAI,SAAS,QAAQ,OAAO,UAAU,UAAU;AAC9C,UAAM,QAAS,MAA6B;AAC5C,QAAI,OAAO,UAAU,YAAY,MAAM,SAAS,EAAG,QAAO;AAAA,EAC5D;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "tsx/esm";
|
|
3
|
+
import {
|
|
4
|
+
deployedCorsFragment,
|
|
5
|
+
deployedCsrfFragment,
|
|
6
|
+
securityHeadersDeclarations
|
|
7
|
+
} from "./chunk-FFGP2LGQ.js";
|
|
8
|
+
|
|
9
|
+
// src/adapters/deployed-preamble.ts
|
|
10
|
+
function deployedEntryPreamble(runtimeConfig, agentsFragment, opts, host) {
|
|
11
|
+
return [
|
|
12
|
+
...securityHeadersDeclarations(opts.securityHeaders),
|
|
13
|
+
``,
|
|
14
|
+
...runtimeConfig.imports,
|
|
15
|
+
...agentsFragment.imports,
|
|
16
|
+
...runtimeConfig.declarations,
|
|
17
|
+
...agentsFragment.declarations,
|
|
18
|
+
...deployedCsrfFragment(opts),
|
|
19
|
+
``,
|
|
20
|
+
...deployedCorsFragment(opts.cors, host)
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
deployedEntryPreamble
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-XG6SQUEP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/deployed-preamble.ts"],"sourcesContent":["import type { SecurityHeadersConfig } from '../core/contracts/security-headers.js'\n\nimport type { DeployedAgentsFragment } from './deployed-agents.js'\nimport { deployedCorsFragment, type DeployedCorsOptions } from './deployed-cors.js'\nimport { deployedCsrfFragment, type DeployedCsrfOptions } from './deployed-csrf.js'\nimport { securityHeadersDeclarations } from './security-headers.js'\n\n/**\n * The module-level preamble five deploy entries emit, in the order they emit it.\n *\n * `bun`, `deno-deploy`, `vercel`, `netlify` and `aws-lambda` wrote these nine lines identically —\n * blank lines included — with one string different between them: the host name the CORS fragment\n * is told. Verified by matching the exact text, not by reading: the template below was searched\n * for in all six adapters and found in five.\n *\n * ## Why this was extracted, and what the alternative was\n *\n * SonarCloud's duplication gate is a REQUIRED check on `develop`, and it failed a promotion PR at\n * 4.2% on new code against a 3% ceiling. Three smaller extractions — the scan source, the security\n * declarations, the entry-options type — took it to 3.9% and stopped helping, because each one\n * ADDS an identical call site and an identical import to every caller. Measured on that PR: of 226\n * added lines under `src/`, 26 repeated, and every one of them was an import or a call.\n *\n * That is the metric describing the shape of extraction rather than a defect, and it is why the\n * answer had to be one bigger seam rather than a fourth small one. This collapses nine repeated\n * lines into one call in five files.\n *\n * Raising the threshold was never on the list: `rules/autonomy-envelope.md` floor 3 forbids moving\n * a bound to pass it, and a duplication gate whose ceiling rises stops reporting duplication.\n *\n * ## Why `cloudflare` is not a caller\n *\n * Its order is genuinely different — security declarations, then CSRF, then the runtime and agents\n * declarations, then CORS — and its CSRF fragment takes a second argument (`'a Worker'`) that no\n * other host passes. Forcing it through here would need a flag per difference, which turns this\n * function into a switch over its callers: the shape that drifts, and the one\n * `serveThroughPluginLifecycle` was extracted to undo after five copies had (#405).\n *\n * A Worker being the odd one is not an accident. It has no filesystem, so it bakes what the others\n * scan, and that changes what has to be declared before what.\n */\nexport function deployedEntryPreamble(\n runtimeConfig: { imports: string[]; declarations: string[] },\n agentsFragment: DeployedAgentsFragment,\n opts: { securityHeaders?: SecurityHeadersConfig } & DeployedCsrfOptions & DeployedCorsOptions,\n host: string,\n): string[] {\n return [\n ...securityHeadersDeclarations(opts.securityHeaders),\n ``,\n ...runtimeConfig.imports,\n ...agentsFragment.imports,\n ...runtimeConfig.declarations,\n ...agentsFragment.declarations,\n ...deployedCsrfFragment(opts),\n ``,\n ...deployedCorsFragment(opts.cors, host),\n ]\n}\n"],"mappings":";;;;;;;;;AAyCO,SAAS,sBACd,eACA,gBACA,MACA,MACU;AACV,SAAO;AAAA,IACL,GAAG,4BAA4B,KAAK,eAAe;AAAA,IACnD;AAAA,IACA,GAAG,cAAc;AAAA,IACjB,GAAG,eAAe;AAAA,IAClB,GAAG,cAAc;AAAA,IACjB,GAAG,eAAe;AAAA,IAClB,GAAG,qBAAqB,IAAI;AAAA,IAC5B;AAAA,IACA,GAAG,qBAAqB,KAAK,MAAM,IAAI;AAAA,EACzC;AACF;","names":[]}
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-O2KGDLA7.js";
|
|
5
5
|
import {
|
|
6
6
|
validateRouteInput
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4D4YVXHR.js";
|
|
8
8
|
import {
|
|
9
9
|
evaluateRoutePolicy,
|
|
10
10
|
subjectFromContext
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-IDWN2OSG.js";
|
|
12
12
|
|
|
13
13
|
// src/core/contracts/module-preloads.ts
|
|
14
14
|
function escapeAttribute(value) {
|
|
@@ -296,4 +296,4 @@ export {
|
|
|
296
296
|
callProcedure,
|
|
297
297
|
createOpenApiHandler
|
|
298
298
|
};
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
299
|
+
//# sourceMappingURL=chunk-YWWMYEAC.js.map
|
package/dist/cli/index.js
CHANGED
|
@@ -15,12 +15,12 @@ function cliVersion() {
|
|
|
15
15
|
// src/cli/index.ts
|
|
16
16
|
var cli = cac("theokit");
|
|
17
17
|
cli.command("dev", "Start development server").option("--port <port>", "Port number").action(async (options) => {
|
|
18
|
-
const { devCommand } = await import("../dev-
|
|
18
|
+
const { devCommand } = await import("../dev-KKO3JIN7.js");
|
|
19
19
|
await devCommand({ port: options.port ? Number(options.port) : void 0 });
|
|
20
20
|
});
|
|
21
21
|
cli.command("build", "Build for production").option("--target <target>", "Deploy target (node, vercel, cloudflare)").action(async (options) => {
|
|
22
22
|
try {
|
|
23
|
-
const { buildCommand } = await import("../build-
|
|
23
|
+
const { buildCommand } = await import("../build-NIHGHPYS.js");
|
|
24
24
|
await buildCommand({ target: options.target });
|
|
25
25
|
} catch (err) {
|
|
26
26
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -32,7 +32,7 @@ cli.command("build", "Build for production").option("--target <target>", "Deploy
|
|
|
32
32
|
});
|
|
33
33
|
cli.command("start", "Start production server").option("--port <port>", "Port number").action(async (options) => {
|
|
34
34
|
try {
|
|
35
|
-
const { startCommand } = await import("../start-
|
|
35
|
+
const { startCommand } = await import("../start-OD4DG4C6.js");
|
|
36
36
|
await startCommand({ port: options.port ? Number(options.port) : void 0 });
|
|
37
37
|
} catch (err) {
|
|
38
38
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -44,7 +44,7 @@ cli.command("start", "Start production server").option("--port <port>", "Port nu
|
|
|
44
44
|
});
|
|
45
45
|
cli.command("preview", "Build for production, then serve it \u2014 one step (B-030)").option("--port <port>", "Port number").option("--target <target>", "Deploy target (node, vercel, cloudflare)").action(async (options) => {
|
|
46
46
|
try {
|
|
47
|
-
const { previewCommand } = await import("../preview-
|
|
47
|
+
const { previewCommand } = await import("../preview-EOL3LMK7.js");
|
|
48
48
|
await previewCommand({
|
|
49
49
|
port: options.port ? Number(options.port) : void 0,
|
|
50
50
|
target: options.target
|
|
@@ -77,7 +77,7 @@ cli.command(
|
|
|
77
77
|
"Run an agent in the terminal (stream + tool calls + approval)"
|
|
78
78
|
).action(async (name, message) => {
|
|
79
79
|
try {
|
|
80
|
-
const { agentCommand } = await import("../agent-
|
|
80
|
+
const { agentCommand } = await import("../agent-7DQ3TKJY.js");
|
|
81
81
|
const { sawError } = await agentCommand(name, message);
|
|
82
82
|
if (sawError) process.exit(1);
|
|
83
83
|
} catch (err) {
|
|
@@ -108,7 +108,7 @@ cli.command("agent sessions gc", "Collect old transcripts for this project (dry
|
|
|
108
108
|
});
|
|
109
109
|
cli.command("mcp <agent>", "Serve an agent as an MCP server over stdio (for desktop MCP clients)").action(async (agent) => {
|
|
110
110
|
try {
|
|
111
|
-
const { mcpCommand } = await import("../mcp-
|
|
111
|
+
const { mcpCommand } = await import("../mcp-I6MCW6KX.js");
|
|
112
112
|
await mcpCommand(agent);
|
|
113
113
|
} catch (err) {
|
|
114
114
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -173,7 +173,7 @@ cli.command(
|
|
|
173
173
|
"Generate <distDir>/openapi.json from route schemas (opt-in via config.openapi)"
|
|
174
174
|
).option("--dry-run", "Print the document to stdout without writing to disk (EC-3)").action(async (options) => {
|
|
175
175
|
try {
|
|
176
|
-
const { openapiCommand } = await import("../openapi-
|
|
176
|
+
const { openapiCommand } = await import("../openapi-24PTE7P6.js");
|
|
177
177
|
await openapiCommand({ dryRun: Boolean(options.dryRun) });
|
|
178
178
|
} catch (err) {
|
|
179
179
|
const msg = err instanceof Error ? err.message : String(err);
|
package/dist/client/index.d.ts
CHANGED
|
@@ -343,6 +343,26 @@ interface MetadataProps {
|
|
|
343
343
|
/** Custom meta tags rendered as children */
|
|
344
344
|
children?: React.ReactNode;
|
|
345
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Why `canonical` is NOT refused the way `ogImage` is — B-243, decided 2026-09-21.
|
|
348
|
+
*
|
|
349
|
+
* The two look like the same shape and are not. `href` on a `<link>` is a URL-typed attribute: the
|
|
350
|
+
* HTML parser resolves it against the document's own base, so `canonical="/contacts"` on
|
|
351
|
+
* `https://mycrm.com/x` IS `https://mycrm.com/contacts` — correct, not broken. `content` on a
|
|
352
|
+
* `<meta>` is a plain string with no base to resolve against, which is why the Open Graph protocol
|
|
353
|
+
* requires an absolute URL and why a relative one there produces a tag that is present,
|
|
354
|
+
* well-formed and wrong.
|
|
355
|
+
*
|
|
356
|
+
* So refusing a relative `canonical` would refuse a value that works. The asymmetry is the
|
|
357
|
+
* decision, and it is written here because the code shows only its result: a reader seeing
|
|
358
|
+
* `refuseRelativeOgImage` three lines above a `canonical` that passes through unchecked has no way
|
|
359
|
+
* to tell a decision from an oversight, and the honest answer to that question costs one comment
|
|
360
|
+
* against a re-investigation.
|
|
361
|
+
*
|
|
362
|
+
* What this does NOT claim: that an absolute `canonical` is never better. It usually is, for the
|
|
363
|
+
* same reason an absolute `og:image` is — it survives being copied into a context with a different
|
|
364
|
+
* base. That is advice, and this framework does not refuse values on advice.
|
|
365
|
+
*/
|
|
346
366
|
declare function Metadata(props: Readonly<MetadataProps>): react.JSX.Element;
|
|
347
367
|
|
|
348
368
|
/**
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/theo-fetch.ts","../../src/client/batch.ts","../../src/client/batch-transport.ts","../../src/client/app-client.ts","../../src/client/index.ts","../../src/client/use-action.ts","../../src/client/action-client.ts","../../src/client/link.tsx","../../src/client/metadata.tsx","../../src/client/image.tsx","../../src/client/mcp-app-host.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,eAAe;;;AC2Cf,SAAS,cAAc,SAAkC;AAC9D,QAAM,MAAM,QAAQ,OAAO;AAC3B,MAAI,QAAuB,CAAC;AAC5B,MAAI,iBAAiB;AAErB,WAAS,QAAc;AACrB,qBA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CAAC,YAA2B;AAMvC,WAAO,eAAe,YAAY,SAAS,GAAG;AAAA,EAChD;AACA,QAAM,SAAS,0BAA0B,MAAM,IAAI;AAEnD,QAAM,YAAY,CAAC,UAA8B;AAE/C,QAAI,MAAM,WAAW,OAAO,cAAe;AAC3C,SAAK,OAAO,MAAM,IAAI;AAAA,EACxB;AACA,QAAM,OAAO,UAAU,cAAc;AACrC,QAAM,iBAAiB,WAAW,SAAS;AAE3C,SAAO;AAAA,IACL;AAAA,IACA,SAAS,MAAM;AACb,YAAM,oBAAoB,WAAW,SAAS;AAC9C,aAAO,OAAO;AAAA,IAChB;AAAA,EACF;AACF;","names":["useRef","useEffect","jsx","jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../src/client/theo-fetch.ts","../../src/client/batch.ts","../../src/client/batch-transport.ts","../../src/client/app-client.ts","../../src/client/index.ts","../../src/client/use-action.ts","../../src/client/action-client.ts","../../src/client/link.tsx","../../src/client/metadata.tsx","../../src/client/image.tsx","../../src/client/mcp-app-host.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,eAAe;;;AC2Cf,SAAS,cAAc,SAAkC;AAC9D,QAAM,MAAM,QAAQ,OAAO;AAC3B,MAAI,QAAuB,CAAC;AAC5B,MAAI,iBAAiB;AAErB,WAAS,QAAc;AACrB,qBAAiB;AACjB,UAAM,UAAU;AAChB,YAAQ,CAAC;AACT,QAAI,QAAQ,WAAW,EAAG;AAG1B,UAAM,SAA0B,CAAC;AACjC,aAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK,KAAK;AAC5C,aAAO,KAAK,QAAQ,MAAM,GAAG,IAAI,GAAG,CAAC;AAAA,IACvC;AAEA,eAAW,SAAS,QAAQ;AAC1B,YAAM,UAA0B,MAAM,IAAI,CAAC,MAAM,EAAE,GAAG;AACtD,cACG,UAAU,OAAO,EACjB,KAAK,CAAC,YAAY;AACjB,iBAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAKrC,gBA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ect","jsx","jsx"]}
|
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
parseAssetsMap
|
|
5
5
|
} from "./chunk-46FM5AFZ.js";
|
|
6
6
|
import {
|
|
7
|
-
deployedAgentsFragment,
|
|
8
7
|
planDeployedPlugins
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-V5SSTT3C.js";
|
|
10
9
|
import {
|
|
10
|
+
deployedAgentsFragment,
|
|
11
11
|
deployedCorsFragment,
|
|
12
12
|
deployedCsrfFragment,
|
|
13
13
|
deployedRuntimeConfigFragment,
|
|
14
14
|
deployedTraceFragment,
|
|
15
15
|
describeDeployedSecurityHeaders,
|
|
16
|
-
|
|
16
|
+
securityHeadersDeclarations,
|
|
17
17
|
serverDirLiteral
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FFGP2LGQ.js";
|
|
19
19
|
import {
|
|
20
20
|
nodeAdapter
|
|
21
21
|
} from "./chunk-KI4DOTN4.js";
|
|
@@ -145,8 +145,19 @@ function renderCloudflareWorkerEntry(opts = {}) {
|
|
|
145
145
|
);
|
|
146
146
|
const runtimeConfig = deployedRuntimeConfigFragment(opts);
|
|
147
147
|
const agentsFragment = deployedAgentsFragment(
|
|
148
|
-
opts.agents === void 0 ? void 0 :
|
|
149
|
-
|
|
148
|
+
opts.agents === void 0 ? void 0 : (
|
|
149
|
+
// B-185 — a Worker has no filesystem, so its identity module is baked exactly like its
|
|
150
|
+
// agents and its routes (ADR 0014). `contextModule` is `undefined` for an app that
|
|
151
|
+
// declares none, and the generator then emits no import for it.
|
|
152
|
+
{ kind: "baked", agents: opts.agents, contextModule: opts.contextModule }
|
|
153
|
+
),
|
|
154
|
+
{
|
|
155
|
+
wrapSecurityHeaders: true,
|
|
156
|
+
// B-185 — bound only when the runtime-config fragment declared the const, which is
|
|
157
|
+
// exactly when a plugins module was emitted. Referencing it otherwise would emit an
|
|
158
|
+
// identifier the entry never declares.
|
|
159
|
+
pluginRunnerExpr: opts.runtimeConfigModule === void 0 ? void 0 : "await THEO_PLUGIN_RUNNER"
|
|
160
|
+
}
|
|
150
161
|
);
|
|
151
162
|
return [
|
|
152
163
|
`// Generated by Theo \u2014 Cloudflare Workers Adapter`,
|
|
@@ -180,8 +191,7 @@ import { injectModulePreloads } from 'theokit/server/http'`,
|
|
|
180
191
|
`// function, same input, so the deployed page and the local one cannot`,
|
|
181
192
|
`// disagree about what the configuration means.`,
|
|
182
193
|
preloadSupport,
|
|
183
|
-
|
|
184
|
-
`const SECURITY_HEADERS = buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true })`,
|
|
194
|
+
...securityHeadersDeclarations(opts.securityHeaders),
|
|
185
195
|
``,
|
|
186
196
|
...deployedCsrfFragment(opts, "a Worker"),
|
|
187
197
|
``,
|
|
@@ -205,14 +215,15 @@ import { injectModulePreloads } from 'theokit/server/http'`,
|
|
|
205
215
|
...cloudflareHandleRequestFragment(
|
|
206
216
|
nonApiBranch,
|
|
207
217
|
runtimeConfig.executeRouteSpread,
|
|
208
|
-
agentsFragment.branch
|
|
218
|
+
agentsFragment.branch,
|
|
219
|
+
agentsFragment.hostBypass
|
|
209
220
|
)
|
|
210
221
|
].join("\n");
|
|
211
222
|
}
|
|
212
|
-
function cloudflareHandleRequestFragment(nonApiBranch, runtimeSpread, agentBranch) {
|
|
223
|
+
function cloudflareHandleRequestFragment(nonApiBranch, runtimeSpread, agentBranch, hostBypass) {
|
|
213
224
|
return [
|
|
214
225
|
`async function handleRequest(request, url, env) {`,
|
|
215
|
-
` if (!url.pathname.startsWith('/api/')) {`,
|
|
226
|
+
` if (!url.pathname.startsWith('/api/')${hostBypass}) {`,
|
|
216
227
|
nonApiBranch,
|
|
217
228
|
` }`,
|
|
218
229
|
``,
|
|
@@ -310,7 +321,15 @@ var cloudflareAdapter = {
|
|
|
310
321
|
mkdirSync(outputDir, { recursive: true });
|
|
311
322
|
const shell = readDocumentShell(cwd, config.ssrStreaming);
|
|
312
323
|
const assetsMap = readAssetsMapForBake(resolve(cwd, ".theokit", "client", "assets-map.json"));
|
|
313
|
-
const scanned = ctx?.scanRoutes?.(config.serverDir) ?? {
|
|
324
|
+
const scanned = ctx?.scanRoutes?.(config.serverDir) ?? {
|
|
325
|
+
routes: [],
|
|
326
|
+
wsRoutes: [],
|
|
327
|
+
agents: [],
|
|
328
|
+
// B-185 — no provider means no scan, and an app whose context nobody looked for is
|
|
329
|
+
// indistinguishable here from one that has none. Both resolve an anonymous caller, which is
|
|
330
|
+
// the honest answer rather than an invented subject.
|
|
331
|
+
contextModule: void 0
|
|
332
|
+
};
|
|
314
333
|
const pluginsPlan = planDeployedPlugins(config.plugins, "cloudflare");
|
|
315
334
|
if (pluginsPlan !== void 0) {
|
|
316
335
|
writeFileSync(resolve(outputDir, "theo.plugins.mjs"), pluginsPlan.source);
|
|
@@ -334,6 +353,9 @@ var cloudflareAdapter = {
|
|
|
334
353
|
routes: scanned.routes,
|
|
335
354
|
// #367 — a Worker has no filesystem, so its agents are decided here like its routes.
|
|
336
355
|
agents: scanned.agents,
|
|
356
|
+
// B-185 — rides beside the agents because it is decided by the same provider, for the same
|
|
357
|
+
// reason: `build.ts` holds `serverDir` and a Worker cannot look for the module itself.
|
|
358
|
+
contextModule: scanned.contextModule,
|
|
337
359
|
wsRoutes: scanned.wsRoutes
|
|
338
360
|
})
|
|
339
361
|
);
|
|
@@ -357,7 +379,8 @@ var cloudflareAdapter = {
|
|
|
357
379
|
export {
|
|
358
380
|
cloudflareAdapter,
|
|
359
381
|
readAssetsMapForBake,
|
|
382
|
+
readDocumentShell,
|
|
360
383
|
renderCloudflareWorkerEntry,
|
|
361
384
|
renderWranglerToml
|
|
362
385
|
};
|
|
363
|
-
//# sourceMappingURL=cloudflare-
|
|
386
|
+
//# sourceMappingURL=cloudflare-GK4VD3EU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/cloudflare.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Cloudflare deploy adapter. All write paths are under `cwd/.theokit/cloudflare/`\n * and `cwd/wrangler.toml`. Build-time tool — no HTTP input.\n */\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport type { TheoConfig } from '../config/schema.js'\nimport { findRootDiv } from '../core/contracts/find-root-div.js'\nimport { parseAssetsMap } from '../core/contracts/module-preloads.js'\nimport type { SecurityHeadersConfig } from '../core/contracts/security-headers.js'\nimport { assertServicesUnsupported, readManifest } from '../services/index.js'\n\nimport { deployedAgentsFragment, type DeployedAgent } from './deployed-agents.js'\nimport { deployedCorsFragment, type DeployedCorsOptions } from './deployed-cors.js'\nimport { deployedCsrfFragment, type DeployedCsrfOptions } from './deployed-csrf.js'\nimport { planDeployedPlugins } from './deployed-plugins-module.js'\nimport {\n deployedRuntimeConfigFragment,\n serverDirLiteral,\n type DeployedRuntimeConfigOptions,\n type DeployedServerDirOptions,\n} from './deployed-runtime-config.js'\nimport { deployedTraceFragment } from './deployed-trace.js'\nimport { nodeAdapter } from './node.js'\nimport { describeDeployedSecurityHeaders, securityHeadersDeclarations } from './security-headers.js'\nimport type { AdapterBuildContext, DeployAdapter } from './types.js'\n\n/**\n * T2.1 — Cloudflare adapter rewritten to consume `theokit/adapters/web-shim`\n * instead of emitting an inline plain-object Request/Response shim. Reduces\n * template from ~50 lines to ~25 and centralizes maintenance.\n */\n\n/**\n * The built `index.html` split into the part before `<div id=\"root\">` and the\n * part after it.\n *\n * Refuses by name when streaming is on and the template is missing, rather than\n * emitting a worker that serves a headless document. A build that cannot produce\n * a correct artifact should say so at build time; the alternative is a deploy\n * that looks successful and serves pages with no stylesheet.\n */\n/**\n * @internal Exported for tests only. Nothing re-exports this module, so this does not reach the\n * published surface — `findRootDiv`, exported for the same reason, appears 0 times in `dist/`.\n */\nexport function readDocumentShell(\n cwd: string,\n streaming: boolean,\n): { htmlHead?: string; htmlTail?: string } {\n if (!streaming) return {}\n\n const indexPath = resolve(cwd, '.theokit/client/index.html')\n if (!existsSync(indexPath)) {\n throw new Error(\n `[adapter-cloudflare] ssrStreaming is on but ${indexPath} does not exist, so the worker ` +\n `would serve a document with no <head> and no client entry. Run the client build first, ` +\n `or set ssrStreaming: false in theo.config.ts.`,\n )\n }\n\n const indexHtml = readFileSync(indexPath, 'utf-8')\n const rootDiv = findRootDiv(indexHtml)\n if (rootDiv === undefined) {\n throw new Error(\n `[adapter-cloudflare] ${indexPath} has no <div id=\"root\">, so the streamed document has ` +\n `nowhere to put the app. Add one, or set ssrStreaming: false in theo.config.ts.`,\n )\n }\n\n return {\n htmlHead: indexHtml.slice(0, rootDiv.insertAt),\n htmlTail: indexHtml.slice(rootDiv.insertAt),\n }\n}\n\n/**\n * The routes, turned into source: static imports, a module map and a literal table (#369).\n *\n * Extracted so the worker renderer stays inside its length budget, and because this is the whole of\n * what changed about how a Worker finds a route — it reads as one idea rather than as three loops\n * inside a hundred lines of template.\n *\n * `../../` because the worker is written to `.theokit/cloudflare/worker.mjs` and `filePath` is\n * relative to the project root. The imports are static so Wrangler's bundler follows them:\n * `wrangler.toml` uploads `.theokit/client` and has never uploaded `server/`, so a module not\n * bundled INTO the worker is not on the platform at all.\n */\nfunction renderBakedRoutes(\n routes: readonly { filePath: string; routePath: string; methods?: readonly string[] }[],\n): { routeImports: string[]; routeModuleEntries: string[]; routeTableEntries: string[] } {\n const routeVar = (index: number): string => `__theoRoute${String(index)}`\n return {\n routeImports: routes.map(\n (route, index) => `import * as ${routeVar(index)} from '../../${route.filePath}'`,\n ),\n routeModuleEntries: routes.map(\n (route, index) => ` ${JSON.stringify(route.filePath)}: ${routeVar(index)},`,\n ),\n routeTableEntries: routes.map(\n (route) =>\n ` { filePath: ${JSON.stringify(route.filePath)}, routePath: ${JSON.stringify(route.routePath)}, ` +\n `methods: ${JSON.stringify([...(route.methods ?? [])])}, ` +\n `...compilePattern(${JSON.stringify(route.routePath)}) },`,\n ),\n }\n}\n\n/**\n * The route-resolution runtime the Worker gets instead of a directory scan (#369).\n *\n * A module map, the literal table, and a loader that refuses anything the build did not bake.\n * Emitted as its own block because it replaces one idea — \"find the routes\" — wholesale.\n */\nfunction routeRuntimeLines(moduleEntries: string[], tableEntries: string[]): string[] {\n return [\n `// #369 — the routes are baked at build time. The Worker used to reach for`,\n `// \\`scanServerRoutes\\` on the server directory — a readdirSync, in a runtime with no`,\n `// filesystem. The pattern is recompiled here from the same routePath the scanner`,\n `// used, so one function decides precedence on every target.`,\n `const ROUTE_MODULES = {`,\n ...moduleEntries,\n `}`,\n ``,\n `const routes = [`,\n ...tableEntries,\n `]`,\n ``,\n `// The executor asks for a module by the path the table names. Anything else was`,\n `// never bundled, and saying so beats returning undefined and failing later on a`,\n `// property access far from the cause.`,\n `async function loadModule(path) {`,\n ` const mod = ROUTE_MODULES[path]`,\n ` if (mod === undefined) {`,\n // No backticks in this message: it is emitted INTO a template literal, and a stray one closes\n // it. That is how #344 shipped a SyntaxError, and the emitted-entry parse gate caught this one\n // before it left the branch.\n \" throw new Error(`Route module '\" +\n '${path}' +\n \"' was not bundled into this Worker. \" +\n 'A Worker has no filesystem, so every route is imported at build time. ' +\n 'Re-run: theokit build --target cloudflare`)',\n ` }`,\n ` return mod`,\n `}`,\n ``,\n ]\n}\n\n/**\n * Read the map `theokit build` emitted, for baking into the worker (B-035).\n *\n * Returns `undefined` — never throws — for an absent or malformed file. A deploy that failed\n * because an optimisation was missing would turn a lost round trip into a broken build, and the\n * worker is correct without it.\n */\nexport function readAssetsMapForBake(path: string): Record<string, string[]> | undefined {\n try {\n return parseAssetsMap(readFileSync(path, 'utf8'))\n } catch {\n return undefined\n }\n}\n\n/**\n * The baked route-to-chunks map, as worker source (B-035).\n *\n * A literal and not a read, for the same reason the document shell is: a Worker has no filesystem\n * at request time. Emitted only when the build produced a map; otherwise the worker carries\n * nothing about preloads and behaves exactly as before.\n *\n * **It emits the DATA and no longer the code.** An earlier revision emitted a hand-written copy of\n * `injectModulePreloads`, justified by a claim that the worker could not import it. That claim was\n * false — `theokit/server` re-exports from `core/contracts/` and the generated worker already\n * imports that subpath — and the copy drifted within a day: a fix for proxy-form request targets\n * landed in the original and not in the duplicate. The worker now imports the real function, which\n * is the shape `adapters/security-headers.ts` established one directory over for exactly this\n * build-half/runtime-half pair.\n */\n/**\n * Whether this worker can preload at all (B-035).\n *\n * ONE predicate, read by the bake, the import and the call. Two conditions for one decision is\n * how the import came to be emitted for a worker that had no map to give it — found at review, in\n * the same change where a copy and its original had already drifted apart.\n *\n * Streaming is required because the other branch serves the document from `env.ASSETS` as a\n * static file and can inject nothing into it.\n */\nfunction preloadsApplyTo(opts: {\n ssrStreaming?: boolean\n assetsMap?: Record<string, string[]>\n}): boolean {\n return opts.ssrStreaming === true && opts.assetsMap !== undefined\n}\n\nfunction renderPreloadSupport(assetsMap: Record<string, string[]> | undefined): string {\n if (assetsMap === undefined) return ''\n return `const __THEO_ASSETS_MAP = ${JSON.stringify(assetsMap)}`\n}\n\n/**\n * The branch that answers a non-API request: streamed SSR, or the static asset the Worker\n * platform serves. Extracted at review — it is the one decision in this emitter with two whole\n * shapes behind it, and keeping it inline pushed the caller past its line budget.\n */\nfunction renderNonApiBranch(\n opts: NonNullable<Parameters<typeof renderCloudflareWorkerEntry>[0]>,\n preloadsApply: boolean,\n): string {\n return opts.ssrStreaming\n ? [\n ` // T2.3 — streaming SSR for non-API routes`,\n ` // The same primitive \\`theokit start\\` uses, not a second one:`,\n ` // 16 bytes of Web Crypto entropy, base64.`,\n ` const nonce = generateNonce()`,\n ` return withSecurityHeaders(`,\n ` await renderStreamingWeb(request, {`,\n !preloadsApply\n ? ` htmlHead: ${JSON.stringify(opts.htmlHead ?? '')},`\n : ` htmlHead: injectModulePreloads(${JSON.stringify(opts.htmlHead ?? '')}, __THEO_ASSETS_MAP, new URL(request.url).pathname),`,\n ` htmlTail: ${JSON.stringify(opts.htmlTail ?? '')},`,\n ` nonce,`,\n ` }),`,\n ` buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true }, { nonce }),`,\n ` )`,\n ].join('\\n')\n : [\n ` // #412 — the document, served by the worker so it carries the same baseline every`,\n ` // API response carries. It used to return 404 here while wrangler.toml declared a`,\n ` // \\`[site]\\` bucket nothing read, so the page was missing rather than unprotected.`,\n ` const assets = env?.ASSETS`,\n ` // A wrangler.toml that predates this binding has no ASSETS. Reading .fetch off`,\n ` // undefined would turn every page request into a 500; 404 is what this target`,\n ` // answered before, which is the honest fallback rather than a new failure.`,\n ` if (assets === undefined) return notFoundResponse()`,\n ` return withSecurityHeaders(await assets.fetch(request), SECURITY_HEADERS)`,\n ].join('\\n')\n}\n\nexport function renderCloudflareWorkerEntry(\n opts: {\n ssrStreaming?: boolean\n htmlHead?: string\n htmlTail?: string\n /**\n * B-035 — the route-to-chunks map, baked as a literal for the same reason the shell above\n * is: a Worker has no filesystem at request time. Absent when the build produced no map,\n * and then nothing about preloads is emitted at all.\n */\n assetsMap?: Record<string, string[]>\n securityHeaders?: SecurityHeadersConfig\n /**\n * The server routes, scanned on the BUILD machine (#369).\n *\n * A Worker has no filesystem, so the worker used to call `scanServerRoutes` — a `readdirSync` —\n * against a directory that does not exist there, and load each module through `import()` of a\n * file path. Both are baked here instead, which is the road this adapter already takes for the\n * document shell one function away.\n *\n * `filePath` is relative to the project root and is used for two things: the key the executor\n * looks a module up by, and the specifier the static import uses. Paths are emitted relative to\n * `.theokit/cloudflare/`, where the worker is written.\n */\n routes?: readonly { filePath: string; routePath: string; methods?: readonly string[] }[]\n /**\n * The two concerns #410 could not bake (#425), composed from one place so the six targets\n * cannot drift into six spellings. `serialization` is a literal like the security values above;\n * `plugins` is an import, because a closure has no literal.\n */\n runtimeConfigModule?: DeployedRuntimeConfigOptions['runtimeConfigModule']\n serialization?: DeployedRuntimeConfigOptions['serialization']\n /**\n * The app's agents, scanned on the build machine (#367).\n *\n * A different scan from `routes` and served by a different function — which is why a worker\n * that only consulted the route table answered every `/api/agents/<name>` with a 404.\n */\n agents?: readonly DeployedAgent[]\n /** B-185 — the app's `server/context.ts`, project-relative, or absent when it declares none. */\n contextModule?: string\n /** WebSocket route files, scanned on the build machine. Only their presence is used (#369). */\n wsRoutes?: readonly string[]\n } & DeployedServerDirOptions &\n DeployedCsrfOptions &\n DeployedCorsOptions = {},\n): string {\n const streamingImport = opts.ssrStreaming\n ? `import { renderStreamingWeb } from '/@theo/entry-server'`\n : `// (ssrStreaming off: renderStreamingWeb not imported)`\n // #343 — the document shell is inlined as a build-time literal because a Worker\n // has no filesystem to read `index.html` from at request time. Without it,\n // `renderStreamingWeb` falls back to its empty-string defaults and the response\n // is React output with no `<html>`, no `<head>`, no stylesheet and no client\n // entry — hydration data for a page that cannot hydrate. The streaming\n // assembly was fixed in the generated entry and this, its only caller, was\n // left passing nothing.\n //\n // `JSON.stringify` and not a template literal: the shell contains quotes,\n // angle brackets and a `</script>`, and embedding it naively produces a worker\n // that fails to parse at deploy time rather than here.\n //\n // #410 — this is also the ONE deploy path that renders HTML at request time,\n // so the one that can mint a per-request CSP nonce: `renderStreamingWeb`\n // threads `options.nonce` into `renderToReadableStream` and into the hydration\n // script (`router/entry-server.ts`). Every other response below carries the\n // nonce-less baseline, which is what `buildSecurityHeaders` already does for a\n // prerendered route (EC-4).\n // Only the streaming branch renders HTML at request time; the other serves the document from\n // `env.ASSETS` as a static file and can inject nothing. Baking the map for it would ship the whole\n // route table as dead weight — found at review, where the emitter was measured declaring it with\n // zero call sites.\n const preloadsApply = preloadsApplyTo(opts)\n const preloadSupport = preloadsApply ? renderPreloadSupport(opts.assetsMap) : ''\n\n const nonApiBranch = renderNonApiBranch(opts, preloadsApply)\n\n // CR-006: Workers lack `process.cwd()` and the `node:*` import surface\n // is brittle even under `nodejs_compat`. We use the Web Crypto\n // `crypto.randomUUID()` instead of `node:crypto.randomUUID`, and embed\n // the server directory as a build-time literal instead of resolving via\n // `node:path` at runtime.\n const { routeImports, routeModuleEntries, routeTableEntries } = renderBakedRoutes(\n opts.routes ?? [],\n )\n const runtimeConfig = deployedRuntimeConfigFragment(opts)\n const agentsFragment = deployedAgentsFragment(\n opts.agents === undefined\n ? undefined\n : // B-185 — a Worker has no filesystem, so its identity module is baked exactly like its\n // agents and its routes (ADR 0014). `contextModule` is `undefined` for an app that\n // declares none, and the generator then emits no import for it.\n { kind: 'baked', agents: opts.agents, contextModule: opts.contextModule },\n {\n wrapSecurityHeaders: true,\n // B-185 — bound only when the runtime-config fragment declared the const, which is\n // exactly when a plugins module was emitted. Referencing it otherwise would emit an\n // identifier the entry never declares.\n pluginRunnerExpr:\n opts.runtimeConfigModule === undefined ? undefined : 'await THEO_PLUGIN_RUNNER',\n },\n )\n\n return [\n `// Generated by Theo — Cloudflare Workers Adapter`,\n `//`,\n `// REQUIREMENTS (EC-3):`,\n `// - wrangler.toml MUST include compatibility_flags = [\"nodejs_compat\"]`,\n `// (still required for transitive theokit/server deps, e.g. busboy)`,\n `// - package.json MUST list \"theokit\" in dependencies (not devDependencies)`,\n `// so Wrangler bundles theokit and its transitive deps`,\n `// - Deploy: wrangler deploy`,\n ``,\n !preloadsApply\n ? `import { matchRoute, executeRoute, compilePattern, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server'`\n : `import { matchRoute, executeRoute, compilePattern, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server'\\nimport { injectModulePreloads } from 'theokit/server/http'`,\n `import { createWebShim } from 'theokit/adapters/web-shim'`,\n opts.ssrStreaming\n ? `import { buildSecurityHeaders, generateNonce, withSecurityHeaders } from 'theokit/adapters/security-headers'`\n : `import { buildSecurityHeaders, withSecurityHeaders } from 'theokit/adapters/security-headers'`,\n `// T3.4 — WS bridge for Cloudflare Workers`,\n `import { createCloudflareWsBridge } from 'theokit/adapters/ws-shim'`,\n streamingImport,\n ``,\n ...runtimeConfig.imports,\n ...agentsFragment.imports,\n ...routeImports,\n ``,\n `// CR-006: server directory is a build-time literal — Workers cannot`,\n `// call process.cwd() and resolving paths at runtime returned '/server'.`,\n `const serverDir = ${serverDirLiteral(opts)}`,\n ``,\n ...routeRuntimeLines(routeModuleEntries, routeTableEntries),\n `// #410 — the security baseline \\`theokit start\\` puts on every response, carried`,\n `// here as a literal because a Worker has no theo.config.ts to read. Same`,\n `// function, same input, so the deployed page and the local one cannot`,\n `// disagree about what the configuration means.`,\n preloadSupport,\n ...securityHeadersDeclarations(opts.securityHeaders),\n ``,\n ...deployedCsrfFragment(opts, 'a Worker'),\n ``,\n ...runtimeConfig.declarations,\n ...agentsFragment.declarations,\n ...deployedCorsFragment(opts.cors, 'cloudflare'),\n `// #369 — whether this project declares a WebSocket route, decided at build time. It used`,\n `// to answer it with \\`scanWebSocketRoutes\\`, which is the same readdirSync.`,\n `const HAS_WS_ROUTES = ${String((opts.wsRoutes ?? []).length > 0)}`,\n ``,\n `function notFoundResponse() {`,\n ` return withSecurityHeaders(`,\n ` new Response(`,\n ` JSON.stringify({ error: { code: 'NOT_FOUND', message: 'Route not found' } }),`,\n ` { status: 404, headers: { 'Content-Type': 'application/json' } },`,\n ` ),`,\n ` SECURITY_HEADERS,`,\n ` )`,\n `}`,\n ``,\n ...cloudflareHandleRequestFragment(\n nonApiBranch,\n runtimeConfig.executeRouteSpread,\n agentsFragment.branch,\n agentsFragment.hostBypass,\n ),\n ].join('\\n')\n}\n\n/**\n * The Worker's request handler, as generated source.\n *\n * Extracted for the reason `vercel.ts` extracts its own fragments: the emitter is one array\n * literal, so every line the entry gains counts against `max-lines-per-function`, and #410 added\n * the CSRF literal to an emitter already sitting exactly at the ceiling.\n *\n * @param nonApiBranch - what a non-`/api/` request gets, which differs with `ssrStreaming`\n */\nfunction cloudflareHandleRequestFragment(\n nonApiBranch: string,\n runtimeSpread: string,\n agentBranch: readonly string[],\n /** SI-020 — the condition that keeps an agent card path out of the static-asset branch. */\n hostBypass: string,\n): string[] {\n return [\n `async function handleRequest(request, url, env) {`,\n ` if (!url.pathname.startsWith('/api/')${hostBypass}) {`,\n nonApiBranch,\n ` }`,\n ``,\n ...agentBranch,\n ``,\n ` const match = matchRoute(url.pathname, routes)`,\n ` if (!match) return notFoundResponse()`,\n ``,\n ` const { req, res, toResponse } = createWebShim(request, { trustedProxy: 'platform' })`,\n ...deployedTraceFragment('request', ' '),\n ` const method = request.method.toUpperCase()`,\n ` // #382 — the run is NOT awaited before the Response is taken. toResponse()`,\n ` // settles as soon as status + headers are known and carries a live body, so`,\n ` // the Worker starts flushing while the handler is still writing. Awaiting`,\n ` // executeRoute() first would re-buffer the whole response here even though`,\n ` // the shim streams; awaiting toResponse() does not — it settles at the head.`,\n ` return withSecurityHeaders(await toResponse(executeRoute({`,\n ` route: match.route, method, params: match.params,`,\n ` req, res, loadModule, serverDir, requestId, ...CSRF_CONFIG, ${runtimeSpread}`,\n ` })), SECURITY_HEADERS)`,\n `}`,\n ``,\n `export default {`,\n ` async fetch(request, env, ctx) {`,\n ` const url = new URL(request.url)`,\n ``,\n ` // T3.4 — Detect WebSocket upgrade and delegate to the CF bridge.`,\n ` // A 101 carries no document and no script, so the security baseline does`,\n ` // not apply to it.`,\n ` if (request.headers.get('upgrade')?.toLowerCase() === 'websocket') {`,\n ` if (!HAS_WS_ROUTES) return notFoundResponse()`,\n ` const cfWs = createCloudflareWsBridge({`,\n ` onOpen: () => {},`,\n ` onMessage: (ws, data) => { ws.send(data) },`,\n ` onClose: () => {},`,\n ` })`,\n ` return cfWs.handle(request)`,\n ` }`,\n ``,\n ` // #409 — the preflight is answered BEFORE anything routes: an OPTIONS the router handles`,\n ` // is an OPTIONS the browser never gets a CORS answer to. The WebSocket upgrade above is`,\n ` // deliberately upstream of it — a 101 is not a CORS-governed response.`,\n ` const preflight = corsPreflight(request)`,\n ` if (preflight !== null) return withSecurityHeaders(preflight, SECURITY_HEADERS)`,\n ``,\n ` return withCors(request, await handleRequest(request, url, env))`,\n ` },`,\n `}`,\n ]\n}\n\nexport function renderWranglerToml(): string {\n return [\n `# Generated by Theo — Cloudflare Workers`,\n `name = \"theo-app\"`,\n `main = \".theokit/cloudflare/worker.mjs\"`,\n `compatibility_date = \"2025-09-01\"`,\n `compatibility_flags = [\"nodejs_compat\"]`,\n ``,\n `# #412 — \\`[assets]\\` with a BINDING, not the legacy \\`[site]\\` bucket.`,\n `#`,\n `# \\`[site]\\` uploads to KV and is read through \\`kv-asset-handler\\` and a`,\n `# \\`__STATIC_CONTENT\\` binding — neither of which this worker has ever had. So the`,\n `# bucket was declared, uploaded, and consumed by nothing: with ssrStreaming off, a`,\n `# deploy answered 404 for its own page. This binding is what the worker calls.`,\n `[assets]`,\n `directory = \".theokit/client\"`,\n `binding = \"ASSETS\"`,\n `# A client-routed app asks for /dashboard, which is no file. Without this the asset`,\n `# handler 404s a deep link and the SPA never boots.`,\n `not_found_handling = \"single-page-application\"`,\n ``,\n `# Environment variables are set via wrangler secret or dashboard`,\n `# Example: wrangler secret put DATABASE_URL`,\n ].join('\\n')\n}\n\nexport const cloudflareAdapter: DeployAdapter = {\n name: 'cloudflare',\n streamsResponses: true,\n // #409 / #410 — the generated entry calls `executeRoute` with routes, loader\n // and serverDir only. CSRF, route policy, file middleware and Zod validation\n // still run because they live inside `executeRoute`; none of the remaining\n // configurable concerns reach it. Declared explicitly rather than omitted so\n // the gap is a statement in the source and not an absence.\n //\n // `securityHeaders` IS applied: the worker carries `security.headers` as a\n // literal and puts the built baseline on every response it returns, including\n // the streamed SSR document — with a per-request nonce, the only deploy path\n // that can mint one (`adapters/security-headers.ts`).\n servesAgents: true,\n appliesConfig: ['securityHeaders', 'csrf', 'disallowed', 'cors', 'serialization', 'plugins'],\n\n async build(config: TheoConfig, cwd: string, ctx?: AdapterBuildContext): Promise<void> {\n // Wave 2 (T2.2) — reject polyglot services on this adapter.\n assertServicesUnsupported('cloudflare', readManifest(cwd))\n\n // 1. Run the standard Node build first (ctx forwarded so nodeAdapter has makeVitePlugins)\n await nodeAdapter.build(config, cwd, ctx)\n\n const outputDir = resolve(cwd, '.theokit/cloudflare')\n mkdirSync(outputDir, { recursive: true })\n\n // 2. Emit Worker entry (now uses the shared web-shim)\n //\n // The document shell is read HERE, after the Node build produced\n // `.theokit/client/index.html`, and inlined into the worker: a Worker has no\n // filesystem at request time. Split on the root div with the same helper the\n // Node server uses (`ssr-setup.ts`), so the two paths cannot disagree about\n // where the shell ends (#343).\n const shell = readDocumentShell(cwd, config.ssrStreaming)\n // B-035 — the route-to-chunks map, read HERE on the build machine for the same reason the\n // shell above is: a Worker has no filesystem at request time. `nodeAdapter.build` ran\n // first, so the map the Node build emitted is on disk by now. Absent map -> nothing about\n // preloads is emitted, and the worker behaves exactly as it did before.\n const assetsMap = readAssetsMapForBake(resolve(cwd, '.theokit', 'client', 'assets-map.json'))\n\n // #369 — the routes are resolved HERE, on the build machine, for the same reason the document\n // shell above is read here: a Worker has no filesystem at request time, and the worker used to\n // run the scan itself against a directory that does not exist there.\n //\n // The scanner is INJECTED rather than imported: importing it would add an `adapters → server`\n // edge, which is the layering inversion ADR-0001 v3 removed for `vite-plugin` and which\n // `adapters-may-only-depend-on-core-router-services` refuses. An absent scanner emits a worker\n // with no routes rather than falling back to a runtime scan — the fallback IS the defect.\n const scanned = ctx?.scanRoutes?.(config.serverDir) ?? {\n routes: [],\n wsRoutes: [],\n agents: [],\n // B-185 — no provider means no scan, and an app whose context nobody looked for is\n // indistinguishable here from one that has none. Both resolve an anonymous caller, which is\n // the honest answer rather than an invented subject.\n contextModule: undefined,\n }\n\n const pluginsPlan = planDeployedPlugins(config.plugins, 'cloudflare')\n if (pluginsPlan !== undefined) {\n // Beside the worker, so the emitted import is a sibling. Wrangler bundles from here, which is\n // what lets the static import reach the app's own module at all (#425).\n writeFileSync(resolve(outputDir, 'theo.plugins.mjs'), pluginsPlan.source)\n }\n\n writeFileSync(\n resolve(outputDir, 'worker.mjs'),\n renderCloudflareWorkerEntry({\n ssrStreaming: config.ssrStreaming,\n ...shell,\n securityHeaders: config.security?.headers,\n csrf: config.security?.csrf,\n disallowed: config.security?.disallowed,\n cors: config.security?.cors,\n assetsMap,\n // #425 — a selector, not a transformer, so it rides as a literal like the values above.\n serialization: config.serialization,\n // #425 — the ONE concern that is not a literal. A closure cannot be baked, so a plugin\n // declared by module specifier is imported by the emitted module instead; a constructed one\n // is refused by name at build time rather than dropped in silence.\n runtimeConfigModule: pluginsPlan?.moduleSpecifier,\n routes: scanned.routes,\n // #367 — a Worker has no filesystem, so its agents are decided here like its routes.\n agents: scanned.agents,\n // B-185 — rides beside the agents because it is decided by the same provider, for the same\n // reason: `build.ts` holds `serverDir` and a Worker cannot look for the module itself.\n contextModule: scanned.contextModule,\n wsRoutes: scanned.wsRoutes,\n }),\n )\n\n // 3. Emit wrangler.toml (with nodejs_compat enforced)\n writeFileSync(resolve(cwd, 'wrangler.toml'), renderWranglerToml())\n\n // eslint-disable-next-line no-console -- CLI build progress\n console.log('\\n ✓ Cloudflare output → .theokit/cloudflare/ + wrangler.toml')\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(\n `${describeDeployedSecurityHeaders({\n target: 'cloudflare',\n securityHeaders: config.security?.headers,\n // Only the streaming worker renders HTML per request, so only it can put\n // the same nonce on the header and on the script tag it emits.\n mintsNonce: config.ssrStreaming,\n // #412 — either way the worker returns the document now: streamed by\n // `renderStreamingWeb`, or from the ASSETS binding it finally calls.\n documentHeaders: 'handler',\n })}\\n`,\n )\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,eAAe;AA0CjB,SAAS,kBACd,KACA,WAC0C;AAC1C,MAAI,CAAC,UAAW,QAAO,CAAC;AAExB,QAAM,YAAY,QAAQ,KAAK,4BAA4B;AAC3D,MAAI,CAAC,WAAW,SAAS,GAAG;AAC1B,UAAM,IAAI;AAAA,MACR,+CAA+C,SAAS;AAAA,IAG1D;AAAA,EACF;AAEA,QAAM,YAAY,aAAa,WAAW,OAAO;AACjD,QAAM,UAAU,YAAY,SAAS;AACrC,MAAI,YAAY,QAAW;AACzB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ZodType = z.ZodUndefined, TBody extends z
|
|
|
105
105
|
* downstream, which the short-circuit shape cannot express.
|
|
106
106
|
*/
|
|
107
107
|
type MiddlewareNext = () => Promise<Response | undefined>;
|
|
108
|
-
type MiddlewareHandler = (request: Request, context: Record<string, unknown>, next
|
|
108
|
+
type MiddlewareHandler = (request: Request, context: Record<string, unknown>, next: MiddlewareNext) => Response | undefined | void | Promise<Response | undefined | void>;
|
|
109
109
|
|
|
110
110
|
export type { MiddlewareHandler as M, RouteConfig as R, MiddlewareNext as a };
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
|
-
deployedAgentsFragment,
|
|
5
4
|
planDeployedPlugins
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-V5SSTT3C.js";
|
|
6
|
+
import {
|
|
7
|
+
deployedEntryPreamble
|
|
8
|
+
} from "./chunk-XG6SQUEP.js";
|
|
7
9
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
agentsDirLiteral,
|
|
11
|
+
deployedAgentsFragment,
|
|
10
12
|
deployedRuntimeConfigFragment,
|
|
11
13
|
deployedTraceFragment,
|
|
12
14
|
describeDeployedSecurityHeaders,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
scannedFromLoaderCache,
|
|
16
|
+
serverDirLiteral
|
|
17
|
+
} from "./chunk-FFGP2LGQ.js";
|
|
15
18
|
import {
|
|
16
19
|
nodeAdapter
|
|
17
20
|
} from "./chunk-KI4DOTN4.js";
|
|
@@ -24,17 +27,25 @@ import {
|
|
|
24
27
|
// src/adapters/deno-deploy.ts
|
|
25
28
|
import { mkdirSync, writeFileSync } from "fs";
|
|
26
29
|
import { resolve } from "path";
|
|
30
|
+
var FRAMEWORK_IMPORTS = [
|
|
31
|
+
`// Use npm: specifier so Deno resolves theokit from the user's package.json`,
|
|
32
|
+
`// equivalent (works in both local 'deno run' and Deno Deploy).`,
|
|
33
|
+
`import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, scanWebSocketRoutes, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'npm:theokit/server'`,
|
|
34
|
+
`import { createWebShim } from 'npm:theokit/adapters/web-shim'`,
|
|
35
|
+
`import { buildSecurityHeaders, withSecurityHeaders } from 'npm:theokit/adapters/security-headers'`,
|
|
36
|
+
`// T3.3 \u2014 WS bridge for Deno runtime`,
|
|
37
|
+
`import { createDenoWsBridge } from 'npm:theokit/adapters/ws-shim'`
|
|
38
|
+
];
|
|
27
39
|
function renderDenoEntry(port, opts = {}) {
|
|
28
40
|
const runtimeConfig = deployedRuntimeConfigFragment(opts);
|
|
29
|
-
const agentsFragment = deployedAgentsFragment(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
41
|
+
const agentsFragment = deployedAgentsFragment(scannedFromLoaderCache(agentsDirLiteral(opts)), {
|
|
42
|
+
notFound: "notFound()",
|
|
43
|
+
importPrefix: "npm:",
|
|
44
|
+
// B-185 — bound only when the runtime-config fragment declared the const, which is
|
|
45
|
+
// exactly when a plugins module was emitted. Referencing it otherwise would emit an
|
|
46
|
+
// identifier the entry never declares.
|
|
47
|
+
pluginRunnerExpr: opts.runtimeConfigModule === void 0 ? void 0 : "await THEO_PLUGIN_RUNNER"
|
|
48
|
+
});
|
|
38
49
|
return [
|
|
39
50
|
`// Generated by Theo \u2014 Deno Deploy Adapter`,
|
|
40
51
|
`// Deploy: deployctl deploy --project=<name> .theokit/deno/server.ts`,
|
|
@@ -45,17 +56,11 @@ function renderDenoEntry(port, opts = {}) {
|
|
|
45
56
|
` throw new Error('TheoDenoDeployAdapter must run inside Deno.')`,
|
|
46
57
|
`}`,
|
|
47
58
|
``,
|
|
48
|
-
|
|
49
|
-
`// equivalent (works in both local 'deno run' and Deno Deploy).`,
|
|
50
|
-
`import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, scanWebSocketRoutes, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'npm:theokit/server'`,
|
|
51
|
-
`import { createWebShim } from 'npm:theokit/adapters/web-shim'`,
|
|
52
|
-
`import { buildSecurityHeaders, withSecurityHeaders } from 'npm:theokit/adapters/security-headers'`,
|
|
53
|
-
`// T3.3 \u2014 WS bridge for Deno runtime`,
|
|
54
|
-
`import { createDenoWsBridge } from 'npm:theokit/adapters/ws-shim'`,
|
|
59
|
+
...FRAMEWORK_IMPORTS,
|
|
55
60
|
``,
|
|
56
61
|
`const port = Number(Deno.env.get('PORT') ?? '${port}')`,
|
|
57
62
|
`const cwd = Deno.cwd()`,
|
|
58
|
-
`const serverDir = cwd + '/
|
|
63
|
+
`const serverDir = cwd + '/' + ${serverDirLiteral(opts)}`,
|
|
59
64
|
`let routesCache = null`,
|
|
60
65
|
`let wsRoutesCache = null`,
|
|
61
66
|
`let loaderCache = null`,
|
|
@@ -65,16 +70,7 @@ function renderDenoEntry(port, opts = {}) {
|
|
|
65
70
|
`// theo.config.ts to read. Non-API paths 404 here and are served by Deno`,
|
|
66
71
|
`// Deploy's static asset handler, so this covers the API and not the`,
|
|
67
72
|
`// document (usetheokit/theokit#412).`,
|
|
68
|
-
|
|
69
|
-
`const SECURITY_HEADERS = buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true })`,
|
|
70
|
-
``,
|
|
71
|
-
...runtimeConfig.imports,
|
|
72
|
-
...agentsFragment.imports,
|
|
73
|
-
...runtimeConfig.declarations,
|
|
74
|
-
...agentsFragment.declarations,
|
|
75
|
-
...deployedCsrfFragment(opts),
|
|
76
|
-
``,
|
|
77
|
-
...deployedCorsFragment(opts.cors, "deno-deploy"),
|
|
73
|
+
...deployedEntryPreamble(runtimeConfig, agentsFragment, opts, "deno-deploy"),
|
|
78
74
|
``,
|
|
79
75
|
`function notFound() {`,
|
|
80
76
|
` return new Response(JSON.stringify({ error: { code: 'NOT_FOUND' } }), {`,
|
|
@@ -108,7 +104,7 @@ function renderDenoEntry(port, opts = {}) {
|
|
|
108
104
|
`async function handleRequest(request) {`,
|
|
109
105
|
` const url = new URL(request.url)`,
|
|
110
106
|
``,
|
|
111
|
-
` if (!url.pathname.startsWith('/api/')) {`,
|
|
107
|
+
` if (!url.pathname.startsWith('/api/')${agentsFragment.hostBypass}) {`,
|
|
112
108
|
` // Static + SPA fallback are served by Deno Deploy's static asset handler.`,
|
|
113
109
|
` return notFound()`,
|
|
114
110
|
` }`,
|
|
@@ -150,7 +146,12 @@ async function buildDeno(config, cwd, deps = {}, ctx) {
|
|
|
150
146
|
// #425 — the ONE concern that is not a literal. A closure cannot be baked, so a plugin
|
|
151
147
|
// declared by module specifier is imported by the emitted module instead; a constructed one
|
|
152
148
|
// is refused by name at build time rather than dropped in silence.
|
|
153
|
-
runtimeConfigModule: pluginsPlan?.moduleSpecifier
|
|
149
|
+
runtimeConfigModule: pluginsPlan?.moduleSpecifier,
|
|
150
|
+
// #95 — the configured directories, which `build.ts:210` already threads into the Vite
|
|
151
|
+
// plugins. Without these two lines the literals above fall to their defaults and a project
|
|
152
|
+
// with a custom dir deploys an entry that resolves a directory it does not have.
|
|
153
|
+
serverDir: config.serverDir,
|
|
154
|
+
agentsDir: config.agentsDir
|
|
154
155
|
});
|
|
155
156
|
const write = deps.writeEntry ?? ((p, c) => {
|
|
156
157
|
writeFileSync(p, c);
|
|
@@ -193,4 +194,4 @@ export {
|
|
|
193
194
|
denoDeployAdapter,
|
|
194
195
|
renderDenoEntry
|
|
195
196
|
};
|
|
196
|
-
//# sourceMappingURL=deno-deploy-
|
|
197
|
+
//# sourceMappingURL=deno-deploy-WMNXRVGL.js.map
|