@wildo-ai/presets-components-3d 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/esm/focal-plane/focal-plane-depth-axis.d.ts +17 -0
  2. package/dist/esm/focal-plane/focal-plane-depth-axis.d.ts.map +1 -0
  3. package/dist/esm/focal-plane/focal-plane-depth-axis.js +59 -0
  4. package/dist/esm/focal-plane/focal-plane-depth-axis.js.map +1 -0
  5. package/dist/esm/focal-plane/focal-plane-settings.d.ts.map +1 -1
  6. package/dist/esm/focal-plane/focal-plane-settings.js.map +1 -1
  7. package/dist/esm/focal-plane/focal-plane-shell-container.d.ts.map +1 -1
  8. package/dist/esm/focal-plane/focal-plane-shell-container.js +10 -119
  9. package/dist/esm/focal-plane/focal-plane-shell-container.js.map +1 -1
  10. package/dist/esm/focal-plane/focal-plane-stylesheet.d.ts +2 -9
  11. package/dist/esm/focal-plane/focal-plane-stylesheet.d.ts.map +1 -1
  12. package/dist/esm/focal-plane/focal-plane-stylesheet.js +41 -80
  13. package/dist/esm/focal-plane/focal-plane-stylesheet.js.map +1 -1
  14. package/dist/esm/focal-plane/focal-plane-vanishing-point.d.ts +27 -0
  15. package/dist/esm/focal-plane/focal-plane-vanishing-point.d.ts.map +1 -0
  16. package/dist/esm/focal-plane/focal-plane-vanishing-point.js +21 -0
  17. package/dist/esm/focal-plane/focal-plane-vanishing-point.js.map +1 -0
  18. package/dist/esm/frame/frame-3d-style.d.ts +24 -4
  19. package/dist/esm/frame/frame-3d-style.d.ts.map +1 -1
  20. package/dist/esm/frame/frame-3d-style.js +86 -6
  21. package/dist/esm/frame/frame-3d-style.js.map +1 -1
  22. package/dist/esm/frame/frame-appearance.js.map +1 -1
  23. package/dist/esm/frame/frame-canvas.js.map +1 -1
  24. package/dist/esm/frame/frame-canvas.lazy.js.map +1 -1
  25. package/dist/esm/frame/frame-color.d.ts.map +1 -1
  26. package/dist/esm/frame/frame-color.js.map +1 -1
  27. package/dist/esm/frame/frame-driver.js.map +1 -1
  28. package/dist/esm/frame/frame-renderer.js.map +1 -1
  29. package/dist/esm/frame/frame-shaders.d.ts.map +1 -1
  30. package/dist/esm/frame/frame-shaders.js.map +1 -1
  31. package/dist/esm/frame/use-frame-appearance.d.ts +1 -1
  32. package/dist/esm/frame/use-frame-appearance.js +3 -3
  33. package/dist/esm/frame/use-frame-appearance.js.map +1 -1
  34. package/dist/esm/index.d.ts +0 -1
  35. package/dist/esm/index.d.ts.map +1 -1
  36. package/dist/esm/index.js +0 -1
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/layout/header-first-shell-container.js.map +1 -1
  39. package/dist/esm/layout/layout-3d-definition.d.ts +5 -7
  40. package/dist/esm/layout/layout-3d-definition.d.ts.map +1 -1
  41. package/dist/esm/layout/layout-3d-definition.js +1 -1
  42. package/dist/esm/layout/layout-3d-definition.js.map +1 -1
  43. package/dist/esm/layout/layout-3d-transition-choreography.d.ts.map +1 -1
  44. package/dist/esm/layout/layout-3d-transition-choreography.js.map +1 -1
  45. package/dist/esm/layout/layout-3d-vocabulary.d.ts.map +1 -1
  46. package/dist/esm/layout/layout-3d-vocabulary.js.map +1 -1
  47. package/dist/esm/layout-3d-main-container.d.ts +13 -18
  48. package/dist/esm/layout-3d-main-container.d.ts.map +1 -1
  49. package/dist/esm/layout-3d-main-container.js +7 -15
  50. package/dist/esm/layout-3d-main-container.js.map +1 -1
  51. package/dist/esm/register-3d-layout.d.ts +8 -4
  52. package/dist/esm/register-3d-layout.d.ts.map +1 -1
  53. package/dist/esm/register-3d-layout.js +16 -36
  54. package/dist/esm/register-3d-layout.js.map +1 -1
  55. package/dist/esm/shell-region-measurement.js.map +1 -1
  56. package/dist/esm/tokens/design-token-resolution.js.map +1 -1
  57. package/dist/esm/tokens/use-design-token-resolution.js.map +1 -1
  58. package/dist/tsconfig.build.tsbuildinfo +1 -1
  59. package/package.json +8 -6
  60. package/dist/esm/focal-plane/use-pane-depth.d.ts +0 -20
  61. package/dist/esm/focal-plane/use-pane-depth.d.ts.map +0 -1
  62. package/dist/esm/focal-plane/use-pane-depth.js +0 -162
  63. package/dist/esm/focal-plane/use-pane-depth.js.map +0 -1
  64. package/dist/esm/focal-plane/use-shared-vanishing-point.d.ts +0 -35
  65. package/dist/esm/focal-plane/use-shared-vanishing-point.d.ts.map +0 -1
  66. package/dist/esm/focal-plane/use-shared-vanishing-point.js +0 -86
  67. package/dist/esm/focal-plane/use-shared-vanishing-point.js.map +0 -1
  68. package/dist/esm/layout/shell-layout-placement.d.ts +0 -26
  69. package/dist/esm/layout/shell-layout-placement.d.ts.map +0 -1
  70. package/dist/esm/layout/shell-layout-placement.js +0 -18
  71. package/dist/esm/layout/shell-layout-placement.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildo-ai/presets-components-3d",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "Optional 3D layouts for the Wildo AI application shell: its regions, unchanged HTML, arranged by a 3D layout over a decorative WebGL frame",
