@pyreon/server 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.
@@ -1,5 +1,6 @@
1
1
  import type { ComponentFn, VNode } from '@pyreon/core'
2
2
  import { h } from '@pyreon/core'
3
+ import { RouterView } from '@pyreon/router'
3
4
  import { createHandler } from '../handler'
4
5
  import {
5
6
  buildClientEntryTag,
@@ -140,6 +141,82 @@ describe('createHandler', () => {
140
141
  expect(await res.text()).toBe('Internal Server Error')
141
142
  })
142
143
 
144
+ test('redirect() from a loader returns a 307 with Location header (no HTML body)', async () => {
145
+ const Home: ComponentFn = () => h('h1', null, 'home')
146
+ const Protected: ComponentFn = () => h('h1', null, 'protected')
147
+ const { redirect } = await import('@pyreon/router')
148
+ const protectedRoutes = [
149
+ { path: '/', component: Home },
150
+ {
151
+ path: '/app',
152
+ component: Protected,
153
+ loader: async () => {
154
+ redirect('/login')
155
+ },
156
+ },
157
+ ]
158
+ const handler = createHandler({ App: Home, routes: protectedRoutes })
159
+ const res = await handler(new Request('http://localhost/app'))
160
+ expect(res.status).toBe(307)
161
+ expect(res.headers.get('Location')).toBe('/login')
162
+ // No body — clients only need the Location header
163
+ expect(await res.text()).toBe('')
164
+ })
165
+
166
+ test('redirect() preserves a custom status', async () => {
167
+ const Home: ComponentFn = () => h('h1', null, 'home')
168
+ const { redirect } = await import('@pyreon/router')
169
+ const permRoutes = [
170
+ { path: '/', component: Home },
171
+ {
172
+ path: '/old',
173
+ component: Home,
174
+ loader: async () => {
175
+ redirect('/new', 308)
176
+ },
177
+ },
178
+ ]
179
+ const handler = createHandler({ App: Home, routes: permRoutes })
180
+ const res = await handler(new Request('http://localhost/old'))
181
+ expect(res.status).toBe(308)
182
+ expect(res.headers.get('Location')).toBe('/new')
183
+ })
184
+
185
+ test('loader can read cookies from ctx.request and redirect when missing', async () => {
186
+ const Home: ComponentFn = () => h('h1', null, 'home')
187
+ const Login: ComponentFn = () => h('h1', null, 'login')
188
+ const Protected: ComponentFn = () => h('h1', null, 'protected')
189
+ const { redirect } = await import('@pyreon/router')
190
+ const authRoutes = [
191
+ { path: '/', component: Home },
192
+ { path: '/login', component: Login },
193
+ {
194
+ path: '/app',
195
+ component: Protected,
196
+ loader: async (ctx: { request?: Request }) => {
197
+ const cookieHeader = ctx.request?.headers.get('cookie') ?? ''
198
+ const sid = /(?:^|;\s*)sid=([^;]+)/.exec(cookieHeader)?.[1]
199
+ if (!sid) redirect('/login')
200
+ return { sid }
201
+ },
202
+ },
203
+ ]
204
+ const handler = createHandler({ App: Home, routes: authRoutes })
205
+
206
+ // No cookie → redirect
207
+ const noCookie = await handler(new Request('http://localhost/app'))
208
+ expect(noCookie.status).toBe(307)
209
+ expect(noCookie.headers.get('Location')).toBe('/login')
210
+
211
+ // Has cookie → renders (no redirect). Status 200 is the contract; the
212
+ // body is whatever `App` renders (this test's App is `Home`, no RouterView).
213
+ const withCookie = await handler(
214
+ new Request('http://localhost/app', { headers: { cookie: 'sid=abc123' } }),
215
+ )
216
+ expect(withCookie.status).toBe(200)
217
+ expect(withCookie.headers.get('Location')).toBeNull()
218
+ })
219
+
143
220
  test('handles URL with query string', async () => {
144
221
  const handler = createHandler({ App: Home, routes })
145
222
  const res = await handler(new Request('http://localhost/?foo=bar&baz=1'))
@@ -149,6 +226,82 @@ describe('createHandler', () => {
149
226
  })
150
227
  })
151
228
 
229
+ // ─── M1.2 — runtime SSR 404 layout chrome ─────────────────────────────────────
230
+ //
231
+ // PR L5 added `findNotFoundFallback` to the router's `resolveRoute` so an
232
+ // unmatched URL produces a synthetic chain `[...ancestorLayouts, syntheticLeaf]`
233
+ // with `isNotFound: true`. M1.2 wires the handler to read that flag and emit
234
+ // HTTP 404 instead of 200 — while still serving the layout-wrapped 404 HTML.
235
+ //
236
+ // Without M1.2, the synthetic chain still rendered (so the HTML body was
237
+ // correct under L5) but the response status stayed at 200 — broken contract
238
+ // for static-host CDNs, search engines, and curl-driven monitoring.
239
+ //
240
+ // Bisect: remove the `resolved?.isNotFound === true ? 404 : 200` ternary in
241
+ // `handler.ts` (replace with `200`) → both specs below fail with
242
+ // `expected 200 to be 404`.
243
+
244
+ describe('createHandler — M1.2 runtime SSR 404 layout chrome', () => {
245
+ const HomePage: ComponentFn = () => h('h1', { 'data-testid': 'home' }, 'Home')
246
+ const NotFound: ComponentFn = () => h('h1', { 'data-testid': 'not-found' }, 'Page Not Found')
247
+ const Layout: ComponentFn = () =>
248
+ h(
249
+ 'div',
250
+ { 'data-testid': 'layout' },
251
+ h('nav', { 'data-testid': 'nav' }, 'NAV'),
252
+ h(RouterView, {}),
253
+ )
254
+
255
+ // Routes tree shape mirrors fs-router's `_404.tsx` convention:
256
+ // - parent layout has `notFoundComponent` attached
257
+ // - matched children render normally
258
+ const routes = [
259
+ {
260
+ path: '/',
261
+ component: Layout,
262
+ notFoundComponent: NotFound,
263
+ children: [{ path: '/', component: HomePage }],
264
+ },
265
+ ]
266
+
267
+ test('matched URL renders normally with status 200', async () => {
268
+ const handler = createHandler({ App: RouterView, routes })
269
+ const res = await handler(new Request('http://localhost/'))
270
+ expect(res.status).toBe(200)
271
+ const html = await res.text()
272
+ expect(html).toContain('data-testid="home"')
273
+ expect(html).toContain('data-testid="layout"') // chrome wraps page
274
+ })
275
+
276
+ test('unmatched URL emits HTTP 404 with layout chrome + not-found body', async () => {
277
+ const handler = createHandler({ App: RouterView, routes })
278
+ const res = await handler(new Request('http://localhost/this-page-does-not-exist'))
279
+
280
+ // M1.2 — status 404 sourced from router.currentRoute().isNotFound.
281
+ expect(res.status).toBe(404)
282
+
283
+ const html = await res.text()
284
+ // The 404 component renders.
285
+ expect(html).toContain('data-testid="not-found"')
286
+ expect(html).toContain('Page Not Found')
287
+ // PR L5 — the parent layout wraps the 404 (the win that started with L5,
288
+ // M1.2 just adds the HTTP status).
289
+ expect(html).toContain('data-testid="layout"')
290
+ expect(html).toContain('data-testid="nav"')
291
+ })
292
+
293
+ test('legacy routes tree without notFoundComponent emits 200 (no synthetic chain)', async () => {
294
+ // Backward-compat: apps without `_404.tsx` in the routes tree fall through
295
+ // to whatever the App renders (typically empty RouterView). The handler
296
+ // doesn't synthesize a 404 status out of thin air — it requires the
297
+ // router's `findNotFoundFallback` to produce the synthetic chain first.
298
+ const plainRoutes = [{ path: '/specific', component: HomePage }]
299
+ const handler = createHandler({ App: RouterView, routes: plainRoutes })
300
+ const res = await handler(new Request('http://localhost/unrelated'))
301
+ expect(res.status).toBe(200)
302
+ })
303
+ })
304
+
152
305
  // ─── Stream mode ──────────────────────────────────────────────────────────────
153
306
 
154
307
  describe('createHandler — stream mode', () => {
@@ -306,6 +459,27 @@ describe('middleware types', () => {
306
459
  // Just verify the module can be imported — it's pure types
307
460
  expect(mod).toBeDefined()
308
461
  })
462
+
463
+ test('useRequestLocals returns the current request locals from context', async () => {
464
+ const { useRequestLocals } = await import('../middleware')
465
+ // Outside a request context, returns the default empty object — exercises
466
+ // the function-call path so coverage sees it (was 50%/never-called before).
467
+ const locals = useRequestLocals()
468
+ expect(typeof locals).toBe('object')
469
+ expect(locals).not.toBeNull()
470
+ })
471
+
472
+ test('createHandler invokes collectStyles and prepends styleTag to head', async () => {
473
+ const App: ComponentFn = () => h('div', null, 'styled')
474
+ const handler = createHandler({
475
+ App,
476
+ routes: [{ path: '/', component: App }],
477
+ collectStyles: () => '<style data-test="style">.x{color:red}</style>',
478
+ })
479
+ const res = await handler(new Request('http://localhost/'))
480
+ const html = await res.text()
481
+ expect(html).toContain('<style data-test="style">')
482
+ })
309
483
  })
310
484
 
311
485
  // ─── Islands ─────────────────────────────────────────────────────────────────
@@ -386,7 +560,12 @@ describe('island', () => {
386
560
 
387
561
  test('island() resolves direct function module (not { default })', async () => {
388
562
  const Inner: ComponentFn = () => h('span', null, 'direct')
389
- const Widget = island(() => Promise.resolve({ default: Inner }), { name: 'Direct' })
563
+ // Loader returns the ComponentFn DIRECTLY (no { default } wrapper)
564
+ // covers the function-typeof branch in the unwrap code.
565
+ const Widget = island(
566
+ () => Promise.resolve(Inner as unknown as ComponentFn),
567
+ { name: 'Direct' },
568
+ )
390
569
 
391
570
  const vnode = await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)(
392
571
  {},
@@ -412,6 +591,63 @@ describe('island', () => {
412
591
  expect(meta.hydrate).toBe('visible')
413
592
  })
414
593
 
594
+ test("island() defaults prefetch to 'none' and does NOT emit data-prefetch attribute", async () => {
595
+ const Inner: ComponentFn = () => h('div', null)
596
+ const Widget = island(() => Promise.resolve({ default: Inner }), {
597
+ name: 'NoPrefetch',
598
+ hydrate: 'visible',
599
+ })
600
+ expect((Widget as unknown as { prefetch: string }).prefetch).toBe('none')
601
+ const vnode = await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)(
602
+ {},
603
+ )
604
+ expect('data-prefetch' in vnode.props).toBe(false)
605
+ })
606
+
607
+ test("island() emits data-prefetch when paired with a deferred hydrate strategy", async () => {
608
+ const Inner: ComponentFn = () => h('div', null)
609
+ const Widget = island(() => Promise.resolve({ default: Inner }), {
610
+ name: 'PrefetchIdle',
611
+ hydrate: 'visible',
612
+ prefetch: 'idle',
613
+ })
614
+ expect((Widget as unknown as { prefetch: string }).prefetch).toBe('idle')
615
+ const vnode = await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)(
616
+ {},
617
+ )
618
+ expect(vnode.props['data-prefetch']).toBe('idle')
619
+ expect(vnode.props['data-hydrate']).toBe('visible')
620
+ })
621
+
622
+ test("island() suppresses data-prefetch when hydrate='load' (loader runs synchronously)", async () => {
623
+ const Inner: ComponentFn = () => h('div', null)
624
+ const Widget = island(() => Promise.resolve({ default: Inner }), {
625
+ name: 'PointlessPrefetch',
626
+ hydrate: 'load',
627
+ prefetch: 'idle',
628
+ })
629
+ const vnode = await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)(
630
+ {},
631
+ )
632
+ // Metadata still records what the user asked for, but the runtime
633
+ // attribute is suppressed because prefetch is meaningless on load.
634
+ expect((Widget as unknown as { prefetch: string }).prefetch).toBe('idle')
635
+ expect('data-prefetch' in vnode.props).toBe(false)
636
+ })
637
+
638
+ test("island() suppresses data-prefetch when hydrate='never' (defeats zero-JS strategy)", async () => {
639
+ const Inner: ComponentFn = () => h('div', null)
640
+ const Widget = island(() => Promise.resolve({ default: Inner }), {
641
+ name: 'NeverPrefetch',
642
+ hydrate: 'never',
643
+ prefetch: 'visible',
644
+ })
645
+ const vnode = await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)(
646
+ {},
647
+ )
648
+ expect('data-prefetch' in vnode.props).toBe(false)
649
+ })
650
+
415
651
  test('island() serializes empty props as empty object', async () => {
416
652
  const Inner: ComponentFn = () => h('div', null)
417
653
  const Widget = island(() => Promise.resolve({ default: Inner }), { name: 'Empty' })
@@ -421,6 +657,65 @@ describe('island', () => {
421
657
  )
422
658
  expect(vnode.props['data-props']).toBe('{}')
423
659
  })
660
+
661
+ test('island() falls back to {} on BigInt props instead of throwing the SSR', async () => {
662
+ const Inner: ComponentFn = () => h('div', null)
663
+ const Widget = island(() => Promise.resolve({ default: Inner }), { name: 'BigIntProps' })
664
+
665
+ const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
666
+ const vnode = await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)({
667
+ // BigInt is not JSON-serializable; would throw inside JSON.stringify pre-fix
668
+ huge: BigInt('9007199254740993'),
669
+ })
670
+ expect(vnode.props['data-props']).toBe('{}')
671
+ expect(errorSpy).toHaveBeenCalledWith(
672
+ expect.stringContaining('BigInt or circular reference'),
673
+ )
674
+ errorSpy.mockRestore()
675
+ })
676
+
677
+ test('island() falls back to {} on circular-reference props', async () => {
678
+ const Inner: ComponentFn = () => h('div', null)
679
+ const Widget = island(() => Promise.resolve({ default: Inner }), { name: 'CircularProps' })
680
+
681
+ const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
682
+ const cyclic: Record<string, unknown> = { name: 'foo' }
683
+ cyclic.self = cyclic
684
+ const vnode = await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)({
685
+ data: cyclic,
686
+ })
687
+ expect(vnode.props['data-props']).toBe('{}')
688
+ expect(errorSpy).toHaveBeenCalled()
689
+ errorSpy.mockRestore()
690
+ })
691
+
692
+ test('island() warns when children prop is dropped (dev only)', async () => {
693
+ const Inner: ComponentFn = () => h('div', null)
694
+ const Widget = island(() => Promise.resolve({ default: Inner }), { name: 'WithKids' })
695
+
696
+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
697
+ await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)({
698
+ title: 'has children',
699
+ children: h('span', null, 'kid'),
700
+ })
701
+ expect(warnSpy).toHaveBeenCalledWith(
702
+ expect.stringContaining('island "WithKids" was passed children'),
703
+ )
704
+ warnSpy.mockRestore()
705
+ })
706
+
707
+ test('island() does NOT warn when children is undefined (no real children)', async () => {
708
+ const Inner: ComponentFn = () => h('div', null)
709
+ const Widget = island(() => Promise.resolve({ default: Inner }), { name: 'NoKidsWarn' })
710
+
711
+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
712
+ await (Widget as unknown as (props: Record<string, unknown>) => Promise<VNode>)({
713
+ title: 'no children',
714
+ children: undefined,
715
+ })
716
+ expect(warnSpy).not.toHaveBeenCalled()
717
+ warnSpy.mockRestore()
718
+ })
424
719
  })
