void 0.7.5 → 0.7.7
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/{auth-DrfOTMmr.d.mts → auth-DmuALf16.d.mts} +4 -4
- package/dist/{better-auth-shared-CZsIpjey.d.mts → better-auth-shared-HXlHRw02.d.mts} +15 -15
- package/dist/cli/cli.mjs +14 -14
- package/dist/{config-BIa9HwVX.mjs → config-DqkeX_Fa.mjs} +5 -5
- package/dist/{db-RqxhOT2E.mjs → db-BnKZW1J7.mjs} +26 -22
- package/dist/{deploy-CRIz77mw.mjs → deploy-D3t53kng.mjs} +46 -16
- package/dist/{domain-CDQhvYNZ.mjs → domain-ClDdX9I1.mjs} +24 -1
- package/dist/{dotenv-DwO4ti0Z.mjs → dotenv-zdFCCgFU.mjs} +26 -26
- package/dist/{env-CnrQY2b6.mjs → env-CU97_4YK.mjs} +1 -1
- package/dist/{env-helpers-CbeM_7-k.d.mts → env-helpers-Dw95CU8e.d.mts} +4 -4
- package/dist/{env-validation-DJKjR_8q.mjs → env-validation-Bc_aiBUm.mjs} +1 -1
- package/dist/{fetch-error-DflegrF3.d.mts → fetch-error-DZ868Xq4.d.mts} +4 -4
- package/dist/{gen-C0EY2k27.mjs → gen-CpeKIqlM.mjs} +2 -2
- package/dist/{handler-dKQWyF-G.d.mts → handler-DJTuxB10.d.mts} +24 -27
- package/dist/{head-CZGAunBV.d.mts → head-C7QW7UY1.d.mts} +5 -6
- package/dist/{headers-YVkHjOyq.mjs → headers-C7Yf6_CN.mjs} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +501 -63
- package/dist/{init-FMZ29UZW.mjs → init-CTtDfVVo.mjs} +4 -4
- package/dist/{node-DFqMcZR1.mjs → node-DHVCtkgt.mjs} +1 -1
- package/dist/pages/client.d.mts +35 -41
- package/dist/pages/head-client.d.mts +1 -1
- package/dist/pages/head.d.mts +1 -1
- package/dist/pages/head.mjs +4 -4
- package/dist/pages/index.d.mts +6 -6
- package/dist/pages/index.mjs +6 -6
- package/dist/pages/islands-plugin.d.mts +4 -13
- package/dist/pages/islands-plugin.mjs +2 -64
- package/dist/pages/prefetch.d.mts +5 -5
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +98 -14
- package/dist/plugin-inference-CXUuq0aC.mjs +577 -0
- package/dist/{prepare-PqAbhLte.mjs → prepare-CKzO06-Z.mjs} +4 -4
- package/dist/{preset-jKn1hQwP.mjs → preset-BhnZpb7t.mjs} +1 -1
- package/dist/{protocol-DxGzKEz2.d.mts → protocol-D7r_deVZ.d.mts} +7 -4
- package/dist/{route-types-DReF1gUY.mjs → route-types-Cnqj_8a7.mjs} +2 -2
- package/dist/runtime/ai.d.mts +33 -40
- package/dist/runtime/auth.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/client.d.mts +2 -2
- package/dist/runtime/env-helpers.d.mts +1 -1
- package/dist/runtime/env-helpers.mjs +3 -3
- package/dist/runtime/env-public-client.d.mts +3 -3
- package/dist/runtime/env-public.d.mts +7 -7
- package/dist/runtime/fetch-stream.d.mts +1 -1
- package/dist/runtime/fetch.d.mts +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/handler.mjs +3 -3
- package/dist/runtime/isr.d.mts +2 -2
- package/dist/runtime/kv.d.mts +12 -12
- package/dist/runtime/live-server.d.mts +4 -4
- package/dist/runtime/live.d.mts +2 -2
- package/dist/runtime/migration-handler.d.mts +6 -6
- package/dist/runtime/seed.d.mts +4 -4
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +8 -8
- package/dist/runtime/ws.d.mts +21 -21
- package/dist/{scan-QtRTdh94.mjs → scan-B8iEm8xn.mjs} +6 -6
- package/dist/{scan-Ba4hFwlH.mjs → scan-CWfLxtOe.mjs} +8 -8
- package/dist/{standard-schema-BfGDWXff.d.mts → standard-schema-D2qvCEYV.d.mts} +14 -14
- package/dist/sveltekit.d.mts +3 -5
- package/dist/types-DG_Ynnyd.d.mts +42 -0
- package/package.json +3 -3
- package/dist/plugin-inference-CCtRkt9O.mjs +0 -2476
- package/dist/types-AdKzPp2C.d.mts +0 -57
package/dist/pages/protocol.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { i as ValidationError, r as separateDeferred, t as DEFERRED } from "../d
|
|
|
3
3
|
import { resolveHead } from "./head.mjs";
|
|
4
4
|
//#region src/pages/protocol.ts
|
|
5
5
|
const POWERED_BY = { "X-Powered-By": "Void" };
|
|
6
|
+
const RENDER_ERROR_ASSET_TAGS_KEY = "__voidPageAssetTags";
|
|
6
7
|
/** Escape characters that are unsafe inside inline <script> tags to prevent XSS. */
|
|
7
8
|
function safeJsonStringify(value) {
|
|
8
9
|
return (JSON.stringify(value) ?? "null").replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("&", "\\u0026").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
|
|
@@ -15,6 +16,85 @@ function pageResponseHeaders(c, headers) {
|
|
|
15
16
|
for (const [key, value] of Object.entries(headers)) out.set(key, value);
|
|
16
17
|
return out;
|
|
17
18
|
}
|
|
19
|
+
function escapeHtmlAttr(value) {
|
|
20
|
+
return value.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<");
|
|
21
|
+
}
|
|
22
|
+
function serializeStyleCss(css) {
|
|
23
|
+
return css.replace(/<\/style/gi, "<\\/style");
|
|
24
|
+
}
|
|
25
|
+
function serializeDevCssAssets(assets, nonce) {
|
|
26
|
+
return assets.map((asset) => `<style data-vite-dev-id="${escapeHtmlAttr(asset.id ?? asset.url)}" nonce="${escapeHtmlAttr(nonce)}">${serializeStyleCss(asset.css)}</style>`).join("\n");
|
|
27
|
+
}
|
|
28
|
+
function hasCompatibleStyleSource(value, nonceSource) {
|
|
29
|
+
return value === "'unsafe-inline'" || value === nonceSource;
|
|
30
|
+
}
|
|
31
|
+
function adjustCspValue(value, nonce) {
|
|
32
|
+
const nonceSource = `'nonce-${nonce}'`;
|
|
33
|
+
const parsed = value.split(";").map((part) => part.trim()).filter(Boolean).map((directive) => {
|
|
34
|
+
const [name = "", ...sources] = directive.split(/\s+/);
|
|
35
|
+
return {
|
|
36
|
+
name: name.toLowerCase(),
|
|
37
|
+
originalName: name,
|
|
38
|
+
sources
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const styleElem = parsed.find((directive) => directive.name === "style-src-elem");
|
|
42
|
+
if (styleElem) {
|
|
43
|
+
if (!styleElem.sources.some((source) => hasCompatibleStyleSource(source, nonceSource))) styleElem.sources.push(nonceSource);
|
|
44
|
+
return parsed.map((directive) => [directive.originalName, ...directive.sources].join(" ")).join("; ");
|
|
45
|
+
}
|
|
46
|
+
const style = parsed.find((directive) => directive.name === "style-src");
|
|
47
|
+
if (style) {
|
|
48
|
+
if (!style.sources.some((source) => hasCompatibleStyleSource(source, nonceSource))) style.sources.push(nonceSource);
|
|
49
|
+
return parsed.map((directive) => [directive.originalName, ...directive.sources].join(" ")).join("; ");
|
|
50
|
+
}
|
|
51
|
+
const defaultSrc = parsed.find((directive) => directive.name === "default-src");
|
|
52
|
+
if (defaultSrc) {
|
|
53
|
+
parsed.push({
|
|
54
|
+
name: "style-src",
|
|
55
|
+
originalName: "style-src",
|
|
56
|
+
sources: [...defaultSrc.sources, nonceSource]
|
|
57
|
+
});
|
|
58
|
+
return parsed.map((directive) => [directive.originalName, ...directive.sources].join(" ")).join("; ");
|
|
59
|
+
}
|
|
60
|
+
parsed.push({
|
|
61
|
+
name: "style-src",
|
|
62
|
+
originalName: "style-src",
|
|
63
|
+
sources: [nonceSource]
|
|
64
|
+
});
|
|
65
|
+
return parsed.map((directive) => [directive.originalName, ...directive.sources].join(" ")).join("; ");
|
|
66
|
+
}
|
|
67
|
+
function adjustDevCssCsp(headers, nonce) {
|
|
68
|
+
if (!nonce) return headers;
|
|
69
|
+
const csp = headers.get("content-security-policy");
|
|
70
|
+
if (csp) headers.set("content-security-policy", adjustCspValue(csp, nonce));
|
|
71
|
+
const cspReportOnly = headers.get("content-security-policy-report-only");
|
|
72
|
+
if (cspReportOnly) headers.set("content-security-policy-report-only", adjustCspValue(cspReportOnly, nonce));
|
|
73
|
+
return headers;
|
|
74
|
+
}
|
|
75
|
+
function prepareAssetTags(assetTags) {
|
|
76
|
+
if (!assetTags.devCss || assetTags.devCss.length === 0) return assetTags;
|
|
77
|
+
const nonce = crypto.randomUUID().replaceAll("-", "");
|
|
78
|
+
return {
|
|
79
|
+
...assetTags,
|
|
80
|
+
css: [assetTags.css, serializeDevCssAssets(assetTags.devCss, nonce)].filter(Boolean).join("\n"),
|
|
81
|
+
devCssNonce: nonce
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function attachRenderErrorAssetTags(error, assetTags) {
|
|
85
|
+
if ((typeof error === "object" || typeof error === "function") && error !== null) Object.defineProperty(error, RENDER_ERROR_ASSET_TAGS_KEY, {
|
|
86
|
+
configurable: true,
|
|
87
|
+
value: assetTags
|
|
88
|
+
});
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
async function renderWithAssetTags(renderFn, pageObj, assetTags) {
|
|
92
|
+
try {
|
|
93
|
+
return await renderFn(pageObj, assetTags);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
attachRenderErrorAssetTags(error, assetTags);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
18
98
|
function pageJsonResponse(c, pageObj) {
|
|
19
99
|
return Response.json(pageObj, { headers: pageResponseHeaders(c, {
|
|
20
100
|
"X-VoidPages": "true",
|
|
@@ -65,14 +145,14 @@ async function writeRenderResult(writer, encoder, result) {
|
|
|
65
145
|
await writer.write(value);
|
|
66
146
|
}
|
|
67
147
|
}
|
|
68
|
-
function renderedResponse(c, result, contentType) {
|
|
69
|
-
return new Response(result, { headers: pageResponseHeaders(c, {
|
|
148
|
+
function renderedResponse(c, result, contentType, assetTags) {
|
|
149
|
+
return new Response(result, { headers: adjustDevCssCsp(pageResponseHeaders(c, {
|
|
70
150
|
"content-type": contentType,
|
|
71
151
|
...POWERED_BY
|
|
72
|
-
}) });
|
|
152
|
+
}), assetTags?.devCssNonce) });
|
|
73
153
|
}
|
|
74
154
|
/** Build a streaming response that sends an initial chunk then streams deferred results. */
|
|
75
|
-
function streamDeferredResponse(initialChunk, deferredMap, c, contentType, formatResolved, formatRejected) {
|
|
155
|
+
function streamDeferredResponse(initialChunk, deferredMap, c, contentType, formatResolved, formatRejected, assetTags) {
|
|
76
156
|
const encoder = new TextEncoder();
|
|
77
157
|
const { readable, writable } = new TransformStream();
|
|
78
158
|
const writer = writable.getWriter();
|
|
@@ -84,10 +164,10 @@ function streamDeferredResponse(initialChunk, deferredMap, c, contentType, forma
|
|
|
84
164
|
})().catch((error) => {
|
|
85
165
|
writer.abort(error).catch(() => {});
|
|
86
166
|
});
|
|
87
|
-
return new Response(readable, { headers: pageResponseHeaders(c, {
|
|
167
|
+
return new Response(readable, { headers: adjustDevCssCsp(pageResponseHeaders(c, {
|
|
88
168
|
"content-type": contentType,
|
|
89
169
|
...POWERED_BY
|
|
90
|
-
}) });
|
|
170
|
+
}), assetTags?.devCssNonce) });
|
|
91
171
|
}
|
|
92
172
|
/** Handle GET page request — run handler, return page object or SSR HTML */
|
|
93
173
|
async function handlePageGet(handler, headFn, c, componentId, renderFn, getAssetTags, configHead, island) {
|
|
@@ -96,8 +176,8 @@ async function handlePageGet(handler, headFn, c, componentId, renderFn, getAsset
|
|
|
96
176
|
if (handler) {
|
|
97
177
|
const result = await handler(c);
|
|
98
178
|
if (result instanceof Response && !isConvertedResponse(result)) {
|
|
99
|
-
const
|
|
100
|
-
if (result.status >= 300 || !
|
|
179
|
+
const contentType = result.headers.get("content-type") || "";
|
|
180
|
+
if (result.status >= 300 || !contentType.includes("application/json")) return result;
|
|
101
181
|
}
|
|
102
182
|
props = await extractProps(result);
|
|
103
183
|
}
|
|
@@ -150,9 +230,10 @@ async function handlePageGet(handler, headFn, c, componentId, renderFn, getAsset
|
|
|
150
230
|
error
|
|
151
231
|
}) + "\n");
|
|
152
232
|
}
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
return
|
|
233
|
+
const assetTags = prepareAssetTags(await getAssetTags(c.req.raw, c.env, componentId));
|
|
234
|
+
const html = await renderWithAssetTags(renderFn, pageObj, assetTags);
|
|
235
|
+
if (!hasDeferred) return renderedResponse(c, html, "text/html; charset=utf-8", assetTags);
|
|
236
|
+
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);
|
|
156
237
|
}
|
|
157
238
|
/** Handle POST/PUT/DELETE page request — run mutation, then re-run GET or redirect */
|
|
158
239
|
async function handlePageMutation(mutationHandler, getHandler, headFn, c, componentId, renderFn, getAssetTags, configHead, island) {
|
|
@@ -178,7 +259,8 @@ async function handlePageMutation(mutationHandler, getHandler, headFn, c, compon
|
|
|
178
259
|
if (island) return Response.json({ errors: e.errors }, { status: 422 });
|
|
179
260
|
const pageObj = buildMutationPageObj(stripDeferred(getHandler ? await extractProps(await getHandler(c)) : {}), e.errors);
|
|
180
261
|
if (isPagesRequest(c)) return pageJsonResponse(c, pageObj);
|
|
181
|
-
|
|
262
|
+
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);
|
|
182
264
|
}
|
|
183
265
|
throw e;
|
|
184
266
|
}
|
|
@@ -190,14 +272,16 @@ async function handlePageMutation(mutationHandler, getHandler, headFn, c, compon
|
|
|
190
272
|
if (island) return Response.json({ errors }, { status: 422 });
|
|
191
273
|
const pageObj = buildMutationPageObj(stripDeferred(getHandler ? await extractProps(await getHandler(c)) : {}), errors);
|
|
192
274
|
if (isPagesRequest(c)) return pageJsonResponse(c, pageObj);
|
|
193
|
-
|
|
275
|
+
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);
|
|
194
277
|
}
|
|
195
278
|
if (status !== 204) return result;
|
|
196
279
|
}
|
|
197
280
|
if (island) return Response.json({ success: true });
|
|
198
281
|
const pageObj = buildMutationPageObj(stripDeferred(getHandler ? await extractProps(await getHandler(c)) : {}), null);
|
|
199
282
|
if (isPagesRequest(c)) return pageJsonResponse(c, pageObj);
|
|
200
|
-
|
|
283
|
+
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);
|
|
201
285
|
}
|
|
202
286
|
//#endregion
|
|
203
287
|
export { ValidationError, flattenValidationErrors, handlePageGet, handlePageMutation, safeJsonStringify };
|