theokit 0.2.4 → 0.4.0-beta.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/{app-typed-client-US2ZXBEC.js → app-typed-client-62FYBLVJ.js} +3 -3
- package/dist/{app-typed-client-6GC6VWXS.js → app-typed-client-ITIYTBXO.js} +3 -3
- package/dist/{build-MREW6MVS.js → build-HIGHJQQV.js} +8 -8
- package/dist/{chunk-YWWHK7R6.js → chunk-2VQKDRVF.js} +2 -2
- package/dist/{chunk-2BQYEBCK.js → chunk-B6RP57M3.js} +84 -2
- package/dist/chunk-B6RP57M3.js.map +1 -0
- package/dist/{chunk-5OKZY2VL.js → chunk-BIGBFZSU.js} +10 -5
- package/dist/chunk-BIGBFZSU.js.map +1 -0
- package/dist/{chunk-X2OLD264.js → chunk-JAAHOGKI.js} +10 -5
- package/dist/chunk-JAAHOGKI.js.map +1 -0
- package/dist/{chunk-SNDZQ64K.js → chunk-OXIQI2XZ.js} +84 -2
- package/dist/chunk-OXIQI2XZ.js.map +1 -0
- package/dist/{chunk-BE2LKDI7.js → chunk-TRH2L3FI.js} +2 -2
- package/dist/cli/index.js +29 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/{dev-6P2DM33Q.js → dev-266MVCVA.js} +6 -6
- package/dist/{dev-emit-PRSRPDHA.js → dev-emit-NO6OZJOQ.js} +3 -3
- package/dist/{dev-emit-MLDFOLUU.js → dev-emit-RBSFZZNO.js} +3 -3
- package/dist/{dist-E6BL4ZVY.js → dist-5V77Z223.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{openapi-SOKZTFE3.js → openapi-FNVSWZOL.js} +3 -3
- package/dist/{registry-5QFTLOL2.js → registry-4MZ26TZD.js} +1 -1
- package/dist/router-RGZFX75G.js +274 -0
- package/dist/router-RGZFX75G.js.map +1 -0
- package/dist/{routes-XVRAUH6H.js → routes-H4SPLFHJ.js} +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server-routes-hmr-GZJGPWMS.js +44 -0
- package/dist/server-routes-hmr-GZJGPWMS.js.map +1 -0
- package/dist/server-routes-hmr-PBHSKCQJ.js +42 -0
- package/dist/server-routes-hmr-PBHSKCQJ.js.map +1 -0
- package/dist/{start-R7XSQL5L.js → start-HX3QUSOS.js} +5 -5
- package/dist/vite-plugin/index.js +2 -2
- package/dist/{vite-plugin-6MPHTKIW.js → vite-plugin-IK3NOWXS.js} +3 -3
- package/package.json +2 -2
- package/dist/chunk-2BQYEBCK.js.map +0 -1
- package/dist/chunk-5OKZY2VL.js.map +0 -1
- package/dist/chunk-SNDZQ64K.js.map +0 -1
- package/dist/chunk-X2OLD264.js.map +0 -1
- /package/dist/{app-typed-client-6GC6VWXS.js.map → app-typed-client-62FYBLVJ.js.map} +0 -0
- /package/dist/{app-typed-client-US2ZXBEC.js.map → app-typed-client-ITIYTBXO.js.map} +0 -0
- /package/dist/{build-MREW6MVS.js.map → build-HIGHJQQV.js.map} +0 -0
- /package/dist/{chunk-YWWHK7R6.js.map → chunk-2VQKDRVF.js.map} +0 -0
- /package/dist/{chunk-BE2LKDI7.js.map → chunk-TRH2L3FI.js.map} +0 -0
- /package/dist/{dev-6P2DM33Q.js.map → dev-266MVCVA.js.map} +0 -0
- /package/dist/{dev-emit-PRSRPDHA.js.map → dev-emit-NO6OZJOQ.js.map} +0 -0
- /package/dist/{dev-emit-MLDFOLUU.js.map → dev-emit-RBSFZZNO.js.map} +0 -0
- /package/dist/{dist-E6BL4ZVY.js.map → dist-5V77Z223.js.map} +0 -0
- /package/dist/{openapi-SOKZTFE3.js.map → openapi-FNVSWZOL.js.map} +0 -0
- /package/dist/{registry-5QFTLOL2.js.map → registry-4MZ26TZD.js.map} +0 -0
- /package/dist/{routes-XVRAUH6H.js.map → routes-H4SPLFHJ.js.map} +0 -0
- /package/dist/{start-R7XSQL5L.js.map → start-HX3QUSOS.js.map} +0 -0
- /package/dist/{vite-plugin-6MPHTKIW.js.map → vite-plugin-IK3NOWXS.js.map} +0 -0
package/dist/server/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
generateManifest,
|
|
3
3
|
loadManifest,
|
|
4
4
|
writeManifest
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-2VQKDRVF.js";
|
|
6
6
|
import {
|
|
7
7
|
_resetKeyCacheForTests,
|
|
8
8
|
assertProductionSecret,
|
|
@@ -137,7 +137,7 @@ import {
|
|
|
137
137
|
matchRoute,
|
|
138
138
|
scanServerRoutes,
|
|
139
139
|
scanWebSocketRoutes
|
|
140
|
-
} from "../chunk-
|
|
140
|
+
} from "../chunk-B6RP57M3.js";
|
|
141
141
|
import {
|
|
142
142
|
ActionScanError,
|
|
143
143
|
scanServerActions,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "tsx/esm";
|
|
3
|
+
import "./chunk-KT3MWNZG.js";
|
|
4
|
+
|
|
5
|
+
// src/vite-plugin/server-routes-hmr.ts
|
|
6
|
+
import { sep } from "path";
|
|
7
|
+
function serverRoutesHmrPlugin(opts) {
|
|
8
|
+
const routesDir = `${opts.serverDir}${sep}routes${sep}`;
|
|
9
|
+
const routesDirPosix = routesDir.replace(/\\/g, "/");
|
|
10
|
+
const debounceMs = opts.debounceMs ?? 50;
|
|
11
|
+
const isUnderRoutes = (filePath) => {
|
|
12
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
13
|
+
return normalized.startsWith(routesDirPosix);
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
name: "theokit:server-routes-hmr",
|
|
17
|
+
configureServer(server) {
|
|
18
|
+
const srv = server;
|
|
19
|
+
let timer = null;
|
|
20
|
+
const fireInvalidation = () => {
|
|
21
|
+
timer = null;
|
|
22
|
+
for (const mod of srv.moduleGraph.idToModuleMap.values()) {
|
|
23
|
+
const normalizedId = mod.id.replace(/\\/g, "/");
|
|
24
|
+
if (normalizedId.startsWith(routesDirPosix)) {
|
|
25
|
+
srv.moduleGraph.invalidateModule(mod);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
srv.ws.send({ type: "full-reload" });
|
|
29
|
+
};
|
|
30
|
+
const scheduleInvalidation = (filePath) => {
|
|
31
|
+
if (!isUnderRoutes(filePath)) return;
|
|
32
|
+
if (timer !== null) clearTimeout(timer);
|
|
33
|
+
timer = setTimeout(fireInvalidation, debounceMs);
|
|
34
|
+
};
|
|
35
|
+
srv.watcher.on("add", scheduleInvalidation);
|
|
36
|
+
srv.watcher.on("change", scheduleInvalidation);
|
|
37
|
+
srv.watcher.on("unlink", scheduleInvalidation);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
serverRoutesHmrPlugin
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=server-routes-hmr-GZJGPWMS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vite-plugin/server-routes-hmr.ts"],"sourcesContent":["/**\n * G6 T1.2 — Vite plugin: watch `server/routes/**` and invalidate SSR module\n * cache on add/change/unlink with a 50 ms debounce window.\n *\n * Plan: .claude/knowledge-base/plans/g6-router-convention-plan.md v1.1\n *\n * Pattern reference: SvelteKit `exports/vite/dev/index.js:335-398`.\n *\n * Why this exists: in dev, `scanServerRoutes` runs per-request (fresh disk\n * read), so adding/removing routes already takes effect on next request.\n * But the SSR dynamic-import cache holds stale code for EDITED routes — Vite\n * needs an explicit `invalidateModule` call to bust it. We also send a\n * `full-reload` so any browser code that imported a route module\n * (rare, but the typed client G1 does this for ts-only type resolution)\n * picks up the change.\n *\n * EC-6: 50 ms debounce collapses bursty file events (e.g., codemod-driven\n * 21-rename storm in T2.1) into a single invalidation cycle — without it,\n * 21 invalidations + 21 full-reloads in 5 s would hang the dev server.\n */\nimport { sep } from 'node:path'\n\nimport type { Plugin, ViteDevServer } from 'vite'\n\nexport interface ServerRoutesHmrPluginOptions {\n /** Absolute path of the consumer's `server/` directory. */\n serverDir: string\n /** Debounce window in milliseconds (default 50 ms per EC-6). */\n debounceMs?: number\n}\n\ninterface ModuleGraphLike {\n getModuleById: (id: string) => unknown\n invalidateModule: (mod: unknown) => void\n idToModuleMap: Map<string, { id: string }>\n}\n\ninterface ViteDevServerLike {\n watcher: { on: (event: string, listener: (path: string) => void) => void }\n moduleGraph: ModuleGraphLike\n ws: { send: (payload: { type: string }) => void }\n}\n\nexport function serverRoutesHmrPlugin(opts: ServerRoutesHmrPluginOptions): Plugin {\n const routesDir = `${opts.serverDir}${sep}routes${sep}`\n // Cross-platform: on Windows the watcher MAY emit forward slashes even on NTFS.\n const routesDirPosix = routesDir.replace(/\\\\/g, '/')\n const debounceMs = opts.debounceMs ?? 50\n\n const isUnderRoutes = (filePath: string): boolean => {\n const normalized = filePath.replace(/\\\\/g, '/')\n return normalized.startsWith(routesDirPosix)\n }\n\n return {\n name: 'theokit:server-routes-hmr',\n\n configureServer(server: ViteDevServer) {\n const srv = server as unknown as ViteDevServerLike\n let timer: ReturnType<typeof setTimeout> | null = null\n\n const fireInvalidation = (): void => {\n timer = null\n for (const mod of srv.moduleGraph.idToModuleMap.values()) {\n const normalizedId = mod.id.replace(/\\\\/g, '/')\n if (normalizedId.startsWith(routesDirPosix)) {\n srv.moduleGraph.invalidateModule(mod)\n }\n }\n srv.ws.send({ type: 'full-reload' })\n }\n\n const scheduleInvalidation = (filePath: string): void => {\n if (!isUnderRoutes(filePath)) return\n if (timer !== null) clearTimeout(timer)\n timer = setTimeout(fireInvalidation, debounceMs)\n }\n\n srv.watcher.on('add', scheduleInvalidation)\n srv.watcher.on('change', scheduleInvalidation)\n srv.watcher.on('unlink', scheduleInvalidation)\n },\n }\n}\n"],"mappings":";;;;;AAoBA,SAAS,WAAW;AAuBb,SAAS,sBAAsB,MAA4C;AAChF,QAAM,YAAY,GAAG,KAAK,SAAS,GAAG,GAAG,SAAS,GAAG;AAErD,QAAM,iBAAiB,UAAU,QAAQ,OAAO,GAAG;AACnD,QAAM,aAAa,KAAK,cAAc;AAEtC,QAAM,gBAAgB,CAAC,aAA8B;AACnD,UAAM,aAAa,SAAS,QAAQ,OAAO,GAAG;AAC9C,WAAO,WAAW,WAAW,cAAc;AAAA,EAC7C;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,gBAAgB,QAAuB;AACrC,YAAM,MAAM;AACZ,UAAI,QAA8C;AAElD,YAAM,mBAAmB,MAAY;AACnC,gBAAQ;AACR,mBAAW,OAAO,IAAI,YAAY,cAAc,OAAO,GAAG;AACxD,gBAAM,eAAe,IAAI,GAAG,QAAQ,OAAO,GAAG;AAC9C,cAAI,aAAa,WAAW,cAAc,GAAG;AAC3C,gBAAI,YAAY,iBAAiB,GAAG;AAAA,UACtC;AAAA,QACF;AACA,YAAI,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;AAAA,MACrC;AAEA,YAAM,uBAAuB,CAAC,aAA2B;AACvD,YAAI,CAAC,cAAc,QAAQ,EAAG;AAC9B,YAAI,UAAU,KAAM,cAAa,KAAK;AACtC,gBAAQ,WAAW,kBAAkB,UAAU;AAAA,MACjD;AAEA,UAAI,QAAQ,GAAG,OAAO,oBAAoB;AAC1C,UAAI,QAAQ,GAAG,UAAU,oBAAoB;AAC7C,UAAI,QAAQ,GAAG,UAAU,oBAAoB;AAAA,IAC/C;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "./chunk-DGUM43GV.js";
|
|
2
|
+
|
|
3
|
+
// src/vite-plugin/server-routes-hmr.ts
|
|
4
|
+
import { sep } from "path";
|
|
5
|
+
function serverRoutesHmrPlugin(opts) {
|
|
6
|
+
const routesDir = `${opts.serverDir}${sep}routes${sep}`;
|
|
7
|
+
const routesDirPosix = routesDir.replace(/\\/g, "/");
|
|
8
|
+
const debounceMs = opts.debounceMs ?? 50;
|
|
9
|
+
const isUnderRoutes = (filePath) => {
|
|
10
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
11
|
+
return normalized.startsWith(routesDirPosix);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
name: "theokit:server-routes-hmr",
|
|
15
|
+
configureServer(server) {
|
|
16
|
+
const srv = server;
|
|
17
|
+
let timer = null;
|
|
18
|
+
const fireInvalidation = () => {
|
|
19
|
+
timer = null;
|
|
20
|
+
for (const mod of srv.moduleGraph.idToModuleMap.values()) {
|
|
21
|
+
const normalizedId = mod.id.replace(/\\/g, "/");
|
|
22
|
+
if (normalizedId.startsWith(routesDirPosix)) {
|
|
23
|
+
srv.moduleGraph.invalidateModule(mod);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
srv.ws.send({ type: "full-reload" });
|
|
27
|
+
};
|
|
28
|
+
const scheduleInvalidation = (filePath) => {
|
|
29
|
+
if (!isUnderRoutes(filePath)) return;
|
|
30
|
+
if (timer !== null) clearTimeout(timer);
|
|
31
|
+
timer = setTimeout(fireInvalidation, debounceMs);
|
|
32
|
+
};
|
|
33
|
+
srv.watcher.on("add", scheduleInvalidation);
|
|
34
|
+
srv.watcher.on("change", scheduleInvalidation);
|
|
35
|
+
srv.watcher.on("unlink", scheduleInvalidation);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
serverRoutesHmrPlugin
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=server-routes-hmr-PBHSKCQJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vite-plugin/server-routes-hmr.ts"],"sourcesContent":["/**\n * G6 T1.2 — Vite plugin: watch `server/routes/**` and invalidate SSR module\n * cache on add/change/unlink with a 50 ms debounce window.\n *\n * Plan: .claude/knowledge-base/plans/g6-router-convention-plan.md v1.1\n *\n * Pattern reference: SvelteKit `exports/vite/dev/index.js:335-398`.\n *\n * Why this exists: in dev, `scanServerRoutes` runs per-request (fresh disk\n * read), so adding/removing routes already takes effect on next request.\n * But the SSR dynamic-import cache holds stale code for EDITED routes — Vite\n * needs an explicit `invalidateModule` call to bust it. We also send a\n * `full-reload` so any browser code that imported a route module\n * (rare, but the typed client G1 does this for ts-only type resolution)\n * picks up the change.\n *\n * EC-6: 50 ms debounce collapses bursty file events (e.g., codemod-driven\n * 21-rename storm in T2.1) into a single invalidation cycle — without it,\n * 21 invalidations + 21 full-reloads in 5 s would hang the dev server.\n */\nimport { sep } from 'node:path'\n\nimport type { Plugin, ViteDevServer } from 'vite'\n\nexport interface ServerRoutesHmrPluginOptions {\n /** Absolute path of the consumer's `server/` directory. */\n serverDir: string\n /** Debounce window in milliseconds (default 50 ms per EC-6). */\n debounceMs?: number\n}\n\ninterface ModuleGraphLike {\n getModuleById: (id: string) => unknown\n invalidateModule: (mod: unknown) => void\n idToModuleMap: Map<string, { id: string }>\n}\n\ninterface ViteDevServerLike {\n watcher: { on: (event: string, listener: (path: string) => void) => void }\n moduleGraph: ModuleGraphLike\n ws: { send: (payload: { type: string }) => void }\n}\n\nexport function serverRoutesHmrPlugin(opts: ServerRoutesHmrPluginOptions): Plugin {\n const routesDir = `${opts.serverDir}${sep}routes${sep}`\n // Cross-platform: on Windows the watcher MAY emit forward slashes even on NTFS.\n const routesDirPosix = routesDir.replace(/\\\\/g, '/')\n const debounceMs = opts.debounceMs ?? 50\n\n const isUnderRoutes = (filePath: string): boolean => {\n const normalized = filePath.replace(/\\\\/g, '/')\n return normalized.startsWith(routesDirPosix)\n }\n\n return {\n name: 'theokit:server-routes-hmr',\n\n configureServer(server: ViteDevServer) {\n const srv = server as unknown as ViteDevServerLike\n let timer: ReturnType<typeof setTimeout> | null = null\n\n const fireInvalidation = (): void => {\n timer = null\n for (const mod of srv.moduleGraph.idToModuleMap.values()) {\n const normalizedId = mod.id.replace(/\\\\/g, '/')\n if (normalizedId.startsWith(routesDirPosix)) {\n srv.moduleGraph.invalidateModule(mod)\n }\n }\n srv.ws.send({ type: 'full-reload' })\n }\n\n const scheduleInvalidation = (filePath: string): void => {\n if (!isUnderRoutes(filePath)) return\n if (timer !== null) clearTimeout(timer)\n timer = setTimeout(fireInvalidation, debounceMs)\n }\n\n srv.watcher.on('add', scheduleInvalidation)\n srv.watcher.on('change', scheduleInvalidation)\n srv.watcher.on('unlink', scheduleInvalidation)\n },\n }\n}\n"],"mappings":";;;AAoBA,SAAS,WAAW;AAuBb,SAAS,sBAAsB,MAA4C;AAChF,QAAM,YAAY,GAAG,KAAK,SAAS,GAAG,GAAG,SAAS,GAAG;AAErD,QAAM,iBAAiB,UAAU,QAAQ,OAAO,GAAG;AACnD,QAAM,aAAa,KAAK,cAAc;AAEtC,QAAM,gBAAgB,CAAC,aAA8B;AACnD,UAAM,aAAa,SAAS,QAAQ,OAAO,GAAG;AAC9C,WAAO,WAAW,WAAW,cAAc;AAAA,EAC7C;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,gBAAgB,QAAuB;AACrC,YAAM,MAAM;AACZ,UAAI,QAA8C;AAElD,YAAM,mBAAmB,MAAY;AACnC,gBAAQ;AACR,mBAAW,OAAO,IAAI,YAAY,cAAc,OAAO,GAAG;AACxD,gBAAM,eAAe,IAAI,GAAG,QAAQ,OAAO,GAAG;AAC9C,cAAI,aAAa,WAAW,cAAc,GAAG;AAC3C,gBAAI,YAAY,iBAAiB,GAAG;AAAA,UACtC;AAAA,QACF;AACA,YAAI,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;AAAA,MACrC;AAEA,YAAM,uBAAuB,CAAC,aAA2B;AACvD,YAAI,CAAC,cAAc,QAAQ,EAAG;AAC9B,YAAI,UAAU,KAAM,cAAa,KAAK;AACtC,gBAAQ,WAAW,kBAAkB,UAAU;AAAA,MACjD;AAEA,UAAI,QAAQ,GAAG,OAAO,oBAAoB;AAC1C,UAAI,QAAQ,GAAG,UAAU,oBAAoB;AAC7C,UAAI,QAAQ,GAAG,UAAU,oBAAoB;AAAA,IAC/C;AAAA,EACF;AACF;","names":[]}
|
|
@@ -25,12 +25,12 @@ import "./chunk-X4JAX2U3.js";
|
|
|
25
25
|
import "./chunk-WZ7CPVQB.js";
|
|
26
26
|
import {
|
|
27
27
|
loadManifest
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-TRH2L3FI.js";
|
|
29
29
|
import {
|
|
30
30
|
matchRoute,
|
|
31
31
|
scanServerRoutes,
|
|
32
32
|
scanWebSocketRoutes
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-OXIQI2XZ.js";
|
|
34
34
|
import {
|
|
35
35
|
scanServerActions
|
|
36
36
|
} from "./chunk-5OFPQK6N.js";
|
|
@@ -47,7 +47,7 @@ import { resolve } from "path";
|
|
|
47
47
|
async function configureAgentRegistryFromConfig(registryConfig) {
|
|
48
48
|
if (registryConfig === void 0) return;
|
|
49
49
|
try {
|
|
50
|
-
const sdk = await import("./dist-
|
|
50
|
+
const sdk = await import("./dist-5V77Z223.js").catch(() => null);
|
|
51
51
|
const sdkConfigure = sdk?.Agent?.registry?.configure;
|
|
52
52
|
if (sdkConfigure === void 0) return;
|
|
53
53
|
const { configureAgentRegistryOnce } = await import("./configure-agent-registry-6YGTJYBC.js");
|
|
@@ -101,7 +101,7 @@ function installGracefulShutdown(server) {
|
|
|
101
101
|
[theokit] ${signal} received \u2014 evicting agents`);
|
|
102
102
|
void (async () => {
|
|
103
103
|
try {
|
|
104
|
-
const sdk = await import("./dist-
|
|
104
|
+
const sdk = await import("./dist-5V77Z223.js").catch(() => null);
|
|
105
105
|
if (sdk?.Agent?.registry?.evictAll !== void 0) {
|
|
106
106
|
await sdk.Agent.registry.evictAll();
|
|
107
107
|
}
|
|
@@ -612,4 +612,4 @@ export {
|
|
|
612
612
|
resolveSsrEntry,
|
|
613
613
|
startCommand
|
|
614
614
|
};
|
|
615
|
-
//# sourceMappingURL=start-
|
|
615
|
+
//# sourceMappingURL=start-HX3QUSOS.js.map
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
defineTheoIntegration,
|
|
6
6
|
theoPlugin,
|
|
7
7
|
theoPluginAsync
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-BIGBFZSU.js";
|
|
9
9
|
import "../chunk-7BIM27LV.js";
|
|
10
10
|
import "../chunk-O4BLVPML.js";
|
|
11
11
|
import "../chunk-CZM6WWWS.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-B6RP57M3.js";
|
|
13
13
|
import "../chunk-7TOMTMHT.js";
|
|
14
14
|
import "../chunk-PB4GR7EP.js";
|
|
15
15
|
import "../chunk-GY5Q27BJ.js";
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
defineTheoIntegration,
|
|
8
8
|
theoPlugin,
|
|
9
9
|
theoPluginAsync
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-JAAHOGKI.js";
|
|
11
11
|
import "./chunk-TPCT3MXV.js";
|
|
12
12
|
import "./chunk-XP7YXRHO.js";
|
|
13
13
|
import "./chunk-X4JAX2U3.js";
|
|
14
14
|
import "./chunk-5ODOE6EF.js";
|
|
15
15
|
import "./chunk-O7335ZGH.js";
|
|
16
16
|
import "./chunk-WZ7CPVQB.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-OXIQI2XZ.js";
|
|
18
18
|
import "./chunk-5OFPQK6N.js";
|
|
19
19
|
import "./chunk-KT3MWNZG.js";
|
|
20
20
|
export {
|
|
@@ -25,4 +25,4 @@ export {
|
|
|
25
25
|
theoPlugin,
|
|
26
26
|
theoPluginAsync
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=vite-plugin-
|
|
28
|
+
//# sourceMappingURL=vite-plugin-IK3NOWXS.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "theokit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"pg": "^8.21.0",
|
|
105
105
|
"pg-mem": "^3.0.14",
|
|
106
106
|
"unstorage": "^1.10.0",
|
|
107
|
-
"@theokit/sdk": "1.
|
|
107
|
+
"@theokit/sdk": "1.6.2"
|
|
108
108
|
},
|
|
109
109
|
"scripts": {
|
|
110
110
|
"build": "tsup"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/scan/match.ts","../src/server/scan/scan.ts","../src/server/scan/detect-http-methods.ts","../src/server/scan/ws-scan.ts"],"sourcesContent":["export interface ServerRouteNode {\n filePath: string\n routePath: string\n paramNames: string[]\n pattern: RegExp\n /** HTTP methods (uppercase) the route file exports. Optional for backward\n * compatibility with manifests generated before G1. Empty array means the\n * file has no HTTP exports (util-only); undefined means \"not detected\". */\n methods?: string[]\n}\n\nexport function compilePattern(routePath: string): {\n pattern: RegExp\n paramNames: string[]\n} {\n const paramNames: string[] = []\n // Single pass: handle both catch-all (:...name) and regular (:name) params\n const regexStr = routePath.replace(/:(?:\\.\\.\\.)?([^/]+)/g, (match: string, name: string) => {\n paramNames.push(name)\n // Catch-all matches across slashes, regular matches single segment\n return match.startsWith(':...') ? '(.+)' : '([^/]+)'\n })\n // `regexStr` is derived from a developer-authored route path (build-time\n // input, not HTTP-controlled). The `security/detect-non-literal-regexp`\n // rule cannot see this constraint — disable narrowly.\n // eslint-disable-next-line security/detect-non-literal-regexp -- route pattern from build-time scan, never HTTP input\n return { pattern: new RegExp(`^${regexStr}$`), paramNames }\n}\n\nexport function matchRoute(\n url: string,\n routes: ServerRouteNode[],\n): { route: ServerRouteNode; params: Record<string, string> } | null {\n // Strip query string and trailing slash\n let path = url.split('?')[0]\n if (path.length > 1 && path.endsWith('/')) {\n path = path.slice(0, -1)\n }\n\n for (const route of routes) {\n const match = route.pattern.exec(path)\n if (match) {\n const params: Record<string, string> = {}\n route.paramNames.forEach((name, i) => {\n params[name] = match[i + 1]\n })\n return { route, params }\n }\n }\n return null\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/routes/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nimport { detectExportedHttpMethods } from './detect-http-methods.js'\nimport { compilePattern, type ServerRouteNode } from './match.js'\n\nconst ROUTE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n\nfunction fileToRoutePath(filePath: string, routesDir: string): string {\n let rel = relative(routesDir, filePath)\n // Strip extension\n const ext = extname(rel)\n rel = rel.slice(0, -ext.length)\n // Normalize separators\n rel = rel.replace(/\\\\/g, '/')\n // Strip index suffix\n if (rel.endsWith('/index')) {\n rel = rel.slice(0, -6)\n } else if (rel === 'index') {\n rel = ''\n }\n // Replace [...param] with :...param (catch-all, before regular params).\n // Replace [param] with :param. Inputs are file paths bounded by the\n // OS filename limit; the bracket capture is bounded by `]`.\n rel = rel.replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':...$1')\n // eslint-disable-next-line sonarjs/slow-regex -- bounded by `]`; input is a single filename\n rel = rel.replace(/\\[([^\\]]+)\\]/g, ':$1')\n return `/api/${rel}`\n}\n\nexport function scanServerRoutes(serverDir: string): ServerRouteNode[] {\n const routesDir = join(serverDir, 'routes')\n if (!existsSync(routesDir) || !statSync(routesDir).isDirectory()) {\n return []\n }\n\n const results: ServerRouteNode[] = []\n walkSourceFiles(routesDir, { extensions: ROUTE_EXTENSIONS }, (absPath) => {\n const routePath = fileToRoutePath(absPath, routesDir)\n const { pattern, paramNames } = compilePattern(routePath)\n const methods = detectExportedHttpMethods(absPath)\n results.push({\n filePath: absPath,\n routePath,\n paramNames,\n pattern,\n methods,\n })\n })\n\n // T1.4 / EC-2 — refuse to scan if a user route collides with the reserved\n // batch endpoint path. User must rename or disable batching.\n const conflicting = results.find((r) => r.routePath === '/api/__theo_batch__')\n if (conflicting) {\n throw new Error(\n `Server route ${conflicting.filePath} resolves to '/api/__theo_batch__' which is reserved for the batch endpoint. Rename the route or disable batching in theo.config.ts.`,\n )\n }\n\n // Sort: static first, then dynamic, then catch-all last\n const isCatchAll = (route: ServerRouteNode) => route.routePath.includes(':...')\n results.sort((a, b) => {\n const aStatic = a.paramNames.length === 0\n const bStatic = b.paramNames.length === 0\n const aCatchAll = isCatchAll(a)\n const bCatchAll = isCatchAll(b)\n\n // Static routes first\n if (aStatic && !bStatic) return -1\n if (!aStatic && bStatic) return 1\n // Catch-all routes last\n if (aCatchAll && !bCatchAll) return 1\n if (!aCatchAll && bCatchAll) return -1\n return a.routePath.localeCompare(b.routePath)\n })\n\n return results\n}\n","/**\n * Detect which HTTP-method named exports a route file declares.\n *\n * Uses the TypeScript compiler API (not regex) per G1 edge-case review EC-4:\n * regex over file content emits false positives for `// export const GET = ...`\n * in comments and `` `export const GET = ...` `` in template literals. AST\n * walking avoids both classes of bug.\n *\n * `typescript` ships as CommonJS with internal dynamic `require('fs')`.\n * When loaded via ESM `import`, the dynamic requires fail at module-bootstrap.\n * We use `createRequire(import.meta.url)` to keep the package on its native\n * CJS path. The type-only namespace import gives us the AST helpers shape.\n *\n * Returns the set of HTTP methods (uppercase) the file exports. Empty array\n * means the file has no HTTP exports (the route file is util-only).\n */\n\nimport { readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\n\nimport type * as TS from 'typescript'\n\nimport { HTTP_METHODS, type HttpMethod } from '../../core/contracts/http-methods.js'\n\nconst require_ = createRequire(import.meta.url)\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst ts = require_('typescript') as typeof TS\n\nconst HTTP_METHOD_NAMES = new Set<string>(HTTP_METHODS)\n\nfunction hasExportModifier(modifiers: readonly TS.Modifier[] | undefined): boolean {\n if (!modifiers) return false\n for (const m of modifiers) {\n if (m.kind === ts.SyntaxKind.ExportKeyword) return true\n }\n return false\n}\n\nfunction collectFromStatement(stmt: TS.Statement, found: Set<HttpMethod>): void {\n // `export const GET = ...` / `export function GET ...` / `export async function GET ...`\n if (ts.isVariableStatement(stmt) && hasExportModifier(ts.getModifiers(stmt))) {\n for (const decl of stmt.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && HTTP_METHOD_NAMES.has(decl.name.text)) {\n found.add(decl.name.text as HttpMethod)\n }\n }\n return\n }\n\n if (\n (ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) &&\n hasExportModifier(ts.getModifiers(stmt))\n ) {\n if (stmt.name && HTTP_METHOD_NAMES.has(stmt.name.text)) {\n found.add(stmt.name.text as HttpMethod)\n }\n return\n }\n\n // `export { GET }` / `export { handler as GET } from './shared'` (EC-5)\n if (ts.isExportDeclaration(stmt) && stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {\n for (const spec of stmt.exportClause.elements) {\n // spec.name is the exported (re-)name; spec.propertyName is the original (when renamed)\n if (HTTP_METHOD_NAMES.has(spec.name.text)) {\n found.add(spec.name.text as HttpMethod)\n }\n }\n }\n}\n\nexport function detectExportedHttpMethods(filePath: string, content?: string): HttpMethod[] {\n const src = content ?? readFileSync(filePath, 'utf-8')\n const sourceFile = ts.createSourceFile(\n filePath,\n src,\n ts.ScriptTarget.Latest,\n /* setParentNodes */ false,\n ts.ScriptKind.TS,\n )\n const found = new Set<HttpMethod>()\n for (const stmt of sourceFile.statements) {\n collectFromStatement(stmt, found)\n }\n return [...found].sort()\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/ws/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nconst WS_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n\nexport interface WebSocketRouteNode {\n filePath: string\n wsPath: string\n}\n\nexport function scanWebSocketRoutes(serverDir: string): WebSocketRouteNode[] {\n const wsDir = join(serverDir, 'ws')\n if (!existsSync(wsDir) || !statSync(wsDir).isDirectory()) {\n return []\n }\n\n const results: WebSocketRouteNode[] = []\n walkSourceFiles(wsDir, { extensions: WS_EXTENSIONS }, (absPath) => {\n let rel = relative(wsDir, absPath)\n rel = rel.replace(/\\\\/g, '/')\n rel = rel.slice(0, -extname(rel).length)\n if (rel.endsWith('/index')) rel = rel.slice(0, -6)\n else if (rel === 'index') rel = ''\n results.push({\n filePath: absPath,\n wsPath: `/ws/${rel}`,\n })\n })\n return results\n}\n"],"mappings":";;;;;;;;AAWO,SAAS,eAAe,WAG7B;AACA,QAAM,aAAuB,CAAC;AAE9B,QAAM,WAAW,UAAU,QAAQ,wBAAwB,CAAC,OAAe,SAAiB;AAC1F,eAAW,KAAK,IAAI;AAEpB,WAAO,MAAM,WAAW,MAAM,IAAI,SAAS;AAAA,EAC7C,CAAC;AAKD,SAAO,EAAE,SAAS,IAAI,OAAO,IAAI,QAAQ,GAAG,GAAG,WAAW;AAC5D;AAEO,SAAS,WACd,KACA,QACmE;AAEnE,MAAI,OAAO,IAAI,MAAM,GAAG,EAAE,CAAC;AAC3B,MAAI,KAAK,SAAS,KAAK,KAAK,SAAS,GAAG,GAAG;AACzC,WAAO,KAAK,MAAM,GAAG,EAAE;AAAA,EACzB;AAEA,aAAW,SAAS,QAAQ;AAC1B,UAAM,QAAQ,MAAM,QAAQ,KAAK,IAAI;AACrC,QAAI,OAAO;AACT,YAAM,SAAiC,CAAC;AACxC,YAAM,WAAW,QAAQ,CAAC,MAAM,MAAM;AACpC,eAAO,IAAI,IAAI,MAAM,IAAI,CAAC;AAAA,MAC5B,CAAC;AACD,aAAO,EAAE,OAAO,OAAO;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;;;AC9CA,SAAS,YAAY,gBAAgB;AACrC,SAAS,SAAS,MAAM,gBAAgB;;;ACYxC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAM9B,IAAM,WAAW,cAAc,YAAY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