@ilha/router 0.8.2 → 0.8.4
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/index.js +1 -1
- package/dist/{src-C_n-faIh.js → src-BFzs4FwW.js} +24 -3
- package/dist/ssr.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as wrapLayout, C as routePath, D as src_default, E as serializeHead, M as setHistoryMode, O as useRoute, S as routeParams, T as router, _ as navigating, a as RouterView, b as redirect, c as composeLoaders, d as error, f as head, g as navigate, h as loader, i as RouterLink, j as getHistoryMode, k as wrapError, l as defineLayout, m as isActive, n as LoaderError, o as afterNavigate, p as invalidate, r as Redirect, s as beforeNavigate, t as LOADER_ENDPOINT, u as enableLinkInterception, v as prefetch, w as routeSearch, x as routeHash, y as prime } from "./src-
|
|
1
|
+
import { A as wrapLayout, C as routePath, D as src_default, E as serializeHead, M as setHistoryMode, O as useRoute, S as routeParams, T as router, _ as navigating, a as RouterView, b as redirect, c as composeLoaders, d as error, f as head, g as navigate, h as loader, i as RouterLink, j as getHistoryMode, k as wrapError, l as defineLayout, m as isActive, n as LoaderError, o as afterNavigate, p as invalidate, r as Redirect, s as beforeNavigate, t as LOADER_ENDPOINT, u as enableLinkInterception, v as prefetch, w as routeSearch, x as routeHash, y as prime } from "./src-BFzs4FwW.js";
|
|
2
2
|
|
|
3
3
|
export { LOADER_ENDPOINT, LoaderError, Redirect, RouterLink, RouterView, afterNavigate, beforeNavigate, composeLoaders, src_default as default, defineLayout, enableLinkInterception, error, getHistoryMode, head, invalidate, isActive, loader, navigate, navigating, prefetch, prime, redirect, routeHash, routeParams, routePath, routeSearch, router, serializeHead, setHistoryMode, useRoute, wrapError, wrapLayout };
|
|
@@ -309,8 +309,13 @@ function injectKPageSlot(layoutHtml, slotInnerHtml, which) {
|
|
|
309
309
|
function layoutHtmlWithEmptyKPage(wrappedLayout, props) {
|
|
310
310
|
const handler = wrappedLayout[WRAP_LAYOUT_HANDLER];
|
|
311
311
|
if (!handler) return wrappedLayout.toString(props);
|
|
312
|
-
const
|
|
313
|
-
|
|
312
|
+
const rawKeyed = (wrappedLayout[WRAP_LAYOUT_LEAF] ?? wrappedLayout).key("page");
|
|
313
|
+
const shellChild = ((partial) => rawKeyed({
|
|
314
|
+
...props,
|
|
315
|
+
...partial ?? {}
|
|
316
|
+
}));
|
|
317
|
+
Object.assign(shellChild, { toString: () => "" });
|
|
318
|
+
return handler(shellChild).toString(props);
|
|
314
319
|
}
|
|
315
320
|
async function wrapLayoutSlotMarkup(innerWrapped, leafPage, props, opts) {
|
|
316
321
|
const pageInner = extractHydratableInnerHtml(await leafPage.hydratable(props, opts));
|
|
@@ -319,9 +324,22 @@ async function wrapLayoutSlotMarkup(innerWrapped, leafPage, props, opts) {
|
|
|
319
324
|
function wrapLayout(layout, page) {
|
|
320
325
|
const leafPage = page[WRAP_LAYOUT_LEAF] ?? page;
|
|
321
326
|
const childWrapped = leafPage !== page ? page : null;
|
|
322
|
-
const
|
|
327
|
+
const rawKeyedPage = page.key("page");
|
|
328
|
+
const layoutInputRef = {};
|
|
329
|
+
const KeyedPage = ((props) => {
|
|
330
|
+
const merged = layoutInputRef.merged;
|
|
331
|
+
return rawKeyedPage(merged && typeof merged === "object" ? {
|
|
332
|
+
...merged,
|
|
333
|
+
...props ?? {}
|
|
334
|
+
} : props);
|
|
335
|
+
});
|
|
336
|
+
Object.assign(KeyedPage, { toString: page.toString.bind(page) });
|
|
337
|
+
const Wrapped = layout(KeyedPage);
|
|
323
338
|
Wrapped[WRAP_LAYOUT_LEAF] = leafPage;
|
|
324
339
|
Wrapped[WRAP_LAYOUT_HANDLER] = layout;
|
|
340
|
+
function setLayoutMergedInput(props) {
|
|
341
|
+
layoutInputRef.merged = props;
|
|
342
|
+
}
|
|
325
343
|
function pageMountHost(host) {
|
|
326
344
|
const slots = [...host.querySelectorAll("[data-ilha-slot=\"k:page\"]")].filter((slot) => {
|
|
327
345
|
const boundary = slot.closest("[data-ilha]");
|
|
@@ -378,10 +396,12 @@ function wrapLayout(layout, page) {
|
|
|
378
396
|
preparePageMountHost(host, pageMountHost(host));
|
|
379
397
|
}
|
|
380
398
|
Wrapped.mount = (host, props) => {
|
|
399
|
+
setLayoutMergedInput(props);
|
|
381
400
|
prepareLayoutMountHost(host);
|
|
382
401
|
return layoutMount(host, props);
|
|
383
402
|
};
|
|
384
403
|
Wrapped[ISLAND_MOUNT_INTERNAL] = (host, props) => {
|
|
404
|
+
setLayoutMergedInput(props);
|
|
385
405
|
prepareLayoutMountHost(host);
|
|
386
406
|
if (typeof layoutInternal === "function") return layoutInternal(host, props);
|
|
387
407
|
return {
|
|
@@ -392,6 +412,7 @@ function wrapLayout(layout, page) {
|
|
|
392
412
|
Wrapped.hydratable = async (props, opts) => {
|
|
393
413
|
if (!opts?.name) throw new Error("wrapLayout: hydratable requires options.name");
|
|
394
414
|
const resolvedProps = props ?? {};
|
|
415
|
+
setLayoutMergedInput(resolvedProps);
|
|
395
416
|
const pageBlock = await leafPage.hydratable(resolvedProps, opts);
|
|
396
417
|
const open = parseHydratableOpenTag(pageBlock);
|
|
397
418
|
if (!open) return pageBlock;
|
package/dist/ssr.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ilha/router",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "A tiny SPA router for Ilha",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"frontend",
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"unplugin": "3.3.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"ilha": "0.9.
|
|
71
|
+
"ilha": "0.9.2",
|
|
72
72
|
"vite": "^8.1.3"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"ilha": ">=0.9.
|
|
75
|
+
"ilha": ">=0.9.2"
|
|
76
76
|
}
|
|
77
77
|
}
|