theokit 0.1.0-alpha.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/build-NSKFOAFX.js +49 -0
- package/dist/build-NSKFOAFX.js.map +1 -0
- package/dist/chunk-ASGEGAWL.js +480 -0
- package/dist/chunk-ASGEGAWL.js.map +1 -0
- package/dist/chunk-ATSTRYYT.js +894 -0
- package/dist/chunk-ATSTRYYT.js.map +1 -0
- package/dist/chunk-KPU44T6G.js +71 -0
- package/dist/chunk-KPU44T6G.js.map +1 -0
- package/dist/chunk-MMZZBPMX.js +335 -0
- package/dist/chunk-MMZZBPMX.js.map +1 -0
- package/dist/chunk-N5YH2UDG.js +85 -0
- package/dist/chunk-N5YH2UDG.js.map +1 -0
- package/dist/chunk-SAVVU5LG.js +66 -0
- package/dist/chunk-SAVVU5LG.js.map +1 -0
- package/dist/chunk-TXMUCDJT.js +43 -0
- package/dist/chunk-TXMUCDJT.js.map +1 -0
- package/dist/chunk-U3OJFWK3.js +162 -0
- package/dist/chunk-U3OJFWK3.js.map +1 -0
- package/dist/cli/index.js +79 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/index.d.ts +37 -0
- package/dist/client/index.js +57 -0
- package/dist/client/index.js.map +1 -0
- package/dist/cloudflare-CVGN7FOU.js +88 -0
- package/dist/cloudflare-CVGN7FOU.js.map +1 -0
- package/dist/dev-7UJK3M2O.js +47 -0
- package/dist/dev-7UJK3M2O.js.map +1 -0
- package/dist/docker-M253W54T.js +101 -0
- package/dist/docker-M253W54T.js.map +1 -0
- package/dist/generate-AA7ZE42F.js +116 -0
- package/dist/generate-AA7ZE42F.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +171 -0
- package/dist/index.js.map +1 -0
- package/dist/rate-limit-C6hHXIj1.d.ts +13 -0
- package/dist/routes-YP357VAC.js +60 -0
- package/dist/routes-YP357VAC.js.map +1 -0
- package/dist/server/index.d.ts +94 -0
- package/dist/server/index.js +148 -0
- package/dist/server/index.js.map +1 -0
- package/dist/start-BIS3RCFQ.js +243 -0
- package/dist/start-BIS3RCFQ.js.map +1 -0
- package/dist/vercel-747SR2FB.js +80 -0
- package/dist/vercel-747SR2FB.js.map +1 -0
- package/dist/vite-plugin/index.d.ts +12 -0
- package/dist/vite-plugin/index.js +8 -0
- package/dist/vite-plugin/index.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
nodeAdapter
|
|
4
|
+
} from "./chunk-TXMUCDJT.js";
|
|
5
|
+
import "./chunk-ASGEGAWL.js";
|
|
6
|
+
import "./chunk-MMZZBPMX.js";
|
|
7
|
+
import "./chunk-U3OJFWK3.js";
|
|
8
|
+
|
|
9
|
+
// src/adapters/vercel.ts
|
|
10
|
+
import { existsSync, mkdirSync, writeFileSync, cpSync } from "fs";
|
|
11
|
+
import { resolve } from "path";
|
|
12
|
+
var vercelAdapter = {
|
|
13
|
+
name: "vercel",
|
|
14
|
+
async build(config, cwd) {
|
|
15
|
+
await nodeAdapter.build(config, cwd);
|
|
16
|
+
const clientDir = resolve(cwd, ".theo/client");
|
|
17
|
+
const outputDir = resolve(cwd, ".vercel/output");
|
|
18
|
+
mkdirSync(resolve(outputDir, "static"), { recursive: true });
|
|
19
|
+
mkdirSync(resolve(outputDir, "functions/api.func"), { recursive: true });
|
|
20
|
+
if (existsSync(clientDir)) {
|
|
21
|
+
cpSync(clientDir, resolve(outputDir, "static"), { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
const functionEntry = [
|
|
24
|
+
`// Generated by Theo \u2014 Vercel Adapter`,
|
|
25
|
+
`// Environment variables are resolved at RUNTIME, not build time (EC-1)`,
|
|
26
|
+
`export default async function handler(req, res) {`,
|
|
27
|
+
` const { createServer } = await import('node:http');`,
|
|
28
|
+
` const { resolve } = await import('node:path');`,
|
|
29
|
+
` const { existsSync } = await import('node:fs');`,
|
|
30
|
+
` const serverDir = resolve(process.cwd(), 'server');`,
|
|
31
|
+
` // Lazy-load Theo server modules`,
|
|
32
|
+
` const { scanServerRoutes } = await import('./theo-server/scan.js');`,
|
|
33
|
+
` const { matchRoute } = await import('./theo-server/match.js');`,
|
|
34
|
+
` const { executeRoute, sendError } = await import('./theo-server/execute.js');`,
|
|
35
|
+
` const { createProductionLoader } = await import('./theo-server/module-loader.js');`,
|
|
36
|
+
` const loadModule = createProductionLoader();`,
|
|
37
|
+
` const url = req.url ?? '/';`,
|
|
38
|
+
` if (url.startsWith('/api/')) {`,
|
|
39
|
+
` const routes = scanServerRoutes(serverDir);`,
|
|
40
|
+
` const match = matchRoute(url, routes);`,
|
|
41
|
+
` if (!match) { sendError(res, 'NOT_FOUND', 'API route not found', 404); return; }`,
|
|
42
|
+
` const method = (req.method ?? 'GET').toUpperCase();`,
|
|
43
|
+
` await executeRoute(match.route, method, match.params, req, res, loadModule, serverDir);`,
|
|
44
|
+
` return;`,
|
|
45
|
+
` }`,
|
|
46
|
+
` // SPA fallback \u2014 Vercel serves static index.html via routing`,
|
|
47
|
+
` res.writeHead(200, { 'Content-Type': 'text/html' });`,
|
|
48
|
+
` res.end('<html><body>SPA fallback</body></html>');`,
|
|
49
|
+
`}`
|
|
50
|
+
].join("\n");
|
|
51
|
+
writeFileSync(resolve(outputDir, "functions/api.func/index.mjs"), functionEntry);
|
|
52
|
+
const vcConfig = {
|
|
53
|
+
runtime: "nodejs22.x",
|
|
54
|
+
handler: "index.mjs",
|
|
55
|
+
launcherType: "Nodejs",
|
|
56
|
+
shouldAddHelpers: true
|
|
57
|
+
};
|
|
58
|
+
writeFileSync(
|
|
59
|
+
resolve(outputDir, "functions/api.func/.vc-config.json"),
|
|
60
|
+
JSON.stringify(vcConfig, null, 2)
|
|
61
|
+
);
|
|
62
|
+
const routingConfig = {
|
|
63
|
+
version: 3,
|
|
64
|
+
routes: [
|
|
65
|
+
{ src: "/api/(.*)", dest: "/api" },
|
|
66
|
+
{ handle: "filesystem" },
|
|
67
|
+
{ src: "/(.*)", dest: "/index.html" }
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
writeFileSync(
|
|
71
|
+
resolve(outputDir, "config.json"),
|
|
72
|
+
JSON.stringify(routingConfig, null, 2)
|
|
73
|
+
);
|
|
74
|
+
console.log("\n \u2713 Vercel output \u2192 .vercel/output/\n");
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
vercelAdapter
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=vercel-747SR2FB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/vercel.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync, cpSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport type { DeployAdapter } from './types.js'\nimport type { TheoConfig } from '../config/schema.js'\nimport { nodeAdapter } from './node.js'\n\nexport const vercelAdapter: DeployAdapter = {\n name: 'vercel',\n\n async build(config: TheoConfig, cwd: string): Promise<void> {\n // 1. Run the standard Node build first\n await nodeAdapter.build(config, cwd)\n\n const clientDir = resolve(cwd, '.theo/client')\n const outputDir = resolve(cwd, '.vercel/output')\n\n // 2. Create .vercel/output structure\n mkdirSync(resolve(outputDir, 'static'), { recursive: true })\n mkdirSync(resolve(outputDir, 'functions/api.func'), { recursive: true })\n\n // 3. Copy static assets\n if (existsSync(clientDir)) {\n cpSync(clientDir, resolve(outputDir, 'static'), { recursive: true })\n }\n\n // 4. Generate serverless function entry\n // This wraps Theo's production server handler for Vercel's serverless runtime\n const functionEntry = [\n `// Generated by Theo — Vercel Adapter`,\n `// Environment variables are resolved at RUNTIME, not build time (EC-1)`,\n `export default async function handler(req, res) {`,\n ` const { createServer } = await import('node:http');`,\n ` const { resolve } = await import('node:path');`,\n ` const { existsSync } = await import('node:fs');`,\n ` const serverDir = resolve(process.cwd(), 'server');`,\n ` // Lazy-load Theo server modules`,\n ` const { scanServerRoutes } = await import('./theo-server/scan.js');`,\n ` const { matchRoute } = await import('./theo-server/match.js');`,\n ` const { executeRoute, sendError } = await import('./theo-server/execute.js');`,\n ` const { createProductionLoader } = await import('./theo-server/module-loader.js');`,\n ` const loadModule = createProductionLoader();`,\n ` const url = req.url ?? '/';`,\n ` if (url.startsWith('/api/')) {`,\n ` const routes = scanServerRoutes(serverDir);`,\n ` const match = matchRoute(url, routes);`,\n ` if (!match) { sendError(res, 'NOT_FOUND', 'API route not found', 404); return; }`,\n ` const method = (req.method ?? 'GET').toUpperCase();`,\n ` await executeRoute(match.route, method, match.params, req, res, loadModule, serverDir);`,\n ` return;`,\n ` }`,\n ` // SPA fallback — Vercel serves static index.html via routing`,\n ` res.writeHead(200, { 'Content-Type': 'text/html' });`,\n ` res.end('<html><body>SPA fallback</body></html>');`,\n `}`,\n ].join('\\n')\n\n writeFileSync(resolve(outputDir, 'functions/api.func/index.mjs'), functionEntry)\n\n // 5. Generate .vc-config.json\n const vcConfig = {\n runtime: 'nodejs22.x',\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n shouldAddHelpers: true,\n }\n writeFileSync(\n resolve(outputDir, 'functions/api.func/.vc-config.json'),\n JSON.stringify(vcConfig, null, 2),\n )\n\n // 6. Generate config.json (routing)\n const routingConfig = {\n version: 3,\n routes: [\n { src: '/api/(.*)', dest: '/api' },\n { handle: 'filesystem' },\n { src: '/(.*)', dest: '/index.html' },\n ],\n }\n writeFileSync(\n resolve(outputDir, 'config.json'),\n JSON.stringify(routingConfig, null, 2),\n )\n\n console.log('\\n ✓ Vercel output → .vercel/output/\\n')\n },\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,YAAY,WAAW,eAAe,cAAc;AAC7D,SAAS,eAAqB;AAKvB,IAAM,gBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,MAAM,MAAM,QAAoB,KAA4B;AAE1D,UAAM,YAAY,MAAM,QAAQ,GAAG;AAEnC,UAAM,YAAY,QAAQ,KAAK,cAAc;AAC7C,UA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';
|
|
2
|
+
import { R as RateLimitConfig } from '../rate-limit-C6hHXIj1.js';
|
|
3
|
+
import 'node:http';
|
|
4
|
+
|
|
5
|
+
interface TheoPluginOptions {
|
|
6
|
+
root?: string;
|
|
7
|
+
rateLimit?: RateLimitConfig;
|
|
8
|
+
ssr?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function theoPlugin(rootOrOptions?: string | TheoPluginOptions): Plugin;
|
|
11
|
+
|
|
12
|
+
export { type TheoPluginOptions, theoPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "theokit",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsup"
|
|
7
|
+
},
|
|
8
|
+
"bin": {
|
|
9
|
+
"theokit": "./dist/cli/index.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./server": {
|
|
17
|
+
"types": "./dist/server/index.d.ts",
|
|
18
|
+
"import": "./dist/server/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./vite-plugin": {
|
|
21
|
+
"types": "./dist/vite-plugin/index.d.ts",
|
|
22
|
+
"import": "./dist/vite-plugin/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./client": {
|
|
25
|
+
"types": "./dist/client/index.d.ts",
|
|
26
|
+
"import": "./dist/client/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"cac": "^6.7.14",
|
|
34
|
+
"vite": "^6.0.0",
|
|
35
|
+
"@vitejs/plugin-react": "^4.4.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"zod": "^3.24.0",
|
|
39
|
+
"react": "^19.0.0",
|
|
40
|
+
"react-dom": "^19.0.0",
|
|
41
|
+
"react-router": "^7.0.0",
|
|
42
|
+
"ws": "^8.0.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"ws": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|