theokit 0.67.0 → 0.68.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.
Files changed (87) hide show
  1. package/dist/{actions-virtual-module-WCHXKH6R.js → actions-virtual-module-3OPYLD76.js} +3 -3
  2. package/dist/{actions-virtual-module-YIWQTI6Q.js → actions-virtual-module-SE44BKR4.js} +4 -4
  3. package/dist/{agent-C7F5O5V4.js → agent-UBDDP2L5.js} +2 -2
  4. package/dist/{app-typed-client-CUM2GZ5Y.js → app-typed-client-BE3PV3JY.js} +3 -3
  5. package/dist/{app-typed-client-2ZEGNFJP.js → app-typed-client-RAFEBA7S.js} +4 -4
  6. package/dist/assets-map-BMQASQHW.js +70 -0
  7. package/dist/assets-map-BMQASQHW.js.map +1 -0
  8. package/dist/assets-map-CV2YZ3MY.js +69 -0
  9. package/dist/assets-map-CV2YZ3MY.js.map +1 -0
  10. package/dist/{build-UNBI6VKC.js → build-U4HVYY6F.js} +6 -6
  11. package/dist/chunk-46FM5AFZ.js +44 -0
  12. package/dist/chunk-46FM5AFZ.js.map +1 -0
  13. package/dist/{chunk-D4VP2QPR.js → chunk-7L7LQ2GU.js} +1 -1
  14. package/dist/{chunk-D4VP2QPR.js.map → chunk-7L7LQ2GU.js.map} +1 -1
  15. package/dist/{chunk-ASBXR57P.js → chunk-7THO4PRL.js} +2 -2
  16. package/dist/{chunk-EQCSUC65.js → chunk-AROOYXI5.js} +2 -2
  17. package/dist/{chunk-PRZCPSUE.js → chunk-CO7Q75IS.js} +28 -13
  18. package/dist/chunk-CO7Q75IS.js.map +1 -0
  19. package/dist/{chunk-UKMOQWUC.js → chunk-FYYKMPST.js} +2 -2
  20. package/dist/{chunk-B4Z7KIIU.js → chunk-G2NWAVGG.js} +2 -2
  21. package/dist/chunk-G2NWAVGG.js.map +1 -0
  22. package/dist/{chunk-WAYUHS54.js → chunk-GDF2XQOO.js} +2 -2
  23. package/dist/{chunk-YNK7DW5V.js → chunk-LADTWXOB.js} +23 -8
  24. package/dist/chunk-LADTWXOB.js.map +1 -0
  25. package/dist/{chunk-5VLP3GQ2.js → chunk-MS4A7N77.js} +1 -1
  26. package/dist/chunk-MS4A7N77.js.map +1 -0
  27. package/dist/{chunk-5AGNZXHJ.js → chunk-Q7T3UQ4L.js} +89 -30
  28. package/dist/chunk-Q7T3UQ4L.js.map +1 -0
  29. package/dist/{chunk-GQIATJEG.js → chunk-QGNSZ2ZK.js} +27 -2
  30. package/dist/chunk-QGNSZ2ZK.js.map +1 -0
  31. package/dist/cli/index.js +6 -6
  32. package/dist/{cloudflare-2WVDBHCC.js → cloudflare-5HU56XIH.js} +36 -9
  33. package/dist/cloudflare-5HU56XIH.js.map +1 -0
  34. package/dist/{route-config-B7FaTSby.d.ts → define-middleware-D2n71Svm.d.ts} +39 -1
  35. package/dist/{dev-GLUZNBNH.js → dev-E3USPAWQ.js} +6 -6
  36. package/dist/{index-BdIaxp0c.d.ts → index-B9iVBHJI.d.ts} +48 -4
  37. package/dist/index.js +4 -4
  38. package/dist/{internal-api-3JIWUI3V.js → internal-api-OOTVIOH2.js} +3 -3
  39. package/dist/{internal-api-OK7FS2ZF.js → internal-api-VAKXXW6F.js} +4 -4
  40. package/dist/{mcp-IPDFRK4S.js → mcp-7UOQM4FW.js} +2 -2
  41. package/dist/{observability-bootstrap-H4NSILXD.js → observability-bootstrap-YQKMEYW7.js} +2 -2
  42. package/dist/{preview-5ONGHDKY.js → preview-GPMF43QX.js} +3 -3
  43. package/dist/{registry-E5XEUKG6.js → registry-UOWTDUFL.js} +3 -3
  44. package/dist/server/define/index.d.ts +2 -28
  45. package/dist/server/define/index.js +2 -2
  46. package/dist/server/http/index.d.ts +2 -2
  47. package/dist/server/http/index.js +5 -3
  48. package/dist/server/index.d.ts +4 -3
  49. package/dist/server/index.js +6 -4
  50. package/dist/server/index.js.map +1 -1
  51. package/dist/{server-boundary-6PYWFYEL.js → server-boundary-A3HW27C7.js} +3 -3
  52. package/dist/{server-boundary-CNYNVFT5.js → server-boundary-V6PCM22J.js} +4 -4
  53. package/dist/{start-UYBVPTSV.js → start-6WEPXA3X.js} +38 -14
  54. package/dist/start-6WEPXA3X.js.map +1 -0
  55. package/dist/{static-SVDWIOXJ.js → static-7OJNB7D2.js} +4 -4
  56. package/dist/vite-plugin/index.js +4 -4
  57. package/dist/{vite-plugin-ILWLTOKK.js → vite-plugin-WBF5NXGW.js} +6 -6
  58. package/package.json +2 -2
  59. package/dist/chunk-5AGNZXHJ.js.map +0 -1
  60. package/dist/chunk-5VLP3GQ2.js.map +0 -1
  61. package/dist/chunk-B4Z7KIIU.js.map +0 -1
  62. package/dist/chunk-GQIATJEG.js.map +0 -1
  63. package/dist/chunk-PRZCPSUE.js.map +0 -1
  64. package/dist/chunk-YNK7DW5V.js.map +0 -1
  65. package/dist/cloudflare-2WVDBHCC.js.map +0 -1
  66. package/dist/start-UYBVPTSV.js.map +0 -1
  67. /package/dist/{actions-virtual-module-WCHXKH6R.js.map → actions-virtual-module-3OPYLD76.js.map} +0 -0
  68. /package/dist/{actions-virtual-module-YIWQTI6Q.js.map → actions-virtual-module-SE44BKR4.js.map} +0 -0
  69. /package/dist/{agent-C7F5O5V4.js.map → agent-UBDDP2L5.js.map} +0 -0
  70. /package/dist/{app-typed-client-CUM2GZ5Y.js.map → app-typed-client-BE3PV3JY.js.map} +0 -0
  71. /package/dist/{app-typed-client-2ZEGNFJP.js.map → app-typed-client-RAFEBA7S.js.map} +0 -0
  72. /package/dist/{build-UNBI6VKC.js.map → build-U4HVYY6F.js.map} +0 -0
  73. /package/dist/{chunk-ASBXR57P.js.map → chunk-7THO4PRL.js.map} +0 -0
  74. /package/dist/{chunk-EQCSUC65.js.map → chunk-AROOYXI5.js.map} +0 -0
  75. /package/dist/{chunk-UKMOQWUC.js.map → chunk-FYYKMPST.js.map} +0 -0
  76. /package/dist/{chunk-WAYUHS54.js.map → chunk-GDF2XQOO.js.map} +0 -0
  77. /package/dist/{dev-GLUZNBNH.js.map → dev-E3USPAWQ.js.map} +0 -0
  78. /package/dist/{internal-api-3JIWUI3V.js.map → internal-api-OOTVIOH2.js.map} +0 -0
  79. /package/dist/{internal-api-OK7FS2ZF.js.map → internal-api-VAKXXW6F.js.map} +0 -0
  80. /package/dist/{mcp-IPDFRK4S.js.map → mcp-7UOQM4FW.js.map} +0 -0
  81. /package/dist/{observability-bootstrap-H4NSILXD.js.map → observability-bootstrap-YQKMEYW7.js.map} +0 -0
  82. /package/dist/{preview-5ONGHDKY.js.map → preview-GPMF43QX.js.map} +0 -0
  83. /package/dist/{registry-E5XEUKG6.js.map → registry-UOWTDUFL.js.map} +0 -0
  84. /package/dist/{server-boundary-6PYWFYEL.js.map → server-boundary-A3HW27C7.js.map} +0 -0
  85. /package/dist/{server-boundary-CNYNVFT5.js.map → server-boundary-V6PCM22J.js.map} +0 -0
  86. /package/dist/{static-SVDWIOXJ.js.map → static-7OJNB7D2.js.map} +0 -0
  87. /package/dist/{vite-plugin-ILWLTOKK.js.map → vite-plugin-WBF5NXGW.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import "tsx/esm";
3
- import "./chunk-B4Z7KIIU.js";
3
+ import "./chunk-G2NWAVGG.js";
4
4
  import "./chunk-UETVDZBE.js";
5
5
  import "./chunk-QD5X56I3.js";
6
6
  import "./chunk-WSMLSIS5.js";
7
- import "./chunk-5VLP3GQ2.js";
7
+ import "./chunk-MS4A7N77.js";
8
8
  import "./chunk-C27VRUVN.js";
9
9
  import "./chunk-7UZZHCRN.js";
10
10
  import "./chunk-BCFA6LHL.js";
@@ -218,4 +218,4 @@ export const actions = manifest
218
218
  export {
219
219
  actionsVirtualModule
220
220
  };
221
- //# sourceMappingURL=actions-virtual-module-WCHXKH6R.js.map
221
+ //# sourceMappingURL=actions-virtual-module-3OPYLD76.js.map
@@ -1,11 +1,11 @@
1
- import "./chunk-WAYUHS54.js";
1
+ import "./chunk-GDF2XQOO.js";
2
2
  import "./chunk-GAJOZJWD.js";
3
3
  import "./chunk-WSOAN4KN.js";
4
4
  import "./chunk-ENSFCKP6.js";
5
- import "./chunk-5AGNZXHJ.js";
5
+ import "./chunk-Q7T3UQ4L.js";
6
6
  import "./chunk-P6OS7652.js";
7
7
  import "./chunk-ZDUO4IYN.js";
8
- import "./chunk-D4VP2QPR.js";
8
+ import "./chunk-7L7LQ2GU.js";
9
9
  import "./chunk-ENRT6DAU.js";
10
10
  import "./chunk-47FFT43U.js";
11
11
  import "./chunk-NTDN54XO.js";
@@ -234,4 +234,4 @@ export const actions = manifest
234
234
  export {
235
235
  actionsVirtualModule
236
236
  };
237
- //# sourceMappingURL=actions-virtual-module-YIWQTI6Q.js.map
237
+ //# sourceMappingURL=actions-virtual-module-SE44BKR4.js.map
@@ -3,7 +3,7 @@ import "tsx/esm";
3
3
  import {
4
4
  agentCommand,
5
5
  createAgentSsrLoader
6
- } from "./chunk-UKMOQWUC.js";
6
+ } from "./chunk-FYYKMPST.js";
7
7
  import "./chunk-UETVDZBE.js";
