@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.
Files changed (114) hide show
  1. package/lib/api-routes-Ci0kVmM4.js +146 -0
  2. package/lib/client.js +7 -2
  3. package/lib/csp.js +19 -9
  4. package/lib/env.js +6 -6
  5. package/lib/font.js +3 -3
  6. package/lib/{fs-router-CQ7Zxeca.js → fs-router-MewHc5SB.js} +56 -24
  7. package/lib/i18n-routing.js +112 -1
  8. package/lib/image-plugin.js +4 -0
  9. package/lib/image.js +141 -108
  10. package/lib/index.js +253 -132
  11. package/lib/link.js +1 -49
  12. package/lib/og-image.js +5 -5
  13. package/lib/rolldown-runtime-CjeV3_4I.js +18 -0
  14. package/lib/script.js +115 -74
  15. package/lib/seo.js +186 -15
  16. package/lib/server.js +275 -1247
  17. package/lib/theme.js +1 -50
  18. package/lib/types/config.d.ts +275 -3
  19. package/lib/types/env.d.ts +2 -2
  20. package/lib/types/i18n-routing.d.ts +197 -6
  21. package/lib/types/image.d.ts +105 -5
  22. package/lib/types/index.d.ts +640 -178
  23. package/lib/types/link.d.ts +3 -3
  24. package/lib/types/script.d.ts +78 -6
  25. package/lib/types/seo.d.ts +128 -4
  26. package/lib/types/server.d.ts +603 -77
  27. package/lib/types/theme.d.ts +2 -2
  28. package/lib/vite-plugin-xjWZwudX.js +2454 -0
  29. package/package.json +16 -13
  30. package/src/adapters/bun.ts +20 -1
  31. package/src/adapters/cloudflare.ts +78 -1
  32. package/src/adapters/index.ts +25 -3
  33. package/src/adapters/netlify.ts +63 -1
  34. package/src/adapters/node.ts +25 -1
  35. package/src/adapters/static.ts +26 -1
  36. package/src/adapters/validate.ts +8 -1
  37. package/src/adapters/vercel.ts +76 -1
  38. package/src/adapters/warn-missing-env.ts +49 -0
  39. package/src/app.ts +35 -1
  40. package/src/client.ts +18 -0
  41. package/src/csp.ts +28 -12
  42. package/src/entry-server.ts +55 -5
  43. package/src/env.ts +7 -7
  44. package/src/font.ts +3 -3
  45. package/src/fs-router.ts +123 -4
  46. package/src/i18n-routing.ts +246 -12
  47. package/src/image.tsx +242 -91
  48. package/src/index.ts +4 -4
  49. package/src/isr.ts +24 -6
  50. package/src/manifest.ts +675 -0
  51. package/src/og-image.ts +5 -5
  52. package/src/script.tsx +159 -36
  53. package/src/seo.ts +346 -15
  54. package/src/server.ts +10 -2
  55. package/src/ssg-plugin.ts +1523 -0
  56. package/src/types.ts +329 -19
  57. package/src/vercel-revalidate-handler.ts +204 -0
  58. package/src/vite-plugin.ts +326 -68
  59. package/lib/actions.js.map +0 -1
  60. package/lib/ai.js.map +0 -1
  61. package/lib/api-routes.js.map +0 -1
  62. package/lib/cache.js.map +0 -1
  63. package/lib/client.js.map +0 -1
  64. package/lib/compression.js.map +0 -1
  65. package/lib/config.js.map +0 -1
  66. package/lib/cors.js.map +0 -1
  67. package/lib/csp.js.map +0 -1
  68. package/lib/env.js.map +0 -1
  69. package/lib/favicon.js.map +0 -1
  70. package/lib/font.js.map +0 -1
  71. package/lib/fs-router-3xzp-4Wj.js.map +0 -1
  72. package/lib/fs-router-CQ7Zxeca.js.map +0 -1
  73. package/lib/i18n-routing.js.map +0 -1
  74. package/lib/image-plugin.js.map +0 -1
  75. package/lib/image.js.map +0 -1
  76. package/lib/index.js.map +0 -1
  77. package/lib/link.js.map +0 -1
  78. package/lib/logger.js.map +0 -1
  79. package/lib/meta.js.map +0 -1
  80. package/lib/middleware.js.map +0 -1
  81. package/lib/og-image.js.map +0 -1
  82. package/lib/rate-limit.js.map +0 -1
  83. package/lib/script.js.map +0 -1
  84. package/lib/seo.js.map +0 -1
  85. package/lib/server.js.map +0 -1
  86. package/lib/testing.js.map +0 -1
  87. package/lib/theme.js.map +0 -1
  88. package/lib/types/actions.d.ts.map +0 -1
  89. package/lib/types/ai.d.ts.map +0 -1
  90. package/lib/types/api-routes.d.ts.map +0 -1
  91. package/lib/types/cache.d.ts.map +0 -1
  92. package/lib/types/client.d.ts.map +0 -1
  93. package/lib/types/compression.d.ts.map +0 -1
  94. package/lib/types/config.d.ts.map +0 -1
  95. package/lib/types/cors.d.ts.map +0 -1
  96. package/lib/types/csp.d.ts.map +0 -1
  97. package/lib/types/env.d.ts.map +0 -1
  98. package/lib/types/favicon.d.ts.map +0 -1
  99. package/lib/types/font.d.ts.map +0 -1
  100. package/lib/types/i18n-routing.d.ts.map +0 -1
  101. package/lib/types/image-plugin.d.ts.map +0 -1
  102. package/lib/types/image.d.ts.map +0 -1
  103. package/lib/types/index.d.ts.map +0 -1
  104. package/lib/types/link.d.ts.map +0 -1
  105. package/lib/types/logger.d.ts.map +0 -1
  106. package/lib/types/meta.d.ts.map +0 -1
  107. package/lib/types/middleware.d.ts.map +0 -1
  108. package/lib/types/og-image.d.ts.map +0 -1
  109. package/lib/types/rate-limit.d.ts.map +0 -1
  110. package/lib/types/script.d.ts.map +0 -1
  111. package/lib/types/seo.d.ts.map +0 -1
  112. package/lib/types/server.d.ts.map +0 -1
  113. package/lib/types/testing.d.ts.map +0 -1
  114. 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
- const key = url.pathname
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
- const req = new Request(url.href, { method: 'GET' })
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.pathname
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
- cache.set(key, { html, headers, timestamp: Date.now() })
134
+ set(key, { html, headers, timestamp: Date.now() })
117
135
 
118
136
  return new Response(html, {
119
137
  status: 200,