@wordpress/boot 0.24.0 → 0.26.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/build-module/components/app/index.mjs +29 -53
- package/build-module/components/app/index.mjs.map +1 -7
- package/build-module/components/app/router.mjs +238 -214
- package/build-module/components/app/router.mjs.map +1 -7
- package/build-module/components/app/use-route-title.mjs +35 -42
- package/build-module/components/app/use-route-title.mjs.map +1 -7
- package/build-module/components/canvas/back-button.mjs +21 -20
- package/build-module/components/canvas/back-button.mjs.map +1 -7
- package/build-module/components/canvas/index.mjs +103 -129
- package/build-module/components/canvas/index.mjs.map +1 -7
- package/build-module/components/canvas/site-preview.mjs +36 -43
- package/build-module/components/canvas/site-preview.mjs.map +1 -7
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +109 -113
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +1 -7
- package/build-module/components/canvas/viewport.mjs +25 -13
- package/build-module/components/canvas/viewport.mjs.map +1 -7
- package/build-module/components/canvas-renderer/index.mjs +40 -32
- package/build-module/components/canvas-renderer/index.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +160 -108
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/navigation/drilldown-item/index.mjs +124 -127
- package/build-module/components/navigation/drilldown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/dropdown-item/index.mjs +156 -173
- package/build-module/components/navigation/dropdown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/index.mjs +55 -90
- package/build-module/components/navigation/index.mjs.map +1 -7
- package/build-module/components/navigation/items.mjs +51 -53
- package/build-module/components/navigation/items.mjs.map +1 -7
- package/build-module/components/navigation/navigation-item/index.mjs +120 -114
- package/build-module/components/navigation/navigation-item/index.mjs.map +1 -7
- package/build-module/components/navigation/navigation-screen/index.mjs +192 -185
- package/build-module/components/navigation/navigation-screen/index.mjs.map +1 -7
- package/build-module/components/navigation/path-matching.mjs +74 -73
- package/build-module/components/navigation/path-matching.mjs.map +1 -7
- package/build-module/components/navigation/router-link-item.mjs +13 -11
- package/build-module/components/navigation/router-link-item.mjs.map +1 -7
- package/build-module/components/navigation/use-sidebar-parent.mjs +37 -48
- package/build-module/components/navigation/use-sidebar-parent.mjs.map +1 -7
- package/build-module/components/plugin-area/index.mjs +20 -24
- package/build-module/components/plugin-area/index.mjs.map +1 -7
- package/build-module/components/root/index.mjs +227 -242
- package/build-module/components/root/index.mjs.map +1 -7
- package/build-module/components/root/single-page.mjs +174 -148
- package/build-module/components/root/single-page.mjs.map +1 -7
- package/build-module/components/root/use-sync-body-background.mjs +28 -22
- package/build-module/components/root/use-sync-body-background.mjs.map +1 -7
- package/build-module/components/save-button/index.mjs +170 -214
- package/build-module/components/save-button/index.mjs.map +1 -7
- package/build-module/components/save-panel/index.mjs +110 -106
- package/build-module/components/save-panel/index.mjs.map +1 -7
- package/build-module/components/save-panel/use-save-shortcut.mjs +42 -51
- package/build-module/components/save-panel/use-save-shortcut.mjs.map +1 -7
- package/build-module/components/sidebar/index.mjs +126 -104
- package/build-module/components/sidebar/index.mjs.map +1 -7
- package/build-module/index.mjs +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +34 -31
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/index.mjs +9 -11
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +48 -55
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +21 -16
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/types.mjs +0 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/store/types.d.ts +1 -1
- package/package.json +30 -31
- package/src/components/canvas/index.tsx +2 -2
- package/src/components/error-boundary/index.tsx +50 -4
- package/src/store/types.ts +1 -1
- package/CHANGELOG.md +0 -81
- package/build-module/index.mjs.map +0 -7
- package/build-module/store/types.mjs.map +0 -7
|
@@ -1,241 +1,265 @@
|
|
|
1
|
-
// packages/boot/src/components/app/router.tsx
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import { useMemo } from "@wordpress/element";
|
|
4
3
|
import { Page } from "@wordpress/admin-ui";
|
|
5
|
-
import {
|
|
6
|
-
privateApis as routePrivateApis
|
|
7
|
-
} from "@wordpress/route";
|
|
4
|
+
import { privateApis } from "@wordpress/route";
|
|
8
5
|
import { resolveSelect } from "@wordpress/data";
|
|
9
|
-
import { store
|
|
6
|
+
import { store } from "@wordpress/core-data";
|
|
10
7
|
import Root from "../root/index.mjs";
|
|
11
|
-
|
|
8
|
+
import ErrorBoundary from "../error-boundary/index.mjs";
|
|
9
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
11
|
// packages/style-runtime/src/index.ts
|
|
13
|
-
|
|
12
|
+
const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
13
|
+
/**
|
|
14
|
+
* Returns the shared style runtime registry.
|
|
15
|
+
*
|
|
16
|
+
* The registry is stored on `globalThis` so separately bundled copies of this
|
|
17
|
+
* package can coordinate through the same document and style maps.
|
|
18
|
+
*
|
|
19
|
+
* @return The shared runtime registry.
|
|
20
|
+
*/
|
|
14
21
|
function getRuntime() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (typeof document !== "undefined") {
|
|
25
|
-
registerDocument(document);
|
|
26
|
-
}
|
|
27
|
-
return globalScope.__wpStyleRuntime;
|
|
22
|
+
const globalScope = globalThis;
|
|
23
|
+
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
24
|
+
globalScope.__wpStyleRuntime = {
|
|
25
|
+
documents: /* @__PURE__ */ new Map(),
|
|
26
|
+
styles: /* @__PURE__ */ new Map(),
|
|
27
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
28
|
+
};
|
|
29
|
+
if (typeof document !== "undefined") registerDocument(document);
|
|
30
|
+
return globalScope.__wpStyleRuntime;
|
|
28
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Checks whether a document already contains a style tag for a hash.
|
|
34
|
+
*
|
|
35
|
+
* @param targetDocument Document to inspect.
|
|
36
|
+
* @param hash Stable hash for the transformed CSS.
|
|
37
|
+
*
|
|
38
|
+
* @return Whether the style hash already exists in the document.
|
|
39
|
+
*/
|
|
29
40
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
for (const style of targetDocument.head.querySelectorAll(
|
|
34
|
-
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
35
|
-
)) {
|
|
36
|
-
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return false;
|
|
41
|
+
if (!targetDocument.head) return false;
|
|
42
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
43
|
+
return false;
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Injects a registered style into a document, unless that document already
|
|
47
|
+
* contains a style tag for the same hash.
|
|
48
|
+
*
|
|
49
|
+
* @param targetDocument Document to inject the style into.
|
|
50
|
+
* @param hash Stable hash for the transformed CSS.
|
|
51
|
+
* @param css CSS text to inject.
|
|
52
|
+
*/
|
|
42
53
|
function injectStyle(targetDocument, hash, css) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
61
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
62
|
-
targetDocument.head.appendChild(style);
|
|
63
|
-
injectedStyles.add(hash);
|
|
54
|
+
if (!targetDocument.head) return;
|
|
55
|
+
const runtime = getRuntime();
|
|
56
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
57
|
+
if (!injectedStyles) {
|
|
58
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
59
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
60
|
+
}
|
|
61
|
+
if (injectedStyles.has(hash)) return;
|
|
62
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
63
|
+
injectedStyles.add(hash);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const style = targetDocument.createElement("style");
|
|
67
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
68
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
69
|
+
targetDocument.head.appendChild(style);
|
|
70
|
+
injectedStyles.add(hash);
|
|
64
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Registers a document as a style injection target.
|
|
74
|
+
*
|
|
75
|
+
* Existing registered styles are replayed into the document immediately.
|
|
76
|
+
* Documents are reference-counted so multiple providers can safely register the
|
|
77
|
+
* same document without one cleanup removing it while another registration is
|
|
78
|
+
* still active.
|
|
79
|
+
*
|
|
80
|
+
* @param targetDocument Document to receive registered styles.
|
|
81
|
+
* @return Cleanup function that unregisters this document registration.
|
|
82
|
+
*/
|
|
65
83
|
function registerDocument(targetDocument) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
if (count <= 1) {
|
|
80
|
-
runtime.documents.delete(targetDocument);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
84
|
-
};
|
|
84
|
+
const runtime = getRuntime();
|
|
85
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
86
|
+
for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
|
|
87
|
+
return () => {
|
|
88
|
+
const count = runtime.documents.get(targetDocument);
|
|
89
|
+
if (count === void 0) return;
|
|
90
|
+
if (count <= 1) {
|
|
91
|
+
runtime.documents.delete(targetDocument);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
95
|
+
};
|
|
85
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Registers a style and injects it into all registered documents.
|
|
99
|
+
*
|
|
100
|
+
* The hash is used as the deduplication key, so calling this repeatedly with
|
|
101
|
+
* the same hash will not add duplicate style tags to a document.
|
|
102
|
+
* Registered styles are retained for the lifetime of the page so they can be
|
|
103
|
+
* replayed into documents that are registered later.
|
|
104
|
+
*
|
|
105
|
+
* @param hash Stable hash for the transformed CSS.
|
|
106
|
+
* @param css CSS text to inject.
|
|
107
|
+
*/
|
|
86
108
|
function registerStyle(hash, css) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
injectStyle(targetDocument, hash, css);
|
|
91
|
-
}
|
|
109
|
+
const runtime = getRuntime();
|
|
110
|
+
runtime.styles.set(hash, css);
|
|
111
|
+
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
92
112
|
}
|
|
93
|
-
|
|
94
113
|
// packages/boot/src/components/root/style.module.scss
|
|
95
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
96
|
-
registerStyle("b215aa5eaa", ".c8317e9ebb034cfa__layout{background:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:row;height:100%;isolation:isolate;width:100%}@media (min-width:600px){.c8317e9ebb034cfa__layout{bottom:0;inset-inline-end:0;inset-inline-start:0;min-height:calc(100vh - 46px);position:absolute;top:0}}@media (min-width:782px){.c8317e9ebb034cfa__layout{min-height:calc(100vh - 32px)}body:has(.c8317e9ebb034cfa__layout.e97bb2807a9c4687__has-full-canvas) .c8317e9ebb034cfa__layout{min-height:100vh}}:where(.c8317e9ebb034cfa__layout) img{height:auto;max-width:100%}.c8317e9ebb034cfa__layout .b8f8c6cf9ae266bf__notices-snackbar{bottom:var(--wpds-dimension-size-md,32px);box-sizing:border-box;display:flex;flex-direction:column;left:0;padding-inline:16px;pointer-events:none;position:fixed;right:0}.c8317e9ebb034cfa__layout .b8f8c6cf9ae266bf__notices-snackbar ._94ac6b8f274ce2f6__components-snackbar,.c8317e9ebb034cfa__layout .b8f8c6cf9ae266bf__notices-snackbar .components-snackbar{margin-inline:auto}.bfc3fedf39b1cf71__sidebar-backdrop{background-color:rgba(0,0,0,.5);bottom:0;cursor:var(--wpds-cursor-control,pointer);inset-inline-end:0;inset-inline-start:0;position:fixed;top:0;z-index:100002}.bb4f70cd030be0a3__sidebar{flex-shrink:0;height:100%;overflow:hidden;position:relative;width:240px}.bb4f70cd030be0a3__sidebar._27e6d590dc5963c9__is-mobile{background:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);bottom:0;box-shadow:2px 0 8px rgba(0,0,0,.2);inset-inline-start:0;max-width:85vw;position:fixed;top:0;width:300px;z-index:100003}._0eb5d3a3e94d6273__mobile-sidebar-drawer{inset-inline-end:0;inset-inline-start:0;position:fixed;top:0}._26789cb167e9f578__layout-single-page ._0eb5d3a3e94d6273__mobile-sidebar-drawer{top:46px}._0eb5d3a3e94d6273__mobile-sidebar-drawer{align-items:center;background:var(--wpds-color-background-surface-neutral,#fcfcfc);border-bottom:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);display:flex;justify-content:flex-start;padding:16px;z-index:3}.fb03501e629fd04e__canvas.fa94dab2ab1e36f3__has-mobile-drawer{padding-top:65px;position:relative}.a03baddce3ef2026__surfaces{display:flex;flex-grow:1;gap:8px;margin:0}@media (min-width:782px){.a03baddce3ef2026__surfaces{margin:8px}._26789cb167e9f578__layout-single-page .a03baddce3ef2026__surfaces{margin-top:0;margin-inline-start:0}}._7ffe3a3db6f69647__inspector,.d12c9efe707e6cb3__stage{background:var(--wpds-color-background-surface-neutral,#fcfcfc);border-radius:0;bottom:0;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);flex:1;height:100vh;inset-inline-end:0;inset-inline-start:0;margin:0;overflow-y:auto;position:relative;position:fixed;top:0;width:100vw}._26789cb167e9f578__layout-single-page ._7ffe3a3db6f69647__inspector,._26789cb167e9f578__layout-single-page .d12c9efe707e6cb3__stage{height:calc(100vh - 46px);top:46px}@media (min-width:782px){._7ffe3a3db6f69647__inspector,.d12c9efe707e6cb3__stage{border-radius:var(--wpds-border-radius-xl,12px);height:auto;margin:0;position:static;width:auto}._26789cb167e9f578__layout-single-page ._7ffe3a3db6f69647__inspector,._26789cb167e9f578__layout-single-page .d12c9efe707e6cb3__stage{height:auto}}.d12c9efe707e6cb3__stage{z-index:2}@media (min-width:782px){.d12c9efe707e6cb3__stage{z-index:auto}}._7ffe3a3db6f69647__inspector{z-index:3}@media (min-width:782px){._7ffe3a3db6f69647__inspector{z-index:auto}}.fb03501e629fd04e__canvas{background:var(--wpds-color-background-surface-neutral,#fcfcfc);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:0;bottom:0;box-shadow:0 1px 3px rgba(0,0,0,.1);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);flex:1;height:100vh;inset-inline-end:0;inset-inline-start:0;margin:0;overflow-y:auto;position:relative;position:fixed;top:0;width:100vw;z-index:1}._26789cb167e9f578__layout-single-page .fb03501e629fd04e__canvas{height:calc(100vh - 46px);top:46px}@media (min-width:782px){.fb03501e629fd04e__canvas{border-radius:var(--wpds-border-radius-xl,12px);height:auto;position:static;width:auto;z-index:auto}._26789cb167e9f578__layout-single-page .fb03501e629fd04e__canvas{height:auto}._7ffe3a3db6f69647__inspector,.c8317e9ebb034cfa__layout.f7fe42ef8c67e96f__has-canvas .d12c9efe707e6cb3__stage{max-width:400px}}.fb03501e629fd04e__canvas .interface-interface-skeleton{height:100%;inset-inline-start:0!important;position:relative;top:0!important}.c8317e9ebb034cfa__layout.e97bb2807a9c4687__has-full-canvas .a03baddce3ef2026__surfaces{gap:0;margin:0}.c8317e9ebb034cfa__layout.e97bb2807a9c4687__has-full-canvas ._7ffe3a3db6f69647__inspector,.c8317e9ebb034cfa__layout.e97bb2807a9c4687__has-full-canvas .d12c9efe707e6cb3__stage{display:none}.c8317e9ebb034cfa__layout.e97bb2807a9c4687__has-full-canvas .fb03501e629fd04e__canvas{border:none;border-radius:0;bottom:0;box-shadow:none;inset-inline-end:0;inset-inline-start:0;margin:0;max-width:none;overflow:hidden;position:fixed;top:var(--wp-admin--admin-bar--height,0)}._26789cb167e9f578__layout-single-page .c8317e9ebb034cfa__layout.e97bb2807a9c4687__has-full-canvas .fb03501e629fd04e__canvas{top:46px}@media (min-width:782px){._26789cb167e9f578__layout-single-page .c8317e9ebb034cfa__layout.e97bb2807a9c4687__has-full-canvas .fb03501e629fd04e__canvas{top:32px}}@media (max-width:782px){._7ffe3a3db6f69647__inspector,.d12c9efe707e6cb3__stage,.fb03501e629fd04e__canvas:not(.fa94dab2ab1e36f3__has-mobile-drawer){height:calc(100vh - var(--wp-admin--admin-bar--height, 0px));top:var(--wp-admin--admin-bar--height,0)}._0eb5d3a3e94d6273__mobile-sidebar-drawer{top:var(--wp-admin--admin-bar--height,0)}}@media not (prefers-reduced-motion:reduce){.fb03501e629fd04e__canvas .interface-interface-skeleton__header{view-transition-name:boot--canvas-header}.fb03501e629fd04e__canvas .interface-interface-skeleton__sidebar{view-transition-name:boot--canvas-sidebar}.d12c9efe707e6cb3__stage{view-transition-name:boot--stage}._7ffe3a3db6f69647__inspector{view-transition-name:boot--inspector}.fb03501e629fd04e__canvas{view-transition-name:boot--canvas}@supports (-webkit-hyphens:none) and (not (-moz-appearance:none)){.d12c9efe707e6cb3__stage{view-transition-name:boot-safari--stage}._7ffe3a3db6f69647__inspector{view-transition-name:boot-safari--inspector}.fb03501e629fd04e__canvas{view-transition-name:boot-safari--canvas}}}@media (max-width:782px){:root:has(.c8317e9ebb034cfa__layout) *{view-transition-name:none!important}}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(root),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(root){animation-duration:.25s}@media not (prefers-reduced-motion:reduce){:root:has(.c8317e9ebb034cfa__layout) .components-popover:first-of-type{view-transition-name:boot--components-popover}}:root:has(.c8317e9ebb034cfa__layout)::view-transition-group(boot--canvas),:root:has(.c8317e9ebb034cfa__layout)::view-transition-group(boot--canvas-header),:root:has(.c8317e9ebb034cfa__layout)::view-transition-group(boot--canvas-sidebar),:root:has(.c8317e9ebb034cfa__layout)::view-transition-group(boot-safari--canvas){z-index:1}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot-safari--canvas),:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot-safari--inspector),:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot-safari--stage),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot-safari--canvas),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot-safari--inspector),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot-safari--stage){width:auto}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--canvas),:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--inspector),:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--stage),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--canvas),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--inspector),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--stage){background:#fff;border-radius:var(--wpds-border-radius-xl,12px);height:100%;object-fit:none;object-position:left top;overflow:hidden;width:100%}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--canvas),:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--canvas){object-position:center top}:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--inspector):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--stage):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot-safari--inspector):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot-safari--stage):only-child{animation-name:ef68027ea03aa34b__zoomOut;will-change:transform,opacity}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--inspector):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--stage):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot-safari--inspector):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot-safari--stage):only-child{animation-name:_0752ac81dff4c432__zoomIn;will-change:transform,opacity}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--canvas):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot-safari--canvas):only-child{animation-name:_3a2e4dc465681136__slideFromRight;will-change:transform}:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--canvas):only-child,:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot-safari--canvas):only-child{animation-name:_86a367ac26a1b61e__slideToRight;will-change:transform}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--canvas-header):only-child{animation-name:_462399c0e9d64199__slideHeaderFromTop;will-change:transform}:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--canvas-header):only-child{animation-name:_8b272f30d43c9f38__slideHeaderToTop;will-change:transform}:root:has(.c8317e9ebb034cfa__layout)::view-transition-new(boot--canvas-sidebar):only-child{animation-name:_69ed6a71d53a2e0c__slideSidebarFromRight;will-change:transform}:root:has(.c8317e9ebb034cfa__layout)::view-transition-old(boot--canvas-sidebar):only-child{animation-name:bf0697a36b00caad__slideSidebarToRight;will-change:transform}@keyframes ef68027ea03aa34b__zoomOut{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.9)}}@keyframes _0752ac81dff4c432__zoomIn{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes _3a2e4dc465681136__slideFromRight{0%{transform:translateX(100vw)}to{transform:translateX(0)}}@keyframes _86a367ac26a1b61e__slideToRight{0%{transform:translateX(0)}to{transform:translateX(100vw)}}@keyframes _462399c0e9d64199__slideHeaderFromTop{0%{transform:translateY(-100%)}}@keyframes _8b272f30d43c9f38__slideHeaderToTop{to{transform:translateY(-100%)}}@keyframes _69ed6a71d53a2e0c__slideSidebarFromRight{0%{transform:translateX(100%)}}@keyframes bf0697a36b00caad__slideSidebarToRight{to{transform:translateX(100%)}}");
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("fed1a7ec24", "._5c711a1cecefd5e8__layout{background:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:row;height:100%;isolation:isolate;width:100%}@media (min-width:600px){._5c711a1cecefd5e8__layout{bottom:0;inset-inline-end:0;inset-inline-start:0;min-height:calc(100vh - 46px);position:absolute;top:0}}@media (min-width:782px){._5c711a1cecefd5e8__layout{min-height:calc(100vh - 32px)}body:has(._5c711a1cecefd5e8__layout._52e00bad88ace7ce__has-full-canvas) ._5c711a1cecefd5e8__layout{min-height:100vh}}:where(._5c711a1cecefd5e8__layout) img{height:auto;max-width:100%}._5c711a1cecefd5e8__layout .eeebb116829e2f94__notices-snackbar{bottom:var(--wpds-dimension-size-md,32px);box-sizing:border-box;display:flex;flex-direction:column;left:0;padding-inline:16px;pointer-events:none;position:fixed;right:0}._5c711a1cecefd5e8__layout .eeebb116829e2f94__notices-snackbar .cb865dcda5233b3b__components-snackbar,._5c711a1cecefd5e8__layout .eeebb116829e2f94__notices-snackbar .components-snackbar{margin-inline:auto}._04b3b4e8346a2b7b__sidebar-backdrop{background-color:rgba(0,0,0,.5);bottom:0;cursor:var(--wpds-cursor-control,pointer);inset-inline-end:0;inset-inline-start:0;position:fixed;top:0;z-index:100002}._615b052cf60fcff2__sidebar{flex-shrink:0;height:100%;overflow:hidden;position:relative;width:240px}._615b052cf60fcff2__sidebar._6be5d95ddf25e57f__is-mobile{background:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);bottom:0;box-shadow:2px 0 8px rgba(0,0,0,.2);inset-inline-start:0;max-width:85vw;position:fixed;top:0;width:300px;z-index:100003}.fd8d6491146392ce__mobile-sidebar-drawer{inset-inline-end:0;inset-inline-start:0;position:fixed;top:0}.f37b94fd2c1f6020__layout-single-page .fd8d6491146392ce__mobile-sidebar-drawer{top:46px}.fd8d6491146392ce__mobile-sidebar-drawer{align-items:center;background:var(--wpds-color-background-surface-neutral,#fcfcfc);border-bottom:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);display:flex;justify-content:flex-start;padding:16px;z-index:3}._6da399dd0a232c1f__canvas._5568e036ddaba310__has-mobile-drawer{padding-top:65px;position:relative}.ff37ba01b23d0bcb__surfaces{display:flex;flex-grow:1;gap:8px;margin:0}@media (min-width:782px){.ff37ba01b23d0bcb__surfaces{margin:8px}.f37b94fd2c1f6020__layout-single-page .ff37ba01b23d0bcb__surfaces{margin-top:0;margin-inline-start:0}}.b37b199f2111c5f8__inspector,.e323e272b8b8ed4f__stage{background:var(--wpds-color-background-surface-neutral,#fcfcfc);border-radius:0;bottom:0;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);flex:1;height:100vh;inset-inline-end:0;inset-inline-start:0;margin:0;overflow-y:auto;position:relative;position:fixed;top:0;width:100vw}.f37b94fd2c1f6020__layout-single-page .b37b199f2111c5f8__inspector,.f37b94fd2c1f6020__layout-single-page .e323e272b8b8ed4f__stage{height:calc(100vh - 46px);top:46px}@media (min-width:782px){.b37b199f2111c5f8__inspector,.e323e272b8b8ed4f__stage{border-radius:var(--wpds-border-radius-xl,12px);height:auto;margin:0;position:static;width:auto}.f37b94fd2c1f6020__layout-single-page .b37b199f2111c5f8__inspector,.f37b94fd2c1f6020__layout-single-page .e323e272b8b8ed4f__stage{height:auto}}.e323e272b8b8ed4f__stage{z-index:2}@media (min-width:782px){.e323e272b8b8ed4f__stage{z-index:auto}}.b37b199f2111c5f8__inspector{z-index:3}@media (min-width:782px){.b37b199f2111c5f8__inspector{z-index:auto}}._6da399dd0a232c1f__canvas{background:var(--wpds-color-background-surface-neutral,#fcfcfc);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:0;bottom:0;box-shadow:0 1px 3px rgba(0,0,0,.1);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);flex:1;height:100vh;inset-inline-end:0;inset-inline-start:0;margin:0;overflow-y:auto;position:relative;position:fixed;top:0;width:100vw;z-index:1}.f37b94fd2c1f6020__layout-single-page ._6da399dd0a232c1f__canvas{height:calc(100vh - 46px);top:46px}@media (min-width:782px){._6da399dd0a232c1f__canvas{border-radius:var(--wpds-border-radius-xl,12px);height:auto;position:static;width:auto;z-index:auto}.f37b94fd2c1f6020__layout-single-page ._6da399dd0a232c1f__canvas{height:auto}._5c711a1cecefd5e8__layout.bbaf96f69377ab55__has-canvas .e323e272b8b8ed4f__stage,.b37b199f2111c5f8__inspector{max-width:400px}}._6da399dd0a232c1f__canvas .interface-interface-skeleton{height:100%;inset-inline-start:0!important;position:relative;top:0!important}._5c711a1cecefd5e8__layout._52e00bad88ace7ce__has-full-canvas .ff37ba01b23d0bcb__surfaces{gap:0;margin:0}._5c711a1cecefd5e8__layout._52e00bad88ace7ce__has-full-canvas .b37b199f2111c5f8__inspector,._5c711a1cecefd5e8__layout._52e00bad88ace7ce__has-full-canvas .e323e272b8b8ed4f__stage{display:none}._5c711a1cecefd5e8__layout._52e00bad88ace7ce__has-full-canvas ._6da399dd0a232c1f__canvas{border:none;border-radius:0;bottom:0;box-shadow:none;inset-inline-end:0;inset-inline-start:0;margin:0;max-width:none;overflow:hidden;position:fixed;top:var(--wp-admin--admin-bar--height,0)}.f37b94fd2c1f6020__layout-single-page ._5c711a1cecefd5e8__layout._52e00bad88ace7ce__has-full-canvas ._6da399dd0a232c1f__canvas{top:46px}@media (min-width:782px){.f37b94fd2c1f6020__layout-single-page ._5c711a1cecefd5e8__layout._52e00bad88ace7ce__has-full-canvas ._6da399dd0a232c1f__canvas{top:32px}}@media (max-width:782px){._6da399dd0a232c1f__canvas:not(._5568e036ddaba310__has-mobile-drawer),.b37b199f2111c5f8__inspector,.e323e272b8b8ed4f__stage{height:calc(100vh - var(--wp-admin--admin-bar--height, 0px));top:var(--wp-admin--admin-bar--height,0)}.fd8d6491146392ce__mobile-sidebar-drawer{top:var(--wp-admin--admin-bar--height,0)}}@media not (prefers-reduced-motion:reduce){._6da399dd0a232c1f__canvas .interface-interface-skeleton__header{view-transition-name:boot--canvas-header}._6da399dd0a232c1f__canvas .interface-interface-skeleton__sidebar{view-transition-name:boot--canvas-sidebar}.e323e272b8b8ed4f__stage{view-transition-name:boot--stage}.b37b199f2111c5f8__inspector{view-transition-name:boot--inspector}._6da399dd0a232c1f__canvas{view-transition-name:boot--canvas}@supports (-webkit-hyphens:none) and (not (-moz-appearance:none)){.e323e272b8b8ed4f__stage{view-transition-name:boot-safari--stage}.b37b199f2111c5f8__inspector{view-transition-name:boot-safari--inspector}._6da399dd0a232c1f__canvas{view-transition-name:boot-safari--canvas}}}@media (max-width:782px){:root:has(._5c711a1cecefd5e8__layout) *{view-transition-name:none!important}}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(root),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(root){animation-duration:.25s}@media not (prefers-reduced-motion:reduce){:root:has(._5c711a1cecefd5e8__layout) .components-popover:first-of-type{view-transition-name:boot--components-popover}}:root:has(._5c711a1cecefd5e8__layout)::view-transition-group(boot--canvas),:root:has(._5c711a1cecefd5e8__layout)::view-transition-group(boot--canvas-header),:root:has(._5c711a1cecefd5e8__layout)::view-transition-group(boot--canvas-sidebar),:root:has(._5c711a1cecefd5e8__layout)::view-transition-group(boot-safari--canvas){z-index:1}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot-safari--canvas),:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot-safari--inspector),:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot-safari--stage),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot-safari--canvas),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot-safari--inspector),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot-safari--stage){width:auto}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--canvas),:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--inspector),:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--stage),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--canvas),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--inspector),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--stage){background:#fff;border-radius:var(--wpds-border-radius-xl,12px);height:100%;object-fit:none;object-position:left top;overflow:hidden;width:100%}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--canvas),:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--canvas){object-position:center top}:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--inspector):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--stage):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot-safari--inspector):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot-safari--stage):only-child{animation-name:_2e385023a338e4a9__zoomOut;will-change:transform,opacity}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--inspector):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--stage):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot-safari--inspector):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot-safari--stage):only-child{animation-name:e245c2f64b6256de__zoomIn;will-change:transform,opacity}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--canvas):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot-safari--canvas):only-child{animation-name:_9aa5832f67721dd4__slideFromRight;will-change:transform}:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--canvas):only-child,:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot-safari--canvas):only-child{animation-name:_4d20ae2879ce77c4__slideToRight;will-change:transform}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--canvas-header):only-child{animation-name:e56b4b1bb9ff1176__slideHeaderFromTop;will-change:transform}:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--canvas-header):only-child{animation-name:e54b49876d2b7dc3__slideHeaderToTop;will-change:transform}:root:has(._5c711a1cecefd5e8__layout)::view-transition-new(boot--canvas-sidebar):only-child{animation-name:f74156de1cf32837__slideSidebarFromRight;will-change:transform}:root:has(._5c711a1cecefd5e8__layout)::view-transition-old(boot--canvas-sidebar):only-child{animation-name:_157f548b8629f8b5__slideSidebarToRight;will-change:transform}@keyframes _2e385023a338e4a9__zoomOut{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.9)}}@keyframes e245c2f64b6256de__zoomIn{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes _9aa5832f67721dd4__slideFromRight{0%{transform:translateX(100vw)}to{transform:translateX(0)}}@keyframes _4d20ae2879ce77c4__slideToRight{0%{transform:translateX(0)}to{transform:translateX(100vw)}}@keyframes e56b4b1bb9ff1176__slideHeaderFromTop{0%{transform:translateY(-100%)}}@keyframes e54b49876d2b7dc3__slideHeaderToTop{to{transform:translateY(-100%)}}@keyframes f74156de1cf32837__slideSidebarFromRight{0%{transform:translateX(100%)}}@keyframes _157f548b8629f8b5__slideSidebarToRight{to{transform:translateX(100%)}}");
|
|
115
|
+
var style_module_default = {
|
|
116
|
+
"layout": "_5c711a1cecefd5e8__layout",
|
|
117
|
+
"has-full-canvas": "_52e00bad88ace7ce__has-full-canvas",
|
|
118
|
+
"notices-snackbar": "eeebb116829e2f94__notices-snackbar",
|
|
119
|
+
"components-snackbar": "cb865dcda5233b3b__components-snackbar",
|
|
120
|
+
"sidebar-backdrop": "_04b3b4e8346a2b7b__sidebar-backdrop",
|
|
121
|
+
"sidebar": "_615b052cf60fcff2__sidebar",
|
|
122
|
+
"is-mobile": "_6be5d95ddf25e57f__is-mobile",
|
|
123
|
+
"mobile-sidebar-drawer": "fd8d6491146392ce__mobile-sidebar-drawer",
|
|
124
|
+
"layout-single-page": "f37b94fd2c1f6020__layout-single-page",
|
|
125
|
+
"canvas": "_6da399dd0a232c1f__canvas",
|
|
126
|
+
"has-mobile-drawer": "_5568e036ddaba310__has-mobile-drawer",
|
|
127
|
+
"surfaces": "ff37ba01b23d0bcb__surfaces",
|
|
128
|
+
"stage": "e323e272b8b8ed4f__stage",
|
|
129
|
+
"inspector": "b37b199f2111c5f8__inspector",
|
|
130
|
+
"has-canvas": "bbaf96f69377ab55__has-canvas",
|
|
131
|
+
"zoomOut": "_2e385023a338e4a9__zoomOut",
|
|
132
|
+
"zoomIn": "e245c2f64b6256de__zoomIn",
|
|
133
|
+
"slideFromRight": "_9aa5832f67721dd4__slideFromRight",
|
|
134
|
+
"slideToRight": "_4d20ae2879ce77c4__slideToRight",
|
|
135
|
+
"slideHeaderFromTop": "e56b4b1bb9ff1176__slideHeaderFromTop",
|
|
136
|
+
"slideHeaderToTop": "e54b49876d2b7dc3__slideHeaderToTop",
|
|
137
|
+
"slideSidebarFromRight": "f74156de1cf32837__slideSidebarFromRight",
|
|
138
|
+
"slideSidebarToRight": "_157f548b8629f8b5__slideSidebarToRight"
|
|
139
|
+
};
|
|
100
140
|
// packages/boot/src/components/app/router.tsx
|
|
101
|
-
|
|
102
|
-
import { unlock } from "../../lock-unlock.mjs";
|
|
103
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
104
|
-
var {
|
|
105
|
-
createLazyRoute,
|
|
106
|
-
createRouter,
|
|
107
|
-
createRootRoute,
|
|
108
|
-
createRoute,
|
|
109
|
-
RouterProvider,
|
|
110
|
-
createBrowserHistory,
|
|
111
|
-
parseHref,
|
|
112
|
-
useLoaderData
|
|
113
|
-
} = unlock(routePrivateApis);
|
|
141
|
+
const { createLazyRoute, createRouter, createRootRoute, createRoute, RouterProvider, createBrowserHistory, parseHref, useLoaderData } = unlock(privateApis);
|
|
114
142
|
function NotFoundComponent() {
|
|
115
|
-
|
|
143
|
+
return /* @__PURE__ */ jsx("div", {
|
|
144
|
+
className: style_module_default.stage,
|
|
145
|
+
children: /* @__PURE__ */ jsx(Page, {
|
|
146
|
+
title: __("Route not found"),
|
|
147
|
+
hasPadding: true,
|
|
148
|
+
children: __("The page you're looking for does not exist")
|
|
149
|
+
})
|
|
150
|
+
});
|
|
116
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates a TanStack route from a Route definition.
|
|
154
|
+
*
|
|
155
|
+
* @param route Route configuration
|
|
156
|
+
* @param parentRoute Parent route.
|
|
157
|
+
* @return Tanstack Route.
|
|
158
|
+
*/
|
|
117
159
|
function createRouteFromDefinition(route, parentRoute) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const Inspector = module.inspector;
|
|
175
|
-
return createLazyRoute(route.path)({
|
|
176
|
-
component: function RouteComponent() {
|
|
177
|
-
const { inspector: showInspector, stage: showStage } = useLoaderData({ from: route.path }) ?? {};
|
|
178
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
179
|
-
Stage && showStage && /* @__PURE__ */ jsx("div", { className: style_module_default.stage, children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Stage, {}) }) }),
|
|
180
|
-
Inspector && showInspector && /* @__PURE__ */ jsx("div", { className: style_module_default.inspector, children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Inspector, {}) }) })
|
|
181
|
-
] });
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
return tanstackRoute;
|
|
160
|
+
let tanstackRoute = createRoute({
|
|
161
|
+
getParentRoute: () => parentRoute,
|
|
162
|
+
path: route.path,
|
|
163
|
+
beforeLoad: async (opts) => {
|
|
164
|
+
if (route.route_module) {
|
|
165
|
+
const routeConfig = (await import(route.route_module)).route || {};
|
|
166
|
+
if (routeConfig.beforeLoad) return routeConfig.beforeLoad({
|
|
167
|
+
params: opts.params || {},
|
|
168
|
+
search: opts.search || {}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
loader: async (opts) => {
|
|
173
|
+
let routeConfig = {};
|
|
174
|
+
if (route.route_module) routeConfig = (await import(route.route_module)).route || {};
|
|
175
|
+
const context = {
|
|
176
|
+
params: opts.params || {},
|
|
177
|
+
search: opts.deps || {}
|
|
178
|
+
};
|
|
179
|
+
const [, loaderData, canvasData, titleData] = await Promise.all([
|
|
180
|
+
resolveSelect(store).getEntityRecord("root", "__unstableBase"),
|
|
181
|
+
routeConfig.loader ? routeConfig.loader(context) : Promise.resolve(void 0),
|
|
182
|
+
routeConfig.canvas ? routeConfig.canvas(context) : Promise.resolve(void 0),
|
|
183
|
+
routeConfig.title ? routeConfig.title(context) : Promise.resolve(void 0)
|
|
184
|
+
]);
|
|
185
|
+
let inspector = true;
|
|
186
|
+
if (routeConfig.inspector) inspector = await routeConfig.inspector(context);
|
|
187
|
+
let stage = true;
|
|
188
|
+
if (routeConfig.stage) stage = await routeConfig.stage(context);
|
|
189
|
+
return {
|
|
190
|
+
...loaderData,
|
|
191
|
+
canvas: canvasData,
|
|
192
|
+
inspector,
|
|
193
|
+
stage,
|
|
194
|
+
title: titleData,
|
|
195
|
+
routeContentModule: route.content_module
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
loaderDeps: (opts) => opts.search
|
|
199
|
+
});
|
|
200
|
+
tanstackRoute = tanstackRoute.lazy(async () => {
|
|
201
|
+
const module = route.content_module ? await import(route.content_module) : {};
|
|
202
|
+
const Stage = module.stage;
|
|
203
|
+
const Inspector = module.inspector;
|
|
204
|
+
return createLazyRoute(route.path)({ component: function RouteComponent() {
|
|
205
|
+
const { inspector: showInspector, stage: showStage } = useLoaderData({ from: route.path }) ?? {};
|
|
206
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [Stage && showStage && /* @__PURE__ */ jsx("div", {
|
|
207
|
+
className: style_module_default.stage,
|
|
208
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Stage, {}) })
|
|
209
|
+
}), Inspector && showInspector && /* @__PURE__ */ jsx("div", {
|
|
210
|
+
className: style_module_default.inspector,
|
|
211
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Inspector, {}) })
|
|
212
|
+
})] });
|
|
213
|
+
} });
|
|
214
|
+
});
|
|
215
|
+
return tanstackRoute;
|
|
186
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Creates a route tree from route definitions.
|
|
219
|
+
*
|
|
220
|
+
* @param routes Routes definition.
|
|
221
|
+
* @param rootComponent Root component to use for the router.
|
|
222
|
+
* @return Router tree.
|
|
223
|
+
*/
|
|
187
224
|
function createRouteTree(routes, rootComponent = Root) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
);
|
|
195
|
-
return rootRoute.addChildren(dynamicRoutes);
|
|
225
|
+
const rootRoute = createRootRoute({
|
|
226
|
+
component: rootComponent,
|
|
227
|
+
context: () => ({})
|
|
228
|
+
});
|
|
229
|
+
const dynamicRoutes = routes.map((route) => createRouteFromDefinition(route, rootRoute));
|
|
230
|
+
return rootRoute.addChildren(dynamicRoutes);
|
|
196
231
|
}
|
|
197
232
|
function createPathHistory() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
});
|
|
233
|
+
return createBrowserHistory({
|
|
234
|
+
parseLocation: () => {
|
|
235
|
+
const url = new URL(window.location.href);
|
|
236
|
+
const pathHref = `${url.searchParams.get("p") || "/"}${url.hash}`;
|
|
237
|
+
return parseHref(pathHref, window.history.state);
|
|
238
|
+
},
|
|
239
|
+
createHref: (href) => {
|
|
240
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
241
|
+
searchParams.set("p", href);
|
|
242
|
+
return `${window.location.pathname}?${searchParams}`;
|
|
243
|
+
}
|
|
244
|
+
});
|
|
211
245
|
}
|
|
212
|
-
function Router({
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (!fromLocation) {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
return ["navigate"];
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
}, [routes, rootComponent]);
|
|
236
|
-
return /* @__PURE__ */ jsx(RouterProvider, { router });
|
|
246
|
+
function Router({ routes, rootComponent = Root }) {
|
|
247
|
+
const router = useMemo(() => {
|
|
248
|
+
const history = createPathHistory();
|
|
249
|
+
const routeTree = createRouteTree(routes, rootComponent);
|
|
250
|
+
return createRouter({
|
|
251
|
+
history,
|
|
252
|
+
routeTree,
|
|
253
|
+
defaultPreload: "intent",
|
|
254
|
+
defaultNotFoundComponent: NotFoundComponent,
|
|
255
|
+
defaultViewTransition: { types: ({ fromLocation }) => {
|
|
256
|
+
if (!fromLocation) return false;
|
|
257
|
+
return ["navigate"];
|
|
258
|
+
} }
|
|
259
|
+
});
|
|
260
|
+
}, [routes, rootComponent]);
|
|
261
|
+
return /* @__PURE__ */ jsx(RouterProvider, { router });
|
|
237
262
|
}
|
|
238
|
-
export {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
//# sourceMappingURL=router.mjs.map
|
|
263
|
+
export { Router as default };
|
|
264
|
+
|
|
265
|
+
//# sourceMappingURL=router.mjs.map
|