@lynx-js/luna-studio 0.0.0-oidc-bootstrap.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +416 -5
  3. package/dist/choreography/choreography-view.d.ts +9 -0
  4. package/dist/choreography/choreography-view.d.ts.map +1 -0
  5. package/dist/choreography/choreography-view.js +256 -0
  6. package/dist/choreography/choreography-view.js.map +1 -0
  7. package/dist/choreography/choreography.d.ts +10 -0
  8. package/dist/choreography/choreography.d.ts.map +1 -0
  9. package/dist/choreography/choreography.js +17 -0
  10. package/dist/choreography/choreography.js.map +1 -0
  11. package/dist/choreography/index.d.ts +3 -0
  12. package/dist/choreography/index.d.ts.map +1 -0
  13. package/dist/choreography/index.js +1 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +3 -0
  17. package/dist/lynx-stage/index.d.ts +3 -0
  18. package/dist/lynx-stage/index.d.ts.map +1 -0
  19. package/dist/lynx-stage/index.js +1 -0
  20. package/dist/lynx-stage/studio-lynx-stage.d.ts +5 -0
  21. package/dist/lynx-stage/studio-lynx-stage.d.ts.map +1 -0
  22. package/dist/lynx-stage/studio-lynx-stage.js +26 -0
  23. package/dist/lynx-stage/studio-lynx-stage.js.map +1 -0
  24. package/dist/types/choreography.d.ts +106 -0
  25. package/dist/types/choreography.d.ts.map +1 -0
  26. package/dist/types/choreography.js +9 -0
  27. package/dist/types/choreography.js.map +1 -0
  28. package/dist/types/index.d.ts +4 -0
  29. package/dist/types/index.d.ts.map +1 -0
  30. package/dist/types/index.js +0 -0
  31. package/dist/types/lynx-stage.d.ts +20 -0
  32. package/dist/types/lynx-stage.d.ts.map +1 -0
  33. package/dist/types/lynx-stage.js +0 -0
  34. package/dist/types/studio.d.ts +115 -0
  35. package/dist/types/studio.d.ts.map +1 -0
  36. package/dist/types/studio.js +60 -0
  37. package/dist/types/studio.js.map +1 -0
  38. package/dist/types/utils.d.ts +4 -0
  39. package/dist/types/utils.d.ts.map +1 -0
  40. package/dist/types/utils.js +0 -0
  41. package/dist/utils/world.d.ts +27 -0
  42. package/dist/utils/world.d.ts.map +1 -0
  43. package/dist/utils/world.js +29 -0
  44. package/dist/utils/world.js.map +1 -0
  45. package/package.json +55 -5
package/LICENSE CHANGED
@@ -198,4 +198,4 @@
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,9 +1,420 @@
1
- # @lynx-js/luna-studio
1
+ # luna-studio
2
2
 
3
- > Reusable multi-stage choreography layer for the L.U.N.A project (OIDC bootstrap placeholder)
3
+ `@lynx-js/luna-studio` is a reusable multi-stage choreography layer for Lynx-based previews and comparison canvases.
4
4
 
5
- This is a placeholder package published only to enable npm Trusted Publishing (OIDC) setup.
5
+ > **Note:** `luna-studio` is still experimental, and its API is constantly changing.
6
6
 
7
- It contains no functional code and should not be installed.
7
+ It packages the rendering, layout, focus, and interaction plumbing needed for:
8
8
 
