@moku-labs/web 0.5.4 → 0.5.5

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/browser.mjs CHANGED
@@ -3303,11 +3303,10 @@ function createSpaKernel(state, config, emit, deps) {
3303
3303
  const region = document.querySelector(resolved.swapSelector);
3304
3304
  if (!region) return false;
3305
3305
  handleStart(pathname);
3306
- const { renderVNode } = await import("./render-BL9Fv6G6.mjs");
3306
+ const { renderVNode } = await import("./render-BNe0s7fr.mjs");
3307
3307
  syncDataHead(hit.route, routeContext);
3308
3308
  unmountPageSpecific(state, emit);
3309
3309
  runSwap(() => {
3310
- region.replaceChildren();
3311
3310
  renderVNode(vnode, region);
3312
3311
  scanAndMount(state, emit, resolved.swapSelector);
3313
3312
  notifyNavEnd(state);
package/dist/index.cjs CHANGED
@@ -6701,11 +6701,10 @@ function createSpaKernel(state, config, emit, deps) {
6701
6701
  const region = document.querySelector(resolved.swapSelector);
6702
6702
  if (!region) return false;
6703
6703
  handleStart(pathname);
6704
- const { renderVNode } = await Promise.resolve().then(() => require("./render-BSTM0Akv.cjs"));
6704
+ const { renderVNode } = await Promise.resolve().then(() => require("./render-DLZEOe4M.cjs"));
6705
6705
  syncDataHead(hit.route, routeContext);
6706
6706
  unmountPageSpecific(state, emit);
6707
6707
  runSwap(() => {
6708
- region.replaceChildren();
6709
6708
  renderVNode(vnode, region);
6710
6709
  scanAndMount(state, emit, resolved.swapSelector);
6711
6710
  notifyNavEnd(state);
package/dist/index.mjs CHANGED
@@ -6688,11 +6688,10 @@ function createSpaKernel(state, config, emit, deps) {
6688
6688
  const region = document.querySelector(resolved.swapSelector);
6689
6689
  if (!region) return false;
6690
6690
  handleStart(pathname);
6691
- const { renderVNode } = await import("./render-BL9Fv6G6.mjs");
6691
+ const { renderVNode } = await import("./render-BNe0s7fr.mjs");
6692
6692
  syncDataHead(hit.route, routeContext);
6693
6693
  unmountPageSpecific(state, emit);
6694
6694
  runSwap(() => {
6695
- region.replaceChildren();
6696
6695
  renderVNode(vnode, region);
6697
6696
  scanAndMount(state, emit, resolved.swapSelector);
6698
6697
  notifyNavEnd(state);
@@ -0,0 +1,32 @@
1
+ import { render } from "preact";
2
+ //#region src/plugins/spa/render.ts
3
+ /**
4
+ * Render a route's `VNode` into the live swap region, starting from a clean slate
5
+ * each time. Preact keeps the previous vdom tree on the container and diffs the
6
+ * next render against it — but the kernel clears the region between navs to drop
7
+ * the static SSR markup. A raw `replaceChildren()` would delete the live DOM out
8
+ * from under Preact's retained vdom, so the next diff patches detached nodes → an
9
+ * empty region (the bug where a SECOND consecutive client nav went blank).
10
+ *
11
+ * To stay correct without tracking element identity, first `render(null, region)`
12
+ * — this unmounts any Preact tree Preact owns AND resets its retained vdom pointer
13
+ * (a no-op the first time, when the region still holds raw SSR/HTML). Then clear
14
+ * whatever static children remain, then mount the new VNode fresh. Reuses the
15
+ * build's component output verbatim (same `route.render`), so the client paint
16
+ * matches the SSG paint.
17
+ *
18
+ * @param vnode - The VNode produced by the matched route's `.render(ctx)`.
19
+ * @param region - The swap-region element to render into.
20
+ * @example
21
+ * ```ts
22
+ * const { renderVNode } = await import("./render");
23
+ * renderVNode(route._handlers.render(ctx), document.querySelector("main > section"));
24
+ * ```
25
+ */
26
+ function renderVNode(vnode, region) {
27
+ render(null, region);
28
+ region.replaceChildren();
29
+ render(vnode, region);
30
+ }
31
+ //#endregion
32
+ export { renderVNode };
@@ -0,0 +1,32 @@
1
+ let preact = require("preact");
2
+ //#region src/plugins/spa/render.ts
3
+ /**
4
+ * Render a route's `VNode` into the live swap region, starting from a clean slate
5
+ * each time. Preact keeps the previous vdom tree on the container and diffs the
6
+ * next render against it — but the kernel clears the region between navs to drop
7
+ * the static SSR markup. A raw `replaceChildren()` would delete the live DOM out
8
+ * from under Preact's retained vdom, so the next diff patches detached nodes → an
9
+ * empty region (the bug where a SECOND consecutive client nav went blank).
10
+ *
11
+ * To stay correct without tracking element identity, first `render(null, region)`
12
+ * — this unmounts any Preact tree Preact owns AND resets its retained vdom pointer
13
+ * (a no-op the first time, when the region still holds raw SSR/HTML). Then clear
14
+ * whatever static children remain, then mount the new VNode fresh. Reuses the
15
+ * build's component output verbatim (same `route.render`), so the client paint
16
+ * matches the SSG paint.
17
+ *
18
+ * @param vnode - The VNode produced by the matched route's `.render(ctx)`.
19
+ * @param region - The swap-region element to render into.
20
+ * @example
21
+ * ```ts
22
+ * const { renderVNode } = await import("./render");
23
+ * renderVNode(route._handlers.render(ctx), document.querySelector("main > section"));
24
+ * ```
25
+ */
26
+ function renderVNode(vnode, region) {
27
+ (0, preact.render)(null, region);
28
+ region.replaceChildren();
29
+ (0, preact.render)(vnode, region);
30
+ }
31
+ //#endregion
32
+ exports.renderVNode = renderVNode;
package/package.json CHANGED
@@ -112,5 +112,5 @@
112
112
  "test:integration": "vitest run --project integration",
113
113
  "test:coverage": "vitest run --project unit --project integration --coverage"
114
114
  },
115
- "version": "0.5.4"
115
+ "version": "0.5.5"
116
116
  }
@@ -1,20 +0,0 @@
1
- import { render } from "preact";
2
- //#region src/plugins/spa/render.ts
3
- /**
4
- * Render a route's `VNode` into the live swap region, replacing its contents.
5
- * Reuses the build's component output verbatim (same `route.render`), so the
6
- * client paint matches the SSG paint.
7
- *
8
- * @param vnode - The VNode produced by the matched route's `.render(ctx)`.
9
- * @param region - The swap-region element to render into.
10
- * @example
11
- * ```ts
12
- * const { renderVNode } = await import("./render");
13
- * renderVNode(route._handlers.render(ctx), document.querySelector("main > section"));
14
- * ```
15
- */
16
- function renderVNode(vnode, region) {
17
- render(vnode, region);
18
- }
19
- //#endregion
20
- export { renderVNode };
@@ -1,20 +0,0 @@
1
- let preact = require("preact");
2
- //#region src/plugins/spa/render.ts
3
- /**
4
- * Render a route's `VNode` into the live swap region, replacing its contents.
5
- * Reuses the build's component output verbatim (same `route.render`), so the
6
- * client paint matches the SSG paint.
7
- *
8
- * @param vnode - The VNode produced by the matched route's `.render(ctx)`.
9
- * @param region - The swap-region element to render into.
10
- * @example
11
- * ```ts
12
- * const { renderVNode } = await import("./render");
13
- * renderVNode(route._handlers.render(ctx), document.querySelector("main > section"));
14
- * ```
15
- */
16
- function renderVNode(vnode, region) {
17
- (0, preact.render)(vnode, region);
18
- }
19
- //#endregion
20
- exports.renderVNode = renderVNode;