6
6
  "author": "Wildo AI",
@@ -29,8 +29,8 @@
29
29
  "test:watch": "vitest"
30
30
  },
31
31
  "dependencies": {
32
- "@wildo-ai/presets-components-models": "1.1.10",
33
- "@wildo-ai/saas-frontend-lib": "1.1.10",
32
+ "@wildo-ai/presets-components-models": "1.1.12",
33
+ "@wildo-ai/saas-frontend-lib": "1.1.12",
34
34
  "culori": "^4.0.2"
35
35
  },
36
36
  "peerDependencies": {
@@ -41,17 +41,19 @@
41
41
  "devDependencies": {
42
42
  "@react-three/fiber": "9.8.1",
43
43
  "@testing-library/react": "^16.0.0",
44
+ "@types/node": "^24.0.15",
44
45
  "@types/react": "^19.0.0",
45
46
  "@types/three": "0.186.0",
46
- "@vitejs/plugin-react": "^4.5.1",
47
+ "@vitejs/plugin-react": "^6.1.2",
47
48
  "jsdom": "^24.0.0",
48
49
  "react": "^19.0.0",
49
50
  "react-dom": "^19.0.0",
50
- "rimraf": "^6.0.1",
51
+ "rimraf": "^6.1.4",
51
52
  "three": "0.186.1",
52
53
  "tsc-watch": "7.2.1",
53
54
  "typescript": "5.9.3",
54
- "vitest": "^1.6.1"
55
+ "vite": "^8.3.6",
56
+ "vitest": "^4.1.12"
55
57
  },
56
58
  "repository": {
57
59
  "type": "git",
@@ -1,20 +0,0 @@
1
- import { type RefObject } from 'react';
2
- import type { FocalPlaneSettings } from './focal-plane-settings';
3
- /**
4
- * What the stylesheet cannot do alone, because the engine unmounts or hides a pane at once (#2049 step 2):
5
- *
6
- * - **Discard.** A side pane dismissed by its close control is removed from the DOM immediately. The removed node,
7
- * no longer React's, is re-parented into a ghost layer at the box it last had, and flies away into depth and fades.
8
- * - **Expand.** An emphasized side pane takes the width, and the engine HIDES the other panes (`hidden`). A still,
9
- * inert image of each hidden pane is left behind, stepped back, visible through the expanded pane's glass. It is a
10
- * picture, not a control: stepped back, it shrinks inside the expanded pane's outline, which covers it, so a click
11
- * could never reach it (an earlier version offered one; a live probe found it unreachable). Returning to side by
12
- * side is the pane's own restore control, or Escape. The image travels forward and goes as the emphasis ends.
13
- * - **Swap.** A pane whose content changes in place dips back and returns (`dip`).
14
- *
15
- * Ghosts are aria-hidden and inert: they are pictures of panes, never a second copy anyone can use.
16
- */
17
- export declare function usePaneDepth(rootRef: RefObject<HTMLElement | null>, settings: FocalPlaneSettings, reducedMotion: boolean): {
18
- dip: (zone: string) => void;
19
- };
20
- //# sourceMappingURL=use-pane-depth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-pane-depth.d.ts","sourceRoot":"","sources":["../../../src/focal-plane/use-pane-depth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAM3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACtC,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,OAAO,GACrB;IAAE,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAqHjC"}
@@ -1,162 +0,0 @@
1
- import { useEffect, useLayoutEffect, useRef } from 'react';
2
- import { ShellRegion } from '@wildo-ai/presets-components-models';
3
- import { NavigationZone } from '@wildo-ai/saas-frontend-lib';
4
- import { FOCAL_PLANE_PANE_SELECTOR } from './focal-plane-stylesheet.js';
5
- import { lastStageRects, VANISHING_POINT } from './use-shared-vanishing-point.js';
6
- /**
7
- * What the stylesheet cannot do alone, because the engine unmounts or hides a pane at once (#2049 step 2):
8
- *
9
- * - **Discard.** A side pane dismissed by its close control is removed from the DOM immediately. The removed node,
10
- * no longer React's, is re-parented into a ghost layer at the box it last had, and flies away into depth and fades.
11
- * - **Expand.** An emphasized side pane takes the width, and the engine HIDES the other panes (`hidden`). A still,
12
- * inert image of each hidden pane is left behind, stepped back, visible through the expanded pane's glass. It is a
13
- * picture, not a control: stepped back, it shrinks inside the expanded pane's outline, which covers it, so a click
14
- * could never reach it (an earlier version offered one; a live probe found it unreachable). Returning to side by
15
- * side is the pane's own restore control, or Escape. The image travels forward and goes as the emphasis ends.
16
- * - **Swap.** A pane whose content changes in place dips back and returns (`dip`).
17
- *
18
- * Ghosts are aria-hidden and inert: they are pictures of panes, never a second copy anyone can use.
19
- */
20
- export function usePaneDepth(rootRef, settings, reducedMotion) {
21
- useLayoutEffect(() => {
22
- const root = rootRef.current;
23
- if (!root)
24
- return undefined;
25
- const back = root.querySelector('.fp-ghosts:not(.fp-ghosts-front)');
26
- const front = root.querySelector('.fp-ghosts-front');
27
- if (!back || !front)
28
- return undefined;
29
- const behind = new Map();
30
- const motion = reducedMotion ? 0 : settings.motionMs;
31
- const place = (ghost, rect) => {
32
- const vx = root.clientWidth * VANISHING_POINT.x;
33
- const vy = root.clientHeight * VANISHING_POINT.y;
34
- Object.assign(ghost.style, { left: `${rect.left}px`, top: `${rect.top}px`, width: `${rect.width}px`, height: `${rect.height}px` });
35
- ghost.style.setProperty('--fp-ox', `${vx - rect.left}px`);
36
- ghost.style.setProperty('--fp-oy', `${vy - rect.top}px`);
37
- };
38
- const inertCopy = (node) => {
39
- const copy = node.cloneNode(true);
40
- sanitise(copy);
41
- return copy;
42
- };
43
- const discard = (node) => {
44
- const rect = lastStageRects.get(node);
45
- // Moved rather than removed (taken out and put back in one batch): it is still on screen, not discarded.
46
- if (!rect || motion === 0 || node.isConnected)
47
- return;
48
- const ghost = document.createElement('div');
49
- ghost.className = 'fp-ghost';
50
- sanitise(node);
51
- ghost.appendChild(node);
52
- place(ghost, rect);
53
- front.appendChild(ghost);
54
- requestAnimationFrame(() => requestAnimationFrame(() => {
55
- ghost.style.setProperty('--fp-z', `${-settings.layerDepthPx * 1.5}px`);
56
- ghost.style.opacity = '0';
57
- }));
58
- setTimeout(() => ghost.remove(), motion + 60);
59
- };
60
- const syncBehind = () => {
61
- const emphasized = root.querySelector('[data-zone-emphasized]');
62
- const hidden = emphasized ? [...root.querySelectorAll(FOCAL_PLANE_PANE_SELECTOR)].filter((pane) => pane.hasAttribute('data-zone-hidden')) : [];
63
- for (const [pane, ghost] of behind) {
64
- if (hidden.includes(pane))
65
- continue;
66
- behind.delete(pane);
67
- ghost.style.setProperty('--fp-z', '0px');
68
- ghost.style.opacity = '0';
69
- setTimeout(() => ghost.remove(), motion);
70
- }
71
- for (const pane of hidden) {
72
- if (behind.has(pane))
73
- continue;
74
- const rect = lastStageRects.get(pane);
75
- if (!rect)
76
- continue;
77
- const ghost = document.createElement('div');
78
- ghost.className = 'fp-ghost fp-ghost-behind';
79
- const copy = inertCopy(pane);
80
- copy.classList.remove('hidden');
81
- copy.removeAttribute('data-zone-hidden');
82
- copy.style.width = '100%';
83
- copy.style.height = '100%';
84
- ghost.appendChild(copy);
85
- place(ghost, rect);
86
- ghost.style.opacity = '0';
87
- back.appendChild(ghost);
88
- behind.set(pane, ghost);
89
- requestAnimationFrame(() => requestAnimationFrame(() => {
90
- ghost.style.setProperty('--fp-z', `${-settings.layerDepthPx}px`);
91
- ghost.style.setProperty('--fp-filter', `brightness(${1 - settings.recedeDim}) saturate(${1 - settings.recedeDim * 0.9})`);
92
- ghost.style.opacity = '1';
93
- }));
94
- }
95
- };
96
- const observer = new MutationObserver((records) => {
97
- let emphasisMayHaveChanged = false;
98
- for (const record of records) {
99
- if (record.type === 'attributes') {
100
- emphasisMayHaveChanged = true;
101
- continue;
102
- }
103
- for (const node of record.removedNodes) {
104
- if (!(node instanceof HTMLElement))
105
- continue;
106
- // A detached node matches no selector that names its ancestors, so the pane is recognised by the box the
107
- // stage last measured for it: only objects (a zone, or a resizable panel) have one.
108
- // Only a SIDE pane is ever dismissed. The primary pane leaves only when the content remounts (a breakpoint
109
- // flip to the single-zone branch), which is not a discard and must not fly a ghost away.
110
- if (lastStageRects.has(node) && isSidePane(node))
111
- discard(node);
112
- }
113
- emphasisMayHaveChanged = true;
114
- }
115
- if (emphasisMayHaveChanged)
116
- syncBehind();
117
- });
118
- const content = root.querySelector(`[data-component-area="${ShellRegion.CONTENT}"]`) ?? root;
119
- observer.observe(content, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-zone-hidden', 'data-zone-emphasized'] });
120
- syncBehind();
121
- return () => {
122
- observer.disconnect();
123
- for (const ghost of behind.values())
124
- ghost.remove();
125
- };
126
- }, [rootRef, settings, reducedMotion]);
127
- const dipRef = useRef(() => undefined);
128
- useEffect(() => {
129
- dipRef.current = (zone) => {
130
- const root = rootRef.current;
131
- if (!root || reducedMotion)
132
- return;
133
- const pane = root.querySelector(`[data-component-area="${ShellRegion.CONTENT}"] :is([data-content-area="${zone}"]:not([data-panel-id] *), [data-panel-id="nav-${zone}"])`);
134
- if (!pane || typeof pane.animate !== 'function')
135
- return;
136
- // Implicit first and last keyframes: the pane dips from, and returns to, whatever depth it rests at.
137
- pane.animate([{ offset: 0.45, transform: `perspective(${settings.cameraDistancePx}px) translate3d(0, 0, ${-settings.layerDepthPx * 0.5}px)`, opacity: 0.55 }], { duration: settings.motionMs, easing: 'cubic-bezier(0.2, 0.9, 0.25, 1)' });
138
- };
139
- }, [rootRef, settings, reducedMotion]);
140
- return { dip: (zone) => dipRef.current(zone) };
141
- }
142
- const SIDE_ZONES = new Set([NavigationZone.SECONDARY, NavigationZone.COMPANION]);
143
- function isSidePane(element) {
144
- const zone = element.dataset.contentArea ?? element.dataset.panelId?.replace(/^nav-/, '');
145
- return zone !== undefined && SIDE_ZONES.has(zone);
146
- }
147
- /**
148
- * Makes a pane a picture: no ids, no focus, invisible to assistive technology, and none of the markers a query for the
149
- * REAL pane would find (a document-level lookup of the primary pane must never return its image). Embedded frames and
150
- * media are dropped rather than loaded a second time.
151
- */
152
- function sanitise(element) {
153
- element.setAttribute('aria-hidden', 'true');
154
- element.setAttribute('inert', '');
155
- for (const node of [element, ...element.querySelectorAll('*')]) {
156
- for (const attribute of ['id', 'data-content-area', 'data-panel-id', 'data-zone-hidden', 'data-zone-emphasized', 'data-component-area'])
157
- node.removeAttribute(attribute);
158
- }
159
- for (const media of element.querySelectorAll('iframe, video, audio'))
160
- media.remove();
161
- }
162
- //# sourceMappingURL=use-pane-depth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-pane-depth.js","sourceRoot":"","sources":["../../../../src/focal-plane/use-pane-depth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAkB,MAAM,8BAA8B,CAAC;AAE/F;;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E,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,qBAAqB,CAAC;YAAE,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3K,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,gBAAgB,CAAC,sBAAsB,CAAC;QAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AACvF,CAAC","sourcesContent":["import { useEffect, useLayoutEffect, useRef, type RefObject } from 'react';\n\nimport { ShellRegion } from '@wildo-ai/presets-components-models';\nimport { NavigationZone } from '@wildo-ai/saas-frontend-lib';\n\nimport { FOCAL_PLANE_PANE_SELECTOR } from './focal-plane-stylesheet';\nimport type { FocalPlaneSettings } from './focal-plane-settings';\nimport { lastStageRects, VANISHING_POINT, type StageRect } from './use-shared-vanishing-point';\n\n/**\n * What the stylesheet cannot do alone, because the engine unmounts or hides a pane at once (#2049 step 2):\n *\n * - **Discard.** A side pane dismissed by its close control is removed from the DOM immediately. The removed node,\n * no longer React's, is re-parented into a ghost layer at the box it last had, and flies away into depth and fades.\n * - **Expand.** An emphasized side pane takes the width, and the engine HIDES the other panes (`hidden`). A still,\n * inert image of each hidden pane is left behind, stepped back, visible through the expanded pane's glass. It is a\n * picture, not a control: stepped back, it shrinks inside the expanded pane's outline, which covers it, so a click\n * could never reach it (an earlier version offered one; a live probe found it unreachable). Returning to side by\n * side is the pane's own restore control, or Escape. The image travels forward and goes as the emphasis ends.\n * - **Swap.** A pane whose content changes in place dips back and returns (`dip`).\n *\n * Ghosts are aria-hidden and inert: they are pictures of panes, never a second copy anyone can use.\n */\nexport function usePaneDepth(\n rootRef: RefObject<HTMLElement | null>,\n settings: FocalPlaneSettings,\n reducedMotion: boolean,\n): { dip: (zone: string) => void } {\n useLayoutEffect(() => {\n const root = rootRef.current;\n if (!root) return undefined;\n const back = root.querySelector<HTMLElement>('.fp-ghosts:not(.fp-ghosts-front)');\n const front = root.querySelector<HTMLElement>('.fp-ghosts-front');\n if (!back || !front) return undefined;\n const behind = new Map<Element, HTMLElement>();\n const motion = reducedMotion ? 0 : settings.motionMs;\n\n const place = (ghost: HTMLElement, rect: StageRect): void => {\n const vx = root.clientWidth * VANISHING_POINT.x;\n const vy = root.clientHeight * VANISHING_POINT.y;\n Object.assign(ghost.style, { left: `${rect.left}px`, top: `${rect.top}px`, width: `${rect.width}px`, height: `${rect.height}px` });\n ghost.style.setProperty('--fp-ox', `${vx - rect.left}px`);\n ghost.style.setProperty('--fp-oy', `${vy - rect.top}px`);\n };\n const inertCopy = (node: Element): HTMLElement => {\n const copy = node.cloneNode(true) as HTMLElement;\n sanitise(copy);\n return copy;\n };\n\n const discard = (node: HTMLElement): void => {\n const rect = lastStageRects.get(node);\n // Moved rather than removed (taken out and put back in one batch): it is still on screen, not discarded.\n if (!rect || motion === 0 || node.isConnected) return;\n const ghost = document.createElement('div');\n ghost.className = 'fp-ghost';\n sanitise(node);\n ghost.appendChild(node);\n place(ghost, rect);\n front.appendChild(ghost);\n requestAnimationFrame(() => requestAnimationFrame(() => {\n ghost.style.setProperty('--fp-z', `${-settings.layerDepthPx * 1.5}px`);\n ghost.style.opacity = '0';\n }));\n setTimeout(() => ghost.remove(), motion + 60);\n };\n\n const syncBehind = (): void => {\n const emphasized = root.querySelector('[data-zone-emphasized]');\n const hidden = emphasized ? [...root.querySelectorAll<HTMLElement>(FOCAL_PLANE_PANE_SELECTOR)].filter((pane) => pane.hasAttribute('data-zone-hidden')) : [];\n for (const [pane, ghost] of behind) {\n if (hidden.includes(pane as HTMLElement)) continue;\n behind.delete(pane);\n ghost.style.setProperty('--fp-z', '0px');\n ghost.style.opacity = '0';\n setTimeout(() => ghost.remove(), motion);\n }\n for (const pane of hidden) {\n if (behind.has(pane)) continue;\n const rect = lastStageRects.get(pane);\n if (!rect) continue;\n const ghost = document.createElement('div');\n ghost.className = 'fp-ghost fp-ghost-behind';\n const copy = inertCopy(pane);\n copy.classList.remove('hidden');\n copy.removeAttribute('data-zone-hidden');\n copy.style.width = '100%';\n copy.style.height = '100%';\n ghost.appendChild(copy);\n place(ghost, rect);\n ghost.style.opacity = '0';\n back.appendChild(ghost);\n behind.set(pane, ghost);\n requestAnimationFrame(() => requestAnimationFrame(() => {\n ghost.style.setProperty('--fp-z', `${-settings.layerDepthPx}px`);\n ghost.style.setProperty('--fp-filter', `brightness(${1 - settings.recedeDim}) saturate(${1 - settings.recedeDim * 0.9})`);\n ghost.style.opacity = '1';\n }));\n }\n };\n\n const observer = new MutationObserver((records) => {\n let emphasisMayHaveChanged = false;\n for (const record of records) {\n if (record.type === 'attributes') {\n emphasisMayHaveChanged = true;\n continue;\n }\n for (const node of record.removedNodes) {\n if (!(node instanceof HTMLElement)) continue;\n // A detached node matches no selector that names its ancestors, so the pane is recognised by the box the\n // stage last measured for it: only objects (a zone, or a resizable panel) have one.\n // Only a SIDE pane is ever dismissed. The primary pane leaves only when the content remounts (a breakpoint\n // flip to the single-zone branch), which is not a discard and must not fly a ghost away.\n if (lastStageRects.has(node) && isSidePane(node)) discard(node);\n }\n emphasisMayHaveChanged = true;\n }\n if (emphasisMayHaveChanged) syncBehind();\n });\n const content = root.querySelector(`[data-component-area=\"${ShellRegion.CONTENT}\"]`) ?? root;\n observer.observe(content, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-zone-hidden', 'data-zone-emphasized'] });\n syncBehind();\n return () => {\n observer.disconnect();\n for (const ghost of behind.values()) ghost.remove();\n };\n }, [rootRef, settings, reducedMotion]);\n\n const dipRef = useRef<(zone: string) => void>(() => undefined);\n useEffect(() => {\n dipRef.current = (zone: string): void => {\n const root = rootRef.current;\n if (!root || reducedMotion) return;\n const pane = root.querySelector<HTMLElement>(`[data-component-area=\"${ShellRegion.CONTENT}\"] :is([data-content-area=\"${zone}\"]:not([data-panel-id] *), [data-panel-id=\"nav-${zone}\"])`);\n if (!pane || typeof pane.animate !== 'function') return;\n // Implicit first and last keyframes: the pane dips from, and returns to, whatever depth it rests at.\n pane.animate(\n [{ offset: 0.45, transform: `perspective(${settings.cameraDistancePx}px) translate3d(0, 0, ${-settings.layerDepthPx * 0.5}px)`, opacity: 0.55 }],\n { duration: settings.motionMs, easing: 'cubic-bezier(0.2, 0.9, 0.25, 1)' },\n );\n };\n }, [rootRef, settings, reducedMotion]);\n return { dip: (zone) => dipRef.current(zone) };\n}\n\nconst SIDE_ZONES: ReadonlySet<string> = new Set([NavigationZone.SECONDARY, NavigationZone.COMPANION]);\nfunction isSidePane(element: HTMLElement): boolean {\n const zone = element.dataset.contentArea ?? element.dataset.panelId?.replace(/^nav-/, '');\n return zone !== undefined && SIDE_ZONES.has(zone);\n}\n\n/**\n * Makes a pane a picture: no ids, no focus, invisible to assistive technology, and none of the markers a query for the\n * REAL pane would find (a document-level lookup of the primary pane must never return its image). Embedded frames and\n * media are dropped rather than loaded a second time.\n */\nfunction sanitise(element: HTMLElement): void {\n element.setAttribute('aria-hidden', 'true');\n element.setAttribute('inert', '');\n for (const node of [element, ...element.querySelectorAll<HTMLElement>('*')]) {\n for (const attribute of ['id', 'data-content-area', 'data-panel-id', 'data-zone-hidden', 'data-zone-emphasized', 'data-component-area']) node.removeAttribute(attribute);\n }\n for (const media of element.querySelectorAll('iframe, video, audio')) media.remove();\n}\n"]}
@@ -1,35 +0,0 @@
1
- import { type RefObject } from 'react';
2
- /** Where the vanishing point sits in the stage: centred, a little above the middle (the eye line of the prototype). */
3
- export declare const VANISHING_POINT: {
4
- x: number;
5
- y: number;
6
- };
7
- /** An object's laid-out box in the stage (untransformed), as last measured. */
8
- export interface StageRect {
9
- left: number;
10
- top: number;
11
- width: number;
12
- height: number;
13
- }
14
- /**
15
- * The last laid-out box of every object, kept so a pane that has just been REMOVED or HIDDEN can still be drawn where
16
- * it was (its ghost flies into depth from there). A zero-size reading never replaces a real one: a hidden pane measures
17
- * as nothing, and its last visible box is the one that matters.
18
- */
19
- export declare const lastStageRects: WeakMap<Element, StageRect>;
20
- /**
21
- * Keeps every object's `transform-origin` on the stage's ONE vanishing point, so objects that each carry their own
22
- * `perspective()` are seen through a single still camera (see `focal-plane-stylesheet.ts`).
23
- *
24
- * The origin is written as two custom properties on each object (`--fp-ox`, `--fp-oy`): the vanishing point minus the
25
- * object's own offset in the stage. Offsets are read from `offsetLeft`/`offsetTop`, which ignore transforms, so an object
26
- * that is currently stepped back still reports where it is laid out. Custom properties written this way are left alone
27
- * by React, which only manages the style properties it set itself.
28
- */
29
- export declare function useSharedVanishingPoint(rootRef: RefObject<HTMLElement | null>): void;
30
- /** An element's layout offset inside `root`, walking the offset-parent chain (transforms are not part of it). */
31
- export declare function offsetWithin(element: HTMLElement, root: HTMLElement): {
32
- left: number;
33
- top: number;
34
- };
35
- //# sourceMappingURL=use-shared-vanishing-point.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-shared-vanishing-point.d.ts","sourceRoot":"","sources":["../../../src/focal-plane/use-shared-vanishing-point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIxD,uHAAuH;AACvH,eAAO,MAAM,eAAe;;;CAAsB,CAAC;AAEnD,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,6BAAoC,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAuCpF;AAED,iHAAiH;AACjH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAYnG"}
@@ -1,86 +0,0 @@
1
- import { useLayoutEffect } from 'react';
2
- import { FOCAL_PLANE_PANE_SELECTOR } from './focal-plane-stylesheet.js';
3
- /** Where the vanishing point sits in the stage: centred, a little above the middle (the eye line of the prototype). */
4
- export const VANISHING_POINT = { x: 0.5, y: 0.42 };
5
- /**
6
- * The last laid-out box of every object, kept so a pane that has just been REMOVED or HIDDEN can still be drawn where
7
- * it was (its ghost flies into depth from there). A zero-size reading never replaces a real one: a hidden pane measures
8
- * as nothing, and its last visible box is the one that matters.
9
- */
10
- export const lastStageRects = new WeakMap();
11
- /**
12
- * Keeps every object's `transform-origin` on the stage's ONE vanishing point, so objects that each carry their own
13
- * `perspective()` are seen through a single still camera (see `focal-plane-stylesheet.ts`).
14
- *
15
- * The origin is written as two custom properties on each object (`--fp-ox`, `--fp-oy`): the vanishing point minus the
16
- * object's own offset in the stage. Offsets are read from `offsetLeft`/`offsetTop`, which ignore transforms, so an object
17
- * that is currently stepped back still reports where it is laid out. Custom properties written this way are left alone
18
- * by React, which only manages the style properties it set itself.
19
- */
20
- export function useSharedVanishingPoint(rootRef) {
21
- useLayoutEffect(() => {
22
- const root = rootRef.current;
23
- if (!root)
24
- return undefined;
25
- let frame = 0;
26
- // Absent in some environments (a test DOM): the window resize and the mutations below still re-measure.
27
- const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => schedule());
28
- const observed = new Set();
29
- const measure = () => {
30
- frame = 0;
31
- const vx = root.clientWidth * VANISHING_POINT.x;
32
- const vy = root.clientHeight * VANISHING_POINT.y;
33
- const objects = new Set(root.querySelectorAll(`[data-fp-object], ${FOCAL_PLANE_PANE_SELECTOR}`));
34
- // Every object is observed, not only the stage: a sidebar collapsing MOVES the content column without resizing
35
- // the stage, and a moved object with a stale origin would be seen from the wrong point.
36
- for (const element of objects)
37
- if (!observed.has(element)) {
38
- resize?.observe(element);
39
- observed.add(element);
40
- }
41
- for (const element of observed)
42
- if (!objects.has(element)) {
43
- resize?.unobserve(element);
44
- observed.delete(element);
45
- }
46
- for (const element of objects) {
47
- const { left, top } = offsetWithin(element, root);
48
- element.style.setProperty('--fp-ox', `${(vx - left).toFixed(1)}px`);
49
- element.style.setProperty('--fp-oy', `${(vy - top).toFixed(1)}px`);
50
- if (element.offsetWidth > 0 && element.offsetHeight > 0)
51
- lastStageRects.set(element, { left, top, width: element.offsetWidth, height: element.offsetHeight });
52
- }
53
- };
54
- const schedule = () => {
55
- if (!frame)
56
- frame = requestAnimationFrame(measure);
57
- };
58
- measure();
59
- resize?.observe(root);
60
- const mutations = new MutationObserver(schedule);
61
- mutations.observe(root, { childList: true, subtree: true });
62
- window.addEventListener('resize', schedule);
63
- return () => {
64
- cancelAnimationFrame(frame);
65
- resize?.disconnect();
66
- mutations.disconnect();
67
- window.removeEventListener('resize', schedule);
68
- };
69
- }, [rootRef]);
70
- }
71
- /** An element's layout offset inside `root`, walking the offset-parent chain (transforms are not part of it). */
72
- export function offsetWithin(element, root) {
73
- let left = 0;
74
- let top = 0;
75
- let node = element;
76
- while (node && node !== root) {
77
- left += node.offsetLeft;
78
- top += node.offsetTop;
79
- const parent = node.offsetParent;
80
- if (!parent || !root.contains(parent) && parent !== root)
81
- break;
82
- node = parent;
83
- }
84
- return { left, top };
85
- }
86
- //# sourceMappingURL=use-shared-vanishing-point.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-shared-vanishing-point.js","sourceRoot":"","sources":["../../../../src/focal-plane/use-shared-vanishing-point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,uHAAuH;AACvH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;AAUnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,OAAO,EAAsB,CAAC;AAEhE;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAsC;IAC5E,eAAe,CAAC,GAAG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AAC;QACjD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,YAAY,CAAC,OAAoB,EAAE,IAAiB;IAClE,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAuB,OAAO,CAAC;IACvC,OAAO,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC7B,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC;QACxB,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAkC,CAAC;QACvD,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,IAAI;YAAE,MAAM;QAChE,IAAI,GAAG,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AACvB,CAAC","sourcesContent":["import { useLayoutEffect, type RefObject } from 'react';\n\nimport { FOCAL_PLANE_PANE_SELECTOR } from './focal-plane-stylesheet';\n\n/** Where the vanishing point sits in the stage: centred, a little above the middle (the eye line of the prototype). */\nexport const VANISHING_POINT = { x: 0.5, y: 0.42 };\n\n/** An object's laid-out box in the stage (untransformed), as last measured. */\nexport interface StageRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/**\n * The last laid-out box of every object, kept so a pane that has just been REMOVED or HIDDEN can still be drawn where\n * it was (its ghost flies into depth from there). A zero-size reading never replaces a real one: a hidden pane measures\n * as nothing, and its last visible box is the one that matters.\n */\nexport const lastStageRects = new WeakMap<Element, StageRect>();\n\n/**\n * Keeps every object's `transform-origin` on the stage's ONE vanishing point, so objects that each carry their own\n * `perspective()` are seen through a single still camera (see `focal-plane-stylesheet.ts`).\n *\n * The origin is written as two custom properties on each object (`--fp-ox`, `--fp-oy`): the vanishing point minus the\n * object's own offset in the stage. Offsets are read from `offsetLeft`/`offsetTop`, which ignore transforms, so an object\n * that is currently stepped back still reports where it is laid out. Custom properties written this way are left alone\n * by React, which only manages the style properties it set itself.\n */\nexport function useSharedVanishingPoint(rootRef: RefObject<HTMLElement | null>): void {\n useLayoutEffect(() => {\n const root = rootRef.current;\n if (!root) return undefined;\n let frame = 0;\n // Absent in some environments (a test DOM): the window resize and the mutations below still re-measure.\n const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => schedule());\n const observed = new Set<HTMLElement>();\n const measure = (): void => {\n frame = 0;\n const vx = root.clientWidth * VANISHING_POINT.x;\n const vy = root.clientHeight * VANISHING_POINT.y;\n const objects = new Set(root.querySelectorAll<HTMLElement>(`[data-fp-object], ${FOCAL_PLANE_PANE_SELECTOR}`));\n // Every object is observed, not only the stage: a sidebar collapsing MOVES the content column without resizing\n // the stage, and a moved object with a stale origin would be seen from the wrong point.\n for (const element of objects) if (!observed.has(element)) { resize?.observe(element); observed.add(element); }\n for (const element of observed) if (!objects.has(element)) { resize?.unobserve(element); observed.delete(element); }\n for (const element of objects) {\n const { left, top } = offsetWithin(element, root);\n element.style.setProperty('--fp-ox', `${(vx - left).toFixed(1)}px`);\n element.style.setProperty('--fp-oy', `${(vy - top).toFixed(1)}px`);\n if (element.offsetWidth > 0 && element.offsetHeight > 0) lastStageRects.set(element, { left, top, width: element.offsetWidth, height: element.offsetHeight });\n }\n };\n const schedule = (): void => {\n if (!frame) frame = requestAnimationFrame(measure);\n };\n measure();\n resize?.observe(root);\n const mutations = new MutationObserver(schedule);\n mutations.observe(root, { childList: true, subtree: true });\n window.addEventListener('resize', schedule);\n return () => {\n cancelAnimationFrame(frame);\n resize?.disconnect();\n mutations.disconnect();\n window.removeEventListener('resize', schedule);\n };\n }, [rootRef]);\n}\n\n/** An element's layout offset inside `root`, walking the offset-parent chain (transforms are not part of it). */\nexport function offsetWithin(element: HTMLElement, root: HTMLElement): { left: number; top: number } {\n let left = 0;\n let top = 0;\n let node: HTMLElement | null = element;\n while (node && node !== root) {\n left += node.offsetLeft;\n top += node.offsetTop;\n const parent = node.offsetParent as HTMLElement | null;\n if (!parent || !root.contains(parent) && parent !== root) break;\n node = parent;\n }\n return { left, top };\n}\n"]}
@@ -1,26 +0,0 @@
1
- import type React from 'react';
2
- import type { AppLayoutPreset_MainContainer_DefaultProps } from '@wildo-ai/saas-frontend-lib';
3
- /** @wildo_source:part:start presets.3d.layout-contract facet:layer:frontend facet:family:layout-3d facet:audience:app-developer */
4
- /**
5
- * How a shell layout disposes the regions — the half of a layout with nothing 3D in it.
6
- *
7
- * Named for the SHELL, not for 3D, on purpose: a composed placement is an ordinary shell container built from the
8
- * building blocks of `@wildo-ai/saas-frontend-lib` (`AppShellProviders`, the region, content and overlays outlets,
9
- * `AppShellLoadingState`), so the same shape can serve a general layout system for 2D shells — planned, not built —
10
- * without renaming. The 3D half (scene, transitions, rest pose) lives in `Layout3DDefinition`.
11
- */
12
- export declare enum ShellLayoutPlacementKind {
13
- /** The main container the registration captured (the 2D default, or an application's own), rendered unchanged. */
14
- INHERIT = "inherit",
15
- /** A container of the layout's own, composed from the shell building blocks. */
16
- COMPOSED = "composed"
17
- }
18
- /** A shell layout's disposal. */
19
- export type ShellLayoutPlacement = {
20
- kind: ShellLayoutPlacementKind.INHERIT;
21
- } | {
22
- kind: ShellLayoutPlacementKind.COMPOSED;
23
- container: React.ComponentType<AppLayoutPreset_MainContainer_DefaultProps>;
24
- };
25
- /** @wildo_source:part:end presets.3d.layout-contract */
26
- //# sourceMappingURL=shell-layout-placement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-layout-placement.d.ts","sourceRoot":"","sources":["../../../src/layout/shell-layout-placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,6BAA6B,CAAC;AAE9F,mIAAmI;AACnI;;;;;;;GAOG;AACH,oBAAY,wBAAwB;IAClC,kHAAkH;IAClH,OAAO,YAAY;IACnB,gFAAgF;IAChF,QAAQ,aAAa;CACtB;AAED,iCAAiC;AACjC,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC;IAAC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,0CAA0C,CAAC,CAAA;CAAE,CAAC;AAC5H,wDAAwD"}
@@ -1,18 +0,0 @@
1
- /** @wildo_source:part:start presets.3d.layout-contract facet:layer:frontend facet:family:layout-3d facet:audience:app-developer */
2
- /**
3
- * How a shell layout disposes the regions — the half of a layout with nothing 3D in it.
4
- *
5
- * Named for the SHELL, not for 3D, on purpose: a composed placement is an ordinary shell container built from the
6
- * building blocks of `@wildo-ai/saas-frontend-lib` (`AppShellProviders`, the region, content and overlays outlets,
7
- * `AppShellLoadingState`), so the same shape can serve a general layout system for 2D shells — planned, not built —
8
- * without renaming. The 3D half (scene, transitions, rest pose) lives in `Layout3DDefinition`.
9
- */
10
- export var ShellLayoutPlacementKind;
11
- (function (ShellLayoutPlacementKind) {
12
- /** The main container the registration captured (the 2D default, or an application's own), rendered unchanged. */
13
- ShellLayoutPlacementKind["INHERIT"] = "inherit";
14
- /** A container of the layout's own, composed from the shell building blocks. */
15
- ShellLayoutPlacementKind["COMPOSED"] = "composed";
16
- })(ShellLayoutPlacementKind || (ShellLayoutPlacementKind = {}));
17
- /** @wildo_source:part:end presets.3d.layout-contract */
18
- //# sourceMappingURL=shell-layout-placement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-layout-placement.js","sourceRoot":"","sources":["../../../../src/layout/shell-layout-placement.ts"],"names":[],"mappings":"AAIA,mIAAmI;AACnI;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,wBAKX;AALD,WAAY,wBAAwB;IAClC,kHAAkH;IAClH,+CAAmB,CAAA;IACnB,gFAAgF;IAChF,iDAAqB,CAAA;AACvB,CAAC,EALW,wBAAwB,KAAxB,wBAAwB,QAKnC;AAMD,wDAAwD","sourcesContent":["import type React from 'react';\n\nimport type { AppLayoutPreset_MainContainer_DefaultProps } from '@wildo-ai/saas-frontend-lib';\n\n/** @wildo_source:part:start presets.3d.layout-contract facet:layer:frontend facet:family:layout-3d facet:audience:app-developer */\n/**\n * How a shell layout disposes the regions — the half of a layout with nothing 3D in it.\n *\n * Named for the SHELL, not for 3D, on purpose: a composed placement is an ordinary shell container built from the\n * building blocks of `@wildo-ai/saas-frontend-lib` (`AppShellProviders`, the region, content and overlays outlets,\n * `AppShellLoadingState`), so the same shape can serve a general layout system for 2D shells — planned, not built —\n * without renaming. The 3D half (scene, transitions, rest pose) lives in `Layout3DDefinition`.\n */\nexport enum ShellLayoutPlacementKind {\n /** The main container the registration captured (the 2D default, or an application's own), rendered unchanged. */\n INHERIT = 'inherit',\n /** A container of the layout's own, composed from the shell building blocks. */\n COMPOSED = 'composed',\n}\n\n/** A shell layout's disposal. */\nexport type ShellLayoutPlacement =\n | { kind: ShellLayoutPlacementKind.INHERIT }\n | { kind: ShellLayoutPlacementKind.COMPOSED; container: React.ComponentType<AppLayoutPreset_MainContainer_DefaultProps> };\n/** @wildo_source:part:end presets.3d.layout-contract */\n"]}