theokit 0.66.1 → 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.
- package/dist/{actions-virtual-module-RMEAW2NX.js → actions-virtual-module-3OPYLD76.js} +4 -4
- package/dist/{actions-virtual-module-LVWXLDCT.js → actions-virtual-module-SE44BKR4.js} +6 -6
- package/dist/adapters/security-headers.d.ts +2 -2
- package/dist/adapters/security-headers.js +1 -1
- package/dist/{agent-OCQA4WXF.js → agent-UBDDP2L5.js} +2 -2
- package/dist/{app-typed-client-J7NWKMS7.js → app-typed-client-BE3PV3JY.js} +4 -4
- package/dist/{app-typed-client-Z4MF5HCB.js → app-typed-client-RAFEBA7S.js} +6 -6
- package/dist/assets-map-BMQASQHW.js +70 -0
- package/dist/assets-map-BMQASQHW.js.map +1 -0
- package/dist/assets-map-CV2YZ3MY.js +69 -0
- package/dist/assets-map-CV2YZ3MY.js.map +1 -0
- package/dist/{aws-lambda-AN6CEBXO.js → aws-lambda-R76PWR27.js} +3 -3
- package/dist/boot/index.d.ts +4 -5
- package/dist/boot/index.js +1 -1
- package/dist/boot/index.js.map +1 -1
- package/dist/{build-JQSCQ3SQ.js → build-U4HVYY6F.js} +6 -6
- package/dist/{bun-3FFL7CS4.js → bun-NPBIAWSU.js} +3 -3
- package/dist/chunk-46FM5AFZ.js +44 -0
- package/dist/chunk-46FM5AFZ.js.map +1 -0
- package/dist/{chunk-PALZUV6E.js → chunk-6B3CMPE4.js} +2 -2
- package/dist/{chunk-D4VP2QPR.js → chunk-7L7LQ2GU.js} +1 -1
- package/dist/{chunk-D4VP2QPR.js.map → chunk-7L7LQ2GU.js.map} +1 -1
- package/dist/{chunk-MOTGIGWC.js → chunk-7THO4PRL.js} +23 -11
- package/dist/{chunk-MOTGIGWC.js.map → chunk-7THO4PRL.js.map} +1 -1
- package/dist/{chunk-3IIKKBOJ.js → chunk-AL5JHX7X.js} +24 -1
- package/dist/chunk-AL5JHX7X.js.map +1 -0
- package/dist/{chunk-EQCSUC65.js → chunk-AROOYXI5.js} +2 -2
- package/dist/{chunk-OPHA3577.js → chunk-CO7Q75IS.js} +28 -13
- package/dist/chunk-CO7Q75IS.js.map +1 -0
- package/dist/{chunk-5GZROLDV.js → chunk-ENSFCKP6.js} +5 -1
- package/dist/{chunk-5GZROLDV.js.map → chunk-ENSFCKP6.js.map} +1 -1
- package/dist/{chunk-N6XDYNWK.js → chunk-FYYKMPST.js} +2 -2
- package/dist/{chunk-O3EBLVMP.js → chunk-G2NWAVGG.js} +3 -3
- package/dist/chunk-G2NWAVGG.js.map +1 -0
- package/dist/{chunk-WAYUHS54.js → chunk-GDF2XQOO.js} +2 -2
- package/dist/{chunk-2ERTA4FM.js → chunk-LADTWXOB.js} +44 -17
- package/dist/chunk-LADTWXOB.js.map +1 -0
- package/dist/{chunk-5VLP3GQ2.js → chunk-MS4A7N77.js} +1 -1
- package/dist/chunk-MS4A7N77.js.map +1 -0
- package/dist/{chunk-5AGNZXHJ.js → chunk-Q7T3UQ4L.js} +89 -30
- package/dist/chunk-Q7T3UQ4L.js.map +1 -0
- package/dist/{chunk-5LRBIP4B.js → chunk-QGNSZ2ZK.js} +27 -2
- package/dist/chunk-QGNSZ2ZK.js.map +1 -0
- package/dist/{chunk-GAPBPRPP.js → chunk-TRCJHFAX.js} +1 -1
- package/dist/{chunk-GAPBPRPP.js.map → chunk-TRCJHFAX.js.map} +1 -1
- package/dist/{chunk-VV2VU3LJ.js → chunk-WSMLSIS5.js} +5 -1
- package/dist/chunk-WSMLSIS5.js.map +1 -0
- package/dist/{chunk-EYRWD2AB.js → chunk-WSOAN4KN.js} +2 -2
- package/dist/cli/index.js +6 -6
- package/dist/{cloudflare-VIQX4FVC.js → cloudflare-5HU56XIH.js} +38 -11
- package/dist/cloudflare-5HU56XIH.js.map +1 -0
- package/dist/{route-config-B7FaTSby.d.ts → define-middleware-D2n71Svm.d.ts} +39 -1
- package/dist/{deno-deploy-PTO7IE4G.js → deno-deploy-BXOQ45LD.js} +3 -3
- package/dist/{dev-DPOAVHUS.js → dev-E3USPAWQ.js} +7 -7
- package/dist/{health-route-C0hk64_U.d.ts → health-route-CYI7z5g3.d.ts} +2 -3
- package/dist/{index-BXGSBlxf.d.ts → index-B9iVBHJI.d.ts} +49 -7
- package/dist/index.js +6 -6
- package/dist/{internal-api-VHFQCXR2.js → internal-api-OOTVIOH2.js} +4 -4
- package/dist/{internal-api-C5NIIJJY.js → internal-api-VAKXXW6F.js} +6 -6
- package/dist/{mcp-LOMU5PGA.js → mcp-7UOQM4FW.js} +2 -2
- package/dist/{netlify-3VSNVURQ.js → netlify-LPJAPMQ2.js} +3 -3
- package/dist/{observability-bootstrap-H4NSILXD.js → observability-bootstrap-YQKMEYW7.js} +2 -2
- package/dist/{preview-24MJYNYN.js → preview-GPMF43QX.js} +3 -3
- package/dist/registry-UOWTDUFL.js +23 -0
- package/dist/{security-headers-C2cByfJn.d.ts → security-headers-vris2MQq.d.ts} +14 -0
- package/dist/server/auth/index.d.ts +17 -1
- package/dist/server/auth/index.js +3 -1
- package/dist/server/define/index.d.ts +3 -29
- package/dist/server/define/index.js +3 -3
- package/dist/server/http/index.d.ts +2 -2
- package/dist/server/http/index.js +5 -3
- package/dist/server/index.d.ts +7 -6
- package/dist/server/index.js +12 -8
- package/dist/server/index.js.map +1 -1
- package/dist/server/security/index.d.ts +2 -2
- package/dist/server/security/index.js +2 -2
- package/dist/{server-boundary-DJ4PYJR5.js → server-boundary-A3HW27C7.js} +4 -4
- package/dist/{server-boundary-FVMJ5WAU.js → server-boundary-V6PCM22J.js} +6 -6
- package/dist/{start-TXRUHKFJ.js → start-6WEPXA3X.js} +39 -15
- package/dist/start-6WEPXA3X.js.map +1 -0
- package/dist/{static-SVDWIOXJ.js → static-7OJNB7D2.js} +4 -4
- package/dist/{vercel-BZ35DF3B.js → vercel-YUZADKGV.js} +3 -3
- package/dist/vite-plugin/index.js +6 -6
- package/dist/{vite-plugin-AVFHID5Z.js → vite-plugin-WBF5NXGW.js} +7 -7
- package/package.json +2 -2
- package/dist/chunk-2ERTA4FM.js.map +0 -1
- package/dist/chunk-3IIKKBOJ.js.map +0 -1
- package/dist/chunk-5AGNZXHJ.js.map +0 -1
- package/dist/chunk-5LRBIP4B.js.map +0 -1
- package/dist/chunk-5VLP3GQ2.js.map +0 -1
- package/dist/chunk-O3EBLVMP.js.map +0 -1
- package/dist/chunk-OPHA3577.js.map +0 -1
- package/dist/chunk-VV2VU3LJ.js.map +0 -1
- package/dist/cloudflare-VIQX4FVC.js.map +0 -1
- package/dist/registry-RZHBBLIF.js +0 -23
- package/dist/start-TXRUHKFJ.js.map +0 -1
- /package/dist/{actions-virtual-module-RMEAW2NX.js.map → actions-virtual-module-3OPYLD76.js.map} +0 -0
- /package/dist/{actions-virtual-module-LVWXLDCT.js.map → actions-virtual-module-SE44BKR4.js.map} +0 -0
- /package/dist/{agent-OCQA4WXF.js.map → agent-UBDDP2L5.js.map} +0 -0
- /package/dist/{app-typed-client-J7NWKMS7.js.map → app-typed-client-BE3PV3JY.js.map} +0 -0
- /package/dist/{app-typed-client-Z4MF5HCB.js.map → app-typed-client-RAFEBA7S.js.map} +0 -0
- /package/dist/{aws-lambda-AN6CEBXO.js.map → aws-lambda-R76PWR27.js.map} +0 -0
- /package/dist/{build-JQSCQ3SQ.js.map → build-U4HVYY6F.js.map} +0 -0
- /package/dist/{bun-3FFL7CS4.js.map → bun-NPBIAWSU.js.map} +0 -0
- /package/dist/{chunk-PALZUV6E.js.map → chunk-6B3CMPE4.js.map} +0 -0
- /package/dist/{chunk-EQCSUC65.js.map → chunk-AROOYXI5.js.map} +0 -0
- /package/dist/{chunk-N6XDYNWK.js.map → chunk-FYYKMPST.js.map} +0 -0
- /package/dist/{chunk-WAYUHS54.js.map → chunk-GDF2XQOO.js.map} +0 -0
- /package/dist/{chunk-EYRWD2AB.js.map → chunk-WSOAN4KN.js.map} +0 -0
- /package/dist/{deno-deploy-PTO7IE4G.js.map → deno-deploy-BXOQ45LD.js.map} +0 -0
- /package/dist/{dev-DPOAVHUS.js.map → dev-E3USPAWQ.js.map} +0 -0
- /package/dist/{internal-api-VHFQCXR2.js.map → internal-api-OOTVIOH2.js.map} +0 -0
- /package/dist/{internal-api-C5NIIJJY.js.map → internal-api-VAKXXW6F.js.map} +0 -0
- /package/dist/{mcp-LOMU5PGA.js.map → mcp-7UOQM4FW.js.map} +0 -0
- /package/dist/{netlify-3VSNVURQ.js.map → netlify-LPJAPMQ2.js.map} +0 -0
- /package/dist/{observability-bootstrap-H4NSILXD.js.map → observability-bootstrap-YQKMEYW7.js.map} +0 -0
- /package/dist/{preview-24MJYNYN.js.map → preview-GPMF43QX.js.map} +0 -0
- /package/dist/{registry-RZHBBLIF.js.map → registry-UOWTDUFL.js.map} +0 -0
- /package/dist/{server-boundary-DJ4PYJR5.js.map → server-boundary-A3HW27C7.js.map} +0 -0
- /package/dist/{server-boundary-FVMJ5WAU.js.map → server-boundary-V6PCM22J.js.map} +0 -0
- /package/dist/{static-SVDWIOXJ.js.map → static-7OJNB7D2.js.map} +0 -0
- /package/dist/{vercel-BZ35DF3B.js.map → vercel-YUZADKGV.js.map} +0 -0
- /package/dist/{vite-plugin-AVFHID5Z.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-
|
|
3
|
+
import "./chunk-G2NWAVGG.js";
|
|
4
4
|
import "./chunk-UETVDZBE.js";
|
|
5
5
|
import "./chunk-QD5X56I3.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-WSMLSIS5.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-
|
|
221
|
+
//# sourceMappingURL=actions-virtual-module-3OPYLD76.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-GDF2XQOO.js";
|
|
2
2
|
import "./chunk-GAJOZJWD.js";
|
|
3
|
-
import "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-WSOAN4KN.js";
|
|
4
|
+
import "./chunk-ENSFCKP6.js";
|
|
5
|
+
import "./chunk-Q7T3UQ4L.js";
|
|
6
6
|
import "./chunk-P6OS7652.js";
|
|
7
7
|
import "./chunk-ZDUO4IYN.js";
|
|
8
|
-
import "./chunk-
|
|
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-
|
|
237
|
+
//# sourceMappingURL=actions-virtual-module-SE44BKR4.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { g as generateNonce } from '../nonce-BXt7Qu_C.js';
|
|
2
|
-
import { S as SecurityHeadersConfig } from '../security-headers-
|
|
3
|
-
export { b as buildSecurityHeaders } from '../security-headers-
|
|
2
|
+
import { S as SecurityHeadersConfig } from '../security-headers-vris2MQq.js';
|
|
3
|
+
export { b as buildSecurityHeaders } from '../security-headers-vris2MQq.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The security headers a deployed target puts on its responses.
|
|
@@ -3,7 +3,7 @@ import "tsx/esm";
|
|
|
3
3
|
import {
|
|
4
4
|
agentCommand,
|
|
5
5
|
createAgentSsrLoader
|
|
6
|
-
} from "./chunk-
|
|
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-
|
|
15
|
+
//# sourceMappingURL=agent-UBDDP2L5.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "tsx/esm";
|
|
3
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-G2NWAVGG.js";
|
|
4
4
|
import "./chunk-UETVDZBE.js";
|
|
5
5
|
import {
|
|
6
6
|
scanControllerModules
|
|
7
7
|
} from "./chunk-QD5X56I3.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-WSMLSIS5.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-
|
|
414
|
+
//# sourceMappingURL=app-typed-client-BE3PV3JY.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
scanControllerModules
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GDF2XQOO.js";
|
|
4
4
|
import "./chunk-GAJOZJWD.js";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-WSOAN4KN.js";
|
|
6
|
+
import "./chunk-ENSFCKP6.js";
|
|
7
|
+
import "./chunk-Q7T3UQ4L.js";
|
|
8
8
|
import "./chunk-P6OS7652.js";
|
|
9
9
|
import "./chunk-ZDUO4IYN.js";
|
|
10
|
-
import "./chunk-
|
|
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-
|
|
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":[]}
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
describeDeployedSecurityHeaders,
|
|
9
9
|
renderSecurityHeadersConfigLiteral,
|
|
10
10
|
serverDirLiteral
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6B3CMPE4.js";
|
|
12
12
|
import {
|
|
13
13
|
nodeAdapter
|
|
14
14
|
} from "./chunk-KI4DOTN4.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-WSMLSIS5.js";
|
|
16
16
|
import {
|
|
17
17
|
assertServicesUnsupported,
|
|
18
18
|
readManifest
|
|
@@ -259,4 +259,4 @@ export {
|
|
|
259
259
|
renderAwsLambdaEntry,
|
|
260
260
|
responseToLambdaResultV2
|
|
261
261
|
};
|
|
262
|
-
//# sourceMappingURL=aws-lambda-
|
|
262
|
+
//# sourceMappingURL=aws-lambda-R76PWR27.js.map
|
package/dist/boot/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { R as ReservedRoutes } from '../health-route-
|
|
1
|
+
import { R as ReservedRoutes } from '../health-route-CYI7z5g3.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* M7-3 — `theokit/boot`: programmatic boot surface for the convention server.
|
|
5
5
|
*
|
|
6
|
-
* The programmatic surface is a Web `fetch` handler
|
|
7
|
-
* handler is the entry point" contract
|
|
8
|
-
*
|
|
9
|
-
* "Coverage Corner 4"). It composes M7-1 (typed 404 envelope) + M7-2 (reserved
|
|
6
|
+
* The programmatic surface is a Web `fetch` handler — the universal "a fetch
|
|
7
|
+
* handler is the entry point" contract. It composes M7-1 (typed 404 envelope)
|
|
8
|
+
* + M7-2 (reserved
|
|
10
9
|
* health/ready routes) and binds NO socket, so embedders + integration tests
|
|
11
10
|
* can fire requests in-process via `app.fetch(new Request(...))`.
|
|
12
11
|
*
|
package/dist/boot/index.js
CHANGED
package/dist/boot/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/boot.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/server/boot.ts"],"mappings":";;;;;;;;;;;;;AAyCO,SAAS,6BACd,UAAyC,CAAC,GACnB;AACvB,SAAO;AAAA,IACL,MAAM,MAAM,SAAqC;AAC/C,YAAM,WAAW,IAAI,IAAI,QAAQ,GAAG,EAAE;AACtC,YAAM,WAAW,MAAM,mBAAmB,UAAU,QAAQ,kBAAkB,CAAC,CAAC;AAChF,UAAI,aAAa,MAAM;AACrB,eAAO,SAAS,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,CAAC;AAAA,MACjE;AAIA,YAAM,WAAW,sBAAsB,IAAI,cAAc,WAAW,CAAC;AACrE,aAAO,SAAS,KAAK,UAAU,EAAE,QAAQ,qBAAqB,SAAS,IAAI,EAAE,CAAC;AAAA,IAChF;AAAA;AAAA;AAAA,IAGA,QAAuB;AACrB,aAAO,QAAQ,QAAQ;AAAA,IACzB;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-
|
|
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-
|
|
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-
|
|
679
|
+
//# sourceMappingURL=build-U4HVYY6F.js.map
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
describeDeployedSecurityHeaders,
|
|
13
13
|
renderSecurityHeadersConfigLiteral,
|
|
14
14
|
serverDirLiteral
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6B3CMPE4.js";
|
|
16
16
|
import {
|
|
17
17
|
nodeAdapter
|
|
18
18
|
} from "./chunk-KI4DOTN4.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-WSMLSIS5.js";
|
|
20
20
|
import {
|
|
21
21
|
assertServicesUnsupported,
|
|
22
22
|
readManifest
|
|
@@ -344,4 +344,4 @@ export {
|
|
|
344
344
|
bunAdapter,
|
|
345
345
|
renderBunEntry
|
|
346
346
|
};
|
|
347
|
-
//# sourceMappingURL=bun-
|
|
347
|
+
//# sourceMappingURL=bun-NPBIAWSU.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, "&").replace(/"/g, """).replace(/</g, "<");
|
|
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, '&').replace(/\"/g, '"').replace(/</g, '<')\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":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
4
|
buildSecurityHeaders
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WSMLSIS5.js";
|
|
6
6
|
|
|
7
7
|
// src/adapters/deployed-cors.ts
|
|
8
8
|
var UnserializableCorsOriginError = class extends Error {
|
|
@@ -189,4 +189,4 @@ export {
|
|
|
189
189
|
renderSecurityHeadersConfigLiteral,
|
|
190
190
|
describeDeployedSecurityHeaders
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-6B3CMPE4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/define/define-middleware.ts"],"mappings":";
|
|
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-
|
|
28
|
+
} from "./chunk-G2NWAVGG.js";
|
|
29
29
|
import {
|
|
30
30
|
getApprovalRegistry
|
|
31
31
|
} from "./chunk-UETVDZBE.js";
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from "./chunk-QD5X56I3.js";
|
|
36
36
|
import {
|
|
37
37
|
generateNonce
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-WSMLSIS5.js";
|
|
39
39
|
|
|
40
40
|
// src/config/resolve-plugin-specifiers.ts
|
|
41
41
|
import { isAbsolute, resolve } from "path";
|
|
@@ -648,8 +648,12 @@ function isListApprovalsPath(urlPath) {
|
|
|
648
648
|
const match = LIST_PATH.exec(urlPath);
|
|
649
649
|
return match ? decodeURIComponent(match[1]) : null;
|
|
650
650
|
}
|
|
651
|
-
function handleListApprovals(registry) {
|
|
652
|
-
|
|
651
|
+
function handleListApprovals(registry, subject) {
|
|
652
|
+
const visible = registry.list().filter((approval) => {
|
|
653
|
+
const owner = registry.ownerOf(approval.approvalId);
|
|
654
|
+
return owner === void 0 || owner === subject;
|
|
655
|
+
});
|
|
656
|
+
return new Response(JSON.stringify({ approvals: visible }), {
|
|
653
657
|
status: 200,
|
|
654
658
|
headers: { "content-type": "application/json; charset=utf-8" }
|
|
655
659
|
});
|
|
@@ -718,13 +722,20 @@ async function matchAgentAuxRoute(method, urlPath, deps) {
|
|
|
718
722
|
}
|
|
719
723
|
async function admitAux(deps, agent, params, body) {
|
|
720
724
|
const mod = await deps.loadModule(agent.filePath);
|
|
725
|
+
const resolve4 = deps.resolveSubject;
|
|
726
|
+
const admitted = { subject: null };
|
|
727
|
+
const recording = resolve4 === void 0 ? void 0 : async () => {
|
|
728
|
+
admitted.subject = await resolve4();
|
|
729
|
+
return admitted.subject;
|
|
730
|
+
};
|
|
721
731
|
const decision = await admitAgentRequest(
|
|
722
732
|
readAgentPolicy(mod, agent.filePath),
|
|
723
|
-
|
|
733
|
+
recording,
|
|
724
734
|
params,
|
|
725
735
|
body
|
|
726
736
|
);
|
|
727
|
-
|
|
737
|
+
const refusal = decision.allowed ? null : agentAccessDenied(decision, params);
|
|
738
|
+
return { refusal, subject: admitted.subject?.id };
|
|
728
739
|
}
|
|
729
740
|
async function serveMatchedAuxRoute(route, request, deps) {
|
|
730
741
|
if (route.kind === "card") {
|
|
@@ -732,11 +743,12 @@ async function serveMatchedAuxRoute(route, request, deps) {
|
|
|
732
743
|
return handleAgentCard(mod, route.agent.name, route.agent.agentPath, deps.baseUrl);
|
|
733
744
|
}
|
|
734
745
|
if (route.kind === "approvals") {
|
|
735
|
-
const
|
|
746
|
+
const admission = await admitAux(deps, route.agent, {
|
|
736
747
|
agent: route.agent.name,
|
|
737
748
|
endpoint: "approvals"
|
|
738
749
|
});
|
|
739
|
-
|
|
750
|
+
if (admission.refusal !== null) return admission.refusal;
|
|
751
|
+
return handleListApprovals(getApprovalRegistry(), admission.subject);
|
|
740
752
|
}
|
|
741
753
|
if (route.kind === "run-stream") {
|
|
742
754
|
return handleAgentRunReconnect(route.runId, request, getRunEventCache());
|
|
@@ -747,14 +759,14 @@ async function serveMatchedAuxRoute(route, request, deps) {
|
|
|
747
759
|
async function serveThreadRoute(route, request, deps) {
|
|
748
760
|
const { agent, sessionId } = route;
|
|
749
761
|
if (route.kind === "thread-stream") {
|
|
750
|
-
const refusal2 = await admitAux(deps, agent, {
|
|
762
|
+
const { refusal: refusal2 } = await admitAux(deps, agent, {
|
|
751
763
|
agent: agent.name,
|
|
752
764
|
endpoint: "thread-stream",
|
|
753
765
|
sessionId
|
|
754
766
|
});
|
|
755
767
|
return refusal2 ?? handleThreadStream(sessionId, request);
|
|
756
768
|
}
|
|
757
|
-
const refusal = await admitAux(deps, agent, {
|
|
769
|
+
const { refusal } = await admitAux(deps, agent, {
|
|
758
770
|
agent: agent.name,
|
|
759
771
|
endpoint: "thread-message",
|
|
760
772
|
sessionId
|
|
@@ -867,4 +879,4 @@ export {
|
|
|
867
879
|
applyNonceToInlineScripts,
|
|
868
880
|
setupSsrDevMiddleware
|
|
869
881
|
};
|
|
870
|
-
//# sourceMappingURL=chunk-
|
|
882
|
+
//# sourceMappingURL=chunk-7THO4PRL.js.map
|