cineview 0.0.1-beta

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 (128) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +102 -0
  3. package/README.zh-CN.md +102 -0
  4. package/dist/animations/animationParser.d.ts +24 -0
  5. package/dist/animations/composer.d.ts +13 -0
  6. package/dist/animations/presets/blink.d.ts +18 -0
  7. package/dist/animations/presets/blur.d.ts +18 -0
  8. package/dist/animations/presets/bounce.d.ts +18 -0
  9. package/dist/animations/presets/elastic.d.ts +23 -0
  10. package/dist/animations/presets/fade.d.ts +18 -0
  11. package/dist/animations/presets/flip.d.ts +18 -0
  12. package/dist/animations/presets/index.d.ts +38 -0
  13. package/dist/animations/presets/rotate.d.ts +23 -0
  14. package/dist/animations/presets/shake.d.ts +28 -0
  15. package/dist/animations/presets/slide.d.ts +23 -0
  16. package/dist/animations/presets/special.d.ts +38 -0
  17. package/dist/animations/presets/zoom.d.ts +23 -0
  18. package/dist/animations/registry.d.ts +51 -0
  19. package/dist/artifacts.json +40 -0
  20. package/dist/blink-BGmsrTwW.mjs +81 -0
  21. package/dist/blur-CQoB_VWp.mjs +52 -0
  22. package/dist/bounce-B_QJxgOq.mjs +64 -0
  23. package/dist/cineview-dev.css +2 -0
  24. package/dist/cineview-dev.es.mjs +2 -0
  25. package/dist/cineview-drag.umd.js +2 -0
  26. package/dist/cineview-scroll.umd.js +2 -0
  27. package/dist/cineview.es.mjs +2 -0
  28. package/dist/cineview.umd.js +2 -0
  29. package/dist/components/Animate/Animate.d.ts +67 -0
  30. package/dist/components/Animate/AnimateRenderBridge.d.ts +16 -0
  31. package/dist/components/Animate/AnimateVideo.d.ts +59 -0
  32. package/dist/components/Animate/StaggerContainer.d.ts +35 -0
  33. package/dist/components/Animate/__fixtures__/animate-media-public-path.fixture.d.ts +1 -0
  34. package/dist/components/Animate/animateInterpolation.d.ts +41 -0
  35. package/dist/components/Animate/animateRenderState.d.ts +23 -0
  36. package/dist/components/Animate/animateSemantics.d.ts +38 -0
  37. package/dist/components/Animate/animateTimeline.d.ts +14 -0
  38. package/dist/components/Animate/dragVisualState.d.ts +26 -0
  39. package/dist/components/Animate/index.d.ts +6 -0
  40. package/dist/components/Animate/useAnimateArrival.d.ts +35 -0
  41. package/dist/components/Animate/useAnimateDrag.d.ts +34 -0
  42. package/dist/components/Animate/useAnimatePublicTimeline.d.ts +16 -0
  43. package/dist/components/Animate/useAnimateScroll.d.ts +83 -0
  44. package/dist/components/Animate/useAnimatedPropertyLanes.d.ts +30 -0
  45. package/dist/components/Animate/visibilityScheduler.d.ts +12 -0
  46. package/dist/components/Cineview/Cineview.d.ts +46 -0
  47. package/dist/components/Cineview/CineviewDispatch.d.ts +2 -0
  48. package/dist/components/Cineview/DirectScrollCineview.d.ts +8 -0
  49. package/dist/components/Cineview/DragSceneStack.d.ts +55 -0
  50. package/dist/components/Cineview/ScrollSceneSlot.d.ts +42 -0
  51. package/dist/components/Cineview/ScrollSceneStack.d.ts +13 -0
  52. package/dist/components/Cineview/ScrollbarOverlay.d.ts +24 -0
  53. package/dist/components/Cineview/directScrollHelpers.d.ts +77 -0
  54. package/dist/components/Cineview/index.d.ts +5 -0
  55. package/dist/components/Cineview/preloadTargets.d.ts +18 -0
  56. package/dist/components/Cineview/regroupCallbacks.d.ts +10 -0
  57. package/dist/components/Cineview/useCineviewImperativeApi.d.ts +21 -0
  58. package/dist/components/Cineview/useNativeScrollController.d.ts +38 -0
  59. package/dist/components/Cineview/useScrollInputBindings.d.ts +9 -0
  60. package/dist/components/Cineview/useScrollSceneLayout.d.ts +24 -0
  61. package/dist/components/Cineview/useScrollSceneSnapshots.d.ts +32 -0
  62. package/dist/components/Cineview/useScrollViewport.d.ts +20 -0
  63. package/dist/components/Cineview/useScrollZoneRegistry.d.ts +35 -0
  64. package/dist/components/Container/Container.d.ts +2 -0
  65. package/dist/components/Container/index.d.ts +1 -0
  66. package/dist/components/Image/Image.d.ts +12 -0
  67. package/dist/components/Image/index.d.ts +2 -0
  68. package/dist/components/Position/Position.d.ts +13 -0
  69. package/dist/components/Position/index.d.ts +1 -0
  70. package/dist/components/Scene/Scene.d.ts +10 -0
  71. package/dist/components/Scene/SceneFixedLayer.d.ts +14 -0
  72. package/dist/components/Scene/__fixtures__/scene-grouped-public-path.fixture.d.ts +1 -0
  73. package/dist/components/Scene/dragPreparedState.d.ts +49 -0
  74. package/dist/components/Scene/helpers.d.ts +101 -0
  75. package/dist/components/Scene/index.d.ts +1 -0
  76. package/dist/components/Scene/sceneScrollBudget.d.ts +38 -0
  77. package/dist/components/Scene/sceneScrollRuntime.d.ts +65 -0
  78. package/dist/components/Scene/types.d.ts +189 -0
  79. package/dist/components/Scene/useDragSceneEngine.d.ts +67 -0
  80. package/dist/components/Scene/useElementTrack.d.ts +82 -0
  81. package/dist/components/Scene/useNativePointerDrag.d.ts +25 -0
  82. package/dist/components/Scene/useSceneAnimationRegistry.d.ts +56 -0
  83. package/dist/components/Scene/useScenePointerInput.d.ts +28 -0
  84. package/dist/components/Scene/useSceneRuntimeState.d.ts +17 -0
  85. package/dist/components/Scene/useSceneScrollTakeover.d.ts +13 -0
  86. package/dist/components/Scene/useScrollSceneEngine.d.ts +28 -0
  87. package/dist/components/runtime/runtimeContext.d.ts +14 -0
  88. package/dist/components/runtime/scrollExternalStore.d.ts +13 -0
  89. package/dist/components/runtime/scrollSceneFrameStore.d.ts +29 -0
  90. package/dist/context/CineviewContext.d.ts +25 -0
  91. package/dist/dev/PerfPanel.d.ts +16 -0
  92. package/dist/dev/index.d.ts +14 -0
  93. package/dist/dev/usePerfMonitor.d.ts +9 -0
  94. package/dist/drag-scene-engine-y8Wj9ivV.mjs +270 -0
  95. package/dist/elastic-CBP_FdRv.mjs +129 -0
  96. package/dist/element-track-Du10P12_.mjs +316 -0
  97. package/dist/entry-drag.d.ts +14 -0
  98. package/dist/entry-scroll.d.ts +14 -0
  99. package/dist/fade-DXxFsgxR.mjs +22 -0
  100. package/dist/flip-CrCoNIws.mjs +49 -0
  101. package/dist/hooks/imagePreloadCache.d.ts +4 -0
  102. package/dist/hooks/mediaPreloadCache.d.ts +31 -0
  103. package/dist/hooks/useFirstSceneEnter.d.ts +65 -0
  104. package/dist/hooks/useImagePreloader.d.ts +31 -0
  105. package/dist/hooks/usePrefersReducedMotion.d.ts +12 -0
  106. package/dist/hooks/useSceneManager.d.ts +79 -0
  107. package/dist/index.d.ts +17 -0
  108. package/dist/media/VideoFrameRenderer.d.ts +48 -0
  109. package/dist/media/videoPlaybackOwnership.d.ts +63 -0
  110. package/dist/performance-monitor-AlOOwzY_.mjs +73 -0
  111. package/dist/public-api.d.ts +12 -0
  112. package/dist/rotate-BMEBKDk5.mjs +69 -0
  113. package/dist/scene-animation-registry-8b0m_IaZ.mjs +422 -0
  114. package/dist/shake-BV6SdR9O.mjs +171 -0
  115. package/dist/slide-DWmVtj0L.mjs +63 -0
  116. package/dist/special-DDz8BopB.mjs +224 -0
  117. package/dist/types/index.d.ts +552 -0
  118. package/dist/utils/animationHelpers.d.ts +15 -0
  119. package/dist/utils/debounce.d.ts +18 -0
  120. package/dist/utils/devLog.d.ts +16 -0
  121. package/dist/utils/dragTimelineMapping.d.ts +30 -0
  122. package/dist/utils/gestureDetector.d.ts +67 -0
  123. package/dist/utils/performanceMonitor.d.ts +66 -0
  124. package/dist/utils/styleConvert.d.ts +7 -0
  125. package/dist/utils/useIsomorphicLayoutEffect.d.ts +22 -0
  126. package/dist/utils/useStructurallyStableValue.d.ts +5 -0
  127. package/dist/zoom-CuAthpqd.mjs +63 -0
  128. package/package.json +171 -0
