@takazudo/zfb-runtime 0.1.0-next.31 → 0.1.0-next.33

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 (2) hide show
  1. package/README.md +36 -6
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -39,7 +39,9 @@ user pages/ + content/ + layouts/ + components/
39
39
 
40
40
  This package supplies the page-router factory the Worker entry calls. It
41
41
  is built on [Hono][hono] but does not leak Hono types through the public
42
- surface — consumers only see the four types in `src/index.ts`.
42
+ surface — consumers import from `src/index.ts`, which re-exports the
43
+ page-router types, the client-router and prefetch API, lifecycle event
44
+ constants, and plugin types, none of which require Hono.
43
45
 
44
46
  [hono]: https://hono.dev/
45
47
 
@@ -64,6 +66,35 @@ import type {
64
66
  } from "@takazudo/zfb-runtime";
65
67
  ```
66
68
 
69
+ ### Client-router / view-transitions / prefetch
70
+
71
+ ```ts
72
+ import {
73
+ ClientRouter, // <ClientRouter /> Preact component — mounts view-transition intercepts
74
+ navigate, // imperative navigation
75
+ supportsViewTransitions, // browser capability check
76
+ transitionEnabledOnThisPage, // reads zfb-view-transitions-enabled meta
77
+ prefetch, // prefetch a URL on demand
78
+ prefetchInit, // bootstrap prefetch strategy (e.g. { prefetchAll: true })
79
+ TRANSITION_BEFORE_PREPARATION,
80
+ TRANSITION_AFTER_PREPARATION,
81
+ TRANSITION_BEFORE_SWAP,
82
+ TRANSITION_AFTER_SWAP,
83
+ TRANSITION_PAGE_LOAD,
84
+ TRANSITION_NAVIGATION_ABORTED,
85
+ swapFunctions, // swap step overrides for advanced consumers
86
+ swap,
87
+ } from "@takazudo/zfb-runtime";
88
+ ```
89
+
90
+ The `./snapshot` and `./client-router` subpath exports are also available for
91
+ consumers that only need part of the surface:
92
+
93
+ ```ts
94
+ import type { ContentSnapshot } from "@takazudo/zfb-runtime/snapshot";
95
+ import { ClientRouter } from "@takazudo/zfb-runtime/client-router";
96
+ ```
97
+
67
98
  ### `createPageRouter(options) → PageRouter`
68
99
 
69
100
  Build a fetch-handler that serves the supplied pages. The returned
@@ -108,8 +139,10 @@ The shape every page module must export:
108
139
  interface PageModule {
109
140
  readonly default: (props: Record<string, unknown>) => unknown;
110
141
  readonly prerender?: boolean; // literal `false` excludes from SSG
111
- readonly content_type?: string; // overrides Content-Type (e.g. "application/xml")
142
+ readonly contentType?: string; // overrides Content-Type (e.g. "application/xml")
112
143
  readonly headings?: readonly PageHeading[]; // MDX-emitted TOC data
144
+ readonly paths?: () => unknown[] | Promise<unknown[]>; // enumerates concrete URLs for dynamic routes (SSG)
145
+ readonly getStaticProps?: () => Promise<{ props: Record<string, unknown> }>; // fetches props at build/render time; result spread into default()
113
146
  }
114
147
 
115
148
  interface PageHeading {
@@ -126,12 +159,9 @@ Default `Content-Type` is `text/html; charset=utf-8`.
126
159
  ```ts
127
160
  interface FrameworkAdapter {
128
161
  renderToString: (vnode: unknown) => string;
129
- hydrate?: (...args: unknown[]) => unknown; // reserved for follow-up SSR-with-hydration
130
162
  }
131
163
  ```
132
164
 
133
- `hydrate` is reserved — the page router does not call it today.
134
-
135
165
  ### `ContentSnapshot` / `EntrySnapshot`
136
166
 
137
167
  Direct TypeScript mirror of the Rust contract in
@@ -200,7 +230,7 @@ enumerated route and writing the response body to `dist/{route}/index.html`.
200
230
  - The returned function is **always** `(request: Request) => Promise<Response>`,
201
231
  even if the underlying Hono path returns synchronously.
202
232
  - `Content-Type` defaults to `text/html; charset=utf-8`. Page modules
203
- with a `content_type` field override it.
233
+ with a `contentType` field override it.
204
234
  - Errors in page evaluation surface as 500 responses with a diagnostic
205
235
  text body; the host's source-map plumbing projects those back to the
206
236
  user's TSX line.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takazudo/zfb-runtime",
3
- "version": "0.1.0-next.31",
3
+ "version": "0.1.0-next.33",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "JavaScript runtime for zfb static sites — Hono-backed page router, content snapshots, and client-side hydration.",
@@ -60,7 +60,7 @@
60
60
  "hono": "^4.12.23"
61
61
  },
62
62
  "peerDependencies": {
63
- "@takazudo/zfb": "0.1.0-next.31"
63
+ "@takazudo/zfb": "0.1.0-next.33"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/node": "^22.0.0",
@@ -69,7 +69,7 @@
69
69
  "react": "^19.2.3",
70
70
  "typescript": "^5.9.0",
71
71
  "vitest": "^2.1.9",
72
- "@takazudo/zfb": "0.1.0-next.31"
72
+ "@takazudo/zfb": "0.1.0-next.33"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsc",