@wordpress/boot 0.25.0 → 0.27.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.
Files changed (75) hide show
  1. package/build-module/components/app/index.mjs +29 -53
  2. package/build-module/components/app/index.mjs.map +1 -7
  3. package/build-module/components/app/router.mjs +238 -214
  4. package/build-module/components/app/router.mjs.map +1 -7
  5. package/build-module/components/app/use-route-title.mjs +35 -42
  6. package/build-module/components/app/use-route-title.mjs.map +1 -7
  7. package/build-module/components/canvas/back-button.mjs +21 -20
  8. package/build-module/components/canvas/back-button.mjs.map +1 -7
  9. package/build-module/components/canvas/index.mjs +104 -130
  10. package/build-module/components/canvas/index.mjs.map +1 -7
  11. package/build-module/components/canvas/site-preview.mjs +36 -43
  12. package/build-module/components/canvas/site-preview.mjs.map +1 -7
  13. package/build-module/components/canvas/use-navigate-to-entity-record.mjs +109 -113
  14. package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +1 -7
  15. package/build-module/components/canvas/viewport.mjs +25 -13
  16. package/build-module/components/canvas/viewport.mjs.map +1 -7
  17. package/build-module/components/canvas-renderer/index.mjs +40 -32
  18. package/build-module/components/canvas-renderer/index.mjs.map +1 -7
  19. package/build-module/components/error-boundary/index.mjs +161 -109
  20. package/build-module/components/error-boundary/index.mjs.map +1 -7
  21. package/build-module/components/navigation/drilldown-item/index.mjs +124 -127
  22. package/build-module/components/navigation/drilldown-item/index.mjs.map +1 -7
  23. package/build-module/components/navigation/dropdown-item/index.mjs +156 -173
  24. package/build-module/components/navigation/dropdown-item/index.mjs.map +1 -7
  25. package/build-module/components/navigation/index.mjs +55 -90
  26. package/build-module/components/navigation/index.mjs.map +1 -7
  27. package/build-module/components/navigation/items.mjs +51 -53
  28. package/build-module/components/navigation/items.mjs.map +1 -7
  29. package/build-module/components/navigation/navigation-item/index.mjs +120 -114
  30. package/build-module/components/navigation/navigation-item/index.mjs.map +1 -7
  31. package/build-module/components/navigation/navigation-screen/index.mjs +192 -185
  32. package/build-module/components/navigation/navigation-screen/index.mjs.map +1 -7
  33. package/build-module/components/navigation/path-matching.mjs +74 -73
  34. package/build-module/components/navigation/path-matching.mjs.map +1 -7
  35. package/build-module/components/navigation/router-link-item.mjs +13 -11
  36. package/build-module/components/navigation/router-link-item.mjs.map +1 -7
  37. package/build-module/components/navigation/use-sidebar-parent.mjs +37 -48
  38. package/build-module/components/navigation/use-sidebar-parent.mjs.map +1 -7
  39. package/build-module/components/plugin-area/index.mjs +20 -24
  40. package/build-module/components/plugin-area/index.mjs.map +1 -7
  41. package/build-module/components/root/index.mjs +228 -243
  42. package/build-module/components/root/index.mjs.map +1 -7
  43. package/build-module/components/root/single-page.mjs +174 -148
  44. package/build-module/components/root/single-page.mjs.map +1 -7
  45. package/build-module/components/root/use-sync-body-background.mjs +28 -22
  46. package/build-module/components/root/use-sync-body-background.mjs.map +1 -7
  47. package/build-module/components/save-button/index.mjs +170 -214
  48. package/build-module/components/save-button/index.mjs.map +1 -7
  49. package/build-module/components/save-panel/index.mjs +110 -106
  50. package/build-module/components/save-panel/index.mjs.map +1 -7
  51. package/build-module/components/save-panel/use-save-shortcut.mjs +42 -51
  52. package/build-module/components/save-panel/use-save-shortcut.mjs.map +1 -7
  53. package/build-module/components/sidebar/index.mjs +126 -104
  54. package/build-module/components/sidebar/index.mjs.map +1 -7
  55. package/build-module/index.mjs +1 -7
  56. package/build-module/lock-unlock.mjs +5 -10
  57. package/build-module/lock-unlock.mjs.map +1 -7
  58. package/build-module/store/actions.mjs +34 -31
  59. package/build-module/store/actions.mjs.map +1 -7
  60. package/build-module/store/index.mjs +9 -11
  61. package/build-module/store/index.mjs.map +1 -7
  62. package/build-module/store/reducer.mjs +48 -55
  63. package/build-module/store/reducer.mjs.map +1 -7
  64. package/build-module/store/selectors.mjs +21 -16
  65. package/build-module/store/selectors.mjs.map +1 -7
  66. package/build-module/store/types.mjs +0 -1
  67. package/build-types/components/error-boundary/index.d.ts.map +1 -1
  68. package/build-types/components/root/index.d.ts.map +1 -1
  69. package/package.json +28 -28
  70. package/src/components/error-boundary/index.tsx +52 -6
  71. package/src/components/navigation/navigation-screen/index.tsx +2 -2
  72. package/src/components/root/_layout.module.scss +1 -1
  73. package/src/components/root/index.tsx +7 -3
  74. package/build-module/index.mjs.map +0 -7
  75. 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 as coreStore } from "@wordpress/core-data";
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
- var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
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
- const globalScope = globalThis;
16
- if (globalScope.__wpStyleRuntime) {
17
- return globalScope.__wpStyleRuntime;
18
- }
19
- globalScope.__wpStyleRuntime = {
20
- documents: /* @__PURE__ */ new Map(),
21
- styles: /* @__PURE__ */ new Map(),
22
- injectedStyles: /* @__PURE__ */ new WeakMap()
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
- if (!targetDocument.head) {
31
- return false;
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
- if (!targetDocument.head) {
44
- return;
45
- }
46
- const runtime = getRuntime();
47
- let injectedStyles = runtime.injectedStyles.get(targetDocument);
48
- if (!injectedStyles) {
49
- injectedStyles = /* @__PURE__ */ new Set();
50
- runtime.injectedStyles.set(targetDocument, injectedStyles);
51
- }
52
- if (injectedStyles.has(hash)) {
53
- return;
54
- }
55
- if (documentContainsStyleHash(targetDocument, hash)) {
56
- injectedStyles.add(hash);
57
- return;
58
- }
59
- const style = targetDocument.createElement("style");
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
- const runtime = getRuntime();
67
- runtime.documents.set(
68
- targetDocument,
69
- (runtime.documents.get(targetDocument) ?? 0) + 1
70
- );
71
- for (const [hash, css] of runtime.styles) {
72
- injectStyle(targetDocument, hash, css);
73
- }
74
- return () => {
75
- const count = runtime.documents.get(targetDocument);
76
- if (count === void 0) {
77
- return;
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
- const runtime = getRuntime();
88
- runtime.styles.set(hash, css);
89
- for (const targetDocument of runtime.documents.keys()) {
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
- var style_module_default = { "layout": "c8317e9ebb034cfa__layout", "has-full-canvas": "e97bb2807a9c4687__has-full-canvas", "notices-snackbar": "b8f8c6cf9ae266bf__notices-snackbar", "components-snackbar": "_94ac6b8f274ce2f6__components-snackbar", "sidebar-backdrop": "bfc3fedf39b1cf71__sidebar-backdrop", "sidebar": "bb4f70cd030be0a3__sidebar", "is-mobile": "_27e6d590dc5963c9__is-mobile", "mobile-sidebar-drawer": "_0eb5d3a3e94d6273__mobile-sidebar-drawer", "layout-single-page": "_26789cb167e9f578__layout-single-page", "canvas": "fb03501e629fd04e__canvas", "has-mobile-drawer": "fa94dab2ab1e36f3__has-mobile-drawer", "surfaces": "a03baddce3ef2026__surfaces", "stage": "d12c9efe707e6cb3__stage", "inspector": "_7ffe3a3db6f69647__inspector", "has-canvas": "f7fe42ef8c67e96f__has-canvas", "zoomOut": "ef68027ea03aa34b__zoomOut", "zoomIn": "_0752ac81dff4c432__zoomIn", "slideFromRight": "_3a2e4dc465681136__slideFromRight", "slideToRight": "_86a367ac26a1b61e__slideToRight", "slideHeaderFromTop": "_462399c0e9d64199__slideHeaderFromTop", "slideHeaderToTop": "_8b272f30d43c9f38__slideHeaderToTop", "slideSidebarFromRight": "_69ed6a71d53a2e0c__slideSidebarFromRight", "slideSidebarToRight": "bf0697a36b00caad__slideSidebarToRight" };
99
-
114
+ if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("5af927cba5", "._56935e6282cea626__layout{background:var(--wpds-color-background-surface-neutral-weak,#f3f3f3);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:row;height:100%;isolation:isolate;width:100%}@media (min-width:600px){._56935e6282cea626__layout{bottom:0;inset-inline-end:0;inset-inline-start:0;min-height:calc(100vh - 46px);position:absolute;top:0}}@media (min-width:782px){._56935e6282cea626__layout{min-height:calc(100vh - 32px)}body:has(._56935e6282cea626__layout._8fc7f864ef1ff9d4__has-full-canvas) ._56935e6282cea626__layout{min-height:100vh}}:where(._56935e6282cea626__layout) img{height:auto;max-width:100%}._56935e6282cea626__layout ._4b753b79328f00f2__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}._56935e6282cea626__layout ._4b753b79328f00f2__notices-snackbar .components-snackbar,._56935e6282cea626__layout ._4b753b79328f00f2__notices-snackbar .efa1f12116c3fb44__components-snackbar{margin-inline:auto}.a42f10ffa1623b1a__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}._24ece5d7d830027c__sidebar{flex-shrink:0;height:100%;overflow:hidden;position:relative;width:240px}._24ece5d7d830027c__sidebar.ea25e130be9dcc55__is-mobile{background:var(--wpds-color-background-surface-neutral-weak,#f3f3f3);bottom:0;box-shadow:0 0 8px rgba(0,0,0,.2);inset-inline-start:0;max-width:85vw;position:fixed;top:0;width:300px;z-index:100003}._46722ab62d8eeeca__mobile-sidebar-drawer{inset-inline-end:0;inset-inline-start:0;position:fixed;top:0}._5021a5c25e2952a7__layout-single-page ._46722ab62d8eeeca__mobile-sidebar-drawer{top:46px}._46722ab62d8eeeca__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}._690b80eca9eb9eb6__canvas._47abeba36a2c03ed__has-mobile-drawer{padding-top:65px;position:relative}._52f74c33fd2757fc__surfaces{display:flex;flex-grow:1;gap:8px;margin:0}@media (min-width:782px){._52f74c33fd2757fc__surfaces{margin:8px}._5021a5c25e2952a7__layout-single-page ._52f74c33fd2757fc__surfaces{margin-top:0;margin-inline-start:0}}._8510aae3042dca12__inspector,.ed02476df88803b9__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}._5021a5c25e2952a7__layout-single-page ._8510aae3042dca12__inspector,._5021a5c25e2952a7__layout-single-page .ed02476df88803b9__stage{height:calc(100vh - 46px);top:46px}@media (min-width:782px){._8510aae3042dca12__inspector,.ed02476df88803b9__stage{border-radius:var(--wpds-border-radius-xl,12px);height:auto;margin:0;position:static;width:auto}._5021a5c25e2952a7__layout-single-page ._8510aae3042dca12__inspector,._5021a5c25e2952a7__layout-single-page .ed02476df88803b9__stage{height:auto}}.ed02476df88803b9__stage{z-index:2}@media (min-width:782px){.ed02476df88803b9__stage{z-index:auto}}._8510aae3042dca12__inspector{z-index:3}@media (min-width:782px){._8510aae3042dca12__inspector{z-index:auto}}._690b80eca9eb9eb6__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}._5021a5c25e2952a7__layout-single-page ._690b80eca9eb9eb6__canvas{height:calc(100vh - 46px);top:46px}@media (min-width:782px){._690b80eca9eb9eb6__canvas{border-radius:var(--wpds-border-radius-xl,12px);height:auto;position:static;width:auto;z-index:auto}._5021a5c25e2952a7__layout-single-page ._690b80eca9eb9eb6__canvas{height:auto}._56935e6282cea626__layout.b4c4ba65515802c9__has-canvas .ed02476df88803b9__stage,._8510aae3042dca12__inspector{max-width:400px}}._690b80eca9eb9eb6__canvas .interface-interface-skeleton{height:100%;inset-inline-start:0!important;position:relative;top:0!important}._56935e6282cea626__layout._8fc7f864ef1ff9d4__has-full-canvas ._52f74c33fd2757fc__surfaces{gap:0;margin:0}._56935e6282cea626__layout._8fc7f864ef1ff9d4__has-full-canvas ._8510aae3042dca12__inspector,._56935e6282cea626__layout._8fc7f864ef1ff9d4__has-full-canvas .ed02476df88803b9__stage{display:none}._56935e6282cea626__layout._8fc7f864ef1ff9d4__has-full-canvas ._690b80eca9eb9eb6__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)}._5021a5c25e2952a7__layout-single-page ._56935e6282cea626__layout._8fc7f864ef1ff9d4__has-full-canvas ._690b80eca9eb9eb6__canvas{top:46px}@media (min-width:782px){._5021a5c25e2952a7__layout-single-page ._56935e6282cea626__layout._8fc7f864ef1ff9d4__has-full-canvas ._690b80eca9eb9eb6__canvas{top:32px}}@media (max-width:782px){._690b80eca9eb9eb6__canvas:not(._47abeba36a2c03ed__has-mobile-drawer),._8510aae3042dca12__inspector,.ed02476df88803b9__stage{height:calc(100vh - var(--wp-admin--admin-bar--height, 0px));top:var(--wp-admin--admin-bar--height,0)}._46722ab62d8eeeca__mobile-sidebar-drawer{top:var(--wp-admin--admin-bar--height,0)}}@media not (prefers-reduced-motion:reduce){._690b80eca9eb9eb6__canvas .interface-interface-skeleton__header{view-transition-name:boot--canvas-header}._690b80eca9eb9eb6__canvas .interface-interface-skeleton__sidebar{view-transition-name:boot--canvas-sidebar}.ed02476df88803b9__stage{view-transition-name:boot--stage}._8510aae3042dca12__inspector{view-transition-name:boot--inspector}._690b80eca9eb9eb6__canvas{view-transition-name:boot--canvas}@supports (-webkit-hyphens:none) and (not (-moz-appearance:none)){.ed02476df88803b9__stage{view-transition-name:boot-safari--stage}._8510aae3042dca12__inspector{view-transition-name:boot-safari--inspector}._690b80eca9eb9eb6__canvas{view-transition-name:boot-safari--canvas}}}@media (max-width:782px){:root:has(._56935e6282cea626__layout) *{view-transition-name:none!important}}:root:has(._56935e6282cea626__layout)::view-transition-new(root),:root:has(._56935e6282cea626__layout)::view-transition-old(root){animation-duration:.25s}@media not (prefers-reduced-motion:reduce){:root:has(._56935e6282cea626__layout) .components-popover:first-of-type{view-transition-name:boot--components-popover}}:root:has(._56935e6282cea626__layout)::view-transition-group(boot--canvas),:root:has(._56935e6282cea626__layout)::view-transition-group(boot--canvas-header),:root:has(._56935e6282cea626__layout)::view-transition-group(boot--canvas-sidebar),:root:has(._56935e6282cea626__layout)::view-transition-group(boot-safari--canvas){z-index:1}:root:has(._56935e6282cea626__layout)::view-transition-new(boot-safari--canvas),:root:has(._56935e6282cea626__layout)::view-transition-new(boot-safari--inspector),:root:has(._56935e6282cea626__layout)::view-transition-new(boot-safari--stage),:root:has(._56935e6282cea626__layout)::view-transition-old(boot-safari--canvas),:root:has(._56935e6282cea626__layout)::view-transition-old(boot-safari--inspector),:root:has(._56935e6282cea626__layout)::view-transition-old(boot-safari--stage){width:auto}:root:has(._56935e6282cea626__layout)::view-transition-new(boot--canvas),:root:has(._56935e6282cea626__layout)::view-transition-new(boot--inspector),:root:has(._56935e6282cea626__layout)::view-transition-new(boot--stage),:root:has(._56935e6282cea626__layout)::view-transition-old(boot--canvas),:root:has(._56935e6282cea626__layout)::view-transition-old(boot--inspector),:root:has(._56935e6282cea626__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(._56935e6282cea626__layout)::view-transition-new(boot--canvas),:root:has(._56935e6282cea626__layout)::view-transition-old(boot--canvas){object-position:center top}:root:has(._56935e6282cea626__layout)::view-transition-old(boot--inspector):only-child,:root:has(._56935e6282cea626__layout)::view-transition-old(boot--stage):only-child,:root:has(._56935e6282cea626__layout)::view-transition-old(boot-safari--inspector):only-child,:root:has(._56935e6282cea626__layout)::view-transition-old(boot-safari--stage):only-child{animation-name:ab73776591f19033__zoomOut;will-change:transform,opacity}:root:has(._56935e6282cea626__layout)::view-transition-new(boot--inspector):only-child,:root:has(._56935e6282cea626__layout)::view-transition-new(boot--stage):only-child,:root:has(._56935e6282cea626__layout)::view-transition-new(boot-safari--inspector):only-child,:root:has(._56935e6282cea626__layout)::view-transition-new(boot-safari--stage):only-child{animation-name:_10c071ed4bf0c4f2__zoomIn;will-change:transform,opacity}:root:has(._56935e6282cea626__layout)::view-transition-new(boot--canvas):only-child,:root:has(._56935e6282cea626__layout)::view-transition-new(boot-safari--canvas):only-child{animation-name:_30a8540aba2100e9__slideFromRight;will-change:transform}:root:has(._56935e6282cea626__layout)::view-transition-old(boot--canvas):only-child,:root:has(._56935e6282cea626__layout)::view-transition-old(boot-safari--canvas):only-child{animation-name:aea85e2dfc564485__slideToRight;will-change:transform}:root:has(._56935e6282cea626__layout)::view-transition-new(boot--canvas-header):only-child{animation-name:_8ad9a41739bd9fbe__slideHeaderFromTop;will-change:transform}:root:has(._56935e6282cea626__layout)::view-transition-old(boot--canvas-header):only-child{animation-name:f56b26b5d5c9bc72__slideHeaderToTop;will-change:transform}:root:has(._56935e6282cea626__layout)::view-transition-new(boot--canvas-sidebar):only-child{animation-name:a2ba8d5a4515e038__slideSidebarFromRight;will-change:transform}:root:has(._56935e6282cea626__layout)::view-transition-old(boot--canvas-sidebar):only-child{animation-name:_6ddf6cb6adc49ad6__slideSidebarToRight;will-change:transform}@keyframes ab73776591f19033__zoomOut{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.9)}}@keyframes _10c071ed4bf0c4f2__zoomIn{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes _30a8540aba2100e9__slideFromRight{0%{transform:translateX(100vw)}to{transform:translateX(0)}}@keyframes aea85e2dfc564485__slideToRight{0%{transform:translateX(0)}to{transform:translateX(100vw)}}@keyframes _8ad9a41739bd9fbe__slideHeaderFromTop{0%{transform:translateY(-100%)}}@keyframes f56b26b5d5c9bc72__slideHeaderToTop{to{transform:translateY(-100%)}}@keyframes a2ba8d5a4515e038__slideSidebarFromRight{0%{transform:translateX(100%)}}@keyframes _6ddf6cb6adc49ad6__slideSidebarToRight{to{transform:translateX(100%)}}");
115
+ var style_module_default = {
116
+ "layout": "_56935e6282cea626__layout",
117
+ "has-full-canvas": "_8fc7f864ef1ff9d4__has-full-canvas",
118
+ "notices-snackbar": "_4b753b79328f00f2__notices-snackbar",
119
+ "components-snackbar": "efa1f12116c3fb44__components-snackbar",
120
+ "sidebar-backdrop": "a42f10ffa1623b1a__sidebar-backdrop",
121
+ "sidebar": "_24ece5d7d830027c__sidebar",
122
+ "is-mobile": "ea25e130be9dcc55__is-mobile",
123
+ "mobile-sidebar-drawer": "_46722ab62d8eeeca__mobile-sidebar-drawer",
124
+ "layout-single-page": "_5021a5c25e2952a7__layout-single-page",
125
+ "canvas": "_690b80eca9eb9eb6__canvas",
126
+ "has-mobile-drawer": "_47abeba36a2c03ed__has-mobile-drawer",
127
+ "surfaces": "_52f74c33fd2757fc__surfaces",
128
+ "stage": "ed02476df88803b9__stage",
129
+ "inspector": "_8510aae3042dca12__inspector",
130
+ "has-canvas": "b4c4ba65515802c9__has-canvas",
131
+ "zoomOut": "ab73776591f19033__zoomOut",
132
+ "zoomIn": "_10c071ed4bf0c4f2__zoomIn",
133
+ "slideFromRight": "_30a8540aba2100e9__slideFromRight",
134
+ "slideToRight": "aea85e2dfc564485__slideToRight",
135
+ "slideHeaderFromTop": "_8ad9a41739bd9fbe__slideHeaderFromTop",
136
+ "slideHeaderToTop": "f56b26b5d5c9bc72__slideHeaderToTop",
137
+ "slideSidebarFromRight": "a2ba8d5a4515e038__slideSidebarFromRight",
138
+ "slideSidebarToRight": "_6ddf6cb6adc49ad6__slideSidebarToRight"
139
+ };
100
140
  // packages/boot/src/components/app/router.tsx
101
- import ErrorBoundary from "../error-boundary/index.mjs";
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
- return /* @__PURE__ */ jsx("div", { className: style_module_default.stage, children: /* @__PURE__ */ jsx(Page, { title: __("Route not found"), hasPadding: true, children: __("The page you're looking for does not exist") }) });
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
- let tanstackRoute = createRoute({
119
- getParentRoute: () => parentRoute,
120
- path: route.path,
121
- beforeLoad: async (opts) => {
122
- if (route.route_module) {
123
- const module = await import(route.route_module);
124
- const routeConfig = module.route || {};
125
- if (routeConfig.beforeLoad) {
126
- return routeConfig.beforeLoad({
127
- params: opts.params || {},
128
- search: opts.search || {}
129
- });
130
- }
131
- }
132
- },
133
- loader: async (opts) => {
134
- let routeConfig = {};
135
- if (route.route_module) {
136
- const module = await import(route.route_module);
137
- routeConfig = module.route || {};
138
- }
139
- const context = {
140
- params: opts.params || {},
141
- search: opts.deps || {}
142
- };
143
- const [, loaderData, canvasData, titleData] = await Promise.all([
144
- resolveSelect(coreStore).getEntityRecord(
145
- "root",
146
- "__unstableBase"
147
- ),
148
- routeConfig.loader ? routeConfig.loader(context) : Promise.resolve(void 0),
149
- routeConfig.canvas ? routeConfig.canvas(context) : Promise.resolve(void 0),
150
- routeConfig.title ? routeConfig.title(context) : Promise.resolve(void 0)
151
- ]);
152
- let inspector = true;
153
- if (routeConfig.inspector) {
154
- inspector = await routeConfig.inspector(context);
155
- }
156
- let stage = true;
157
- if (routeConfig.stage) {
158
- stage = await routeConfig.stage(context);
159
- }
160
- return {
161
- ...loaderData,
162
- canvas: canvasData,
163
- inspector,
164
- stage,
165
- title: titleData,
166
- routeContentModule: route.content_module
167
- };
168
- },
169
- loaderDeps: (opts) => opts.search
170
- });
171
- tanstackRoute = tanstackRoute.lazy(async () => {
172
- const module = route.content_module ? await import(route.content_module) : {};
173
- const Stage = module.stage;
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
- const rootRoute = createRootRoute({
189
- component: rootComponent,
190
- context: () => ({})
191
- });
192
- const dynamicRoutes = routes.map(
193
- (route) => createRouteFromDefinition(route, rootRoute)
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
- return createBrowserHistory({
199
- parseLocation: () => {
200
- const url = new URL(window.location.href);
201
- const path = url.searchParams.get("p") || "/";
202
- const pathHref = `${path}${url.hash}`;
203
- return parseHref(pathHref, window.history.state);
204
- },
205
- createHref: (href) => {
206
- const searchParams = new URLSearchParams(window.location.search);
207
- searchParams.set("p", href);
208
- return `${window.location.pathname}?${searchParams}`;
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
- routes,
214
- rootComponent = Root
215
- }) {
216
- const router = useMemo(() => {
217
- const history = createPathHistory();
218
- const routeTree = createRouteTree(routes, rootComponent);
219
- return createRouter({
220
- history,
221
- routeTree,
222
- defaultPreload: "intent",
223
- defaultNotFoundComponent: NotFoundComponent,
224
- defaultViewTransition: {
225
- types: ({
226
- fromLocation
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
- Router as default
240
- };
241
- //# sourceMappingURL=router.mjs.map
263
+ export { Router as default };
264
+
265
+ //# sourceMappingURL=router.mjs.map