8
8
  import "./chunk-5NNFO7R7.js";
9
9
  import "./chunk-Z7CJHDLS.js";
@@ -12,4 +12,4 @@ export {
12
12
  agentCommand,
13
13
  createAgentSsrLoader
14
14
  };
15
- //# sourceMappingURL=agent-C7F5O5V4.js.map
15
+ //# sourceMappingURL=agent-UBDDP2L5.js.map
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import "tsx/esm";
3
- import "./chunk-B4Z7KIIU.js";
3
+ import "./chunk-G2NWAVGG.js";
4
4
  import "./chunk-UETVDZBE.js";
5
5
  import {
6
6
  scanControllerModules
7
7
  } from "./chunk-QD5X56I3.js";
8
8
  import "./chunk-WSMLSIS5.js";
9
- import "./chunk-5VLP3GQ2.js";
9
+ import "./chunk-MS4A7N77.js";
10
10
  import "./chunk-C27VRUVN.js";
11
11
  import "./chunk-7UZZHCRN.js";
12
12
  import {
@@ -411,4 +411,4 @@ export {
411
411
  generateClientDts,
412
412
  shouldReemitForFile
413
413
  };
414
- //# sourceMappingURL=app-typed-client-CUM2GZ5Y.js.map
414
+ //# sourceMappingURL=app-typed-client-BE3PV3JY.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  scanControllerModules
3
- } from "./chunk-WAYUHS54.js";
3
+ } from "./chunk-GDF2XQOO.js";
4
4
  import "./chunk-GAJOZJWD.js";
5
5
  import "./chunk-WSOAN4KN.js";
6
6
  import "./chunk-ENSFCKP6.js";
7
- import "./chunk-5AGNZXHJ.js";
7
+ import "./chunk-Q7T3UQ4L.js";
8
8
  import "./chunk-P6OS7652.js";
