@lynx-js/luna-studio 0.1.0 → 0.1.1

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.
@@ -1 +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"}
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,CA2OrC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -5,7 +5,7 @@ import { MotionPresentation, MotionStage, MotionStageContainer } from "@lynx-js/
5
5
  import { AnimatePresence } from "motion/react";
6
6
  import { useMemo, useState } from "react";
7
7
  import { StudioLynxStage } from "../lynx-stage/index.js";
8
- import { getStageWorldState } from "../utils/world.js";
8
+ import { getStageWorldState, isForegroundStage } from "../utils/world.js";
9
9
  const slidingVariants = {
10
10
  initial: {
11
11
  opacity: 0,
@@ -113,7 +113,7 @@ function ChoreographyView({ layout, modeGrid, mode = 'compare', defaultFocusKey,
113
113
  onLynxRuntimeCallEvent
114
114
  ]);
115
115
  const resolvedActiveFocusKey = useMemo(()=>{
116
- const focusableStages = layout[mode].filter(hasFocusKey);
116
+ const focusableStages = layout[mode].filter((stage)=>hasFocusKey(stage));
117
117
  if (void 0 !== activeFocusKey && focusableStages.some((stage)=>stage.focusKey === activeFocusKey)) return activeFocusKey;
118
118
  return focusableStages[0]?.focusKey ?? '';
119
119
  }, [
@@ -123,18 +123,18 @@ function ChoreographyView({ layout, modeGrid, mode = 'compare', defaultFocusKey,
123
123
  ]);
124
124
  const rendered = useMemo(()=>{
125
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));
126
+ const focusableStages = stages.filter((stage)=>hasFocusKey(stage));
127
+ const focusableBackgroundStages = focusableStages.filter((stage)=>stage.focusKey !== resolvedActiveFocusKey);
128
+ const backgroundMidpoint = (focusableBackgroundStages.length - 1) / 2;
129
+ const activeFocusIndex = Math.max(0, focusableStages.findIndex((stage)=>stage.focusKey === resolvedActiveFocusKey));
130
130
  return stages.map((stage)=>{
131
- const compOrder = nonFocusedStages.findIndex((bg)=>bg.id === stage.id);
132
- const escape = stage.focusKey === resolvedActiveFocusKey;
131
+ const backgroundIndex = focusableBackgroundStages.findIndex((backgroundStage)=>backgroundStage.id === stage.id);
132
+ const escape = isForegroundStage(stage.focusKey, resolvedActiveFocusKey);
133
133
  const { world, zIndex, maskOpacity } = getStageWorldState({
134
134
  mode,
135
- compOrder,
136
- mid,
137
- focusedIndex,
135
+ backgroundIndex,
136
+ backgroundMidpoint,
137
+ activeFocusIndex,
138
138
  escape
139
139
  });
140
140
  const resolvedBundleRoot = stage.bundleRoot ?? bundleRoot;
@@ -1 +1 @@
1
- {"version":3,"file":"choreography/choreography-view.js","sources":["../../src/choreography/choreography-view.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { inferThemeMode } from '@lynx-js/luna-core'\nimport { useEventCallback } from '@lynx-js/luna-stage'\nimport {\n MotionPresentation,\n MotionStage,\n MotionStageContainer,\n} from '@lynx-js/luna-stage/motion'\nimport { AnimatePresence } from 'motion/react'\nimport type { SpringOptions, Transition } from 'motion/react'\nimport type {\n CSSProperties,\n JSX,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { useMemo, useState } from 'react'\n\nimport { StudioLynxStage } from '../lynx-stage'\nimport type {\n ChoreographyViewProps,\n InteractionParams,\n LynxRuntimeCall,\n StudioResolvedStage,\n} from '../types'\nimport { getStageWorldState } from '../utils/world'\n\ntype RenderData = StudioResolvedStage & {\n world: { x: number, y: number, z: number }\n zIndex: number\n maskOpacity: number\n // Pre-resolved props for StudioLynxStage. Optional so that omitting them\n // matches `exactOptionalPropertyTypes` semantics on the consuming side.\n resolvedBundleRoot?: string\n extraGlobalProps?: Record<string, unknown>\n}\n\ntype FocusableStudioStage = StudioResolvedStage & {\n focusKey: string\n}\n\nconst slidingVariants = {\n initial: { opacity: 0, x: -300 },\n animate: { opacity: 1, x: 0 },\n exit: { opacity: 0, x: 300 },\n}\n\nconst presentationTransition: Transition = {\n type: 'spring',\n visualDuration: 0.3,\n bounce: 0.3,\n}\n\nconst fitTransition: SpringOptions = { visualDuration: 0.8, bounce: 0.1 }\n\nconst BASE_STYLE: CSSProperties = {\n width: '100%',\n height: '100%',\n pointerEvents: 'none',\n position: 'relative',\n}\n\nconst DEFAULT_STAGE_APPEARANCE_BY_MODE = {\n light: {\n outlineColor: 'rgb(0 0 0 / 0.04)',\n maskColor: '#f5f5f5',\n },\n dark: {\n outlineColor: 'rgb(255 255 255 / 0.10)',\n maskColor: '#00000080',\n },\n} as const\n\nfunction hasFocusKey(\n stage: StudioResolvedStage,\n): stage is FocusableStudioStage {\n return stage.focusKey !== undefined\n}\n\nfunction createStageInteraction(\n stage: StudioResolvedStage,\n containerEvent: MouseEvent | PointerEvent,\n): InteractionParams {\n return {\n target: 'stage',\n stageId: stage.id,\n entry: stage.entry,\n containerEvent,\n }\n}\n\nfunction createContentInteraction(\n stage: StudioResolvedStage,\n call: LynxRuntimeCall,\n): InteractionParams {\n return {\n target: 'content',\n stageId: stage.id,\n entry: stage.entry,\n runtimeCall: call,\n ...(call.data === undefined ? {} : { payload: call.data }),\n }\n}\n\n/**\n * Internal choreography renderer that resolves layout, focus state, interaction\n * normalization, and Lynx-stage wiring for the active presentation mode.\n */\nfunction ChoreographyView({\n layout,\n modeGrid,\n mode = 'compare',\n defaultFocusKey,\n className,\n style,\n bundleRoot,\n resolveFocusKey,\n buildStageGlobalProps,\n themeKey,\n stageAppearance,\n interactionTarget = 'content',\n onLynxRuntimeCall,\n onInteraction,\n}: ChoreographyViewProps): JSX.Element {\n const [activeFocusKey, setActiveFocusKey] = useState<string | undefined>(\n defaultFocusKey,\n )\n const containerInteractive = interactionTarget === 'stage'\n const contentInteractive = interactionTarget === 'content'\n const containerGrid = modeGrid?.[mode]\n\n // Stable proxies that always invoke the latest props. Safe to call from\n // event handlers.\n const resolveFocusKeyEvent = useEventCallback(resolveFocusKey)\n const onInteractionEvent = useEventCallback(onInteraction)\n const onLynxRuntimeCallEvent = useEventCallback(onLynxRuntimeCall)\n\n const dispatchInteractionEvent = useEventCallback((\n interaction: InteractionParams,\n ): void => {\n const nextActiveFocusKey = resolveFocusKeyEvent(interaction)\n if (nextActiveFocusKey !== undefined) {\n setActiveFocusKey(nextActiveFocusKey)\n }\n onInteractionEvent(interaction)\n })\n\n const stageContainerEventHandlers = useMemo(() => {\n const handlers = new Map<\n string,\n {\n onClick: (e: ReactMouseEvent | ReactPointerEvent) => void\n onPointerCancel: (e: ReactMouseEvent | ReactPointerEvent) => void\n onPointerDown: (e: ReactMouseEvent | ReactPointerEvent) => void\n onPointerUp: (e: ReactMouseEvent | ReactPointerEvent) => void\n }\n >()\n\n for (const stage of layout[mode]) {\n const dispatch = (e: ReactMouseEvent | ReactPointerEvent) => {\n dispatchInteractionEvent(createStageInteraction(stage, e.nativeEvent))\n }\n handlers.set(stage.id, {\n onClick: dispatch,\n onPointerCancel: dispatch,\n onPointerDown: dispatch,\n onPointerUp: dispatch,\n })\n }\n return handlers\n }, [dispatchInteractionEvent, layout, mode])\n\n const stageRuntimeCallHandlers = useMemo(() => {\n const handlers = new Map<string, (call: LynxRuntimeCall) => unknown>()\n\n for (const stage of layout[mode]) {\n handlers.set(stage.id, (call: LynxRuntimeCall) => {\n dispatchInteractionEvent(createContentInteraction(stage, call))\n return onLynxRuntimeCallEvent(call)\n })\n }\n return handlers\n }, [dispatchInteractionEvent, layout, mode, onLynxRuntimeCallEvent])\n\n const resolvedActiveFocusKey = useMemo(() => {\n // eslint-disable-next-line unicorn/no-array-callback-reference\n const focusableStages = layout[mode].filter(hasFocusKey)\n\n if (\n activeFocusKey !== undefined\n && focusableStages.some(stage => stage.focusKey === activeFocusKey)\n ) {\n return activeFocusKey\n }\n\n return focusableStages[0]?.focusKey ?? ''\n }, [activeFocusKey, layout, mode])\n\n const rendered: RenderData[] = useMemo(() => {\n const stages = layout[mode]\n // eslint-disable-next-line unicorn/no-array-callback-reference\n const focusableStages = stages.filter(hasFocusKey)\n const nonFocusedStages = stages.filter(\n stage => stage.focusKey !== resolvedActiveFocusKey,\n )\n\n const mid = (nonFocusedStages.length - 1) / 2\n const focusedIndex = Math.max(\n 0,\n focusableStages.findIndex(\n stage => stage.focusKey === resolvedActiveFocusKey,\n ),\n )\n\n return stages.map((stage) => {\n // `compOrder` tracks render identity; `focusKey` is optional focus semantics.\n const compOrder = nonFocusedStages.findIndex(\n bg => bg.id === stage.id,\n )\n // Only the active focus stage escapes the surrounding focus layout.\n const escape = stage.focusKey === resolvedActiveFocusKey\n const { world, zIndex, maskOpacity } = getStageWorldState({\n mode,\n compOrder,\n mid,\n focusedIndex,\n escape,\n })\n\n const resolvedBundleRoot = stage.bundleRoot ?? bundleRoot\n const extraGlobalProps = buildStageGlobalProps?.({\n stage,\n viewMode: mode,\n activeFocusKey: resolvedActiveFocusKey,\n focusKey: stage.focusKey,\n })\n\n return {\n ...stage,\n world,\n zIndex,\n maskOpacity,\n ...(resolvedBundleRoot === undefined ? {} : { resolvedBundleRoot }),\n ...(extraGlobalProps === undefined ? {} : { extraGlobalProps }),\n }\n })\n }, [bundleRoot, buildStageGlobalProps, layout, mode, resolvedActiveFocusKey])\n\n const mergedContainerStyle: CSSProperties = useMemo(() => {\n const gridStyle: CSSProperties | undefined = containerGrid && {\n display: 'grid',\n gridTemplateColumns: `repeat(${containerGrid.cols}, minmax(0, 1fr))`,\n gridTemplateRows: `repeat(${containerGrid.rows}, minmax(0, 1fr))`,\n alignItems: 'stretch',\n }\n return {\n ...BASE_STYLE,\n ...gridStyle,\n ...style,\n }\n }, [containerGrid, style])\n\n const resolvedThemeKey = themeKey ?? 'lunaris-dark'\n const resolvedThemeMode = inferThemeMode(resolvedThemeKey) ?? 'dark'\n\n const resolvedStageAppearance = useMemo(() => {\n const fallback = DEFAULT_STAGE_APPEARANCE_BY_MODE[resolvedThemeMode]\n const fromDefault = stageAppearance?.default\n const fromMode = stageAppearance?.[resolvedThemeMode]\n\n return {\n outlineColor: fromMode?.outlineColor ?? fromDefault?.outlineColor\n ?? fallback.outlineColor,\n maskColor: fromMode?.maskColor ?? fromDefault?.maskColor\n ?? fallback.maskColor,\n } as const\n }, [resolvedThemeMode, stageAppearance])\n\n const stageOutlineStyle: CSSProperties = useMemo(\n () => ({\n backgroundColor: resolvedStageAppearance.outlineColor,\n }),\n [resolvedStageAppearance.outlineColor],\n )\n\n const maskColor = resolvedStageAppearance.maskColor\n\n return (\n <div className={className} style={mergedContainerStyle}>\n <AnimatePresence mode='popLayout'>\n {rendered.map((stage) => {\n const stageRuntimeCallHandler = stageRuntimeCallHandlers.get(stage.id)\n\n return (\n <MotionStageContainer\n layoutId={stage.id}\n key={stage.id}\n className={stage.className}\n {...(containerInteractive\n ? stageContainerEventHandlers.get(stage.id)\n : undefined)}\n style={{\n ...stage.style,\n zIndex: stage.zIndex,\n pointerEvents: containerInteractive ? 'auto' : 'none',\n }}\n >\n <MotionPresentation\n variants={slidingVariants}\n initial='initial'\n animate='animate'\n exit='exit'\n transition={presentationTransition}\n >\n <MotionStage\n fitProgress={0}\n fitTransition={fitTransition}\n world={stage.world}\n focalLength={mode === 'focus' ? 500 : 0}\n style={stageOutlineStyle}\n contentInteractive={contentInteractive}\n maskColor={maskColor}\n maskOpacity={stage.maskOpacity}\n >\n <StudioLynxStage\n entry={stage.entry}\n lunaTheme={mode === 'compare'\n ? stage.theme\n : resolvedThemeKey}\n {...(stageRuntimeCallHandler === undefined\n ? {}\n : { onLynxRuntimeCall: stageRuntimeCallHandler })}\n {...(stage.resolvedBundleRoot === undefined\n ? {}\n : { bundleRoot: stage.resolvedBundleRoot })}\n {...(stage.extraGlobalProps === undefined\n ? {}\n : { extraGlobalProps: stage.extraGlobalProps })}\n />\n </MotionStage>\n </MotionPresentation>\n </MotionStageContainer>\n )\n })}\n </AnimatePresence>\n </div>\n )\n}\n\nexport { ChoreographyView }\n"],"names":["slidingVariants","presentationTransition","fitTransition","BASE_STYLE","DEFAULT_STAGE_APPEARANCE_BY_MODE","hasFocusKey","stage","undefined","createStageInteraction","containerEvent","createContentInteraction","call","ChoreographyView","layout","modeGrid","mode","defaultFocusKey","className","style","bundleRoot","resolveFocusKey","buildStageGlobalProps","themeKey","stageAppearance","interactionTarget","onLynxRuntimeCall","onInteraction","activeFocusKey","setActiveFocusKey","useState","containerInteractive","contentInteractive","containerGrid","resolveFocusKeyEvent","useEventCallback","onInteractionEvent","onLynxRuntimeCallEvent","dispatchInteractionEvent","interaction","nextActiveFocusKey","stageContainerEventHandlers","useMemo","handlers","Map","dispatch","e","stageRuntimeCallHandlers","resolvedActiveFocusKey","focusableStages","rendered","stages","nonFocusedStages","mid","focusedIndex","Math","compOrder","bg","escape","world","zIndex","maskOpacity","getStageWorldState","resolvedBundleRoot","extraGlobalProps","mergedContainerStyle","gridStyle","resolvedThemeKey","resolvedThemeMode","inferThemeMode","resolvedStageAppearance","fallback","fromDefault","fromMode","stageOutlineStyle","maskColor","AnimatePresence","stageRuntimeCallHandler","MotionStageContainer","MotionPresentation","MotionStage","StudioLynxStage"],"mappings":";;;;;;;;AA4CA,MAAMA,kBAAkB;IACtB,SAAS;QAAE,SAAS;QAAG,GAAG;IAAK;IAC/B,SAAS;QAAE,SAAS;QAAG,GAAG;IAAE;IAC5B,MAAM;QAAE,SAAS;QAAG,GAAG;IAAI;AAC7B;AAEA,MAAMC,yBAAqC;IACzC,MAAM;IACN,gBAAgB;IAChB,QAAQ;AACV;AAEA,MAAMC,gBAA+B;IAAE,gBAAgB;IAAK,QAAQ;AAAI;AAExE,MAAMC,aAA4B;IAChC,OAAO;IACP,QAAQ;IACR,eAAe;IACf,UAAU;AACZ;AAEA,MAAMC,mCAAmC;IACvC,OAAO;QACL,cAAc;QACd,WAAW;IACb;IACA,MAAM;QACJ,cAAc;QACd,WAAW;IACb;AACF;AAEA,SAASC,YACPC,KAA0B;IAE1B,OAAOA,AAAmBC,WAAnBD,MAAM,QAAQ;AACvB;AAEA,SAASE,uBACPF,KAA0B,EAC1BG,cAAyC;IAEzC,OAAO;QACL,QAAQ;QACR,SAASH,MAAM,EAAE;QACjB,OAAOA,MAAM,KAAK;QAClBG;IACF;AACF;AAEA,SAASC,yBACPJ,KAA0B,EAC1BK,IAAqB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view.js","sources":["../../src/choreography/choreography-view.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { inferThemeMode } from '@lynx-js/luna-core'\nimport { useEventCallback } from '@lynx-js/luna-stage'\nimport {\n MotionPresentation,\n MotionStage,\n MotionStageContainer,\n} from '@lynx-js/luna-stage/motion'\nimport { AnimatePresence } from 'motion/react'\nimport type { SpringOptions, Transition } from 'motion/react'\nimport type {\n CSSProperties,\n JSX,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { useMemo, useState } from 'react'\n\nimport { StudioLynxStage } from '../lynx-stage'\nimport type {\n ChoreographyViewProps,\n InteractionParams,\n LynxRuntimeCall,\n StudioResolvedStage,\n} from '../types'\nimport { getStageWorldState, isForegroundStage } from '../utils/world'\n\ntype RenderData = StudioResolvedStage & {\n world: { x: number, y: number, z: number }\n zIndex: number\n maskOpacity: number\n // Pre-resolved props for StudioLynxStage. Optional so that omitting them\n // matches `exactOptionalPropertyTypes` semantics on the consuming side.\n resolvedBundleRoot?: string\n extraGlobalProps?: Record<string, unknown>\n}\n\ntype FocusableStudioStage = StudioResolvedStage & {\n focusKey: string\n}\n\nconst slidingVariants = {\n initial: { opacity: 0, x: -300 },\n animate: { opacity: 1, x: 0 },\n exit: { opacity: 0, x: 300 },\n}\n\nconst presentationTransition: Transition = {\n type: 'spring',\n visualDuration: 0.3,\n bounce: 0.3,\n}\n\nconst fitTransition: SpringOptions = { visualDuration: 0.8, bounce: 0.1 }\n\nconst BASE_STYLE: CSSProperties = {\n width: '100%',\n height: '100%',\n pointerEvents: 'none',\n position: 'relative',\n}\n\nconst DEFAULT_STAGE_APPEARANCE_BY_MODE = {\n light: {\n outlineColor: 'rgb(0 0 0 / 0.04)',\n maskColor: '#f5f5f5',\n },\n dark: {\n outlineColor: 'rgb(255 255 255 / 0.10)',\n maskColor: '#00000080',\n },\n} as const\n\nfunction hasFocusKey(\n stage: StudioResolvedStage,\n): stage is FocusableStudioStage {\n return stage.focusKey !== undefined\n}\n\nfunction createStageInteraction(\n stage: StudioResolvedStage,\n containerEvent: MouseEvent | PointerEvent,\n): InteractionParams {\n return {\n target: 'stage',\n stageId: stage.id,\n entry: stage.entry,\n containerEvent,\n }\n}\n\nfunction createContentInteraction(\n stage: StudioResolvedStage,\n call: LynxRuntimeCall,\n): InteractionParams {\n return {\n target: 'content',\n stageId: stage.id,\n entry: stage.entry,\n runtimeCall: call,\n ...(call.data === undefined ? {} : { payload: call.data }),\n }\n}\n\n/**\n * Internal choreography renderer that resolves layout, focus state, interaction\n * normalization, and Lynx-stage wiring for the active presentation mode.\n */\nfunction ChoreographyView({\n layout,\n modeGrid,\n mode = 'compare',\n defaultFocusKey,\n className,\n style,\n bundleRoot,\n resolveFocusKey,\n buildStageGlobalProps,\n themeKey,\n stageAppearance,\n interactionTarget = 'content',\n onLynxRuntimeCall,\n onInteraction,\n}: ChoreographyViewProps): JSX.Element {\n const [activeFocusKey, setActiveFocusKey] = useState<string | undefined>(\n defaultFocusKey,\n )\n const containerInteractive = interactionTarget === 'stage'\n const contentInteractive = interactionTarget === 'content'\n const containerGrid = modeGrid?.[mode]\n\n // Stable proxies that always invoke the latest props. Safe to call from\n // event handlers.\n const resolveFocusKeyEvent = useEventCallback(resolveFocusKey)\n const onInteractionEvent = useEventCallback(onInteraction)\n const onLynxRuntimeCallEvent = useEventCallback(onLynxRuntimeCall)\n\n const dispatchInteractionEvent = useEventCallback((\n interaction: InteractionParams,\n ): void => {\n const nextActiveFocusKey = resolveFocusKeyEvent(interaction)\n if (nextActiveFocusKey !== undefined) {\n setActiveFocusKey(nextActiveFocusKey)\n }\n onInteractionEvent(interaction)\n })\n\n const stageContainerEventHandlers = useMemo(() => {\n const handlers = new Map<\n string,\n {\n onClick: (e: ReactMouseEvent | ReactPointerEvent) => void\n onPointerCancel: (e: ReactMouseEvent | ReactPointerEvent) => void\n onPointerDown: (e: ReactMouseEvent | ReactPointerEvent) => void\n onPointerUp: (e: ReactMouseEvent | ReactPointerEvent) => void\n }\n >()\n\n for (const stage of layout[mode]) {\n const dispatch = (e: ReactMouseEvent | ReactPointerEvent) => {\n dispatchInteractionEvent(createStageInteraction(stage, e.nativeEvent))\n }\n handlers.set(stage.id, {\n onClick: dispatch,\n onPointerCancel: dispatch,\n onPointerDown: dispatch,\n onPointerUp: dispatch,\n })\n }\n return handlers\n }, [dispatchInteractionEvent, layout, mode])\n\n const stageRuntimeCallHandlers = useMemo(() => {\n const handlers = new Map<string, (call: LynxRuntimeCall) => unknown>()\n\n for (const stage of layout[mode]) {\n handlers.set(stage.id, (call: LynxRuntimeCall) => {\n dispatchInteractionEvent(createContentInteraction(stage, call))\n return onLynxRuntimeCallEvent(call)\n })\n }\n return handlers\n }, [dispatchInteractionEvent, layout, mode, onLynxRuntimeCallEvent])\n\n const resolvedActiveFocusKey = useMemo(() => {\n const focusableStages = layout[mode].filter(stage => hasFocusKey(stage))\n\n if (\n activeFocusKey !== undefined\n && focusableStages.some(stage => stage.focusKey === activeFocusKey)\n ) {\n return activeFocusKey\n }\n\n return focusableStages[0]?.focusKey ?? ''\n }, [activeFocusKey, layout, mode])\n\n const rendered: RenderData[] = useMemo(() => {\n const stages = layout[mode]\n\n // Only stages with a focus key participate in focus selection and the\n // surrounding 3D fan. Stages without one remain persistent foreground\n // content, such as controls shared by every focused stage.\n const focusableStages = stages.filter(stage => hasFocusKey(stage))\n\n // The active focus stage escapes the fan, so only the remaining focusable\n // stages contribute to its ordering and midpoint.\n const focusableBackgroundStages = focusableStages.filter(\n stage => stage.focusKey !== resolvedActiveFocusKey,\n )\n\n const backgroundMidpoint = (focusableBackgroundStages.length - 1) / 2\n const activeFocusIndex = Math.max(\n 0,\n focusableStages.findIndex(\n stage => stage.focusKey === resolvedActiveFocusKey,\n ),\n )\n\n return stages.map((stage) => {\n // Foreground stages intentionally resolve to -1 here. Their world state\n // ignores the background index while `escape` is true.\n const backgroundIndex = focusableBackgroundStages.findIndex(\n backgroundStage => backgroundStage.id === stage.id,\n )\n\n // Both persistent non-focusable content and the active focus stage stay\n // centered, elevated, and unmasked.\n const escape = isForegroundStage(\n stage.focusKey,\n resolvedActiveFocusKey,\n )\n const { world, zIndex, maskOpacity } = getStageWorldState({\n mode,\n backgroundIndex,\n backgroundMidpoint,\n activeFocusIndex,\n escape,\n })\n\n const resolvedBundleRoot = stage.bundleRoot ?? bundleRoot\n const extraGlobalProps = buildStageGlobalProps?.({\n stage,\n viewMode: mode,\n activeFocusKey: resolvedActiveFocusKey,\n focusKey: stage.focusKey,\n })\n\n return {\n ...stage,\n world,\n zIndex,\n maskOpacity,\n ...(resolvedBundleRoot === undefined ? {} : { resolvedBundleRoot }),\n ...(extraGlobalProps === undefined ? {} : { extraGlobalProps }),\n }\n })\n }, [bundleRoot, buildStageGlobalProps, layout, mode, resolvedActiveFocusKey])\n\n const mergedContainerStyle: CSSProperties = useMemo(() => {\n const gridStyle: CSSProperties | undefined = containerGrid && {\n display: 'grid',\n gridTemplateColumns: `repeat(${containerGrid.cols}, minmax(0, 1fr))`,\n gridTemplateRows: `repeat(${containerGrid.rows}, minmax(0, 1fr))`,\n alignItems: 'stretch',\n }\n return {\n ...BASE_STYLE,\n ...gridStyle,\n ...style,\n }\n }, [containerGrid, style])\n\n const resolvedThemeKey = themeKey ?? 'lunaris-dark'\n const resolvedThemeMode = inferThemeMode(resolvedThemeKey) ?? 'dark'\n\n const resolvedStageAppearance = useMemo(() => {\n const fallback = DEFAULT_STAGE_APPEARANCE_BY_MODE[resolvedThemeMode]\n const fromDefault = stageAppearance?.default\n const fromMode = stageAppearance?.[resolvedThemeMode]\n\n return {\n outlineColor: fromMode?.outlineColor ?? fromDefault?.outlineColor\n ?? fallback.outlineColor,\n maskColor: fromMode?.maskColor ?? fromDefault?.maskColor\n ?? fallback.maskColor,\n } as const\n }, [resolvedThemeMode, stageAppearance])\n\n const stageOutlineStyle: CSSProperties = useMemo(\n () => ({\n backgroundColor: resolvedStageAppearance.outlineColor,\n }),\n [resolvedStageAppearance.outlineColor],\n )\n\n const maskColor = resolvedStageAppearance.maskColor\n\n return (\n <div className={className} style={mergedContainerStyle}>\n <AnimatePresence mode='popLayout'>\n {rendered.map((stage) => {\n const stageRuntimeCallHandler = stageRuntimeCallHandlers.get(stage.id)\n\n return (\n <MotionStageContainer\n layoutId={stage.id}\n key={stage.id}\n className={stage.className}\n {...(containerInteractive\n ? stageContainerEventHandlers.get(stage.id)\n : undefined)}\n style={{\n ...stage.style,\n zIndex: stage.zIndex,\n pointerEvents: containerInteractive ? 'auto' : 'none',\n }}\n >\n <MotionPresentation\n variants={slidingVariants}\n initial='initial'\n animate='animate'\n exit='exit'\n transition={presentationTransition}\n >\n <MotionStage\n fitProgress={0}\n fitTransition={fitTransition}\n world={stage.world}\n focalLength={mode === 'focus' ? 500 : 0}\n style={stageOutlineStyle}\n contentInteractive={contentInteractive}\n maskColor={maskColor}\n maskOpacity={stage.maskOpacity}\n >\n <StudioLynxStage\n entry={stage.entry}\n lunaTheme={mode === 'compare'\n ? stage.theme\n : resolvedThemeKey}\n {...(stageRuntimeCallHandler === undefined\n ? {}\n : { onLynxRuntimeCall: stageRuntimeCallHandler })}\n {...(stage.resolvedBundleRoot === undefined\n ? {}\n : { bundleRoot: stage.resolvedBundleRoot })}\n {...(stage.extraGlobalProps === undefined\n ? {}\n : { extraGlobalProps: stage.extraGlobalProps })}\n />\n </MotionStage>\n </MotionPresentation>\n </MotionStageContainer>\n )\n })}\n </AnimatePresence>\n </div>\n )\n}\n\nexport { ChoreographyView }\n"],"names":["slidingVariants","presentationTransition","fitTransition","BASE_STYLE","DEFAULT_STAGE_APPEARANCE_BY_MODE","hasFocusKey","stage","undefined","createStageInteraction","containerEvent","createContentInteraction","call","ChoreographyView","layout","modeGrid","mode","defaultFocusKey","className","style","bundleRoot","resolveFocusKey","buildStageGlobalProps","themeKey","stageAppearance","interactionTarget","onLynxRuntimeCall","onInteraction","activeFocusKey","setActiveFocusKey","useState","containerInteractive","contentInteractive","containerGrid","resolveFocusKeyEvent","useEventCallback","onInteractionEvent","onLynxRuntimeCallEvent","dispatchInteractionEvent","interaction","nextActiveFocusKey","stageContainerEventHandlers","useMemo","handlers","Map","dispatch","e","stageRuntimeCallHandlers","resolvedActiveFocusKey","focusableStages","rendered","stages","focusableBackgroundStages","backgroundMidpoint","activeFocusIndex","Math","backgroundIndex","backgroundStage","escape","isForegroundStage","world","zIndex","maskOpacity","getStageWorldState","resolvedBundleRoot","extraGlobalProps","mergedContainerStyle","gridStyle","resolvedThemeKey","resolvedThemeMode","inferThemeMode","resolvedStageAppearance","fallback","fromDefault","fromMode","stageOutlineStyle","maskColor","AnimatePresence","stageRuntimeCallHandler","MotionStageContainer","MotionPresentation","MotionStage","StudioLynxStage"],"mappings":";;;;;;;;AA4CA,MAAMA,kBAAkB;IACtB,SAAS;QAAE,SAAS;QAAG,GAAG;IAAK;IAC/B,SAAS;QAAE,SAAS;QAAG,GAAG;IAAE;IAC5B,MAAM;QAAE,SAAS;QAAG,GAAG;IAAI;AAC7B;AAEA,MAAMC,yBAAqC;IACzC,MAAM;IACN,gBAAgB;IAChB,QAAQ;AACV;AAEA,MAAMC,gBAA+B;IAAE,gBAAgB;IAAK,QAAQ;AAAI;AAExE,MAAMC,aAA4B;IAChC,OAAO;IACP,QAAQ;IACR,eAAe;IACf,UAAU;AACZ;AAEA,MAAMC,mCAAmC;IACvC,OAAO;QACL,cAAc;QACd,WAAW;IACb;IACA,MAAM;QACJ,cAAc;QACd,WAAW;IACb;AACF;AAEA,SAASC,YACPC,KAA0B;IAE1B,OAAOA,AAAmBC,WAAnBD,MAAM,QAAQ;AACvB;AAEA,SAASE,uBACPF,KAA0B,EAC1BG,cAAyC;IAEzC,OAAO;QACL,QAAQ;QACR,SAASH,MAAM,EAAE;QACjB,OAAOA,MAAM,KAAK;QAClBG;IACF;AACF;AAEA,SAASC,yBACPJ,KAA0B,EAC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;;mBAzCjDA,MAAM,EAAE;YA+CnB;;;AAIR"}
@@ -9,19 +9,20 @@ export interface StageWorldState {
9
9
  zIndex: number;
10
10
  maskOpacity: number;
11
11
  }
12
+ export declare function isForegroundStage(focusKey: string | undefined, activeFocusKey: string): boolean;
12
13
  /**
13
14
  * Resolves the presentation transform for a stage.
14
15
  *
15
- * In focus mode, `escape` marks the active focused stage, which stays centered,
16
- * elevated, and unmasked. Non-focused stages use `compOrder` to fan out around
17
- * that active stage, while `focusedIndex` adds a small rotation offset so focus
18
- * transitions preserve a sense of direction.
16
+ * In focus mode, `escape` marks foreground stages, which stay centered,
17
+ * elevated, and unmasked. Focusable background stages use `backgroundIndex`
18
+ * to fan out around the foreground, while `activeFocusIndex` adds a small
19
+ * rotation offset so focus transitions preserve a sense of direction.
19
20
  */
20
- export declare function getStageWorldState({ mode, compOrder, mid, focusedIndex, escape, }: {
21
+ export declare function getStageWorldState({ mode, backgroundIndex, backgroundMidpoint, activeFocusIndex, escape, }: {
21
22
  mode: StudioViewMode;
22
- compOrder: number;
23
- mid: number;
24
- focusedIndex: number;
23
+ backgroundIndex: number;
24
+ backgroundMidpoint: number;
25
+ activeFocusIndex: number;
25
26
  escape: boolean;
26
27
  }): StageWorldState;
27
28
  //# sourceMappingURL=world.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/utils/world.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB;AAUD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,GAAG,EACH,YAAY,EACZ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,OAAO,CAAA;CAChB,GAAG,eAAe,CAkClB"}
1
+ {"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/utils/world.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB;AAID,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,cAAc,EAAE,MAAM,GACrB,OAAO,CAET;AAQD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,GACP,EAAE;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,OAAO,CAAA;CAChB,GAAG,eAAe,CAoClB"}
@@ -3,20 +3,23 @@ const WORLD_ORIGIN = {
3
3
  y: 0,
4
4
  z: 0
5
5
  };
6
+ function isForegroundStage(focusKey, activeFocusKey) {
7
+ return void 0 === focusKey || focusKey === activeFocusKey;
8
+ }
6
9
  function getOrderDirection(orderOffset) {
7
10
  if (0 === orderOffset) return 0;
8
11
  return orderOffset > 0 ? 1 : -1;
9
12
  }
10
- function getStageWorldState({ mode, compOrder, mid, focusedIndex, escape }) {
11
- const orderOffset = compOrder - mid;
13
+ function getStageWorldState({ mode, backgroundIndex, backgroundMidpoint, activeFocusIndex, escape }) {
14
+ const orderOffset = backgroundIndex - backgroundMidpoint;
12
15
  const direction = getOrderDirection(orderOffset);
13
- const theta = (20 * orderOffset + direction * focusedIndex * 2) / 180 * Math.PI;
16
+ const theta = (20 * orderOffset + direction * activeFocusIndex * 2) / 180 * Math.PI;
14
17
  const world = 'focus' === mode ? {
15
18
  x: escape ? 0 : 600 * Math.sin(theta),
16
19
  y: 0,
17
20
  z: escape ? 0 : 600 * -Math.cos(theta)
18
21
  } : WORLD_ORIGIN;
19
- const zIndex = 'focus' === mode ? escape ? 100 : Math.ceil(2 * Math.abs(compOrder - mid)) : 0;
22
+ const zIndex = 'focus' === mode ? escape ? 100 : Math.ceil(2 * Math.abs(backgroundIndex - backgroundMidpoint)) : 0;
20
23
  const maskOpacity = 'focus' === mode ? escape ? 0 : Math.max(0, Math.min(1, (1 - 0.6 * Math.abs(2 * theta / Math.PI)) * 0.5)) : 0;
21
24
  return {
22
25
  world,
@@ -24,6 +27,6 @@ function getStageWorldState({ mode, compOrder, mid, focusedIndex, escape }) {
24
27
  maskOpacity
25
28
  };
26
29
  }
27
- export { getStageWorldState };
30
+ export { getStageWorldState, isForegroundStage };
28
31
 
29
32
  //# sourceMappingURL=world.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils/world.js","sources":["../../src/utils/world.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { StudioViewMode } from '../types'\n\nexport interface WorldPos {\n x: number\n y: number\n z: number\n}\n\nexport interface StageWorldState {\n world: WorldPos\n zIndex: number\n maskOpacity: number\n}\n\nconst WORLD_ORIGIN: WorldPos = { x: 0, y: 0, z: 0 }\n\nfunction getOrderDirection(orderOffset: number): -1 | 0 | 1 {\n // Centered stages should not receive a focus-index angle offset.\n if (orderOffset === 0) return 0\n return orderOffset > 0 ? 1 : -1\n}\n\n/**\n * Resolves the presentation transform for a stage.\n *\n * In focus mode, `escape` marks the active focused stage, which stays centered,\n * elevated, and unmasked. Non-focused stages use `compOrder` to fan out around\n * that active stage, while `focusedIndex` adds a small rotation offset so focus\n * transitions preserve a sense of direction.\n */\nexport function getStageWorldState({\n mode,\n compOrder,\n mid,\n focusedIndex,\n escape,\n}: {\n mode: StudioViewMode\n compOrder: number\n mid: number\n focusedIndex: number\n escape: boolean\n}): StageWorldState {\n const orderOffset = compOrder - mid\n const direction = getOrderDirection(orderOffset)\n const theta = (orderOffset * 20 + direction * focusedIndex * 2)\n / 180 * Math.PI\n\n const world: WorldPos = mode === 'focus'\n ? {\n x: escape ? 0 : Math.sin(theta) * 600,\n y: 0,\n z: escape ? 0 : -Math.cos(theta) * 600,\n }\n : WORLD_ORIGIN\n\n const zIndex = mode === 'focus'\n ? (escape ? 100 : Math.ceil(Math.abs(compOrder - mid) * 2))\n : 0\n\n const maskOpacity = mode === 'focus'\n ? (\n escape\n ? 0\n : Math.max(\n 0,\n Math.min(1, (1 - Math.abs(theta * 2 / Math.PI) * 0.6) * 0.5),\n )\n )\n : 0\n\n return {\n world,\n zIndex,\n maskOpacity,\n }\n}\n"],"names":["WORLD_ORIGIN","getOrderDirection","orderOffset","getStageWorldState","mode","compOrder","mid","focusedIndex","escape","direction","theta","Math","world","zIndex","maskOpacity"],"mappings":"AAkBA,MAAMA,eAAyB;IAAE,GAAG;IAAG,GAAG;IAAG,GAAG;AAAE;AAElD,SAASC,kBAAkBC,WAAmB;IAE5C,IAAIA,AAAgB,MAAhBA,aAAmB,OAAO;IAC9B,OAAOA,cAAc,IAAI,IAAI;AAC/B;AAUO,SAASC,mBAAmB,EACjCC,IAAI,EACJC,SAAS,EACTC,GAAG,EACHC,YAAY,EACZC,MAAM,EAOP;IACC,MAAMN,cAAcG,YAAYC;IAChC,MAAMG,YAAYR,kBAAkBC;IACpC,MAAMQ,QAASR,AAAAA,CAAAA,AAAc,KAAdA,cAAmBO,YAAYF,eAAe,KACzD,MAAMI,KAAK,EAAE;IAEjB,MAAMC,QAAkBR,AAAS,YAATA,OACpB;QACA,GAAGI,SAAS,IAAIG,AAAkB,MAAlBA,KAAK,GAAG,CAACD;QACzB,GAAG;QACH,GAAGF,SAAS,IAAI,AAAmB,MAAnB,CAACG,KAAK,GAAG,CAACD;IAC5B,IACEV;IAEJ,MAAMa,SAAST,AAAS,YAATA,OACVI,SAAS,MAAMG,KAAK,IAAI,CAACA,AAA4B,IAA5BA,KAAK,GAAG,CAACN,YAAYC,QAC/C;IAEJ,MAAMQ,cAAcV,AAAS,YAATA,OAEhBI,SACI,IACAG,KAAK,GAAG,CACR,GACAA,KAAK,GAAG,CAAC,GAAI,KAAIA,AAAgC,MAAhCA,KAAK,GAAG,CAACD,AAAQ,IAARA,QAAYC,KAAK,EAAE,CAAM,IAAK,QAG5D;IAEJ,OAAO;QACLC;QACAC;QACAC;IACF;AACF"}
1
+ {"version":3,"file":"utils/world.js","sources":["../../src/utils/world.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { StudioViewMode } from '../types'\n\nexport interface WorldPos {\n x: number\n y: number\n z: number\n}\n\nexport interface StageWorldState {\n world: WorldPos\n zIndex: number\n maskOpacity: number\n}\n\nconst WORLD_ORIGIN: WorldPos = { x: 0, y: 0, z: 0 }\n\nexport function isForegroundStage(\n focusKey: string | undefined,\n activeFocusKey: string,\n): boolean {\n return focusKey === undefined || focusKey === activeFocusKey\n}\n\nfunction getOrderDirection(orderOffset: number): -1 | 0 | 1 {\n // Centered stages should not receive a focus-index angle offset.\n if (orderOffset === 0) return 0\n return orderOffset > 0 ? 1 : -1\n}\n\n/**\n * Resolves the presentation transform for a stage.\n *\n * In focus mode, `escape` marks foreground stages, which stay centered,\n * elevated, and unmasked. Focusable background stages use `backgroundIndex`\n * to fan out around the foreground, while `activeFocusIndex` adds a small\n * rotation offset so focus transitions preserve a sense of direction.\n */\nexport function getStageWorldState({\n mode,\n backgroundIndex,\n backgroundMidpoint,\n activeFocusIndex,\n escape,\n}: {\n mode: StudioViewMode\n backgroundIndex: number\n backgroundMidpoint: number\n activeFocusIndex: number\n escape: boolean\n}): StageWorldState {\n const orderOffset = backgroundIndex - backgroundMidpoint\n const direction = getOrderDirection(orderOffset)\n const theta = (orderOffset * 20 + direction * activeFocusIndex * 2)\n / 180 * Math.PI\n\n const world: WorldPos = mode === 'focus'\n ? {\n x: escape ? 0 : Math.sin(theta) * 600,\n y: 0,\n z: escape ? 0 : -Math.cos(theta) * 600,\n }\n : WORLD_ORIGIN\n\n const zIndex = mode === 'focus'\n ? (escape\n ? 100\n : Math.ceil(Math.abs(backgroundIndex - backgroundMidpoint) * 2))\n : 0\n\n const maskOpacity = mode === 'focus'\n ? (\n escape\n ? 0\n : Math.max(\n 0,\n Math.min(1, (1 - Math.abs(theta * 2 / Math.PI) * 0.6) * 0.5),\n )\n )\n : 0\n\n return {\n world,\n zIndex,\n maskOpacity,\n }\n}\n"],"names":["WORLD_ORIGIN","isForegroundStage","focusKey","activeFocusKey","undefined","getOrderDirection","orderOffset","getStageWorldState","mode","backgroundIndex","backgroundMidpoint","activeFocusIndex","escape","direction","theta","Math","world","zIndex","maskOpacity"],"mappings":"AAkBA,MAAMA,eAAyB;IAAE,GAAG;IAAG,GAAG;IAAG,GAAG;AAAE;AAE3C,SAASC,kBACdC,QAA4B,EAC5BC,cAAsB;IAEtB,OAAOD,AAAaE,WAAbF,YAA0BA,aAAaC;AAChD;AAEA,SAASE,kBAAkBC,WAAmB;IAE5C,IAAIA,AAAgB,MAAhBA,aAAmB,OAAO;IAC9B,OAAOA,cAAc,IAAI,IAAI;AAC/B;AAUO,SAASC,mBAAmB,EACjCC,IAAI,EACJC,eAAe,EACfC,kBAAkB,EAClBC,gBAAgB,EAChBC,MAAM,EAOP;IACC,MAAMN,cAAcG,kBAAkBC;IACtC,MAAMG,YAAYR,kBAAkBC;IACpC,MAAMQ,QAASR,AAAAA,CAAAA,AAAc,KAAdA,cAAmBO,YAAYF,mBAAmB,KAC7D,MAAMI,KAAK,EAAE;IAEjB,MAAMC,QAAkBR,AAAS,YAATA,OACpB;QACA,GAAGI,SAAS,IAAIG,AAAkB,MAAlBA,KAAK,GAAG,CAACD;QACzB,GAAG;QACH,GAAGF,SAAS,IAAI,AAAmB,MAAnB,CAACG,KAAK,GAAG,CAACD;IAC5B,IACEd;IAEJ,MAAMiB,SAAST,AAAS,YAATA,OACVI,SACC,MACAG,KAAK,IAAI,CAACA,AAAiD,IAAjDA,KAAK,GAAG,CAACN,kBAAkBC,uBACvC;IAEJ,MAAMQ,cAAcV,AAAS,YAATA,OAEhBI,SACI,IACAG,KAAK,GAAG,CACR,GACAA,KAAK,GAAG,CAAC,GAAI,KAAIA,AAAgC,MAAhCA,KAAK,GAAG,CAACD,AAAQ,IAARA,QAAYC,KAAK,EAAE,CAAM,IAAK,QAG5D;IAEJ,OAAO;QACLC;QACAC;QACAC;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/luna-studio",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Reusable multi-stage choreography layer for the L.U.N.A project",
5
5
  "keywords": [
6
6
  "luna",