{"version":3,"file":"notify-inspector.mjs","sources":["../../../../src/animation/utils/notify-inspector.ts"],"sourcesContent":["import { frameData } from \"../../frameloop/frame-data\"\nimport { time } from \"../../frameloop/sync-time\"\n\ninterface MotionInspectBase {\n animation: unknown\n timestamp: number\n frameTimestamp: number\n frameIsProcessing: boolean\n}\n\ninterface MotionInspectAnimationStart extends MotionInspectBase {\n kind: \"animation-start\"\n options: object\n}\n\ninterface MotionInspectLayoutAnimationStart extends MotionInspectBase {\n kind: \"layout-animation-start\"\n node: unknown\n}\n\ntype MotionInspectRecord =\n | MotionInspectAnimationStart\n | MotionInspectLayoutAnimationStart\n\ntype MotionInspectHook = (record: MotionInspectRecord) => void\n\ntype InspectGlobal = typeof globalThis & {\n __MOTION_INSPECT__?: MotionInspectHook\n}\n\nfunction baseRecord(\n kind: K,\n animation: unknown\n) {\n return {\n kind,\n animation,\n timestamp: time.now(),\n frameTimestamp: frameData.timestamp,\n frameIsProcessing: frameData.isProcessing,\n }\n}\n\n/**\n * Notify an optional inspector without adding a public Motion API.\n *\n * The record is a raw firehose: the live animation handle, the concrete\n * animation's internal options object untouched (timing fields in\n * internal milliseconds, name/keyframes/element/motionValue still\n * attached), a timestamp and the raw frameloop state at notify time.\n * All interpretation belongs to the consumer behind\n * globalThis.__MOTION_INSPECT__.\n */\nexport function notifyAnimationStart(\n animation: unknown,\n options: object,\n transition?: object\n): void {\n const notify = (globalThis as InspectGlobal).__MOTION_INSPECT__\n if (!notify) return\n\n try {\n notify({\n ...baseRecord(\"animation-start\", animation),\n options: transition ? { ...options, ...transition } : options,\n })\n } catch {}\n}\n\n/**\n * Layout animations drive a projection node's progress rather than a\n * property, so the record forwards the live node itself: it carries the\n * DOM instance, the layout options (layoutId) and the progress handle.\n * Fired inside the frame.update that starts the animation, so nodes\n * animating in the same layout commit share frameTimestamp.\n */\nexport function notifyLayoutAnimationStart(\n animation: unknown,\n node: unknown\n): void {\n const notify = (globalThis as InspectGlobal).__MOTION_INSPECT__\n if (!notify) return\n\n try {\n notify({\n ...baseRecord(\"layout-animation-start\", animation),\n node,\n })\n } catch {}\n}\n"],"names":[],"mappings":";;;AA8BA,SAAS,UAAU,CACf,IAAO,EACP,SAAkB,EAAA;IAElB,OAAO;QACH,IAAI;QACJ,SAAS;AACT,QAAA,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,cAAc,EAAE,SAAS,CAAC,SAAS;QACnC,iBAAiB,EAAE,SAAS,CAAC,YAAY;KAC5C;AACL;AAEA;;;;;;;;;AASG;SACa,oBAAoB,CAChC,SAAkB,EAClB,OAAe,EACf,UAAmB,EAAA;AAEnB,IAAA,MAAM,MAAM,GAAI,UAA4B,CAAC,kBAAkB;AAC/D,IAAA,IAAI,CAAC,MAAM;QAAE;AAEb,IAAA,IAAI;AACA,QAAA,MAAM,CAAC;AACH,YAAA,GAAG,UAAU,CAAC,iBAAiB,EAAE,SAAS,CAAC;AAC3C,YAAA,OAAO,EAAE,UAAU,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO;AAChE,SAAA,CAAC;IACN;IAAE,MAAM,EAAC;AACb;AAEA;;;;;;AAMG;AACG,SAAU,0BAA0B,CACtC,SAAkB,EAClB,IAAa,EAAA;AAEb,IAAA,MAAM,MAAM,GAAI,UAA4B,CAAC,kBAAkB;AAC/D,IAAA,IAAI,CAAC,MAAM;QAAE;AAEb,IAAA,IAAI;AACA,QAAA,MAAM,CAAC;AACH,YAAA,GAAG,UAAU,CAAC,wBAAwB,EAAE,SAAS,CAAC;YAClD,IAAI;AACP,SAAA,CAAC;IACN;IAAE,MAAM,EAAC;AACb;;;;"}