425
720
 
426
721
  // ─── SSG ─────────────────────────────────────────────────────────────────────
package/lib/client.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["/**\n * Client-side entry helpers for Pyreon SSR/SSG apps.\n *\n * ## Full app hydration\n *\n * ```ts\n * // entry-client.ts\n * import { startClient } from \"@pyreon/server/client\"\n * import { App } from \"./App\"\n * import { routes } from \"./routes\"\n *\n * startClient({ App, routes })\n * ```\n *\n * ## Island hydration (partial)\n *\n * ```ts\n * // entry-client.ts\n * import { hydrateIslands } from \"@pyreon/server/client\"\n *\n * hydrateIslands({\n * Counter: () => import(\"./Counter\"),\n * Search: () => import(\"./Search\"),\n * })\n * ```\n */\n\nimport type { ComponentFn } from '@pyreon/core'\nimport { h } from '@pyreon/core'\nimport { createRouter, hydrateLoaderData, type RouteRecord, RouterProvider } from '@pyreon/router'\nimport { hydrateRoot, mount } from '@pyreon/runtime-dom'\nimport type { HydrationStrategy } from './island'\n\n// ─── Full app hydration ──────────────────────────────────────────────────────\n\nexport interface StartClientOptions {\n /** Root application component */\n App: ComponentFn\n /** Route definitions (same as server) */\n routes: RouteRecord[]\n /** CSS selector or element for the app container (default: \"#app\") */\n container?: string | Element\n}\n\n/**\n * Hydrate a server-rendered Pyreon app on the client.\n *\n * Handles:\n * - Router creation (history mode)\n * - Loader data hydration from `window.__PYREON_LOADER_DATA__`\n * - Hydration if container has SSR content, fresh mount otherwise\n *\n * Returns a cleanup function that unmounts the app.\n */\nexport function startClient(options: StartClientOptions): () => void {\n if (typeof document === 'undefined') {\n throw new Error('[Pyreon] startClient() can only be called in the browser.')\n }\n const { App, routes, container = '#app' } = options\n\n const el = typeof container === 'string' ? document.querySelector(container) : container\n\n if (!el) {\n throw new Error(`[Pyreon] Container \"${container}\" not found`)\n }\n\n // Create client-side router (history mode to match SSR)\n const router = createRouter({ routes, mode: 'history' })\n\n // Hydrate loader data from SSR (avoids re-fetching on initial render)\n const loaderData = (window as unknown as Record<string, unknown>).__PYREON_LOADER_DATA__\n if (loaderData && typeof loaderData === 'object') {\n hydrateLoaderData(router as never, loaderData as Record<string, unknown>)\n }\n\n // Build app tree\n const app = h(RouterProvider, { router }, h(App, null))\n\n // Hydrate if container has SSR content, mount fresh otherwise\n if (el.childNodes.length > 0) {\n return hydrateRoot(el, app)\n }\n return mount(app, el as HTMLElement)\n}\n\n// ─── Island hydration ────────────────────────────────────────────────────────\n\ntype IslandLoader = () => Promise<{ default: ComponentFn } | ComponentFn>\n\n/**\n * Hydrate all `<pyreon-island>` elements on the page.\n *\n * Only loads JavaScript for components that are actually present in the HTML.\n * Respects hydration strategies (load, idle, visible, media, never).\n *\n * @example\n * hydrateIslands({\n * Counter: () => import(\"./Counter\"),\n * Search: () => import(\"./Search\"),\n * })\n */\n/**\n * Hydrate all `<pyreon-island>` elements on the page.\n * Returns a cleanup function that disconnects any pending observers/listeners.\n */\nexport function hydrateIslands(registry: Record<string, IslandLoader>): () => void {\n if (typeof document === 'undefined') return () => {}\n const islands = document.querySelectorAll('pyreon-island')\n const cleanups: (() => void)[] = []\n\n for (const el of islands) {\n const componentId = el.getAttribute('data-component')\n if (!componentId) continue\n\n const loader = registry[componentId]\n if (!loader) {\n console.warn(`No loader registered for island \"${componentId}\"`)\n continue\n }\n\n const strategy = (el.getAttribute('data-hydrate') ?? 'load') as HydrationStrategy\n const propsJson = el.getAttribute('data-props') ?? '{}'\n\n const cleanup = scheduleHydration(el as HTMLElement, loader, propsJson, strategy)\n if (cleanup) cleanups.push(cleanup)\n }\n\n return () => {\n for (const fn of cleanups) fn()\n }\n}\n\nfunction scheduleHydration(\n el: HTMLElement,\n loader: IslandLoader,\n propsJson: string,\n strategy: HydrationStrategy,\n): (() => void) | null {\n if (typeof window === 'undefined') return null\n let cancelled = false\n const hydrate = () => {\n if (!cancelled) hydrateIsland(el, loader, propsJson)\n }\n\n switch (strategy) {\n case 'load':\n hydrate()\n return null\n\n case 'idle': {\n if ('requestIdleCallback' in window) {\n const id = requestIdleCallback(hydrate)\n return () => {\n cancelled = true\n cancelIdleCallback(id)\n }\n }\n const id = setTimeout(hydrate, 200)\n return () => {\n cancelled = true\n clearTimeout(id)\n }\n }\n\n case 'visible':\n return observeVisibility(el, hydrate)\n\n case 'never':\n return null\n\n default:\n // media(query)\n if (strategy.startsWith('media(')) {\n const query = strategy.slice(6, -1)\n const mql = window.matchMedia(query)\n if (mql.matches) {\n hydrate()\n return null\n }\n const onChange = (e: MediaQueryListEvent) => {\n if (e.matches) {\n mql.removeEventListener('change', onChange)\n hydrate()\n }\n }\n mql.addEventListener('change', onChange)\n return () => {\n cancelled = true\n mql.removeEventListener('change', onChange)\n }\n }\n hydrate()\n return null\n }\n}\n\nasync function hydrateIsland(\n el: HTMLElement,\n loader: IslandLoader,\n propsJson: string,\n): Promise<void> {\n const name = el.getAttribute('data-component') ?? 'unknown'\n try {\n let props: Record<string, unknown>\n try {\n props = JSON.parse(propsJson)\n if (typeof props !== 'object' || props === null || Array.isArray(props)) {\n throw new TypeError('Expected object')\n }\n } catch (parseErr) {\n console.error(`Invalid island props JSON for \"${name}\"`, parseErr)\n return\n }\n\n const mod = await loader()\n const Comp = typeof mod === 'function' ? mod : mod.default\n hydrateRoot(el, h(Comp, props))\n } catch (err) {\n console.error(`Failed to hydrate island \"${name}\"`, err)\n }\n}\n\nfunction observeVisibility(el: HTMLElement, callback: () => void): (() => void) | null {\n if (typeof window === 'undefined') return null\n if (!('IntersectionObserver' in window)) {\n callback()\n return null\n }\n\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.disconnect()\n callback()\n return\n }\n }\n },\n { rootMargin: '200px' },\n )\n\n observer.observe(el)\n return () => observer.disconnect()\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsDA,SAAgB,YAAY,SAAyC;AACnE,KAAI,OAAO,aAAa,YACtB,OAAM,IAAI,MAAM,4DAA4D;CAE9E,MAAM,EAAE,KAAK,QAAQ,YAAY,WAAW;CAE5C,MAAM,KAAK,OAAO,cAAc,WAAW,SAAS,cAAc,UAAU,GAAG;AAE/E,KAAI,CAAC,GACH,OAAM,IAAI,MAAM,uBAAuB,UAAU,aAAa;CAIhE,MAAM,SAAS,aAAa;EAAE;EAAQ,MAAM;EAAW,CAAC;CAGxD,MAAM,aAAc,OAA8C;AAClE,KAAI,cAAc,OAAO,eAAe,SACtC,mBAAkB,QAAiB,WAAsC;CAI3E,MAAM,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,KAAK,KAAK,CAAC;AAGvD,KAAI,GAAG,WAAW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W,MAAM;AACpC,QAAI,IAAI,SAAS;AACf,cAAS;AACT,YAAO;;IAET,MAAM,YAAY,MAA2B;AAC3C,SAAI,EAAE,SAAS;AACb,UAAI,oBAAoB,UAAU,SAAS;AAC3C,eAAS;;;AAGb,QAAI,iBAAiB,UAAU,SAAS;AACxC,iBAAa;AACX,iBAAY;AACZ,SAAI,oBAAoB,UAAU,SAAS;;;AAG/C,YAAS;AACT,UAAO;;;AAIb,eAAe,cACb,IACA,QACA,WACe;CACf,MAAM,OAAO,GAAG,aAAa,iBAAiB,IAAI;AAClD,KAAI;EACF,IAAI;AACJ,MAAI;AACF,WAAQ,KAAK,MAAM,UAAU;AAC7B,OAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,MAAM,CACrE,OAAM,IAAI,UAAU,kBAAkB;WAEjC,UAAU;AACjB,WAAQ,MAAM,kCAAkC,KAAK,IAAI,SAAS;AAClE;;EAGF,MAAM,MAAM,MAAM,QAAQ;AAE1B,cAAY,IAAI,EADH,OAAO,QAAQ,aAAa,MAAM,IAAI,SAC3B,MAAM,CAAC;UACxB,KAAK;AACZ,UAAQ,MAAM,6BAA6B,KAAK,IAAI,IAAI;;;AAI5D,SAAS,kBAAkB,IAAiB,UAA2C;AACrF,KAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,KAAI,EAAE,0BAA0B,SAAS;AACvC,YAAU;AACV,SAAO;;CAGT,MAAM,WAAW,IAAI,sBAClB,YAAY;AACX,OAAK,MAAM,SAAS,QAClB,KAAI,MAAM,gBAAgB;AACxB,YAAS,YAAY;AACrB,aAAU;AACV;;IAIN,EAAE,YAAY,SAAS,CACxB;AAED,UAAS,QAAQ,GAAG;AACpB,cAAa,SAAS,YAAY"}
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../head/lib/ssr.js","../src/html.ts","../src/middleware.ts","../src/handler.ts","../src/island.ts","../src/ssg.ts"],"sourcesContent":["import { createContext, h, pushContext } from \"@pyreon/core\";\nimport { renderToString } from \"@pyreon/runtime-server\";\n\n//#region src/context.ts\nfunction createHeadContext() {\n\tconst map = /* @__PURE__ */ new Map();\n\tlet dirty = true;\n\tlet cachedTags = [];\n\tlet cachedTitleTemplate;\n\tlet cachedHtmlAttrs = {};\n\tlet cachedBodyAttrs = {};\n\tfunction rebuild() {\n\t\tif (!dirty) return;\n\t\tdirty = false;\n\t\tconst keyed = /* @__PURE__ */ new Map();\n\t\tconst unkeyed = [];\n\t\tlet titleTemplate;\n\t\tconst htmlAttrs = {};\n\t\tconst bodyAttrs = {};\n\t\tfor (const entry of map.values()) {\n\t\t\tfor (const tag of entry.tags) if (tag.key) keyed.set(tag.key, tag);\n\t\t\telse unkeyed.push(tag);\n\t\t\tif (entry.titleTemplate !== void 0) titleTemplate = entry.titleTemplate;\n\t\t\tif (entry.htmlAttrs) Object.assign(htmlAttrs, entry.htmlAttrs);\n\t\t\tif (entry.bodyAttrs) Object.assign(bodyAttrs, entry.bodyAttrs);\n\t\t}\n\t\tcachedTags = [...keyed.values(), ...unkeyed];\n\t\tcachedTitleTemplate = titleTemplate;\n\t\tcachedHtmlAttrs = htmlAttrs;\n\t\tcachedBodyAttrs = bodyAttrs;\n\t}\n\treturn {\n\t\tadd(id, entry) {\n\t\t\tmap.set(id, entry);\n\t\t\tdirty = true;\n\t\t},\n\t\tremove(id) {\n\t\t\tmap.delete(id);\n\t\t\tdirty = true;\n\t\t},\n\t\tresolve() {\n\t\t\trebuild();\n\t\t\treturn cachedTags;\n\t\t},\n\t\tresolveTitleTemplate() {\n\t\t\trebuild();\n\t\t\treturn cachedTitleTemplate;\n\t\t},\n\t\tresolveHtmlAttrs() {\n\t\t\trebuild();\n\t\t\treturn cachedHtmlAttrs;\n\t\t},\n\t\tresolveBodyAttrs() {\n\t\t\trebuild();\n\t\t\treturn cachedBodyAttrs;\n\t\t}\n\t};\n}\nconst HeadContext = createContext(null);\n\n//#endregion\n//#region src/ssr.ts\nconst VOID_TAGS = new Set([\n\t\"meta\",\n\t\"link\",\n\t\"base\"\n]);\nasync function renderWithHead(app) {\n\tconst ctx = createHeadContext();\n\tfunction HeadInjector() {\n\t\tpushContext(new Map([[HeadContext.id, ctx]]));\n\t\treturn app;\n\t}\n\tconst html = await renderToString(h(HeadInjector, null));\n\tconst titleTemplate = ctx.resolveTitleTemplate();\n\treturn {\n\t\thtml,\n\t\thead: ctx.resolve().map((tag) => serializeTag(tag, titleTemplate)).join(\"\\n \"),\n\t\thtmlAttrs: ctx.resolveHtmlAttrs(),\n\t\tbodyAttrs: ctx.resolveBodyAttrs()\n\t};\n}\nfunction serializeTag(tag, titleTemplate) {\n\tif (tag.tag === \"title\") {\n\t\tconst raw = tag.children || \"\";\n\t\treturn `<title>${esc(titleTemplate ? typeof titleTemplate === \"function\" ? titleTemplate(raw) : titleTemplate.replace(/%s/g, raw) : raw)}</title>`;\n\t}\n\tconst props = tag.props;\n\tconst attrs = props ? Object.entries(props).map(([k, v]) => `${k}=\"${esc(v)}\"`).join(\" \") : \"\";\n\tconst open = attrs ? `<${tag.tag} ${attrs}` : `<${tag.tag}`;\n\tif (VOID_TAGS.has(tag.tag)) return `${open} />`;\n\treturn `${open}>${(tag.children || \"\").replace(/<\\/(script|style|noscript)/gi, \"<\\\\/$1\").replace(/<!--/g, \"<\\\\!--\")}</${tag.tag}>`;\n}\nconst ESC_RE = /[&<>\"]/g;\nconst ESC_MAP = {\n\t\"&\": \"&amp;\",\n\t\"<\": \"&lt;\",\n\t\">\": \"&gt;\",\n\t\"\\\"\": \"&quot;\"\n};\nfunction esc(s) {\n\treturn ESC_RE.test(s) ? s.replace(ESC_RE, (ch) => ESC_MAP[ch]) : s;\n}\n\n//#endregion\nexport { renderWithHead };\n//# sourceMappingURL=ssr.js.map","/**\n * HTML template processing for SSR/SSG.\n *\n * Templates use comment placeholders:\n * <!--pyreon-head--> — replaced with <head> tags (title, meta, link, etc.)\n * <!--pyreon-app--> — replaced with rendered application HTML\n * <!--pyreon-scripts--> — replaced with client entry script + inline loader data\n */\n\nexport const DEFAULT_TEMPLATE = `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <!--pyreon-head-->\n</head>\n<body>\n <div id=\"app\"><!--pyreon-app--></div>\n <!--pyreon-scripts-->\n</body>\n</html>`\n\nexport interface TemplateData {\n head: string\n app: string\n scripts: string\n}\n\n/**\n * Pre-compiled template — splits the template string once so that\n * each request only concatenates 6 parts instead of scanning 3x with `.replace()`.\n */\nexport interface CompiledTemplate {\n /** [before-head, between-head-app, between-app-scripts, after-scripts] */\n parts: [string, string, string, string]\n}\n\nexport function compileTemplate(template: string): CompiledTemplate {\n if (!template.includes('<!--pyreon-app-->')) {\n throw new Error('[Pyreon] Template must contain <!--pyreon-app--> placeholder')\n }\n const [beforeHead, afterHead] = splitOnce(template, '<!--pyreon-head-->')\n const [betweenHeadApp, afterApp] = splitOnce(afterHead, '<!--pyreon-app-->')\n const [betweenAppScripts, afterScripts] = splitOnce(afterApp, '<!--pyreon-scripts-->')\n return { parts: [beforeHead, betweenHeadApp, betweenAppScripts, afterScripts] }\n}\n\nfunction splitOnce(str: string, delimiter: string): [string, string] {\n const idx = str.indexOf(delimiter)\n if (idx === -1) return [str, '']\n return [str.slice(0, idx), str.slice(idx + delimiter.length)]\n}\n\nexport function processTemplate(template: string, data: TemplateData): string {\n return template\n .replace('<!--pyreon-head-->', data.head)\n .replace('<!--pyreon-app-->', data.app)\n .replace('<!--pyreon-scripts-->', data.scripts)\n}\n\n/** Fast path using a pre-compiled template */\nexport function processCompiledTemplate(compiled: CompiledTemplate, data: TemplateData): string {\n const [p0, p1, p2, p3] = compiled.parts\n return p0 + data.head + p1 + data.app + p2 + data.scripts + p3\n}\n\n/**\n * Build the script tags for client hydration.\n *\n * Emits:\n * 1. Inline script with serialized loader data (if any)\n * 2. Module script tag pointing to the client entry\n */\nexport function buildScripts(\n clientEntry: string,\n loaderData: Record<string, unknown> | null,\n): string {\n const parts: string[] = []\n\n if (loaderData && Object.keys(loaderData).length > 0) {\n // Escape </script> inside JSON to prevent premature tag close\n const json = JSON.stringify(loaderData).replace(/<\\//g, '<\\\\/')\n parts.push(`<script>window.__PYREON_LOADER_DATA__=${json}</script>`)\n }\n\n parts.push(`<script type=\"module\" src=\"${clientEntry}\"></script>`)\n\n return parts.join('\\n ')\n}\n\n/** Pre-build the static client entry script tag (invariant across requests) */\nexport function buildClientEntryTag(clientEntry: string): string {\n return `<script type=\"module\" src=\"${clientEntry}\"></script>`\n}\n\n/** Fast path: build scripts with a pre-built client entry tag */\nexport function buildScriptsFast(\n clientEntryTag: string,\n loaderData: Record<string, unknown> | null,\n): string {\n if (loaderData && Object.keys(loaderData).length > 0) {\n const json = JSON.stringify(loaderData).replace(/<\\//g, '<\\\\/')\n return `<script>window.__PYREON_LOADER_DATA__=${json}</script>\\n ${clientEntryTag}`\n }\n return clientEntryTag\n}\n","/**\n * SSR middleware — simple request processing pipeline.\n *\n * Middleware runs before rendering. Return a Response to short-circuit\n * (e.g. for redirects, auth checks, or static file serving).\n * Return void / undefined to continue to the next middleware or rendering.\n *\n * @example\n * const authMiddleware: Middleware = async (ctx) => {\n * const token = ctx.req.headers.get(\"Authorization\")\n * if (!token) return new Response(\"Unauthorized\", { status: 401 })\n * ctx.locals.user = await verifyToken(token)\n * }\n *\n * const handler = createHandler({\n * App,\n * routes,\n * middleware: [authMiddleware],\n * })\n */\n\nimport { createContext, useContext, provide } from '@pyreon/core'\n\nexport interface MiddlewareContext {\n /** The incoming request */\n req: Request\n /** Parsed URL */\n url: URL\n /** Pathname + search (passed to router) */\n path: string\n /** Response headers — middleware can set custom headers */\n headers: Headers\n /** Arbitrary per-request data shared between middleware and components */\n locals: Record<string, unknown>\n}\n\n/**\n * Middleware function. Return a Response to short-circuit, or void to continue.\n */\nexport type Middleware = (ctx: MiddlewareContext) => Response | void | Promise<Response | void>\n\n/**\n * Context for per-request locals — populated by the SSR handler from\n * middleware `ctx.locals`. Components access it via `useRequestLocals()`.\n *\n * This bridges the middleware → component gap: middleware sets `ctx.locals`,\n * the handler provides it into the Pyreon context system, and components\n * read it without coupling to the middleware layer.\n */\nexport const RequestLocalsCtx = createContext<Record<string, unknown>>({})\n\n/**\n * Read per-request locals inside a component (SSR only).\n *\n * Returns the `ctx.locals` object populated by middleware.\n * On the client, returns an empty object.\n *\n * @example\n * ```tsx\n * import { useRequestLocals } from \"@pyreon/server\"\n *\n * function MyComponent() {\n * const locals = useRequestLocals()\n * const nonce = locals.cspNonce as string ?? ''\n * return <script nonce={nonce}>...</script>\n * }\n * ```\n */\nexport function useRequestLocals(): Record<string, unknown> {\n return useContext(RequestLocalsCtx)\n}\n\n/**\n * Provide request locals into the component tree.\n * Called by the SSR handler — not for direct use.\n * @internal\n */\nexport function provideRequestLocals(locals: Record<string, unknown>): void {\n provide(RequestLocalsCtx, locals)\n}\n","/**\n * SSR request handler.\n *\n * Creates a Web-standard `(Request) => Promise<Response>` handler that:\n * 1. Runs middleware (auth, redirects, headers, etc.)\n * 2. Creates a per-request router with the matched URL\n * 3. Prefetches loader data for matched routes\n * 4. Renders the app to HTML with head tag collection\n * 5. Injects everything into an HTML template\n * 6. Returns a Response\n *\n * Compatible with Bun.serve, Deno.serve, Cloudflare Workers,\n * Express (via adapter), and any Web-standard server.\n *\n * @example\n * import { createHandler } from \"@pyreon/server\"\n *\n * const handler = createHandler({\n * App,\n * routes,\n * template: await Bun.file(\"index.html\").text(),\n * })\n *\n * Bun.serve({ fetch: handler })\n */\n\nimport type { ComponentFn } from '@pyreon/core'\nimport { h } from '@pyreon/core'\nimport { renderWithHead } from '@pyreon/head/ssr'\nimport {\n createRouter,\n prefetchLoaderData,\n type RouteRecord,\n RouterProvider,\n serializeLoaderData,\n} from '@pyreon/router'\nimport { renderToStream, runWithRequestContext } from '@pyreon/runtime-server'\nimport {\n buildClientEntryTag,\n buildScriptsFast,\n type CompiledTemplate,\n compileTemplate,\n DEFAULT_TEMPLATE,\n processCompiledTemplate,\n} from './html'\nimport type { Middleware, MiddlewareContext } from './middleware'\nimport { provideRequestLocals } from './middleware'\n\nconst __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production'\n\nexport interface HandlerOptions {\n /** Root application component */\n App: ComponentFn\n /** Route definitions */\n routes: RouteRecord[]\n /**\n * HTML template with placeholders:\n * <!--pyreon-head--> — head tags (title, meta, link, etc.)\n * <!--pyreon-app--> — rendered app HTML\n * <!--pyreon-scripts--> — client entry + loader data\n *\n * Defaults to a minimal HTML5 template.\n */\n template?: string\n /** Path to the client entry module (default: \"/src/entry-client.ts\") */\n clientEntry?: string\n /** Middleware chain — runs before rendering */\n middleware?: Middleware[]\n /**\n * Rendering mode:\n * \"string\" (default) — full renderToString, complete HTML in one response\n * \"stream\" — progressive streaming via renderToStream (Suspense out-of-order)\n */\n mode?: 'string' | 'stream'\n /**\n * Collect CSS styles after rendering. Called after renderToString/renderWithHead.\n * Return a `<style>` tag string to inject into `<head>`.\n * Used by @pyreon/styler's sheet.getStyleTag() to prevent FOUC in SSG.\n *\n * @example\n * import { sheet } from '@pyreon/styler'\n * createHandler({\n * collectStyles: () => {\n * const tag = sheet.getStyleTag()\n * sheet.reset()\n * return tag\n * },\n * })\n */\n collectStyles?: () => string\n}\n\nexport function createHandler(options: HandlerOptions): (req: Request) => Promise<Response> {\n const {\n App,\n routes,\n template = DEFAULT_TEMPLATE,\n clientEntry = '/src/entry-client.ts',\n middleware = [],\n mode = 'string',\n collectStyles,\n } = options\n\n // Pre-compile once at handler creation — avoids 3x string scan per request\n const compiled = compileTemplate(template)\n const clientEntryTag = buildClientEntryTag(clientEntry)\n\n return async function handler(req: Request): Promise<Response> {\n const url = new URL(req.url)\n const path = url.pathname + url.search\n\n // ── Middleware pipeline ────────────────────────────────────────────────────\n const ctx: MiddlewareContext = {\n req,\n url,\n path,\n headers: new Headers({ 'Content-Type': 'text/html; charset=utf-8' }),\n locals: {},\n }\n\n for (const mw of middleware) {\n const result = await mw(ctx)\n if (result instanceof Response) return result\n }\n\n // ── Per-request router ────────────────────────────────────────────────────\n const router = createRouter({ routes, mode: 'history', url: path })\n\n return runWithRequestContext(async () => {\n try {\n // Bridge middleware locals → Pyreon context system so components\n // can access per-request data (CSP nonce, auth user, etc.)\n provideRequestLocals(ctx.locals)\n\n // Pre-run loaders so data is available during render\n await prefetchLoaderData(router as never, path)\n\n // Build the VNode tree\n const app = h(RouterProvider, { router }, h(App, null))\n\n if (mode === 'stream') {\n return renderStreamResponse(app, router, compiled, clientEntryTag, ctx.headers)\n }\n\n // ── String mode (default) ─────────────────────────────────────────────\n const { html: appHtml, head } = await renderWithHead(app)\n\n // Collect CSS-in-JS styles if a collector was provided.\n // The consumer passes collectStyles (e.g. sheet.getStyleTag from @pyreon/styler)\n // to inject scoped CSS into <head> and prevent FOUC in SSG pages.\n const styleTag = collectStyles ? collectStyles() : ''\n\n const loaderData = serializeLoaderData(router as never)\n const scripts = buildScriptsFast(clientEntryTag, loaderData)\n const headWithStyles = styleTag ? `${styleTag}\\n${head}` : head\n const fullHtml = processCompiledTemplate(compiled, { head: headWithStyles, app: appHtml, scripts })\n\n return new Response(fullHtml, { status: 200, headers: ctx.headers })\n } catch (err) {\n if (__DEV__) {\n console.error('[Pyreon Server] SSR render failed:', err)\n }\n return new Response('Internal Server Error', {\n status: 500,\n headers: { 'Content-Type': 'text/plain' },\n })\n }\n })\n }\n}\n\n/**\n * Streaming mode: shell is emitted immediately, app content streams progressively.\n *\n * Head tags from the initial synchronous render are included in the shell.\n * Suspense boundaries resolve out-of-order via inline <template> + swap scripts.\n */\nasync function renderStreamResponse(\n app: ReturnType<typeof h>,\n router: ReturnType<typeof createRouter>,\n compiled: CompiledTemplate,\n clientEntryTag: string,\n extraHeaders: Headers,\n): Promise<Response> {\n const loaderData = serializeLoaderData(router as never)\n const scripts = buildScriptsFast(clientEntryTag, loaderData)\n\n // Use pre-split parts: [before-head, between-head-app, between-app-scripts, after-scripts]\n const [p0, p1, p2, p3] = compiled.parts\n const shellHead = p0 + p1\n const shellTail = p2 + scripts + p3\n\n const appStream = renderToStream(app)\n const reader = appStream.getReader()\n\n const stream = new ReadableStream<Uint8Array>({\n async start(controller) {\n const encoder = new TextEncoder()\n const push = (s: string) => controller.enqueue(encoder.encode(s))\n\n try {\n push(shellHead)\n\n // Stream app content\n let done = false\n while (!done) {\n const result = await reader.read()\n done = result.done\n if (result.value) push(result.value)\n }\n\n push(shellTail)\n } catch (err) {\n if (__DEV__) {\n console.error('[Pyreon Server] Stream render failed:', err)\n }\n // Emit an inline error indicator — status code is already sent (200)\n push(`<script>console.error(\"[pyreon/server] Stream render failed\")</script>`)\n push(shellTail)\n } finally {\n controller.close()\n }\n },\n })\n\n return new Response(stream, {\n status: 200,\n headers: extraHeaders,\n })\n}\n","/**\n * Island architecture — partial hydration for content-heavy sites.\n *\n * Islands are interactive components embedded in otherwise-static HTML.\n * Only island components ship JavaScript to the client — the rest of the\n * page stays as zero-JS server-rendered HTML.\n *\n * ## Server side\n *\n * `island()` wraps an async component import and returns a ComponentFn.\n * During SSR, it renders the component output inside a `<pyreon-island>` element\n * with serialized props, so the client knows what to hydrate.\n *\n * ```tsx\n * import { island } from \"@pyreon/server\"\n *\n * const Counter = island(() => import(\"./Counter\"), { name: \"Counter\" })\n * const Search = island(() => import(\"./Search\"), { name: \"Search\" })\n *\n * function Page() {\n * return <div>\n * <h1>Static heading (no JS)</h1>\n * <Counter initial={5} /> // hydrated on client\n * <p>Static paragraph</p>\n * <Search /> // hydrated on client\n * </div>\n * }\n * ```\n *\n * ## Client side\n *\n * Use `hydrateIslands()` from `@pyreon/server/client` to hydrate all islands\n * on the page. Only the island components' JavaScript is loaded.\n *\n * ```ts\n * // entry-client.ts (island mode)\n * import { hydrateIslands } from \"@pyreon/server/client\"\n *\n * hydrateIslands({\n * Counter: () => import(\"./Counter\"),\n * Search: () => import(\"./Search\"),\n * })\n * ```\n *\n * ## Hydration strategies\n *\n * Control when an island hydrates via the `hydrate` option:\n * - \"load\" (default) — hydrate immediately on page load\n * - \"idle\" — hydrate when the browser is idle (requestIdleCallback)\n * - \"visible\" — hydrate when the island scrolls into the viewport\n * - \"media(query)\" — hydrate when a media query matches\n * - \"never\" — never hydrate (render-only, no client JS)\n */\n\nimport type { ComponentFn, Props, VNode } from '@pyreon/core'\nimport { h } from '@pyreon/core'\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport type HydrationStrategy = 'load' | 'idle' | 'visible' | 'never' | `media(${string})`\n\nexport interface IslandOptions {\n /** Unique name — must match the key in the client-side hydrateIslands() registry */\n name: string\n /** When to hydrate on the client (default: \"load\") */\n hydrate?: HydrationStrategy\n}\n\nexport interface IslandMeta {\n readonly __island: true\n readonly name: string\n readonly hydrate: HydrationStrategy\n}\n\n// ─── Server-side island factory ──────────────────────────────────────────────\n\n/**\n * Create an island component.\n *\n * Returns an async ComponentFn that:\n * 1. Resolves the dynamic import\n * 2. Renders the component to VNodes\n * 3. Wraps the output in `<pyreon-island>` with serialized props + hydration strategy\n */\nexport function island<P extends Props = Props>(\n loader: () => Promise<{ default: ComponentFn<P> } | ComponentFn<P>>,\n options: IslandOptions,\n): ComponentFn<P> & IslandMeta {\n const { name, hydrate = 'load' } = options\n\n const IslandWrapper = async function IslandWrapper(props: P): Promise<VNode | null> {\n const mod = await loader()\n const Comp = typeof mod === 'function' ? mod : mod.default\n const serializedProps = serializeIslandProps(props)\n\n return h(\n 'pyreon-island',\n {\n 'data-component': name,\n 'data-props': serializedProps,\n 'data-hydrate': hydrate,\n },\n h(Comp, props),\n )\n }\n\n // Attach metadata so the Vite plugin can detect islands for code-splitting\n const wrapper = IslandWrapper as unknown as ComponentFn<P> & IslandMeta\n Object.defineProperties(wrapper, {\n __island: { value: true, enumerable: true },\n name: { value: name, enumerable: true, writable: false, configurable: true },\n hydrate: { value: hydrate, enumerable: true },\n })\n\n return wrapper\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\n/**\n * Serialize component props to a JSON string for embedding in HTML attributes.\n * Strips non-serializable values (functions, symbols, children).\n */\nfunction serializeIslandProps(props: Record<string, unknown>): string {\n const clean: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(props)) {\n // Skip non-serializable or internal props\n if (key === 'children') continue\n if (typeof value === 'function') continue\n if (typeof value === 'symbol') continue\n if (value === undefined) continue\n clean[key] = value\n }\n // The SSR renderer's renderProp() already applies escapeHtml() to attribute\n // values, so the JSON is safe to embed in HTML attributes without double-escaping.\n return JSON.stringify(clean)\n}\n","/**\n * Static Site Generation — pre-render routes to HTML files at build time.\n *\n * @example\n * // ssg.ts (run with: bun run ssg.ts)\n * import { createHandler } from \"@pyreon/server\"\n * import { prerender } from \"@pyreon/server\"\n * import { App } from \"./src/App\"\n * import { routes } from \"./src/routes\"\n *\n * const handler = createHandler({ App, routes })\n *\n * await prerender({\n * handler,\n * paths: [\"/\", \"/about\", \"/blog\", \"/blog/hello-world\"],\n * outDir: \"dist\",\n * })\n *\n * @example\n * // Dynamic paths from a CMS or filesystem\n * await prerender({\n * handler,\n * paths: async () => {\n * const posts = await fetchAllPosts()\n * return [\"/\", \"/about\", ...posts.map(p => `/blog/${p.slug}`)]\n * },\n * outDir: \"dist\",\n * })\n */\n\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, join, resolve } from 'node:path'\n\nexport interface PrerenderOptions {\n /** SSR handler created by createHandler() */\n handler: (req: Request) => Promise<Response>\n /** Routes to pre-render — array of URL paths or async function that returns them */\n paths: string[] | (() => string[] | Promise<string[]>)\n /** Output directory for the generated HTML files */\n outDir: string\n /** Origin for constructing full URLs (default: \"http://localhost\") */\n origin?: string\n /**\n * Called after each page is rendered — use for logging or progress tracking.\n * Return false to skip writing this page.\n */\n onPage?: (path: string, html: string) => void | boolean | Promise<void | boolean>\n}\n\nexport interface PrerenderResult {\n /** Number of pages generated */\n pages: number\n /** Paths that failed to render */\n errors: { path: string; error: unknown }[]\n /** Total elapsed time in milliseconds */\n elapsed: number\n}\n\n/**\n * Pre-render a list of routes to static HTML files.\n *\n * For each path:\n * 1. Constructs a Request for the path\n * 2. Calls the SSR handler to render to HTML\n * 3. Writes the HTML to `outDir/<path>/index.html`\n *\n * The root path \"/\" becomes `outDir/index.html`.\n * Paths like \"/about\" become `outDir/about/index.html`.\n */\nexport async function prerender(options: PrerenderOptions): Promise<PrerenderResult> {\n const { handler, outDir, origin = 'http://localhost', onPage } = options\n\n const start = Date.now()\n\n // Resolve paths (may be async)\n const paths = typeof options.paths === 'function' ? await options.paths() : options.paths\n\n let pages = 0\n const errors: PrerenderResult['errors'] = []\n\n async function renderPage(path: string): Promise<void> {\n const url = new URL(path, origin)\n const req = new Request(url.href)\n const res = await Promise.race([\n handler(req),\n new Promise<never>((_, reject) =>\n setTimeout(() => reject(new Error(`Prerender timeout for \"${path}\" (30s)`)), 30_000),\n ),\n ])\n\n if (!res.ok) {\n errors.push({ path, error: new Error(`HTTP ${res.status}`) })\n return\n }\n\n const html = await res.text()\n\n if (onPage) {\n const result = await onPage(path, html)\n if (result === false) return\n }\n\n const filePath = resolveOutputPath(outDir, path)\n\n const resolvedOut = resolve(outDir)\n if (!resolve(filePath).startsWith(resolvedOut)) {\n errors.push({ path, error: new Error(`Path traversal detected: \"${path}\"`) })\n return\n }\n\n await mkdir(dirname(filePath), { recursive: true })\n await writeFile(filePath, html, 'utf-8')\n pages++\n }\n\n // Process paths concurrently (batch of 10 to avoid overwhelming)\n const BATCH_SIZE = 10\n for (let i = 0; i < paths.length; i += BATCH_SIZE) {\n const batch = paths.slice(i, i + BATCH_SIZE)\n await Promise.all(\n batch.map(async (path) => {\n try {\n await renderPage(path)\n } catch (error) {\n errors.push({ path, error })\n }\n }),\n )\n }\n\n return {\n pages,\n errors,\n elapsed: Date.now() - start,\n }\n}\n\nfunction resolveOutputPath(outDir: string, path: string): string {\n if (path === '/') return join(outDir, 'index.html')\n if (path.endsWith('.html')) return join(outDir, path)\n return join(outDir, path, 'index.html')\n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a"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"client2.d.ts","names":[],"sources":["../../../src/client.ts"],"mappings":";;;;UAmCiB,kBAAA;EAoD4C;EAlD3D,GAAA,EAAK,WAAA;EAkD0B;EAhD/B,MAAA,EAAQ,WAAA;EAgDgB;EA9CxB,SAAA,YAAqB,OAAA;AAAA;;;;AAgEvB;;;;;;;iBAnDgB,WAAA,CAAY,OAAA,EAAS,kBAAA;AAAA,KAiChC,YAAA,SAAqB,OAAA;EAAU,OAAA,EAAS,WAAA;AAAA,IAAgB,WAAA;;;;;;;;;;;;;;;;;iBAkB7C,cAAA,CAAe,QAAA,EAAU,MAAA,SAAe,YAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index2.d.ts","names":[],"sources":["../../../src/middleware.ts","../../../src/handler.ts","../../../src/html.ts","../../../src/island.ts","../../../src/ssg.ts"],"mappings":";;;;;;;;AAuBA;;;;;;;;;;;;;;;;UAAiB,iBAAA;EAUP;EARR,GAAA,EAAK,OAAA;EAQS;EANd,GAAA,EAAK,GAAA;EAYe;EAVpB,IAAA;EAU6B;EAR7B,OAAA,EAAS,OAAA;EAQoE;EAN7E,MAAA,EAAQ,MAAA;AAAA;;;;KAME,UAAA,IAAc,GAAA,EAAK,iBAAA,KAAsB,QAAA,UAAkB,OAAA,CAAQ,QAAA;;;;ACW/E;;;;;;;;;;;;;;iBDkBgB,gBAAA,CAAA,GAAoB,MAAA;;;UClBnB,cAAA;EDX8D;ECa7E,GAAA,EAAK,WAAA;EDbuE;ECe5E,MAAA,EAAQ,WAAA;EDfqB;;;;;;;AA6B/B;ECLE,QAAA;;EAEA,WAAA;EDGwC;ECDxC,UAAA,GAAa,UAAA;;;AAjBf;;;EAuBE,IAAA;EAnBQ;;;;;;;;;;;;;;;EAmCR,aAAA;AAAA;AAAA,iBAGc,aAAA,CAAc,OAAA,EAAS,cAAA,IAAkB,GAAA,EAAK,OAAA,KAAY,OAAA,CAAQ,QAAA;;;;;;;ADrElF;;;;c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