@@ -0,0 +1,48 @@
1
+ import { CSSProperties, FormEventHandler, MutableRefObject, ReactEventHandler } from 'react';
2
+ import { MotionValue } from 'framer-motion';
3
+ import { AnimateTimelineFrame } from '../types';
4
+ type VideoEventHandler = ReactEventHandler<HTMLVideoElement>;
5
+ type VideoErrorHandler = FormEventHandler<HTMLVideoElement>;
6
+ /**
7
+ * Imperative media-residency control for scroll-driven scrub videos
8
+ * (AnimateVideo `releaseOnLeave`, task-flow 2026-08-14 Plan A).
9
+ *
10
+ * Decoded video frames and GPU textures stay resident after a `<video>` has
11
+ * been scrubbed through, and the compositor pressure they create measurably
12
+ * drops frames in *other* scenes once the viewer scrolls past (probe evidence:
13
+ * `site/scripts/_rv-video-residency.mjs`). This handle lets the owner drop
14
+ * that residency once the zone is far away and restore it before return:
15
+ *
16
+ * - `release()`: pause + drop `src` + `load()` — the browser discards decoded
17
+ * frames/buffer. The blob URL lease is *kept* so warm-up costs no network.
18
+ * - `warmUp()`: re-attach `src` (blob already in memory) and bump the media
19
+ * epoch — pending scrub seeks re-arm on the next `loadedmetadata` and catch
20
+ * up to the current timeline position.
21
+ */
22
+ export interface VideoFrameRendererControl {
23
+ release(): void;
24
+ warmUp(): void;
25
+ }
26
+ export interface VideoFrameRendererProps {
27
+ src: string;
28
+ /** Legacy progress-only input. Atomic timelineFrame takes ownership when supplied. */
29
+ progress: number | MotionValue<number>;
30
+ timelineFrame?: MotionValue<AnimateTimelineFrame>;
31
+ scrubRange?: readonly [fromSeconds: number, toSeconds: number];
32
+ width?: number | string;
33
+ height?: number | string;
34
+ style?: CSSProperties;
35
+ 'aria-label'?: string;
36
+ preload?: boolean;
37
+ poster?: string;
38
+ playbackRate?: number;
39
+ onEnded?: VideoEventHandler;
40
+ onPlay?: VideoEventHandler;
41
+ onPause?: VideoEventHandler;
42
+ onTimeUpdate?: VideoEventHandler;
43
+ onError?: VideoErrorHandler;
44
+ /** Optional imperative release/warm-up handle (see VideoFrameRendererControl). */
45
+ controlRef?: MutableRefObject<VideoFrameRendererControl | null>;
46
+ }
47
+ export declare const VideoFrameRenderer: import('react').ForwardRefExoticComponent<VideoFrameRendererProps & import('react').RefAttributes<HTMLVideoElement>>;
48
+ export {};
@@ -0,0 +1,63 @@
1
+ import { AnimateTimelineFrame } from '../types';
2
+ export type VideoPlaybackOwnershipStatus = 'framework-scrub' | 'play-pending' | 'native-playback' | 'native-paused' | 'play-rejected' | 'ended';
3
+ export interface VideoPlaybackOwnershipState {
4
+ readonly activationId: number;
5
+ readonly status: VideoPlaybackOwnershipStatus;
6
+ readonly activePlayRequestId: number | null;
7
+ /** Most recent framework play request whose promise/event may still arrive. */
8
+ readonly settledPlayRequestId: number | null;
9
+ readonly nextPlayRequestId: number;
10
+ readonly lastSeekTime: number | null;
11
+ readonly endpointLatched: boolean;
12
+ readonly outgoingLatched: boolean;
13
+ /** Blocks untagged late play events after framework has reclaimed scrub ownership. */
14
+ readonly frameworkPlayBlocked: boolean;
15
+ /** The next native pause event acknowledges a framework-issued pause command. */
16
+ readonly frameworkPausePending: boolean;
17
+ }
18
+ export type VideoPlaybackOwnershipCommand = {
19
+ readonly type: 'pause';
20
+ } | {
21
+ readonly type: 'seek';
22
+ readonly time: number;
23
+ } | {
24
+ readonly type: 'play';
25
+ readonly requestId: number;
26
+ };
27
+ interface TimelineFrameEvent {
28
+ readonly type: 'timeline-frame';
29
+ readonly frame: AnimateTimelineFrame;
30
+ readonly duration: number;
31
+ readonly scrubRange?: readonly [fromSeconds: number, toSeconds: number];
32
+ }
33
+ export type VideoPlaybackOwnershipEvent = TimelineFrameEvent | {
34
+ readonly type: 'media-play';
35
+ readonly requestId?: number;
36
+ readonly activationId: number;
37
+ } | {
38
+ readonly type: 'media-pause';
39
+ readonly activationId: number;
40
+ } | {
41
+ readonly type: 'media-ended';
42
+ readonly activationId: number;
43
+ } | {
44
+ readonly type: 'play-resolved';
45
+ readonly requestId: number;
46
+ } | {
47
+ readonly type: 'play-rejected';
48
+ readonly requestId: number;
49
+ } | {
50
+ readonly type: 'activate';
51
+ readonly activationId: number;
52
+ } | {
53
+ readonly type: 'reset';
54
+ readonly activationId: number;
55
+ };
56
+ export interface VideoPlaybackOwnershipResult {
57
+ readonly state: VideoPlaybackOwnershipState;
58
+ readonly commands: readonly VideoPlaybackOwnershipCommand[];
59
+ }
60
+ export declare function mapVideoScrubProgress(progress: number, duration: number, scrubRange?: readonly [fromSeconds: number, toSeconds: number]): number | null;
61
+ export declare function createVideoPlaybackOwnershipState(activationId: number): VideoPlaybackOwnershipState;
62
+ export declare function reduceVideoPlaybackOwnership(state: VideoPlaybackOwnershipState, event: VideoPlaybackOwnershipEvent): VideoPlaybackOwnershipResult;
63
+ export {};
@@ -0,0 +1,73 @@
1
+ var l = class {
2
+ constructor() {
3
+ this.frameCount = 0, this.lastTime = performance.now(), this.frameTimes = [], this.memorySamples = [], this.lastMemorySampleTime = 0, this.cachedMemoryUsage = void 0, this.cachedBundleSizeKb = 0, this.rafId = null, this.isMonitoring = !1, this.measure = () => {
4
+ if (!this.isMonitoring) return;
5
+ const e = performance.now(), s = e - this.lastTime;
6
+ this.frameCount++, this.frameTimes.push(s), this.frameTimes.length > 60 && this.frameTimes.shift(), this.sampleMemory(e), this.lastTime = e, this.rafId = requestAnimationFrame(this.measure);
7
+ };
8
+ }
9
+ start() {
10
+ this.isMonitoring || (this.isMonitoring = !0, this.frameCount = 0, this.lastTime = performance.now(), this.frameTimes = [], this.memorySamples = [], this.lastMemorySampleTime = 0, this.cachedMemoryUsage = void 0, this.cachedBundleSizeKb = this.estimateBundleSizeKb(), this.measure());
11
+ }
12
+ stop() {
13
+ this.isMonitoring = !1, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
14
+ }
15
+ getMetrics() {
16
+ const e = this.calculateAvgFrameTime();
17
+ if (this.frameTimes.length === 0) return {
18
+ fps: 0,
19
+ avgFrameTime: 0,
20
+ memoryUsage: this.getMemoryUsage(),
21
+ bundleSize: this.getBundleSizeKb()
22
+ };
23
+ const s = 1e3 / Math.max(e, 1);
24
+ return {
25
+ fps: Math.round(Math.min(Math.max(s, 0), 60) * 10) / 10,
26
+ avgFrameTime: Math.round(e * 100) / 100,
27
+ memoryUsage: this.getMemoryUsage(),
28
+ bundleSize: this.getBundleSizeKb()
29
+ };
30
+ }
31
+ calculateAvgFrameTime() {
32
+ return this.frameTimes.length === 0 ? 0 : this.frameTimes.reduce((e, s) => e + s, 0) / this.frameTimes.length;
33
+ }
34
+ getMemoryUsage() {
35
+ return this.sampleMemory(performance.now(), this.cachedMemoryUsage === void 0), this.cachedMemoryUsage;
36
+ }
37
+ sampleMemory(e, s = !1) {
38
+ if (!performance.memory) {
39
+ this.cachedMemoryUsage = void 0, this.memorySamples = [];
40
+ return;
41
+ }
42
+ if (!s && e - this.lastMemorySampleTime < 1e3) return;
43
+ const a = performance.memory.usedJSHeapSize / 1048576;
44
+ this.memorySamples.push(a), this.memorySamples.length > 8 && this.memorySamples.shift();
45
+ const i = [...this.memorySamples].sort((o, h) => o - h), t = Math.floor(i.length / 2), n = i.length % 2 === 0 ? (i[t - 1] + i[t]) / 2 : i[t];
46
+ this.cachedMemoryUsage = Math.round(n * 10) / 10, this.lastMemorySampleTime = e;
47
+ }
48
+ getBundleSizeKb() {
49
+ return this.cachedBundleSizeKb > 0 ? this.cachedBundleSizeKb : (this.cachedBundleSizeKb = this.estimateBundleSizeKb(), this.cachedBundleSizeKb);
50
+ }
51
+ estimateBundleSizeKb() {
52
+ if (typeof performance > "u" || typeof performance.getEntriesByType != "function") return 0;
53
+ const e = performance.getEntriesByType("resource");
54
+ if (e.length === 0) return 0;
55
+ const s = e.reduce((a, i) => {
56
+ const t = i.name.toLowerCase();
57
+ return t.endsWith(".js") || t.endsWith(".mjs") || t.endsWith(".css") || t.includes(".js?") || t.includes(".mjs?") || t.includes(".css?") ? a + Math.max(i.decodedBodySize || 0, i.transferSize || 0) : a;
58
+ }, 0);
59
+ return Math.round(s / 1024 * 10) / 10;
60
+ }
61
+ }, m = new l(), r = 0, c = m, u = () => {
62
+ r += 1, r === 1 && m.start();
63
+ let e = !1;
64
+ return () => {
65
+ e || (e = !0, r = Math.max(r - 1, 0), r === 0 && m.stop());
66
+ };
67
+ };
68
+ export {
69
+ c as n,
70
+ u as t
71
+ };
72
+
73
+ //# sourceMappingURL=performance-monitor-AlOOwzY_.mjs.map
@@ -0,0 +1,12 @@
1
+ import { ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
2
+ import { AnimateProps, PositionProps, SceneProps } from './types';
3
+ export { useAnimateTimeline } from './components/Animate';
4
+ export { Container } from './components/Container';
5
+ export { Image } from './components/Image';
6
+ export type { ImageProps } from './components/Image';
7
+ export { AnimateVideo } from './components/Animate/AnimateVideo';
8
+ export type { AnimateVideoProps } from './components/Animate/AnimateVideo';
9
+ export declare const Animate: (props: AnimateProps) => ReactNode;
10
+ export declare const Position: ForwardRefExoticComponent<PositionProps & RefAttributes<HTMLDivElement>>;
11
+ export declare const Scene: ForwardRefExoticComponent<SceneProps & RefAttributes<HTMLDivElement>>;
12
+ export type { SlideDirection, ScrollMode, SceneAnchor, SceneStackMode, DragThresholdConfig, DragTimelineUnit, SceneDragConfig, DragModeConfig, ScrollModeConfig, ScrollbarConfig, A11yConfig, SceneChangeDetail, CineviewErrorCode, CineviewErrorDetail, DragDetail, DragStartDetail, DragBlockedDetail, DragEndDetail, ZoneDetail, ZoneProgressDetail, SceneVisibilityDetail, CineviewCommonCallbacks, CineviewDragCallbacks, CineviewScrollCallbacks, DragModeCallbacks, ScrollModeCallbacks, CineviewCallbacks, PresetAnimation, CustomAnimation, ComposedAnimation, AnimationType, CineviewBaseProps, CineviewDragModeProps, CineviewScrollModeProps, CineviewProps, PerformanceMetrics, CineviewRef, CineviewScrollRef, CineviewPreloadTarget, AnimateProps, AnimateStaggerConfig, AnimateRenderState, AnimatePhase, AnimateTimelineLane, AnimateTimelineSource, AnimateTimelineFrame, AnimateTimeline, PositionProps, ContainerProps, SceneProps, } from './types';
@@ -0,0 +1,69 @@
1
+ var t = {
2
+ rotate: {
3
+ initial: {
4
+ rotate: -180,
5
+ opacity: 0
6
+ },
7
+ animate: {
8
+ rotate: 0,
9
+ opacity: 1
10
+ },
11
+ exit: {
12
+ rotate: 180,
13
+ opacity: 0
14
+ }
15
+ },
16
+ "rotate-in": {
17
+ initial: {
18
+ rotate: -180,
19
+ scale: 0,
20
+ opacity: 0
21
+ },
22
+ animate: {
23
+ rotate: 0,
24
+ scale: 1,
25
+ opacity: 1
26
+ },
27
+ exit: {
28
+ rotate: 0,
29
+ scale: 1,
30
+ opacity: 1
31
+ }
32
+ },
33
+ "rotate-out": {
34
+ initial: {
35
+ rotate: 0,
36
+ scale: 1,
37
+ opacity: 1
38
+ },
39
+ animate: {
40
+ rotate: 0,
41
+ scale: 1,
42
+ opacity: 1
43
+ },
44
+ exit: {
45
+ rotate: 180,
46
+ scale: 0,
47
+ opacity: 0
48
+ }
49
+ },
50
+ spin: {
51
+ initial: {
52
+ rotate: 0,
53
+ opacity: 0
54
+ },
55
+ animate: {
56
+ rotate: 360,
57
+ opacity: 1
58
+ },
59
+ exit: {
60
+ rotate: 720,
61
+ opacity: 0
62
+ }
63
+ }
64
+ };
65
+ export {
66
+ t as rotateAnimations
67
+ };
68
+
69
+ //# sourceMappingURL=rotate-BMEBKDk5.mjs.map
@@ -0,0 +1,422 @@
1
+ import { useCallback as p, useEffect as Q, useRef as y, useState as X } from "react";
2
+ function de(...e) {
3
+ }
4
+ function $e(...e) {
5
+ }
6
+ function we(e, ...a) {
7
+ }
8
+ function B(e, a) {
9
+ return e === a || e === "visibility" && a === "scroll";
10
+ }
11
+ var fe = class {
12
+ constructor(e) {
13
+ this.source = new Map(e), Object.freeze(this);
14
+ }
15
+ get size() {
16
+ return this.source.size;
17
+ }
18
+ get(e) {
19
+ return this.source.get(e);
20
+ }
21
+ has(e) {
22
+ return this.source.has(e);
23
+ }
24
+ forEach(e, a) {
25
+ this.source.forEach((i, s) => e.call(a, i, s, this));
26
+ }
27
+ entries() {
28
+ return this.source.entries();
29
+ }
30
+ keys() {
31
+ return this.source.keys();
32
+ }
33
+ values() {
34
+ return this.source.values();
35
+ }
36
+ [Symbol.iterator]() {
37
+ return this.entries();
38
+ }
39
+ get [Symbol.toStringTag]() {
40
+ return "ImmutableMapView";
41
+ }
42
+ };
43
+ function Z(e) {
44
+ return new fe(e);
45
+ }
46
+ function pe(e) {
47
+ const a = [];
48
+ return e.registrations.forEach((i, s) => {
49
+ a.push([s, Object.freeze({ ...i })]);
50
+ }), Object.freeze({
51
+ registrations: Z(a),
52
+ calculatedDelays: Z(e.calculatedDelays),
53
+ issues: Object.freeze([...e.issues]),
54
+ timelineDuration: e.timelineDuration
55
+ });
56
+ }
57
+ function ee(e) {
58
+ switch (e.type) {
59
+ case "missing-dependency":
60
+ return `${e.type}:${e.animateId}:${e.after}`;
61
+ case "circular-dependency":
62
+ return `${e.type}:${e.animateId}:${e.cycle.join(">")}`;
63
+ case "duplicate-id":
64
+ return `${e.type}:${e.animateId}`;
65
+ case "incompatible-lane":
66
+ return `${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`;
67
+ }
68
+ }
69
+ function b(e, a) {
70
+ const i = ee(a);
71
+ e.some((s) => ee(s) === i) || e.push(a);
72
+ }
73
+ function ye(e) {
74
+ const a = e.slice(0, -1);
75
+ let i = 0;
76
+ for (let l = 1; l < a.length; l += 1) a[l] < a[i] && (i = l);
77
+ const s = a.slice(i).concat(a.slice(0, i));
78
+ return s.concat(s[0]);
79
+ }
80
+ function te({ baseDuration: e, registrations: a, declaredLanes: i = /* @__PURE__ */ new Map(), duplicateIds: s = [] }) {
81
+ const l = /* @__PURE__ */ new Map(), m = [], w = /* @__PURE__ */ new Set(), D = /* @__PURE__ */ new Set();
82
+ Array.from(s).forEach((o) => {
83
+ b(m, {
84
+ type: "duplicate-id",
85
+ animateId: o
86
+ });
87
+ });
88
+ const I = (o, d) => {
89
+ const $ = l.get(o);
90
+ if ($ !== void 0) return $;
91
+ const f = a.get(o);
92
+ if (w.has(o)) {
93
+ const k = d.indexOf(o), R = ye(d.slice(k).concat(o));
94
+ return R.slice(0, -1).forEach((A) => D.add(A)), b(m, {
95
+ type: "circular-dependency",
96
+ animateId: R[0],
97
+ cycle: R
98
+ }), l.set(o, f.delay), f.delay;
99
+ }
100
+ w.add(o);
101
+ let v = f.delay;
102
+ if (f.after) {
103
+ const k = a.get(f.after), R = i.get(f.after);
104
+ if (!k)
105
+ f.lane !== void 0 && R !== void 0 && !B(f.lane, R) ? b(m, {
106
+ type: "incompatible-lane",
107
+ animateId: o,
108
+ after: f.after,
109
+ followerLane: f.lane,
110
+ leaderLane: R
111
+ }) : b(m, {
112
+ type: "missing-dependency",
113
+ animateId: o,
114
+ after: f.after
115
+ });
116
+ else if (f.lane !== void 0 && k.lane !== void 0 && !B(f.lane, k.lane)) b(m, {
117
+ type: "incompatible-lane",
118
+ animateId: o,
119
+ after: f.after,
120
+ followerLane: f.lane,
121
+ leaderLane: k.lane
122
+ });
123
+ else {
124
+ const A = I(f.after, d.concat(o));
125
+ !(f.lane === "visibility" && k.lane === "scroll") && !D.has(o) && (v += A + k.duration);
126
+ }
127
+ }
128
+ return w.delete(o), l.set(o, v), v;
129
+ };
130
+ a.forEach((o, d) => {
131
+ I(d, []);
132
+ });
133
+ let L = Math.max(e, 0);
134
+ return a.forEach((o, d) => {
135
+ const $ = l.get(d);
136
+ L = Math.max(L, $ + o.duration);
137
+ }), {
138
+ registrations: new Map(a),
139
+ calculatedDelays: l,
140
+ issues: m,
141
+ timelineDuration: L
142
+ };
143
+ }
144
+ function _(e) {
145
+ switch (e.type) {
146
+ case "missing-dependency":
147
+ return `${e.type}:${e.animateId}:${e.after}`;
148
+ case "circular-dependency":
149
+ return `${e.type}:${e.animateId}:${e.cycle.join(">")}`;
150
+ case "duplicate-id":
151
+ return `${e.type}:${e.animateId}`;
152
+ case "incompatible-lane":
153
+ return `${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`;
154
+ }
155
+ }
156
+ function me(e) {
157
+ return e.kind === "invalid" ? `${e.kind}:${e.leaderId}:${e.reason}` : `${e.kind}:${e.leaderId ?? ""}:${e.generation ?? ""}:${e.kind === "satisfied" ? e.source : ""}`;
158
+ }
159
+ function j(e) {
160
+ let a;
161
+ return e.forEach((i) => {
162
+ a = i;
163
+ }), a;
164
+ }
165
+ function F(e, a, i = Object.is) {
166
+ if (e.size !== a.size) return !1;
167
+ for (const [s, l] of e) {
168
+ const m = a.get(s);
169
+ if (m === void 0 || !i(l, m)) return !1;
170
+ }
171
+ return !0;
172
+ }
173
+ function ge(e, a) {
174
+ return e.timelineDuration === a.timelineDuration && F(e.registrations, a.registrations, (i, s) => i.delay === s.delay && i.duration === s.duration && i.after === s.after && i.lane === s.lane) && F(e.calculatedDelays, a.calculatedDelays) && e.issues.length === a.issues.length && e.issues.every((i, s) => _(i) === _(a.issues[s]));
175
+ }
176
+ function ve({ sceneIndex: e, baseDuration: a, reportError: i, onStableSnapshot: s }) {
177
+ const l = y(/* @__PURE__ */ new Map()), m = y(/* @__PURE__ */ new Map()), w = y(/* @__PURE__ */ new Map()), D = y(/* @__PURE__ */ new Map()), I = y(/* @__PURE__ */ new Set()), L = y(te({
178
+ baseDuration: a,
179
+ registrations: w.current
180
+ })), o = y(/* @__PURE__ */ new Set()), d = y(null), $ = y(/* @__PURE__ */ new Map()), f = y(0), v = y(0), k = y(0), R = y(null), A = y(null), M = y(!0), P = y(i);
181
+ P.current = i;
182
+ const x = y(s);
183
+ x.current = s;
184
+ const K = y(a), [ne, re] = X(a), [ae, q] = X(!1), z = p(() => {
185
+ M.current && q(!1);
186
+ }, []), H = p((t) => {
187
+ t.forEach((n) => {
188
+ const r = _(n);
189
+ if (o.current.has(r)) return;
190
+ o.current.add(r);
191
+ let c, u;
192
+ n.type === "missing-dependency" ? (c = "INVALID_ANIMATION", u = `Animate "${n.animateId}" references non-existent component "${n.after}" via after in Scene ${e}.`) : n.type === "circular-dependency" ? (c = "CIRCULAR_DEPENDENCY", u = `Animate after chain contains a cycle in Scene ${e}: ${n.cycle.join(" -> ")}.`) : n.type === "duplicate-id" ? (c = "INVALID_COMPONENT_HIERARCHY", u = `More than one Animate component registered animateId "${n.animateId}" in Scene ${e}.`) : (c = "INVALID_ANIMATION", u = `Animate "${n.animateId}" uses ${n.followerLane} after "${n.after}" driven by ${n.leaderLane} in Scene ${e}; this dependency direction is incompatible.`), P.current?.({
193
+ code: c,
194
+ message: u,
195
+ context: { sceneIndex: e }
196
+ });
197
+ });
198
+ }, [e]), U = p(() => {
199
+ w.current.clear(), D.current.clear(), I.current.clear(), l.current.forEach((t, n) => {
200
+ const r = j(t);
201
+ r && w.current.set(n, r.info), t.size > 1 && I.current.add(n);
202
+ }), m.current.forEach((t, n) => {
203
+ let r;
204
+ t.forEach((c) => {
205
+ c.disposed || (r = c);
206
+ }), r && D.current.set(n, r.lane);
207
+ });
208
+ }, []), E = p(() => {
209
+ U();
210
+ const t = te({
211
+ baseDuration: a,
212
+ registrations: w.current,
213
+ declaredLanes: D.current,
214
+ duplicateIds: I.current
215
+ });
216
+ return L.current = t, K.current = t.timelineDuration, M.current && re((n) => n === t.timelineDuration ? n : t.timelineDuration), t;
217
+ }, [a, U]), Y = p((t) => L.current.issues.some((n) => n.type === "circular-dependency" && n.cycle.includes(t)), []), C = p((t, n) => {
218
+ const { follower: r, leaderId: c } = t, u = l.current.get(c), h = D.current.get(c);
219
+ if (!u || u.size === 0)
220
+ return n && h !== void 0 && r.info.lane !== void 0 && !B(r.info.lane, h) ? (t.sawLeader = !0, {
221
+ kind: "invalid",
222
+ leaderId: c,
223
+ reason: "incompatible-lane"
224
+ }) : n ? {
225
+ kind: "invalid",
226
+ leaderId: c,
227
+ reason: t.sawLeader ? "leader-unregistered" : "missing"
228
+ } : {
229
+ kind: "pending",
230
+ leaderId: c
231
+ };
232
+ t.sawLeader = !0;
233
+ const g = j(u);
234
+ return n && Y(r.id) ? {
235
+ kind: "invalid",
236
+ leaderId: c,
237
+ reason: "cycle"
238
+ } : n && u.size > 1 ? {
239
+ kind: "invalid",
240
+ leaderId: c,
241
+ reason: "duplicate"
242
+ } : n && r.info.lane !== void 0 && g.info.lane !== void 0 && !B(r.info.lane, g.info.lane) ? {
243
+ kind: "invalid",
244
+ leaderId: c,
245
+ reason: "incompatible-lane"
246
+ } : g.enterCompleted ? {
247
+ kind: "satisfied",
248
+ source: "completed",
249
+ leaderId: c,
250
+ generation: g.generation
251
+ } : {
252
+ kind: "pending",
253
+ leaderId: c,
254
+ generation: g.generation
255
+ };
256
+ }, [Y]), V = p((t, n) => {
257
+ if (t.terminal) return;
258
+ const r = me(n);
259
+ t.lastSignature !== r && (t.lastSignature = r, t.listener(n), n.kind !== "pending" && (t.terminal = !0));
260
+ }, []), O = p((t) => {
261
+ $.current.forEach((n) => {
262
+ [...n].forEach((r) => {
263
+ if (r.follower.disposed || r.terminal) {
264
+ n.delete(r);
265
+ return;
266
+ }
267
+ V(r, C(r, t)), r.terminal && n.delete(r);
268
+ });
269
+ }), $.current.forEach((n, r) => {
270
+ n.size === 0 && $.current.delete(r);
271
+ });
272
+ }, [V, C]), W = p((t) => {
273
+ if (v.current !== 0 || !M.current) return;
274
+ const n = /* @__PURE__ */ new Map();
275
+ l.current.forEach((h, g) => {
276
+ const J = j(h);
277
+ J?.enterVariant && n.set(g, J.enterVariant);
278
+ });
279
+ const r = R.current, c = A.current, u = r !== null && c !== null && ge(r, t) && F(c, n);
280
+ q(!0), !u && (k.current += 1, R.current = t, A.current = new Map(n), x.current?.(pe(t), k.current, n));
281
+ }, []), N = p(() => {
282
+ if (v.current !== 0 || !M.current) return;
283
+ d.current !== null && (clearTimeout(d.current), d.current = null);
284
+ const t = E();
285
+ H(t.issues), O(!0), W(t);
286
+ }, [
287
+ W,
288
+ E,
289
+ O,
290
+ H
291
+ ]), S = p(() => {
292
+ z(), d.current !== null && clearTimeout(d.current), d.current = setTimeout(() => {
293
+ d.current = null, N();
294
+ }, 0);
295
+ }, [N, z]), ce = p(() => {
296
+ v.current += 1, z();
297
+ let t = !1;
298
+ const n = () => t ? !1 : (t = !0, v.current = Math.max(0, v.current - 1), v.current === 0);
299
+ return {
300
+ complete: () => {
301
+ n() && N();
302
+ },
303
+ cancel: () => {
304
+ n() && S();
305
+ }
306
+ };
307
+ }, [
308
+ N,
309
+ z,
310
+ S
311
+ ]), G = p((t) => {
312
+ $.current.forEach((n, r) => {
313
+ n.forEach((c) => {
314
+ c.follower.token === t.token && n.delete(c);
315
+ }), n.size === 0 && $.current.delete(r);
316
+ });
317
+ }, []), T = p((t) => {
318
+ if (t.disposed) return;
319
+ t.disposed = !0, G(t);
320
+ const n = l.current.get(t.id);
321
+ n?.delete(t.token), n?.size === 0 && l.current.delete(t.id), E(), S();
322
+ }, [
323
+ E,
324
+ G,
325
+ S
326
+ ]), ie = p((t, n) => {
327
+ const r = {
328
+ token: Symbol(t),
329
+ id: t,
330
+ generation: ++f.current,
331
+ info: n,
332
+ enterVariant: null,
333
+ enterCompleted: !1,
334
+ disposed: !1
335
+ };
336
+ let c = l.current.get(t);
337
+ return c || (c = /* @__PURE__ */ new Map(), l.current.set(t, c)), c.set(r.token, r), E(), S(), w.current.size > 100 && `${e}${w.current.size}`, {
338
+ animateId: t,
339
+ generation: r.generation,
340
+ getCalculatedDelay: () => L.current.calculatedDelays.get(t) ?? r.info.delay,
341
+ setEnterVariant: (u) => {
342
+ r.disposed || l.current.get(t)?.has(r.token) && (r.enterVariant = u, S());
343
+ },
344
+ observeAfter: (u) => {
345
+ if (!r.info.after)
346
+ return u({
347
+ kind: "satisfied",
348
+ source: "none"
349
+ }), () => {
350
+ };
351
+ const h = {
352
+ follower: r,
353
+ listener: u,
354
+ leaderId: r.info.after,
355
+ sawLeader: !1,
356
+ lastSignature: null,
357
+ terminal: !1
358
+ };
359
+ let g = $.current.get(h.leaderId);
360
+ return g || (g = /* @__PURE__ */ new Set(), $.current.set(h.leaderId, g)), g.add(h), V(h, C(h, v.current === 0 && d.current === null)), () => {
361
+ h.terminal = !0, g?.delete(h), g?.size === 0 && $.current.delete(h.leaderId);
362
+ };
363
+ },
364
+ publishEnterCompleted: () => {
365
+ r.disposed || r.enterCompleted || l.current.get(t)?.has(r.token) && (r.enterCompleted = !0, O(!1));
366
+ },
367
+ dispose: () => T(r)
368
+ };
369
+ }, [
370
+ T,
371
+ V,
372
+ C,
373
+ E,
374
+ O,
375
+ e,
376
+ S
377
+ ]), le = p((t, n) => {
378
+ const r = {
379
+ token: Symbol(t),
380
+ id: t,
381
+ lane: n,
382
+ disposed: !1
383
+ };
384
+ let c = m.current.get(t);
385
+ return c || (c = /* @__PURE__ */ new Map(), m.current.set(t, c)), c.set(r.token, r), E(), S(), { dispose: () => {
386
+ if (r.disposed) return;
387
+ r.disposed = !0;
388
+ const u = m.current.get(t);
389
+ u?.delete(r.token), u?.size === 0 && m.current.delete(t), E(), S();
390
+ } };
391
+ }, [E, S]), oe = p((t) => {
392
+ const n = l.current.get(t), r = n ? j(n) : void 0;
393
+ r && T(r);
394
+ }, [T]), se = p((t) => L.current.calculatedDelays.get(t) ?? w.current.get(t)?.delay ?? 0, []), ue = p(() => K.current, []);
395
+ return Q(() => {
396
+ S();
397
+ }, [a, S]), Q(() => {
398
+ M.current = !0;
399
+ const t = l.current, n = m.current, r = w.current, c = D.current, u = I.current, h = o.current, g = $.current;
400
+ return () => {
401
+ M.current = !1, d.current !== null && (clearTimeout(d.current), d.current = null), v.current = 0, t.clear(), n.clear(), r.clear(), c.clear(), u.clear(), h.clear(), g.clear();
402
+ };
403
+ }, []), {
404
+ timelineDuration: ne,
405
+ isStable: ae,
406
+ beginPreparation: ce,
407
+ registerAnimate: ie,
408
+ declareAnimateLane: le,
409
+ unregisterAnimate: oe,
410
+ getCalculatedDelay: se,
411
+ getTimelineDuration: ue
412
+ };
413
+ }
414
+ export {
415
+ de as a,
416
+ we as i,
417
+ Z as n,
418
+ $e as r,
419
+ ve as t
420
+ };
421
+
422
+ //# sourceMappingURL=scene-animation-registry-8b0m_IaZ.mjs.map