@takazudo/zfb-runtime 0.1.0-next.14 → 0.1.0-next.15
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-router.d.ts","sourceRoot":"","sources":["../src/client-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-router.d.ts","sourceRoot":"","sources":["../src/client-router.ts"],"names":[],"mappings":"AAoDA,MAAM,WAAW,iBAAiB;IAChC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACvB,CAAC;AAyCF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAoB,EACpB,WAAW,EAAE,eAAuB,GACrC,GAAE,iBAAsB,GAAG,SAAS,mBAAmB,EAAE,CA6CzD"}
|
package/dist/client-router.js
CHANGED
|
@@ -12,13 +12,19 @@
|
|
|
12
12
|
// via `init()`. The component calls `init()` as a side effect on first import.
|
|
13
13
|
// No inline <script> dangerouslySetInnerHTML is emitted.
|
|
14
14
|
//
|
|
15
|
-
//
|
|
16
|
-
// `@takazudo/zfb-runtime` does not depend on
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
15
|
+
// Framework-agnostic element minting (no JSX syntax):
|
|
16
|
+
// `@takazudo/zfb-runtime` does not depend on a framework runtime. Head nodes
|
|
17
|
+
// are minted by calling `jsx` from `react/jsx-runtime` directly — NOT JSX
|
|
18
|
+
// syntax, so this stays a plain `.ts` file with no tsconfig JSX changes. The
|
|
19
|
+
// engine alias-rewrites `react/jsx-runtime` → `preact/jsx-runtime` in Preact
|
|
20
|
+
// mode (bundler.rs ~2886) and resolves it natively in React mode, so the same
|
|
21
|
+
// call mints a real element for whichever framework the project configured.
|
|
22
|
+
// The previous approach (a hand-rolled `{ type, props, key, constructor:
|
|
23
|
+
// undefined }` object literal — the Preact diff-path sentinel) only worked for
|
|
24
|
+
// Preact: React's renderer rejects such an object as a child with React error
|
|
25
|
+
// #31 ("Objects are not valid as a React child"), because a real React element
|
|
26
|
+
// carries `$$typeof: Symbol.for("react.element")` a literal cannot fake. Same
|
|
27
|
+
// migration as `Island` in @takazudo/zfb.
|
|
22
28
|
//
|
|
23
29
|
// The component renders three sibling elements to <head>:
|
|
24
30
|
// 1. A <style> tag with the `.zfb-route-announcer` ARIA helper class.
|
|
@@ -27,6 +33,7 @@
|
|
|
27
33
|
//
|
|
28
34
|
// The route-announcer <div> is injected into <body> by `announce()` in
|
|
29
35
|
// `client-router/router.ts` on every navigation.
|
|
36
|
+
import { jsx } from "react/jsx-runtime";
|
|
30
37
|
import { init } from "./client-router/router.js";
|
|
31
38
|
import { init as prefetchInit } from "./client-router/prefetch.js";
|
|
32
39
|
// Side-effect: wire click + submit intercepts on first import of this component.
|
|
@@ -39,14 +46,23 @@ if (typeof document !== "undefined") {
|
|
|
39
46
|
// lifetime even if <ClientRouter prefetchAll /> is mounted multiple times (#276).
|
|
40
47
|
let prefetchBootstrapped = false;
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
49
|
+
* Mint a head element through the per-project JSX runtime.
|
|
50
|
+
*
|
|
51
|
+
* Calls `jsx` from `react/jsx-runtime` (alias-rewritten to
|
|
52
|
+
* `preact/jsx-runtime` in Preact mode by the engine, native in React mode)
|
|
53
|
+
* so the returned value is a real element for whichever framework the
|
|
54
|
+
* project configured — NOT a hand-rolled `{ type, props, key }` literal,
|
|
55
|
+
* which only Preact accepts and which makes React throw error #31. A stable
|
|
56
|
+
* `key` is passed because `ClientRouter()` returns these nodes in a plain
|
|
57
|
+
* array (React warns about keyless list children otherwise). Mirrors the
|
|
58
|
+
* `Island` migration in `@takazudo/zfb`.
|
|
45
59
|
*/
|
|
46
|
-
function makeVNode(type, props) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
function makeVNode(type, props, key) {
|
|
61
|
+
// `jsx`'s `type` param is typed `ElementType` (string-literal intrinsic
|
|
62
|
+
// tags or component types), which rejects an arbitrary runtime `string`.
|
|
63
|
+
// The tag is dynamic here, so cast to the factory's own first-param type —
|
|
64
|
+
// robust whether the engine aliases `jsx` to react or preact at build time.
|
|
65
|
+
return jsx(type, props, key);
|
|
50
66
|
}
|
|
51
67
|
// CSS for the route-announcer element. Ported verbatim from Astro's
|
|
52
68
|
// `<style is:global>` block in ClientRouter.astro (lines 11–23), renaming
|
|
@@ -91,11 +107,11 @@ export function ClientRouter({ fallback = "animate", prefetchAll: prefetchAllPro
|
|
|
91
107
|
}
|
|
92
108
|
const nodes = [
|
|
93
109
|
// Global styles for the ARIA route-announcer div injected into <body>.
|
|
94
|
-
makeVNode("style", { dangerouslySetInnerHTML: { __html: announcerCss } }),
|
|
110
|
+
makeVNode("style", { dangerouslySetInnerHTML: { __html: announcerCss } }, "zfb-vt-style"),
|
|
95
111
|
// Opt-in meta tag: router checks for this to decide whether to intercept navigations.
|
|
96
|
-
makeVNode("meta", { name: "zfb-view-transitions-enabled", content: "true" }),
|
|
112
|
+
makeVNode("meta", { name: "zfb-view-transitions-enabled", content: "true" }, "zfb-vt-enabled"),
|
|
97
113
|
// Fallback strategy meta tag: read by getFallback() in router.ts.
|
|
98
|
-
makeVNode("meta", { name: "zfb-view-transitions-fallback", content: fallback }),
|
|
114
|
+
makeVNode("meta", { name: "zfb-view-transitions-fallback", content: fallback }, "zfb-vt-fallback"),
|
|
99
115
|
];
|
|
100
116
|
// Prefetch-disabled meta tag (#277): emitted when the bundler set
|
|
101
117
|
// `globalThis.__zfb.prefetchDisabled = true` (from `zfb.config.ts`
|
|
@@ -110,7 +126,7 @@ export function ClientRouter({ fallback = "animate", prefetchAll: prefetchAllPro
|
|
|
110
126
|
// Pin the contract verbatim — the attribute names and content value are
|
|
111
127
|
// shared with the sibling prefetch-core sub-issue (#276).
|
|
112
128
|
if (globalThis.__zfb?.prefetchDisabled === true) {
|
|
113
|
-
nodes.push(makeVNode("meta", { name: "zfb-prefetch-disabled", content: "true" }));
|
|
129
|
+
nodes.push(makeVNode("meta", { name: "zfb-prefetch-disabled", content: "true" }, "zfb-prefetch-disabled"));
|
|
114
130
|
}
|
|
115
131
|
return nodes;
|
|
116
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-router.js","sourceRoot":"","sources":["../src/client-router.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,wDAAwD;AACxD,uDAAuD;AACvD,yEAAyE;AACzE,EAAE;AACF,2DAA2D;AAC3D,2EAA2E;AAC3E,6EAA6E;AAC7E,2EAA2E;AAC3E,+EAA+E;AAC/E,iFAAiF;AACjF,2DAA2D;AAC3D,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"client-router.js","sourceRoot":"","sources":["../src/client-router.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,wDAAwD;AACxD,uDAAuD;AACvD,yEAAyE;AACzE,EAAE;AACF,2DAA2D;AAC3D,2EAA2E;AAC3E,6EAA6E;AAC7E,2EAA2E;AAC3E,+EAA+E;AAC/E,iFAAiF;AACjF,2DAA2D;AAC3D,EAAE;AACF,sDAAsD;AACtD,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,2EAA2E;AAC3E,iFAAiF;AACjF,gFAAgF;AAChF,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KAAK,GAA0B;QACnC,uEAAuE;QACvE,SAAS,CAAC,OAAO,EAAE,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,cAAc,CAAC;QACzF,sFAAsF;QACtF,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,gBAAgB,CAAC;QAC9F,kEAAkE;QAClE,SAAS,CACP,MAAM,EACN,EAAE,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,QAAQ,EAAE,EAC5D,iBAAiB,CAClB;KACF,CAAC;IAEF,kEAAkE;IAClE,mEAAmE;IACnE,0EAA0E;IAC1E,iFAAiF;IACjF,gDAAgD;IAChD,EAAE;IACF,yEAAyE;IACzE,+EAA+E;IAC/E,iBAAiB;IACjB,EAAE;IACF,wEAAwE;IACxE,0DAA0D;IAC1D,IAAK,UAAyD,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,EAAE,CAAC;QAChG,KAAK,CAAC,IAAI,CACR,SAAS,CACP,MAAM,EACN,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,EAAE,EAClD,uBAAuB,CACxB,CACF,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
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.15",
|
|
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,14 +60,16 @@
|
|
|
60
60
|
"hono": "^4.7.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@takazudo/zfb": "0.1.0-next.
|
|
63
|
+
"@takazudo/zfb": "0.1.0-next.15"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^22.0.0",
|
|
67
|
+
"@types/react": "^18.3.0",
|
|
67
68
|
"happy-dom": "^15.7.4",
|
|
69
|
+
"react": "^18.3.1",
|
|
68
70
|
"typescript": "^5.9.0",
|
|
69
71
|
"vitest": "^2.1.9",
|
|
70
|
-
"@takazudo/zfb": "0.1.0-next.
|
|
72
|
+
"@takazudo/zfb": "0.1.0-next.15"
|
|
71
73
|
},
|
|
72
74
|
"scripts": {
|
|
73
75
|
"build": "tsc",
|