@nifrajs/web-preact 2.10.0 → 2.12.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.
- package/dist/client.d.ts +14 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -1
- package/dist/client.js.map +1 -1
- package/dist/query.d.ts +1 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -1
- package/dist/query.js.map +1 -1
- package/dist/router.d.ts +2 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +3 -1
- package/dist/router.js.map +1 -1
- package/package.json +11 -9
- package/src/client.ts +18 -1
- package/src/query.ts +4 -6
- package/src/router.ts +15 -7
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MountRouterOptions, RenderProps } from "@nifrajs/web";
|
|
2
2
|
export { errorBoundary } from "./error.js";
|
|
3
|
+
/**
|
|
4
|
+
* Preact cannot apply Bun's hot updates, so the generated client entry reloads instead.
|
|
5
|
+
*
|
|
6
|
+
* Bun's dev server runs React Fast Refresh over JSX modules. A Preact component compiles to JSX that
|
|
7
|
+
* looks the same, so the update is ACCEPTED - and then dropped, because Preact's refresh runtime
|
|
8
|
+
* (prefresh) is not the one Bun installs. Measured: `bun:beforeUpdate` and `bun:afterUpdate` both fire,
|
|
9
|
+
* the server logs the rebuild, the browser keeps rendering the old component and never reloads. The
|
|
10
|
+
* edit simply appears not to happen.
|
|
11
|
+
*
|
|
12
|
+
* Reloading loses component state, which React keeps here. That is the honest trade until Bun's dev
|
|
13
|
+
* server can install prefresh: a visible reload beats an edit that silently does nothing.
|
|
14
|
+
*/
|
|
15
|
+
export declare const hotUpdateNeedsReload = true;
|
|
3
16
|
/** Hydrate a server-rendered Preact layout `chain` (with the loader `props`) inside `container`. */
|
|
4
17
|
export declare function hydrate(chain: readonly unknown[], props: RenderProps, container: unknown): void;
|
|
5
18
|
/**
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAkBnE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAA;AAExC,oGAAoG;AACpG,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAE/F;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAmB7D"}
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// `/client`, not the root: the root's graph carries the server, and Vite's dev server evaluates it
|
|
2
|
+
// instead of tree-shaking it - which broke hydration before the browser ran a line of app code.
|
|
3
|
+
import { searchOfChain } from "@nifrajs/web/client";
|
|
2
4
|
/**
|
|
3
5
|
* @nifrajs/web-preact/client - Preact client runtime. `hydrate` hydrates a single SSR'd route;
|
|
4
6
|
* `mountRouter` hydrates a stateful Router that subscribes to the agnostic store (via
|
|
@@ -13,6 +15,19 @@ import { setMountedRouter } from "./fetcher.js";
|
|
|
13
15
|
// The `_error` boundary chain element - defined in its own (DOM-free) module, re-exported here so
|
|
14
16
|
// nifra's client codegen resolves it from `@nifrajs/web-preact/client` alongside `mountRouter`.
|
|
15
17
|
export { errorBoundary } from "./error.js";
|
|
18
|
+
/**
|
|
19
|
+
* Preact cannot apply Bun's hot updates, so the generated client entry reloads instead.
|
|
20
|
+
*
|
|
21
|
+
* Bun's dev server runs React Fast Refresh over JSX modules. A Preact component compiles to JSX that
|
|
22
|
+
* looks the same, so the update is ACCEPTED - and then dropped, because Preact's refresh runtime
|
|
23
|
+
* (prefresh) is not the one Bun installs. Measured: `bun:beforeUpdate` and `bun:afterUpdate` both fire,
|
|
24
|
+
* the server logs the rebuild, the browser keeps rendering the old component and never reloads. The
|
|
25
|
+
* edit simply appears not to happen.
|
|
26
|
+
*
|
|
27
|
+
* Reloading loses component state, which React keeps here. That is the honest trade until Bun's dev
|
|
28
|
+
* server can install prefresh: a visible reload beats an edit that silently does nothing.
|
|
29
|
+
*/
|
|
30
|
+
export const hotUpdateNeedsReload = true;
|
|
16
31
|
/** Hydrate a server-rendered Preact layout `chain` (with the loader `props`) inside `container`. */
|
|
17
32
|
export function hydrate(chain, props, container) {
|
|
18
33
|
preactHydrate(compose(chain, props), container);
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,mGAAmG;AACnG,gGAAgG;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD;;;;;;GAMG;AACH,OAAO,EAA0B,CAAC,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,kGAAkG;AAClG,gGAAgG;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAA;AAExC,oGAAoG;AACpG,MAAM,UAAU,OAAO,CAAC,KAAyB,EAAE,KAAkB,EAAE,SAAkB;IACvF,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,SAAoB,CAAC,CAAA;AAC5D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAC5D,gBAAgB,CAAC,MAAM,CAAC,CAAA,CAAC,+DAA+D;IACxF,MAAM,MAAM,GAAsB,GAAG,EAAE;QACrC,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrE,uGAAuG;QACvG,uFAAuF;QACvF,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACjC,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACrD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;YAC1C,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,aAAa,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC;YACtE,2EAA2E;YAC3E,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9D,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,SAAoB,CAAC,CAAA;AACtD,CAAC"}
|
package/dist/query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { QueryClient, QueryState } from "@nifrajs/web";
|
|
2
2
|
/** Access the query client to imperatively `invalidateQueries(keyOrPrefix)` (e.g. after a mutation). */
|
|
3
3
|
export declare function useQueryClient(): Pick<QueryClient, "invalidateQueries">;
|
|
4
4
|
/** A query's reactive {@link QueryState} plus `isPending` + `refetch`. */
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAe,UAAU,EAAE,MAAM,cAAc,CAAA;AAwBxE,wGAAwG;AACxG,wBAAgB,cAAc,IAAI,IAAI,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAEvE;AAgBD,0EAA0E;AAC1E,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IACtD,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAA;CACnC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAejF"}
|
package/dist/query.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// `/client`, not the root - these are DOM values, and the root's graph carries the
|
|
2
|
+
// server, which Vite's dev server evaluates rather than tree-shakes.
|
|
3
|
+
import { createQueryClient } from "@nifrajs/web/client";
|
|
2
4
|
/**
|
|
3
5
|
* `@nifrajs/web-preact/query` - Preact bindings for the keyed query-cache. `useQuery(key, fn)` subscribes a
|
|
4
6
|
* component to a query (via `useSyncExternalStore` from preact/compat) and fetches on mount / key change;
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,mFAAmF;AACnF,qEAAqE;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD;;;;;;;;;GASG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,IAAI,MAA+B,CAAA;AACnC,SAAS,SAAS;IAChB,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,SAAS,CAAA,CAAC,wCAAwC;IAC5F,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAC/E,OAAO,MAAM,CAAA;AACf,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,cAAc;IAC5B,OAAO,SAAS,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAA;AACvD,CAAC;AAED,wGAAwG;AACxG,MAAM,IAAI,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,MAAM,CAAC,iBAAiB;CACpC,CAAC,CAAA;AACF,MAAM,YAAY,GAAG,GAAsB,EAAE,CAAC,IAAI,CAAA;AAClD,MAAM,aAAa,GAAG,GAAiB,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,CAAA;AAClD,MAAM,SAAS,GAAG,KAAK,IAAoB,EAAE;IAC3C,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAA;AAC9F,CAAC,CAAA;AAUD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAI,GAAY,EAAE,EAAoB;IAC5D,MAAM,MAAM,GAA+B,SAAS,EAAE,EAAE,KAAK,CAAI,GAAG,EAAE,EAAE,CAAC,CAAA;IACzE,MAAM,KAAK,GAAG,oBAAoB,CAChC,MAAM,EAAE,SAAS,IAAI,aAAa,EAClC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CACxC,CAAA;IACD,wGAAwG;IACxG,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAC1D,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IACZ,OAAO;QACL,GAAG,KAAK;QACR,SAAS,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS;QACrC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAE,SAA8B;KACnE,CAAA;AACH,CAAC"}
|
package/dist/router.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InferOutput, StandardSchemaV1 } from "@nifrajs/core/server";
|
|
2
|
-
import {
|
|
3
|
-
export type { Blocker, BlockerFunction, BlockerState, NavigateFunction }
|
|
2
|
+
import type { Blocker, BlockerFunction, BlockerState, NavigateFunction } from "@nifrajs/web";
|
|
3
|
+
export type { Blocker, BlockerFunction, BlockerState, NavigateFunction };
|
|
4
4
|
export declare const SearchContext: import("preact").Context<Record<string, unknown>>;
|
|
5
5
|
/**
|
|
6
6
|
* The route's typed, validated search params - the SAME value the loader received as `ctx.search`.
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAIzE,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,YAAY,EACZ,gBAAgB,EAGjB,MAAM,cAAc,CAAA;AAmBrB,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAgBxE,eAAO,MAAM,aAAa,mDACsE,CAAA;AAGhG;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,MAAM,SAAS,gBAAgB,GAAG,SAAS,GAAG,SAAS,KACpD,MAAM,SAAS,gBAAgB,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAInF;AAED;;sEAEsE;AACtE,wBAAgB,WAAW,IAAI,gBAAgB,CAO9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,OAAO,GAAG,eAAe,GAAG,OAAO,CAe1E"}
|
package/dist/router.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// `/client`, not the root - these are DOM values, and the root's graph carries the
|
|
2
|
+
// server, which Vite's dev server evaluates rather than tree-shakes.
|
|
3
|
+
import { getBrowserNavigate, IDLE_BLOCKER, registerBlocker, resolveNavigate, } from "@nifrajs/web/client";
|
|
2
4
|
/**
|
|
3
5
|
* `@nifrajs/web-preact/router` - Preact routing bindings over the agnostic `@nifrajs/web` history layer:
|
|
4
6
|
* `useNavigate` (programmatic navigation), `useBlocker` (the unsaved-changes guard), and `useSearch`
|
package/dist/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAYA,mFAAmF;AACnF,qEAAqE;AACrE,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIpF,2EAA2E;AAC3E,MAAM,YAAY,GAAsC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAEzE;;;;;;2BAM2B;AAC3B,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;AACzE,MAAM,iBAAiB,GAAG,UAEzB,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GACxB,iBAAiB,CAAC,mBAAmB,CAAC,IAAI,aAAa,CAA0B,YAAY,CAAC,CAAA;AAChG,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,aAAa,CAAA;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS;IAGvB,OAAO,UAAU,CAAC,aAAa,CAEJ,CAAA;AAC7B,CAAC;AAED;;sEAEsE;AACtE,MAAM,UAAU,WAAW;IACzB,OAAO,WAAW,CAAC,CAAC,EAAyC,EAAE,OAAyB,EAAE,EAAE;QAC1F,MAAM,QAAQ,GAAG,kBAAkB,EAAE,CAAA;QACrC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAM;QAClC,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC,EAAE,EAAE,CAAqB,CAAA;AAC5B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,WAAsC;IAC/D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,YAAY,CAAC,CAAA;IAC7D,oGAAoG;IACpG,oFAAoF;IACpF,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;IAC1C,cAAc,CAAC,OAAO,GAAG,WAAW,CAAA;IACpC,SAAS,CACP,GAAG,EAAE,CACH,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE;QACvB,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAA;QACtC,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IAChE,CAAC,EAAE,UAAU,CAAC,EAChB,EAAE,CACH,CAAA;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/web-preact",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Preact render adapter for @nifrajs/web - streaming SSR + hydration (no build plugin).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
7
7
|
"typescript",
|
|
8
8
|
"nifra",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"ssr"
|
|
9
|
+
"preact",
|
|
10
|
+
"ssr",
|
|
11
|
+
"hydration",
|
|
12
|
+
"streaming-ssr",
|
|
13
|
+
"render-adapter",
|
|
14
|
+
"full-stack"
|
|
13
15
|
],
|
|
14
16
|
"type": "module",
|
|
15
17
|
"main": "./dist/index.js",
|
|
@@ -80,10 +82,10 @@
|
|
|
80
82
|
"access": "public"
|
|
81
83
|
},
|
|
82
84
|
"dependencies": {
|
|
83
|
-
"@nifrajs/core": "2.
|
|
84
|
-
"@nifrajs/i18n": "2.
|
|
85
|
-
"@nifrajs/image": "2.
|
|
86
|
-
"@nifrajs/web": "2.
|
|
85
|
+
"@nifrajs/core": "2.12.0",
|
|
86
|
+
"@nifrajs/i18n": "2.12.0",
|
|
87
|
+
"@nifrajs/image": "2.12.0",
|
|
88
|
+
"@nifrajs/web": "2.12.0",
|
|
87
89
|
"preact-render-to-string": "^6.5.0"
|
|
88
90
|
},
|
|
89
91
|
"peerDependencies": {
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MountRouterOptions, RenderProps } from "@nifrajs/web"
|
|
2
|
+
// `/client`, not the root: the root's graph carries the server, and Vite's dev server evaluates it
|
|
3
|
+
// instead of tree-shaking it - which broke hydration before the browser ran a line of app code.
|
|
4
|
+
import { searchOfChain } from "@nifrajs/web/client"
|
|
2
5
|
/**
|
|
3
6
|
* @nifrajs/web-preact/client - Preact client runtime. `hydrate` hydrates a single SSR'd route;
|
|
4
7
|
* `mountRouter` hydrates a stateful Router that subscribes to the agnostic store (via
|
|
@@ -15,6 +18,20 @@ import { setMountedRouter } from "./fetcher.ts"
|
|
|
15
18
|
// nifra's client codegen resolves it from `@nifrajs/web-preact/client` alongside `mountRouter`.
|
|
16
19
|
export { errorBoundary } from "./error.ts"
|
|
17
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Preact cannot apply Bun's hot updates, so the generated client entry reloads instead.
|
|
23
|
+
*
|
|
24
|
+
* Bun's dev server runs React Fast Refresh over JSX modules. A Preact component compiles to JSX that
|
|
25
|
+
* looks the same, so the update is ACCEPTED - and then dropped, because Preact's refresh runtime
|
|
26
|
+
* (prefresh) is not the one Bun installs. Measured: `bun:beforeUpdate` and `bun:afterUpdate` both fire,
|
|
27
|
+
* the server logs the rebuild, the browser keeps rendering the old component and never reloads. The
|
|
28
|
+
* edit simply appears not to happen.
|
|
29
|
+
*
|
|
30
|
+
* Reloading loses component state, which React keeps here. That is the honest trade until Bun's dev
|
|
31
|
+
* server can install prefresh: a visible reload beats an edit that silently does nothing.
|
|
32
|
+
*/
|
|
33
|
+
export const hotUpdateNeedsReload = true
|
|
34
|
+
|
|
18
35
|
/** Hydrate a server-rendered Preact layout `chain` (with the loader `props`) inside `container`. */
|
|
19
36
|
export function hydrate(chain: readonly unknown[], props: RenderProps, container: unknown): void {
|
|
20
37
|
preactHydrate(compose(chain, props), container as Element)
|
package/src/query.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type QueryState,
|
|
6
|
-
} from "@nifrajs/web"
|
|
1
|
+
import type { QueryClient, QueryHandle, QueryState } from "@nifrajs/web"
|
|
2
|
+
// `/client`, not the root - these are DOM values, and the root's graph carries the
|
|
3
|
+
// server, which Vite's dev server evaluates rather than tree-shakes.
|
|
4
|
+
import { createQueryClient } from "@nifrajs/web/client"
|
|
7
5
|
/**
|
|
8
6
|
* `@nifrajs/web-preact/query` - Preact bindings for the keyed query-cache. `useQuery(key, fn)` subscribes a
|
|
9
7
|
* component to a query (via `useSyncExternalStore` from preact/compat) and fetches on mount / key change;
|
package/src/router.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import type { InferOutput, StandardSchemaV1 } from "@nifrajs/core/server"
|
|
2
|
+
// `import type` + a local re-export, NOT `export type { … } from "@nifrajs/web"`: that form leaves a
|
|
3
|
+
// bare `import "@nifrajs/web"` in the output, which pulls the server graph into the browser under
|
|
4
|
+
// Vite's dev server. Sourced from the ROOT so the generated `RouteSearch` augmentation applies.
|
|
5
|
+
import type {
|
|
6
|
+
Blocker,
|
|
7
|
+
BlockerFunction,
|
|
8
|
+
BlockerState,
|
|
9
|
+
NavigateFunction,
|
|
10
|
+
NavigateOptions,
|
|
11
|
+
NavigateTargetInput,
|
|
12
|
+
} from "@nifrajs/web"
|
|
13
|
+
// `/client`, not the root - these are DOM values, and the root's graph carries the
|
|
14
|
+
// server, which Vite's dev server evaluates rather than tree-shakes.
|
|
2
15
|
import {
|
|
3
|
-
type Blocker,
|
|
4
|
-
type BlockerFunction,
|
|
5
16
|
getBrowserNavigate,
|
|
6
17
|
IDLE_BLOCKER,
|
|
7
|
-
type NavigateFunction,
|
|
8
|
-
type NavigateOptions,
|
|
9
|
-
type NavigateTargetInput,
|
|
10
18
|
registerBlocker,
|
|
11
19
|
resolveNavigate,
|
|
12
|
-
} from "@nifrajs/web"
|
|
20
|
+
} from "@nifrajs/web/client"
|
|
13
21
|
/**
|
|
14
22
|
* `@nifrajs/web-preact/router` - Preact routing bindings over the agnostic `@nifrajs/web` history layer:
|
|
15
23
|
* `useNavigate` (programmatic navigation), `useBlocker` (the unsaved-changes guard), and `useSearch`
|
|
@@ -20,7 +28,7 @@ import {
|
|
|
20
28
|
import { createContext } from "preact"
|
|
21
29
|
import { useCallback, useContext, useEffect, useRef, useState } from "preact/compat"
|
|
22
30
|
|
|
23
|
-
export type { Blocker, BlockerFunction, BlockerState, NavigateFunction }
|
|
31
|
+
export type { Blocker, BlockerFunction, BlockerState, NavigateFunction }
|
|
24
32
|
|
|
25
33
|
// Frozen empty search so the default context value has a stable reference.
|
|
26
34
|
const EMPTY_SEARCH: Readonly<Record<string, unknown>> = Object.freeze({})
|