void 0.9.1 → 0.9.3
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 +1 -0
- package/dist/{better-auth-shared-ChVbrq52.mjs → better-auth-shared-QAfk8CAS.mjs} +1 -1
- package/dist/cli/cli.mjs +14 -14
- package/dist/{config-BVEC0lti.mjs → config-8dLIngKW.mjs} +1 -1
- package/dist/{db-DiddQC2v.mjs → db-UW4IYQFw.mjs} +4 -4
- package/dist/{deploy-CRU9fGjE.mjs → deploy-RQXpVBL-.mjs} +27 -10
- package/dist/{domain-DxTc6HDn.mjs → domain-B7RntQ1r.mjs} +12 -27
- package/dist/{drizzle-2fs1qTgy.mjs → drizzle-DYstYz0j.mjs} +1 -1
- package/dist/{env-Bvw0wMTI.mjs → env-C_ZcxxED.mjs} +2 -2
- package/dist/{env-types-D6qI1ThV.mjs → env-types-CaJaIRXU.mjs} +1 -1
- package/dist/{env-validation-DBJsxZLz.mjs → env-validation-LH6eoyW-.mjs} +3 -3
- package/dist/{gen-CZdNWIaA.mjs → gen-O5mXZ76K.mjs} +2 -2
- package/dist/{handler-xflsMwWM.d.mts → handler-hm9KldPP.d.mts} +21 -1
- package/dist/{headers-Y0jshugF.mjs → headers-VkAnACKX.mjs} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +48 -43
- package/dist/{init-BHupO7Fm.mjs → init-DGrLx2ls.mjs} +5 -5
- package/dist/{node-CHWVVjO6.mjs → node-Df8UjQ2H.mjs} +2 -2
- package/dist/pages/client.d.mts +1 -1
- package/dist/pages/index.d.mts +7 -5
- package/dist/pages/index.mjs +3 -3
- package/dist/pages/islands-plugin.d.mts +1 -1
- package/dist/pages/islands-plugin.mjs +1 -1
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +29 -11
- package/dist/{plugin-inference-BUBhHt_1.mjs → plugin-inference--7geW5Z2.mjs} +1 -1
- package/dist/{prepare-CrlAVbWS.mjs → prepare-DT-7QII_.mjs} +14 -19
- package/dist/{preset-CIJG2O7a.mjs → preset-2aBxMfY1.mjs} +1 -1
- package/dist/{project-tsconfig-HAGjfY6w.mjs → project-tsconfig-BTNuNoJ0.mjs} +18 -4
- package/dist/{protocol-DYca39yJ.d.mts → protocol-B9GZA4Bn.d.mts} +7 -4
- package/dist/{route-types-jxRfWuCb.mjs → route-types-D03ryMXz.mjs} +3 -2
- package/dist/runtime/ai.d.mts +20 -100
- package/dist/runtime/ai.mjs +101 -54
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/handler.d.mts +2 -2
- package/dist/runtime/handler.mjs +67 -1
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws.d.mts +1 -1
- package/dist/{scan-BNC_1OsY.mjs → scan-B2H1Vo2C.mjs} +3 -3
- package/dist/{scan-2YmJkYAf.mjs → scan-VCAM1oh3.mjs} +55 -29
- package/dist/{types-Dm9kep2X.d.mts → types-DEWCqHtl.d.mts} +12 -3
- package/package.json +2 -2
- package/skills/void/docs/guide/ai.md +109 -51
- package/skills/void/docs/guide/pages-routing/layouts.md +8 -7
- package/skills/void/docs/guide/pages-routing/loaders.md +1 -1
- package/skills/void/docs/guide/pages-routing/overview.md +32 -5
- package/skills/void/docs/guide/server-routing.md +28 -0
- package/skills/void/docs/node_modules/void/AGENTS.md +15 -14
- package/skills/void/docs/node_modules/void/README.md +1 -0
- package/skills/void/docs/reference/api.md +53 -3
- package/skills/void/docs/reference/cli.md +4 -2
- package/skills/void/docs/reference/config.md +1 -1
- /package/dist/{dist-DR9sIMbM.mjs → dist-5cGIJHQQ.mjs} +0 -0
- /package/dist/{dotenv-Bkoqyq9r.mjs → dotenv-lS94ymhM.mjs} +0 -0
- /package/dist/{log-CWWZV4V1.mjs → log-BdD_Fpms.mjs} +0 -0
- /package/dist/{providers-uC0PJg1c.mjs → providers-BwPbdHdi.mjs} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { r as __toESM } from "./chunk-DJd-R1mw.mjs";
|
|
2
2
|
import { a as join, n as dirname, s as relative } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
3
3
|
import { u as require_picocolors } from "./output-DeiS4oEX.mjs";
|
|
4
|
-
import { C as hasApiRoutes, S as resolveSandboxConfig, T as resolveAssetRoutingPolicy, _ as readWranglerCompat, a as prerenderPagesNode, b as SANDBOX_MIGRATION_TAG, c as stripInternalEnvKeys, d as ensureWranglerCompatibilityDate, f as ensureWranglerNodejsAlsFlag, g as readExistingLiveBindingConfig, h as normalizeWranglerCompatibilityFlags, i as prerenderPages, l as LIVE_MIGRATION_TAG, m as nextDurableObjectMigrationTag, n as resolveDistDir, o as filterLoadedEnv, p as hasDurableObjectSqliteMigration, r as resolveWorkerDirName, s as resolveRemoteMode, u as ensureWranglerCompat, v as resolveLiveBindingConfig, w as hasDocumentRoutes, x as isSandboxEnabled, y as syncWranglerBindings } from "./deploy-
|
|
4
|
+
import { C as hasApiRoutes, S as resolveSandboxConfig, T as resolveAssetRoutingPolicy, _ as readWranglerCompat, a as prerenderPagesNode, b as SANDBOX_MIGRATION_TAG, c as stripInternalEnvKeys, d as ensureWranglerCompatibilityDate, f as ensureWranglerNodejsAlsFlag, g as readExistingLiveBindingConfig, h as normalizeWranglerCompatibilityFlags, i as prerenderPages, l as LIVE_MIGRATION_TAG, m as nextDurableObjectMigrationTag, n as resolveDistDir, o as filterLoadedEnv, p as hasDurableObjectSqliteMigration, r as resolveWorkerDirName, s as resolveRemoteMode, u as ensureWranglerCompat, v as resolveLiveBindingConfig, w as hasDocumentRoutes, x as isSandboxEnabled, y as syncWranglerBindings } from "./deploy-RQXpVBL-.mjs";
|
|
5
5
|
import { i as resolveProjectPaths, n as readProjectPaths, t as assertNoRootSourceConventionConflicts } from "./project-paths-CCMrHYQm.mjs";
|
|
6
6
|
import { n as loadVoidAuthConfig, t as findVoidAuthConfig } from "./config-hhMYPVRT.mjs";
|
|
7
7
|
import { c as getToken, u as isStagingMode } from "./client-DIfOFf1W.mjs";
|
|
8
8
|
import { r as readProjectConfig } from "./project-CH9pdo16.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { a as
|
|
12
|
-
import { i as
|
|
13
|
-
import { r as
|
|
14
|
-
import {
|
|
15
|
-
import { n as
|
|
9
|
+
import { n as ensureProjectTsconfig, r as writeFileIfChanged } from "./project-tsconfig-BTNuNoJ0.mjs";
|
|
10
|
+
import { c as getDatabaseDialect, f as readConfig, l as isNodeTarget, p as resolveBindingNames } from "./config-8dLIngKW.mjs";
|
|
11
|
+
import { a as scanQueuesSync, i as scanWebSocketRoutesSync, n as scanRoutePatternsSync, o as scanJobsSync, r as scanRoutes, t as scanMiddlewareSync } from "./scan-B2H1Vo2C.mjs";
|
|
12
|
+
import { a as SSR_CLIENT_ENTRY_RELATIVE_PATHS, c as validateSsrEntries, f as isIdentifier, g as walk, i as inferProjectBindings, l as validateSsrEntry, m as isMemberExpression, n as FRAMEWORK_SCAN_DIRS, o as SSR_SERVER_ENTRY_RELATIVE_PATHS, p as isLiteral, r as detectFramework, t as DEFAULT_SCAN_DIRS, u as inferBindingsFromSource } from "./plugin-inference--7geW5Z2.mjs";
|
|
13
|
+
import { i as voidWarn, n as voidError, r as voidLog, t as setShowTimestamp } from "./log-BdD_Fpms.mjs";
|
|
14
|
+
import { r as parseDotenvFile } from "./dotenv-lS94ymhM.mjs";
|
|
15
|
+
import { i as generateDbDts, n as generateQueueTypes, r as DRIZZLE_OPERATORS, t as generateRouteTypes } from "./route-types-D03ryMXz.mjs";
|
|
16
16
|
import { t as discoverSchema } from "./discover-C8N1I4tK.mjs";
|
|
17
17
|
import { t as MagicString } from "./magic-string.es-C1Fb0uxq.mjs";
|
|
18
|
-
import { n as findEnvFileForPaths, r as generateEnvTypes, t as findEnvFile } from "./env-types-
|
|
19
|
-
import { a as loadUserEnvFile } from "./env-validation-
|
|
20
|
-
import { i as resolveLayoutIds } from "./scan-
|
|
18
|
+
import { n as findEnvFileForPaths, r as generateEnvTypes, t as findEnvFile } from "./env-types-CaJaIRXU.mjs";
|
|
19
|
+
import { a as loadUserEnvFile } from "./env-validation-LH6eoyW-.mjs";
|
|
20
|
+
import { i as resolveLayoutIds } from "./scan-VCAM1oh3.mjs";
|
|
21
21
|
import { n as STAGING_PROXY_URL, t as DEFAULT_PROXY_URL } from "./proxy-M3pxItg2.mjs";
|
|
22
|
-
import { n as lintDuplicateSources, r as mergeRoutingRules, t as lintDestinationSplats } from "./headers-
|
|
23
|
-
import { n as generateVoidAuthDrizzleSchema, t as generateVoidAuthDatabaseModule } from "./drizzle-
|
|
22
|
+
import { n as lintDuplicateSources, r as mergeRoutingRules, t as lintDestinationSplats } from "./headers-VkAnACKX.mjs";
|
|
23
|
+
import { n as generateVoidAuthDrizzleSchema, t as generateVoidAuthDatabaseModule } from "./drizzle-DYstYz0j.mjs";
|
|
24
24
|
import { t as INTERNAL_BINDING_PREFIXES } from "./env-raw-RDkMnSTC.mjs";
|
|
25
25
|
import { n as defer } from "./defer-CouVukrf.mjs";
|
|
26
|
-
import { VoidAssetRewriteError, defineHandler, defineHead, defineMiddleware, defineQueue, defineRender, defineScheduled } from "./runtime/handler.mjs";
|
|
26
|
+
import { VoidAssetRewriteError, basicAuth, defineHandler, defineHead, defineMiddleware, defineQueue, defineRender, defineScheduled } from "./runtime/handler.mjs";
|
|
27
27
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, writeFileSync, writeSync } from "node:fs";
|
|
28
28
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
29
29
|
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
@@ -1058,7 +1058,7 @@ function envSchemaPlugin(root, options = {}) {
|
|
|
1058
1058
|
if (!envFile) return;
|
|
1059
1059
|
mkdirSync(outDir, { recursive: true });
|
|
1060
1060
|
const { dts } = generateEnvTypes(envFile, outDir);
|
|
1061
|
-
|
|
1061
|
+
writeFileIfChanged(join(outDir, "env.d.ts"), dts);
|
|
1062
1062
|
}
|
|
1063
1063
|
async function importUserEnv() {
|
|
1064
1064
|
if (!envFile) return;
|
|
@@ -1686,7 +1686,7 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
|
|
|
1686
1686
|
if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
|
|
1687
1687
|
}
|
|
1688
1688
|
if (auth?.enabled) {
|
|
1689
|
-
const { runLocalVoidAuthMigrations } = await import("./node-
|
|
1689
|
+
const { runLocalVoidAuthMigrations } = await import("./node-Df8UjQ2H.mjs");
|
|
1690
1690
|
await runLocalVoidAuthMigrations(root, dialect, persistRoot, databaseId, auth.configPath);
|
|
1691
1691
|
voidLog("Applied Better Auth migrations");
|
|
1692
1692
|
}
|
|
@@ -3139,8 +3139,8 @@ window.__vite_plugin_react_preamble_installed__ = true;
|
|
|
3139
3139
|
return lines.join("\n");
|
|
3140
3140
|
}
|
|
3141
3141
|
function compilePrerenderCollector(lines, scan, ssr, options) {
|
|
3142
|
-
const staticPaths = scan.pages.pages.filter((page) => page.
|
|
3143
|
-
const dynamicPages = scan.pages.pages.filter((page) => page.
|
|
3142
|
+
const staticPaths = scan.pages.pages.filter((page) => page.shouldPrerender && page.params.length === 0 && !page.catchAll).map((page) => page.pattern);
|
|
3143
|
+
const dynamicPages = scan.pages.pages.filter((page) => page.shouldPrerender && page.hasGetPrerenderPaths && (page.params.length > 0 || page.catchAll));
|
|
3144
3144
|
const explicitPaths = options.explicitPrerenderPaths ?? [];
|
|
3145
3145
|
lines.push(`function __voidBuildPrerenderPath(pattern, params) {`);
|
|
3146
3146
|
lines.push(` let path = pattern;`);
|
|
@@ -3194,11 +3194,16 @@ function compilePrerenderCollector(lines, scan, ssr, options) {
|
|
|
3194
3194
|
function compilePageRoutes(lines, scan, pages, options) {
|
|
3195
3195
|
lines.push(`import { handlePageGet, handlePageMutation } from ${JSON.stringify(pages.protocolPath)};`);
|
|
3196
3196
|
lines.push(`import { renderHeadToString, renderHtmlAttrs, renderBodyAttrs } from ${JSON.stringify(pages.headPath)};`);
|
|
3197
|
-
lines.push(`import
|
|
3197
|
+
lines.push(`import * as __voidPagesRenderer from "virtual:void-pages-renderer";`);
|
|
3198
3198
|
if (options.dev) lines.push(`import { getVoidPagesDevCss } from "virtual:void-pages-dev-assets";`);
|
|
3199
|
-
const hasIslandPages = scan.pages.pages.some((p) => p.island);
|
|
3199
|
+
const hasIslandPages = scan.pages.pages.some((p) => p.renderMode === "island");
|
|
3200
3200
|
if (hasIslandPages) lines.push(`import { renderIslandPage } from "virtual:void-islands-renderer";`);
|
|
3201
3201
|
lines.push("");
|
|
3202
|
+
lines.push(`const renderPage = __voidPagesRenderer.renderPage;`);
|
|
3203
|
+
lines.push(`if (typeof __voidPagesRenderer.renderPreambleScript === "string") {`);
|
|
3204
|
+
lines.push(` renderPage.preambleScript = __voidPagesRenderer.renderPreambleScript;`);
|
|
3205
|
+
lines.push(`}`);
|
|
3206
|
+
lines.push("");
|
|
3202
3207
|
lines.push(`const __voidHeadConfig = ${JSON.stringify(pages.headConfig ?? null)};`);
|
|
3203
3208
|
lines.push("");
|
|
3204
3209
|
pushDefaultErrorPageHelpers(lines, options);
|
|
@@ -3447,17 +3452,17 @@ function compilePageRoutes(lines, scan, pages, options) {
|
|
|
3447
3452
|
lines.push(`const ${headVarName} = () => (${JSON.stringify(headObj)});`);
|
|
3448
3453
|
mdHeadRef = headVarName;
|
|
3449
3454
|
}
|
|
3450
|
-
const renderer = page.island ? "renderIslandPage" : "renderPage";
|
|
3451
|
-
const assetTags = page.island && pages.islandClientEntryId ? "getIslandsAssetTags" : "getPagesAssetTags";
|
|
3452
|
-
const
|
|
3455
|
+
const renderer = page.renderMode === "island" ? "renderIslandPage" : "renderPage";
|
|
3456
|
+
const assetTags = page.renderMode === "island" && pages.islandClientEntryId ? "getIslandsAssetTags" : "getPagesAssetTags";
|
|
3457
|
+
const renderOptions = `, ${JSON.stringify({ renderMode: page.renderMode })}`;
|
|
3453
3458
|
lines.push(`app.get(${JSON.stringify(page.pattern)}, async (c) => {`);
|
|
3454
3459
|
if (serverImportPath) {
|
|
3455
3460
|
const loaderName = `_pload_${safeId}`;
|
|
3456
3461
|
lines.push(` const mod = await ${loaderName}();`);
|
|
3457
|
-
lines.push(` return handlePageGet(mod.loader, mod.head, c, ${JSON.stringify(page.componentId)}, ${renderer}, ${assetTags}, __voidHeadConfig${
|
|
3462
|
+
lines.push(` return handlePageGet(mod.loader, mod.head, c, ${JSON.stringify(page.componentId)}, ${renderer}, ${assetTags}, __voidHeadConfig${renderOptions});`);
|
|
3458
3463
|
} else {
|
|
3459
3464
|
const headArg = mdHeadRef ?? "undefined";
|
|
3460
|
-
lines.push(` return handlePageGet(undefined, ${headArg}, c, ${JSON.stringify(page.componentId)}, ${renderer}, ${assetTags}, __voidHeadConfig${
|
|
3465
|
+
lines.push(` return handlePageGet(undefined, ${headArg}, c, ${JSON.stringify(page.componentId)}, ${renderer}, ${assetTags}, __voidHeadConfig${renderOptions});`);
|
|
3461
3466
|
}
|
|
3462
3467
|
lines.push(`});`);
|
|
3463
3468
|
if (page.methods.includes("action") || page.methods.includes("actions")) {
|
|
@@ -3469,7 +3474,7 @@ function compilePageRoutes(lines, scan, pages, options) {
|
|
|
3469
3474
|
lines.push(` const handler = actionName ? mod.actions?.[actionName] : mod.actions?.default;`);
|
|
3470
3475
|
lines.push(` if (!handler) return new Response("Unknown action" + (actionName ? ": " + actionName : ""), { status: 404 });`);
|
|
3471
3476
|
} else lines.push(` const handler = mod.action;`);
|
|
3472
|
-
lines.push(` return handlePageMutation(handler, mod.loader, mod.head, c, ${JSON.stringify(page.componentId)}, ${renderer}, ${assetTags}, __voidHeadConfig${
|
|
3477
|
+
lines.push(` return handlePageMutation(handler, mod.loader, mod.head, c, ${JSON.stringify(page.componentId)}, ${renderer}, ${assetTags}, __voidHeadConfig${renderOptions});`);
|
|
3473
3478
|
lines.push(`});`);
|
|
3474
3479
|
}
|
|
3475
3480
|
}
|
|
@@ -4241,12 +4246,12 @@ function routingPlugin(root, options) {
|
|
|
4241
4246
|
function writeRouteTypes() {
|
|
4242
4247
|
if (!scan) return;
|
|
4243
4248
|
const { dts } = generateRouteTypes(scan, routesDir, outDir, pagesDir);
|
|
4244
|
-
|
|
4249
|
+
writeFileIfChanged(join(outDir, "routes.d.ts"), dts);
|
|
4245
4250
|
}
|
|
4246
4251
|
function writeQueueTypes() {
|
|
4247
4252
|
if (!scan) return;
|
|
4248
4253
|
const dts = generateQueueTypes(scan.queues, queuesDir, outDir);
|
|
4249
|
-
|
|
4254
|
+
writeFileIfChanged(join(outDir, "queues.d.ts"), dts);
|
|
4250
4255
|
}
|
|
4251
4256
|
async function rescan() {
|
|
4252
4257
|
scan = await scanRoutes(root, {
|
|
@@ -4347,8 +4352,8 @@ function routingPlugin(root, options) {
|
|
|
4347
4352
|
const env = loadEnv(resolvedConfig?.mode ?? "development", root, "");
|
|
4348
4353
|
const schemaPath = join(outDir, "better-auth-schema.ts");
|
|
4349
4354
|
const databasePath = join(outDir, "better-auth-db.ts");
|
|
4350
|
-
|
|
4351
|
-
|
|
4355
|
+
writeFileIfChanged(schemaPath, generateVoidAuthDrizzleSchema(authRuntime, env));
|
|
4356
|
+
writeFileIfChanged(databasePath, generateVoidAuthDatabaseModule({
|
|
4352
4357
|
dialect: compileOptions.auth.dialect,
|
|
4353
4358
|
schemaImportPath: schemaPath,
|
|
4354
4359
|
drizzleAdapterPath
|
|
@@ -4424,9 +4429,9 @@ function routingPlugin(root, options) {
|
|
|
4424
4429
|
const outDir = join(root, ".void");
|
|
4425
4430
|
mkdirSync(outDir, { recursive: true });
|
|
4426
4431
|
if (options.target) {
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
} else
|
|
4432
|
+
writeFileIfChanged(join(outDir, "app.ts"), compileNodeApp(options.target, compileOptions.honoPath, getEnvSchemaModule()));
|
|
4433
|
+
writeFileIfChanged(join(outDir, "index.ts"), compileNodeServer(options.target));
|
|
4434
|
+
} else writeFileIfChanged(join(outDir, "entry.ts"), compileWorkerEntry(false, remote, void 0, void 0, compileOptions.runtimeEnvPath, getEnvSchemaModule(), options.hasSandbox ? {
|
|
4430
4435
|
bindingName: options.sandboxBindingName,
|
|
4431
4436
|
className: options.sandboxClassName,
|
|
4432
4437
|
runtimePath: sandboxRuntimePath
|
|
@@ -4490,9 +4495,9 @@ function routingPlugin(root, options) {
|
|
|
4490
4495
|
}
|
|
4491
4496
|
}
|
|
4492
4497
|
if (options.target) {
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
} else
|
|
4498
|
+
writeFileIfChanged(join(outDir, "app.ts"), compileNodeApp(options.target, compileOptions.honoPath, getEnvSchemaModule()));
|
|
4499
|
+
writeFileIfChanged(join(outDir, "index.ts"), compileNodeServer(options.target));
|
|
4500
|
+
} else writeFileIfChanged(join(outDir, "entry.ts"), compileWorkerEntry(scan.queues.length > 0, remote, resolvedConfig?.build.assetsDir, (scan.websockets ?? []).map((route) => route.className), compileOptions.runtimeEnvPath, getEnvSchemaModule(), options.hasSandbox ? {
|
|
4496
4501
|
bindingName: options.sandboxBindingName,
|
|
4497
4502
|
className: options.sandboxClassName,
|
|
4498
4503
|
runtimePath: sandboxRuntimePath
|
|
@@ -4540,9 +4545,9 @@ function routingPlugin(root, options) {
|
|
|
4540
4545
|
writeRouteTypes();
|
|
4541
4546
|
writeQueueTypes();
|
|
4542
4547
|
if (options.target) {
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
} else
|
|
4548
|
+
writeFileIfChanged(join(outDir, "app.ts"), compileNodeApp(options.target, compileOptions.honoPath, getEnvSchemaModule()));
|
|
4549
|
+
writeFileIfChanged(join(outDir, "index.ts"), compileNodeServer(options.target));
|
|
4550
|
+
} else writeFileIfChanged(join(outDir, "entry.ts"), compileWorkerEntry(scan.queues.length > 0, remote, resolvedConfig?.build.assetsDir, (scan.websockets ?? []).map((route) => route.className), compileOptions.runtimeEnvPath, getEnvSchemaModule(), options.hasSandbox ? {
|
|
4546
4551
|
bindingName: options.sandboxBindingName,
|
|
4547
4552
|
className: options.sandboxClassName,
|
|
4548
4553
|
runtimePath: sandboxRuntimePath
|
|
@@ -4717,7 +4722,7 @@ function generateClassATriggerWrapper(root, framework, original, isBuild, assets
|
|
|
4717
4722
|
const outDir = join(root, ".void");
|
|
4718
4723
|
mkdirSync(outDir, { recursive: true });
|
|
4719
4724
|
const wrapperPath = join(outDir, `${framework}-trigger-wrapper.ts`);
|
|
4720
|
-
|
|
4725
|
+
writeFileIfChanged(wrapperPath, isBuild ? `// @ts-nocheck — Auto-generated by Void for vite build. Do NOT edit.
|
|
4721
4726
|
import original from ${JSON.stringify(original)};
|
|
4722
4727
|
|
|
4723
4728
|
export default {
|
|
@@ -4747,7 +4752,7 @@ function generateVinextPagesEntry(root) {
|
|
|
4747
4752
|
const outDir = join(root, ".void");
|
|
4748
4753
|
mkdirSync(outDir, { recursive: true });
|
|
4749
4754
|
const entryPath = join(outDir, "vinext-pages-entry.ts");
|
|
4750
|
-
|
|
4755
|
+
writeFileIfChanged(entryPath, `// Auto-generated by Void — vinext Pages Router worker entry
|
|
4751
4756
|
// @ts-expect-error virtual module resolved by vinext at build time
|
|
4752
4757
|
import { renderPage, handleApiRoute } from "virtual:vinext-server-entry";
|
|
4753
4758
|
|
|
@@ -4773,7 +4778,7 @@ function generateReactRouterEntry(root) {
|
|
|
4773
4778
|
const outDir = join(root, ".void");
|
|
4774
4779
|
mkdirSync(outDir, { recursive: true });
|
|
4775
4780
|
const entryPath = join(outDir, "react-router-entry.ts");
|
|
4776
|
-
|
|
4781
|
+
writeFileIfChanged(entryPath, `// Auto-generated by Void — React Router v7 worker entry
|
|
4777
4782
|
import { createRequestHandler } from "react-router";
|
|
4778
4783
|
|
|
4779
4784
|
const requestHandler = createRequestHandler(
|
|
@@ -5555,4 +5560,4 @@ function voidPlugin(options) {
|
|
|
5555
5560
|
];
|
|
5556
5561
|
}
|
|
5557
5562
|
//#endregion
|
|
5558
|
-
export { VoidAssetRewriteError, defer, defineHandler, defineHead, defineMiddleware, defineQueue, defineRender, defineScheduled, voidPlugin };
|
|
5563
|
+
export { VoidAssetRewriteError, basicAuth, defer, defineHandler, defineHead, defineMiddleware, defineQueue, defineRender, defineScheduled, voidPlugin };
|
|
@@ -4,16 +4,16 @@ import { n as readProjectPaths } from "./project-paths-CCMrHYQm.mjs";
|
|
|
4
4
|
import { c as getToken, n as PlatformClient, u as isStagingMode } from "./client-DIfOFf1W.mjs";
|
|
5
5
|
import { _ as me, c as R, g as ge, i as Ee, l as Re, u as Se, v as ue, x as q, y as ye } from "./dist-abzUneor.mjs";
|
|
6
6
|
import { a as writeProjectConfig, r as readProjectConfig } from "./project-CH9pdo16.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { r as
|
|
10
|
-
import {
|
|
7
|
+
import { n as ensureProjectTsconfig, t as createProjectTsconfig } from "./project-tsconfig-BTNuNoJ0.mjs";
|
|
8
|
+
import { c as getDatabaseDialect, f as readConfig } from "./config-8dLIngKW.mjs";
|
|
9
|
+
import { r as detectFramework } from "./plugin-inference--7geW5Z2.mjs";
|
|
10
|
+
import { r as parseDotenvFile, t as expandDotenv } from "./dotenv-lS94ymhM.mjs";
|
|
11
11
|
import { t as MagicString } from "./magic-string.es-C1Fb0uxq.mjs";
|
|
12
12
|
import { n as writeDrizzleConfig } from "./config--wXmVOoe.mjs";
|
|
13
13
|
import { n as getAgentById, r as getPackageDir, t as detectAgents } from "./agents-MhSzNMiC.mjs";
|
|
14
14
|
import { n as promptAndCreateProject, r as promptProjectSelection } from "./create-project-DCUrFJxa.mjs";
|
|
15
15
|
import { t as promptForLoginToken } from "./login-tt1OmNVg.mjs";
|
|
16
|
-
import { r as formatProjectCommand } from "./preset-
|
|
16
|
+
import { r as formatProjectCommand } from "./preset-2aBxMfY1.mjs";
|
|
17
17
|
import { n as findInstalledYarnPnpRuntime, r as hasLocalLockfile, t as buildDrizzleKitSpawnEnv } from "./yarn-pnp-0SwYgQxx.mjs";
|
|
18
18
|
import { createRequire } from "node:module";
|
|
19
19
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as join } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
2
2
|
import { n as loadVoidAuthConfig, t as findVoidAuthConfig } from "./config-hhMYPVRT.mjs";
|
|
3
|
-
import { f as readConfig } from "./config-
|
|
4
|
-
import { r as resolveVoidAuthMigrationSchema } from "./drizzle-
|
|
3
|
+
import { f as readConfig } from "./config-8dLIngKW.mjs";
|
|
4
|
+
import { r as resolveVoidAuthMigrationSchema } from "./drizzle-DYstYz0j.mjs";
|
|
5
5
|
import { n as applySqliteAuthMigrations, t as applyPgAuthMigrations } from "./auth-migrations-CuQkjjWE.mjs";
|
|
6
6
|
import { getMiniflareDatabasePath } from "./runner-DLZ9E_cX.mjs";
|
|
7
7
|
import { loadEnv } from "vite";
|
package/dist/pages/client.d.mts
CHANGED
package/dist/pages/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as renderHtmlAttrs, i as renderHeadToString, n as HeadDescriptor, o as resolveHead, r as renderBodyAttrs, t as HeadConfig } from "../head-BsSTGnIe.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { i as PageDefinition, n as LayoutDefinition, o as PageScanResult, r as NamedLayoutDefinition } from "../types-DEWCqHtl.mjs";
|
|
3
3
|
import { serializePageData } from "./serialize.mjs";
|
|
4
4
|
import { RewriteDestination } from "void/routes";
|
|
5
5
|
|
|
@@ -27,21 +27,23 @@ declare function resolvePagesDir(root?: string): string;
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/pages/layout-resolution.d.ts
|
|
29
29
|
/** Resolve the layout chain for a component (innermost last) */
|
|
30
|
-
declare function resolveLayoutChain(componentId: string, layouts: Array<LayoutDefinition
|
|
30
|
+
declare function resolveLayoutChain(componentId: string, layouts: Array<LayoutDefinition>, componentPath?: string): Array<LayoutDefinition>;
|
|
31
31
|
/** Walk up directory tree to find closest _layouts/<name> */
|
|
32
|
-
declare function resolveNamedLayout(name: string, componentId: string, namedLayouts: Array<NamedLayoutDefinition
|
|
32
|
+
declare function resolveNamedLayout(name: string, componentId: string, namedLayouts: Array<NamedLayoutDefinition>, componentPath?: string): NamedLayoutDefinition | null;
|
|
33
33
|
/** Resolve effective layout chain accounting for named layout selection */
|
|
34
34
|
declare function resolveEffectiveLayoutChain(page: {
|
|
35
35
|
componentId: string;
|
|
36
|
+
componentPath?: string;
|
|
36
37
|
layout?: string | false;
|
|
37
38
|
}, layouts: Array<LayoutDefinition>, namedLayouts: Array<NamedLayoutDefinition>): Array<LayoutDefinition | NamedLayoutDefinition>;
|
|
38
39
|
//#endregion
|
|
39
40
|
//#region src/pages/scan.d.ts
|
|
40
|
-
|
|
41
|
+
type PageScanOptions = {
|
|
41
42
|
output?: "server" | "static";
|
|
42
43
|
paths?: ProjectPaths;
|
|
43
44
|
pagesDir?: string;
|
|
44
|
-
}
|
|
45
|
+
};
|
|
46
|
+
declare function scanPages(root: string, options?: PageScanOptions): Promise<PageScanResult>;
|
|
45
47
|
//#endregion
|
|
46
48
|
//#region src/pages/manifest.d.ts
|
|
47
49
|
/**
|
package/dist/pages/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as join } from "../pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
2
2
|
import { r as resolvePagesDir } from "../project-paths-CCMrHYQm.mjs";
|
|
3
|
-
import { f as readConfig } from "../config-
|
|
4
|
-
import { a as resolveNamedLayout, i as resolveLayoutIds, n as resolveEffectiveLayoutChain, r as resolveLayoutChain, t as scanPages } from "../scan-
|
|
5
|
-
import { i as parseRedirectsFile } from "../headers-
|
|
3
|
+
import { f as readConfig } from "../config-8dLIngKW.mjs";
|
|
4
|
+
import { a as resolveNamedLayout, i as resolveLayoutIds, n as resolveEffectiveLayoutChain, r as resolveLayoutChain, t as scanPages } from "../scan-VCAM1oh3.mjs";
|
|
5
|
+
import { i as parseRedirectsFile } from "../headers-VkAnACKX.mjs";
|
|
6
6
|
import { renderBodyAttrs, renderHeadToString, renderHtmlAttrs, resolveHead } from "./head.mjs";
|
|
7
7
|
import { serializePageData } from "./serialize.mjs";
|
|
8
8
|
//#region src/pages/manifest.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as resolve, n as dirname } from "../pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
2
|
-
import { n as resolveEffectiveLayoutChain, t as scanPages } from "../scan-
|
|
2
|
+
import { n as resolveEffectiveLayoutChain, t as scanPages } from "../scan-VCAM1oh3.mjs";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
4
4
|
import { normalizePath } from "vite";
|
|
5
5
|
//#region src/pages/islands-plugin.ts
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as handlePageMutation, i as handlePageGet, n as PageRenderResult, o as safeJsonStringify, r as flattenValidationErrors, t as PageObject } from "../protocol-
|
|
1
|
+
import { w as ValidationError } from "../handler-hm9KldPP.mjs";
|
|
2
|
+
import { a as handlePageMutation, i as handlePageGet, n as PageRenderResult, o as safeJsonStringify, r as flattenValidationErrors, t as PageObject } from "../protocol-B9GZA4Bn.mjs";
|
|
3
3
|
export { PageObject, PageRenderResult, ValidationError, flattenValidationErrors, handlePageGet, handlePageMutation, safeJsonStringify };
|
package/dist/pages/protocol.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isConvertedResponse } from "../runtime/response.mjs";
|
|
2
2
|
import { i as ValidationError, r as separateDeferred, t as DEFERRED } from "../defer-CouVukrf.mjs";
|
|
3
|
-
import { resolveHead } from "./head.mjs";
|
|
3
|
+
import { renderBodyAttrs, renderHeadToString, renderHtmlAttrs, resolveHead } from "./head.mjs";
|
|
4
|
+
import { serializePageData } from "./serialize.mjs";
|
|
4
5
|
//#region src/pages/protocol.ts
|
|
5
6
|
const POWERED_BY = { "X-Powered-By": "Void" };
|
|
6
7
|
const RENDER_ERROR_ASSET_TAGS_KEY = "__voidPageAssetTags";
|
|
@@ -95,6 +96,21 @@ async function renderWithAssetTags(renderFn, pageObj, assetTags) {
|
|
|
95
96
|
attachRenderErrorAssetTags(error, assetTags);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
function renderClientOnlyPage(pageObj, assetTags, renderFn) {
|
|
100
|
+
const pageData = serializePageData(pageObj);
|
|
101
|
+
const headHtml = pageObj.head ? renderHeadToString(pageObj.head) : "";
|
|
102
|
+
const htmlAttrs = pageObj.head ? renderHtmlAttrs(pageObj.head) : "";
|
|
103
|
+
const bodyAttrs = pageObj.head ? renderBodyAttrs(pageObj.head) : "";
|
|
104
|
+
return `<!doctype html>
|
|
105
|
+
<html${htmlAttrs}>
|
|
106
|
+
<head>${headHtml}${typeof renderFn.preambleScript === "string" ? renderFn.preambleScript : ""}${assetTags.css}${assetTags.preloads}</head>
|
|
107
|
+
<body${bodyAttrs}>
|
|
108
|
+
<script id="__VOID_PAGE_DATA__" type="application/json">${pageData}<\/script>
|
|
109
|
+
<div id="app" data-void-ssr="false"></div>
|
|
110
|
+
${assetTags.body}
|
|
111
|
+
</body>
|
|
112
|
+
</html>`;
|
|
113
|
+
}
|
|
98
114
|
function pageJsonResponse(c, pageObj) {
|
|
99
115
|
return Response.json(pageObj, { headers: pageResponseHeaders(c, {
|
|
100
116
|
"X-VoidPages": "true",
|
|
@@ -170,7 +186,8 @@ function streamDeferredResponse(initialChunk, deferredMap, c, contentType, forma
|
|
|
170
186
|
}), assetTags?.devCssNonce) });
|
|
171
187
|
}
|
|
172
188
|
/** Handle GET page request — run handler, return page object or SSR HTML */
|
|
173
|
-
async function handlePageGet(handler, headFn, c, componentId, renderFn, getAssetTags, configHead,
|
|
189
|
+
async function handlePageGet(handler, headFn, c, componentId, renderFn, getAssetTags, configHead, options) {
|
|
190
|
+
const renderMode = options?.renderMode ?? "server";
|
|
174
191
|
const shared = c.get("shared") ?? {};
|
|
175
192
|
let props = {};
|
|
176
193
|
if (handler) {
|
|
@@ -200,7 +217,7 @@ async function handlePageGet(handler, headFn, c, componentId, renderFn, getAsset
|
|
|
200
217
|
deferredKeys
|
|
201
218
|
}
|
|
202
219
|
};
|
|
203
|
-
if (
|
|
220
|
+
if (renderMode !== "island" && isPagesRequest(c)) {
|
|
204
221
|
if (c.req.header("purpose") === "prefetch" && hasDeferred) {
|
|
205
222
|
const resolvedProps = { ...immediateProps };
|
|
206
223
|
await Promise.all(Object.entries(deferredMap).map(async ([, { resolver, keys }]) => {
|
|
@@ -231,12 +248,13 @@ async function handlePageGet(handler, headFn, c, componentId, renderFn, getAsset
|
|
|
231
248
|
}) + "\n");
|
|
232
249
|
}
|
|
233
250
|
const assetTags = prepareAssetTags(await getAssetTags(c.req.raw, c.env, componentId));
|
|
234
|
-
const html = await renderWithAssetTags(renderFn, pageObj, assetTags);
|
|
251
|
+
const html = renderMode === "client" ? renderClientOnlyPage(pageObj, assetTags, renderFn) : await renderWithAssetTags(renderFn, pageObj, assetTags);
|
|
235
252
|
if (!hasDeferred) return renderedResponse(c, html, "text/html; charset=utf-8", assetTags);
|
|
236
253
|
return streamDeferredResponse(html, deferredMap, c, "text/html; charset=utf-8", (group, data) => `\n<script>window.__resolveDeferred?window.__resolveDeferred(${safeJsonStringify(group)},${safeJsonStringify(data)}):(window.__deferredQueue??=[]).push([${safeJsonStringify(group)},${safeJsonStringify(data)}])<\/script>`, (group, error) => `\n<script>window.__rejectDeferred?window.__rejectDeferred(${safeJsonStringify(group)},${safeJsonStringify(error)}):(window.__deferredQueue??=[]).push([${safeJsonStringify(group)},0,${safeJsonStringify(error)}])<\/script>`, assetTags);
|
|
237
254
|
}
|
|
238
255
|
/** Handle POST/PUT/DELETE page request — run mutation, then re-run GET or redirect */
|
|
239
|
-
async function handlePageMutation(mutationHandler, getHandler, headFn, c, componentId, renderFn, getAssetTags, configHead,
|
|
256
|
+
async function handlePageMutation(mutationHandler, getHandler, headFn, c, componentId, renderFn, getAssetTags, configHead, options) {
|
|
257
|
+
const renderMode = options?.renderMode ?? "server";
|
|
240
258
|
const shared = c.get("shared") ?? {};
|
|
241
259
|
const middlewareHead = c.get("headDefaults");
|
|
242
260
|
function buildMutationPageObj(props, errors) {
|
|
@@ -256,11 +274,11 @@ async function handlePageMutation(mutationHandler, getHandler, headFn, c, compon
|
|
|
256
274
|
result = mutationHandler ? await mutationHandler(c) : void 0;
|
|
257
275
|
} catch (e) {
|
|
258
276
|
if (e instanceof ValidationError) {
|
|
259
|
-
if (island) return Response.json({ errors: e.errors }, { status: 422 });
|
|
277
|
+
if (renderMode === "island") return Response.json({ errors: e.errors }, { status: 422 });
|
|
260
278
|
const pageObj = buildMutationPageObj(stripDeferred(getHandler ? await extractProps(await getHandler(c)) : {}), e.errors);
|
|
261
279
|
if (isPagesRequest(c)) return pageJsonResponse(c, pageObj);
|
|
262
280
|
const assetTags = prepareAssetTags(await getAssetTags(c.req.raw, c.env, componentId));
|
|
263
|
-
return renderedResponse(c, await renderWithAssetTags(renderFn, pageObj, assetTags), "text/html; charset=utf-8", assetTags);
|
|
281
|
+
return renderedResponse(c, renderMode === "client" ? renderClientOnlyPage(pageObj, assetTags, renderFn) : await renderWithAssetTags(renderFn, pageObj, assetTags), "text/html; charset=utf-8", assetTags);
|
|
264
282
|
}
|
|
265
283
|
throw e;
|
|
266
284
|
}
|
|
@@ -269,19 +287,19 @@ async function handlePageMutation(mutationHandler, getHandler, headFn, c, compon
|
|
|
269
287
|
if (status >= 300 && status < 400) return result;
|
|
270
288
|
if (status === 400) {
|
|
271
289
|
const errors = flattenValidationErrors(await result.json());
|
|
272
|
-
if (island) return Response.json({ errors }, { status: 422 });
|
|
290
|
+
if (renderMode === "island") return Response.json({ errors }, { status: 422 });
|
|
273
291
|
const pageObj = buildMutationPageObj(stripDeferred(getHandler ? await extractProps(await getHandler(c)) : {}), errors);
|
|
274
292
|
if (isPagesRequest(c)) return pageJsonResponse(c, pageObj);
|
|
275
293
|
const assetTags = prepareAssetTags(await getAssetTags(c.req.raw, c.env, componentId));
|
|
276
|
-
return renderedResponse(c, await renderWithAssetTags(renderFn, pageObj, assetTags), "text/html; charset=utf-8", assetTags);
|
|
294
|
+
return renderedResponse(c, renderMode === "client" ? renderClientOnlyPage(pageObj, assetTags, renderFn) : await renderWithAssetTags(renderFn, pageObj, assetTags), "text/html; charset=utf-8", assetTags);
|
|
277
295
|
}
|
|
278
296
|
if (status !== 204) return result;
|
|
279
297
|
}
|
|
280
|
-
if (island) return Response.json({ success: true });
|
|
298
|
+
if (renderMode === "island") return Response.json({ success: true });
|
|
281
299
|
const pageObj = buildMutationPageObj(stripDeferred(getHandler ? await extractProps(await getHandler(c)) : {}), null);
|
|
282
300
|
if (isPagesRequest(c)) return pageJsonResponse(c, pageObj);
|
|
283
301
|
const assetTags = prepareAssetTags(await getAssetTags(c.req.raw, c.env, componentId));
|
|
284
|
-
return renderedResponse(c, await renderWithAssetTags(renderFn, pageObj, assetTags), "text/html; charset=utf-8", assetTags);
|
|
302
|
+
return renderedResponse(c, renderMode === "client" ? renderClientOnlyPage(pageObj, assetTags, renderFn) : await renderWithAssetTags(renderFn, pageObj, assetTags), "text/html; charset=utf-8", assetTags);
|
|
285
303
|
}
|
|
286
304
|
//#endregion
|
|
287
305
|
export { ValidationError, flattenValidationErrors, handlePageGet, handlePageMutation, safeJsonStringify };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as join, s as relative } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
2
2
|
import { n as readProjectPaths } from "./project-paths-CCMrHYQm.mjs";
|
|
3
|
-
import { n as globSync } from "./dist-
|
|
3
|
+
import { n as globSync } from "./dist-5cGIJHQQ.mjs";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { parseSync } from "vite";
|
|
6
6
|
import { parse } from "es-module-lexer/js";
|
|
@@ -3,22 +3,21 @@ import { n as cliTitle } from "./output-DeiS4oEX.mjs";
|
|
|
3
3
|
import { i as resolveProjectPaths } from "./project-paths-CCMrHYQm.mjs";
|
|
4
4
|
import { n as loadVoidAuthConfig, t as findVoidAuthConfig } from "./config-hhMYPVRT.mjs";
|
|
5
5
|
import { c as R, g as ge, u as Se, y as ye } from "./dist-abzUneor.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { i as
|
|
10
|
-
import { n as
|
|
6
|
+
import { n as ensureProjectTsconfig, r as writeFileIfChanged } from "./project-tsconfig-BTNuNoJ0.mjs";
|
|
7
|
+
import { c as getDatabaseDialect, f as readConfig } from "./config-8dLIngKW.mjs";
|
|
8
|
+
import { r as scanRoutes } from "./scan-B2H1Vo2C.mjs";
|
|
9
|
+
import { i as inferProjectBindings, n as FRAMEWORK_SCAN_DIRS, r as detectFramework } from "./plugin-inference--7geW5Z2.mjs";
|
|
10
|
+
import { i as generateDbDts, n as generateQueueTypes, t as generateRouteTypes } from "./route-types-D03ryMXz.mjs";
|
|
11
11
|
import { t as discoverSchema } from "./discover-C8N1I4tK.mjs";
|
|
12
|
-
import { r as generateEnvTypes, t as findEnvFile } from "./env-types-
|
|
13
|
-
import { n as generateVoidAuthDrizzleSchema, t as generateVoidAuthDatabaseModule } from "./drizzle-
|
|
14
|
-
import { existsSync, mkdirSync, rmSync
|
|
12
|
+
import { r as generateEnvTypes, t as findEnvFile } from "./env-types-CaJaIRXU.mjs";
|
|
13
|
+
import { n as generateVoidAuthDrizzleSchema, t as generateVoidAuthDatabaseModule } from "./drizzle-DYstYz0j.mjs";
|
|
14
|
+
import { existsSync, mkdirSync, rmSync } from "node:fs";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { loadEnv } from "vite";
|
|
17
17
|
//#region src/codegen/prepare.ts
|
|
18
18
|
function writeGeneratedFile(outDir, fileName, content, written) {
|
|
19
19
|
mkdirSync(outDir, { recursive: true });
|
|
20
|
-
|
|
21
|
-
written.push(join(".void", fileName));
|
|
20
|
+
if (writeFileIfChanged(join(outDir, fileName), content)) written.push(join(".void", fileName));
|
|
22
21
|
}
|
|
23
22
|
function removeGeneratedFile(outDir, fileName, removed) {
|
|
24
23
|
const filePath = join(outDir, fileName);
|
|
@@ -62,8 +61,7 @@ async function prepareProject(root) {
|
|
|
62
61
|
const schema = discoverSchema(root, paths);
|
|
63
62
|
const hasDbRuntime = schema != null || authEnabled;
|
|
64
63
|
if (hasDbRuntime) {
|
|
65
|
-
generateDbDts(outDir, schema, dialect);
|
|
66
|
-
written.push(join(".void", "db.d.ts"));
|
|
64
|
+
if (generateDbDts(outDir, schema, dialect)) written.push(join(".void", "db.d.ts"));
|
|
67
65
|
} else removeGeneratedFile(outDir, "db.d.ts", removed);
|
|
68
66
|
if (authEnabled) {
|
|
69
67
|
const authRuntime = {
|
|
@@ -75,20 +73,17 @@ async function prepareProject(root) {
|
|
|
75
73
|
const schemaPath = join(outDir, "better-auth-schema.ts");
|
|
76
74
|
const databasePath = join(outDir, "better-auth-db.ts");
|
|
77
75
|
const drizzleAdapterPath = fileURLToPath(import.meta.resolve("better-auth/adapters/drizzle"));
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
if (writeFileIfChanged(schemaPath, generateVoidAuthDrizzleSchema(authRuntime, env))) written.push(join(".void", "better-auth-schema.ts"));
|
|
77
|
+
if (writeFileIfChanged(databasePath, generateVoidAuthDatabaseModule({
|
|
80
78
|
dialect,
|
|
81
79
|
schemaImportPath: schemaPath,
|
|
82
80
|
drizzleAdapterPath
|
|
83
|
-
}));
|
|
84
|
-
written.push(join(".void", "better-auth-schema.ts"));
|
|
85
|
-
written.push(join(".void", "better-auth-db.ts"));
|
|
81
|
+
}))) written.push(join(".void", "better-auth-db.ts"));
|
|
86
82
|
} else {
|
|
87
83
|
removeGeneratedFile(outDir, "better-auth-schema.ts", removed);
|
|
88
84
|
removeGeneratedFile(outDir, "better-auth-db.ts", removed);
|
|
89
85
|
}
|
|
90
|
-
ensureProjectTsconfig(root, hasRouteTypes, hasDbRuntime, schema != null, { paths });
|
|
91
|
-
written.push(join(".void", "tsconfig.json"));
|
|
86
|
+
if (ensureProjectTsconfig(root, hasRouteTypes, hasDbRuntime, schema != null, { paths })) written.push(join(".void", "tsconfig.json"));
|
|
92
87
|
return {
|
|
93
88
|
written,
|
|
94
89
|
removed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as join, c as resolve } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
2
2
|
import { n as readProjectPaths } from "./project-paths-CCMrHYQm.mjs";
|
|
3
|
-
import { s as hasSsrEntry } from "./plugin-inference
|
|
3
|
+
import { s as hasSsrEntry } from "./plugin-inference--7geW5Z2.mjs";
|
|
4
4
|
import { i as readPackageJson, n as hasPackageDependency, t as getPackageDependencies } from "./package-json-B2TD0JLu.mjs";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
//#region src/cli/preset.ts
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import { a as join, s as relative } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
1
|
+
import { a as join, n as dirname, s as relative } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
2
2
|
import { n as readProjectPaths } from "./project-paths-CCMrHYQm.mjs";
|
|
3
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
//#region src/codegen/write-if-changed.ts
|
|
5
|
+
function writeFileIfChanged(path, content) {
|
|
6
|
+
let existing = null;
|
|
7
|
+
try {
|
|
8
|
+
existing = readFileSync(path, "utf8");
|
|
9
|
+
} catch (err) {
|
|
10
|
+
if (err.code !== "ENOENT") throw err;
|
|
11
|
+
}
|
|
12
|
+
if (existing === content) return false;
|
|
13
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
14
|
+
writeFileSync(path, content);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
4
18
|
//#region src/codegen/project-tsconfig.ts
|
|
5
19
|
/**
|
|
6
20
|
* Build the generated .void/tsconfig.json contents. Lists the generated
|
|
@@ -62,7 +76,7 @@ function ensureProjectTsconfig(root, hasRouteTypes, hasDb, hasSchema, options =
|
|
|
62
76
|
const outDir = join(root, ".void");
|
|
63
77
|
mkdirSync(outDir, { recursive: true });
|
|
64
78
|
const tsconfig = createProjectTsconfig(root, hasRouteTypes, hasDb, hasSchema, options);
|
|
65
|
-
|
|
79
|
+
return writeFileIfChanged(join(outDir, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n");
|
|
66
80
|
}
|
|
67
81
|
//#endregion
|
|
68
|
-
export { ensureProjectTsconfig as n, createProjectTsconfig as t };
|
|
82
|
+
export { ensureProjectTsconfig as n, writeFileIfChanged as r, createProjectTsconfig as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as HeadDescriptor, t as HeadConfig } from "./head-BsSTGnIe.mjs";
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as DevCssAsset } from "./types-
|
|
2
|
+
import { n as CloudBindings, r as CloudContext } from "./handler-hm9KldPP.mjs";
|
|
3
|
+
import { a as PageRenderMode, t as DevCssAsset } from "./types-DEWCqHtl.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/pages/protocol.d.ts
|
|
6
6
|
/** Escape characters that are unsafe inside inline <script> tags to prevent XSS. */
|
|
@@ -19,6 +19,9 @@ type PageObject = {
|
|
|
19
19
|
type PageRenderResult = string | ReadableStream<Uint8Array>;
|
|
20
20
|
type PageHandler = ((c: CloudContext) => unknown | Promise<unknown>) | undefined;
|
|
21
21
|
type PageHeadHandler = ((c: CloudContext, props: Record<string, unknown>) => HeadDescriptor | undefined) | undefined;
|
|
22
|
+
type PageRenderOptions = {
|
|
23
|
+
renderMode?: PageRenderMode;
|
|
24
|
+
};
|
|
22
25
|
type AssetTags = {
|
|
23
26
|
css: string;
|
|
24
27
|
preloads: string;
|
|
@@ -31,8 +34,8 @@ type GetAssetTags = (req: Request, env: CloudBindings, componentId: string) => P
|
|
|
31
34
|
/** Flatten withValidator's { issues: [{ slot, issues: [{ message, path }] }] } into { field: message } */
|
|
32
35
|
declare function flattenValidationErrors(body: unknown): Record<string, string>;
|
|
33
36
|
/** Handle GET page request — run handler, return page object or SSR HTML */
|
|
34
|
-
declare function handlePageGet(handler: PageHandler, headFn: PageHeadHandler, c: CloudContext, componentId: string, renderFn: RenderPage, getAssetTags: GetAssetTags, configHead?: HeadConfig,
|
|
37
|
+
declare function handlePageGet(handler: PageHandler, headFn: PageHeadHandler, c: CloudContext, componentId: string, renderFn: RenderPage, getAssetTags: GetAssetTags, configHead?: HeadConfig, options?: PageRenderOptions): Promise<Response>;
|
|
35
38
|
/** Handle POST/PUT/DELETE page request — run mutation, then re-run GET or redirect */
|
|
36
|
-
declare function handlePageMutation(mutationHandler: PageHandler, getHandler: PageHandler, headFn: PageHeadHandler, c: CloudContext, componentId: string, renderFn: RenderPage, getAssetTags: GetAssetTags, configHead?: HeadConfig,
|
|
39
|
+
declare function handlePageMutation(mutationHandler: PageHandler, getHandler: PageHandler, headFn: PageHeadHandler, c: CloudContext, componentId: string, renderFn: RenderPage, getAssetTags: GetAssetTags, configHead?: HeadConfig, options?: PageRenderOptions): Promise<Response>;
|
|
37
40
|
//#endregion
|
|
38
41
|
export { handlePageMutation as a, handlePageGet as i, PageRenderResult as n, safeJsonStringify as o, flattenValidationErrors as r, PageObject as t };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a as join, s as relative } from "./pathe.M-eThtNZ-BrPhGF_K.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { r as writeFileIfChanged } from "./project-tsconfig-BTNuNoJ0.mjs";
|
|
3
|
+
import { mkdirSync } from "node:fs";
|
|
3
4
|
//#region src/codegen/db-types.ts
|
|
4
5
|
const DRIZZLE_OPERATORS = "sql, eq, ne, gt, gte, lt, lte, and, or, not, desc, asc, like, ilike, notLike, inArray, notInArray, isNull, isNotNull, between, notBetween, exists, notExists, count, sum, avg, min, max";
|
|
5
6
|
/**
|
|
@@ -53,7 +54,7 @@ function generateDbDts(outDir, schema, dialect) {
|
|
|
53
54
|
"export type { DrizzleD1Database } from \"void/_db\";",
|
|
54
55
|
""
|
|
55
56
|
];
|
|
56
|
-
|
|
57
|
+
return writeFileIfChanged(join(outDir, "db.d.ts"), lines.join("\n"));
|
|
57
58
|
}
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region src/codegen/queue-types.ts
|