{"version":3,"file":"LayoutAnimationBuilder.mjs","sources":["../../../src/layout/LayoutAnimationBuilder.ts"],"sourcesContent":["import type { Box } from \"motion-utils\"\nimport { GroupAnimation } from \"../animation/GroupAnimation\"\nimport type {\n AnimationOptions,\n AnimationPlaybackControls,\n Transition,\n} from \"../animation/types\"\nimport { frame } from \"../frameloop\"\nimport { copyBoxInto } from \"../projection/geometry/copy\"\nimport { createBox } from \"../projection/geometry/models\"\nimport { HTMLProjectionNode } from \"../projection/node/HTMLProjectionNode\"\nimport type { IProjectionNode } from \"../projection/node/types\"\nimport { HTMLVisualElement } from \"../render/html/HTMLVisualElement\"\nimport { visualElementStore } from \"../render/store\"\nimport type { VisualElement } from \"../render/VisualElement\"\nimport { resolveElements, type ElementOrSelector } from \"../utils/resolve-elements\"\n\ntype LayoutAnimationScope = Element | Document\n\ninterface LayoutElementRecord {\n element: Element\n visualElement: VisualElement\n projection: IProjectionNode\n}\n\ninterface LayoutAttributes {\n layout?: boolean | \"position\" | \"size\" | \"preserve-aspect\" | \"x\" | \"y\"\n layoutId?: string\n}\n\ntype LayoutBuilderResolve = (animation: GroupAnimation) => void\ntype LayoutBuilderReject = (error: unknown) => void\n\ninterface ProjectionOptions {\n layout?: boolean | \"position\" | \"size\" | \"preserve-aspect\" | \"x\" | \"y\"\n layoutId?: string\n animationType?: \"size\" | \"position\" | \"both\" | \"preserve-aspect\" | \"x\" | \"y\"\n transition?: Transition\n crossfade?: boolean\n}\n\nconst layoutSelector = \"[data-layout], [data-layout-id]\"\nconst noop = () => {}\nfunction snapshotFromTarget(projection: IProjectionNode): LayoutElementRecord[\"projection\"][\"snapshot\"] {\n const target = projection.targetWithTransforms || projection.target\n if (!target) return undefined\n\n const measuredBox = createBox()\n const layoutBox = createBox()\n copyBoxInto(measuredBox, target as Box)\n copyBoxInto(layoutBox, target as Box)\n\n return {\n animationId: projection.root?.animationId ?? 0,\n measuredBox,\n layoutBox,\n latestValues: projection.animationValues || projection.latestValues || {},\n source: projection.id,\n }\n}\n\nexport class LayoutAnimationBuilder {\n private scope: LayoutAnimationScope\n private updateDom: () => void | Promise\n private defaultOptions?: AnimationOptions\n private sharedTransitions = new Map()\n private notifyReady: LayoutBuilderResolve = noop\n private rejectReady: LayoutBuilderReject = noop\n private readyPromise: Promise\n\n constructor(\n scope: LayoutAnimationScope,\n updateDom: () => void | Promise,\n defaultOptions?: AnimationOptions\n ) {\n this.scope = scope\n this.updateDom = updateDom\n this.defaultOptions = defaultOptions\n\n this.readyPromise = new Promise((resolve, reject) => {\n this.notifyReady = resolve\n this.rejectReady = reject\n })\n\n frame.postRender(() => {\n this.start().then(this.notifyReady).catch(this.rejectReady)\n })\n }\n\n shared(id: string, transition: AnimationOptions): this {\n this.sharedTransitions.set(id, transition)\n return this\n }\n\n then(\n resolve: LayoutBuilderResolve,\n reject?: LayoutBuilderReject\n ): Promise {\n return this.readyPromise.then(resolve, reject)\n }\n\n private async start(): Promise {\n const beforeElements = collectLayoutElements(this.scope)\n const beforeRecords = this.buildRecords(beforeElements)\n\n beforeRecords.forEach(({ projection }) => {\n const hasCurrentAnimation = Boolean(projection.currentAnimation)\n const isSharedLayout = Boolean(projection.options.layoutId)\n if (hasCurrentAnimation && isSharedLayout) {\n const snapshot = snapshotFromTarget(projection)\n if (snapshot) {\n projection.snapshot = snapshot\n } else if (projection.snapshot) {\n projection.snapshot = undefined\n }\n } else if (\n projection.snapshot &&\n (projection.currentAnimation || projection.isProjecting())\n ) {\n projection.snapshot = undefined\n }\n projection.isPresent = true\n projection.willUpdate()\n })\n\n await this.updateDom()\n\n const afterElements = collectLayoutElements(this.scope)\n const afterRecords = this.buildRecords(afterElements)\n this.handleExitingElements(beforeRecords, afterRecords)\n\n afterRecords.forEach(({ projection }) => {\n const instance = projection.instance as HTMLElement | undefined\n const resumeFromInstance = projection.resumeFrom\n ?.instance as HTMLElement | undefined\n if (!instance || !resumeFromInstance) return\n if (!(\"style\" in instance)) return\n\n const currentTransform = instance.style.transform\n const resumeFromTransform = resumeFromInstance.style.transform\n\n if (\n currentTransform &&\n resumeFromTransform &&\n currentTransform === resumeFromTransform\n ) {\n instance.style.transform = \"\"\n instance.style.transformOrigin = \"\"\n }\n })\n\n afterRecords.forEach(({ projection }) => {\n projection.isPresent = true\n })\n\n const root = getProjectionRoot(afterRecords, beforeRecords)\n root?.didUpdate()\n\n await new Promise((resolve) => {\n frame.postRender(() => resolve())\n })\n\n const animations = collectAnimations(afterRecords)\n const animation = new GroupAnimation(animations)\n\n return animation\n }\n\n private buildRecords(elements: Element[]): LayoutElementRecord[] {\n const records: LayoutElementRecord[] = []\n const recordMap = new Map()\n\n for (const element of elements) {\n const parentRecord = findParentRecord(element, recordMap, this.scope)\n const { layout, layoutId } = readLayoutAttributes(element)\n const override = layoutId\n ? this.sharedTransitions.get(layoutId)\n : undefined\n const transition = override || this.defaultOptions\n const record = getOrCreateRecord(element, parentRecord?.projection, {\n layout,\n layoutId,\n animationType: typeof layout === \"string\" ? layout : \"both\",\n transition: transition as Transition,\n })\n recordMap.set(element, record)\n records.push(record)\n }\n\n return records\n }\n\n private handleExitingElements(\n beforeRecords: LayoutElementRecord[],\n afterRecords: LayoutElementRecord[]\n ): void {\n const afterElementsSet = new Set(afterRecords.map((record) => record.element))\n\n beforeRecords.forEach((record) => {\n if (afterElementsSet.has(record.element)) return\n\n // For shared layout elements, relegate to set up resumeFrom\n // so the remaining element animates from this position\n if (record.projection.options.layoutId) {\n record.projection.isPresent = false\n record.projection.relegate()\n }\n\n record.visualElement.unmount()\n visualElementStore.delete(record.element)\n })\n\n // Clear resumeFrom on EXISTING nodes that point to unmounted projections\n // This prevents crossfade animation when the source element was removed entirely\n // But preserve resumeFrom for NEW nodes so they can animate from the old position\n // Also preserve resumeFrom for lead nodes that were just promoted via relegate\n const beforeElementsSet = new Set(beforeRecords.map((record) => record.element))\n afterRecords.forEach(({ element, projection }) => {\n if (\n beforeElementsSet.has(element) &&\n projection.resumeFrom &&\n !projection.resumeFrom.instance &&\n !projection.isLead()\n ) {\n projection.resumeFrom = undefined\n projection.snapshot = undefined\n }\n })\n }\n}\n\nexport function parseAnimateLayoutArgs(\n scopeOrUpdateDom: ElementOrSelector | (() => void),\n updateDomOrOptions?: (() => void) | AnimationOptions,\n options?: AnimationOptions\n): {\n scope: Element | Document\n updateDom: () => void\n defaultOptions?: AnimationOptions\n} {\n // animateLayout(updateDom)\n if (typeof scopeOrUpdateDom === \"function\") {\n return {\n scope: document,\n updateDom: scopeOrUpdateDom,\n defaultOptions: updateDomOrOptions as AnimationOptions | undefined,\n }\n }\n\n // animateLayout(scope, updateDom, options?)\n const elements = resolveElements(scopeOrUpdateDom)\n const scope = elements[0] || document\n\n return {\n scope,\n updateDom: updateDomOrOptions as () => void,\n defaultOptions: options,\n }\n}\n\nfunction collectLayoutElements(scope: LayoutAnimationScope): Element[] {\n const elements = Array.from(scope.querySelectorAll(layoutSelector))\n\n if (scope instanceof Element && scope.matches(layoutSelector)) {\n if (!elements.includes(scope)) {\n elements.unshift(scope)\n }\n }\n\n return elements\n}\n\nfunction readLayoutAttributes(element: Element): LayoutAttributes {\n const layoutId = element.getAttribute(\"data-layout-id\") || undefined\n const rawLayout = element.getAttribute(\"data-layout\")\n let layout: LayoutAttributes[\"layout\"]\n\n if (rawLayout === \"\" || rawLayout === \"true\") {\n layout = true\n } else if (rawLayout) {\n layout = rawLayout as LayoutAttributes[\"layout\"]\n }\n\n return {\n layout,\n layoutId,\n }\n}\n\nfunction createVisualState() {\n return {\n latestValues: {},\n renderState: {\n transform: {},\n transformOrigin: {},\n style: {},\n vars: {},\n },\n }\n}\n\nfunction getOrCreateRecord(\n element: Element,\n parentProjection?: IProjectionNode,\n projectionOptions?: ProjectionOptions\n): LayoutElementRecord {\n const existing = visualElementStore.get(element) as VisualElement | undefined\n const visualElement =\n existing ??\n new HTMLVisualElement(\n {\n props: {},\n presenceContext: null,\n visualState: createVisualState(),\n },\n { allowProjection: true }\n )\n\n if (!existing || !visualElement.projection) {\n visualElement.projection = new HTMLProjectionNode(\n visualElement.latestValues,\n parentProjection\n )\n }\n\n visualElement.projection.setOptions({\n ...projectionOptions,\n visualElement,\n })\n\n if (!visualElement.current) {\n visualElement.mount(element as HTMLElement)\n } else if (!visualElement.projection.instance) {\n // Mount projection if VisualElement is already mounted but projection isn't\n // This happens when animate() was called before animateLayout()\n visualElement.projection.mount(element as HTMLElement)\n }\n\n if (!existing) {\n visualElementStore.set(element, visualElement)\n }\n\n return {\n element,\n visualElement,\n projection: visualElement.projection as IProjectionNode,\n }\n}\n\nfunction findParentRecord(\n element: Element,\n recordMap: Map,\n scope: LayoutAnimationScope\n) {\n let parent = element.parentElement\n\n while (parent) {\n const record = recordMap.get(parent)\n if (record) return record\n\n if (parent === scope) break\n parent = parent.parentElement\n }\n\n return undefined\n}\n\nfunction getProjectionRoot(\n afterRecords: LayoutElementRecord[],\n beforeRecords: LayoutElementRecord[]\n) {\n const record = afterRecords[0] || beforeRecords[0]\n return record?.projection.root\n}\n\nfunction collectAnimations(afterRecords: LayoutElementRecord[]) {\n const animations = new Set()\n\n afterRecords.forEach((record) => {\n const animation = record.projection.currentAnimation\n if (animation) animations.add(animation)\n })\n\n return Array.from(animations)\n}\n"],"names":[],"mappings":";;;;;;;;;AAyCA,MAAM,cAAc,GAAG,iCAAiC;AACxD,MAAM,IAAI,GAAG,MAAK,EAAE,CAAC;AACrB,SAAS,kBAAkB,CAAC,UAA2B,EAAA;IACnD,MAAM,MAAM,GAAG,UAAU,CAAC,oBAAoB,IAAI,UAAU,CAAC,MAAM;AACnE,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,SAAS;AAE7B,IAAA,MAAM,WAAW,GAAG,SAAS,EAAE;AAC/B,IAAA,MAAM,SAAS,GAAG,SAAS,EAAE;AAC7B,IAAA,WAAW,CAAC,WAAW,EAAE,MAAa,CAAC;AACvC,IAAA,WAAW,CAAC,SAAS,EAAE,MAAa,CAAC;IAErC,OAAO;AACH,QAAA,WAAW,EAAE,UAAU,CAAC,IA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