@wordpress/boot 0.19.0 → 0.21.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/CHANGELOG.md +38 -0
- package/README.md +4 -0
- package/build-module/components/app/index.mjs.map +2 -2
- package/build-module/components/app/router.mjs +100 -4
- package/build-module/components/app/router.mjs.map +3 -3
- package/build-module/components/app/use-route-title.mjs.map +2 -2
- package/build-module/components/canvas/back-button.mjs.map +2 -2
- package/build-module/components/canvas/index.mjs +72 -13
- package/build-module/components/canvas/index.mjs.map +2 -2
- package/build-module/components/canvas/site-preview.mjs +50 -0
- package/build-module/components/canvas/site-preview.mjs.map +7 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +122 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +7 -0
- package/build-module/components/canvas/viewport.mjs +18 -0
- package/build-module/components/canvas/viewport.mjs.map +7 -0
- package/build-module/components/canvas-renderer/index.mjs.map +2 -2
- package/build-module/components/error-boundary/index.mjs +129 -0
- package/build-module/components/error-boundary/index.mjs.map +7 -0
- package/build-module/components/navigation/drilldown-item/index.mjs +91 -1
- package/build-module/components/navigation/drilldown-item/index.mjs.map +3 -3
- package/build-module/components/navigation/dropdown-item/index.mjs +99 -12
- package/build-module/components/navigation/dropdown-item/index.mjs.map +4 -4
- package/build-module/components/navigation/index.mjs +1 -2
- package/build-module/components/navigation/index.mjs.map +2 -2
- package/build-module/components/navigation/items.mjs.map +2 -2
- package/build-module/components/navigation/navigation-item/index.mjs +88 -15
- package/build-module/components/navigation/navigation-item/index.mjs.map +3 -3
- package/build-module/components/navigation/navigation-screen/index.mjs +111 -38
- package/build-module/components/navigation/navigation-screen/index.mjs.map +3 -3
- package/build-module/components/navigation/path-matching.mjs.map +2 -2
- package/build-module/components/navigation/router-link-item.mjs.map +2 -2
- package/build-module/components/navigation/use-sidebar-parent.mjs +1 -1
- package/build-module/components/navigation/use-sidebar-parent.mjs.map +2 -2
- package/build-module/components/plugin-area/index.mjs +29 -0
- package/build-module/components/plugin-area/index.mjs.map +7 -0
- package/build-module/components/root/index.mjs +220 -122
- package/build-module/components/root/index.mjs.map +3 -3
- package/build-module/components/root/single-page.mjs +139 -47
- package/build-module/components/root/single-page.mjs.map +3 -3
- package/build-module/components/root/use-sync-body-background.mjs.map +2 -2
- package/build-module/components/save-button/index.mjs +127 -16
- package/build-module/components/save-button/index.mjs.map +3 -3
- package/build-module/components/save-panel/index.mjs +91 -1
- package/build-module/components/save-panel/index.mjs.map +3 -3
- package/build-module/components/save-panel/use-save-shortcut.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +90 -10
- package/build-module/components/sidebar/index.mjs.map +3 -3
- package/build-module/index.mjs +0 -16
- package/build-module/index.mjs.map +3 -3
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/store/actions.mjs +8 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/index.mjs.map +2 -2
- package/build-module/store/reducer.mjs +16 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +9 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-types/components/app/index.d.ts.map +1 -1
- package/build-types/components/app/router.d.ts +0 -3
- package/build-types/components/app/router.d.ts.map +1 -1
- package/build-types/components/app/use-route-title.d.ts.map +1 -1
- package/build-types/components/canvas/back-button.d.ts.map +1 -1
- package/build-types/components/canvas/index.d.ts +0 -3
- package/build-types/components/canvas/index.d.ts.map +1 -1
- package/build-types/components/canvas/site-preview.d.ts +10 -0
- package/build-types/components/canvas/site-preview.d.ts.map +1 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts +40 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts.map +1 -0
- package/build-types/components/canvas/viewport.d.ts +15 -0
- package/build-types/components/canvas/viewport.d.ts.map +1 -0
- package/build-types/components/canvas-renderer/index.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts +22 -0
- package/build-types/components/error-boundary/index.d.ts.map +1 -0
- package/build-types/components/navigation/drilldown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts +0 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/index.d.ts.map +1 -1
- package/build-types/components/navigation/items.d.ts +0 -3
- package/build-types/components/navigation/items.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-item/index.d.ts +0 -1
- package/build-types/components/navigation/navigation-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-screen/index.d.ts +0 -7
- package/build-types/components/navigation/navigation-screen/index.d.ts.map +1 -1
- package/build-types/components/navigation/path-matching.d.ts +0 -3
- package/build-types/components/navigation/path-matching.d.ts.map +1 -1
- package/build-types/components/navigation/router-link-item.d.ts.map +1 -1
- package/build-types/components/navigation/use-sidebar-parent.d.ts.map +1 -1
- package/build-types/components/plugin-area/index.d.ts +12 -0
- package/build-types/components/plugin-area/index.d.ts.map +1 -0
- package/build-types/components/root/index.d.ts +0 -1
- package/build-types/components/root/index.d.ts.map +1 -1
- package/build-types/components/root/single-page.d.ts +0 -1
- package/build-types/components/root/single-page.d.ts.map +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts.map +1 -1
- package/build-types/components/save-button/index.d.ts +0 -4
- package/build-types/components/save-button/index.d.ts.map +1 -1
- package/build-types/components/save-panel/index.d.ts.map +1 -1
- package/build-types/components/save-panel/use-save-shortcut.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts +0 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/index.d.ts +0 -5
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +15 -5
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/index.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +0 -3
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +12 -3
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/store/types.d.ts +34 -6
- package/build-types/store/types.d.ts.map +1 -1
- package/package.json +28 -25
- package/src/components/app/index.tsx +0 -7
- package/src/components/app/router.tsx +19 -18
- package/src/components/app/use-route-title.ts +0 -7
- package/src/components/canvas/back-button.tsx +0 -3
- package/src/components/canvas/index.tsx +117 -22
- package/src/components/canvas/site-preview.tsx +64 -0
- package/src/components/canvas/use-navigate-to-entity-record.ts +220 -0
- package/src/components/canvas/viewport.ts +34 -0
- package/src/components/canvas-renderer/index.tsx +0 -7
- package/src/components/error-boundary/index.tsx +71 -0
- package/src/components/error-boundary/style.module.scss +13 -0
- package/src/components/navigation/drilldown-item/index.tsx +2 -13
- package/src/components/navigation/dropdown-item/index.tsx +11 -19
- package/src/components/navigation/dropdown-item/{style.scss → style.module.scss} +6 -2
- package/src/components/navigation/index.tsx +1 -9
- package/src/components/navigation/items.tsx +0 -7
- package/src/components/navigation/navigation-item/index.tsx +3 -18
- package/src/components/navigation/navigation-item/{style.scss → style.module.scss} +7 -14
- package/src/components/navigation/navigation-screen/index.tsx +6 -26
- package/src/components/navigation/navigation-screen/{style.scss → style.module.scss} +10 -9
- package/src/components/navigation/path-matching.ts +0 -3
- package/src/components/navigation/router-link-item.tsx +0 -11
- package/src/components/navigation/use-sidebar-parent.ts +1 -13
- package/src/components/plugin-area/index.tsx +34 -0
- package/src/components/root/{style.scss → _layout.module.scss} +71 -40
- package/src/components/root/_view-transitions.module.scss +205 -0
- package/src/components/root/index.tsx +44 -35
- package/src/components/root/single-page.tsx +15 -18
- package/src/components/root/style.module.scss +2 -0
- package/src/components/root/use-sync-body-background.ts +1 -4
- package/src/components/save-button/index.tsx +36 -21
- package/src/components/save-button/style.module.scss +10 -0
- package/src/components/save-panel/index.tsx +2 -8
- package/src/components/save-panel/style.module.scss +7 -0
- package/src/components/save-panel/use-save-shortcut.ts +0 -3
- package/src/components/sidebar/index.tsx +5 -12
- package/src/components/sidebar/style.module.scss +29 -0
- package/src/index.tsx +0 -5
- package/src/lock-unlock.ts +0 -3
- package/src/store/actions.ts +18 -4
- package/src/store/index.ts +0 -7
- package/src/store/reducer.ts +19 -3
- package/src/store/selectors.ts +28 -3
- package/src/store/types.ts +37 -6
- package/build-style/style-rtl.css +0 -132
- package/build-style/style.css +0 -132
- package/build-style/view-transitions-rtl.css +0 -189
- package/build-style/view-transitions.css +0 -189
- package/build-types/components/site-hub/index.d.ts +0 -4
- package/build-types/components/site-hub/index.d.ts.map +0 -1
- package/build-types/components/site-icon/index.d.ts +0 -9
- package/build-types/components/site-icon/index.d.ts.map +0 -1
- package/build-types/components/site-icon-link/index.d.ts +0 -8
- package/build-types/components/site-icon-link/index.d.ts.map +0 -1
- package/build-types/components/user-theme-provider/index.d.ts +0 -6
- package/build-types/components/user-theme-provider/index.d.ts.map +0 -1
- package/src/components/save-button/style.scss +0 -9
- package/src/components/sidebar/style.scss +0 -23
- package/src/style.scss +0 -33
- package/src/view-transitions.scss +0 -221
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.21.0 (2026-08-26)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- Restore bottom-centered snackbar notices after the CSS Modules migration ([#81995](https://github.com/WordPress/gutenberg/pull/81995)).
|
|
10
|
+
- Mount the plugins registered with `registerPlugin`, so the sidebars, panels and menu items they fill render ([#81754](https://github.com/WordPress/gutenberg/pull/81754)).
|
|
11
|
+
- Canvas: Show the site's front end where a route names no entity and the theme has no block templates to resolve one from, instead of an editor with nothing open. Was previously handled by the home route alone, leaving `/identity` broken on a classic theme ([#81749](https://github.com/WordPress/gutenberg/pull/81749)).
|
|
12
|
+
- Canvas: Open an entity at the width its `viewport` param asks for through the editor provider, so the width comes from the theme's breakpoints rather than the defaults ([#81750](https://github.com/WordPress/gutenberg/pull/81750)).
|
|
13
|
+
- Canvas: Stop writing the current width into the `viewport` search param when leaving an entity. The param says where an entity opens; a width set from the device preview is view state and no longer follows the user between entities ([#81750](https://github.com/WordPress/gutenberg/pull/81750)).
|
|
14
|
+
- Canvas: Do not offer to edit a trashed entity from its preview ([#81632](https://github.com/WordPress/gutenberg/pull/81632)).
|
|
15
|
+
- Translate the click-to-edit label on a previewed canvas, and name the action rather than the gesture ([#81620](https://github.com/WordPress/gutenberg/pull/81620)).
|
|
16
|
+
|
|
17
|
+
### Enhancements
|
|
18
|
+
|
|
19
|
+
- Save button: Use the shared UI keyboard shortcut utilities for its tooltip and accessibility metadata. ([#81826](https://github.com/WordPress/gutenberg/pull/81826))
|
|
20
|
+
- Contain a failure to the surface it happened in, so a stage, inspector or canvas that throws leaves the rest of the screen working ([#81622](https://github.com/WordPress/gutenberg/pull/81622)).
|
|
21
|
+
- Warn before leaving the page with unsaved changes ([#81625](https://github.com/WordPress/gutenberg/pull/81625)).
|
|
22
|
+
- Open an entity at the width its `viewport` search param asks for, so a navigation overlay meant for mobile is edited at mobile width ([#81617](https://github.com/WordPress/gutenberg/pull/81617)).
|
|
23
|
+
- Add a `stage` visibility function to a route's config, mirroring `inspector`, so a route can hide its stage and leave the canvas to fill the surfaces area.
|
|
24
|
+
- Pass the editor's entity navigation callbacks from the canvas, so a template part or synced pattern can be opened from the block inspector and navigated back out of, restoring the block that was selected ([#81590](https://github.com/WordPress/gutenberg/pull/81590)).
|
|
25
|
+
- Add `registerEntityLinks` and `getEntityLink`, so an application declares where each post type is listed and edited and the canvas resolves every link through them ([#81590](https://github.com/WordPress/gutenberg/pull/81590)).
|
|
26
|
+
- Run the editor's post actions from the canvas, returning to the list when an entity is trashed or deleted and offering a way to reach a duplicate ([#81590](https://github.com/WordPress/gutenberg/pull/81590)).
|
|
27
|
+
|
|
28
|
+
### Breaking Changes
|
|
29
|
+
|
|
30
|
+
- Remove `editLink` from a route's canvas data. Register the post type's `edit` path with `registerEntityLinks` instead ([#81590](https://github.com/WordPress/gutenberg/pull/81590)).
|
|
31
|
+
|
|
32
|
+
### Internal
|
|
33
|
+
|
|
34
|
+
- Migrate Boot styles to CSS Modules and encapsulate its internal DOM classes ([#81756](https://github.com/WordPress/gutenberg/pull/81756)).
|
|
35
|
+
|
|
36
|
+
## 0.20.0 (2026-08-12)
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
- Adjust the specificity of the responsive image default in the layout container so components can size their own images ([#80845](https://github.com/WordPress/gutenberg/pull/80845)).
|
|
41
|
+
- Ignore `updateMenuItem` for menu items that were never registered, instead of adding a partial entry that renders as an empty navigation row ([#81581](https://github.com/WordPress/gutenberg/pull/81581)).
|
|
42
|
+
|
|
5
43
|
## 0.19.0 (2026-07-29)
|
|
6
44
|
|
|
7
45
|
## 0.18.0 (2026-07-14)
|
package/README.md
CHANGED
|
@@ -55,6 +55,10 @@ Both functions follow the same startup sequence:
|
|
|
55
55
|
2. Run the page's init modules (see below).
|
|
56
56
|
3. Render the application into `mountId`.
|
|
57
57
|
|
|
58
|
+
Boot's internal shell is private. Consumers can style the mount element and
|
|
59
|
+
their own route content. Boot does not provide stable styling hooks or
|
|
60
|
+
replacement hooks for its internal layout, navigation, and surface elements.
|
|
61
|
+
|
|
58
62
|
## Init modules
|
|
59
63
|
|
|
60
64
|
Init modules are script modules that run a one-time setup step at page startup, after menu items and routes are registered and before the app renders. They are useful for tasks that cannot be expressed in the page's static PHP configuration, such as assigning menu-item icons or registering core-data entities.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/app/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { createRoot, StrictMode, type ComponentType } from '@wordpress/element';\nimport { dispatch, useSelect } from '@wordpress/data';\nimport Router from './router';\nimport RootSinglePage from '../root/single-page';\nimport { store } from '../../store';\nimport type { MenuItem, Route } from '../../store/types';\n\ninterface AppProps {\n\trootComponent?: ComponentType;\n}\n\nfunction App( { rootComponent }: AppProps ) {\n\tconst routes = useSelect( ( select ) => select( store ).getRoutes(), [] );\n\n\treturn <Router routes={ routes } rootComponent={ rootComponent } />;\n}\n\n/*\n * Import and run page init modules.\n * Each module must export an async `init` function,\n * awaited before the app renders so startup tasks finish first.\n */\nasync function runInitModules( initModules?: string[] ) {\n\tfor ( const moduleId of initModules ?? [] ) {\n\t\tconst module = await import( moduleId );\n\t\tawait module.init();\n\t}\n}\n\ninterface InitProps {\n\tmountId: string;\n\tmenuItems?: MenuItem[];\n\troutes?: Route[];\n\tinitModules?: string[];\n\tdashboardLink?: string;\n}\n\nexport async function init( {\n\tmountId,\n\tmenuItems,\n\troutes,\n\tinitModules,\n\tdashboardLink,\n}: InitProps ) {\n\t( menuItems ?? [] ).forEach( ( menuItem ) => {\n\t\tdispatch( store ).registerMenuItem( menuItem.id, menuItem );\n\t} );\n\n\t( routes ?? [] ).forEach( ( route ) => {\n\t\tdispatch( store ).registerRoute( route );\n\t} );\n\n\tif ( dashboardLink ) {\n\t\tdispatch( store ).setDashboardLink( dashboardLink );\n\t}\n\n\tawait runInitModules( initModules );\n\n\t// Render the app\n\tconst rootElement = document.getElementById( mountId );\n\tif ( rootElement ) {\n\t\tconst root = createRoot( rootElement );\n\t\troot.render(\n\t\t\t<StrictMode>\n\t\t\t\t<App />\n\t\t\t</StrictMode>\n\t\t);\n\t}\n}\n\ninterface InitSinglePageProps {\n\tmountId: string;\n\troutes?: Route[];\n\tinitModules?: string[];\n}\n\nexport async function initSinglePage( {\n\tmountId,\n\troutes,\n\tinitModules,\n}: InitSinglePageProps ) {\n\t( routes ?? [] ).forEach( ( route ) => {\n\t\tdispatch( store ).registerRoute( route );\n\t} );\n\n\tawait runInitModules( initModules );\n\n\t// Render the app without sidebar\n\tconst rootElement = document.getElementById( mountId );\n\tif ( rootElement ) {\n\t\tconst root = createRoot( root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AACtC,aAAU,KAAM,EAAE,cAAe,KAAM;AAAA,EACxC,CAAE;AAEF,QAAM,eAAgB,WAAY;AAGlC,QAAM,cAAc,SAAS,eAAgB,OAAQ;AACrD,MAAK,aAAc;AAClB,UAAM,OAAO,WAAY,WAAY;AACrC,SAAK;AAAA,MACJ,oBAAC,cACA,8BAAC,OAAI,eAAgB,gBAAiB,GACvC;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,6 +8,97 @@ import {
|
|
|
8
8
|
import { resolveSelect } from "@wordpress/data";
|
|
9
9
|
import { store as coreStore } from "@wordpress/core-data";
|
|
10
10
|
import Root from "../root/index.mjs";
|
|
11
|
+
|
|
12
|
+
// packages/style-runtime/src/index.ts
|
|
13
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
14
|
+
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;
|
|
28
|
+
}
|
|
29
|
+
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
|
+
}
|
|
42
|
+
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);
|
|
64
|
+
}
|
|
65
|
+
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
|
+
};
|
|
85
|
+
}
|
|
86
|
+
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
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 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
|
+
|
|
100
|
+
// packages/boot/src/components/app/router.tsx
|
|
101
|
+
import ErrorBoundary from "../error-boundary/index.mjs";
|
|
11
102
|
import { unlock } from "../../lock-unlock.mjs";
|
|
12
103
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
104
|
var {
|
|
@@ -21,7 +112,7 @@ var {
|
|
|
21
112
|
useLoaderData
|
|
22
113
|
} = unlock(routePrivateApis);
|
|
23
114
|
function NotFoundComponent() {
|
|
24
|
-
return /* @__PURE__ */ jsx("div", { className:
|
|
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") }) });
|
|
25
116
|
}
|
|
26
117
|
function createRouteFromDefinition(route, parentRoute) {
|
|
27
118
|
let tanstackRoute = createRoute({
|
|
@@ -62,10 +153,15 @@ function createRouteFromDefinition(route, parentRoute) {
|
|
|
62
153
|
if (routeConfig.inspector) {
|
|
63
154
|
inspector = await routeConfig.inspector(context);
|
|
64
155
|
}
|
|
156
|
+
let stage = true;
|
|
157
|
+
if (routeConfig.stage) {
|
|
158
|
+
stage = await routeConfig.stage(context);
|
|
159
|
+
}
|
|
65
160
|
return {
|
|
66
161
|
...loaderData,
|
|
67
162
|
canvas: canvasData,
|
|
68
163
|
inspector,
|
|
164
|
+
stage,
|
|
69
165
|
title: titleData,
|
|
70
166
|
routeContentModule: route.content_module
|
|
71
167
|
};
|
|
@@ -78,10 +174,10 @@ function createRouteFromDefinition(route, parentRoute) {
|
|
|
78
174
|
const Inspector = module.inspector;
|
|
79
175
|
return createLazyRoute(route.path)({
|
|
80
176
|
component: function RouteComponent() {
|
|
81
|
-
const { inspector: showInspector } = useLoaderData({ from: route.path }) ?? {};
|
|
177
|
+
const { inspector: showInspector, stage: showStage } = useLoaderData({ from: route.path }) ?? {};
|
|
82
178
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
-
Stage && /* @__PURE__ */ jsx("div", { className:
|
|
84
|
-
Inspector && showInspector && /* @__PURE__ */ jsx("div", { className:
|
|
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, {}) }) })
|
|
85
181
|
] });
|
|
86
182
|
}
|
|
87
183
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/app/router.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { Page } from '@wordpress/admin-ui';\nimport {\n\tprivateApis as routePrivateApis,\n\ttype AnyRoute,\n} from '@wordpress/route';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Root from '../root';\nimport type { Route, RouteConfig, RouteLoaderContext } from '../../store/types';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tcreateLazyRoute,\n\tcreateRouter,\n\tcreateRootRoute,\n\tcreateRoute,\n\tRouterProvider,\n\tcreateBrowserHistory,\n\tparseHref,\n\tuseLoaderData,\n} = unlock( routePrivateApis );\n\n// Not found component\nfunction NotFoundComponent() {\n\treturn (\n\t\t<div className=\"boot-layout__stage\">\n\t\t\t<Page title={ __( 'Route not found' ) } hasPadding>\n\t\t\t\t{ __( \"The page you're looking for does not exist\" ) }\n\t\t\t</Page>\n\t\t</div>\n\t);\n}\n\n/**\n * Creates a TanStack route from a Route definition.\n *\n * @param route Route configuration\n * @param parentRoute Parent route.\n * @return Tanstack Route.\n */\nfunction createRouteFromDefinition( route: Route, parentRoute: AnyRoute ) {\n\t// Create route without component initially\n\tlet tanstackRoute = createRoute( {\n\t\tgetParentRoute: () => parentRoute,\n\t\tpath: route.path,\n\t\tbeforeLoad: async ( opts: any ) => {\n\t\t\t// Import route module here (lazy)\n\t\t\tif ( route.route_module ) {\n\t\t\t\tconst module = await import( route.route_module );\n\t\t\t\tconst routeConfig = module.route || {};\n\n\t\t\t\tif ( routeConfig.beforeLoad ) {\n\t\t\t\t\treturn routeConfig.beforeLoad( {\n\t\t\t\t\t\tparams: opts.params || {},\n\t\t\t\t\t\tsearch: opts.search || {},\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tloader: async ( opts: any ) => {\n\t\t\t// Import route module here (lazy)\n\t\t\tlet routeConfig: RouteConfig = {};\n\t\t\tif ( route.route_module ) {\n\t\t\t\tconst module = await import( route.route_module );\n\t\t\t\trouteConfig = module.route || {};\n\t\t\t}\n\n\t\t\tconst context: RouteLoaderContext = {\n\t\t\t\tparams: opts.params || {},\n\t\t\t\tsearch: opts.deps || {},\n\t\t\t};\n\n\t\t\tconst [ , loaderData, canvasData, titleData ] = await Promise.all( [\n\t\t\t\tresolveSelect( coreStore ).getEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'__unstableBase'\n\t\t\t\t),\n\t\t\t\trouteConfig.loader\n\t\t\t\t\t? routeConfig.loader( context )\n\t\t\t\t\t: Promise.resolve( undefined ),\n\t\t\t\trouteConfig.canvas\n\t\t\t\t\t? routeConfig.canvas( context )\n\t\t\t\t\t: Promise.resolve( undefined ),\n\t\t\t\trouteConfig.title\n\t\t\t\t\t? routeConfig.title( context )\n\t\t\t\t\t: Promise.resolve( undefined ),\n\t\t\t] );\n\n\t\t\tlet inspector = true;\n\t\t\tif ( routeConfig.inspector ) {\n\t\t\t\tinspector = await routeConfig.inspector( context );\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...( loaderData as any ),\n\t\t\t\tcanvas: canvasData,\n\t\t\t\tinspector,\n\t\t\t\ttitle: titleData,\n\t\t\t\trouteContentModule: route.content_module,\n\t\t\t};\n\t\t},\n\t\tloaderDeps: ( opts: any ) => opts.search,\n\t} );\n\n\t// Chain .lazy() to preload content module on intent\n\ttanstackRoute = tanstackRoute.lazy( async () => {\n\t\tconst module = route.content_module\n\t\t\t? await import( route.content_module )\n\t\t\t: {};\n\n\t\tconst Stage = module.stage;\n\t\tconst Inspector = module.inspector;\n\n\t\treturn createLazyRoute( route.path )( {\n\t\t\tcomponent: function RouteComponent() {\n\t\t\t\tconst { inspector: showInspector } =\n\t\t\t\t\tuseLoaderData( { from: route.path } ) ?? {};\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ Stage && (\n\t\t\t\t\t\t\t<div className=\"boot-layout__stage\">\n\t\t\t\t\t\t\t\t<Stage />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ Inspector && showInspector && (\n\t\t\t\t\t\t\t<div className=\"boot-layout__inspector\">\n\t\t\t\t\t\t\t\t<Inspector />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t},\n\t\t} );\n\t} );\n\n\treturn tanstackRoute;\n}\n\n/**\n * Creates a route tree from route definitions.\n *\n * @param routes Routes definition.\n * @param rootComponent Root component to use for the router.\n * @return Router tree.\n */\nfunction createRouteTree(\n\troutes: Route[],\n\trootComponent: ComponentType = Root\n) {\n\tconst rootRoute = createRootRoute( {\n\t\tcomponent: rootComponent as any,\n\t\tcontext: () => ( {} ),\n\t} );\n\n\t// Create routes from definitions (now synchronous)\n\tconst dynamicRoutes = routes.map( ( route ) =>\n\t\tcreateRouteFromDefinition( route, rootRoute )\n\t);\n\n\treturn rootRoute.addChildren( dynamicRoutes );\n}\n\n// Create custom history that parses ?p= query parameter\nfunction createPathHistory() {\n\treturn createBrowserHistory( {\n\t\tparseLocation: () => {\n\t\t\tconst url = new URL( window.location.href );\n\t\t\tconst path = url.searchParams.get( 'p' ) || '/';\n\t\t\tconst pathHref = `${ path }${ url.hash }`;\n\t\t\treturn parseHref( pathHref, window.history.state );\n\t\t},\n\t\tcreateHref: ( href: string ) => {\n\t\t\tconst searchParams = new URLSearchParams( window.location.search );\n\t\t\tsearchParams.set( 'p', href );\n\t\t\treturn `${ window.location.pathname }?${ searchParams }`;\n\t\t},\n\t} );\n}\n\ninterface RouterProps {\n\troutes: Route[];\n\trootComponent?: ComponentType;\n}\n\nexport default function Router( {\n\troutes,\n\trootComponent = Root,\n}: RouterProps ) {\n\tconst router = useMemo( () => {\n\t\tconst history = createPathHistory();\n\t\tconst routeTree = createRouteTree( routes, rootComponent );\n\n\t\treturn createRouter( {\n\t\t\thistory,\n\t\t\trouteTree,\n\t\t\tdefaultPreload: 'intent',\n\t\t\tdefaultNotFoundComponent: NotFoundComponent,\n\t\t\tdefaultViewTransition: {\n\t\t\t\ttypes: ( {\n\t\t\t\t\tfromLocation,\n\t\t\t\t}: {\n\t\t\t\t\tfromLocation?: unknown;\n\t\t\t\t\ttoLocation: unknown;\n\t\t\t\t\tpathChanged: boolean;\n\t\t\t\t\threfChanged: boolean;\n\t\t\t\t\thashChanged: boolean;\n\t\t\t\t} ) => {\n\t\t\t\t\t// Disable view transition on initial navigation (no previous location)\n\t\t\t\t\tif ( ! fromLocation ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Enable with navigation type for subsequent navigations\n\t\t\t\t\treturn [ 'navigate' ];\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t}, [ routes, rootComponent ] );\n\n\treturn <RouterProvider router={ router } />;\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
3
|
+
"sources": ["../../../src/components/app/router.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/root/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["import type { ComponentType } from 'react';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { Page } from '@wordpress/admin-ui';\nimport {\n\tprivateApis as routePrivateApis,\n\ttype AnyRoute,\n} from '@wordpress/route';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport Root from '../root';\nimport styles from '../root/style.module.scss';\nimport ErrorBoundary from '../error-boundary';\nimport type { Route, RouteConfig, RouteLoaderContext } from '../../store/types';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tcreateLazyRoute,\n\tcreateRouter,\n\tcreateRootRoute,\n\tcreateRoute,\n\tRouterProvider,\n\tcreateBrowserHistory,\n\tparseHref,\n\tuseLoaderData,\n} = unlock( routePrivateApis );\n\n// Not found component\nfunction NotFoundComponent() {\n\treturn (\n\t\t<div className={ styles.stage }>\n\t\t\t<Page title={ __( 'Route not found' ) } hasPadding>\n\t\t\t\t{ __( \"The page you're looking for does not exist\" ) }\n\t\t\t</Page>\n\t\t</div>\n\t);\n}\n\n/**\n * Creates a TanStack route from a Route definition.\n *\n * @param route Route configuration\n * @param parentRoute Parent route.\n * @return Tanstack Route.\n */\nfunction createRouteFromDefinition( route: Route, parentRoute: AnyRoute ) {\n\t// Create route without component initially\n\tlet tanstackRoute = createRoute( {\n\t\tgetParentRoute: () => parentRoute,\n\t\tpath: route.path,\n\t\tbeforeLoad: async ( opts: any ) => {\n\t\t\t// Import route module here (lazy)\n\t\t\tif ( route.route_module ) {\n\t\t\t\tconst module = await import( route.route_module );\n\t\t\t\tconst routeConfig = module.route || {};\n\n\t\t\t\tif ( routeConfig.beforeLoad ) {\n\t\t\t\t\treturn routeConfig.beforeLoad( {\n\t\t\t\t\t\tparams: opts.params || {},\n\t\t\t\t\t\tsearch: opts.search || {},\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tloader: async ( opts: any ) => {\n\t\t\t// Import route module here (lazy)\n\t\t\tlet routeConfig: RouteConfig = {};\n\t\t\tif ( route.route_module ) {\n\t\t\t\tconst module = await import( route.route_module );\n\t\t\t\trouteConfig = module.route || {};\n\t\t\t}\n\n\t\t\tconst context: RouteLoaderContext = {\n\t\t\t\tparams: opts.params || {},\n\t\t\t\tsearch: opts.deps || {},\n\t\t\t};\n\n\t\t\tconst [ , loaderData, canvasData, titleData ] = await Promise.all( [\n\t\t\t\tresolveSelect( coreStore ).getEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'__unstableBase'\n\t\t\t\t),\n\t\t\t\trouteConfig.loader\n\t\t\t\t\t? routeConfig.loader( context )\n\t\t\t\t\t: Promise.resolve( undefined ),\n\t\t\t\trouteConfig.canvas\n\t\t\t\t\t? routeConfig.canvas( context )\n\t\t\t\t\t: Promise.resolve( undefined ),\n\t\t\t\trouteConfig.title\n\t\t\t\t\t? routeConfig.title( context )\n\t\t\t\t\t: Promise.resolve( undefined ),\n\t\t\t] );\n\n\t\t\tlet inspector = true;\n\t\t\tif ( routeConfig.inspector ) {\n\t\t\t\tinspector = await routeConfig.inspector( context );\n\t\t\t}\n\n\t\t\tlet stage = true;\n\t\t\tif ( routeConfig.stage ) {\n\t\t\t\tstage = await routeConfig.stage( context );\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...( loaderData as any ),\n\t\t\t\tcanvas: canvasData,\n\t\t\t\tinspector,\n\t\t\t\tstage,\n\t\t\t\ttitle: titleData,\n\t\t\t\trouteContentModule: route.content_module,\n\t\t\t};\n\t\t},\n\t\tloaderDeps: ( opts: any ) => opts.search,\n\t} );\n\n\t// Chain .lazy() to preload content module on intent\n\ttanstackRoute = tanstackRoute.lazy( async () => {\n\t\tconst module = route.content_module\n\t\t\t? await import( route.content_module )\n\t\t\t: {};\n\n\t\tconst Stage = module.stage;\n\t\tconst Inspector = module.inspector;\n\n\t\treturn createLazyRoute( route.path )( {\n\t\t\tcomponent: function RouteComponent() {\n\t\t\t\tconst { inspector: showInspector, stage: showStage } =\n\t\t\t\t\tuseLoaderData( { from: route.path } ) ?? {};\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ Stage && showStage && (\n\t\t\t\t\t\t\t<div className={ styles.stage }>\n\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t<Stage />\n\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ Inspector && showInspector && (\n\t\t\t\t\t\t\t<div className={ styles.inspector }>\n\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t<Inspector />\n\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t},\n\t\t} );\n\t} );\n\n\treturn tanstackRoute;\n}\n\n/**\n * Creates a route tree from route definitions.\n *\n * @param routes Routes definition.\n * @param rootComponent Root component to use for the router.\n * @return Router tree.\n */\nfunction createRouteTree(\n\troutes: Route[],\n\trootComponent: ComponentType = Root\n) {\n\tconst rootRoute = createRootRoute( {\n\t\tcomponent: rootComponent as any,\n\t\tcontext: () => ( {} ),\n\t} );\n\n\t// Create routes from definitions (now synchronous)\n\tconst dynamicRoutes = routes.map( ( route ) =>\n\t\tcreateRouteFromDefinition( route, rootRoute )\n\t);\n\n\treturn rootRoute.addChildren( dynamicRoutes );\n}\n\n// Create custom history that parses ?p= query parameter\nfunction createPathHistory() {\n\treturn createBrowserHistory( {\n\t\tparseLocation: () => {\n\t\t\tconst url = new URL( window.location.href );\n\t\t\tconst path = url.searchParams.get( 'p' ) || '/';\n\t\t\tconst pathHref = `${ path }${ url.hash }`;\n\t\t\treturn parseHref( pathHref, window.history.state );\n\t\t},\n\t\tcreateHref: ( href: string ) => {\n\t\t\tconst searchParams = new URLSearchParams( window.location.search );\n\t\t\tsearchParams.set( 'p', href );\n\t\t\treturn `${ window.location.pathname }?${ searchParams }`;\n\t\t},\n\t} );\n}\n\ninterface RouterProps {\n\troutes: Route[];\n\trootComponent?: ComponentType;\n}\n\nexport default function Router( {\n\troutes,\n\trootComponent = Root,\n}: RouterProps ) {\n\tconst router = useMemo( () => {\n\t\tconst history = createPathHistory();\n\t\tconst routeTree = createRouteTree( routes, rootComponent );\n\n\t\treturn createRouter( {\n\t\t\thistory,\n\t\t\trouteTree,\n\t\t\tdefaultPreload: 'intent',\n\t\t\tdefaultNotFoundComponent: NotFoundComponent,\n\t\t\tdefaultViewTransition: {\n\t\t\t\ttypes: ( {\n\t\t\t\t\tfromLocation,\n\t\t\t\t}: {\n\t\t\t\t\tfromLocation?: unknown;\n\t\t\t\t\ttoLocation: unknown;\n\t\t\t\t\tpathChanged: boolean;\n\t\t\t\t\threfChanged: boolean;\n\t\t\t\t\thashChanged: boolean;\n\t\t\t\t} ) => {\n\t\t\t\t\t// Disable view transition on initial navigation (no previous location)\n\t\t\t\t\tif ( ! fromLocation ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Enable with navigation type for subsequent navigations\n\t\t\t\t\treturn [ 'navigate' ];\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t}, [ routes, rootComponent ] );\n\n\treturn <RouterProvider router={ router } />;\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"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%)}}\");\n}\nexport 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\"};\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB;AAAA,EACC,eAAe;AAAA,OAET;AACP,SAAS,qBAAqB;AAC9B,SAAS,SAAS,iBAAiB;AACnC,OAAO,UAAU;;;ACAjB,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AA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AM,eAAe,IAAI,gBAAiB,OAAO,SAAS,MAAO;AACjE,mBAAa,IAAK,KAAK,IAAK;AAC5B,aAAO,GAAI,OAAO,SAAS,QAAS,IAAK,YAAa;AAAA,IACvD;AAAA,EACD,CAAE;AACH;AAOe,SAAR,OAAyB;AAAA,EAC/B;AAAA,EACA,gBAAgB;AACjB,GAAiB;AAChB,QAAM,SAAS,QAAS,MAAM;AAC7B,UAAM,UAAU,kBAAkB;AAClC,UAAM,YAAY,gBAAiB,QAAQ,aAAc;AAEzD,WAAO,aAAc;AAAA,MACpB;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,0BAA0B;AAAA,MAC1B,uBAAuB;AAAA,QACtB,OAAO,CAAE;AAAA,UACR;AAAA,QACD,MAMO;AAEN,cAAK,CAAE,cAAe;AACrB,mBAAO;AAAA,UACR;AAGA,iBAAO,CAAE,UAAW;AAAA,QACrB;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAE,QAAQ,aAAc,CAAE;AAE7B,SAAO,oBAAC,kBAAe,QAAkB;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/app/use-route-title.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useEffect, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore, type UnstableBase } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { privateApis as routePrivateApis } from '@wordpress/route';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useMatches } = unlock( routePrivateApis );\n\n/**\n * Hook that manages document title updates based on route changes.\n * Formats titles with WordPress conventions and announces them to screen readers.\n *\n * This hook should be called from the Root component to ensure it runs on every route.\n */\nexport default function useRouteTitle() {\n\tconst location = useLocation();\n\tconst matches = useMatches();\n\tconst currentMatch = matches[ matches.length - 1 ];\n\tconst routeTitle = ( currentMatch?.loaderData as any )?.title as\n\t\t| string\n\t\t| undefined;\n\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord< UnstableBase >(\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase'\n\t\t\t)?.name,\n\t\t[]\n\t);\n\n\tconst isInitialLocationRef = useRef( true );\n\n\tuseEffect( () => {\n\t\tisInitialLocationRef.current = false;\n\t}, [ location ] );\n\n\tuseEffect( () => {\n\t\t// Don't update or announce the title for initial page load.\n\t\tif ( isInitialLocationRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\trouteTitle &&\n\t\t\ttypeof routeTitle === 'string' &&\n\t\t\tsiteTitle &&\n\t\t\ttypeof siteTitle === 'string'\n\t\t) {\n\t\t\t// Decode entities for display\n\t\t\tconst decodedRouteTitle = decodeEntities( routeTitle );\n\t\t\tconst decodedSiteTitle = decodeEntities( siteTitle );\n\n\t\t\t// Format title following WordPress admin conventions\n\t\t\tconst formattedTitle = sprintf(\n\t\t\t\t/* translators: Admin document title. 1: Admin screen name, 2: Site name. */\n\t\t\t\t__( '%1$s ‹ %2$s — WordPress' ),\n\t\t\t\tdecodedRouteTitle,\n\t\t\t\tdecodedSiteTitle\n\t\t\t);\n\n\t\t\tdocument.title = formattedTitle;\n\n\t\t\t// Announce title on route change for screen readers.\n\t\t\tif ( decodedRouteTitle ) {\n\t\t\t\tspeak( decodedRouteTitle, 'assertive' );\n\t\t\t}\n\t\t}\n\t}, [ routeTitle, siteTitle, location ] );\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAoC;AACtD,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,SAAS,eAAe,wBAAwB;AAChD,SAAS,cAAc;AAEvB,IAAM,EAAE,aAAa,WAAW,IAAI,OAAQ,gBAAiB;AAQ9C,SAAR,gBAAiC;AACvC,QAAM,WAAW,YAAY;AAC7B,QAAM,UAAU,WAAW;AAC3B,QAAM,eAAe,QAAS,QAAQ,SAAS,CAAE;AACjD,QAAM,aAAe,cAAc,YAAqB;AAIxD,QAAM,YAAY;AAAA,IACjB,CAAE,WACD,OAAQ,SAAU,EAAE;AAAA,MACnB;AAAA,MACA;AAAA,IACD,GAAG;AAAA,IACJ,CAAC;AAAA,EACF;AAEA,QAAM,uBAAuB,OAAQ,IAAK;AAE1C,YAAW,MAAM;AAChB,yBAAqB,UAAU;AAAA,EAChC,GAAG,CAAE,QAAS,CAAE;AAEhB,YAAW,MAAM;AAEhB,QAAK,qBAAqB,SAAU;AACnC;AAAA,IACD;AAEA,QACC,cACA,OAAO,eAAe,YACtB,aACA,OAAO,cAAc,UACpB;AAED,YAAM,oBAAoB,eAAgB,UAAW;AACrD,YAAM,mBAAmB,eAAgB,SAAU;AAGnD,YAAM,iBAAiB;AAAA;AAAA,QAEtB,GAAI,yBAA0B;AAAA,QAC9B;AAAA,QACA;AAAA,MACD;AAEA,eAAS,QAAQ;AAGjB,UAAK,mBAAoB;AACxB,cAAO,mBAAmB,WAAY;AAAA,MACvC;AAAA,IACD;AAAA,EACD,GAAG,CAAE,YAAY,WAAW,QAAS,CAAE;AACxC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/canvas/back-button.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { Button } from '@wordpress/components';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { __, isRTL } from '@wordpress/i18n';\n\n/**\n * Back button component that appears in full-screen canvas mode.\n *\n * @param {Object} props Component props\n * @param {number} props.length Number of BackButton fills (from Slot)\n * @return Back button\n */\nexport default function BootBackButton( { length }: { length: number } ) {\n\tconst handleBack = () => {\n\t\twindow.history.back();\n\t};\n\n\t// Only render if this is the only back button\n\tif ( length > 1 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ handleBack }\n\t\t\tlabel={ __( 'Go back' ) }\n\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,cAAc;AACvB,SAAS,aAAa,oBAAoB;AAC1C,SAAS,IAAI,aAAa;AAoBxB;AAXa,SAAR,eAAiC,EAAE,OAAO,GAAwB;AACxE,QAAM,aAAa,MAAM;AACxB,WAAO,QAAQ,KAAK;AAAA,EACrB;AAGA,MAAK,SAAS,GAAI;AACjB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,SAAU;AAAA,MACV,OAAQ,GAAI,SAAU;AAAA,MACtB,MAAO,MAAM,IAAI,eAAe;AAAA;AAAA,EACjC;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,65 @@
|
|
|
1
1
|
// packages/boot/src/components/canvas/index.tsx
|
|
2
|
-
import { useState, useEffect } from "@wordpress/element";
|
|
2
|
+
import { useState, useEffect, useMemo } from "@wordpress/element";
|
|
3
3
|
import { Spinner } from "@wordpress/components";
|
|
4
|
-
import { useNavigate } from "@wordpress/route";
|
|
4
|
+
import { useNavigate, useSearch } from "@wordpress/route";
|
|
5
|
+
import { __ } from "@wordpress/i18n";
|
|
6
|
+
import { useSelect } from "@wordpress/data";
|
|
7
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
8
|
+
import { store as bootStore } from "../../store/index.mjs";
|
|
5
9
|
import BootBackButton from "./back-button.mjs";
|
|
10
|
+
import SitePreview from "./site-preview.mjs";
|
|
11
|
+
import useNavigateToEntityRecord, {
|
|
12
|
+
useActionPerformed
|
|
13
|
+
} from "./use-navigate-to-entity-record.mjs";
|
|
14
|
+
import { getDeviceType } from "./viewport.mjs";
|
|
6
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
16
|
function Canvas({ canvas }) {
|
|
8
17
|
const [Editor, setEditor] = useState(null);
|
|
9
18
|
const navigate = useNavigate();
|
|
19
|
+
const { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord } = useNavigateToEntityRecord();
|
|
20
|
+
const onActionPerformed = useActionPerformed(canvas.postType);
|
|
21
|
+
const viewport = useSearch({
|
|
22
|
+
strict: false,
|
|
23
|
+
select: (search) => search.viewport
|
|
24
|
+
});
|
|
25
|
+
const hasEntity = !!(canvas.postType && canvas.postId);
|
|
26
|
+
const isBlockTheme = useSelect(
|
|
27
|
+
(select) => select(coreStore).getCurrentTheme()?.is_block_theme,
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
30
|
+
const { editLink, isTrashed } = useSelect(
|
|
31
|
+
(select) => {
|
|
32
|
+
if (!canvas.postType || !canvas.postId) {
|
|
33
|
+
return { editLink: void 0, isTrashed: false };
|
|
34
|
+
}
|
|
35
|
+
const record = select(coreStore).getEntityRecord(
|
|
36
|
+
"postType",
|
|
37
|
+
canvas.postType,
|
|
38
|
+
canvas.postId
|
|
39
|
+
);
|
|
40
|
+
return {
|
|
41
|
+
editLink: select(bootStore).getEntityLink(
|
|
42
|
+
canvas.postType,
|
|
43
|
+
canvas.postId
|
|
44
|
+
),
|
|
45
|
+
isTrashed: record?.status === "trash"
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
[canvas.postType, canvas.postId]
|
|
49
|
+
);
|
|
50
|
+
const settings = useMemo(
|
|
51
|
+
() => ({
|
|
52
|
+
isPreviewMode: canvas.isPreview,
|
|
53
|
+
styles: canvas.isPreview ? [{ css: "body{min-height:100vh;}" }] : [],
|
|
54
|
+
onNavigateToEntityRecord,
|
|
55
|
+
onNavigateToPreviousEntityRecord
|
|
56
|
+
}),
|
|
57
|
+
[
|
|
58
|
+
canvas.isPreview,
|
|
59
|
+
onNavigateToEntityRecord,
|
|
60
|
+
onNavigateToPreviousEntityRecord
|
|
61
|
+
]
|
|
62
|
+
);
|
|
10
63
|
useEffect(() => {
|
|
11
64
|
import("@wordpress/lazy-editor").then((module) => {
|
|
12
65
|
setEditor(() => module.Editor);
|
|
@@ -14,7 +67,10 @@ function Canvas({ canvas }) {
|
|
|
14
67
|
console.error("Failed to load lazy editor:", error);
|
|
15
68
|
});
|
|
16
69
|
}, []);
|
|
17
|
-
if (!
|
|
70
|
+
if (!hasEntity && isBlockTheme === false) {
|
|
71
|
+
return /* @__PURE__ */ jsx(SitePreview, {});
|
|
72
|
+
}
|
|
73
|
+
if (!Editor || !hasEntity && isBlockTheme === void 0) {
|
|
18
74
|
return /* @__PURE__ */ jsx(
|
|
19
75
|
"div",
|
|
20
76
|
{
|
|
@@ -41,34 +97,37 @@ function Canvas({ canvas }) {
|
|
|
41
97
|
{
|
|
42
98
|
postType: canvas.postType,
|
|
43
99
|
postId: canvas.postId,
|
|
44
|
-
settings
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
backButton
|
|
100
|
+
settings,
|
|
101
|
+
backButton,
|
|
102
|
+
onActionPerformed,
|
|
103
|
+
initialViewport: getDeviceType(viewport)
|
|
49
104
|
}
|
|
50
105
|
)
|
|
51
106
|
}
|
|
52
107
|
),
|
|
53
|
-
canvas.isPreview &&
|
|
108
|
+
canvas.isPreview && editLink && /* @__PURE__ */ jsx(
|
|
54
109
|
"div",
|
|
55
110
|
{
|
|
56
|
-
onClick: () => navigate({ to:
|
|
111
|
+
onClick: isTrashed ? void 0 : () => navigate({ to: editLink }),
|
|
57
112
|
onKeyDown: (e) => {
|
|
113
|
+
if (isTrashed) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
58
116
|
if (e.key === "Enter" || e.key === " ") {
|
|
59
117
|
e.preventDefault();
|
|
60
|
-
navigate({ to:
|
|
118
|
+
navigate({ to: editLink });
|
|
61
119
|
}
|
|
62
120
|
},
|
|
63
121
|
style: {
|
|
64
122
|
position: "absolute",
|
|
65
123
|
inset: 0,
|
|
66
|
-
cursor: "pointer",
|
|
124
|
+
cursor: isTrashed ? "default" : "pointer",
|
|
67
125
|
zIndex: 1
|
|
68
126
|
},
|
|
69
127
|
role: "button",
|
|
70
128
|
tabIndex: 0,
|
|
71
|
-
"aria-
|
|
129
|
+
"aria-disabled": isTrashed,
|
|
130
|
+
"aria-label": __("Edit")
|
|
72
131
|
}
|
|
73
132
|
)
|
|
74
133
|
] });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/canvas/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useState, useEffect, useMemo } from '@wordpress/element';\nimport { Spinner } from '@wordpress/components';\nimport { useNavigate, useSearch } from '@wordpress/route';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as bootStore } from '../../store';\nimport type { CanvasData } from '../../store/types';\nimport BootBackButton from './back-button';\nimport SitePreview from './site-preview';\nimport useNavigateToEntityRecord, {\n\tuseActionPerformed,\n} from './use-navigate-to-entity-record';\nimport { getDeviceType } from './viewport';\n\ninterface CanvasProps {\n\tcanvas: CanvasData;\n}\n\n/**\n * Canvas component that dynamically loads and renders the lazy editor.\n *\n * @param {Object} props - Component props\n * @param {Object} props.canvas - Canvas data containing postType and postId\n * @return Canvas surface with editor\n */\nexport default function Canvas( { canvas }: CanvasProps ) {\n\tconst [ Editor, setEditor ] = useState< any >( null );\n\tconst navigate = useNavigate();\n\tconst { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord } =\n\t\tuseNavigateToEntityRecord();\n\tconst onActionPerformed = useActionPerformed( canvas.postType );\n\n\t/*\n\t * An entity can be asked to be edited at a particular width — a navigation\n\t * overlay meant for mobile — and carries the width it was left at when\n\t * returned to. Anything else opens at the default.\n\t */\n\tconst viewport = useSearch( {\n\t\tstrict: false,\n\t\tselect: ( search ) => ( search as { viewport?: string } ).viewport,\n\t} ) as string | undefined;\n\n\t/*\n\t * Where clicking a previewed canvas goes, resolved the same way the editor\n\t * resolves anywhere else it sends you to edit an entity, and whether it\n\t * should go anywhere at all: a trashed entity has to be restored before it\n\t * can be edited.\n\t *\n\t * The record is the one the editor loads for this canvas, so reading it\n\t * here costs no request of its own.\n\t */\n\t/*\n\t * A route that names no entity leaves the editor to resolve one, which it\n\t * does from the block templates only a block theme has. `undefined` while\n\t * the theme is still being read.\n\t */\n\tconst hasEntity = !! ( canvas.postType && canvas.postId );\n\tconst isBlockTheme = useSelect(\n\t\t( select ) =>\n\t\t\t(\n\t\t\t\tselect( coreStore ).getCurrentTheme() as\n\t\t\t\t\t| { is_block_theme?: boolean }\n\t\t\t\t\t| undefined\n\t\t\t )?.is_block_theme,\n\t\t[]\n\t);\n\n\tconst { editLink, isTrashed } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! canvas.postType || ! canvas.postId ) {\n\t\t\t\treturn { editLink: undefined, isTrashed: false };\n\t\t\t}\n\n\t\t\tconst record = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcanvas.postType,\n\t\t\t\tcanvas.postId\n\t\t\t) as { status?: string } | undefined;\n\n\t\t\treturn {\n\t\t\t\teditLink: select( bootStore ).getEntityLink(\n\t\t\t\t\tcanvas.postType,\n\t\t\t\t\tcanvas.postId\n\t\t\t\t),\n\t\t\t\tisTrashed: record?.status === 'trash',\n\t\t\t};\n\t\t},\n\t\t[ canvas.postType, canvas.postId ]\n\t);\n\n\t/*\n\t * Memoized because the editor provider pushes these settings into the store\n\t * whenever their identity changes, and the callbacks have to stay stable for\n\t * the block inspector to keep offering the same affordance.\n\t */\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\tisPreviewMode: canvas.isPreview,\n\t\t\tstyles: canvas.isPreview\n\t\t\t\t? [ { css: 'body{min-height:100vh;}' } ]\n\t\t\t\t: [],\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t} ),\n\t\t[\n\t\t\tcanvas.isPreview,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseEffect( () => {\n\t\t// Dynamically import the lazy-editor module\n\t\timport( '@wordpress/lazy-editor' )\n\t\t\t.then( ( module ) => {\n\t\t\t\tsetEditor( () => module.Editor );\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( 'Failed to load lazy editor:', error );\n\t\t\t} );\n\t}, [] );\n\n\t// Nothing for the editor to open, so show the site the route configures.\n\tif ( ! hasEntity && isBlockTheme === false ) {\n\t\treturn <SitePreview />;\n\t}\n\n\t// Show spinner while loading the editor module, and until it is known which\n\t// of the two this canvas is, so the wrong one is never shown first.\n\tif ( ! Editor || ( ! hasEntity && isBlockTheme === undefined ) ) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\talignItems: 'center',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\tpadding: '2rem',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Render back button in full-screen mode (when not preview)\n\t// Uses render prop pattern to receive fillProps from Slot\n\tconst backButton = ! canvas.isPreview\n\t\t? ( { length }: { length: number } ) => (\n\t\t\t\t<BootBackButton length={ length } />\n\t\t )\n\t\t: undefined;\n\n\t// Render the editor with canvas data\n\treturn (\n\t\t<div style={ { height: '100%', position: 'relative' } }>\n\t\t\t<div\n\t\t\t\tstyle={ { height: '100%' } }\n\t\t\t\t// @ts-expect-error inert not typed properly\n\t\t\t\tinert={ canvas.isPreview ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t<Editor\n\t\t\t\t\tpostType={ canvas.postType }\n\t\t\t\t\tpostId={ canvas.postId }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tbackButton={ backButton }\n\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\tinitialViewport={ getDeviceType( viewport ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{ canvas.isPreview && editLink && (\n\t\t\t\t<div\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tisTrashed\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: () => navigate( { to: editLink } )\n\t\t\t\t\t}\n\t\t\t\t\tonKeyDown={ ( e ) => {\n\t\t\t\t\t\tif ( isTrashed ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( e.key === 'Enter' || e.key === ' ' ) {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tnavigate( { to: editLink } );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\tinset: 0,\n\t\t\t\t\t\tcursor: isTrashed ? 'default' : 'pointer',\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t} }\n\t\t\t\t\trole=\"button\"\n\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\taria-disabled={ isTrashed }\n\t\t\t\t\taria-label={ __( 'Edit' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU,WAAW,eAAe;AAC7C,SAAS,eAAe;AACxB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,SAAS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AChB;AAAA,UACD;AACA,cAAK,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAM;AACzC,cAAE,eAAe;AACjB,qBAAU,EAAE,IAAI,SAAS,CAAE;AAAA,UAC5B;AAAA,QACD;AAAA,QACA,OAAQ;AAAA,UACP,UAAU;AAAA,UACV,OAAO;AAAA,UACP,QAAQ,YAAY,YAAY;AAAA,UAChC,QAAQ;AAAA,QACT;AAAA,QACA,MAAK;AAAA,QACL,UAAW;AAAA,QACX,iBAAgB;AAAA,QAChB,cAAa,GAAI,MAAO;AAAA;AAAA,IACzB;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/boot/src/components/canvas/site-preview.tsx
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { useSelect } from "@wordpress/data";
|
|
4
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
5
|
+
import { focus } from "@wordpress/dom";
|
|
6
|
+
import { addQueryArgs } from "@wordpress/url";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
function SitePreview() {
|
|
9
|
+
const siteUrl = useSelect((select) => {
|
|
10
|
+
const siteData = select(coreStore).getEntityRecord(
|
|
11
|
+
"root",
|
|
12
|
+
"__unstableBase"
|
|
13
|
+
);
|
|
14
|
+
return siteData?.home;
|
|
15
|
+
}, []);
|
|
16
|
+
if (typeof siteUrl !== "string" || !siteUrl) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
"iframe",
|
|
21
|
+
{
|
|
22
|
+
src: addQueryArgs(siteUrl, {
|
|
23
|
+
// Parameter for hiding the admin bar.
|
|
24
|
+
wp_site_preview: 1
|
|
25
|
+
}),
|
|
26
|
+
title: __("Site Preview"),
|
|
27
|
+
style: {
|
|
28
|
+
display: "block",
|
|
29
|
+
width: "100%",
|
|
30
|
+
height: "100%",
|
|
31
|
+
backgroundColor: "#fff"
|
|
32
|
+
},
|
|
33
|
+
onLoad: (event) => {
|
|
34
|
+
const iframeDocument = event.target.contentDocument;
|
|
35
|
+
if (!iframeDocument) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
focus.focusable.find(iframeDocument.documentElement).forEach((element) => {
|
|
39
|
+
element.style.pointerEvents = "none";
|
|
40
|
+
element.tabIndex = -1;
|
|
41
|
+
element.setAttribute("aria-hidden", "true");
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
SitePreview as default
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=site-preview.mjs.map
|