9
9
  import "./chunk-ZDUO4IYN.js";
10
- import "./chunk-D4VP2QPR.js";
10
+ import "./chunk-7L7LQ2GU.js";
11
11
  import "./chunk-ENRT6DAU.js";
12
12
  import "./chunk-47FFT43U.js";
13
13
  import "./chunk-NTDN54XO.js";
@@ -427,4 +427,4 @@ export {
427
427
  generateClientDts,
428
428
  shouldReemitForFile
429
429
  };
430
- //# sourceMappingURL=app-typed-client-2ZEGNFJP.js.map
430
+ //# sourceMappingURL=app-typed-client-RAFEBA7S.js.map
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ import "tsx/esm";
3
+
4
+ // src/vite-plugin/assets-map.ts
5
+ var PAGE_FILE = /[/\\]page\.(tsx|ts|jsx|js)$/;
6
+ function routePathForPageFile(appDir, moduleId) {
7
+ const normalised = moduleId.replace(/\\/g, "/");
8
+ const root = appDir.replace(/\\/g, "/").replace(/\/$/, "");
9
+ if (!normalised.startsWith(`${root}/`)) return void 0;
10
+ if (!PAGE_FILE.test(normalised)) return void 0;
11
+ const relative = normalised.slice(root.length).replace(PAGE_FILE, "");
12
+ return relative === "" ? "/" : relative;
13
+ }
14
+ function staticClosure(bundle, start) {
15
+ const seen = /* @__PURE__ */ new Set();
16
+ const queue = [start];
17
+ while (queue.length > 0) {
18
+ const name = queue.pop();
19
+ if (name === void 0 || seen.has(name)) continue;
20
+ seen.add(name);
21
+ for (const next of bundle[name]?.imports ?? []) queue.push(next);
22
+ }
23
+ return seen;
24
+ }
25
+ function buildAssetsMap(bundle, appDir) {
26
+ const chunks = Object.entries(bundle).filter(
27
+ (entry) => entry[1]?.type === "chunk"
28
+ );
29
+ const alreadyLoaded = /* @__PURE__ */ new Set();
30
+ for (const [name, chunk] of chunks) {
31
+ if (chunk.isEntry === true) {
32
+ for (const reachable of staticClosure(bundle, name)) alreadyLoaded.add(reachable);
33
+ }
34
+ }
35
+ const map = {};
36
+ for (const [name, chunk] of chunks) {
37
+ const moduleId = chunk.facadeModuleId;
38
+ if (moduleId === void 0 || moduleId === null) continue;
39
+ const route = routePathForPageFile(appDir, moduleId);
40
+ if (route === void 0) continue;
41
+ map[route] = [...staticClosure(bundle, name)].filter((f) => !alreadyLoaded.has(f)).sort((a, b) => a.localeCompare(b));
42
+ }
43
+ return map;
44
+ }
45
+ function assetsMapPlugin(opts) {
46
+ let isSsrPass = false;
47
+ return {
48
+ name: "theokit:assets-map",
49
+ apply: "build",
50
+ configResolved(config) {
51
+ isSsrPass = Boolean(config.build.ssr);
52
+ },
53
+ generateBundle(_options, bundle) {
54
+ if (isSsrPass) return;
55
+ const map = buildAssetsMap(bundle, opts.appDir);
56
+ this.emitFile({
57
+ type: "asset",
58
+ fileName: "assets-map.json",
59
+ source: `${JSON.stringify(map, null, 2)}
60
+ `
61
+ });
62
+ }
63
+ };
64
+ }
65
+ export {
66
+ assetsMapPlugin,
67
+ buildAssetsMap,
68
+ routePathForPageFile
69
+ };
70
+ //# sourceMappingURL=assets-map-BMQASQHW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite-plugin/assets-map.ts"],"sourcesContent":["/**\n * Emits `assets-map.json` — the route-to-chunks relation a document needs in order to preload\n * what the current route will import, instead of discovering it one round trip later.\n *\n * Chunk names exist only AFTER bundling, which is why this is a `generateBundle` hook and not a\n * post-build script reading `.vite/manifest.json`: Rollup hands the bundle in as an argument, and\n * the pre-bundle manifests must keep emitting before Vite so a failing build still leaves\n * diagnostics (B-035 ADR-1).\n *\n * `apply: 'build'` is not decoration. The plugin set this joins is shared by `theokit build`,\n * `theo dev` and `theo agent`; removing the plugin from the two serve chains is stronger than\n * relying on the hook never being reached there. The repository already uses the mirror of this in\n * `services-typed-client.ts` (`apply: 'serve'`, \"dev-only; never runs in build\").\n *\n * The SSR pass is skipped by reading the RESOLVED `build.ssr`, never a factory option: the adapter\n * calls the plugin factory twice (`adapters/node.ts:57` client, `:71` ssr) and passes `ssr: true`\n * to BOTH when the project enables SSR, so the option in the signature cannot tell the passes\n * apart. Emitting on the server pass would produce a second, unread `assets-map.json` under\n * `.theokit/server/` — harmless, because `this.emitFile` can only write inside its own build's\n * `outDir`, and deliberately avoided anyway so no future reader picks the wrong one.\n */\nimport type { Plugin } from 'vite'\n\n/** A route path mapped to the chunk file names it needs beyond what the entry already loads. */\nexport type AssetsMap = Record<string, string[]>\n\n/** Rollup's `generateBundle` bundle value, narrowed to the fields this hook reads. */\n/**\n * Exported so a fixture can be typed as one. A test that builds a chunk shape by hand and cannot\n * name the type is a test the compiler checks against `Record<string, unknown>` — which is what\n * silently erased every `fileName` a fixture passed until the root `tsc` reported it.\n */\nexport interface BundleChunk {\n type: string\n isEntry?: boolean\n fileName: string\n facadeModuleId?: string | null\n imports?: string[]\n /**\n * Declared and deliberately NOT walked. A dynamic import is by definition what the browser fetches\n * later; preloading it would defeat the split that made it dynamic.\n *\n * Naming it here is what makes the test asserting that meaningful. The field was absent from this\n * type while a fixture passed it, so the case named \"does not follow dynamic imports\" passed\n * because the walker ignores unknown keys — proving the behaviour by accident rather than by\n * design. The root `tsc` reported it once the fixture helper stopped erasing its overrides.\n */\n dynamicImports?: string[]\n}\n\n/**\n * A bundle as this hook reads it. The value is `| undefined` ON PURPOSE: an `imports` entry may\n * name something the bundle does not contain (an external), and a lookup that cannot miss would\n * make the optional chain in `staticClosure` look redundant to a type-based lint while removing\n * it would crash at runtime. The type is widened to match reality rather than the guard narrowed\n * to match the type.\n */\ntype BundleLike = Record<string, BundleChunk | undefined>\n\nconst PAGE_FILE = /[/\\\\]page\\.(tsx|ts|jsx|js)$/\n\n/**\n * Derive the route path a page file serves. `<appDir>/about/page.tsx` -> `/about`;\n * `<appDir>/page.tsx` -> `/`. Returns undefined when the file is not a page under `appDir`.\n */\nexport function routePathForPageFile(appDir: string, moduleId: string): string | undefined {\n const normalised = moduleId.replace(/\\\\/g, '/')\n const root = appDir.replace(/\\\\/g, '/').replace(/\\/$/, '')\n if (!normalised.startsWith(`${root}/`)) return undefined\n if (!PAGE_FILE.test(normalised)) return undefined\n const relative = normalised.slice(root.length).replace(PAGE_FILE, '')\n return relative === '' ? '/' : relative\n}\n\n/**\n * Every chunk reachable from `start` through STATIC imports, `start` included. Dynamic imports are\n * deliberately excluded: they are what the browser fetches later, by definition, and preloading\n * them would defeat the split that produced them.\n */\nfunction staticClosure(bundle: BundleLike, start: string): Set<string> {\n const seen = new Set<string>()\n const queue = [start]\n while (queue.length > 0) {\n const name = queue.pop()\n if (name === undefined || seen.has(name)) continue\n seen.add(name)\n for (const next of bundle[name]?.imports ?? []) queue.push(next)\n }\n return seen\n}\n\n/**\n * Compute the map from a Rollup bundle. Exported for unit testing without running a build —\n * the hook below is a thin wrapper so this function carries the behaviour.\n */\nexport function buildAssetsMap(bundle: BundleLike, appDir: string): AssetsMap {\n const chunks = Object.entries(bundle).filter(\n (entry): entry is [string, BundleChunk] => entry[1]?.type === 'chunk',\n )\n\n // What the document already loads. A route needing only these needs no preload at all, which is\n // the case an over-eager implementation gets wrong and the empty array records honestly.\n const alreadyLoaded = new Set<string>()\n for (const [name, chunk] of chunks) {\n if (chunk.isEntry === true) {\n for (const reachable of staticClosure(bundle, name)) alreadyLoaded.add(reachable)\n }\n }\n\n const map: AssetsMap = {}\n for (const [name, chunk] of chunks) {\n const moduleId = chunk.facadeModuleId\n if (moduleId === undefined || moduleId === null) continue\n const route = routePathForPageFile(appDir, moduleId)\n if (route === undefined) continue\n map[route] = [...staticClosure(bundle, name)]\n .filter((f) => !alreadyLoaded.has(f))\n .sort((a, b) => a.localeCompare(b))\n }\n return map\n}\n\n/** The plugin. See the module docblock for why `apply` and the SSR skip are what they are. */\nexport function assetsMapPlugin(opts: { appDir: string }): Plugin {\n let isSsrPass = false\n return {\n name: 'theokit:assets-map',\n apply: 'build',\n configResolved(config) {\n // The RESOLVED flag, per build pass — not the factory option, which is `true` in both.\n isSsrPass = Boolean(config.build.ssr)\n },\n generateBundle(_options, bundle) {\n if (isSsrPass) return\n const map = buildAssetsMap(bundle, opts.appDir)\n this.emitFile({\n type: 'asset',\n fileName: 'assets-map.json',\n source: `${JSON.stringify(map, null, 2)}\\n`,\n })\n },\n }\n}\n"],"mappings":";;;;AA2DA,IAAM,YAAY;AAMX,SAAS,qBAAqB,QAAgB,UAAsC;AACzF,QAAM,aAAa,SAAS,QAAQ,OAAO,GAAG;AAC9C,QAAM,OAAO,OAAO,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE;AACzD,MAAI,CAAC,WAAW,WAAW,GAAG,IAAI,GAAG,EAAG,QAAO;AAC/C,MAAI,CAAC,UAAU,KAAK,UAAU,EAAG,QAAO;AACxC,QAAM,WAAW,WAAW,MAAM,KAAK,MAAM,EAAE,QAAQ,WAAW,EAAE;AACpE,SAAO,aAAa,KAAK,MAAM;AACjC;AAOA,SAAS,cAAc,QAAoB,OAA4B;AACrE,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAQ,CAAC,KAAK;AACpB,SAAO,MAAM,SAAS,GAAG;AACvB,UAAM,OAAO,MAAM,IAAI;AACvB,QAAI,SAAS,UAAa,KAAK,IAAI,IAAI,EAAG;AAC1C,SAAK,IAAI,IAAI;AACb,eAAW,QAAQ,OAAO,IAAI,GAAG,WAAW,CAAC,EAAG,OAAM,KAAK,IAAI;AAAA,EACjE;AACA,SAAO;AACT;AAMO,SAAS,eAAe,QAAoB,QAA2B;AAC5E,QAAM,SAAS,OAAO,QAAQ,MAAM,EAAE;AAAA,IACpC,CAAC,UAA0C,MAAM,CAAC,GAAG,SAAS;AAAA,EAChE;AAIA,QAAM,gBAAgB,oBAAI,IAAY;AACtC,aAAW,CAAC,MAAM,KAAK,KAAK,QAAQ;AAClC,QAAI,MAAM,YAAY,MAAM;AAC1B,iBAAW,aAAa,cAAc,QAAQ,IAAI,EAAG,eAAc,IAAI,SAAS;AAAA,IAClF;AAAA,EACF;AAEA,QAAM,MAAiB,CAAC;AACxB,aAAW,CAAC,MAAM,KAAK,KAAK,QAAQ;AAClC,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,UAAa,aAAa,KAAM;AACjD,UAAM,QAAQ,qBAAqB,QAAQ,QAAQ;AACnD,QAAI,UAAU,OAAW;AACzB,QAAI,KAAK,IAAI,CAAC,GAAG,cAAc,QAAQ,IAAI,CAAC,EACzC,OAAO,CAAC,MAAM,CAAC,cAAc,IAAI,CAAC,CAAC,EACnC,KAAK,CAAC,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;AAAA,EACtC;AACA,SAAO;AACT;AAGO,SAAS,gBAAgB,MAAkC;AAChE,MAAI,YAAY;AAChB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,eAAe,QAAQ;AAErB,kBAAY,QAAQ,OAAO,MAAM,GAAG;AAAA,IACtC;AAAA,IACA,eAAe,UAAU,QAAQ;AAC/B,UAAI,UAAW;AACf,YAAM,MAAM,eAAe,QAAQ,KAAK,MAAM;AAC9C,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,CAAC;AAAA;AAAA,MACzC,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,69 @@
1
+ import "./chunk-XTHN6JBX.js";
2
+
3
+ // src/vite-plugin/assets-map.ts
4
+ var PAGE_FILE = /[/\\]page\.(tsx|ts|jsx|js)$/;
5
+ function routePathForPageFile(appDir, moduleId) {
6
+ const normalised = moduleId.replace(/\\/g, "/");
7
+ const root = appDir.replace(/\\/g, "/").replace(/\/$/, "");
8
+ if (!normalised.startsWith(`${root}/`)) return void 0;
9
+ if (!PAGE_FILE.test(normalised)) return void 0;
10
+ const relative = normalised.slice(root.length).replace(PAGE_FILE, "");
11
+ return relative === "" ? "/" : relative;
12
+ }
13
+ function staticClosure(bundle, start) {
14
+ const seen = /* @__PURE__ */ new Set();
15
+ const queue = [start];
16
+ while (queue.length > 0) {
17
+ const name = queue.pop();
18
+ if (name === void 0 || seen.has(name)) continue;
19
+ seen.add(name);
20
+ for (const next of bundle[name]?.imports ?? []) queue.push(next);
21
+ }
22
+ return seen;
23
+ }
24
+ function buildAssetsMap(bundle, appDir) {
25
+ const chunks = Object.entries(bundle).filter(
26
+ (entry) => entry[1]?.type === "chunk"
27
+ );
28
+ const alreadyLoaded = /* @__PURE__ */ new Set();
29
+ for (const [name, chunk] of chunks) {
30
+ if (chunk.isEntry === true) {
31
+ for (const reachable of staticClosure(bundle, name)) alreadyLoaded.add(reachable);
32
+ }
33
+ }
34
+ const map = {};
35
+ for (const [name, chunk] of chunks) {
36
+ const moduleId = chunk.facadeModuleId;
37
+ if (moduleId === void 0 || moduleId === null) continue;
38
+ const route = routePathForPageFile(appDir, moduleId);
39
+ if (route === void 0) continue;
40
+ map[route] = [...staticClosure(bundle, name)].filter((f) => !alreadyLoaded.has(f)).sort((a, b) => a.localeCompare(b));
41
+ }
42
+ return map;
43
+ }
44
+ function assetsMapPlugin(opts) {
45
+ let isSsrPass = false;
46
+ return {
47
+ name: "theokit:assets-map",
48
+ apply: "build",
49
+ configResolved(config) {
50
+ isSsrPass = Boolean(config.build.ssr);
51
+ },
52
+ generateBundle(_options, bundle) {
53
+ if (isSsrPass) return;
54
+ const map = buildAssetsMap(bundle, opts.appDir);
55
+ this.emitFile({
56
+ type: "asset",
57
+ fileName: "assets-map.json",
58
+ source: `${JSON.stringify(map, null, 2)}
59
+ `
60
+ });
61
+ }
62
+ };
63
+ }
64
+ export {
65
+ assetsMapPlugin,
66
+ buildAssetsMap,
67
+ routePathForPageFile
68
+ };
69
+ //# sourceMappingURL=assets-map-CV2YZ3MY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite-plugin/assets-map.ts"],"mappings":";;;AA2DA,IAAM,YAAY;AAMX,SAAS,qBAAqB,QAAgB,UAAsC;AACzF,QAAM,aAAa,SAAS,QAAQ,OAAO,GAAG;AAC9C,QAAM,OAAO,OAAO,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE;AACzD,MAAI,CAAC,WAAW,WAAW,GAAG,IAAI,GAAG,EAAG,QAAO;AAC/C,MAAI,CAAC,UAAU,KAAK,UAAU,EAAG,QAAO;AACxC,QAAM,WAAW,WAAW,MAAM,KAAK,MAAM,EAAE,QAAQ,WAAW,EAAE;AACpE,SAAO,aAAa,KAAK,MAAM;AACjC;AAOA,SAAS,cAAc,QAAoB,OAA4B;AACrE,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAQ,CAAC,KAAK;AACpB,SAAO,MAAM,SAAS,GAAG;AACvB,UAAM,OAAO,MAAM,IAAI;AACvB,QAAI,SAAS,UAAa,KAAK,IAAI,IAAI,EAAG;AAC1C,SAAK,IAAI,IAAI;AACb,eAAW,QAAQ,OAAO,IAAI,GAAG,WAAW,CAAC,EAAG,OAAM,KAAK,IAAI;AAAA,EACjE;AACA,SAAO;AACT;AAMO,SAAS,eAAe,QAAoB,QAA2B;AAC5E,QAAM,SAAS,OAAO,QAAQ,MAAM,EAAE;AAAA,IACpC,CAAC,UAA0C,MAAM,CAAC,GAAG,SAAS;AAAA,EAChE;AAIA,QAAM,gBAAgB,oBAAI,IAAY;AACtC,aAAW,CAAC,MAAM,KAAK,KAAK,QAAQ;AAClC,QAAI,MAAM,YAAY,MAAM;AAC1B,iBAAW,aAAa,cAAc,QAAQ,IAAI,EAAG,eAAc,IAAI,SAAS;AAAA,IAClF;AAAA,EACF;AAEA,QAAM,MAAiB,CAAC;AACxB,aAAW,CAAC,MAAM,KAAK,KAAK,QAAQ;AAClC,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,UAAa,aAAa,KAAM;AACjD,UAAM,QAAQ,qBAAqB,QAAQ,QAAQ;AACnD,QAAI,UAAU,OAAW;AACzB,QAAI,KAAK,IAAI,CAAC,GAAG,cAAc,QAAQ,IAAI,CAAC,EACzC,OAAO,CAAC,MAAM,CAAC,cAAc,IAAI,CAAC,CAAC,EACnC,KAAK,CAAC,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;AAAA,EACtC;AACA,SAAO;AACT;AAGO,SAAS,gBAAgB,MAAkC;AAChE,MAAI,YAAY;AAChB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,eAAe,QAAQ;AAErB,kBAAY,QAAQ,OAAO,MAAM,GAAG;AAAA,IACtC;AAAA,IACA,eAAe,UAAU,QAAQ;AAC/B,UAAI,UAAW;AACf,YAAM,MAAM,eAAe,QAAQ,KAAK,MAAM;AAC9C,WAAK,SAAS;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,CAAC;AAAA;AAAA,MACzC,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -10,13 +10,13 @@ import {
10
10
  import {
11
11
  preflightNodeAndBindings
12
12
  } from "./chunk-KTMQUYED.js";
