@agent-native/core 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/adapters/convex/adapter.d.ts +24 -0
- package/dist/adapters/convex/adapter.d.ts.map +1 -0
- package/dist/adapters/convex/adapter.js +125 -0
- package/dist/adapters/convex/adapter.js.map +1 -0
- package/dist/adapters/convex/index.d.ts +4 -0
- package/dist/adapters/convex/index.d.ts.map +1 -0
- package/dist/adapters/convex/index.js +3 -0
- package/dist/adapters/convex/index.js.map +1 -0
- package/dist/adapters/drizzle/adapter.d.ts +36 -0
- package/dist/adapters/drizzle/adapter.d.ts.map +1 -0
- package/dist/adapters/drizzle/adapter.js +210 -0
- package/dist/adapters/drizzle/adapter.js.map +1 -0
- package/dist/adapters/drizzle/index.d.ts +3 -0
- package/dist/adapters/drizzle/index.d.ts.map +1 -0
- package/dist/adapters/drizzle/index.js +3 -0
- package/dist/adapters/drizzle/index.js.map +1 -0
- package/dist/adapters/drizzle/schema.d.ts +146 -0
- package/dist/adapters/drizzle/schema.d.ts.map +1 -0
- package/dist/adapters/drizzle/schema.js +20 -0
- package/dist/adapters/drizzle/schema.js.map +1 -0
- package/dist/adapters/firestore/adapter.d.ts +3 -2
- package/dist/adapters/firestore/adapter.d.ts.map +1 -1
- package/dist/adapters/firestore/adapter.js +23 -6
- package/dist/adapters/firestore/adapter.js.map +1 -1
- package/dist/adapters/supabase/adapter.d.ts +2 -1
- package/dist/adapters/supabase/adapter.d.ts.map +1 -1
- package/dist/adapters/supabase/adapter.js +4 -1
- package/dist/adapters/supabase/adapter.js.map +1 -1
- package/dist/adapters/sync/config.d.ts +22 -2
- package/dist/adapters/sync/config.d.ts.map +1 -1
- package/dist/adapters/sync/config.js +175 -16
- package/dist/adapters/sync/config.js.map +1 -1
- package/dist/adapters/sync/create-file-sync.d.ts +32 -0
- package/dist/adapters/sync/create-file-sync.d.ts.map +1 -0
- package/dist/adapters/sync/create-file-sync.js +218 -0
- package/dist/adapters/sync/create-file-sync.js.map +1 -0
- package/dist/adapters/sync/file-sync.d.ts +40 -6
- package/dist/adapters/sync/file-sync.d.ts.map +1 -1
- package/dist/adapters/sync/file-sync.js +442 -97
- package/dist/adapters/sync/file-sync.js.map +1 -1
- package/dist/adapters/sync/index.d.ts +3 -2
- package/dist/adapters/sync/index.d.ts.map +1 -1
- package/dist/adapters/sync/index.js +3 -1
- package/dist/adapters/sync/index.js.map +1 -1
- package/dist/adapters/sync/merge.js +3 -2
- package/dist/adapters/sync/merge.js.map +1 -1
- package/dist/adapters/sync/types.d.ts +36 -2
- package/dist/adapters/sync/types.d.ts.map +1 -1
- package/dist/adapters/sync/types.js +22 -1
- package/dist/adapters/sync/types.js.map +1 -1
- package/dist/agent/index.d.ts +3 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +2 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/production-agent.d.ts +16 -0
- package/dist/agent/production-agent.d.ts.map +1 -0
- package/dist/agent/production-agent.js +152 -0
- package/dist/agent/production-agent.js.map +1 -0
- package/dist/agent/types.d.ts +38 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +2 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +2 -0
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +37 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/client/PoweredByBadge.d.ts +14 -0
- package/dist/client/PoweredByBadge.d.ts.map +1 -0
- package/dist/client/PoweredByBadge.js +60 -0
- package/dist/client/PoweredByBadge.js.map +1 -0
- package/dist/client/ProductionAgentPanel.d.ts +10 -0
- package/dist/client/ProductionAgentPanel.d.ts.map +1 -0
- package/dist/client/ProductionAgentPanel.js +121 -0
- package/dist/client/ProductionAgentPanel.js.map +1 -0
- package/dist/client/Turnstile.d.ts +35 -0
- package/dist/client/Turnstile.d.ts.map +1 -0
- package/dist/client/Turnstile.js +77 -0
- package/dist/client/Turnstile.js.map +1 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/use-file-sync-status.d.ts +21 -0
- package/dist/client/use-file-sync-status.d.ts.map +1 -0
- package/dist/client/use-file-sync-status.js +65 -0
- package/dist/client/use-file-sync-status.js.map +1 -0
- package/dist/client/use-session.d.ts +16 -0
- package/dist/client/use-session.d.ts.map +1 -0
- package/dist/client/use-session.js +49 -0
- package/dist/client/use-session.js.map +1 -0
- package/dist/client/useProductionAgent.d.ts +18 -0
- package/dist/client/useProductionAgent.d.ts.map +1 -0
- package/dist/client/useProductionAgent.js +135 -0
- package/dist/client/useProductionAgent.js.map +1 -0
- package/dist/db/index.d.ts +21 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +17 -0
- package/dist/db/index.js.map +1 -0
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/router/index.d.ts +3 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +5 -0
- package/dist/router/index.js.map +1 -0
- package/dist/scripts/core-scripts.d.ts +10 -0
- package/dist/scripts/core-scripts.d.ts.map +1 -0
- package/dist/scripts/core-scripts.js +15 -0
- package/dist/scripts/core-scripts.js.map +1 -0
- package/dist/scripts/db/exec.d.ts +11 -0
- package/dist/scripts/db/exec.d.ts.map +1 -0
- package/dist/scripts/db/exec.js +86 -0
- package/dist/scripts/db/exec.js.map +1 -0
- package/dist/scripts/db/index.d.ts +2 -0
- package/dist/scripts/db/index.d.ts.map +1 -0
- package/dist/scripts/db/index.js +6 -0
- package/dist/scripts/db/index.js.map +1 -0
- package/dist/scripts/db/query.d.ts +10 -0
- package/dist/scripts/db/query.d.ts.map +1 -0
- package/dist/scripts/db/query.js +96 -0
- package/dist/scripts/db/query.js.map +1 -0
- package/dist/scripts/db/schema.d.ts +12 -0
- package/dist/scripts/db/schema.d.ts.map +1 -0
- package/dist/scripts/db/schema.js +112 -0
- package/dist/scripts/db/schema.js.map +1 -0
- package/dist/scripts/index.d.ts +4 -0
- package/dist/scripts/index.d.ts.map +1 -1
- package/dist/scripts/index.js +4 -0
- package/dist/scripts/index.js.map +1 -1
- package/dist/scripts/runner.d.ts +3 -0
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +53 -14
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/auth.d.ts +59 -0
- package/dist/server/auth.d.ts.map +1 -0
- package/dist/server/auth.js +442 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/captcha.d.ts +12 -0
- package/dist/server/captcha.d.ts.map +1 -0
- package/dist/server/captcha.js +43 -0
- package/dist/server/captcha.js.map +1 -0
- package/dist/server/create-server.d.ts +13 -10
- package/dist/server/create-server.d.ts.map +1 -1
- package/dist/server/create-server.js +41 -27
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +6 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/missing-key.d.ts +9 -5
- package/dist/server/missing-key.d.ts.map +1 -1
- package/dist/server/missing-key.js +12 -7
- package/dist/server/missing-key.js.map +1 -1
- package/dist/server/sse.d.ts +12 -7
- package/dist/server/sse.d.ts.map +1 -1
- package/dist/server/sse.js +79 -15
- package/dist/server/sse.js.map +1 -1
- package/dist/vite/client.d.ts +28 -5
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +36 -15
- package/dist/vite/client.js.map +1 -1
- package/dist/vite/dev-api-server.d.ts +10 -0
- package/dist/vite/dev-api-server.d.ts.map +1 -0
- package/dist/vite/dev-api-server.js +148 -0
- package/dist/vite/dev-api-server.js.map +1 -0
- package/dist/vite/index.d.ts +2 -3
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -3
- package/dist/vite/index.js.map +1 -1
- package/package.json +26 -17
- package/src/templates/default/AGENTS.md +148 -22
- package/src/templates/default/_gitignore +9 -5
- package/src/templates/default/client/entry.client.tsx +4 -0
- package/src/templates/default/client/entry.server.tsx +55 -0
- package/src/templates/default/client/root.tsx +82 -0
- package/src/templates/default/client/routes/_index.tsx +19 -0
- package/src/templates/default/client/routes.ts +4 -0
- package/src/templates/default/client/vite-env.d.ts +5 -0
- package/src/templates/default/package.json +5 -7
- package/src/templates/default/react-router.config.ts +6 -0
- package/src/templates/default/server/lib/watcher.ts +21 -0
- package/src/templates/default/server/plugins/auth.ts +5 -0
- package/src/templates/default/server/plugins/file-sync.ts +39 -0
- package/src/templates/default/server/routes/[...page].get.ts +12 -0
- package/src/templates/default/server/routes/api/events.get.ts +7 -0
- package/src/templates/default/server/routes/api/file-sync/status.get.ts +13 -0
- package/src/templates/default/server/routes/api/hello.get.ts +5 -0
- package/src/templates/default/tsconfig.json +9 -1
- package/src/templates/default/vite.config.ts +4 -1
- package/tsconfig.base.json +3 -1
- package/dist/adapters/neon/adapter.d.ts +0 -28
- package/dist/adapters/neon/adapter.d.ts.map +0 -1
- package/dist/adapters/neon/adapter.js +0 -135
- package/dist/adapters/neon/adapter.js.map +0 -1
- package/dist/adapters/neon/index.d.ts +0 -3
- package/dist/adapters/neon/index.d.ts.map +0 -1
- package/dist/adapters/neon/index.js +0 -3
- package/dist/adapters/neon/index.js.map +0 -1
- package/dist/server/production.d.ts +0 -18
- package/dist/server/production.d.ts.map +0 -1
- package/dist/server/production.js +0 -37
- package/dist/server/production.js.map +0 -1
- package/dist/vite/express-plugin.d.ts +0 -14
- package/dist/vite/express-plugin.d.ts.map +0 -1
- package/dist/vite/express-plugin.js +0 -53
- package/dist/vite/express-plugin.js.map +0 -1
- package/dist/vite/server.d.ts +0 -21
- package/dist/vite/server.d.ts.map +0 -1
- package/dist/vite/server.js +0 -68
- package/dist/vite/server.js.map +0 -1
- package/src/templates/default/index.html +0 -14
- package/src/templates/default/server/index.ts +0 -22
- package/src/templates/default/server/node-build.ts +0 -4
- package/src/templates/default/vite.config.server.ts +0 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function meta() {
|
|
2
|
+
return [{ title: "{{APP_TITLE}}" }];
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function HydrateFallback() {
|
|
6
|
+
return (
|
|
7
|
+
<div className="flex items-center justify-center h-screen">
|
|
8
|
+
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-foreground" />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function IndexPage() {
|
|
14
|
+
return (
|
|
15
|
+
<div className="flex items-center justify-center h-screen">
|
|
16
|
+
<h1 className="text-2xl font-bold">{{ APP_TITLE }}</h1>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -10,28 +10,26 @@
|
|
|
10
10
|
"script": "agent-native script"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-native/core": "^0.
|
|
13
|
+
"@agent-native/core": "^0.4.1",
|
|
14
14
|
"dotenv": "^17.2.1",
|
|
15
|
-
"
|
|
15
|
+
"isbot": "^5"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"@react-router/dev": "^7.13.1",
|
|
19
|
+
"@react-router/fs-routes": "^7.13.1",
|
|
18
20
|
"@tanstack/react-query": "^5.84.2",
|
|
19
|
-
"@types/cors": "^2.8.19",
|
|
20
|
-
"@types/express": "^5.0.3",
|
|
21
21
|
"@types/node": "^24.2.1",
|
|
22
22
|
"@types/react": "^18.3.23",
|
|
23
23
|
"@types/react-dom": "^18.3.7",
|
|
24
|
-
"@vitejs/plugin-react-swc": "^4.0.0",
|
|
25
24
|
"autoprefixer": "^10.4.21",
|
|
26
25
|
"class-variance-authority": "^0.7.1",
|
|
27
26
|
"clsx": "^2.1.1",
|
|
28
|
-
"cors": "^2.8.5",
|
|
29
27
|
"lucide-react": "^0.539.0",
|
|
30
28
|
"postcss": "^8.5.6",
|
|
31
29
|
"prettier": "^3.6.2",
|
|
32
30
|
"react": "^18.3.1",
|
|
33
31
|
"react-dom": "^18.3.1",
|
|
34
|
-
"react-router
|
|
32
|
+
"react-router": "^7.13.1",
|
|
35
33
|
"sonner": "^1.7.4",
|
|
36
34
|
"tailwind-merge": "^2.6.0",
|
|
37
35
|
"tailwindcss": "^3.4.17",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createFileWatcher } from "@agent-native/core";
|
|
2
|
+
import type { SSEHandlerOptions } from "@agent-native/core";
|
|
3
|
+
|
|
4
|
+
/** Shared chokidar watcher — used by SSE route and plugins */
|
|
5
|
+
export const watcher = createFileWatcher("./data");
|
|
6
|
+
|
|
7
|
+
/** Extra SSE emitters (populated by file-sync plugin at startup) */
|
|
8
|
+
export const sseExtraEmitters: NonNullable<SSEHandlerOptions["extraEmitters"]> =
|
|
9
|
+
[];
|
|
10
|
+
|
|
11
|
+
/** Sync result — set by file-sync plugin */
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
export let syncResult: any = { status: "disabled" };
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
export function setSyncResult(result: any) {
|
|
17
|
+
syncResult = result;
|
|
18
|
+
if (result.status === "ready" && result.sseEmitter) {
|
|
19
|
+
sseExtraEmitters.push(result.sseEmitter);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { defineNitroPlugin } from "@agent-native/core";
|
|
4
|
+
import { createFileSync } from "@agent-native/core/adapters/sync";
|
|
5
|
+
import { setSyncResult } from "../lib/watcher";
|
|
6
|
+
|
|
7
|
+
export default defineNitroPlugin(async () => {
|
|
8
|
+
const result = await createFileSync({ contentRoot: "./data" });
|
|
9
|
+
setSyncResult(result);
|
|
10
|
+
|
|
11
|
+
if (result.status === "error") {
|
|
12
|
+
console.warn(`[app] File sync failed: ${result.reason}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Graceful shutdown
|
|
16
|
+
process.on("SIGTERM", async () => {
|
|
17
|
+
if (result.status === "ready") await result.shutdown();
|
|
18
|
+
process.exit(0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Notify agent of sync conflicts
|
|
22
|
+
if (result.status === "ready") {
|
|
23
|
+
result.fileSync.syncEvents.on("sync", (event: any) => {
|
|
24
|
+
try {
|
|
25
|
+
if (event.type === "conflict-needs-llm") {
|
|
26
|
+
fs.mkdirSync("application-state", { recursive: true });
|
|
27
|
+
fs.writeFileSync(
|
|
28
|
+
"application-state/sync-conflict.json",
|
|
29
|
+
JSON.stringify(event, null, 2),
|
|
30
|
+
);
|
|
31
|
+
} else if (event.type === "conflict-resolved") {
|
|
32
|
+
fs.rmSync("application-state/sync-conflict.json", { force: true });
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
/* best-effort */
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRequestHandler } from "react-router";
|
|
2
|
+
import { defineEventHandler, toWebRequest } from "h3";
|
|
3
|
+
|
|
4
|
+
const handler = createRequestHandler(
|
|
5
|
+
// virtual module provided by React Router Vite plugin
|
|
6
|
+
() => import("virtual:react-router/server-build"),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export default defineEventHandler(async (event) => {
|
|
10
|
+
const webReq = toWebRequest(event);
|
|
11
|
+
return handler(webReq);
|
|
12
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { syncResult } from "../../../lib/watcher";
|
|
3
|
+
|
|
4
|
+
export default defineEventHandler(() => {
|
|
5
|
+
if (syncResult.status !== "ready") {
|
|
6
|
+
return { enabled: false, conflicts: 0 };
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
enabled: true,
|
|
10
|
+
connected: true,
|
|
11
|
+
conflicts: syncResult.fileSync.conflictCount,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "@agent-native/core/tsconfig.base.json"
|
|
2
|
+
"extends": "@agent-native/core/tsconfig.base.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"client/**/*",
|
|
5
|
+
"server/**/*",
|
|
6
|
+
"shared/**/*",
|
|
7
|
+
"vite.config.ts",
|
|
8
|
+
"react-router.config.ts",
|
|
9
|
+
".react-router/types/**/*"
|
|
10
|
+
]
|
|
3
11
|
}
|
package/tsconfig.base.json
CHANGED
|
@@ -24,11 +24,13 @@
|
|
|
24
24
|
"noFallthroughCasesInSwitch": false,
|
|
25
25
|
"strictNullChecks": false,
|
|
26
26
|
|
|
27
|
+
"rootDirs": [".", "./.react-router/types"],
|
|
27
28
|
"baseUrl": ".",
|
|
28
29
|
"paths": {
|
|
29
30
|
"@/*": ["./client/*"],
|
|
30
31
|
"@shared/*": ["./shared/*"]
|
|
31
|
-
}
|
|
32
|
+
},
|
|
33
|
+
"types": ["vite/client"]
|
|
32
34
|
},
|
|
33
35
|
"include": [
|
|
34
36
|
"client/**/*",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { FileSyncAdapter, FileRecord, FileChange, Unsubscribe } from "../sync/types.js";
|
|
2
|
-
interface NeonQueryResult {
|
|
3
|
-
rows: any[];
|
|
4
|
-
rowCount: number;
|
|
5
|
-
}
|
|
6
|
-
type NeonSql = (strings: TemplateStringsArray, ...values: any[]) => Promise<NeonQueryResult>;
|
|
7
|
-
export interface NeonAdapterOptions {
|
|
8
|
-
/** Polling interval in ms for subscribe(). Default: 2000 */
|
|
9
|
-
pollIntervalMs?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class NeonFileSyncAdapter implements FileSyncAdapter {
|
|
12
|
-
private sql;
|
|
13
|
-
private pollIntervalMs;
|
|
14
|
-
constructor(sql: NeonSql, options?: NeonAdapterOptions);
|
|
15
|
-
query(appId: string, ownerId: string): Promise<{
|
|
16
|
-
id: string;
|
|
17
|
-
data: FileRecord;
|
|
18
|
-
}[]>;
|
|
19
|
-
get(id: string): Promise<{
|
|
20
|
-
id: string;
|
|
21
|
-
data: FileRecord;
|
|
22
|
-
} | null>;
|
|
23
|
-
set(id: string, record: Partial<FileRecord>): Promise<void>;
|
|
24
|
-
delete(id: string): Promise<void>;
|
|
25
|
-
subscribe(appId: string, ownerId: string, onChange: (changes: FileChange[]) => void, onError: (error: any) => void): Unsubscribe;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/neon/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAM1B,UAAU,eAAe;IACvB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,OAAO,GAAG,CACb,OAAO,EAAE,oBAAoB,EAC7B,GAAG,MAAM,EAAE,GAAG,EAAE,KACb,OAAO,CAAC,eAAe,CAAC,CAAC;AA6B9B,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,mBAAoB,YAAW,eAAe;IAIvD,OAAO,CAAC,GAAG;IAHb,OAAO,CAAC,cAAc,CAAS;gBAGrB,GAAG,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,kBAAkB;IAKxB,KAAK,CACT,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,EAAE,CAAC;IAUxC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,IAAI,CAAC;IASjE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB3D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,SAAS,CACP,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,EACzC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAC5B,WAAW;CA8Ef"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// Column mapping helpers
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
/**
|
|
5
|
-
* Table schema (same as Supabase):
|
|
6
|
-
* files(id TEXT PK, path TEXT, content TEXT, app TEXT, owner_id TEXT,
|
|
7
|
-
* last_updated BIGINT, created_at BIGINT)
|
|
8
|
-
*
|
|
9
|
-
* CREATE INDEX idx_files_app_owner ON files(app, owner_id);
|
|
10
|
-
*/
|
|
11
|
-
function rowToRecord(row) {
|
|
12
|
-
return {
|
|
13
|
-
path: row.path,
|
|
14
|
-
content: row.content,
|
|
15
|
-
app: row.app,
|
|
16
|
-
ownerId: row.owner_id,
|
|
17
|
-
lastUpdated: Number(row.last_updated),
|
|
18
|
-
createdAt: row.created_at != null ? Number(row.created_at) : undefined,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export class NeonFileSyncAdapter {
|
|
22
|
-
sql;
|
|
23
|
-
pollIntervalMs;
|
|
24
|
-
constructor(sql, options) {
|
|
25
|
-
this.sql = sql;
|
|
26
|
-
this.pollIntervalMs = options?.pollIntervalMs ?? 2000;
|
|
27
|
-
}
|
|
28
|
-
async query(appId, ownerId) {
|
|
29
|
-
const result = await this.sql `
|
|
30
|
-
SELECT * FROM files WHERE app = ${appId} AND owner_id = ${ownerId}
|
|
31
|
-
`;
|
|
32
|
-
return result.rows.map((row) => ({
|
|
33
|
-
id: row.id,
|
|
34
|
-
data: rowToRecord(row),
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
async get(id) {
|
|
38
|
-
const result = await this.sql `
|
|
39
|
-
SELECT * FROM files WHERE id = ${id} LIMIT 1
|
|
40
|
-
`;
|
|
41
|
-
if (result.rows.length === 0)
|
|
42
|
-
return null;
|
|
43
|
-
const row = result.rows[0];
|
|
44
|
-
return { id: row.id, data: rowToRecord(row) };
|
|
45
|
-
}
|
|
46
|
-
async set(id, record) {
|
|
47
|
-
const path = record.path ?? "";
|
|
48
|
-
const content = record.content ?? "";
|
|
49
|
-
const app = record.app ?? "";
|
|
50
|
-
const ownerId = record.ownerId ?? "";
|
|
51
|
-
const lastUpdated = record.lastUpdated ?? 0;
|
|
52
|
-
const createdAt = record.createdAt ?? null;
|
|
53
|
-
await this.sql `
|
|
54
|
-
INSERT INTO files (id, path, content, app, owner_id, last_updated, created_at)
|
|
55
|
-
VALUES (${id}, ${path}, ${content}, ${app}, ${ownerId}, ${lastUpdated}, ${createdAt})
|
|
56
|
-
ON CONFLICT (id) DO UPDATE SET
|
|
57
|
-
path = COALESCE(EXCLUDED.path, files.path),
|
|
58
|
-
content = COALESCE(EXCLUDED.content, files.content),
|
|
59
|
-
app = COALESCE(EXCLUDED.app, files.app),
|
|
60
|
-
owner_id = COALESCE(EXCLUDED.owner_id, files.owner_id),
|
|
61
|
-
last_updated = COALESCE(EXCLUDED.last_updated, files.last_updated),
|
|
62
|
-
created_at = COALESCE(EXCLUDED.created_at, files.created_at)
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
async delete(id) {
|
|
66
|
-
await this.sql `DELETE FROM files WHERE id = ${id}`;
|
|
67
|
-
}
|
|
68
|
-
subscribe(appId, ownerId, onChange, onError) {
|
|
69
|
-
const snapshot = new Map();
|
|
70
|
-
let stopped = false;
|
|
71
|
-
const poll = async () => {
|
|
72
|
-
if (stopped)
|
|
73
|
-
return;
|
|
74
|
-
try {
|
|
75
|
-
const result = await this.sql `
|
|
76
|
-
SELECT * FROM files WHERE app = ${appId} AND owner_id = ${ownerId}
|
|
77
|
-
`;
|
|
78
|
-
const currentIds = new Set();
|
|
79
|
-
const changes = [];
|
|
80
|
-
for (const row of result.rows) {
|
|
81
|
-
currentIds.add(row.id);
|
|
82
|
-
const record = rowToRecord(row);
|
|
83
|
-
const prev = snapshot.get(row.id);
|
|
84
|
-
if (!prev) {
|
|
85
|
-
changes.push({ type: "added", id: row.id, data: record });
|
|
86
|
-
snapshot.set(row.id, {
|
|
87
|
-
content: row.content,
|
|
88
|
-
lastUpdated: Number(row.last_updated),
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
else if (prev.content !== row.content ||
|
|
92
|
-
prev.lastUpdated !== Number(row.last_updated)) {
|
|
93
|
-
changes.push({ type: "modified", id: row.id, data: record });
|
|
94
|
-
snapshot.set(row.id, {
|
|
95
|
-
content: row.content,
|
|
96
|
-
lastUpdated: Number(row.last_updated),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
for (const [id] of snapshot) {
|
|
101
|
-
if (!currentIds.has(id)) {
|
|
102
|
-
const prev = snapshot.get(id);
|
|
103
|
-
changes.push({
|
|
104
|
-
type: "removed",
|
|
105
|
-
id,
|
|
106
|
-
data: {
|
|
107
|
-
path: "",
|
|
108
|
-
content: prev.content,
|
|
109
|
-
app: appId,
|
|
110
|
-
ownerId,
|
|
111
|
-
lastUpdated: prev.lastUpdated,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
snapshot.delete(id);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (changes.length > 0) {
|
|
118
|
-
onChange(changes);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
onError(err);
|
|
123
|
-
}
|
|
124
|
-
if (!stopped) {
|
|
125
|
-
setTimeout(poll, this.pollIntervalMs);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
// Start polling
|
|
129
|
-
poll();
|
|
130
|
-
return () => {
|
|
131
|
-
stopped = true;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/adapters/neon/adapter.ts"],"names":[],"mappings":"AAqBA,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E;;;;;;GAMG;AAEH,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,OAAO,EAAE,GAAG,CAAC,QAAQ;QACrB,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC;QACrC,SAAS,EAAE,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;KACvE,CAAC;AACJ,CAAC;AAWD,MAAM,OAAO,mBAAmB;IAIpB;IAHF,cAAc,CAAS;IAE/B,YACU,GAAY,EACpB,OAA4B;QADpB,QAAG,GAAH,G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,CAAC,OAAO,EAAE,CAAC;gBACb,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC;QAEF,gBAAgB;QAChB,IAAI,EAAE,CAAC;QAEP,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/neon/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC5E,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/neon/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AAC5E,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Express } from "express";
|
|
2
|
-
export interface ProductionServerOptions {
|
|
3
|
-
/** Port to listen on. Default: process.env.PORT || 3000 */
|
|
4
|
-
port?: number | string;
|
|
5
|
-
/** Path to the built SPA directory. Default: inferred from import.meta or "dist/spa" */
|
|
6
|
-
spaDir?: string;
|
|
7
|
-
/** App name for log messages. Default: "Agent-Native" */
|
|
8
|
-
appName?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Start a production server that:
|
|
12
|
-
* 1. Serves the built SPA static files
|
|
13
|
-
* 2. Falls back to index.html for client-side routing (SPA fallback)
|
|
14
|
-
* 3. Returns 404 JSON for unknown API routes
|
|
15
|
-
* 4. Handles graceful shutdown on SIGTERM/SIGINT
|
|
16
|
-
*/
|
|
17
|
-
export declare function createProductionServer(app: Express, options?: ProductionServerOptions): void;
|
|
18
|
-
//# sourceMappingURL=production.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/server/production.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGvC,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,wFAAwF;IACxF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,uBAA4B,GACpC,IAAI,CA+BN"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import express from "express";
|
|
3
|
-
/**
|
|
4
|
-
* Start a production server that:
|
|
5
|
-
* 1. Serves the built SPA static files
|
|
6
|
-
* 2. Falls back to index.html for client-side routing (SPA fallback)
|
|
7
|
-
* 3. Returns 404 JSON for unknown API routes
|
|
8
|
-
* 4. Handles graceful shutdown on SIGTERM/SIGINT
|
|
9
|
-
*/
|
|
10
|
-
export function createProductionServer(app, options = {}) {
|
|
11
|
-
const port = options.port ?? process.env.PORT ?? 3000;
|
|
12
|
-
const appName = options.appName ?? "Agent-Native";
|
|
13
|
-
// Resolve SPA directory
|
|
14
|
-
const spaDir = options.spaDir ?? path.resolve(process.cwd(), "dist/spa");
|
|
15
|
-
// Serve static files
|
|
16
|
-
app.use(express.static(spaDir));
|
|
17
|
-
// SPA fallback — serve index.html for all non-API routes
|
|
18
|
-
app.get("*", (req, res) => {
|
|
19
|
-
if (req.path.startsWith("/api/") || req.path.startsWith("/health")) {
|
|
20
|
-
return res.status(404).json({ error: "API endpoint not found" });
|
|
21
|
-
}
|
|
22
|
-
res.sendFile(path.join(spaDir, "index.html"));
|
|
23
|
-
});
|
|
24
|
-
app.listen(port, () => {
|
|
25
|
-
console.log(`${appName} server running on port ${port}`);
|
|
26
|
-
console.log(` Frontend: http://localhost:${port}`);
|
|
27
|
-
console.log(` API: http://localhost:${port}/api`);
|
|
28
|
-
});
|
|
29
|
-
// Graceful shutdown
|
|
30
|
-
const shutdown = (signal) => {
|
|
31
|
-
console.log(`Received ${signal}, shutting down gracefully`);
|
|
32
|
-
process.exit(0);
|
|
33
|
-
};
|
|
34
|
-
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
35
|
-
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=production.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"production.js","sourceRoot":"","sources":["../../src/server/production.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,OAAO,MAAM,SAAS,CAAC;AAW9B;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAY,EACZ,UAAmC,EAAE;IAErC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;IACtD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,cAAc,CAAC;IAElD,wBAAwB;IACxB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IAEzE,qBAAqB;IACrB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAEhC,yDAAyD;IACzD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACxB,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACnE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QACpB,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,2BAA2B,IAAI,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,oBAAoB;IACpB,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,4BAA4B,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "vite";
|
|
2
|
-
export interface ExpressPluginOptions {
|
|
3
|
-
/** Path to the module that exports createServer(). Default: "./server" */
|
|
4
|
-
serverEntry?: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Vite plugin that mounts the Express app as middleware during dev.
|
|
8
|
-
* Only active in serve mode (not during build).
|
|
9
|
-
*
|
|
10
|
-
* The Express app is re-created when server files change so you don't
|
|
11
|
-
* have to manually restart `pnpm dev` after editing server code.
|
|
12
|
-
*/
|
|
13
|
-
export declare function expressPlugin(options?: ExpressPluginOptions): Plugin;
|
|
14
|
-
//# sourceMappingURL=express-plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express-plugin.d.ts","sourceRoot":"","sources":["../../src/vite/express-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAGlD,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CA2DxE"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vite plugin that mounts the Express app as middleware during dev.
|
|
3
|
-
* Only active in serve mode (not during build).
|
|
4
|
-
*
|
|
5
|
-
* The Express app is re-created when server files change so you don't
|
|
6
|
-
* have to manually restart `pnpm dev` after editing server code.
|
|
7
|
-
*/
|
|
8
|
-
export function expressPlugin(options = {}) {
|
|
9
|
-
const serverEntry = options.serverEntry ?? "./server";
|
|
10
|
-
return {
|
|
11
|
-
name: "agent-native-express",
|
|
12
|
-
apply: "serve",
|
|
13
|
-
configureServer(server) {
|
|
14
|
-
let app = null;
|
|
15
|
-
async function loadApp() {
|
|
16
|
-
// Invalidate the module graph so we get fresh code
|
|
17
|
-
const resolved = await server.moduleGraph.resolveUrl(serverEntry);
|
|
18
|
-
if (resolved) {
|
|
19
|
-
const mod = server.moduleGraph.getModuleById(resolved[1]);
|
|
20
|
-
if (mod)
|
|
21
|
-
server.moduleGraph.invalidateModule(mod);
|
|
22
|
-
}
|
|
23
|
-
const ssrMod = await server.ssrLoadModule(serverEntry);
|
|
24
|
-
const createServer = ssrMod.createServer ?? ssrMod.createAppServer ?? ssrMod.default;
|
|
25
|
-
if (typeof createServer !== "function") {
|
|
26
|
-
throw new Error(`[@agent-native/core] Could not find createServer export in "${serverEntry}". ` +
|
|
27
|
-
`Export a createServer() function that returns an Express app.`);
|
|
28
|
-
}
|
|
29
|
-
app = createServer();
|
|
30
|
-
}
|
|
31
|
-
// Initial load
|
|
32
|
-
const ready = loadApp();
|
|
33
|
-
// Re-create the app when any server file changes
|
|
34
|
-
server.watcher.on("change", (file) => {
|
|
35
|
-
if (file.includes("/server/") || file.includes("\\server\\")) {
|
|
36
|
-
console.log(`[agent-native] Server file changed, reloading: ${file.split("/server/").pop()}`);
|
|
37
|
-
loadApp().catch((err) => console.error("[agent-native] Failed to reload server:", err));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
// Proxy middleware — delegates to the latest Express app
|
|
41
|
-
server.middlewares.use(async (req, res, next) => {
|
|
42
|
-
await ready; // wait for initial load
|
|
43
|
-
if (app) {
|
|
44
|
-
app(req, res, next);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
next();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=express-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express-plugin.js","sourceRoot":"","sources":["../../src/vite/express-plugin.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,UAAgC,EAAE;IAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,UAAU,CAAC;IAEtD,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,OAAO;QACd,eAAe,CAAC,MAAM;YACpB,IAAI,GAAG,GAAQ,IAAI,CAAC;YAEpB,KAAK,UAAU,OAAO;gBACpB,mDAAmD;gBACnD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;gBAClE,IAAI,QAAQ,EAAE,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AAC,wBAAwB;gBACrC,IAAI,GAAG,EAAE,CAAC;oBACR,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;gBACtB,CAAC;qBAAM,CAAC;oBACN,IAAI,EAAE,CAAC;gBACT,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/vite/server.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { UserConfig } from "vite";
|
|
2
|
-
export interface ServerConfigOptions {
|
|
3
|
-
/** Server entry file. Default: "server/node-build.ts" */
|
|
4
|
-
entry?: string;
|
|
5
|
-
/** Output directory. Default: "dist/server" */
|
|
6
|
-
outDir?: string;
|
|
7
|
-
/** Output filename (without extension). Default: "production" */
|
|
8
|
-
fileName?: string;
|
|
9
|
-
/** Node target. Default: "node22" */
|
|
10
|
-
target?: string;
|
|
11
|
-
/** Additional external packages to exclude from bundle */
|
|
12
|
-
external?: string[];
|
|
13
|
-
/** Override resolve aliases */
|
|
14
|
-
aliases?: Record<string, string>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Create the server build Vite config.
|
|
18
|
-
* Builds the Node.js server entry as an ES module with externalized dependencies.
|
|
19
|
-
*/
|
|
20
|
-
export declare function defineServerConfig(options?: ServerConfigOptions): UserConfig;
|
|
21
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAwBD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,mBAAwB,GAChC,UAAU,CAyCZ"}
|