void 1.1.12 → 1.2.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/{account-cmd-Cj6sCMTk.mjs → account-cmd-CdUll_35.mjs} +5 -5
- package/dist/action-key-XZ9HkWAO.mjs +26 -0
- package/dist/{application-analysis-D7nNmNJb.mjs → application-analysis-fEqoSeMp.mjs} +11 -11
- package/dist/{application-routing-CZH66gXn.mjs → application-routing-DAhNP4u3.mjs} +1 -1
- package/dist/{ast-CPGPjb0V.mjs → ast-CsZ_q_gc.mjs} +6 -1
- package/dist/ast-bindings-C3yaPs1y.mjs +296 -0
- package/dist/{auth-link-Dj7lAC_K.mjs → auth-link-C87vGXM-.mjs} +5 -5
- package/dist/{auth-router-CNsMOFCa.mjs → auth-router-6I81r-ix.mjs} +3 -3
- package/dist/{better-auth-shared-Bv18bB-l.d.mts → better-auth-shared-DVk2DkTW.d.mts} +1 -1
- package/dist/{build-cmd-ByhegwRC.mjs → build-cmd-ex1g-j_e.mjs} +4 -4
- package/dist/{cache-CEFb5ban.mjs → cache-oHzrnY3z.mjs} +4 -4
- package/dist/{cancel-deploy-CaARY26n.mjs → cancel-deploy-viAMD0Q_.mjs} +3 -3
- package/dist/cf-build-output-BJHuSsVN.mjs +1 -0
- package/dist/{cf-build-output-ChEKWan2.mjs → cf-build-output-BhVxldCw.mjs} +4 -3
- package/dist/{cf-command-values-b8OqDoo9.mjs → cf-command-values-ByHk0xg4.mjs} +2 -1
- package/dist/cf-worker-settings-BECvvTVd.mjs +37 -0
- package/dist/cli/cli.mjs +32 -32
- package/dist/cli/cloudflare-operation-process.mjs +23 -13
- package/dist/cli/env-schema-probe.d.mts +1 -1
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/{client-BdzxubTS.mjs → client-BEkdj1kx.mjs} +1 -1
- package/dist/client-BiRDZTSd.mjs +1 -0
- package/dist/{cloudflare-auth-DSvBc1Gu.mjs → cloudflare-auth-Byo_0_N9.mjs} +1 -1
- package/dist/{cloudflare-cmd-D_2-Q-_i.mjs → cloudflare-cmd-DMzCv12s.mjs} +5 -5
- package/dist/{cloudflare-config-rdFOys4X.mjs → cloudflare-config-DchHxPTo.mjs} +1 -1
- package/dist/{cloudflare-connect-BN-k2kD-.mjs → cloudflare-connect-CCRTVg-I.mjs} +3 -3
- package/dist/{cloudflare-operations-D5PLrOqD.mjs → cloudflare-operations-Dh9dEHJj.mjs} +6 -6
- package/dist/{cloudflare-operations-BFLCpUCV.mjs → cloudflare-operations-DsSaw2BT.mjs} +1 -1
- package/dist/{cloudflare-process-CZJ4viYl.mjs → cloudflare-process-8jEYIeim.mjs} +3 -2
- package/dist/{config-DC5llZaI.mjs → config-BIaXIkkv.mjs} +8 -3
- package/dist/{config-DYJV8aEH.mjs → config-BU6hMu1W.mjs} +1 -1
- package/dist/{config-D26zcdKy.mjs → config-DHgSEWT7.mjs} +39 -6
- package/dist/{config-7qoq2p9v.d.mts → config-DQfHOKh9.d.mts} +10 -1
- package/dist/config-entry.d.mts +1 -1
- package/dist/{connect-C4_m2moF.mjs → connect-k7R2rPVA.mjs} +6 -6
- package/dist/{create-project-CvuYDD-l.mjs → create-project-DTuy-l0z.mjs} +1 -1
- package/dist/{create-project-D8jQTwVQ.mjs → create-project-DV71ol5d.mjs} +4 -4
- package/dist/{db-BsiOAa0A.mjs → db-DVOkLH5X.mjs} +30 -24
- package/dist/{delete-CAma7nFi.mjs → delete-BbP5eopu.mjs} +4 -4
- package/dist/{deploy-D1gIPiAq.mjs → deploy-7H32EnUs.mjs} +114 -71
- package/dist/deploy-CE0Ev0Ob.mjs +2 -0
- package/dist/{deploy-managed-static-B9KVxY3X.mjs → deploy-managed-static-DlvcvnQT.mjs} +15 -15
- package/dist/{deploy-transport-B3mtEi_q.mjs → deploy-transport-BzGEj0Ge.mjs} +2 -2
- package/dist/deploy.mjs +7 -7
- package/dist/{dev-inbox-Rd6j_8vM.mjs → dev-inbox-D0jxye_D.mjs} +1 -1
- package/dist/{dispatch-BAbbn3jg.mjs → dispatch-DoUnxTNo.mjs} +15 -11
- package/dist/{dist-CfgIkieS.mjs → dist-B1PLt4_8.mjs} +1 -1
- package/dist/{dist-BVdsO7Py.mjs → dist-Cor9XGoz.mjs} +94 -200
- package/dist/{dist-Bn8Kodjp.mjs → dist-D15hFhP0.mjs} +1 -1
- package/dist/{domain-BAdwm-QS.mjs → domain-CA2wBgra.mjs} +5 -5
- package/dist/drizzle-9TubSZvI.mjs +1 -0
- package/dist/{email-BcjSyAL0.mjs → email-B9ayYQEG.mjs} +1 -1
- package/dist/{email-MwjA7kaL.mjs → email-DXpCc77w.mjs} +10 -10
- package/dist/{email-cloudflare-etpKiITL.mjs → email-cloudflare-D03g2TkS.mjs} +7 -7
- package/dist/{entry-B_0IhV64.mjs → entry-BEM8ZuGP.mjs} +40 -12
- package/dist/{env-B163-G1s.mjs → env-DgOQ9_8S.mjs} +6 -6
- package/dist/{env-public-CCdykygU.d.mts → env-public-6lqiSD2b.d.mts} +1 -0
- package/dist/{env-types-GRchm5dw.mjs → env-types-BicfKBhV.mjs} +1 -1
- package/dist/{env-validation-CuGfWRJd.mjs → env-validation-BmsdCZEk.mjs} +1 -1
- package/dist/{env-validation-D_KyMdab.mjs → env-validation-Dwq3PJzK.mjs} +3 -3
- package/dist/{gen-CYN3wiov.mjs → gen-BfmcIi2g.mjs} +5 -5
- package/dist/gen-NrOlWZaG.mjs +1 -0
- package/dist/{github-cmd-C8QsnJQs.mjs → github-cmd-CY9LUqLh.mjs} +4 -4
- package/dist/{handler-D5K_yP6T.d.mts → handler-BbkSPzGF.d.mts} +90 -8
- package/dist/{headers-Bi4bOAwp.mjs → headers-D522zd0A.mjs} +2 -2
- package/dist/help-BeAFFE5C.mjs +1 -0
- package/dist/{help-B2sFwn9b.mjs → help-CxSlPpzJ.mjs} +40 -10
- package/dist/{inbound-BuTfm11U.mjs → inbound-VrOLqwZY.mjs} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +91 -57
- package/dist/{info-Bxunp14X.mjs → info-7VDlhtyy.mjs} +4 -4
- package/dist/{init-DGFQMnbk.mjs → init-DxYyOs4-.mjs} +103 -43
- package/dist/{link-CwrfpjIM.mjs → link-Ddmod1dZ.mjs} +5 -5
- package/dist/{list-hKoW5z-b.mjs → list-MogaugiO.mjs} +5 -5
- package/dist/{live-JheIDZKc.d.mts → live-Bt8Y_0bg.d.mts} +1 -1
- package/dist/{local-d1-CpaPbd_L.mjs → local-d1-BHBnKWRb.mjs} +1 -1
- package/dist/{log-vqY3pqwI.mjs → log-BMwmN5Ae.mjs} +2 -2
- package/dist/{login-f2eu2TQh.mjs → login-Cttnagmm.mjs} +4 -4
- package/dist/login-DgDwlKc_.mjs +1 -0
- package/dist/{logs-CEWqD-_B.mjs → logs-CAszUWZI.mjs} +4 -4
- package/dist/{migrate-DYfdWBXt.mjs → migrate-DyT2jJ8y.mjs} +5 -5
- package/dist/migrate-n49ZeS1X.mjs +1 -0
- package/dist/{mime-srOklVVv.mjs → mime-BAyHPskU.mjs} +1 -1
- package/dist/nitro.mjs +3 -3
- package/dist/{node-uN8_zxJr.mjs → node-WB7c2N4L.mjs} +2 -2
- package/dist/operator-cmd-d2MvJOrl.mjs +1 -0
- package/dist/{operator-cmd-DCr_QGMH.mjs → operator-cmd-skshjMGl.mjs} +4 -4
- package/dist/output-BW9uK099.mjs +1 -0
- package/dist/{output-CKguMgr7.mjs → output-BpgYODYx.mjs} +3 -3
- package/dist/pages/client.d.mts +1 -1
- package/dist/pages/client.mjs +30 -20
- package/dist/pages/index.d.mts +1 -1
- package/dist/pages/index.mjs +3 -3
- package/dist/pages/islands-plugin.mjs +2 -1
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +1 -1
- package/dist/{parse-filename-CUbj-1MP.mjs → parse-filename-DioPHiR9.mjs} +1 -35
- package/dist/{picocolors-BTps1_gs.mjs → picocolors-BsDfhxIw.mjs} +1 -1
- package/dist/{platform-args-B7ke06up.mjs → platform-args-DVbVClZl.mjs} +12 -4
- package/dist/platform-args-kQrgxScY.mjs +1 -0
- package/dist/{platform-auth-config-qGvEuns3.mjs → platform-auth-config-C-pm5Qzx.mjs} +6 -6
- package/dist/{platform-auth-protection-CyLcD6ot.mjs → platform-auth-protection-SHhvim1L.mjs} +4 -4
- package/dist/{platform-auth-recovery-B2LKI8V2.mjs → platform-auth-recovery-DXVWs-wA.mjs} +4 -4
- package/dist/{platform-cmd-CX7phm7V.mjs → platform-cmd-D5I1beUX.mjs} +7 -7
- package/dist/{platform-cmd-B2ec5eFg.mjs → platform-cmd-PiNRkopU.mjs} +1 -1
- package/dist/{platform-domain-DDNK2y-4.mjs → platform-domain-jpmBfZeb.mjs} +4 -4
- package/dist/{platform-lifecycle-CWc5gr6c.mjs → platform-lifecycle-DH3Yr1qQ.mjs} +1 -1
- package/dist/{platform-lifecycle-3CR98Tg2.mjs → platform-lifecycle-DyKmuNY6.mjs} +28 -17
- package/dist/{platform-management-o3LCCeE4.mjs → platform-management--vDwSn35.mjs} +11 -5
- package/dist/{platform-management-DAE6g2QU.mjs → platform-management-7m-PLaPJ.mjs} +1 -1
- package/dist/{platform-plans-config-CBMZxCep.mjs → platform-plans-config-CeydDSj0.mjs} +2 -2
- package/dist/{platform-recovery-Dmsg7lWA.mjs → platform-recovery-BiNpZZab.mjs} +2 -2
- package/dist/{platform-setup-hFbnWAVQ.mjs → platform-setup-Ca53gtt0.mjs} +3 -2
- package/dist/{plugin-inference-Bekzjuqw.mjs → plugin-inference-DUjCd55H.mjs} +145 -218
- package/dist/{prepare-HKo7Rh5V.mjs → prepare-BcAE5Sdj.mjs} +3 -3
- package/dist/prepare-C4I0f--h.mjs +1 -0
- package/dist/{prepare-DepAGBcV.mjs → prepare-DA-17DhO.mjs} +5 -5
- package/dist/{prerender-render-Bfsumdkv.mjs → prerender-render-Cijv7UFo.mjs} +11 -6
- package/dist/prerender-render.mjs +1 -1
- package/dist/{project-cmd-8ylYGx-O.mjs → project-cmd-DA4K5faU.mjs} +17 -17
- package/dist/{project-team-Bvpl78we.mjs → project-team-CQBNveX3.mjs} +4 -4
- package/dist/{project-token-QWHoJH2t.mjs → project-token-CCalFyQf.mjs} +4 -4
- package/dist/{project-zero-trust-8tJ-RFvu.mjs → project-zero-trust-DPnkiEuT.mjs} +4 -4
- package/dist/{protocol-Ssc_LhHj.d.mts → protocol-BBDpJz3G.d.mts} +3 -1
- package/dist/{protocol-bAUUkx70.mjs → protocol-DimNxVRr.mjs} +41 -16
- package/dist/{provision-BgXFDv0d.mjs → provision-BFLCrnUp.mjs} +1 -1
- package/dist/{provision-DZKYCEJg.mjs → provision-DtROpNNI.mjs} +3 -3
- package/dist/{requests-Vk5Zyhcy.mjs → requests-BpH0kImL.mjs} +3 -3
- package/dist/resolve-project-DD1vu8s9.mjs +1 -0
- package/dist/{resolve-project-WpwkCB_c.mjs → resolve-project-Xoi6eTWY.mjs} +1 -1
- package/dist/{rollback-CH4yMQys.mjs → rollback-CXS1tAa-.mjs} +4 -4
- package/dist/{rolldown-runtime-DXIUcv95.mjs → rolldown-runtime-3h0WiCiA.mjs} +1 -1
- package/dist/{routing-assets-VkrKIbxE.mjs → routing-assets-DdSFxoLp.mjs} +10 -4
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/email/testing.mjs +4 -4
- package/dist/runtime/email.mjs +3 -3
- package/dist/runtime/env-public.d.mts +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/routing.d.mts +17 -76
- package/dist/runtime/routing.mjs +277 -216
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +2 -2
- package/dist/runtime/ws.d.mts +1 -1
- package/dist/{scan-D2-FcLHs.mjs → scan-8IzYXiU_.mjs} +12 -11
- package/dist/{secret-wr6Sn4Xa.mjs → secret-BbXHfLAt.mjs} +6 -6
- package/dist/{skills-C_yRTg0g.mjs → skills-CrUO3PJ0.mjs} +1 -1
- package/dist/{subcommand-prompt-CNZc4XUd.mjs → subcommand-prompt-D9OhhbGG.mjs} +2 -2
- package/dist/{version-metadata-B1Bm2wSq.mjs → version-metadata-tS39iW09.mjs} +1 -1
- package/dist/wrangler-BLb3_luP.mjs +1 -0
- package/dist/{wrangler-C9XSzrju.mjs → wrangler-F96NnLyb.mjs} +13 -5
- package/dist/{wrapper-DGsYwNi6.mjs → wrapper-D3sZyh2C.mjs} +3 -3
- package/dist/{ws-nnFnAyQb.d.mts → ws-BH-im_tX.d.mts} +1 -1
- package/docs/guide/ai.md +1 -1
- package/docs/guide/database/postgresql.md +1 -1
- package/docs/guide/database.md +26 -0
- package/docs/guide/email/domains.md +1 -1
- package/docs/guide/pages-routing/actions-and-forms.md +1 -1
- package/docs/guide/platform/installation/credentials.md +1 -1
- package/docs/guide/platform/installation/domains.md +16 -0
- package/docs/guide/self-hosted-platform.md +1 -1
- package/docs/guide/server-routing.md +1 -1
- package/docs/integrations/cloudflare.md +1 -0
- package/docs/reference/api/env.md +1 -1
- package/docs/reference/api/rewrites.md +1 -1
- package/docs/reference/api/types.md +1 -0
- package/docs/reference/cli/platform-installation.md +3 -2
- package/docs/reference/cli/setup.md +17 -0
- package/docs/reference/config.md +13 -0
- package/docs/reference/resource-inference.md +4 -0
- package/package.json +22 -22
- package/sandbox.Dockerfile +1 -1
- package/schema.json +23 -3
- package/dist/cf-build-output-Dcmxa-Zm.mjs +0 -1
- package/dist/cf-user-agent-BkEHPDLA.mjs +0 -16
- package/dist/client-DAnfyMe9.mjs +0 -1
- package/dist/deploy-Dc0XsCQj.mjs +0 -2
- package/dist/gen-Cf-RBVg4.mjs +0 -1
- package/dist/help-w-xlx_kq.mjs +0 -1
- package/dist/login-08mBwZfI.mjs +0 -1
- package/dist/migrate-Di-4EuoE.mjs +0 -1
- package/dist/operator-cmd-Bv20yLu2.mjs +0 -1
- package/dist/platform-args-B_LrqEZB.mjs +0 -1
- package/dist/prepare-EVEbQ9n2.mjs +0 -1
- package/dist/resolve-project-PnhzMtY6.mjs +0 -1
- package/dist/wrangler-DAdxHEzh.mjs +0 -1
package/dist/runtime/routing.mjs
CHANGED
|
@@ -1,9 +1,249 @@
|
|
|
1
|
-
import { n as createClientAssetTags, r as createManifestLoader, t as ASSET_EXTENSIONS } from "../routing-assets-
|
|
1
|
+
import { n as createClientAssetTags, r as createManifestLoader, t as ASSET_EXTENSIONS } from "../routing-assets-DdSFxoLp.mjs";
|
|
2
2
|
import { t as convertReturnValue } from "../response-Tn7rU0MV.mjs";
|
|
3
|
-
import { n as
|
|
3
|
+
import { i as searchWithoutActionKey, n as hasActionKey, r as markActionKey, t as actionKeySegment } from "../action-key-XZ9HkWAO.mjs";
|
|
4
|
+
import { n as handlePageGet, r as handlePageMutation } from "../protocol-DimNxVRr.mjs";
|
|
4
5
|
import { t as VoidAssetRewriteError } from "../handler-BZ1t7-Rv.mjs";
|
|
5
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
6
7
|
import { compilePattern, matchPattern, matchPatternCaptures, mergeQueryIntoLocation, substituteParams } from "@void/edge";
|
|
8
|
+
//#region src/runtime/routing-worker.ts
|
|
9
|
+
const ASSET_CONTENT_TYPES = {
|
|
10
|
+
".avif": "image/avif",
|
|
11
|
+
".css": "text/css; charset=utf-8",
|
|
12
|
+
".gif": "image/gif",
|
|
13
|
+
".html": "text/html; charset=utf-8",
|
|
14
|
+
".ico": "image/x-icon",
|
|
15
|
+
".jpeg": "image/jpeg",
|
|
16
|
+
".jpg": "image/jpeg",
|
|
17
|
+
".js": "text/javascript; charset=utf-8",
|
|
18
|
+
".json": "application/json; charset=utf-8",
|
|
19
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
20
|
+
".png": "image/png",
|
|
21
|
+
".svg": "image/svg+xml",
|
|
22
|
+
".txt": "text/plain; charset=utf-8",
|
|
23
|
+
".wasm": "application/wasm",
|
|
24
|
+
".webp": "image/webp",
|
|
25
|
+
".woff": "font/woff",
|
|
26
|
+
".woff2": "font/woff2"
|
|
27
|
+
};
|
|
28
|
+
/** Apply native static policy before application middleware adds authored headers. */
|
|
29
|
+
function applyAssetCachePolicy(request, asset, assetsDir = "assets", fingerprinted = false) {
|
|
30
|
+
if (!["GET", "HEAD"].includes(request.method) || ![
|
|
31
|
+
200,
|
|
32
|
+
206,
|
|
33
|
+
304
|
|
34
|
+
].includes(asset.status)) return asset;
|
|
35
|
+
const pathname = new URL(request.url).pathname;
|
|
36
|
+
const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
|
|
37
|
+
const extension = filename.slice(filename.lastIndexOf(".")).toLowerCase();
|
|
38
|
+
const headers = new Headers(asset.headers);
|
|
39
|
+
if (!headers.has("Content-Type") && ASSET_CONTENT_TYPES[extension]) headers.set("Content-Type", ASSET_CONTENT_TYPES[extension]);
|
|
40
|
+
const policy = headers.get("Cache-Control");
|
|
41
|
+
const providerDefault = (policy ?? "").toLowerCase().split(",").map((part) => part.trim()).sort().join(",") === "max-age=0,must-revalidate,public";
|
|
42
|
+
const hashed = fingerprinted && pathname.startsWith("/" + assetsDir.replace(/^\/+|\/+$/g, "") + "/") && extension !== ".html" && !(headers.get("Content-Type") ?? "").toLowerCase().includes("text/html");
|
|
43
|
+
if (!headers.has("Set-Cookie") && hashed && (!policy || providerDefault)) headers.set("Cache-Control", "public, max-age=31536000, immutable");
|
|
44
|
+
else if (!policy) headers.set("Cache-Control", "no-store");
|
|
45
|
+
return new Response(asset.body, {
|
|
46
|
+
status: asset.status,
|
|
47
|
+
statusText: asset.statusText,
|
|
48
|
+
headers
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Public filenames are never evidence of a content fingerprint. */
|
|
52
|
+
function createAssetCachePolicy(assetsDir, loadManifest = createManifestLoader()) {
|
|
53
|
+
let files;
|
|
54
|
+
return async (request, env, asset) => {
|
|
55
|
+
const path = new URL(request.url).pathname;
|
|
56
|
+
if (!["GET", "HEAD"].includes(request.method) || ![
|
|
57
|
+
200,
|
|
58
|
+
206,
|
|
59
|
+
304
|
|
60
|
+
].includes(asset.status) || !path.startsWith("/" + (assetsDir ?? "assets").replace(/^\/+|\/+$/g, "") + "/")) return applyAssetCachePolicy(request, asset, assetsDir);
|
|
61
|
+
if (!files) files = loadManifest(request, env).then((manifest) => new Set(Object.values(manifest ?? {}).flatMap((entry) => Array.isArray(entry?.immutableFiles) ? entry.immutableFiles : [])), () => /* @__PURE__ */ new Set());
|
|
62
|
+
return applyAssetCachePolicy(request, asset, assetsDir, (await files).has(path.slice(1)));
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function createAssetFallback(options = {}) {
|
|
66
|
+
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
67
|
+
return async (request, env, response) => {
|
|
68
|
+
if (response.status !== 404 || !env.ASSETS || request.method !== "GET" && request.method !== "HEAD") return response;
|
|
69
|
+
const asset = await env.ASSETS.fetch(new Request(request.url, {
|
|
70
|
+
method: request.method,
|
|
71
|
+
headers: request.headers
|
|
72
|
+
}));
|
|
73
|
+
if (asset.status !== 404) return cachePolicy(request, env, asset);
|
|
74
|
+
const accept = request.headers.get("accept") ?? "";
|
|
75
|
+
if (options.serveSpaFallback && accept.includes("text/html")) {
|
|
76
|
+
const url = new URL("/index.html", request.url);
|
|
77
|
+
const index = await env.ASSETS.fetch(new Request(url, { method: request.method }));
|
|
78
|
+
if (index.status === 200) {
|
|
79
|
+
const res = new Response(index.body, {
|
|
80
|
+
status: 200,
|
|
81
|
+
headers: index.headers
|
|
82
|
+
});
|
|
83
|
+
res.headers.set("Cache-Control", "no-store");
|
|
84
|
+
res.headers.set("Content-Type", "text/html; charset=utf-8");
|
|
85
|
+
return res;
|
|
86
|
+
}
|
|
87
|
+
} else if (!options.serveSpaFallback && options.notFound === "404-page" && accept.includes("text/html") && (asset.headers.get("content-type") ?? "").includes("text/html")) {
|
|
88
|
+
const res = new Response(asset.body, asset);
|
|
89
|
+
res.headers.set("Cache-Control", "no-store");
|
|
90
|
+
return res;
|
|
91
|
+
}
|
|
92
|
+
return response;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Hide platform capabilities without copying bindings or changing application bindings. */
|
|
96
|
+
function filterInternalBindings(env, prefixes, exactNames = []) {
|
|
97
|
+
const hidden = (key) => typeof key === "string" && (prefixes.some((prefix) => key.startsWith(prefix)) || exactNames.includes(key));
|
|
98
|
+
return new Proxy(env, {
|
|
99
|
+
get: (target, prop, receiver) => hidden(prop) ? void 0 : Reflect.get(target, prop, receiver),
|
|
100
|
+
has: (target, prop) => !hidden(prop) && Reflect.has(target, prop),
|
|
101
|
+
ownKeys: (target) => Reflect.ownKeys(target).filter((key) => !hidden(key)),
|
|
102
|
+
getOwnPropertyDescriptor: (target, prop) => hidden(prop) ? void 0 : Reflect.getOwnPropertyDescriptor(target, prop)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function createWorkerFetch(options) {
|
|
106
|
+
return async (request, originalEnv, ctx) => {
|
|
107
|
+
const url = new URL(request.url);
|
|
108
|
+
const discovery = request.method === "POST" && url.pathname === "/__void/prerender-paths" && originalEnv.__VOID_PRERENDER === "1";
|
|
109
|
+
if (options.validateEnv && !discovery) await options.validateEnv(originalEnv);
|
|
110
|
+
const env = options.remoteEnv && originalEnv.__VOID_REMOTE === "1" ? options.remoteEnv(originalEnv) : originalEnv;
|
|
111
|
+
if (options.isr) {
|
|
112
|
+
env.__VOID_ISR_DEPLOYMENT_ID ??= options.isr.deploymentId;
|
|
113
|
+
env.__VOID_ISR_HOST = url.hostname;
|
|
114
|
+
}
|
|
115
|
+
return options.withRawEnv(env, () => options.withRuntimeEnv(env, async () => {
|
|
116
|
+
if (options.emailReceipt && url.pathname === "/__void/email/receipt/v1") return options.emailReceipt(request, env, ctx);
|
|
117
|
+
if (request.method === "GET" && url.pathname === "/__void/ready") {
|
|
118
|
+
const metadata = options.versionMetadataBinding ? env[options.versionMetadataBinding] : void 0;
|
|
119
|
+
return Response.json({
|
|
120
|
+
ready: true,
|
|
121
|
+
...options.versionMetadataBinding ? { versionId: metadata?.id } : {}
|
|
122
|
+
}, options.versionMetadataBinding ? { headers: { "cache-control": "no-store" } } : void 0);
|
|
123
|
+
}
|
|
124
|
+
const internal = await options.internalRoute(request, env, ctx);
|
|
125
|
+
if (internal) return internal;
|
|
126
|
+
if (discovery) return Response.json({ paths: await options.collectPrerenderPaths(request, env, ctx) });
|
|
127
|
+
const userEnv = options.filterBindings(env);
|
|
128
|
+
const render = async (req) => options.assets(req, env, await options.app.fetch(req, userEnv, ctx));
|
|
129
|
+
if (options.isr && env.ISR_CACHE && request.headers.get("upgrade")?.toLowerCase() !== "websocket") {
|
|
130
|
+
const cached = await options.isr.handle(request, env, ctx, render);
|
|
131
|
+
if (cached) return cached;
|
|
132
|
+
}
|
|
133
|
+
return render(request);
|
|
134
|
+
}));
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/runtime/routing-pages.ts
|
|
139
|
+
function actionNameOf(url) {
|
|
140
|
+
return new URL(url).searchParams.keys().next().value;
|
|
141
|
+
}
|
|
142
|
+
const routeHandlers = /* @__PURE__ */ new WeakSet();
|
|
143
|
+
const namedActionHandlers = /* @__PURE__ */ new WeakSet();
|
|
144
|
+
/** Records a handler that answers a route, so the marker can tell it from middleware. */
|
|
145
|
+
function markRouteHandler(handler) {
|
|
146
|
+
routeHandlers.add(handler);
|
|
147
|
+
return handler;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Runs before auth and user middleware, so a c.redirect() there leaves the
|
|
151
|
+
* action key out too. It marks the request only when a page with named actions
|
|
152
|
+
* is the route that will answer it, not when a broad page pattern also matches.
|
|
153
|
+
*
|
|
154
|
+
* `matchedRoutes` comes from 'hono/route' of the same Hono copy as the app: it
|
|
155
|
+
* reads the request through a Symbol that each copy defines for itself.
|
|
156
|
+
*/
|
|
157
|
+
function createNamedActionMarker(matchedRoutes) {
|
|
158
|
+
return async (c, next) => {
|
|
159
|
+
const answer = matchedRoutes(c).slice(c.req.routeIndex + 1).find((route) => routeHandlers.has(route.handler));
|
|
160
|
+
if (answer && namedActionHandlers.has(answer.handler) && actionNameOf(c.req.url)) markActionKey(c.req.raw);
|
|
161
|
+
await next();
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function createPageGetHandler(options) {
|
|
165
|
+
return markRouteHandler(async (context) => {
|
|
166
|
+
const mod = options.load ? await options.load() : { head: options.head };
|
|
167
|
+
return handlePageGet(mod.loader, mod.head, context, options.componentId, options.render, options.assets, options.headConfig ?? void 0, options.renderOptions);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function createPageMutationHandler(options) {
|
|
171
|
+
const mutationHandler = async (context) => {
|
|
172
|
+
const mod = options.load ? await options.load() : {};
|
|
173
|
+
const actionName = options.namedActions ? actionNameOf(context.req.url) : void 0;
|
|
174
|
+
const name = actionName || "default";
|
|
175
|
+
const named = mod.actions;
|
|
176
|
+
const candidate = named && Object.hasOwn(named, name) ? named[name] : void 0;
|
|
177
|
+
const handler = options.namedActions ? typeof candidate === "function" ? candidate : void 0 : mod.action;
|
|
178
|
+
if (options.namedActions && !handler) return new Response("Unknown action" + (actionName ? ": " + actionName : ""), { status: 404 });
|
|
179
|
+
if (actionName) markActionKey(context.req.raw);
|
|
180
|
+
return handlePageMutation(handler, mod.loader, mod.head, context, options.componentId, options.render, options.assets, options.headConfig ?? void 0, options.renderOptions);
|
|
181
|
+
};
|
|
182
|
+
if (options.namedActions) namedActionHandlers.add(mutationHandler);
|
|
183
|
+
return markRouteHandler(mutationHandler);
|
|
184
|
+
}
|
|
185
|
+
function createPagesFallback(options) {
|
|
186
|
+
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
187
|
+
return async (c) => {
|
|
188
|
+
const path = c.req.path;
|
|
189
|
+
if (path === "/api" || path.startsWith("/api/") || c.req.method !== "GET" && c.req.method !== "HEAD") return c.text("Not Found", 404);
|
|
190
|
+
const assets = c.env?.ASSETS;
|
|
191
|
+
const assetResponse = assets && typeof assets.fetch === "function" ? await assets.fetch(c.req.raw) : options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
|
|
192
|
+
if (assetResponse.status !== 404) return cachePolicy(c.req.raw, c.env, assetResponse);
|
|
193
|
+
const fallback = options.fallbackRules ? await options.routing.applyFallback(c, options.fallbackRules) : void 0;
|
|
194
|
+
if (fallback) return fallback;
|
|
195
|
+
if (path.includes("/.") || path.substring(path.lastIndexOf("/") + 1).includes(".")) return options.errors.serveCustomPage(c, 404, "Not Found");
|
|
196
|
+
if (path !== "/" && path.endsWith("/")) {
|
|
197
|
+
const url = new URL(c.req.url);
|
|
198
|
+
url.pathname = path.slice(0, -1);
|
|
199
|
+
return Response.redirect(url.href, 301);
|
|
200
|
+
}
|
|
201
|
+
return options.routing.markNoMatch(c.req.raw, await options.errors.serveCustomPage(c, 404, "Not Found"));
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function createSsrFallback(options) {
|
|
205
|
+
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
206
|
+
const fetchAssets = async (c) => {
|
|
207
|
+
const binding = c.env?.ASSETS;
|
|
208
|
+
if (!binding || typeof binding.fetch !== "function") return options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
|
|
209
|
+
const response = await binding.fetch(c.req.raw);
|
|
210
|
+
return response.status === 404 ? options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 })) : cachePolicy(c.req.raw, c.env, response);
|
|
211
|
+
};
|
|
212
|
+
return async (c) => {
|
|
213
|
+
if (options.nodeTarget && options.fallbackRules) {
|
|
214
|
+
const fallback = await options.routing.applyFallback(c, options.fallbackRules);
|
|
215
|
+
if (fallback) return fallback;
|
|
216
|
+
}
|
|
217
|
+
const path = c.req.path;
|
|
218
|
+
const destination = c.req.header("sec-fetch-dest");
|
|
219
|
+
if (path === "/api" || path.startsWith("/api/") || /\/[^/]+\.[^/]+$/.test(path) || destination && destination !== "document" && destination !== "empty") {
|
|
220
|
+
const response = await fetchAssets(c);
|
|
221
|
+
if (!options.nodeTarget && options.fallbackRules && response.status === 404) {
|
|
222
|
+
const fallback = await options.routing.applyFallback(c, options.fallbackRules);
|
|
223
|
+
if (fallback) return fallback;
|
|
224
|
+
}
|
|
225
|
+
return response;
|
|
226
|
+
}
|
|
227
|
+
const mod = await options.load();
|
|
228
|
+
const render = typeof mod.render === "function" ? mod.render : mod.default;
|
|
229
|
+
if (typeof render !== "function") throw new Error("ssr: Invalid entry. Export render(c, assetTags).");
|
|
230
|
+
return render(c, await options.assets(c.req.raw, c.env));
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function createAssetNotFound(options) {
|
|
234
|
+
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
235
|
+
return async (c) => {
|
|
236
|
+
if (!options.nodeTarget) {
|
|
237
|
+
const assets = c.env?.ASSETS;
|
|
238
|
+
if (assets && typeof assets.fetch === "function") {
|
|
239
|
+
const response = await assets.fetch(c.req.raw);
|
|
240
|
+
if (response.status !== 404) return cachePolicy(c.req.raw, c.env, response);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return (options.fallbackRules ? await options.routing.applyFallback(c, options.fallbackRules) : void 0) ?? options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
7
247
|
//#region src/runtime/routing-errors.ts
|
|
8
248
|
const ERROR_PAGE_FONT_STACK = "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
|
|
9
249
|
const errorStack = Error;
|
|
@@ -563,217 +803,6 @@ function createErrorRenderer(options) {
|
|
|
563
803
|
};
|
|
564
804
|
}
|
|
565
805
|
//#endregion
|
|
566
|
-
//#region src/runtime/routing-worker.ts
|
|
567
|
-
const ASSET_CONTENT_TYPES = {
|
|
568
|
-
".avif": "image/avif",
|
|
569
|
-
".css": "text/css; charset=utf-8",
|
|
570
|
-
".gif": "image/gif",
|
|
571
|
-
".html": "text/html; charset=utf-8",
|
|
572
|
-
".ico": "image/x-icon",
|
|
573
|
-
".jpeg": "image/jpeg",
|
|
574
|
-
".jpg": "image/jpeg",
|
|
575
|
-
".js": "text/javascript; charset=utf-8",
|
|
576
|
-
".json": "application/json; charset=utf-8",
|
|
577
|
-
".mjs": "text/javascript; charset=utf-8",
|
|
578
|
-
".png": "image/png",
|
|
579
|
-
".svg": "image/svg+xml",
|
|
580
|
-
".txt": "text/plain; charset=utf-8",
|
|
581
|
-
".wasm": "application/wasm",
|
|
582
|
-
".webp": "image/webp",
|
|
583
|
-
".woff": "font/woff",
|
|
584
|
-
".woff2": "font/woff2"
|
|
585
|
-
};
|
|
586
|
-
/** Apply native static policy before application middleware adds authored headers. */
|
|
587
|
-
function applyAssetCachePolicy(request, asset, assetsDir = "assets", fingerprinted = false) {
|
|
588
|
-
if (!["GET", "HEAD"].includes(request.method) || ![
|
|
589
|
-
200,
|
|
590
|
-
206,
|
|
591
|
-
304
|
|
592
|
-
].includes(asset.status)) return asset;
|
|
593
|
-
const pathname = new URL(request.url).pathname;
|
|
594
|
-
const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
|
|
595
|
-
const extension = filename.slice(filename.lastIndexOf(".")).toLowerCase();
|
|
596
|
-
const headers = new Headers(asset.headers);
|
|
597
|
-
if (!headers.has("Content-Type") && ASSET_CONTENT_TYPES[extension]) headers.set("Content-Type", ASSET_CONTENT_TYPES[extension]);
|
|
598
|
-
const policy = headers.get("Cache-Control");
|
|
599
|
-
const providerDefault = (policy ?? "").toLowerCase().split(",").map((part) => part.trim()).sort().join(",") === "max-age=0,must-revalidate,public";
|
|
600
|
-
const hashed = fingerprinted && pathname.startsWith("/" + assetsDir.replace(/^\/+|\/+$/g, "") + "/") && extension !== ".html" && !(headers.get("Content-Type") ?? "").toLowerCase().includes("text/html");
|
|
601
|
-
if (!headers.has("Set-Cookie") && hashed && (!policy || providerDefault)) headers.set("Cache-Control", "public, max-age=31536000, immutable");
|
|
602
|
-
else if (!policy) headers.set("Cache-Control", "no-store");
|
|
603
|
-
return new Response(asset.body, {
|
|
604
|
-
status: asset.status,
|
|
605
|
-
statusText: asset.statusText,
|
|
606
|
-
headers
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
/** Public filenames are never evidence of a content fingerprint. */
|
|
610
|
-
function createAssetCachePolicy(assetsDir, loadManifest = createManifestLoader()) {
|
|
611
|
-
let files;
|
|
612
|
-
return async (request, env, asset) => {
|
|
613
|
-
const path = new URL(request.url).pathname;
|
|
614
|
-
if (!["GET", "HEAD"].includes(request.method) || ![
|
|
615
|
-
200,
|
|
616
|
-
206,
|
|
617
|
-
304
|
|
618
|
-
].includes(asset.status) || !path.startsWith("/" + (assetsDir ?? "assets").replace(/^\/+|\/+$/g, "") + "/")) return applyAssetCachePolicy(request, asset, assetsDir);
|
|
619
|
-
if (!files) files = loadManifest(request, env).then((manifest) => new Set(Object.values(manifest ?? {}).flatMap((entry) => Array.isArray(entry?.immutableFiles) ? entry.immutableFiles : [])), () => /* @__PURE__ */ new Set());
|
|
620
|
-
return applyAssetCachePolicy(request, asset, assetsDir, (await files).has(path.slice(1)));
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
function createAssetFallback(options = {}) {
|
|
624
|
-
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
625
|
-
return async (request, env, response) => {
|
|
626
|
-
if (response.status !== 404 || !env.ASSETS || request.method !== "GET" && request.method !== "HEAD") return response;
|
|
627
|
-
const asset = await env.ASSETS.fetch(new Request(request.url, {
|
|
628
|
-
method: request.method,
|
|
629
|
-
headers: request.headers
|
|
630
|
-
}));
|
|
631
|
-
if (asset.status !== 404) return cachePolicy(request, env, asset);
|
|
632
|
-
const accept = request.headers.get("accept") ?? "";
|
|
633
|
-
if (options.serveSpaFallback && accept.includes("text/html")) {
|
|
634
|
-
const url = new URL("/index.html", request.url);
|
|
635
|
-
const index = await env.ASSETS.fetch(new Request(url, { method: request.method }));
|
|
636
|
-
if (index.status === 200) {
|
|
637
|
-
const res = new Response(index.body, {
|
|
638
|
-
status: 200,
|
|
639
|
-
headers: index.headers
|
|
640
|
-
});
|
|
641
|
-
res.headers.set("Cache-Control", "no-store");
|
|
642
|
-
res.headers.set("Content-Type", "text/html; charset=utf-8");
|
|
643
|
-
return res;
|
|
644
|
-
}
|
|
645
|
-
} else if (!options.serveSpaFallback && options.notFound === "404-page" && accept.includes("text/html") && (asset.headers.get("content-type") ?? "").includes("text/html")) {
|
|
646
|
-
const res = new Response(asset.body, asset);
|
|
647
|
-
res.headers.set("Cache-Control", "no-store");
|
|
648
|
-
return res;
|
|
649
|
-
}
|
|
650
|
-
return response;
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
/** Hide platform capabilities without copying bindings or changing application bindings. */
|
|
654
|
-
function filterInternalBindings(env, prefixes, exactNames = []) {
|
|
655
|
-
const hidden = (key) => typeof key === "string" && (prefixes.some((prefix) => key.startsWith(prefix)) || exactNames.includes(key));
|
|
656
|
-
return new Proxy(env, {
|
|
657
|
-
get: (target, prop, receiver) => hidden(prop) ? void 0 : Reflect.get(target, prop, receiver),
|
|
658
|
-
has: (target, prop) => !hidden(prop) && Reflect.has(target, prop),
|
|
659
|
-
ownKeys: (target) => Reflect.ownKeys(target).filter((key) => !hidden(key)),
|
|
660
|
-
getOwnPropertyDescriptor: (target, prop) => hidden(prop) ? void 0 : Reflect.getOwnPropertyDescriptor(target, prop)
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
function createWorkerFetch(options) {
|
|
664
|
-
return async (request, originalEnv, ctx) => {
|
|
665
|
-
const url = new URL(request.url);
|
|
666
|
-
const discovery = request.method === "POST" && url.pathname === "/__void/prerender-paths" && originalEnv.__VOID_PRERENDER === "1";
|
|
667
|
-
if (options.validateEnv && !discovery) await options.validateEnv(originalEnv);
|
|
668
|
-
const env = options.remoteEnv && originalEnv.__VOID_REMOTE === "1" ? options.remoteEnv(originalEnv) : originalEnv;
|
|
669
|
-
if (options.isr) {
|
|
670
|
-
env.__VOID_ISR_DEPLOYMENT_ID ??= options.isr.deploymentId;
|
|
671
|
-
env.__VOID_ISR_HOST = url.hostname;
|
|
672
|
-
}
|
|
673
|
-
return options.withRawEnv(env, () => options.withRuntimeEnv(env, async () => {
|
|
674
|
-
if (options.emailReceipt && url.pathname === "/__void/email/receipt/v1") return options.emailReceipt(request, env, ctx);
|
|
675
|
-
if (request.method === "GET" && url.pathname === "/__void/ready") {
|
|
676
|
-
const metadata = options.versionMetadataBinding ? env[options.versionMetadataBinding] : void 0;
|
|
677
|
-
return Response.json({
|
|
678
|
-
ready: true,
|
|
679
|
-
...options.versionMetadataBinding ? { versionId: metadata?.id } : {}
|
|
680
|
-
}, options.versionMetadataBinding ? { headers: { "cache-control": "no-store" } } : void 0);
|
|
681
|
-
}
|
|
682
|
-
const internal = await options.internalRoute(request, env, ctx);
|
|
683
|
-
if (internal) return internal;
|
|
684
|
-
if (discovery) return Response.json({ paths: await options.collectPrerenderPaths(request, env, ctx) });
|
|
685
|
-
const userEnv = options.filterBindings(env);
|
|
686
|
-
const render = async (req) => options.assets(req, env, await options.app.fetch(req, userEnv, ctx));
|
|
687
|
-
if (options.isr && env.ISR_CACHE && request.headers.get("upgrade")?.toLowerCase() !== "websocket") {
|
|
688
|
-
const cached = await options.isr.handle(request, env, ctx, render);
|
|
689
|
-
if (cached) return cached;
|
|
690
|
-
}
|
|
691
|
-
return render(request);
|
|
692
|
-
}));
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
//#endregion
|
|
696
|
-
//#region src/runtime/routing-pages.ts
|
|
697
|
-
function createPageGetHandler(options) {
|
|
698
|
-
return async (context) => {
|
|
699
|
-
const mod = options.load ? await options.load() : { head: options.head };
|
|
700
|
-
return handlePageGet(mod.loader, mod.head, context, options.componentId, options.render, options.assets, options.headConfig ?? void 0, options.renderOptions);
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
function createPageMutationHandler(options) {
|
|
704
|
-
return async (context) => {
|
|
705
|
-
const mod = options.load ? await options.load() : {};
|
|
706
|
-
const actionName = options.namedActions ? new URL(context.req.url).searchParams.keys().next().value : void 0;
|
|
707
|
-
const name = actionName || "default";
|
|
708
|
-
const named = mod.actions;
|
|
709
|
-
const candidate = named && Object.hasOwn(named, name) ? named[name] : void 0;
|
|
710
|
-
const handler = options.namedActions ? typeof candidate === "function" ? candidate : void 0 : mod.action;
|
|
711
|
-
if (options.namedActions && !handler) return new Response("Unknown action" + (actionName ? ": " + actionName : ""), { status: 404 });
|
|
712
|
-
return handlePageMutation(handler, mod.loader, mod.head, context, options.componentId, options.render, options.assets, options.headConfig ?? void 0, options.renderOptions);
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
function createPagesFallback(options) {
|
|
716
|
-
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
717
|
-
return async (c) => {
|
|
718
|
-
const path = c.req.path;
|
|
719
|
-
if (path === "/api" || path.startsWith("/api/") || c.req.method !== "GET" && c.req.method !== "HEAD") return c.text("Not Found", 404);
|
|
720
|
-
const assets = c.env?.ASSETS;
|
|
721
|
-
const assetResponse = assets && typeof assets.fetch === "function" ? await assets.fetch(c.req.raw) : options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
|
|
722
|
-
if (assetResponse.status !== 404) return cachePolicy(c.req.raw, c.env, assetResponse);
|
|
723
|
-
const fallback = options.fallbackRules ? await options.routing.applyFallback(c, options.fallbackRules) : void 0;
|
|
724
|
-
if (fallback) return fallback;
|
|
725
|
-
if (path.includes("/.") || path.substring(path.lastIndexOf("/") + 1).includes(".")) return options.errors.serveCustomPage(c, 404, "Not Found");
|
|
726
|
-
if (path !== "/" && path.endsWith("/")) {
|
|
727
|
-
const url = new URL(c.req.url);
|
|
728
|
-
url.pathname = path.slice(0, -1);
|
|
729
|
-
return Response.redirect(url.href, 301);
|
|
730
|
-
}
|
|
731
|
-
return options.routing.markNoMatch(c.req.raw, await options.errors.serveCustomPage(c, 404, "Not Found"));
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
function createSsrFallback(options) {
|
|
735
|
-
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
736
|
-
const fetchAssets = async (c) => {
|
|
737
|
-
const binding = c.env?.ASSETS;
|
|
738
|
-
if (!binding || typeof binding.fetch !== "function") return options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
|
|
739
|
-
const response = await binding.fetch(c.req.raw);
|
|
740
|
-
return response.status === 404 ? options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 })) : cachePolicy(c.req.raw, c.env, response);
|
|
741
|
-
};
|
|
742
|
-
return async (c) => {
|
|
743
|
-
if (options.nodeTarget && options.fallbackRules) {
|
|
744
|
-
const fallback = await options.routing.applyFallback(c, options.fallbackRules);
|
|
745
|
-
if (fallback) return fallback;
|
|
746
|
-
}
|
|
747
|
-
const path = c.req.path;
|
|
748
|
-
const destination = c.req.header("sec-fetch-dest");
|
|
749
|
-
if (path === "/api" || path.startsWith("/api/") || /\/[^/]+\.[^/]+$/.test(path) || destination && destination !== "document" && destination !== "empty") {
|
|
750
|
-
const response = await fetchAssets(c);
|
|
751
|
-
if (!options.nodeTarget && options.fallbackRules && response.status === 404) {
|
|
752
|
-
const fallback = await options.routing.applyFallback(c, options.fallbackRules);
|
|
753
|
-
if (fallback) return fallback;
|
|
754
|
-
}
|
|
755
|
-
return response;
|
|
756
|
-
}
|
|
757
|
-
const mod = await options.load();
|
|
758
|
-
const render = typeof mod.render === "function" ? mod.render : mod.default;
|
|
759
|
-
if (typeof render !== "function") throw new Error("ssr: Invalid entry. Export render(c, assetTags).");
|
|
760
|
-
return render(c, await options.assets(c.req.raw, c.env));
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
function createAssetNotFound(options) {
|
|
764
|
-
const cachePolicy = createAssetCachePolicy(options.assetsDir);
|
|
765
|
-
return async (c) => {
|
|
766
|
-
if (!options.nodeTarget) {
|
|
767
|
-
const assets = c.env?.ASSETS;
|
|
768
|
-
if (assets && typeof assets.fetch === "function") {
|
|
769
|
-
const response = await assets.fetch(c.req.raw);
|
|
770
|
-
if (response.status !== 404) return cachePolicy(c.req.raw, c.env, response);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
return (options.fallbackRules ? await options.routing.applyFallback(c, options.fallbackRules) : void 0) ?? options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
//#endregion
|
|
777
806
|
//#region src/runtime/routing.ts
|
|
778
807
|
/** One state owner per generated app: recursive dispatch shares rewrite and fallback guards. */
|
|
779
808
|
function createRoutingRuntime(app, options = {}) {
|
|
@@ -824,6 +853,7 @@ function createRoutingRuntime(app, options = {}) {
|
|
|
824
853
|
if (search) rewriteUrl.search = search;
|
|
825
854
|
const request = new Request(rewriteUrl.toString(), c.req.raw);
|
|
826
855
|
rememberOriginal(request, c);
|
|
856
|
+
keepActionKey(c.req.raw, request, search);
|
|
827
857
|
if (fallback) fallbackHandled.add(request);
|
|
828
858
|
const response = await dispatch(request, c);
|
|
829
859
|
const kind = rule.force === true ? "rewrite" : "fallback";
|
|
@@ -854,11 +884,12 @@ function createRoutingRuntime(app, options = {}) {
|
|
|
854
884
|
if (search) url.search = search;
|
|
855
885
|
const request = new Request(url.toString(), c.req.raw);
|
|
856
886
|
rememberOriginal(request, c);
|
|
887
|
+
keepActionKey(c.req.raw, request, search);
|
|
857
888
|
return dispatch(request, c).then((response) => annotate(response, `c.rewrite -> ${path} (middleware)`));
|
|
858
889
|
};
|
|
859
890
|
const redirect = c.redirect.bind(c);
|
|
860
891
|
c.redirect = (location, status) => {
|
|
861
|
-
if (typeof location === "string" && location.startsWith("/") && !location.startsWith("//")) return redirect(
|
|
892
|
+
if (typeof location === "string" && location.startsWith("/") && !location.startsWith("//")) return redirect(redirectLocation(c.req.raw, location, status), status);
|
|
862
893
|
return redirect(location, status);
|
|
863
894
|
};
|
|
864
895
|
c.originalUrl = () => originalUrls.get(c.req.raw) ?? null;
|
|
@@ -909,6 +940,36 @@ function createRoutingRuntime(app, options = {}) {
|
|
|
909
940
|
markNoMatch
|
|
910
941
|
};
|
|
911
942
|
}
|
|
943
|
+
function redirectLocation(request, location, status) {
|
|
944
|
+
const url = new URL(request.url);
|
|
945
|
+
const search = url.search;
|
|
946
|
+
if (!hasActionKey(request)) return mergeQueryIntoLocation(location, search);
|
|
947
|
+
if (status === 303 || (status === void 0 || status === 301 || status === 302) && request.method === "POST") return mergeQueryIntoLocation(location, searchWithoutActionKey(search));
|
|
948
|
+
const hash = location.indexOf("#");
|
|
949
|
+
const destinationQuery = location.indexOf("?");
|
|
950
|
+
if (destinationQuery === -1 || hash !== -1 && hash < destinationQuery) return mergeQueryIntoLocation(location, search);
|
|
951
|
+
const merged = mergeQueryIntoLocation(location, searchWithoutActionKey(search));
|
|
952
|
+
if (actionKeySegment(location.slice(destinationQuery, hash === -1 ? location.length : hash)) && new URL(location, url).pathname === url.pathname) return merged;
|
|
953
|
+
const mergedHash = merged.indexOf("#");
|
|
954
|
+
const base = mergedHash === -1 ? merged : merged.slice(0, mergedHash);
|
|
955
|
+
const fragment = mergedHash === -1 ? "" : merged.slice(mergedHash);
|
|
956
|
+
const q = base.indexOf("?");
|
|
957
|
+
const segments = q === -1 ? [] : base.slice(q + 1).split("&");
|
|
958
|
+
const key = actionKeySegment(search);
|
|
959
|
+
const name = queryKey(key);
|
|
960
|
+
const hasName = (segment) => segment !== "" && queryKey(segment) === name;
|
|
961
|
+
const own = location.slice(destinationQuery + 1, hash === -1 ? location.length : hash).split("&").some(hasName) ? segments.findIndex(hasName) : -1;
|
|
962
|
+
const first = own === -1 ? key : segments.splice(own, 1)[0];
|
|
963
|
+
const rest = segments.join("&");
|
|
964
|
+
return base.slice(0, q === -1 ? base.length : q) + "?" + first + (rest ? "&" + rest : "") + fragment;
|
|
965
|
+
}
|
|
966
|
+
function queryKey(segment) {
|
|
967
|
+
return new URLSearchParams(segment).keys().next().value;
|
|
968
|
+
}
|
|
969
|
+
/** A rewrite that keeps the query keeps the action key in it too. */
|
|
970
|
+
function keepActionKey(from, to, destinationSearch) {
|
|
971
|
+
if (!destinationSearch && hasActionKey(from)) markActionKey(to);
|
|
972
|
+
}
|
|
912
973
|
function markNoMatch(request, response) {
|
|
913
974
|
const url = new URL(request.url);
|
|
914
975
|
if (response.status !== 404 || request.method !== "GET" && request.method !== "HEAD" || url.pathname === "/api" || url.pathname.startsWith("/api/") || /\/[^/]+\.[^/]+$/.test(url.pathname)) return response;
|
|
@@ -921,7 +982,7 @@ function markNoMatch(request, response) {
|
|
|
921
982
|
});
|
|
922
983
|
}
|
|
923
984
|
function createHttpRouteHandler(load, method) {
|
|
924
|
-
return async (c) => convertReturnValue(await (await load())[method](c));
|
|
985
|
+
return markRouteHandler(async (c) => convertReturnValue(await (await load())[method](c)));
|
|
925
986
|
}
|
|
926
987
|
function createModuleLoader(load, cache = true) {
|
|
927
988
|
let module;
|
|
@@ -932,4 +993,4 @@ function createModuleLoader(load, cache = true) {
|
|
|
932
993
|
};
|
|
933
994
|
}
|
|
934
995
|
//#endregion
|
|
935
|
-
export { createAssetFallback, createAssetNotFound, createClientAssetTags, createErrorRenderer, createHttpRouteHandler, createManifestLoader, createModuleLoader, createPageGetHandler, createPageMutationHandler, createPagesFallback, createRoutingRuntime, createSsrFallback, createWorkerFetch, filterInternalBindings, markNoMatch };
|
|
996
|
+
export { createAssetFallback, createAssetNotFound, createClientAssetTags, createErrorRenderer, createHttpRouteHandler, createManifestLoader, createModuleLoader, createNamedActionMarker, createPageGetHandler, createPageMutationHandler, createPagesFallback, createRoutingRuntime, createSsrFallback, createWorkerFetch, filterInternalBindings, markNoMatch, markRouteHandler };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { D as runValidation, E as ValidatorSlots, T as HandlerInput } from "../handler-
|
|
1
|
+
import { D as runValidation, E as ValidatorSlots, T as HandlerInput } from "../handler-BbkSPzGF.mjs";
|
|
2
2
|
export { HandlerInput, ValidatorSlots, runValidation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as AuthState } from "../auth-DkcFflXV.mjs";
|
|
2
|
-
import { r as VoidAuthRuntimeOptions, t as VoidAuthEnv } from "../better-auth-shared-
|
|
3
|
-
import { f as WebSocketInstanceKey, t as AnyWebSocketDefinition } from "../ws-
|
|
2
|
+
import { r as VoidAuthRuntimeOptions, t as VoidAuthEnv } from "../better-auth-shared-DVk2DkTW.mjs";
|
|
3
|
+
import { f as WebSocketInstanceKey, t as AnyWebSocketDefinition } from "../ws-BH-im_tX.mjs";
|
|
4
4
|
//#region src/runtime/ws-server.d.ts
|
|
5
5
|
export type WebSocketRouteMeta = {
|
|
6
6
|
name?: string;
|
package/dist/runtime/ws.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RoomDefinition, c as VoidSocket, d as WebSocketConnection, f as WebSocketInstanceKey, h as defineWebSocket, i as RoomController, l as VoidSocketCloseEvent, m as defineRoom, n as ConnectCommonOptions, o as SocketContext, p as connect, r as RoomContext, s as SocketDefinition, t as AnyWebSocketDefinition, u as WebSocketBaseContext } from "../ws-
|
|
1
|
+
import { a as RoomDefinition, c as VoidSocket, d as WebSocketConnection, f as WebSocketInstanceKey, h as defineWebSocket, i as RoomController, l as VoidSocketCloseEvent, m as defineRoom, n as ConnectCommonOptions, o as SocketContext, p as connect, r as RoomContext, s as SocketDefinition, t as AnyWebSocketDefinition, u as WebSocketBaseContext } from "../ws-BH-im_tX.mjs";
|
|
2
2
|
export { AnyWebSocketDefinition, ConnectCommonOptions, RoomContext, RoomController, RoomDefinition, SocketContext, SocketDefinition, VoidSocket, VoidSocketCloseEvent, WebSocketBaseContext, WebSocketConnection, WebSocketInstanceKey, connect, defineRoom, defineWebSocket };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { a as join, n as dirname, r as extname, t as basename } from "./dist-ipQi0Q8y.mjs";
|
|
2
2
|
import { n as readProjectPaths } from "./project-paths-DGu_QZ_Q.mjs";
|
|
3
|
-
import { t as glob } from "./dist-
|
|
4
|
-
import { n as isIdentifier, r as isLiteral } from "./ast-
|
|
5
|
-
import { a as staticLiteral, i as staticExportInitializers,
|
|
6
|
-
import {
|
|
3
|
+
import { t as glob } from "./dist-D15hFhP0.mjs";
|
|
4
|
+
import { n as isIdentifier, o as moduleExportName, r as isLiteral } from "./ast-CsZ_q_gc.mjs";
|
|
5
|
+
import { a as staticLiteral, i as staticExportInitializers, t as bindingNames } from "./ast-bindings-C3yaPs1y.mjs";
|
|
6
|
+
import { n as parseRouteFilename } from "./parse-filename-DioPHiR9.mjs";
|
|
7
|
+
import { i as voidWarn } from "./log-BMwmN5Ae.mjs";
|
|
7
8
|
import { t as MagicString } from "./dist-Cegxq8gs.mjs";
|
|
8
9
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
10
|
import { parseSync } from "vite";
|
|
@@ -209,11 +210,10 @@ function detectPageServerMetadata(source, filename) {
|
|
|
209
210
|
if (declaration?.type === "VariableDeclaration") {
|
|
210
211
|
const variables = declaration;
|
|
211
212
|
for (const variable of variables.declarations ?? []) {
|
|
212
|
-
|
|
213
|
-
const name = variable.id.name;
|
|
214
|
-
if (PAGE_METHODS.has(name)) metadata.methods.push(name);
|
|
213
|
+
for (const name of bindingNames(variable.id)) if (PAGE_METHODS.has(name)) metadata.methods.push(name);
|
|
215
214
|
else if (name === "getPrerenderPaths") metadata.hasGetPrerenderPaths = true;
|
|
216
|
-
|
|
215
|
+
if (isIdentifier(variable.id) && variables.kind === "const") {
|
|
216
|
+
const name = variable.id.name;
|
|
217
217
|
if (name === "revalidate") {
|
|
218
218
|
const value = readLiteral(variable.init);
|
|
219
219
|
if (typeof value === "number" && Number.isInteger(value) && value >= 0) metadata.revalidate = value;
|
|
@@ -231,9 +231,10 @@ function detectPageServerMetadata(source, filename) {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
for (const specifier of exported.specifiers ?? []) {
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
|
|
234
|
+
const name = moduleExportName(specifier.exported);
|
|
235
|
+
if (specifier.exportKind === "type" || name === void 0) continue;
|
|
236
|
+
if (PAGE_METHODS.has(name)) metadata.methods.push(name);
|
|
237
|
+
else if (name === "getPrerenderPaths") metadata.hasGetPrerenderPaths = true;
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
240
|
return metadata;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as readDeploymentPlatform, r as readProjectConfig } from "./project-rqDnVsJN.mjs";
|
|
2
2
|
import { c as getToken } from "./auth-B6iOCjKI.mjs";
|
|
3
|
-
import { A as confirm, H as outro, L as log, O as cancel, U as password, tt as isCancel } from "./dist-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { a as resolveProjectBySlug, t as getRequestedProjectSlug } from "./resolve-project-
|
|
7
|
-
import { _ as validateSecretValues } from "./env-validation-
|
|
3
|
+
import { A as confirm, H as outro, L as log, O as cancel, U as password, tt as isCancel } from "./dist-Cor9XGoz.mjs";
|
|
4
|
+
import { r as PlatformClient } from "./client-BEkdj1kx.mjs";
|
|
5
|
+
import { m as printSuccess, o as formatCount, p as note } from "./output-BpgYODYx.mjs";
|
|
6
|
+
import { a as resolveProjectBySlug, t as getRequestedProjectSlug } from "./resolve-project-Xoi6eTWY.mjs";
|
|
7
|
+
import { _ as validateSecretValues } from "./env-validation-Dwq3PJzK.mjs";
|
|
8
8
|
import { readFileSync } from "node:fs";
|
|
9
9
|
//#region src/cli/secret.ts
|
|
10
10
|
async function runSecretCommand(root, args) {
|
|
@@ -93,7 +93,7 @@ async function resolveSecretBackend(root, args) {
|
|
|
93
93
|
}
|
|
94
94
|
async function resolveCloudflareSecretBackend(root, args) {
|
|
95
95
|
if (args.projectName) throw new Error("secret: --project selects a Void platform project and is not used for direct Cloudflare apps.");
|
|
96
|
-
const { deleteCloudflareSecret, listCloudflareSecrets, putCloudflareSecret, resolveCloudflareOperationContext, syncCloudflareSecrets } = await import("./cloudflare-operations-
|
|
96
|
+
const { deleteCloudflareSecret, listCloudflareSecrets, putCloudflareSecret, resolveCloudflareOperationContext, syncCloudflareSecrets } = await import("./cloudflare-operations-DsSaw2BT.mjs");
|
|
97
97
|
const context = resolveCloudflareOperationContext(root);
|
|
98
98
|
return {
|
|
99
99
|
target: "Cloudflare Worker",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as join, s as relative } from "./dist-ipQi0Q8y.mjs";
|
|
2
|
-
import { L as log } from "./dist-
|
|
2
|
+
import { L as log } from "./dist-Cor9XGoz.mjs";
|
|
3
3
|
import { r as getPackageDir } from "./agents-CuNtT0D_.mjs";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, readdirSync, readlinkSync, symlinkSync } from "node:fs";
|
|
5
5
|
//#region src/cli/skills.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as wrapTextWithPrefix, G as promptTitle, M as getGuide, V as optionText, b as S_RADIO_ACTIVE, d as S_CHECKBOX_SELECTED, i as S_BAR_END, it as wrapAnsi, j as formatInstructionFooter, n as SELECT_INSTRUCTIONS, r as S_BAR, t as MULTISELECT_INSTRUCTIONS, u as S_CHECKBOX_INACTIVE, w as S_STEP_SUBMIT } from "./dist-
|
|
2
|
-
import { f as import_picocolors } from "./output-
|
|
1
|
+
import { $ as wrapTextWithPrefix, G as promptTitle, M as getGuide, V as optionText, b as S_RADIO_ACTIVE, d as S_CHECKBOX_SELECTED, i as S_BAR_END, it as wrapAnsi, j as formatInstructionFooter, n as SELECT_INSTRUCTIONS, r as S_BAR, t as MULTISELECT_INSTRUCTIONS, u as S_CHECKBOX_INACTIVE, w as S_STEP_SUBMIT } from "./dist-Cor9XGoz.mjs";
|
|
2
|
+
import { f as import_picocolors } from "./output-BpgYODYx.mjs";
|
|
3
3
|
//#region src/cli/subcommand-prompt.ts
|
|
4
4
|
const isUpKey = (key) => key === "\x1B[A" || key === "\x1BOA";
|
|
5
5
|
const isDownKey = (key) => key === "\x1B[B" || key === "\x1BOB";
|