13
+ import "./chunk-QD5X56I3.js";
14
+ import "./chunk-C27VRUVN.js";
15
+ import "./chunk-7UZZHCRN.js";
13
16
  import {
14
17
  emitOpenApi,
15
18
  loadRoutesForOpenApi
16
19
  } from "./chunk-47VNWTL4.js";
17
- import "./chunk-QD5X56I3.js";
18
- import "./chunk-C27VRUVN.js";
19
- import "./chunk-7UZZHCRN.js";
20
20
  import {
21
21
  generateManifest,
22
22
  writeManifest as writeManifest2
@@ -554,7 +554,7 @@ async function buildCommand(options) {
554
554
  `);
555
555
  }
556
556
  async function runAdapterBuild(target, config, cwd) {
557
- const { theoPluginAsync } = await import("./vite-plugin-ILWLTOKK.js");
557
+ const { theoPluginAsync } = await import("./vite-plugin-WBF5NXGW.js");
558
558
  const { default: react } = await import("@vitejs/plugin-react");
559
559
  const ctx = {
560
560
  // `react()` may return Plugin or Plugin[] depending on version; spread the
@@ -603,7 +603,7 @@ async function runAdapterBuild(target, config, cwd) {
603
603
  };
604
604
  }
605
605
  };
606
- const { resolveAdapter } = await import("./registry-E5XEUKG6.js");
606
+ const { resolveAdapter } = await import("./registry-UOWTDUFL.js");
607
607
  const adapter = await resolveAdapter(target);
608
608
  const { warnUnappliedConfig, assertRateLimitEnforceable } = await import("./config-support-O4REYSK5.js");
609
609
  assertRateLimitEnforceable(config, adapter, target);
@@ -676,4 +676,4 @@ function relativize3(absPath, root) {
676
676
  export {
677
677
  buildCommand
678
678
  };
679
- //# sourceMappingURL=build-UNBI6VKC.js.map
679
+ //# sourceMappingURL=build-U4HVYY6F.js.map
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import "tsx/esm";
3
+
4
+ // src/core/contracts/module-preloads.ts
5
+ function escapeAttribute(value) {
6
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
7
+ }
8
+ function routePathFromTarget(target) {
9
+ if (target.startsWith("/")) return target.split(/[?#]/)[0];
10
+ try {
11
+ return new URL(target).pathname;
12
+ } catch {
13
+ return void 0;
14
+ }
15
+ }
16
+ function injectModulePreloads(head, assetsMap, url) {
17
+ if (assetsMap === void 0) return head;
18
+ const path = routePathFromTarget(url);
19
+ if (path === void 0) return head;
20
+ const route = path.length > 1 ? path.replace(/\/$/, "") : path;
21
+ const chunks = assetsMap[route] ?? assetsMap[path];
22
+ if (chunks === void 0 || chunks.length === 0) return head;
23
+ const links = chunks.map((chunk) => `<link rel="modulepreload" href="/${escapeAttribute(chunk)}">`).join("");
24
+ const closing = /<\/head\s*>/i;
25
+ return closing.test(head) ? head.replace(closing, (tag) => links + tag) : head + links;
26
+ }
27
+ function parseAssetsMap(text) {
28
+ try {
29
+ const parsed = JSON.parse(text);
30
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
31
+ const entries = Object.entries(parsed).filter(
32
+ (entry) => Array.isArray(entry[1]) && entry[1].every((value) => typeof value === "string")
33
+ );
34
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
35
+ } catch {
36
+ return void 0;
37
+ }
38
+ }
39
+
40
+ export {
41
+ injectModulePreloads,
42
+ parseAssetsMap
43
+ };
44
+ //# sourceMappingURL=chunk-46FM5AFZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/contracts/module-preloads.ts"],"sourcesContent":["/**\n * Render `<link rel=\"modulepreload\">` for the chunks a route needs beyond the entry (B-035).\n *\n * **The single source of truth, for the Node server AND the Cloudflare worker.**\n *\n * An earlier revision of this file asserted that the worker had to carry a COPY because\n * `theokit`'s package exports declare no subpath reaching `core/`. **That was false, and it was\n * stated three times** — here, in `adapters/cloudflare.ts`, and in a commit message. `server/\n * index.ts` already re-exports from `core/contracts/` *\"for consumer ergonomics\"* in its own\n * words, `adapters/security-headers.ts` imports `generateNonce` and `buildSecurityHeaders` from\n * here, and the generated worker imports BOTH of those subpaths. Adding a named export to an\n * existing barrel touches no `package.json`, so the constraint never existed.\n *\n * The copy is gone. `theokit/server` re-exports `injectModulePreloads` and the worker imports it,\n * which is the shape `adapters/security-headers.ts` established one directory over — and whose\n * docblock states the reason better than this one could: *\"a shape stated in two files drifts\"*.\n * It drifted the same day: the proxy fix below landed in this file and not in the copy.\n */\n\n/** A route path mapped to the chunk file names it needs beyond the entry. */\nexport type AssetsMap = Record<string, string[] | undefined>\n\n/** Attribute-safe: a chunk name must not be able to close the attribute it sits in. */\nfunction escapeAttribute(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;')\n}\n\n/**\n * Inject one `<link rel=\"modulepreload\">` per chunk the route needs, before `</head>`.\n *\n * In the HEAD, not the body: a preload the browser meets after parsing the entry teaches it\n * nothing it was not about to learn a moment later, which is the defect rather than a preference.\n *\n * Returns `head` unchanged for an absent map, an unmapped route, or an empty chunk list. None of\n * those is an error: a build predating the map, or a route the scan did not see, must serve\n * without preloads rather than fail the request.\n */\n/**\n * The route path a request target names, whichever form the target takes.\n *\n * **Found at review, B-035.** The two call sites do not agree on the shape they pass:\n * `cli/commands/start/request-handler.ts` passes `req.url` RAW, and the Cloudflare worker passes\n * `new URL(request.url).pathname`. RFC 9112 §3.2.2 requires an origin server to accept the\n * absolute form, and a proxy sends it — so `GET http://example.com/about` reached this function as\n * a whole URL, matched no key, and the feature silently did nothing on Node behind a proxy while\n * the worker worked. Normalising HERE rather than at each call site is what makes the two agree by\n * construction instead of by two people remembering.\n *\n * Returns `undefined` for a target this cannot read. That is deliberate: inventing a route from an\n * unparseable target would preload another route's chunks, which is worse than preloading none.\n */\nfunction routePathFromTarget(target: string): string | undefined {\n if (target.startsWith('/')) return target.split(/[?#]/)[0]\n // Absolute form. `URL` is the platform's own parser and is present in Node and in a Worker —\n // parsimony rung 3, and it is the same parser the worker's call site already uses.\n try {\n return new URL(target).pathname\n } catch {\n return undefined\n }\n}\n\nexport function injectModulePreloads(\n head: string,\n assetsMap: AssetsMap | undefined,\n url: string,\n): string {\n if (assetsMap === undefined) return head\n const path = routePathFromTarget(url)\n if (path === undefined) return head\n const route = path.length > 1 ? path.replace(/\\/$/, '') : path\n const chunks = assetsMap[route] ?? assetsMap[path]\n if (chunks === undefined || chunks.length === 0) return head\n const links = chunks\n .map((chunk) => `<link rel=\"modulepreload\" href=\"/${escapeAttribute(chunk)}\">`)\n .join('')\n const closing = /<\\/head\\s*>/i\n return closing.test(head) ? head.replace(closing, (tag) => links + tag) : head + links\n}\n\n/**\n * Decide whether a document is a usable assets map, and return it if so.\n *\n * **Found at review, B-035.** This body existed TWICE, byte-identical modulo the function name —\n * `cli/commands/start/ssr-setup.ts` for the Node server and `adapters/cloudflare.ts` for the bake.\n * Nothing forced the copy: `.dependency-cruiser.cjs` permits `adapters/` -> `core/`, and\n * `cloudflare.ts` already imports from here. What was duplicated is the ACCEPTANCE RULE for a file\n * format, so tightening one side — rejecting `../` in a chunk name, say, which is the obvious next\n * hardening for a value that becomes an `href` — would have left the other accepting it, surfacing\n * as \"Cloudflare accepts a map Node rejects\" in a deploy.\n *\n * The I/O stays with each caller; only the shape decision lives here.\n *\n * Returns `undefined` for anything unusable, and never throws. A server that refused to boot, or a\n * deploy that failed, because an optimisation was missing would turn a lost round trip into an\n * outage.\n */\nexport function parseAssetsMap(text: string): Record<string, string[]> | undefined {\n try {\n const parsed: unknown = JSON.parse(text)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return undefined\n const entries = Object.entries(parsed).filter(\n (entry): entry is [string, string[]] =>\n Array.isArray(entry[1]) && entry[1].every((value) => typeof value === 'string'),\n )\n return entries.length > 0 ? Object.fromEntries(entries) : undefined\n } catch {\n return undefined\n }\n}\n"],"mappings":";;;;AAuBA,SAAS,gBAAgB,OAAuB;AAC9C,SAAO,MAAM,QAAQ,MAAM,OAAO,EAAE,QAAQ,MAAM,QAAQ,EAAE,QAAQ,MAAM,MAAM;AAClF;AA0BA,SAAS,oBAAoB,QAAoC;AAC/D,MAAI,OAAO,WAAW,GAAG,EAAG,QAAO,OAAO,MAAM,MAAM,EAAE,CAAC;AAGzD,MAAI;AACF,WAAO,IAAI,IAAI,MAAM,EAAE;AAAA,EACzB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,qBACd,MACA,WACA,KACQ;AACR,MAAI,cAAc,OAAW,QAAO;AACpC,QAAM,OAAO,oBAAoB,GAAG;AACpC,MAAI,SAAS,OAAW,QAAO;AAC/B,QAAM,QAAQ,KAAK,SAAS,IAAI,KAAK,QAAQ,OAAO,EAAE,IAAI;AAC1D,QAAM,SAAS,UAAU,KAAK,KAAK,UAAU,IAAI;AACjD,MAAI,WAAW,UAAa,OAAO,WAAW,EAAG,QAAO;AACxD,QAAM,QAAQ,OACX,IAAI,CAAC,UAAU,oCAAoC,gBAAgB,KAAK,CAAC,IAAI,EAC7E,KAAK,EAAE;AACV,QAAM,UAAU;AAChB,SAAO,QAAQ,KAAK,IAAI,IAAI,KAAK,QAAQ,SAAS,CAAC,QAAQ,QAAQ,GAAG,IAAI,OAAO;AACnF;AAmBO,SAAS,eAAe,MAAoD;AACjF,MAAI;AACF,UAAM,SAAkB,KAAK,MAAM,IAAI;AACvC,QAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,EAAG,QAAO;AACnF,UAAM,UAAU,OAAO,QAAQ,MAAM,EAAE;AAAA,MACrC,CAAC,UACC,MAAM,QAAQ,MAAM,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,MAAM,CAAC,UAAU,OAAO,UAAU,QAAQ;AAAA,IAClF;AACA,WAAO,QAAQ,SAAS,IAAI,OAAO,YAAY,OAAO,IAAI;AAAA,EAC5D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -13,4 +13,4 @@ export {
13
13
  WEB_SHAPED_MIDDLEWARE,
14
14
  defineMiddleware
15
15
  };
