@pyreon/zero 0.14.0 → 0.16.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/lib/api-routes-Ci0kVmM4.js +146 -0
- package/lib/client.js +7 -2
- package/lib/csp.js +19 -9
- package/lib/env.js +6 -6
- package/lib/font.js +3 -3
- package/lib/{fs-router-CQ7Zxeca.js → fs-router-MewHc5SB.js} +56 -24
- package/lib/i18n-routing.js +112 -1
- package/lib/image-plugin.js +4 -0
- package/lib/image.js +141 -108
- package/lib/index.js +253 -132
- package/lib/link.js +1 -49
- package/lib/og-image.js +5 -5
- package/lib/rolldown-runtime-CjeV3_4I.js +18 -0
- package/lib/script.js +115 -74
- package/lib/seo.js +186 -15
- package/lib/server.js +275 -1247
- package/lib/theme.js +1 -50
- package/lib/types/config.d.ts +275 -3
- package/lib/types/env.d.ts +2 -2
- package/lib/types/i18n-routing.d.ts +197 -6
- package/lib/types/image.d.ts +105 -5
- package/lib/types/index.d.ts +640 -178
- package/lib/types/link.d.ts +3 -3
- package/lib/types/script.d.ts +78 -6
- package/lib/types/seo.d.ts +128 -4
- package/lib/types/server.d.ts +603 -77
- package/lib/types/theme.d.ts +2 -2
- package/lib/vite-plugin-xjWZwudX.js +2454 -0
- package/package.json +16 -13
- package/src/adapters/bun.ts +20 -1
- package/src/adapters/cloudflare.ts +78 -1
- package/src/adapters/index.ts +25 -3
- package/src/adapters/netlify.ts +63 -1
- package/src/adapters/node.ts +25 -1
- package/src/adapters/static.ts +26 -1
- package/src/adapters/validate.ts +8 -1
- package/src/adapters/vercel.ts +76 -1
- package/src/adapters/warn-missing-env.ts +49 -0
- package/src/app.ts +35 -1
- package/src/client.ts +18 -0
- package/src/csp.ts +28 -12
- package/src/entry-server.ts +55 -5
- package/src/env.ts +7 -7
- package/src/font.ts +3 -3
- package/src/fs-router.ts +123 -4
- package/src/i18n-routing.ts +246 -12
- package/src/image.tsx +242 -91
- package/src/index.ts +4 -4
- package/src/isr.ts +24 -6
- package/src/manifest.ts +675 -0
- package/src/og-image.ts +5 -5
- package/src/script.tsx +159 -36
- package/src/seo.ts +346 -15
- package/src/server.ts +10 -2
- package/src/ssg-plugin.ts +1523 -0
- package/src/types.ts +329 -19
- package/src/vercel-revalidate-handler.ts +204 -0
- package/src/vite-plugin.ts +326 -68
- package/lib/actions.js.map +0 -1
- package/lib/ai.js.map +0 -1
- package/lib/api-routes.js.map +0 -1
- package/lib/cache.js.map +0 -1
- package/lib/client.js.map +0 -1
- package/lib/compression.js.map +0 -1
- package/lib/config.js.map +0 -1
- package/lib/cors.js.map +0 -1
- package/lib/csp.js.map +0 -1
- package/lib/env.js.map +0 -1
- package/lib/favicon.js.map +0 -1
- package/lib/font.js.map +0 -1
- package/lib/fs-router-3xzp-4Wj.js.map +0 -1
- package/lib/fs-router-CQ7Zxeca.js.map +0 -1
- package/lib/i18n-routing.js.map +0 -1
- package/lib/image-plugin.js.map +0 -1
- package/lib/image.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/link.js.map +0 -1
- package/lib/logger.js.map +0 -1
- package/lib/meta.js.map +0 -1
- package/lib/middleware.js.map +0 -1
- package/lib/og-image.js.map +0 -1
- package/lib/rate-limit.js.map +0 -1
- package/lib/script.js.map +0 -1
- package/lib/seo.js.map +0 -1
- package/lib/server.js.map +0 -1
- package/lib/testing.js.map +0 -1
- package/lib/theme.js.map +0 -1
- package/lib/types/actions.d.ts.map +0 -1
- package/lib/types/ai.d.ts.map +0 -1
- package/lib/types/api-routes.d.ts.map +0 -1
- package/lib/types/cache.d.ts.map +0 -1
- package/lib/types/client.d.ts.map +0 -1
- package/lib/types/compression.d.ts.map +0 -1
- package/lib/types/config.d.ts.map +0 -1
- package/lib/types/cors.d.ts.map +0 -1
- package/lib/types/csp.d.ts.map +0 -1
- package/lib/types/env.d.ts.map +0 -1
- package/lib/types/favicon.d.ts.map +0 -1
- package/lib/types/font.d.ts.map +0 -1
- package/lib/types/i18n-routing.d.ts.map +0 -1
- package/lib/types/image-plugin.d.ts.map +0 -1
- package/lib/types/image.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/link.d.ts.map +0 -1
- package/lib/types/logger.d.ts.map +0 -1
- package/lib/types/meta.d.ts.map +0 -1
- package/lib/types/middleware.d.ts.map +0 -1
- package/lib/types/og-image.d.ts.map +0 -1
- package/lib/types/rate-limit.d.ts.map +0 -1
- package/lib/types/script.d.ts.map +0 -1
- package/lib/types/seo.d.ts.map +0 -1
- package/lib/types/server.d.ts.map +0 -1
- package/lib/types/testing.d.ts.map +0 -1
- package/lib/types/theme.d.ts.map +0 -1
package/src/index.ts
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
// ─── Components (browser-safe) ──────────────────────────────────────────────
|
|
15
15
|
|
|
16
|
-
export type { ImageProps, ImageSource } from "./image";
|
|
17
|
-
export { Image } from "./image";
|
|
16
|
+
export type { ImageProps, ImageRenderProps, ImageSource, UseImageReturn } from "./image";
|
|
17
|
+
export { createImage, Image, useImage } from "./image";
|
|
18
18
|
export type { LinkProps, LinkRenderProps, UseLinkReturn } from "./link";
|
|
19
19
|
export { createLink, Link, prefetchRoute, useLink } from "./link";
|
|
20
|
-
export type { ScriptProps, ScriptStrategy } from "./script";
|
|
21
|
-
export { Script } from "./script";
|
|
20
|
+
export type { ScriptProps, ScriptRenderProps, ScriptStrategy, UseScriptReturn } from "./script";
|
|
21
|
+
export { createScript, Script, useScript } from "./script";
|
|
22
22
|
export type { MetaProps } from "./meta";
|
|
23
23
|
export { buildMetaTags, Meta } from "./meta";
|
|
24
24
|
|
package/src/isr.ts
CHANGED
|
@@ -29,6 +29,14 @@ export function createISRHandler(
|
|
|
29
29
|
const revalidating = new Set<string>()
|
|
30
30
|
const revalidateMs = config.revalidate * 1000
|
|
31
31
|
const maxEntries = Math.max(1, config.maxEntries ?? 1000)
|
|
32
|
+
// M1.1 — cache-key derivation. Default keys by pathname only (the
|
|
33
|
+
// pre-M1 behaviour). User-supplied `cacheKey` opts in to varying
|
|
34
|
+
// by cookies / query / headers — required for auth-gated pages.
|
|
35
|
+
// See `ISRConfig.cacheKey` JSDoc for the auth-incompatibility caveat.
|
|
36
|
+
const deriveKey: (req: Request, url: URL) => string
|
|
37
|
+
= typeof config.cacheKey === 'function'
|
|
38
|
+
? (req, _url) => (config.cacheKey as (r: Request) => string)(req)
|
|
39
|
+
: (_req, url) => url.pathname
|
|
32
40
|
|
|
33
41
|
function set(key: string, entry: CacheEntry): void {
|
|
34
42
|
// LRU: re-inserting moves the key to the newest position. Then if we're
|
|
@@ -51,13 +59,23 @@ export function createISRHandler(
|
|
|
51
59
|
return entry
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
async function revalidate(url: URL) {
|
|
55
|
-
|
|
62
|
+
async function revalidate(url: URL, originalReq: Request) {
|
|
63
|
+
// Re-derive key from the ORIGINAL request so cookies / headers /
|
|
64
|
+
// query that varied the cache entry are preserved across revalidation.
|
|
65
|
+
// Without this, a user-supplied `cacheKey` that reads cookies would
|
|
66
|
+
// re-render against a no-cookie request and stomp the cached entry
|
|
67
|
+
// with the wrong-user content.
|
|
68
|
+
const key = deriveKey(originalReq, url)
|
|
56
69
|
if (revalidating.has(key)) return
|
|
57
70
|
revalidating.add(key)
|
|
58
71
|
|
|
59
72
|
try {
|
|
60
|
-
|
|
73
|
+
// Forward the original request shape (headers + method) so the
|
|
74
|
+
// re-render sees the same auth context as the user's read.
|
|
75
|
+
const req = new Request(url.href, {
|
|
76
|
+
method: 'GET',
|
|
77
|
+
headers: originalReq.headers,
|
|
78
|
+
})
|
|
61
79
|
const res = await handler(req)
|
|
62
80
|
const html = await res.text()
|
|
63
81
|
const headers: Record<string, string> = {}
|
|
@@ -80,7 +98,7 @@ export function createISRHandler(
|
|
|
80
98
|
}
|
|
81
99
|
|
|
82
100
|
const url = new URL(req.url)
|
|
83
|
-
const key = url
|
|
101
|
+
const key = deriveKey(req, url)
|
|
84
102
|
// `touch` moves the entry to the newest LRU position on read so
|
|
85
103
|
// hot paths survive eviction even when the cap is small. `get`
|
|
86
104
|
// wouldn't update ordering.
|
|
@@ -91,7 +109,7 @@ export function createISRHandler(
|
|
|
91
109
|
|
|
92
110
|
if (age > revalidateMs) {
|
|
93
111
|
// Stale — serve cached but revalidate in background
|
|
94
|
-
revalidate(url)
|
|
112
|
+
revalidate(url, req)
|
|
95
113
|
}
|
|
96
114
|
|
|
97
115
|
return new Response(entry.html, {
|
|
@@ -113,7 +131,7 @@ export function createISRHandler(
|
|
|
113
131
|
headers[k] = v
|
|
114
132
|
})
|
|
115
133
|
|
|
116
|
-
|
|
134
|
+
set(key, { html, headers, timestamp: Date.now() })
|
|
117
135
|
|
|
118
136
|
return new Response(html, {
|
|
119
137
|
status: 200,
|