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,316 @@
1
+ import { useCallback as ht, useEffect as y, useRef as c } from "react";
2
+ import { animate as F } from "framer-motion";
3
+ var g = "time", J = {
4
+ time: 10,
5
+ percent: 1
6
+ }, Et = {
7
+ unit: g,
8
+ scale: J[g]
9
+ };
10
+ function Ft(l) {
11
+ return l === "time" || l === "percent";
12
+ }
13
+ function vt(l) {
14
+ return l?.unit !== void 0 || l?.scale !== void 0;
15
+ }
16
+ function _t(l, v, p) {
17
+ const M = vt(v) ? v : l, C = M?.unit;
18
+ if (C !== void 0 && !Ft(C))
19
+ return p?.({
20
+ field: "unit",
21
+ value: C
22
+ }), {
23
+ unit: g,
24
+ scale: J.time
25
+ };
26
+ const k = C ?? "time", R = M?.scale;
27
+ return R !== void 0 && (typeof R != "number" || !Number.isFinite(R) || R < 0) ? (p?.({
28
+ field: "scale",
29
+ value: R
30
+ }), {
31
+ unit: k,
32
+ scale: J[k]
33
+ }) : {
34
+ unit: k,
35
+ scale: R ?? J[k]
36
+ };
37
+ }
38
+ function N(l, v, p) {
39
+ const M = Math.max(0, Number.isFinite(v) ? v : 0), C = Number.isFinite(p) ? p : 0, k = l.unit === "time" ? l.scale : M * l.scale / 100;
40
+ return Math.min(M, Math.max(0, C * k));
41
+ }
42
+ function Nt({ slideMode: l, isActive: v, sceneIndex: p, sceneOffset: M, globalDirection: C, globalIsDragging: k, candidateSuspended: R = !1, globalRenderProgress: tt, globalDragTimelineProgress: G, renderProgressMotion: rt, dragTimelineProgressMotion: A, dragRelease: z, firstSceneEnterReady: et, elementElapsedMotion: nt, getTimelineDuration: ut, timelineDurationState: bt, dragTransaction: O, preparedSnapshot: Q, requirePreparedSnapshot: ct = !1, dragMappingConfig: st, takeoverSnapshot: T, onElementContinuationChange: lt, onSettleComplete: ot, onColdStartComplete: at }) {
43
+ const r = c(null), a = c(null), o = c(0), V = c(null), S = c(null), W = c(!1), d = c(0), X = c(!1), B = c(ut);
44
+ B.current = ut;
45
+ const it = c(O);
46
+ it.current = O;
47
+ const Y = c(Q);
48
+ Y.current = Q;
49
+ const _ = c(ct);
50
+ _.current = ct;
51
+ const ft = c(null), Z = () => {
52
+ const t = it.current;
53
+ return t || (_.current ? null : Y.current ?? null);
54
+ }, D = (t) => t?.registrySnapshot.timelineDuration ?? B.current(), mt = (t) => t?.mapping ?? kt.current, x = c(ot);
55
+ x.current = ot;
56
+ const L = c(at);
57
+ L.current = at;
58
+ const pt = c(lt);
59
+ pt.current = lt;
60
+ const $ = c(!1), f = (t) => {
61
+ $.current !== t && ($.current = t, pt.current?.(t));
62
+ }, b = c(nt);
63
+ b.current = nt;
64
+ const I = c(null), w = c(null), H = c(null), K = c(null), kt = c(st ?? Et);
65
+ kt.current = st ?? Et;
66
+ const P = c(A?.get() ?? G);
67
+ return P.current = A?.get() ?? G, y(() => {
68
+ if (!(l !== "drag" || !R) && r.current) {
69
+ if ($.current) {
70
+ I.current = Math.max(0, b.current.get());
71
+ const t = T?.current, u = t?.sceneIndices.includes(p) ?? !1;
72
+ H.current = u ? t.token : null, w.current = u ? t.baseRatio : null, K.current = null;
73
+ }
74
+ o.current += 1, r.current.stop(), r.current = null, a.current = null;
75
+ }
76
+ }, [
77
+ R,
78
+ p,
79
+ l,
80
+ T
81
+ ]), y(() => {
82
+ if (R || k) return;
83
+ const t = H.current, u = T?.current;
84
+ t !== null && u?.token === t && u.baseRatio !== null || (I.current = null, w.current = null, H.current = null, K.current = null);
85
+ }, [
86
+ R,
87
+ k,
88
+ T
89
+ ]), y(() => {
90
+ if (l !== "drag" || !k) return;
91
+ r.current && (r.current.stop(), r.current = null, a.current = null), f(!1), W.current = !0, X.current = !1;
92
+ const t = (u) => {
93
+ P.current = u;
94
+ const s = rt?.get() ?? tt, e = s > 1e-4 ? "forward" : s < -1e-4 ? "backward" : C;
95
+ if (!(e === "forward" && M === 1 || e === "backward" && M === -1)) return;
96
+ const n = Z();
97
+ if (_.current && !n) return;
98
+ const m = D(n), h = Math.max(0, Math.min(u, 1)), i = mt(n), E = I.current;
99
+ if (E !== null) {
100
+ const U = T?.current, j = H.current;
101
+ if (j !== null && U?.token === j && U.sceneIndices.includes(p) && U.baseRatio !== null) {
102
+ const q = U.baseRatio;
103
+ if (w.current = q, K.current !== j && Math.abs(Math.abs(s) - q) <= 1e-6 && Math.abs(h - U.staleRatio) <= 1e-6 && Math.abs(h - q) > 1e-6) {
104
+ K.current = j;
105
+ return;
106
+ }
107
+ const Ut = N(i, m, q * 100), yt = N(i, m, h * 100);
108
+ b.current.set(Math.max(0, Math.min(m, E + yt - Ut)));
109
+ return;
110
+ }
111
+ const Rt = w.current;
112
+ if (Rt === null) {
113
+ w.current = h;
114
+ return;
115
+ }
116
+ const Mt = N(i, m, Rt * 100), Ct = N(i, m, h * 100);
117
+ b.current.set(Math.max(0, Math.min(m, E + Ct - Mt)));
118
+ return;
119
+ }
120
+ b.current.set(N(i, m, h * 100));
121
+ };
122
+ if (t(A?.get() ?? G), A) return A.on("change", t);
123
+ }, [
124
+ l,
125
+ k,
126
+ G,
127
+ tt,
128
+ A,
129
+ rt,
130
+ C,
131
+ M,
132
+ p,
133
+ T,
134
+ O?.transactionId
135
+ ]), y(() => {
136
+ if (l !== "drag" || R) return;
137
+ const t = z;
138
+ if (!t || t.targetSceneIndex !== p) return;
139
+ const u = Z();
140
+ if (_.current && !u || V.current === t.token) return;
141
+ V.current = t.token;
142
+ const s = ++o.current;
143
+ r.current?.stop(), r.current = null, f(!1);
144
+ const e = b.current, n = D(u), m = typeof t.progressRatio == "number" ? t.progressRatio : P.current, h = u && "releaseSeed" in u ? u.releaseSeed.elapsedMs : N(mt(u), n, Math.max(0, Math.min(m, 1)) * 100), i = Math.max(0, e.get(), h);
145
+ if (i > e.get() && e.set(i), t.mode === "enter") {
146
+ if (e.set(0), n <= 1e-3) {
147
+ e.set(n);
148
+ return;
149
+ }
150
+ a.current = "cold-start", r.current = F(e, n, {
151
+ duration: n / 1e3,
152
+ ease: "linear",
153
+ onUpdate: (E) => {
154
+ o.current === s && e.set(E);
155
+ },
156
+ onComplete: () => {
157
+ o.current === s && (r.current = null, a.current = null, e.set(n));
158
+ }
159
+ });
160
+ } else if (t.mode === "settle") {
161
+ const E = n - i;
162
+ if (E <= 1e-3) {
163
+ f(!1), e.set(n), S.current = t.token, x.current?.();
164
+ return;
165
+ }
166
+ a.current = "settle", f(!0), r.current = F(e, n, {
167
+ duration: E / 1e3,
168
+ ease: "linear",
169
+ onUpdate: (U) => {
170
+ o.current === s && e.set(U);
171
+ },
172
+ onComplete: () => {
173
+ o.current === s && (r.current = null, a.current = null, f(!1), e.set(n), S.current = t.token, x.current?.());
174
+ }
175
+ });
176
+ } else {
177
+ if (i <= 1e-3) {
178
+ f(!1), e.set(0);
179
+ return;
180
+ }
181
+ const E = Math.min(Math.max(i, 0) * 0.5, 300);
182
+ a.current = "bounce", f(!0), r.current = F(e, 0, {
183
+ duration: E / 1e3,
184
+ ease: "easeOut",
185
+ onUpdate: (U) => {
186
+ o.current === s && e.set(U);
187
+ },
188
+ onComplete: () => {
189
+ o.current === s && (r.current = null, a.current = null, f(!1), e.set(0));
190
+ }
191
+ });
192
+ }
193
+ }, [
194
+ l,
195
+ z?.token,
196
+ p,
197
+ O?.transactionId
198
+ ]), y(() => {
199
+ if (l !== "drag" || R || k) return;
200
+ const t = z;
201
+ if (!t || t.mode === "enter" || t.targetSceneIndex !== p || V.current !== t.token || t.mode === "settle" && S.current === t.token || r.current) return;
202
+ const u = Z();
203
+ if (_.current && !u) return;
204
+ const s = b.current, e = Math.max(0, s.get());
205
+ if (t.mode === "bounce") {
206
+ if (e <= 1e-3) {
207
+ f(!1), s.set(0);
208
+ return;
209
+ }
210
+ const i = ++o.current;
211
+ a.current = "bounce", f(!0), r.current = F(s, 0, {
212
+ duration: Math.min(e * 0.5, 300) / 1e3,
213
+ ease: "easeOut",
214
+ onUpdate: (E) => {
215
+ o.current === i && s.set(E);
216
+ },
217
+ onComplete: () => {
218
+ o.current === i && (r.current = null, a.current = null, f(!1), s.set(0));
219
+ }
220
+ });
221
+ return;
222
+ }
223
+ const n = D(u), m = n - e;
224
+ if (m <= 1e-3) {
225
+ f(!1), s.set(n), S.current = t.token, x.current?.();
226
+ return;
227
+ }
228
+ const h = ++o.current;
229
+ a.current = "settle", f(!0), r.current = F(s, n, {
230
+ duration: m / 1e3,
231
+ ease: "linear",
232
+ onUpdate: (i) => {
233
+ o.current === h && s.set(i);
234
+ },
235
+ onComplete: () => {
236
+ o.current === h && (r.current = null, a.current = null, f(!1), s.set(n), S.current = t.token, x.current?.());
237
+ }
238
+ });
239
+ }, [
240
+ l,
241
+ R,
242
+ k,
243
+ z?.token,
244
+ p
245
+ ]), y(() => {
246
+ if (l !== "drag" || p !== 0 || !et || k) return;
247
+ const t = b.current;
248
+ if (!W.current) {
249
+ const n = Y.current ?? null;
250
+ if (_.current && !n) return;
251
+ ft.current = n;
252
+ const m = D(n);
253
+ W.current = !0, X.current = n === null, d.current = m;
254
+ const h = m - Math.max(0, t.get());
255
+ if (h <= 1e-3) {
256
+ t.set(m), L.current?.();
257
+ return;
258
+ }
259
+ const i = ++o.current;
260
+ a.current = "cold-start", r.current = F(t, m, {
261
+ duration: h / 1e3,
262
+ ease: "linear",
263
+ onUpdate: (E) => {
264
+ o.current === i && t.set(E);
265
+ },
266
+ onComplete: () => {
267
+ o.current === i && (r.current = null, a.current = null, t.set(d.current), L.current?.());
268
+ }
269
+ });
270
+ return;
271
+ }
272
+ if (!X.current || ft.current) return;
273
+ const u = B.current();
274
+ if (u <= d.current + 1e-3) return;
275
+ r.current?.stop(), d.current = u;
276
+ const s = u - Math.max(0, t.get());
277
+ if (s <= 1e-3) {
278
+ t.set(u), r.current = null, a.current = null, L.current?.();
279
+ return;
280
+ }
281
+ const e = ++o.current;
282
+ a.current = "cold-start", r.current = F(t, u, {
283
+ duration: s / 1e3,
284
+ ease: "linear",
285
+ onUpdate: (n) => {
286
+ o.current === e && t.set(n);
287
+ },
288
+ onComplete: () => {
289
+ o.current === e && (r.current = null, a.current = null, t.set(d.current), L.current?.());
290
+ }
291
+ });
292
+ }, [
293
+ l,
294
+ p,
295
+ et,
296
+ k,
297
+ bt,
298
+ Q?.revision
299
+ ]), y(() => () => {
300
+ r.current?.stop(), r.current = null, f(!1);
301
+ }, []), {
302
+ completeImmediately: ht(() => {
303
+ o.current += 1, r.current?.stop(), r.current = null, a.current = null, f(!1), b.current.set(B.current());
304
+ }, []),
305
+ resetImmediately: ht(() => {
306
+ o.current += 1, r.current?.stop(), r.current = null, a.current = null, f(!1), b.current.set(0);
307
+ }, [])
308
+ };
309
+ }
310
+ export {
311
+ N as n,
312
+ _t as r,
313
+ Nt as t
314
+ };
315
+
316
+ //# sourceMappingURL=element-track-Du10P12_.mjs.map
@@ -0,0 +1,14 @@
1
+ // 由 scripts/build-all.mjs 生成,请勿手改。
2
+ // 拖拽专用入口的类型面:与全量入口的唯一差异是 `Cineview` 不接受 `mode`
3
+ // (本产物只含拖拽引擎;需要另一种模式请用 "cineview/scroll",
4
+ // 需要运行时按 mode 切换请用 "cineview")。
5
+ import type { ForwardRefExoticComponent, RefAttributes } from 'react';
6
+ import type { CineviewProps, CineviewRef } from './index';
7
+
8
+ export * from './index';
9
+
10
+ export declare type CineviewDragProps = Omit<Extract<CineviewProps, { mode?: 'drag' }>, 'mode'>;
11
+
12
+ export declare const Cineview: ForwardRefExoticComponent<
13
+ CineviewDragProps & RefAttributes<CineviewRef>
14
+ >;
@@ -0,0 +1,14 @@
1
+ // 由 scripts/build-all.mjs 生成,请勿手改。
2
+ // 滚动专用入口的类型面:与全量入口的唯一差异是 `Cineview` 不接受 `mode`
3
+ // (本产物只含滚动引擎;需要另一种模式请用 "cineview/drag",
4
+ // 需要运行时按 mode 切换请用 "cineview")。
5
+ import type { ForwardRefExoticComponent, RefAttributes } from 'react';
6
+ import type { CineviewProps, CineviewRef } from './index';
7
+
8
+ export * from './index';
9
+
10
+ export declare type CineviewScrollProps = Omit<Extract<CineviewProps, { mode: 'scroll' }>, 'mode'>;
11
+
12
+ export declare const Cineview: ForwardRefExoticComponent<
13
+ CineviewScrollProps & RefAttributes<CineviewRef>
14
+ >;
@@ -0,0 +1,22 @@
1
+ var i = {
2
+ fade: {
3
+ initial: { opacity: 0 },
4
+ animate: { opacity: 1 },
5
+ exit: { opacity: 0 }
6
+ },
7
+ "fade-in": {
8
+ initial: { opacity: 0 },
9
+ animate: { opacity: 1 },
10
+ exit: { opacity: 1 }
11
+ },
12
+ "fade-out": {
13
+ initial: { opacity: 1 },
14
+ animate: { opacity: 1 },
15
+ exit: { opacity: 0 }
16
+ }
17
+ };
18
+ export {
19
+ i as fadeAnimations
20
+ };
21
+
22
+ //# sourceMappingURL=fade-DXxFsgxR.mjs.map
@@ -0,0 +1,49 @@
1
+ var t = {
2
+ flip: {
3
+ initial: {
4
+ rotateY: -180,
5
+ opacity: 0
6
+ },
7
+ animate: {
8
+ rotateY: 0,
9
+ opacity: 1
10
+ },
11
+ exit: {
12
+ rotateY: 180,
13
+ opacity: 0
14
+ }
15
+ },
16
+ "flip-x": {
17
+ initial: {
18
+ rotateX: -180,
19
+ opacity: 0
20
+ },
21
+ animate: {
22
+ rotateX: 0,
23
+ opacity: 1
24
+ },
25
+ exit: {
26
+ rotateX: 180,
27
+ opacity: 0
28
+ }
29
+ },
30
+ "flip-y": {
31
+ initial: {
32
+ rotateY: -180,
33
+ opacity: 0
34
+ },
35
+ animate: {
36
+ rotateY: 0,
37
+ opacity: 1
38
+ },
39
+ exit: {
40
+ rotateY: 180,
41
+ opacity: 0
42
+ }
43
+ }
44
+ };
45
+ export {
46
+ t as flipAnimations
47
+ };
48
+
49
+ //# sourceMappingURL=flip-CrCoNIws.mjs.map
@@ -0,0 +1,4 @@
1
+ export declare function markImageAsPreloaded(url: string): void;
2
+ export declare function isImagePreloaded(url: string): boolean;
3
+ export declare function subscribeToPreloadedImages(listener: (url: string) => void): () => void;
4
+ export declare function resetPreloadedImageCache(): void;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Media preload cache (video blobs), parallel to imagePreloadCache.
3
+ *
4
+ * Unlike images where `onload` means ready, video scrub requires the entire
5
+ * buffer to be seekable. This cache defines "ready" as "video blob fetched
6
+ * and seekable", and waits for it as part of priorityComplete in the first-screen
7
+ * cold-start gate. Eviction revokes objectURLs. Disabled in SSR/no-window environments.
8
+ */
9
+ export type MediaKind = 'video';
10
+ /** Infers media type from URL extension; returns null for non-video (caller can pass explicit kind). */
11
+ export declare function inferMediaKind(src: string): MediaKind | null;
12
+ export declare function isMediaPreloaded(src: string): boolean;
13
+ export declare function getVideoObjectUrl(src: string): string | undefined;
14
+ export declare function subscribeToPreloadedMedia(listener: (url: string) => void): () => void;
15
+ /**
16
+ * Acquires and leases an objectURL for a mounted video consumer. LRU must not revoke
17
+ * URLs while leases exist. Each successful acquire must be paired with one release.
18
+ */
19
+ export declare function acquireVideoObjectUrl(src: string): string | undefined;
20
+ /** Releases the mounted consumer's lease; retries budget eviction immediately after the last lease is released. */
21
+ export declare function releaseVideoObjectUrl(src: string): void;
22
+ /**
23
+ * Preloads a media resource. Already ready → resolves immediately; in-flight → reuses
24
+ * same Promise (deduplication). When kind is missing, infers from extension; inference
25
+ * failure rejects. Failure clears in-flight record, allowing retries.
26
+ */
27
+ export declare function preloadMedia(src: string, kind?: MediaKind): Promise<void>;
28
+ /** Sets LRU byte budget (default 128MB). Immediately evicts to new budget after setting. */
29
+ export declare function setMediaByteBudget(bytes: number): void;
30
+ /** Test/hot-reload reset: clears cache and revokes all objectURLs. */
31
+ export declare function resetMediaPreloadCache(): void;
@@ -0,0 +1,65 @@
1
+ import { CineviewErrorCode } from '../types';
2
+ /**
3
+ * Global first-screen cold-start gate. Mode-agnostic: owns the two decoupled
4
+ * booleans that govern when the first mounted scene is allowed to play its
5
+ * one-shot enter pass, plus the priority-asset / timeout / preventDefault /
6
+ * static-reveal coordination that used to live inline in Cineview.
7
+ *
8
+ * Two-boolean model (intentionally NOT a 3-state enum — see project memory):
9
+ * - `firstSceneEnterActive` — the WINDOW flag. While true, the first scene is
10
+ * held at / playing its enter pass instead of snapping to rest. In drag mode
11
+ * `useAnimateDrag` reads it; in scroll mode it is inert (the scroll visibility
12
+ * path gates on `firstSceneEnterReady` only), but kept so the lifecycle is
13
+ * identical across modes.
14
+ * - `firstSceneEnterReady` — the START trigger. Turns true once first-screen
15
+ * priority assets settle (or are forced ready). `(active=true, ready=false)`
16
+ * means "held at initial, not yet entering" (pre-load and the preventDefault
17
+ * path); `(active=false, ready=true)` is the completed-extendable state.
18
+ *
19
+ * This hook owns the GATING SIGNAL only — it never runs the enter tween itself.
20
+ * Each mode's element track / visibility state machine consumes `ready` and
21
+ * plays its own animation; drag clears the window via `handleComplete` when its
22
+ * element track reaches T. Scroll leaves the (inert) window as-is.
23
+ */
24
+ export interface UseFirstSceneEnterParams {
25
+ /** Whether the cold-start mechanism is engaged at all (false → reveal statically). */
26
+ enabled: boolean;
27
+ /** Whether a first scene exists to drive. */
28
+ hasFirstScene: boolean;
29
+ /** First-screen priority assets are ready (preloadState.priorityComplete). */
30
+ priorityComplete: boolean;
31
+ /** Fallback timeout before emitting FIRST_SCENE_TIMEOUT and revealing statically. */
32
+ timeoutMs: number;
33
+ /**
34
+ * When true, an external owner has preempted the cold start (e.g. the user
35
+ * grabbed the first scene mid-enter in drag mode). Clears both flags so the
36
+ * gesture fully owns the track. Scroll passes false.
37
+ */
38
+ preemptSignal?: boolean;
39
+ /**
40
+ * Routes a recoverable FIRST_SCENE_TIMEOUT to the consumer. Returns true if
41
+ * the consumer handled it (preventDefault) — in which case the scene is left
42
+ * at its initial visual for consumer-driven recovery instead of static reveal.
43
+ */
44
+ emitRecoverableError: (code: CineviewErrorCode, message: string, context?: Record<string, unknown>) => boolean;
45
+ /** Lazily read preload counts for the timeout error context. */
46
+ getPreloadCounts: () => {
47
+ loadedCount: number;
48
+ totalCount: number;
49
+ };
50
+ }
51
+ export type FirstSceneActivationKind = 'ready' | 'static';
52
+ export interface UseFirstSceneEnterResult {
53
+ firstSceneEnterActive: boolean;
54
+ firstSceneEnterReady: boolean;
55
+ /**
56
+ * Monotonic one-shot signal for the first Scene's formal activation. Asset
57
+ * readiness and the default timeout fallback activate; a handled timeout or
58
+ * pointer preemption does not.
59
+ */
60
+ firstSceneActivationToken: number;
61
+ firstSceneActivationKind: FirstSceneActivationKind | null;
62
+ /** Clears the window once the first scene's enter pass reaches its terminal. */
63
+ handleComplete: () => void;
64
+ }
65
+ export declare function useFirstSceneEnter({ enabled, hasFirstScene, priorityComplete, timeoutMs, preemptSignal, emitRecoverableError, getPreloadCounts, }: UseFirstSceneEnterParams): UseFirstSceneEnterResult;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * useImagePreloader Hook
3
+ * Manages image preload queue and progress tracking
4
+ */
5
+ export interface ImageLoadResult {
6
+ url: string;
7
+ success: boolean;
8
+ error?: Error;
9
+ }
10
+ export interface UseImagePreloaderOptions {
11
+ priorityUrls?: string[];
12
+ backgroundUrls?: string[];
13
+ onProgress?: (progress: number) => void;
14
+ onComplete?: (results: ImageLoadResult[]) => void;
15
+ onError?: (url: string, error: Error) => void;
16
+ }
17
+ export interface UseImagePreloaderState {
18
+ isLoading: boolean;
19
+ progress: number;
20
+ loadedCount: number;
21
+ totalCount: number;
22
+ results: ImageLoadResult[];
23
+ errors: Map<string, Error>;
24
+ priorityComplete: boolean;
25
+ }
26
+ export interface UseImagePreloaderActions {
27
+ startPreload: () => Promise<void>;
28
+ reset: () => void;
29
+ addUrls: (urls: string[], priority?: boolean) => void;
30
+ }
31
+ export declare const useImagePreloader: (options?: UseImagePreloaderOptions) => [UseImagePreloaderState, UseImagePreloaderActions];
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The OS "reduce motion" preference.
3
+ *
4
+ * It is an external input that can flip while a scene stays mounted, so it is read
5
+ * through `useSyncExternalStore` rather than sampled once. The server snapshot is
6
+ * `false`: SSR has no media query, and rendering the reduced variant into HTML that
7
+ * a full-motion client then hydrates would be the wrong default.
8
+ *
9
+ * Read this once at the Cineview root and pass it down the runtime context — one
10
+ * matchMedia subscription per root, not one per Animate.
11
+ */
12
+ export declare function usePrefersReducedMotion(): boolean;
@@ -0,0 +1,79 @@
1
+ import { ScrollMode } from '../types';
2
+ export interface DragRelease {
3
+ token: number;
4
+ mode: 'settle' | 'bounce' | 'enter';
5
+ direction: 'forward' | 'backward';
6
+ targetSceneIndex: number;
7
+ progressRatio?: number;
8
+ }
9
+ export type DragReleaseInput = Omit<DragRelease, 'token'>;
10
+ export interface ScrollTransitionSnapshot {
11
+ fromScene: number;
12
+ toScene: number;
13
+ direction: 'forward' | 'backward';
14
+ progressRatio: number;
15
+ startedAt: number;
16
+ lastInputAt: number;
17
+ isSettling: boolean;
18
+ settleDirection: 'forward' | 'backward' | null;
19
+ }
20
+ export interface UseSceneManagerOptions {
21
+ totalScenes: number;
22
+ initialScene?: number;
23
+ mode?: ScrollMode;
24
+ onBeforeChange?: (from: number, to: number) => void;
25
+ /**
26
+ * Fires at the authoritative index commit. Unlike onAfterChange, this is not a
27
+ * lifecycle notification and is used internally to mint Scene activation tokens.
28
+ */
29
+ onCommit?: (sceneIndex: number, previousIndex: number, kind: 'drag' | 'programmatic') => void;
30
+ onAfterChange?: (sceneIndex: number, previousIndex?: number) => void;
31
+ }
32
+ export interface SceneManagerState {
33
+ currentScene: number;
34
+ isAnimating: boolean;
35
+ direction: 'forward' | 'backward' | null;
36
+ dragProgress: number;
37
+ dragTimelineProgress: number;
38
+ scrollProgress: number;
39
+ scrollDirection: 'forward' | 'backward' | null;
40
+ renderProgress: number;
41
+ isDragging: boolean;
42
+ isScrolling: boolean;
43
+ sharedTimelineDurationMs: number;
44
+ dragRelease: DragRelease | null;
45
+ scrollTransitionSnapshot: ScrollTransitionSnapshot | null;
46
+ }
47
+ export interface SceneManagerActions {
48
+ reconcileSceneList: (index: number) => void;
49
+ goToScene: (index: number, animated?: boolean) => void;
50
+ nextScene: () => void;
51
+ prevScene: () => void;
52
+ setAnimating: (animating: boolean) => void;
53
+ canGoNext: () => boolean;
54
+ canGoPrev: () => boolean;
55
+ setDragProgress: (progress: number) => void;
56
+ setDragTimelineProgress: (progress: number) => void;
57
+ setScrollProgress: (progress: number) => void;
58
+ setScrollDirection: (direction: 'forward' | 'backward' | null) => void;
59
+ setScrollTransitionSnapshot: (snapshot: ScrollTransitionSnapshot | null) => void;
60
+ setRenderProgress: (progress: number) => void;
61
+ setIsDragging: (dragging: boolean) => void;
62
+ setIsScrolling: (scrolling: boolean) => void;
63
+ setSharedTimelineDurationMs: (duration: number) => void;
64
+ setDragRelease: (release: DragReleaseInput | null) => void;
65
+ resetDragInteraction: () => void;
66
+ /** Ends a superseded settle/bounce join without changing the current render position. */
67
+ abortDragContinuation: () => void;
68
+ resetScrollInteraction: () => void;
69
+ /**
70
+ * Applies a drag commit. Returns `true` when the scene index actually moved.
71
+ * An out-of-bounds target returns `false` WITHOUT touching `currentScene`, so
72
+ * callers that arm work on the scene-change render must disarm it on `false`.
73
+ */
74
+ commitDragSceneChange: (direction: 'forward' | 'backward', progressRatio: number, elapsedMs?: number, timelineDuration?: number) => boolean;
75
+ completeDragTransition: () => void;
76
+ commitScrollSceneChange: (direction: 'forward' | 'backward', progressRatio: number) => void;
77
+ clearScrollTransitionSnapshot: () => void;
78
+ }
79
+ export declare const useSceneManager: (options: UseSceneManagerOptions) => [SceneManagerState, SceneManagerActions];
@@ -0,0 +1,17 @@
1
+ /**
2
+ * CineView React UI Framework
3
+ * A React UI framework for creating cinematic full-screen sliding page introductions
4
+ *
5
+ * This entry point is **full-featured**: `CineView` is a runtime-dispatched component
6
+ * based on `mode`, and both engines are included in the bundle.
7
+ * Maintains existing behavior and export surface (default `mode='drag'`).
8
+ *
9
+ * For single-mode usage with smaller bundle size, use mode-specific entry points
10
+ * (especially relevant for UMD consumers, as single-file UMD cannot code-split
11
+ * and the full entry point will always include both engines):
12
+ * - `cineview/drag` → drag engine only
13
+ * - `cineview/scroll` → scroll engine only
14
+ * See `src/entry-drag.ts` / `src/entry-scroll.ts`.
15
+ */
16
+ export * from './public-api';
17
+ export { Cineview } from './components/Cineview';