16
- //# sourceMappingURL=chunk-D4VP2QPR.js.map
16
+ //# sourceMappingURL=chunk-7L7LQ2GU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/define/define-middleware.ts"],"mappings":";AA2CO,IAAM,wBAAwB,uBAAO,IAAI,+BAA+B;AAUxE,SAAS,iBAAiB,SAA+C;AAC9E,SAAO,eAAe,SAAS,uBAAuB;AAAA,IACpD,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/server/define/define-middleware.ts"],"mappings":";AAkEO,IAAM,wBAAwB,uBAAO,IAAI,+BAA+B;AAUxE,SAAS,iBAAiB,SAA+C;AAC9E,SAAO,eAAe,SAAS,uBAAuB;AAAA,IACpD,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACD,SAAO;AACT;","names":[]}
@@ -25,7 +25,7 @@ import {
25
25
  parseAgentRequestBody,
26
26
  readAgentPolicy,
27
27
  subjectFromContext
28
- } from "./chunk-B4Z7KIIU.js";
28
+ } from "./chunk-G2NWAVGG.js";
29
29
  import {
30
30
  getApprovalRegistry
31
31
  } from "./chunk-UETVDZBE.js";
@@ -879,4 +879,4 @@ export {
879
879
  applyNonceToInlineScripts,
880
880
  setupSsrDevMiddleware
881
881
  };