9
- A proper release will replace this package once OIDC is configured.
9
+ - compare / focus / lineup stage arrangements
10
+ - shared or per-stage theme application
11
+ - host-side stage-container interaction handling
12
+ - embedded Lynx runtime callback forwarding
13
+ - app-defined focus resolution and global-props injection
14
+
15
+ It does **not** ship an application shell.
16
+
17
+ The following app-level pieces stay outside this package:
18
+
19
+ - `Studio`
20
+ - `MenuBar`
21
+ - `StudioFrame`
22
+ - keyboard shortcut glue
23
+ - demo-specific runtime handling
24
+ - app-owned layout catalogs and business metadata
25
+
26
+ If you only need a single device-framed preview, use [`@lynx-js/luna-stage`](../luna-stage) directly.
27
+
28
+ ## Installation
29
+
30
+ ```sh
31
+ npm i @lynx-js/luna-studio @lynx-js/web-core motion react
32
+ ```
33
+
34
+ `luna-studio` depends on `@lynx-js/luna-stage` internally for its rendering primitives and expects the Lynx Web runtime to be available through `@lynx-js/web-core`.
35
+
36
+ ## Public API
37
+
38
+ Current public exports from `@lynx-js/luna-studio` are grouped by components and types:
39
+
40
+ - Components
41
+ - `Choreography`
42
+ - Studio model types
43
+ - `StudioStage`
44
+ - `StudioStageSlice`
45
+ - `StudioResolvedStage`
46
+ - `ResolveStudioLayoutParams`
47
+ - `StageGlobalPropsBuilder`
48
+ - `StudioGridSpec`
49
+ - `StudioLayout`
50
+ - `StudioResolvedLayout`
51
+ - `StudioModeGrid`
52
+ - `StudioViewMode`
53
+ - `LunaThemeKey`
54
+ - `LunaThemeMode`
55
+ - `LunaThemeVariant`
56
+ - Choreography types
57
+ - `ChoreographyBaseProps`
58
+ - `ChoreographyProps`
59
+ - `ChoreographyInteractionProps`
60
+ - `ChoreographyViewProps`
61
+ - `InteractionParams`
62
+ - `InteractionTarget`
63
+ - `FocusKeyResolver`
64
+ - `StageAppearance`
65
+ - Lynx bridge types
66
+ - `LynxRuntimeCall`
67
+ - Helpers
68
+ - `resolveStudioLayout`
69
+ - `indexResolvedLayout`
70
+ - `getPayloadString`
71
+
72
+ `ChoreographyView` and `StudioLynxStage` exist inside the package as internal implementation layers, but they are not part of the public component API.
73
+
74
+ ## Quick Start
75
+
76
+ ```tsx
77
+ import { Choreography } from '@lynx-js/luna-studio';
78
+ import type { StudioModeGrid, StudioResolvedLayout } from '@lynx-js/luna-studio';
79
+
80
+ const modeGrid: StudioModeGrid = {
81
+ compare: { cols: 2, rows: 1 },
82
+ focus: { cols: 3, rows: 1 },
83
+ lineup: { cols: 3, rows: 1 },
84
+ };
85
+
86
+ const layout: StudioResolvedLayout = {
87
+ compare: [
88
+ {
89
+ id: 'button-light',
90
+ entry: 'ActButton',
91
+ theme: 'luna-light',
92
+ focusKey: 'button',
93
+ style: { gridColumn: '1 / span 1', gridRow: '1 / span 1' },
94
+ },
95
+ {
96
+ id: 'button-dark',
97
+ entry: 'ActButton',
98
+ theme: 'luna-dark',
99
+ focusKey: 'button',
100
+ style: { gridColumn: '2 / span 1', gridRow: '1 / span 1' },
101
+ },
102
+ ],
103
+ focus: [
104
+ {
105
+ id: 'button-focus',
106
+ entry: 'ActButton',
107
+ theme: 'luna-light',
108
+ focusKey: 'button',
109
+ style: { gridColumn: '2 / span 1', gridRow: '1 / span 1' },
110
+ },
111
+ ],
112
+ lineup: [
113
+ {
114
+ id: 'button-lineup',
115
+ entry: 'ActButton',
116
+ theme: 'lunaris-dark',
117
+ focusKey: 'button',
118
+ style: { gridColumn: '2 / span 1', gridRow: '1 / span 1' },
119
+ },
120
+ ],
121
+ };
122
+
123
+ export function Demo() {
124
+ return (
125
+ <div className='size-full'>
126
+ <Choreography
127
+ bundleRoot='/bundles/'
128
+ layout={layout}
129
+ modeGrid={modeGrid}
130
+ viewMode='compare'
131
+ themeKey='lunaris-dark'
132
+ interactionTarget='content'
133
+ />
134
+ </div>
135
+ );
136
+ }
137
+ ```
138
+
139
+ If your host prefers an authoring model that separates a resource pool (entry/bundleRoot/theme defaults) from per-mode layout overrides, you can build the resolved layout with `resolveStudioLayout`:
140
+
141
+ ```ts
142
+ import { resolveStudioLayout } from '@lynx-js/luna-studio';
143
+ import type {
144
+ ResolveStudioLayoutParams,
145
+ StudioLayout,
146
+ StudioStage,
147
+ } from '@lynx-js/luna-studio';
148
+
149
+ const stagePool: Record<string, StudioStage> = {
150
+ Button: { id: 'Button', entry: 'ActButton', theme: 'luna-light' },
151
+ };
152
+
153
+ const layoutSpec: StudioLayout = {
154
+ compare: [{ id: 'Button', style: { gridColumn: '1 / 2', gridRow: '1 / 2' } }],
155
+ focus: [{ id: 'Button', style: { gridColumn: '1 / 2', gridRow: '1 / 2' } }],
156
+ lineup: [{ id: 'Button', style: { gridColumn: '1 / 2', gridRow: '1 / 2' } }],
157
+ };
158
+
159
+ const resolvedLayout = resolveStudioLayout(
160
+ {
161
+ stagePool,
162
+ layoutSpec,
163
+ } satisfies ResolveStudioLayoutParams,
164
+ );
165
+ ```
166
+
167
+ ## Core Concepts
168
+
169
+ ### `StudioStage`
170
+
171
+ `StudioStage` is the resource/pool definition for a stage (resource locator + defaults).
172
+
173
+ ```ts
174
+ type StudioStage = {
175
+ id: string;
176
+ entry: string;
177
+ theme: LunaThemeKey;
178
+ bundleRoot?: string;
179
+ focusKey?: string;
180
+ };
181
+ ```
182
+
183
+ Notes:
184
+
185
+ - `entry` and `bundleRoot` are the resource locator used to locate the Lynx bundle.
186
+ - `theme` and `focusKey` are stage-level defaults used during layout resolution.
187
+
188
+ ### `StudioResolvedStage`
189
+
190
+ `StudioResolvedStage` is the per-stage data boundary consumed by the choreography layer.
191
+
192
+ ```ts
193
+ type StudioResolvedStage = {
194
+ id: string;
195
+ className?: string;
196
+ style?: CSSProperties;
197
+ bundleRoot?: string;
198
+ focusKey?: string;
199
+ entry: string;
200
+ theme: LunaThemeKey;
201
+ };
202
+ ```
203
+
204
+ Notes:
205
+
206
+ - `id` is the stable stage identity used for layout, motion, and interaction correlation.
207
+ - `className` and `style` apply to the stage container.
208
+ - `bundleRoot` can be provided per-stage; otherwise `Choreography.bundleRoot` may act as a host-level fallback.
209
+ - app-specific metadata should live in app-local extension types rather than reopening the public `StudioResolvedStage` contract.
210
+
211
+ ### `StudioStageSlice`
212
+
213
+ `StudioStageSlice` is the per-mode layout projection for a stage. It references a pool stage by `id` and carries host-side overrides for that mode.
214
+
215
+ ```ts
216
+ type StudioStageSlice = {
217
+ id: string;
218
+ className?: string;
219
+ style?: CSSProperties;
220
+ theme?: LunaThemeKey;
221
+ focusKey?: string;
222
+ };
223
+ ```
224
+
225
+ Notes:
226
+
227
+ - Slice ids must be unique within the same `StudioViewMode`. `Choreography` uses the resolved `stage.id` as the stable render identity (React key, Motion layout id, and emitted `interaction.stageId`).
228
+ - To render the same Lynx `entry` multiple times, define multiple `StudioStage` pool items with different `id` values but the same `entry`.
229
+
230
+ ### `StudioLayout`
231
+
232
+ `StudioLayout` is the authoring layout specification for the three built-in presentation modes. Each item references a stage by `id` and carries host-side overrides (e.g., `className`, `style`, `theme`, `focusKey`).
233
+
234
+ ```ts
235
+ type StudioLayout = Record<
236
+ 'compare' | 'focus' | 'lineup',
237
+ StudioStageSlice[]
238
+ >;
239
+ ```
240
+
241
+ ### `StudioResolvedLayout`
242
+
243
+ `StudioResolvedLayout` contains one stage list for each built-in presentation mode.
244
+
245
+ ```ts
246
+ type StudioResolvedLayout = Record<
247
+ 'compare' | 'focus' | 'lineup',
248
+ StudioResolvedStage[]
249
+ >;
250
+ ```
251
+
252
+ `modeGrid` can optionally provide the grid dimensions for each mode when the host wants the container layout to be grid-driven.
253
+
254
+ ### `StudioViewMode`
255
+
256
+ `StudioViewMode` selects which layout slice is active.
257
+
258
+ | Mode | Behavior |
259
+ | --------- | --------------------------------------------------------------- |
260
+ | `compare` | Renders multiple stages side-by-side and allows per-stage theme |
261
+ | `focus` | Renders a shared theme with 3D focal emphasis |
262
+ | `lineup` | Renders a shared theme in the lineup arrangement |
263
+
264
+ ## Interaction Model
265
+
266
+ ### `InteractionParams`
267
+
268
+ `InteractionParams` is the normalized interaction envelope used by choreography callbacks.
269
+
270
+ ```ts
271
+ type InteractionParams =
272
+ | {
273
+ target: 'stage';
274
+ stageId: string;
275
+ entry: string;
276
+ payload?: unknown;
277
+ containerEvent: MouseEvent | PointerEvent;
278
+ }
279
+ | {
280
+ target: 'content';
281
+ stageId: string;
282
+ entry: string;
283
+ payload?: unknown;
284
+ runtimeCall: LynxRuntimeCall;
285
+ };
286
+ ```
287
+
288
+ Notes:
289
+
290
+ - `target: 'stage'` means the interaction is attributed to the host-side stage layer; the raw browser payload is exposed as `containerEvent`.
291
+ - `target: 'content'` means the interaction is attributed to embedded Lynx content; the raw Lynx runtime payload is exposed as `runtimeCall`.
292
+ - `containerEvent.type` distinguishes host-side click / pointer variants.
293
+ - `runtimeCall.name` distinguishes content-side interaction kinds emitted through `onNativeModulesCall`.
294
+
295
+ ### `interactionTarget`
296
+
297
+ `interactionTarget` controls which layer receives pointer interaction first:
298
+
299
+ - `'content'`: embedded Lynx content is interactive
300
+ - `'stage'`: the outer stage container is interactive
301
+
302
+ ### `onInteraction`
303
+
304
+ Receives the normalized choreography interaction envelope.
305
+
306
+ ```ts
307
+ type OnInteraction = (interaction: InteractionParams) => unknown;
308
+ ```
309
+
310
+ Use this as the primary high-level callback when you want one place to observe both host-side stage-container interactions and embedded-content runtime callbacks. The concrete raw payload is available as `interaction.containerEvent` or `interaction.runtimeCall`, depending on `interaction.target`.
311
+
312
+ ### `onLynxRuntimeCall`
313
+
314
+ Receives raw runtime callbacks emitted from embedded Lynx content.
315
+
316
+ ```ts
317
+ type OnLynxRuntimeCall = (call: LynxRuntimeCall) => unknown;
318
+
319
+ type LynxRuntimeCall = {
320
+ entry: string;
321
+ channel: string;
322
+ name: string;
323
+ data: unknown;
324
+ };
325
+ ```
326
+
327
+ Use this only when you need the original Lynx bridge / RPC callback directly, rather than the normalized `onInteraction` abstraction.
328
+
329
+ This keeps the package surface runtime-neutral:
330
+
331
+ - no low-level `moduleName` leak
332
+ - `channel` remains the host-facing source identifier
333
+ - app-specific interpretation stays outside the package
334
+
335
+ ### `resolveFocusKey`
336
+
337
+ `resolveFocusKey` maps a normalized interaction back to a stage-level `focusKey`.
338
+
339
+ ```ts
340
+ type FocusKeyResolver = (
341
+ interaction: InteractionParams,
342
+ ) => string | undefined;
343
+ ```
344
+
345
+ This is the app-owned bridge between generic choreography interactions and business-specific focus semantics.
346
+
347
+ ### `buildStageGlobalProps`
348
+
349
+ `buildStageGlobalProps` lets the host derive app-specific Lynx global props for each rendered stage.
350
+
351
+ ```ts
352
+ type StageGlobalPropsBuilder = (params: {
353
+ stage: StudioStage;
354
+ viewMode: StudioViewMode;
355
+ activeFocusKey: string;
356
+ focusKey: string | undefined;
357
+ }) => Record<string, unknown> | undefined;
358
+ ```
359
+
360
+ The two focus-related fields serve different roles:
361
+
362
+ - `activeFocusKey` is the current choreography-wide active focus identity.
363
+ - `focusKey` is the focus identity of the specific `stage` currently being rendered.
364
+
365
+ In other words, `activeFocusKey` answers "which focus target is currently active?", while `focusKey` answers "which focus target does this particular stage belong to?".
366
+
367
+ This makes it easy to derive stage-local props such as:
368
+
369
+ - whether the current stage is the active/focused stage
370
+ - which shared component or semantic key is currently active elsewhere in the choreography
371
+ - app-specific flags that depend on both the rendered stage and the global focus state
372
+
373
+ ## `Choreography` API
374
+
375
+ `Choreography` is the main public component in this package.
376
+
377
+ Internally, it wraps `ChoreographyView`, which is the lower-level renderer responsible for layout, focus state, interaction normalization, and Lynx-stage wiring.
378
+
379
+ ```ts
380
+ type ChoreographyProps = Omit<ChoreographyViewProps, 'mode'> & {
381
+ viewMode?: StudioViewMode;
382
+ };
383
+ ```
384
+
385
+ Behavior notes:
386
+
387
+ - `viewMode` defaults to `'compare'`
388
+ - `themeKey` defaults to `'lunaris-dark'`
389
+ - `interactionTarget` defaults to `'content'`
390
+ - `focusKey` is read directly from each resolved stage in `layout` (i.e., from the `StudioResolvedLayout` stage items)
391
+ - `bundleRoot` can provide a choreography-level fallback; per-stage resource roots are taken from each resolved stage in `layout`
392
+ - `layout` is required and should already be fully resolved by the host app
393
+
394
+ ## Scope
395
+
396
+ This package covers the reusable choreography layer:
397
+
398
+ - public choreography types and data model
399
+ - grid-driven multi-stage layout and focus presentation
400
+ - normalized stage/content interaction handling
401
+ - the internal `ChoreographyView` renderer
402
+ - the internal Lynx runtime adapter used by `Choreography`
403
+
404
+ This package does **not** provide:
405
+
406
+ - a top-level `Studio` shell component
407
+ - built-in demo layout data
408
+ - app chrome such as `MenuBar`
409
+ - app-level keyboard bindings
410
+ - demo-specific runtime event parsing
411
+ - a public `lynx-stage` subpath export
412
+
413
+ ## Intended Consumers
414
+
415
+ Use `@lynx-js/luna-studio` when you need a reusable multi-stage choreography layer but want to keep your app shell, layout data, business semantics, and event handling local:
416
+
417
+ - documentation sites embedding multiple Lynx entries
418
+ - design system comparison canvases
419
+ - host apps that need both stage-container interactions and Lynx runtime callbacks
420
+ - future `lynx-website` integration
@@ -0,0 +1,9 @@
1
+ import type { JSX } from 'react';
2
+ import type { ChoreographyViewProps } from '../types';
3
+ /**
4
+ * Internal choreography renderer that resolves layout, focus state, interaction
5
+ * normalization, and Lynx-stage wiring for the active presentation mode.
6
+ */
7
+ declare function ChoreographyView({ layout, modeGrid, mode, defaultFocusKey, className, style, bundleRoot, resolveFocusKey, buildStageGlobalProps, themeKey, stageAppearance, interactionTarget, onLynxRuntimeCall, onInteraction, }: ChoreographyViewProps): JSX.Element;
8
+ export { ChoreographyView };
9
+ //# sourceMappingURL=choreography-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choreography-view.d.ts","sourceRoot":"","sources":["../../src/choreography/choreography-view.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,GAAG,EAGJ,MAAM,OAAO,CAAA;AAId,OAAO,KAAK,EACV,qBAAqB,EAItB,MAAM,UAAU,CAAA;AAgFjB;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,EACxB,MAAM,EACN,QAAQ,EACR,IAAgB,EAChB,eAAe,EACf,SAAS,EACT,KAAK,EACL,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,QAAQ,EACR,eAAe,EACf,iBAA6B,EAC7B,iBAAiB,EACjB,aAAa,GACd,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAgOrC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -0,0 +1,256 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { inferThemeMode } from "@lynx-js/luna-core";
3
+ import { useEventCallback } from "@lynx-js/luna-stage";
4
+ import { MotionPresentation, MotionStage, MotionStageContainer } from "@lynx-js/luna-stage/motion";
5
+ import { AnimatePresence } from "motion/react";
6
+ import { useMemo, useState } from "react";
7
+ import { StudioLynxStage } from "../lynx-stage/index.js";
8
+ import { getStageWorldState } from "../utils/world.js";
9
+ const slidingVariants = {
10
+ initial: {
11
+ opacity: 0,
12
+ x: -300
13
+ },
14
+ animate: {
15
+ opacity: 1,
16
+ x: 0
17
+ },
18
+ exit: {
19
+ opacity: 0,
20
+ x: 300
21
+ }
22
+ };
23
+ const presentationTransition = {
24
+ type: 'spring',
25
+ visualDuration: 0.3,
26
+ bounce: 0.3
27
+ };
28
+ const fitTransition = {
29
+ visualDuration: 0.8,
30
+ bounce: 0.1
31
+ };
32
+ const BASE_STYLE = {
33
+ width: '100%',
34
+ height: '100%',
35
+ pointerEvents: 'none',
36
+ position: 'relative'
37
+ };
38
+ const DEFAULT_STAGE_APPEARANCE_BY_MODE = {
39
+ light: {
40
+ outlineColor: 'rgb(0 0 0 / 0.04)',
41
+ maskColor: '#f5f5f5'
42
+ },
43
+ dark: {
44
+ outlineColor: 'rgb(255 255 255 / 0.10)',
45
+ maskColor: '#00000080'
46
+ }
47
+ };
48
+ function hasFocusKey(stage) {
49
+ return void 0 !== stage.focusKey;
50
+ }
51
+ function createStageInteraction(stage, containerEvent) {
52
+ return {
53
+ target: 'stage',
54
+ stageId: stage.id,
55
+ entry: stage.entry,
56
+ containerEvent
57
+ };
58
+ }
59
+ function createContentInteraction(stage, call) {
60
+ return {
61
+ target: 'content',
62
+ stageId: stage.id,
63
+ entry: stage.entry,
64
+ runtimeCall: call,
65
+ ...void 0 === call.data ? {} : {
66
+ payload: call.data
67
+ }
68
+ };
69
+ }
70
+ function ChoreographyView({ layout, modeGrid, mode = 'compare', defaultFocusKey, className, style, bundleRoot, resolveFocusKey, buildStageGlobalProps, themeKey, stageAppearance, interactionTarget = 'content', onLynxRuntimeCall, onInteraction }) {
71
+ const [activeFocusKey, setActiveFocusKey] = useState(defaultFocusKey);
72
+ const containerInteractive = 'stage' === interactionTarget;
73
+ const contentInteractive = 'content' === interactionTarget;
74
+ const containerGrid = modeGrid?.[mode];
75
+ const resolveFocusKeyEvent = useEventCallback(resolveFocusKey);
76
+ const onInteractionEvent = useEventCallback(onInteraction);
77
+ const onLynxRuntimeCallEvent = useEventCallback(onLynxRuntimeCall);
78
+ const dispatchInteractionEvent = useEventCallback((interaction)=>{
79
+ const nextActiveFocusKey = resolveFocusKeyEvent(interaction);
80
+ if (void 0 !== nextActiveFocusKey) setActiveFocusKey(nextActiveFocusKey);
81
+ onInteractionEvent(interaction);
82
+ });
83
+ const stageContainerEventHandlers = useMemo(()=>{
84
+ const handlers = new Map();
85
+ for (const stage of layout[mode]){
86
+ const dispatch = (e)=>{
87
+ dispatchInteractionEvent(createStageInteraction(stage, e.nativeEvent));
88
+ };
89
+ handlers.set(stage.id, {
90
+ onClick: dispatch,
91
+ onPointerCancel: dispatch,
92
+ onPointerDown: dispatch,
93
+ onPointerUp: dispatch
94
+ });
95
+ }
96
+ return handlers;
97
+ }, [
98
+ dispatchInteractionEvent,
99
+ layout,
100
+ mode
101
+ ]);
102
+ const stageRuntimeCallHandlers = useMemo(()=>{
103
+ const handlers = new Map();
104
+ for (const stage of layout[mode])handlers.set(stage.id, (call)=>{
105
+ dispatchInteractionEvent(createContentInteraction(stage, call));
106
+ return onLynxRuntimeCallEvent(call);
107
+ });
108
+ return handlers;
109
+ }, [
110
+ dispatchInteractionEvent,
111
+ layout,
112
+ mode,
113
+ onLynxRuntimeCallEvent
114
+ ]);
115
+ const resolvedActiveFocusKey = useMemo(()=>{
116
+ const focusableStages = layout[mode].filter(hasFocusKey);
117
+ if (void 0 !== activeFocusKey && focusableStages.some((stage)=>stage.focusKey === activeFocusKey)) return activeFocusKey;
118
+ return focusableStages[0]?.focusKey ?? '';
119
+ }, [
120
+ activeFocusKey,
121
+ layout,
122
+ mode
123
+ ]);
124
+ const rendered = useMemo(()=>{
125
+ const stages = layout[mode];
126
+ const focusableStages = stages.filter(hasFocusKey);
127
+ const nonFocusedStages = stages.filter((stage)=>stage.focusKey !== resolvedActiveFocusKey);
128
+ const mid = (nonFocusedStages.length - 1) / 2;
129
+ const focusedIndex = Math.max(0, focusableStages.findIndex((stage)=>stage.focusKey === resolvedActiveFocusKey));
130
+ return stages.map((stage)=>{
131
+ const compOrder = nonFocusedStages.findIndex((bg)=>bg.id === stage.id);
132
+ const escape = stage.focusKey === resolvedActiveFocusKey;
133
+ const { world, zIndex, maskOpacity } = getStageWorldState({
134
+ mode,
135
+ compOrder,
136
+ mid,
137
+ focusedIndex,
138
+ escape
139
+ });
140
+ const resolvedBundleRoot = stage.bundleRoot ?? bundleRoot;
141
+ const extraGlobalProps = buildStageGlobalProps?.({
142
+ stage,
143
+ viewMode: mode,
144
+ activeFocusKey: resolvedActiveFocusKey,
145
+ focusKey: stage.focusKey
146
+ });
147
+ return {
148
+ ...stage,
149
+ world,
150
+ zIndex,
151
+ maskOpacity,
152
+ ...void 0 === resolvedBundleRoot ? {} : {
153
+ resolvedBundleRoot
154
+ },
155
+ ...void 0 === extraGlobalProps ? {} : {
156
+ extraGlobalProps
157
+ }
158
+ };
159
+ });
160
+ }, [
161
+ bundleRoot,
162
+ buildStageGlobalProps,
163
+ layout,
164
+ mode,
165
+ resolvedActiveFocusKey
166
+ ]);
167
+ const mergedContainerStyle = useMemo(()=>{
168
+ const gridStyle = containerGrid && {
169
+ display: 'grid',
170
+ gridTemplateColumns: `repeat(${containerGrid.cols}, minmax(0, 1fr))`,
171
+ gridTemplateRows: `repeat(${containerGrid.rows}, minmax(0, 1fr))`,
172
+ alignItems: 'stretch'
173
+ };
174
+ return {
175
+ ...BASE_STYLE,
176
+ ...gridStyle,
177
+ ...style
178
+ };
179
+ }, [
180
+ containerGrid,
181
+ style
182
+ ]);
183
+ const resolvedThemeKey = themeKey ?? 'lunaris-dark';
184
+ const resolvedThemeMode = inferThemeMode(resolvedThemeKey) ?? 'dark';
185
+ const resolvedStageAppearance = useMemo(()=>{
186
+ const fallback = DEFAULT_STAGE_APPEARANCE_BY_MODE[resolvedThemeMode];
187
+ const fromDefault = stageAppearance?.default;
188
+ const fromMode = stageAppearance?.[resolvedThemeMode];
189
+ return {
190
+ outlineColor: fromMode?.outlineColor ?? fromDefault?.outlineColor ?? fallback.outlineColor,
191
+ maskColor: fromMode?.maskColor ?? fromDefault?.maskColor ?? fallback.maskColor
192
+ };
193
+ }, [
194
+ resolvedThemeMode,
195
+ stageAppearance
196
+ ]);
197
+ const stageOutlineStyle = useMemo(()=>({
198
+ backgroundColor: resolvedStageAppearance.outlineColor
199
+ }), [
200
+ resolvedStageAppearance.outlineColor
201
+ ]);
202
+ const maskColor = resolvedStageAppearance.maskColor;
203
+ return /*#__PURE__*/ jsx("div", {
204
+ className: className,
205
+ style: mergedContainerStyle,
206
+ children: /*#__PURE__*/ jsx(AnimatePresence, {
207
+ mode: "popLayout",
208
+ children: rendered.map((stage)=>{
209
+ const stageRuntimeCallHandler = stageRuntimeCallHandlers.get(stage.id);
210
+ return /*#__PURE__*/ jsx(MotionStageContainer, {
211
+ layoutId: stage.id,
212
+ className: stage.className,
213
+ ...containerInteractive ? stageContainerEventHandlers.get(stage.id) : void 0,
214
+ style: {
215
+ ...stage.style,
216
+ zIndex: stage.zIndex,
217
+ pointerEvents: containerInteractive ? 'auto' : 'none'
218
+ },
219
+ children: /*#__PURE__*/ jsx(MotionPresentation, {
220
+ variants: slidingVariants,
221
+ initial: "initial",
222
+ animate: "animate",
223
+ exit: "exit",
224
+ transition: presentationTransition,
225
+ children: /*#__PURE__*/ jsx(MotionStage, {
226
+ fitProgress: 0,
227
+ fitTransition: fitTransition,
228
+ world: stage.world,
229
+ focalLength: 'focus' === mode ? 500 : 0,
230
+ style: stageOutlineStyle,
231
+ contentInteractive: contentInteractive,
232
+ maskColor: maskColor,
233
+ maskOpacity: stage.maskOpacity,
234
+ children: /*#__PURE__*/ jsx(StudioLynxStage, {
235
+ entry: stage.entry,
236
+ lunaTheme: 'compare' === mode ? stage.theme : resolvedThemeKey,
237
+ ...void 0 === stageRuntimeCallHandler ? {} : {
238
+ onLynxRuntimeCall: stageRuntimeCallHandler
239
+ },
240
+ ...void 0 === stage.resolvedBundleRoot ? {} : {
241
+ bundleRoot: stage.resolvedBundleRoot
242
+ },
243
+ ...void 0 === stage.extraGlobalProps ? {} : {
244
+ extraGlobalProps: stage.extraGlobalProps
245
+ }
246
+ })
247
+ })
248
+ })
249
+ }, stage.id);
250
+ })
251
+ })
252
+ });
253
+ }
254
+ export { ChoreographyView };
255
+
256
+ //# sourceMappingURL=choreography-view.js.map