@takazudo/zfb-runtime 0.1.0-next.77 → 0.1.0-next.79
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/README.md +31 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ import type {
|
|
|
76
76
|
|
|
77
77
|
```ts
|
|
78
78
|
import {
|
|
79
|
-
ClientRouter, // <
|
|
79
|
+
ClientRouter, // framework-agnostic <head> helper — enables view-transition intercepts
|
|
80
80
|
navigate, // imperative navigation
|
|
81
81
|
supportsViewTransitions, // browser capability check
|
|
82
82
|
transitionEnabledOnThisPage, // reads zfb-view-transitions-enabled meta
|
|
@@ -123,6 +123,25 @@ export default function Layout({ children }) {
|
|
|
123
123
|
}
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
+
`ClientRouterProps`:
|
|
127
|
+
|
|
128
|
+
- `fallback?: "none" | "animate" | "swap"` controls the fallback strategy
|
|
129
|
+
when native View Transitions are unavailable. The default is `"animate"`.
|
|
130
|
+
- `prefetchAll?: boolean` bootstraps same-origin link prefetching with the
|
|
131
|
+
default hover strategy. Treat this as a site-wide router policy and mount
|
|
132
|
+
the same value on every page that participates in SPA navigation.
|
|
133
|
+
- `preserveHtmlAttrs?: string[]` emits
|
|
134
|
+
`<meta name="zfb-preserve-html-attrs">` so the swap step preserves
|
|
135
|
+
runtime-owned `<html>` attributes such as `data-theme`. Mount the same
|
|
136
|
+
list on every soft-navigable page: the router reads the outgoing page's
|
|
137
|
+
meta before each swap, so a page that omits a name can drop that
|
|
138
|
+
attribute when navigating away.
|
|
139
|
+
- `traverseRefetch?: boolean` emits
|
|
140
|
+
`<meta name="zfb-traverse-refetch" content="true">` to opt out of the
|
|
141
|
+
same-URL Back/Forward fast path for per-request SSR pages whose content
|
|
142
|
+
can change at the same URL. Mount the same value on every page in that
|
|
143
|
+
SPA navigation set so traversal behavior is deterministic.
|
|
144
|
+
|
|
126
145
|
**How the runtime reaches the browser.** `<ClientRouter />` itself only renders
|
|
127
146
|
SSR `<head>` tags. The click/form interception is registered by an `init()` call
|
|
128
147
|
that runs as a side effect when `@takazudo/zfb-runtime/client-router` is imported
|
|
@@ -270,7 +289,7 @@ export default { fetch: router };
|
|
|
270
289
|
from memory rather than the Node `fs` API. Workers have no `fs`,
|
|
271
290
|
so this branch is the production path. Idempotent; subsequent
|
|
272
291
|
calls overwrite (matches the dev-mode live-reload contract).
|
|
273
|
-
2. Constructs an internal Hono app and registers `app.
|
|
292
|
+
2. Constructs an internal Hono app and registers `app.all(page.route, …)`
|
|
274
293
|
for every entry in `pages`. The handler imports the page module,
|
|
275
294
|
calls `framework.renderToString(module.default({}))`, and returns
|
|
276
295
|
the string in a `Response`.
|
|
@@ -348,7 +367,7 @@ esbuild step. The bundle's entry point must look like this:
|
|
|
348
367
|
|
|
349
368
|
```ts
|
|
350
369
|
// dist/worker.mjs (shape — generated by the bundler, not committed)
|
|
351
|
-
import { createPageRouter } from "@takazudo/zfb-runtime";
|
|
370
|
+
import { createPageRouter } from "@takazudo/zfb-runtime/server";
|
|
352
371
|
import * as preactRender from "preact-render-to-string";
|
|
353
372
|
|
|
354
373
|
import HomePage from "./pages/index.tsx";
|
|
@@ -401,10 +420,12 @@ pnpm --filter @takazudo/zfb-runtime typecheck
|
|
|
401
420
|
```
|
|
402
421
|
|
|
403
422
|
Tests run in `vitest` under Node's `node` environment (no jsdom — the
|
|
404
|
-
|
|
405
|
-
natively).
|
|
406
|
-
|
|
407
|
-
|
|
423
|
+
server-side router targets the Workers `fetch` model, which Node
|
|
424
|
+
implements natively). Client-router DOM suites opt into
|
|
425
|
+
`@vitest-environment happy-dom` per test file. The framework adapter is
|
|
426
|
+
stubbed so tests do not pull in preact-render-to-string. Determinism is
|
|
427
|
+
asserted by rendering twice from independently-constructed routers and
|
|
428
|
+
comparing byte-equal.
|
|
408
429
|
|
|
409
430
|
The embedded V8 host is **not** booted from this package's tests — that
|
|
410
431
|
integration belongs to the Rust-side build host. The end-to-end
|
|
@@ -416,5 +437,6 @@ route") is exercised by the host crate's test suite, not here.
|
|
|
416
437
|
`createPageRouter` calls `setContentSnapshot` from `zfb/content`. The
|
|
417
438
|
two modules share module-level state, so they must resolve to the same
|
|
418
439
|
instance — pinning `zfb` as a peer dep makes that explicit and lets pnpm
|
|
419
|
-
hoist a single shared copy.
|
|
420
|
-
`
|
|
440
|
+
hoist a single shared copy. Install matching published versions of
|
|
441
|
+
`@takazudo/zfb-runtime` and `@takazudo/zfb` so that shared state remains
|
|
442
|
+
single-instanced.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zfb-runtime",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.79",
|
|
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.",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"react": "^19.2.3",
|
|
78
|
-
"@takazudo/zfb": "0.1.0-next.
|
|
78
|
+
"@takazudo/zfb": "0.1.0-next.79"
|
|
79
79
|
},
|
|
80
80
|
"peerDependenciesMeta": {
|
|
81
81
|
"react": {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"react": "^19.2.3",
|
|
90
90
|
"typescript": "^5.9.0",
|
|
91
91
|
"vitest": "^2.1.9",
|
|
92
|
-
"@takazudo/zfb": "0.1.0-next.
|
|
92
|
+
"@takazudo/zfb": "0.1.0-next.79"
|
|
93
93
|
},
|
|
94
94
|
"scripts": {
|
|
95
95
|
"build": "tsc",
|