882
- //# sourceMappingURL=chunk-ASBXR57P.js.map
882
+ //# sourceMappingURL=chunk-7THO4PRL.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMiddleware
3
- } from "./chunk-D4VP2QPR.js";
3
+ } from "./chunk-7L7LQ2GU.js";
4
4
  import {
5
5
  defineAgentTool
6
6
  } from "./chunk-DVUJLMTF.js";
@@ -232,4 +232,4 @@ export {
232
232
  defineChannel,
233
233
  defineWebChannel
234
234
  };
235
- //# sourceMappingURL=chunk-EQCSUC65.js.map
235
+ //# sourceMappingURL=chunk-AROOYXI5.js.map
@@ -12,14 +12,10 @@ import {
12
12
  serveMatchedAuxRoute,
13
13
  serveThroughPluginLifecycle,
14
14
  setupSsrDevMiddleware
15
- } from "./chunk-ASBXR57P.js";
15
+ } from "./chunk-7THO4PRL.js";
16
16
  import {
17
17
  resolveTheoRootDir
18
18
  } from "./chunk-FDOOBTXJ.js";
19
- import {
20
- isRouteFile,
21
- scanRoutes
22
- } from "./chunk-47MM2JUK.js";
23
19
  import {
24
20
  BATCH_PATH,
25
21
  CSP_REPORT_PATH,
@@ -38,7 +34,7 @@ import {
38
34
  mountAgent,
39
35
  readAgentPolicy,
40
36
  writeWebResponseToServerResponse
41
- } from "./chunk-B4Z7KIIU.js";
37
+ } from "./chunk-G2NWAVGG.js";
42
38
  import {
43
39
  getApprovalRegistry,
44
40
  resolveProvider
@@ -53,10 +49,14 @@ import {
53
49
  TRACE_HEADER,
54
50
  createObservabilityPluginFromConfig,
55
51
  extractTraceId
56
- } from "./chunk-5VLP3GQ2.js";
52
+ } from "./chunk-MS4A7N77.js";
57
53
  import {
58
54
  logRequest
59
55
  } from "./chunk-C27VRUVN.js";
