@expofp/renderer 3.32.0 → 3.33.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.
@@ -22,7 +22,19 @@ export function DebugPanelProvider(props) {
22
22
  // nothing here closes over the entries themselves.
23
23
  const panel = {
24
24
  set(key, value) {
25
- setEntries((prev) => key in prev && Object.is(prev[key], value) ? prev : { ...prev, [key]: value });
25
+ setEntries((prev) => {
26
+ // An existing key keeps the slot it already holds, because the spread writes it in place.
27
+ if (key in prev)
28
+ return Object.is(prev[key], value) ? prev : { ...prev, [key]: value };
29
+ // A key arrives for the first time, so rebuild the object in name order. Insertion order is
30
+ // what the readout prints, and a key that a publisher removes on unmount would otherwise
31
+ // come back at the bottom. `Object.fromEntries` needs Chrome 73, so build the object here.
32
+ const next = {};
33
+ for (const name of [...Object.keys(prev), key].sort()) {
34
+ next[name] = name === key ? value : prev[name];
35
+ }
36
+ return next;
37
+ });
26
38
  },
27
39
  remove(key) {
28
40
  setEntries((prev) => {
@@ -34,7 +34,13 @@ function PanelView(props) {
34
34
  const keys = Object.keys(value);
35
35
  valueToSerialize = keys.length === 1 ? value[keys[0]] : value;
36
36
  }
37
- return JSON.stringify(valueToSerialize, replacer, 2).replaceAll('"', '');
37
+ // `JSON.stringify` returns `undefined`, not a string, for a value that JSON cannot hold: the
38
+ // value `undefined` itself, or a function. The unwrap above exposes such a value, because a
39
+ // lone entry becomes the whole value. A wrapper of two entries hides it, because
40
+ // `JSON.stringify` drops the key. An empty string keeps the readout blank, so a publisher can
41
+ // push any value and the panel still renders.
42
+ const json = JSON.stringify(valueToSerialize, replacer, 2) ?? '';
43
+ return json.replaceAll('"', '');
38
44
  }
39
45
  return (_jsxs("div", { className: `${styles.container} ${styles[corner]}`, children: [_jsxs("button", { className: styles.toggle, onClick: () => setIsOpen((open) => !open), children: [isOpen ? 'Hide' : 'Show', " ", label] }), isOpen && _jsx("div", { className: styles.info, children: serialize() })] }));
40
46
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { type CameraAPI, type CameraAxes, type CameraState, type ControlsConfig, type InertiaConfig, type PanConfig, type RollConfig, type TransitionOptions, useCameraAPI, useCameraMoveStart, useCameraState, type ZoomToOptions, } from './controls';
2
2
  export { prepareDebug } from './debug/debug-chunk';
3
+ export { useDebugPanel } from './debug/debug-context';
3
4
  export * from './Renderer';
4
5
  export { type CameraProps, type SmoothTime } from './space/Camera';
5
6
  export { type CanvasPoint, type CanvasPointLike, type PlanPoint, type PlanPointLike, } from './space/Space';
package/dist/index.js CHANGED
@@ -4,6 +4,8 @@
4
4
  export { useCameraAPI, useCameraMoveStart, useCameraState, } from './controls';
5
5
  // The debug chunk's preload, for an external host that must create its context instrumented.
6
6
  export { prepareDebug } from './debug/debug-chunk';
7
+ // Publishing a host's own values into the debug panel.
8
+ export { useDebugPanel } from './debug/debug-context';
7
9
  export * from './Renderer';
8
10
  export { useViewport } from './space/viewport';
9
11
  export * from './types/defs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expofp/renderer",
3
- "version": "3.32.0",
3
+ "version": "3.33.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/expofp/efp-app.git",
@@ -42,7 +42,7 @@
42
42
  "troika-three-text": "^0.52.5",
43
43
  "tslib": "^2.3.0",
44
44
  "webgl-memory": "^1.1.3",
45
- "@expofp/geometry": "3.32.0"
45
+ "@expofp/geometry": "3.33.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@react-three/test-renderer": "^9.1.0",