@buffcore/admin-shell 0.8.45 → 0.8.46
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.
|
@@ -5,7 +5,8 @@ export declare function SceneSignal({ sceneKey, status }: {
|
|
|
5
5
|
status: Status;
|
|
6
6
|
}): null;
|
|
7
7
|
/** This sibling commits only when the view's Suspense/error boundary commits its content. */
|
|
8
|
-
export declare function ReadySignal({ sceneKey }: {
|
|
8
|
+
export declare function ReadySignal({ sceneKey, search }: {
|
|
9
9
|
sceneKey: string;
|
|
10
|
+
search: string;
|
|
10
11
|
}): import("react").JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SCENE_LOOK_ATTR, SCENE_LOOK_REUSABLE } from '@buffcore/contracts/prototype';
|
|
2
3
|
import { useEffect, useLayoutEffect, useReducer, useRef } from 'react';
|
|
3
4
|
import { SCENE_STATUS } from './scene-status.js';
|
|
4
5
|
const report = (sceneKey, status) => window.parent.postMessage({ type: SCENE_STATUS, key: sceneKey, status }, '*');
|
|
@@ -42,6 +43,16 @@ export function SceneSignal({ sceneKey, status }) {
|
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
45
|
/** This sibling commits only when the view's Suspense/error boundary commits its content. */
|
|
45
|
-
export function ReadySignal({ sceneKey }) {
|
|
46
|
+
export function ReadySignal({ sceneKey, search }) {
|
|
47
|
+
useLayoutEffect(() => {
|
|
48
|
+
const html = document.documentElement;
|
|
49
|
+
html.setAttribute(SCENE_LOOK_ATTR, search);
|
|
50
|
+
// Any view can move in place: the snapshot checks each scene against a fresh load.
|
|
51
|
+
html.setAttribute(SCENE_LOOK_REUSABLE, '');
|
|
52
|
+
return () => {
|
|
53
|
+
html.removeAttribute(SCENE_LOOK_ATTR);
|
|
54
|
+
html.removeAttribute(SCENE_LOOK_REUSABLE);
|
|
55
|
+
};
|
|
56
|
+
}, [search]);
|
|
46
57
|
return _jsx(SceneSignal, { sceneKey: sceneKey, status: "ready" });
|
|
47
58
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const SCENE_STATUS = "buffcore:prototype-scene";
|
|
1
|
+
export { SCENE_STATUS } from '@buffcore/contracts/prototype';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const SCENE_STATUS = 'buffcore:prototype-scene';
|
|
1
|
+
export { SCENE_STATUS } from '@buffcore/contracts/prototype';
|
|
@@ -13,4 +13,4 @@ export interface AdminSceneProps {
|
|
|
13
13
|
/** The page's query: `?key&theme&mode&locale`. */
|
|
14
14
|
search: string;
|
|
15
15
|
}
|
|
16
|
-
export declare function AdminScene(
|
|
16
|
+
export declare function AdminScene(props: AdminSceneProps): import("react").JSX.Element;
|
package/dist/prototype/scene.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
1
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
// One admin scene at /_scene?key&theme&mode&locale: only its view, with its sample props, in the
|
|
3
4
|
// asked theme, mode and language. No sign-in and no API calls: the view gets everything as props.
|
|
5
|
+
import { SCENE_LOOK_CHANGE } from '@buffcore/contracts/prototype';
|
|
4
6
|
import { createI18n } from '@buffcore/i18n';
|
|
5
7
|
import { I18nProvider, useT } from '@buffcore/i18n/react';
|
|
6
|
-
import { useMemo } from 'react';
|
|
8
|
+
import { useLayoutEffect, useMemo, useState } from 'react';
|
|
7
9
|
import { EmptyState } from '../components/states.js';
|
|
8
10
|
import { PageLook } from './PageLook.js';
|
|
9
11
|
import { SceneBoundary } from './SceneBoundary.js';
|
|
@@ -12,7 +14,22 @@ function Missing({ sceneKey }) {
|
|
|
12
14
|
const t = useT();
|
|
13
15
|
return _jsx(EmptyState, { icon: "circle-help", title: t('admin.prototype.missing', { key: sceneKey }) });
|
|
14
16
|
}
|
|
15
|
-
export function AdminScene(
|
|
17
|
+
export function AdminScene(props) {
|
|
18
|
+
const [moved, setMoved] = useState();
|
|
19
|
+
useLayoutEffect(() => {
|
|
20
|
+
const read = () => {
|
|
21
|
+
window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
|
|
22
|
+
setMoved(window.location.search);
|
|
23
|
+
};
|
|
24
|
+
window.addEventListener(SCENE_LOOK_CHANGE, read);
|
|
25
|
+
return () => window.removeEventListener(SCENE_LOOK_CHANGE, read);
|
|
26
|
+
}, []);
|
|
27
|
+
// Only a move in place draws the look afresh, as a full load would. The router's own changes keep
|
|
28
|
+
// the page mounted and remount the view when the scene changes: remounting the whole look there
|
|
29
|
+
// made every scene the studio or a check steps through about 80 ms slower.
|
|
30
|
+
return _createElement(SceneLook, { ...props, key: moved, search: moved ?? props.search });
|
|
31
|
+
}
|
|
32
|
+
function SceneLook({ scenes, views, theme, themes, catalogs, search }) {
|
|
16
33
|
const params = new URLSearchParams(search);
|
|
17
34
|
const key = params.get('key') ?? '';
|
|
18
35
|
const locale = params.get('locale') ?? 'en';
|
|
@@ -20,5 +37,5 @@ export function AdminScene({ scenes, views, theme, themes, catalogs, search }) {
|
|
|
20
37
|
const look = themes.find((th) => th.key === params.get('theme')) ?? theme;
|
|
21
38
|
const scene = scenes.find((s) => s.surface === 'admin' && s.key === key);
|
|
22
39
|
const View = scene && views[scene.view];
|
|
23
|
-
return (_jsx(I18nProvider, { translator: translator, children: _jsx(PageLook, { theme: look, mode: params.get('mode') ?? undefined, locale: locale, children: _jsx("div", { style: { height: '100dvh' }, children: scene && View ? (_jsxs(SceneBoundary, { sceneKey: key, children: [_jsx(View, { ...scene.props }), _jsx(ReadySignal, { sceneKey: key })] }, key)) : (_jsxs(_Fragment, { children: [_jsx(Missing, { sceneKey: key }), _jsx(SceneSignal, { sceneKey: key, status: "missing" })] })) }) }) }));
|
|
40
|
+
return (_jsx(I18nProvider, { translator: translator, children: _jsx(PageLook, { theme: look, mode: params.get('mode') ?? undefined, locale: locale, children: _jsx("div", { style: { height: '100dvh' }, children: scene && View ? (_jsxs(SceneBoundary, { sceneKey: key, children: [_jsx(View, { ...scene.props }), _jsx(ReadySignal, { sceneKey: key, search: search })] }, key)) : (_jsxs(_Fragment, { children: [_jsx(Missing, { sceneKey: key }), _jsx(SceneSignal, { sceneKey: key, status: "missing" })] })) }) }) }));
|
|
24
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buffcore/admin-shell",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.46",
|
|
4
4
|
"description": "The React DOM admin console for a BuffCore product, with its prototype viewer.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "BuffApe",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"@tanstack/react-router": "1.170.42",
|
|
38
38
|
"firebase": "12.19.0",
|
|
39
39
|
"qrcode": "1.5.4",
|
|
40
|
-
"@buffcore/
|
|
41
|
-
"@buffcore/
|
|
42
|
-
"@buffcore/
|
|
43
|
-
"@buffcore/
|
|
44
|
-
"@buffcore/
|
|
40
|
+
"@buffcore/config": "0.8.46",
|
|
41
|
+
"@buffcore/tokens": "0.8.46",
|
|
42
|
+
"@buffcore/sdk": "0.8.46",
|
|
43
|
+
"@buffcore/i18n": "0.8.46",
|
|
44
|
+
"@buffcore/contracts": "0.8.46"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=19",
|