56
+ import {
57
+ isRouteFile,
58
+ scanRoutes
59
+ } from "./chunk-47MM2JUK.js";
60
60
  import {
61
61
  scanAgents
62
62
  } from "./chunk-5NNFO7R7.js";
@@ -122,6 +122,18 @@ function runConfigHook(ctx) {
122
122
  }
123
123
  },
124
124
  resolve: {
125
+ // B-228 — one module instance per package, or two React contexts reach the client and the
126
+ // one `RouterProvider` filled is not the one `useLocation()` reads. The alias list below is
127
+ // what creates the condition: its catch-all maps any unlisted `theokit/*` subpath to
128
+ // WORKSPACE SOURCE, whose own bare `react-router` import then resolves against the
129
+ // workspace's node_modules while the app's entry resolves against its own. Measured
130
+ // 2026-09-20: 7.18.2 and 7.18.4 both reached one bundle, and React Router's ErrorBoundary
131
+ // replaced the whole tree with "Unexpected Application Error!".
132
+ //
133
+ // React and react-dom carry the same hazard by the same route — two React instances would
134
+ // produce this class of defect with a different symptom — so all four are named rather than
135
+ // the one that was caught.
136
+ dedupe: ["react-router", "react-router/dom", "react", "react-dom"],
125
137
  alias: [
126
138
  // Order still matters — first match wins — but the entries below are
127
139
  // EXACT (#377). A Vite alias whose `find` is a string matches by prefix,
@@ -2181,19 +2193,21 @@ async function theoPluginAsync(rootOrOptions) {
2181
2193
  })
2182
2194
  );
2183
2195
  }
2184
- const { appTypedClientPlugin } = await import("./app-typed-client-CUM2GZ5Y.js");
2196
+ const { assetsMapPlugin } = await import("./assets-map-BMQASQHW.js");
2197
+ const assetsMap = assetsMapPlugin({ appDir: resolve5(projectRoot, options.appDir ?? "app") });
2198
+ const { appTypedClientPlugin } = await import("./app-typed-client-BE3PV3JY.js");
2185
2199
  const appClientPlugin = appTypedClientPlugin({
2186
2200
  cwd: projectRoot,
2187
2201
  serverDir: serverDirAbs,
2188
2202
  distDir: resolve5(projectRoot, ".theokit")
2189
2203
  });
2190
- const { actionsVirtualModule } = await import("./actions-virtual-module-WCHXKH6R.js");
2204
+ const { actionsVirtualModule } = await import("./actions-virtual-module-3OPYLD76.js");
2191
2205
  const actionsPlugin = actionsVirtualModule({
2192
2206
  serverDir: serverDirAbs,
2193
2207
  distDir: resolve5(projectRoot, ".theokit")
2194
2208
  });
2195
2209
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-D4OA2TXB.js");
2196
- const { generateManifest } = await import("./internal-api-3JIWUI3V.js");
2210
+ const { generateManifest } = await import("./internal-api-OOTVIOH2.js");
2197
2211
  const agentsClientPlugin = agentsTypedClientPlugin({
2198
2212
  projectRoot,
2199
2213
  agentsDir: agentsDirName,
@@ -2210,7 +2224,7 @@ async function theoPluginAsync(rootOrOptions) {
2210
2224
  const controllerTransformPlugin = controllerSwcTransformPlugin({
2211
2225
  serverDir: serverDirAbs
2212
2226
  });
2213
- const { serverOnlyImportBoundary } = await import("./server-boundary-6PYWFYEL.js");
2227
+ const { serverOnlyImportBoundary } = await import("./server-boundary-A3HW27C7.js");
2214
2228
  const serverBoundaryPlugin = serverOnlyImportBoundary({
2215
2229
  projectRoot,
2216
2230
  serverDir: serverDirAbs
@@ -2226,7 +2240,8 @@ async function theoPluginAsync(rootOrOptions) {
2226
2240
  appClientPlugin,
2227
2241
  actionsPlugin,
2228
2242
  agentsClientPlugin,
2229
- routesHmrPlugin
2243
+ routesHmrPlugin,
2244
+ assetsMap
2230
2245
  ];
2231
2246
  }
2232
2247
  function buildOptimizeDepsInclude(projectRoot, viteOptimizeDeps) {
@@ -2385,4 +2400,4 @@ export {
2385
2400
  theoPluginAsync,
2386
2401
  theoPlugin
2387
2402
  };
2388
- //# sourceMappingURL=chunk-PRZCPSUE.js.map
2403
+ //# sourceMappingURL=chunk-CO7Q75IS.js.map