@oxyhq/bloom 1.0.6 → 1.2.0

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 (220) hide show
  1. package/docs/level-picker.mdx +105 -0
  2. package/docs/media-flight.mdx +272 -0
  3. package/docs/migrating-the-media-gallery.mdx +103 -0
  4. package/docs/migrating-to-1.0.mdx +1 -1
  5. package/docs/slider.mdx +3 -1
  6. package/docs/zoomable-media-gallery.mdx +116 -0
  7. package/lib/commonjs/floating/index.js.map +1 -1
  8. package/lib/commonjs/image-aspect-ratio-cache/aspect-ratio-cache.js +1 -1
  9. package/lib/commonjs/index.js +8 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/index.web.js +33 -25
  12. package/lib/commonjs/index.web.js.map +1 -1
  13. package/lib/commonjs/level-picker/LevelPicker.js +349 -0
  14. package/lib/commonjs/level-picker/LevelPicker.js.map +1 -0
  15. package/lib/commonjs/level-picker/LevelPicker.web.js +346 -0
  16. package/lib/commonjs/level-picker/LevelPicker.web.js.map +1 -0
  17. package/lib/commonjs/level-picker/constants.js +137 -0
  18. package/lib/commonjs/level-picker/constants.js.map +1 -0
  19. package/lib/commonjs/level-picker/index.js +13 -0
  20. package/lib/commonjs/level-picker/index.js.map +1 -0
  21. package/lib/commonjs/level-picker/index.web.js +13 -0
  22. package/lib/commonjs/level-picker/index.web.js.map +1 -0
  23. package/lib/commonjs/level-picker/types.js +6 -0
  24. package/lib/commonjs/level-picker/types.js.map +1 -0
  25. package/lib/commonjs/media-flight/MediaFlightLayer.js +151 -0
  26. package/lib/commonjs/media-flight/MediaFlightLayer.js.map +1 -0
  27. package/lib/commonjs/media-flight/MediaSurface.js +188 -0
  28. package/lib/commonjs/media-flight/MediaSurface.js.map +1 -0
  29. package/lib/commonjs/media-flight/constants.js +39 -0
  30. package/lib/commonjs/media-flight/constants.js.map +1 -0
  31. package/lib/commonjs/media-flight/expo-video-module.js +148 -0
  32. package/lib/commonjs/media-flight/expo-video-module.js.map +1 -0
  33. package/lib/commonjs/media-flight/index.js +102 -0
  34. package/lib/commonjs/media-flight/index.js.map +1 -0
  35. package/lib/commonjs/media-flight/store.js +457 -0
  36. package/lib/commonjs/media-flight/store.js.map +1 -0
  37. package/lib/commonjs/media-flight/types.js +6 -0
  38. package/lib/commonjs/media-flight/types.js.map +1 -0
  39. package/lib/commonjs/media-flight/use-media-flight.js +41 -0
  40. package/lib/commonjs/media-flight/use-media-flight.js.map +1 -0
  41. package/lib/commonjs/tab-bar/TabBarBase.js +1 -1
  42. package/lib/commonjs/{zoomable-image-gallery/ZoomableImageGallery.js → zoomable-media-gallery/ZoomableMediaGallery.js} +185 -131
  43. package/lib/commonjs/zoomable-media-gallery/ZoomableMediaGallery.js.map +1 -0
  44. package/lib/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/constants.js.map +1 -1
  45. package/lib/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/index.js +5 -5
  46. package/lib/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/index.js.map +1 -1
  47. package/lib/commonjs/zoomable-media-gallery/types.js +6 -0
  48. package/lib/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/types.js.map +1 -1
  49. package/lib/module/floating/index.js +5 -0
  50. package/lib/module/floating/index.js.map +1 -1
  51. package/lib/module/image-aspect-ratio-cache/aspect-ratio-cache.js +1 -1
  52. package/lib/module/index.js +3 -1
  53. package/lib/module/index.js.map +1 -1
  54. package/lib/module/index.web.js +3 -1
  55. package/lib/module/index.web.js.map +1 -1
  56. package/lib/module/level-picker/LevelPicker.js +343 -0
  57. package/lib/module/level-picker/LevelPicker.js.map +1 -0
  58. package/lib/module/level-picker/LevelPicker.web.js +340 -0
  59. package/lib/module/level-picker/LevelPicker.web.js.map +1 -0
  60. package/lib/module/level-picker/constants.js +131 -0
  61. package/lib/module/level-picker/constants.js.map +1 -0
  62. package/lib/module/level-picker/index.js +4 -0
  63. package/lib/module/level-picker/index.js.map +1 -0
  64. package/lib/module/level-picker/index.web.js +4 -0
  65. package/lib/module/level-picker/index.web.js.map +1 -0
  66. package/lib/module/level-picker/types.js +4 -0
  67. package/lib/module/level-picker/types.js.map +1 -0
  68. package/lib/module/media-flight/MediaFlightLayer.js +146 -0
  69. package/lib/module/media-flight/MediaFlightLayer.js.map +1 -0
  70. package/lib/module/media-flight/MediaSurface.js +180 -0
  71. package/lib/module/media-flight/MediaSurface.js.map +1 -0
  72. package/lib/module/media-flight/constants.js +35 -0
  73. package/lib/module/media-flight/constants.js.map +1 -0
  74. package/lib/module/media-flight/expo-video-module.js +142 -0
  75. package/lib/module/media-flight/expo-video-module.js.map +1 -0
  76. package/lib/module/media-flight/index.js +9 -0
  77. package/lib/module/media-flight/index.js.map +1 -0
  78. package/lib/module/media-flight/store.js +439 -0
  79. package/lib/module/media-flight/store.js.map +1 -0
  80. package/lib/module/media-flight/types.js +4 -0
  81. package/lib/module/media-flight/types.js.map +1 -0
  82. package/lib/module/media-flight/use-media-flight.js +36 -0
  83. package/lib/module/media-flight/use-media-flight.js.map +1 -0
  84. package/lib/module/tab-bar/TabBarBase.js +1 -1
  85. package/lib/module/{zoomable-image-gallery/ZoomableImageGallery.js → zoomable-media-gallery/ZoomableMediaGallery.js} +184 -130
  86. package/lib/module/zoomable-media-gallery/ZoomableMediaGallery.js.map +1 -0
  87. package/lib/module/{zoomable-image-gallery → zoomable-media-gallery}/constants.js.map +1 -1
  88. package/lib/module/zoomable-media-gallery/index.js +5 -0
  89. package/lib/module/zoomable-media-gallery/index.js.map +1 -0
  90. package/lib/module/zoomable-media-gallery/types.js +4 -0
  91. package/lib/module/{zoomable-image-gallery → zoomable-media-gallery}/types.js.map +1 -1
  92. package/lib/typescript/commonjs/floating/index.d.ts +5 -0
  93. package/lib/typescript/commonjs/floating/index.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/index.d.ts +2 -0
  95. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/index.web.d.ts +2 -0
  97. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/level-picker/LevelPicker.d.ts +6 -0
  99. package/lib/typescript/commonjs/level-picker/LevelPicker.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/level-picker/LevelPicker.web.d.ts +6 -0
  101. package/lib/typescript/commonjs/level-picker/LevelPicker.web.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/level-picker/constants.d.ts +93 -0
  103. package/lib/typescript/commonjs/level-picker/constants.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/level-picker/index.d.ts +3 -0
  105. package/lib/typescript/commonjs/level-picker/index.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/level-picker/index.web.d.ts +3 -0
  107. package/lib/typescript/commonjs/level-picker/index.web.d.ts.map +1 -0
  108. package/lib/typescript/commonjs/level-picker/types.d.ts +63 -0
  109. package/lib/typescript/commonjs/level-picker/types.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/media-flight/MediaFlightLayer.d.ts +11 -0
  111. package/lib/typescript/commonjs/media-flight/MediaFlightLayer.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/media-flight/MediaSurface.d.ts +106 -0
  113. package/lib/typescript/commonjs/media-flight/MediaSurface.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/media-flight/constants.d.ts +18 -0
  115. package/lib/typescript/commonjs/media-flight/constants.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/media-flight/expo-video-module.d.ts +103 -0
  117. package/lib/typescript/commonjs/media-flight/expo-video-module.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/media-flight/index.d.ts +9 -0
  119. package/lib/typescript/commonjs/media-flight/index.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/media-flight/store.d.ts +132 -0
  121. package/lib/typescript/commonjs/media-flight/store.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/media-flight/types.d.ts +195 -0
  123. package/lib/typescript/commonjs/media-flight/types.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/media-flight/use-media-flight.d.ts +4 -0
  125. package/lib/typescript/commonjs/media-flight/use-media-flight.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/zoomable-media-gallery/ZoomableMediaGallery.d.ts +5 -0
  127. package/lib/typescript/commonjs/zoomable-media-gallery/ZoomableMediaGallery.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/constants.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/zoomable-media-gallery/index.d.ts +4 -0
  130. package/lib/typescript/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/index.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/zoomable-media-gallery/types.d.ts +90 -0
  132. package/lib/typescript/commonjs/zoomable-media-gallery/types.d.ts.map +1 -0
  133. package/lib/typescript/module/floating/index.d.ts +5 -0
  134. package/lib/typescript/module/floating/index.d.ts.map +1 -1
  135. package/lib/typescript/module/index.d.ts +2 -0
  136. package/lib/typescript/module/index.d.ts.map +1 -1
  137. package/lib/typescript/module/index.web.d.ts +2 -0
  138. package/lib/typescript/module/index.web.d.ts.map +1 -1
  139. package/lib/typescript/module/level-picker/LevelPicker.d.ts +6 -0
  140. package/lib/typescript/module/level-picker/LevelPicker.d.ts.map +1 -0
  141. package/lib/typescript/module/level-picker/LevelPicker.web.d.ts +6 -0
  142. package/lib/typescript/module/level-picker/LevelPicker.web.d.ts.map +1 -0
  143. package/lib/typescript/module/level-picker/constants.d.ts +93 -0
  144. package/lib/typescript/module/level-picker/constants.d.ts.map +1 -0
  145. package/lib/typescript/module/level-picker/index.d.ts +3 -0
  146. package/lib/typescript/module/level-picker/index.d.ts.map +1 -0
  147. package/lib/typescript/module/level-picker/index.web.d.ts +3 -0
  148. package/lib/typescript/module/level-picker/index.web.d.ts.map +1 -0
  149. package/lib/typescript/module/level-picker/types.d.ts +63 -0
  150. package/lib/typescript/module/level-picker/types.d.ts.map +1 -0
  151. package/lib/typescript/module/media-flight/MediaFlightLayer.d.ts +11 -0
  152. package/lib/typescript/module/media-flight/MediaFlightLayer.d.ts.map +1 -0
  153. package/lib/typescript/module/media-flight/MediaSurface.d.ts +106 -0
  154. package/lib/typescript/module/media-flight/MediaSurface.d.ts.map +1 -0
  155. package/lib/typescript/module/media-flight/constants.d.ts +18 -0
  156. package/lib/typescript/module/media-flight/constants.d.ts.map +1 -0
  157. package/lib/typescript/module/media-flight/expo-video-module.d.ts +103 -0
  158. package/lib/typescript/module/media-flight/expo-video-module.d.ts.map +1 -0
  159. package/lib/typescript/module/media-flight/index.d.ts +9 -0
  160. package/lib/typescript/module/media-flight/index.d.ts.map +1 -0
  161. package/lib/typescript/module/media-flight/store.d.ts +132 -0
  162. package/lib/typescript/module/media-flight/store.d.ts.map +1 -0
  163. package/lib/typescript/module/media-flight/types.d.ts +195 -0
  164. package/lib/typescript/module/media-flight/types.d.ts.map +1 -0
  165. package/lib/typescript/module/media-flight/use-media-flight.d.ts +4 -0
  166. package/lib/typescript/module/media-flight/use-media-flight.d.ts.map +1 -0
  167. package/lib/typescript/module/zoomable-media-gallery/ZoomableMediaGallery.d.ts +5 -0
  168. package/lib/typescript/module/zoomable-media-gallery/ZoomableMediaGallery.d.ts.map +1 -0
  169. package/lib/typescript/module/{zoomable-image-gallery → zoomable-media-gallery}/constants.d.ts.map +1 -1
  170. package/lib/typescript/module/zoomable-media-gallery/index.d.ts +4 -0
  171. package/lib/typescript/module/{zoomable-image-gallery → zoomable-media-gallery}/index.d.ts.map +1 -1
  172. package/lib/typescript/module/zoomable-media-gallery/types.d.ts +90 -0
  173. package/lib/typescript/module/zoomable-media-gallery/types.d.ts.map +1 -0
  174. package/package.json +61 -8
  175. package/src/floating/index.ts +5 -0
  176. package/src/image-aspect-ratio-cache/aspect-ratio-cache.ts +1 -1
  177. package/src/index.ts +4 -1
  178. package/src/index.web.ts +4 -1
  179. package/src/level-picker/LevelPicker.tsx +365 -0
  180. package/src/level-picker/LevelPicker.web.tsx +374 -0
  181. package/src/level-picker/constants.ts +131 -0
  182. package/src/level-picker/index.ts +2 -0
  183. package/src/level-picker/index.web.ts +2 -0
  184. package/src/level-picker/types.ts +63 -0
  185. package/src/media-flight/MediaFlightLayer.tsx +144 -0
  186. package/src/media-flight/MediaSurface.tsx +233 -0
  187. package/src/media-flight/constants.ts +32 -0
  188. package/src/media-flight/expo-video-module.ts +181 -0
  189. package/src/media-flight/index.ts +33 -0
  190. package/src/media-flight/store.ts +497 -0
  191. package/src/media-flight/types.ts +210 -0
  192. package/src/media-flight/use-media-flight.ts +42 -0
  193. package/src/tab-bar/TabBarBase.tsx +1 -1
  194. package/src/{zoomable-image-gallery/ZoomableImageGallery.tsx → zoomable-media-gallery/ZoomableMediaGallery.tsx} +192 -117
  195. package/src/zoomable-media-gallery/index.ts +11 -0
  196. package/src/zoomable-media-gallery/types.ts +100 -0
  197. package/docs/zoomable-image-gallery.mdx +0 -66
  198. package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js.map +0 -1
  199. package/lib/commonjs/zoomable-image-gallery/types.js +0 -2
  200. package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js.map +0 -1
  201. package/lib/module/zoomable-image-gallery/index.js +0 -5
  202. package/lib/module/zoomable-image-gallery/index.js.map +0 -1
  203. package/lib/module/zoomable-image-gallery/types.js +0 -2
  204. package/lib/typescript/commonjs/zoomable-image-gallery/ZoomableImageGallery.d.ts +0 -5
  205. package/lib/typescript/commonjs/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +0 -1
  206. package/lib/typescript/commonjs/zoomable-image-gallery/index.d.ts +0 -4
  207. package/lib/typescript/commonjs/zoomable-image-gallery/types.d.ts +0 -56
  208. package/lib/typescript/commonjs/zoomable-image-gallery/types.d.ts.map +0 -1
  209. package/lib/typescript/module/zoomable-image-gallery/ZoomableImageGallery.d.ts +0 -5
  210. package/lib/typescript/module/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +0 -1
  211. package/lib/typescript/module/zoomable-image-gallery/index.d.ts +0 -4
  212. package/lib/typescript/module/zoomable-image-gallery/types.d.ts +0 -56
  213. package/lib/typescript/module/zoomable-image-gallery/types.d.ts.map +0 -1
  214. package/src/zoomable-image-gallery/index.ts +0 -9
  215. package/src/zoomable-image-gallery/types.ts +0 -59
  216. /package/lib/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/constants.js +0 -0
  217. /package/lib/module/{zoomable-image-gallery → zoomable-media-gallery}/constants.js +0 -0
  218. /package/lib/typescript/commonjs/{zoomable-image-gallery → zoomable-media-gallery}/constants.d.ts +0 -0
  219. /package/lib/typescript/module/{zoomable-image-gallery → zoomable-media-gallery}/constants.d.ts +0 -0
  220. /package/src/{zoomable-image-gallery → zoomable-media-gallery}/constants.ts +0 -0
@@ -0,0 +1,439 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The media-flight registry: anchors, live surfaces, and the animation that
5
+ * moves them.
6
+ *
7
+ * ## Why the animation lives HERE and not in the layer
8
+ *
9
+ * A flight is started by an imperative call (`flyTo`) from a screen that may be
10
+ * about to unmount. If the layer drove the animation from an effect keyed on the
11
+ * flight record, the first frame would be one commit late — and on web, where
12
+ * the origin route is genuinely gone by the next commit, that frame is the one
13
+ * the user sees. Driving the shared value at the call site makes the leg start
14
+ * exactly when the caller says it does and leaves the layer a pure painter.
15
+ *
16
+ * The shared values are created with `makeMutable` rather than `useSharedValue`
17
+ * for the same reason: they belong to a flight, not to a component, and the
18
+ * component that paints a flight is not the one that starts it.
19
+ *
20
+ * ## Why the registry is anchored on `globalThis`
21
+ *
22
+ * Same reason as the portal group and the overlay stack: `exports` ships a
23
+ * `react-native` → `src` condition beside the `lib/module` and `lib/commonjs`
24
+ * forks, and a bundler can resolve `@oxyhq/bloom/media-flight` through different
25
+ * conditions from different call sites. Two physical copies of this module would
26
+ * each keep their own registry, and the `<MediaFlightLayer>` mounted at the app
27
+ * root would never see the flight a screen started.
28
+ */
29
+ import { Platform } from 'react-native';
30
+ import { Easing, makeMutable, runOnJS, withSpring, withTiming } from 'react-native-reanimated';
31
+ import { RADIUS } from "../design-tokens/index.js";
32
+ import { SURFACE_MOUNT_TIMEOUT_MS } from "./constants.js";
33
+ import { CLOSE_DURATION_WEB, CLOSE_SPRING, OPEN_DURATION_WEB, OPEN_SPRING } from "../zoomable-media-gallery/constants.js";
34
+ /**
35
+ * Default corner radius of a flying box — Bloom's `radius-12`, the same value
36
+ * the media gallery fits its media at, so a flight that lands in the gallery
37
+ * lands on an identical shape.
38
+ */
39
+ export const DEFAULT_FLIGHT_CORNER_RADIUS = RADIUS['radius-12'];
40
+
41
+ /**
42
+ * Bookkeeping the layer does not RENDER, kept out of the `MediaFlight` record
43
+ * on purpose.
44
+ *
45
+ * The record is replaced on every visual change so its identity tells React the
46
+ * leg moved; folding these flags into it would churn that identity on events
47
+ * nobody paints, and folding the record into these would put mutable state back
48
+ * in a rendered position. They are separate because they answer to different
49
+ * consumers.
50
+ */
51
+
52
+ function emptyRegistry() {
53
+ return {
54
+ anchors: new Map(),
55
+ flights: new Map(),
56
+ status: new Map(),
57
+ listeners: new Set(),
58
+ snapshot: [],
59
+ progress: makeMutable(0)
60
+ };
61
+ }
62
+ function statusFor(id) {
63
+ const reg = registry();
64
+ let status = reg.status.get(id);
65
+ if (!status) {
66
+ status = {
67
+ mounted: false,
68
+ settled: false,
69
+ handedOff: false,
70
+ mountWaiters: [],
71
+ mountTimer: null
72
+ };
73
+ reg.status.set(id, status);
74
+ }
75
+ return status;
76
+ }
77
+ function clearTimers(status) {
78
+ if (status.mountTimer !== null) clearTimeout(status.mountTimer);
79
+ status.mountTimer = null;
80
+ }
81
+ function resolveMountWaiters(status) {
82
+ const waiters = status.mountWaiters;
83
+ status.mountWaiters = [];
84
+ if (status.mountTimer !== null) {
85
+ clearTimeout(status.mountTimer);
86
+ status.mountTimer = null;
87
+ }
88
+ for (const waiter of waiters) waiter();
89
+ }
90
+ function registry() {
91
+ globalThis.__oxyhq_bloom_media_flight__ ??= emptyRegistry();
92
+ return globalThis.__oxyhq_bloom_media_flight__;
93
+ }
94
+ function publish(reg) {
95
+ reg.snapshot = [...reg.flights.values()];
96
+ for (const listener of reg.listeners) listener();
97
+ }
98
+
99
+ /** Subscribe to the live-surface set. The layer's `useSyncExternalStore` half. */
100
+ export function subscribeToFlights(listener) {
101
+ const reg = registry();
102
+ reg.listeners.add(listener);
103
+ return () => {
104
+ reg.listeners.delete(listener);
105
+ };
106
+ }
107
+
108
+ /** The live surfaces, oldest first. Stable identity between changes. */
109
+ export function getFlights() {
110
+ return registry().snapshot;
111
+ }
112
+
113
+ /** The shared progress value of the most recent leg. */
114
+ export function flightProgress() {
115
+ return registry().progress;
116
+ }
117
+
118
+ /**
119
+ * Register (or clear) the node that anchors `id`.
120
+ *
121
+ * A `Map` re-insertion moves the key to the end, which is what makes "the most
122
+ * recently registered node is the anchor" true even when an origin screen's
123
+ * callback ref fires again after the destination has registered.
124
+ */
125
+ export function registerAnchor(id, node) {
126
+ const reg = registry();
127
+ reg.anchors.delete(id);
128
+ if (node !== null) reg.anchors.set(id, node);
129
+ }
130
+ export function measureAnchor(id) {
131
+ const node = registry().anchors.get(id);
132
+ if (!node) return Promise.resolve(null);
133
+ return new Promise(resolve => {
134
+ node.measureInWindow((x, y, width, height) => {
135
+ // A zero-area measurement is what a node reports while it is laid out but
136
+ // not yet on screen. Flying to it would collapse the surface to a point,
137
+ // so it reads as "no anchor" and the caller skips the transition.
138
+ resolve(width > 0 && height > 0 ? {
139
+ x,
140
+ y,
141
+ width,
142
+ height
143
+ } : null);
144
+ });
145
+ });
146
+ }
147
+
148
+ /** Whether a surface is currently live for `id`. */
149
+ export function hasFlight(id) {
150
+ return registry().flights.has(id);
151
+ }
152
+
153
+ /**
154
+ * Take the surface for `id` live (if it is not already) and move it to `rect`.
155
+ *
156
+ * Retargeting mid-flight keeps the SAME `MediaFlight` record — and therefore the
157
+ * same mounted `VideoView` — which is the whole point. A second record would be
158
+ * a second surface for one id, and swapping between them is exactly the remount
159
+ * that restarts playback.
160
+ *
161
+ * ## Why it returns a promise, and what the promise means
162
+ *
163
+ * It resolves once the layer has COMMITTED a surface for this id — not once
164
+ * that surface has painted.
165
+ *
166
+ * The distinction is the whole ordering contract. expo-video's web player keeps
167
+ * a `Set` of mounted `<video>` elements and, on each mount, copies
168
+ * `currentTime`, play state, volume, muted and rate from `[...set][0]`. If the
169
+ * set is EMPTY when the new element mounts, it returns early and the element
170
+ * starts at zero — a restart. So the layer's surface has to enter that set while
171
+ * the origin's is still in it, which means the caller must not tear the origin
172
+ * down (on web: must not navigate) until this promise resolves.
173
+ *
174
+ * That knowledge lives here rather than in the caller, which is the point: a
175
+ * consumer that has to know the mount order is a consumer that will get it wrong
176
+ * once and produce an intermittent restart nobody can reproduce locally.
177
+ *
178
+ * Painting is deliberately NOT waited on. `MediaSurface` renders the poster
179
+ * BEHIND the video on both platforms, and neither an unpainted `<video>` (no
180
+ * `poster` attribute is set) nor an Android `TextureView` with the ExoPlayer
181
+ * shutter off draws anything opaque — so the still shows through until the first
182
+ * frame lands, and there is no black box to hide. Waiting for a decode would
183
+ * trade an invisible problem for a laggy tap.
184
+ */
185
+ export function flyTo(id, rect, content, options) {
186
+ const reg = registry();
187
+ const existing = reg.flights.get(id);
188
+ if (existing) {
189
+ // A retarget REPLACES the record rather than mutating it. Identity is what
190
+ // tells React (and the React Compiler) that the leg changed: a mutated
191
+ // record has the same identity, so a memoized read of `flight.from` would
192
+ // keep returning the previous leg's origin forever — the exact
193
+ // external-mutable-state stale read the compiler is documented to produce.
194
+ // The shared value is carried over untouched, so the surface resumes rather
195
+ // than restarting.
196
+ const next = {
197
+ ...existing,
198
+ // The leg that was running is abandoned where it stands: `from` becomes
199
+ // the rect the surface is CURRENTLY at, so a retarget never snaps.
200
+ from: interpolateRect(existing.from, existing.to, existing.progress.value),
201
+ to: rect,
202
+ content,
203
+ cornerRadius: options?.cornerRadius ?? existing.cornerRadius,
204
+ contentFit: options?.contentFit ?? existing.contentFit,
205
+ // NOT retargetable: `MediaSurface` captures it on first render because
206
+ // expo-video forbids changing it at runtime, so a new value here would be
207
+ // silently ignored by the view it is meant to configure.
208
+ surfaceType: existing.surfaceType,
209
+ landing: false,
210
+ generation: existing.generation + 1
211
+ };
212
+ reg.flights.set(id, next);
213
+ const retargeted = statusFor(id);
214
+ retargeted.settled = false;
215
+ animate(next, false);
216
+ publish(reg);
217
+ return awaitSurfaceMount(id);
218
+ }
219
+
220
+ // Nothing live yet. `from` is the origin rect the caller measured; without one
221
+ // the surface simply appears at `rect` rather than flying in from a corner.
222
+ const flight = {
223
+ id,
224
+ content,
225
+ from: options?.from ?? rect,
226
+ to: rect,
227
+ cornerRadius: options?.cornerRadius ?? DEFAULT_FLIGHT_CORNER_RADIUS,
228
+ contentFit: options?.contentFit ?? 'cover',
229
+ surfaceType: options?.surfaceType ?? 'textureView',
230
+ progress: makeMutable(0),
231
+ landing: false,
232
+ generation: 0
233
+ };
234
+ reg.flights.set(id, flight);
235
+ const status = statusFor(id);
236
+ status.mounted = false;
237
+ status.settled = false;
238
+ status.handedOff = false;
239
+ animate(flight, false);
240
+ publish(reg);
241
+ return awaitSurfaceMount(id);
242
+ }
243
+
244
+ /**
245
+ * Resolve once `<MediaFlightLayer>` reports it has committed the surface, or
246
+ * after {@link SURFACE_MOUNT_TIMEOUT_MS} — which is what happens when no layer
247
+ * is mounted at all. Degrading to "carry on without a transition" is right;
248
+ * never resolving would mean an app that forgot one line at its root has a feed
249
+ * whose videos cannot be opened.
250
+ */
251
+ function awaitSurfaceMount(id) {
252
+ const status = statusFor(id);
253
+ if (status.mounted) return Promise.resolve();
254
+ return new Promise(resolve => {
255
+ status.mountWaiters.push(resolve);
256
+ if (status.mountTimer !== null) return;
257
+ status.mountTimer = setTimeout(() => {
258
+ status.mountTimer = null;
259
+ warnNoLayerMounted();
260
+ resolveMountWaiters(status);
261
+ }, SURFACE_MOUNT_TIMEOUT_MS);
262
+ });
263
+ }
264
+
265
+ /**
266
+ * The layer calls this from the surface's mount effect. It is the commit signal
267
+ * `flyTo` waits on, and the only thing that makes the ordering contract above
268
+ * true rather than hopeful.
269
+ */
270
+ export function notifySurfaceMounted(id) {
271
+ const status = statusFor(id);
272
+ status.mounted = true;
273
+ resolveMountWaiters(status);
274
+ }
275
+
276
+ /** The layer calls this when a leg's animation finishes. */
277
+ export function notifySurfaceSettled(id) {
278
+ const status = statusFor(id);
279
+ status.settled = true;
280
+ if (status.handedOff) releaseFlight(id);
281
+ }
282
+
283
+ /**
284
+ * A destination surface reporting that it is LIVE — it has presented a frame of
285
+ * its own, so the flying copy is now redundant and can go.
286
+ *
287
+ * This is the release condition, and it is deliberately not the animation's
288
+ * clock. Measured against production, a fullscreen video route needs ~1 s from
289
+ * tap to first presented frame; releasing when a ~300 ms animation ends would
290
+ * leave ~700 ms with nothing live on screen — the hole the transition exists to
291
+ * cover, made longer.
292
+ *
293
+ * Wire it by giving the destination's `<MediaSurface>` a `flightId`; it calls
294
+ * this itself on its first frame. A destination that renders something other
295
+ * than a Bloom surface can call it directly.
296
+ */
297
+ export function handOffFlight(id) {
298
+ const reg = registry();
299
+ if (!reg.flights.has(id)) return;
300
+ const status = statusFor(id);
301
+ status.handedOff = true;
302
+ // Mid-flight the surface is still travelling: releasing now would make it
303
+ // vanish somewhere between the two rects. `notifySurfaceSettled` picks it up.
304
+ if (status.settled) releaseFlight(id);
305
+ }
306
+
307
+ /**
308
+ * Aim the live surface at its anchor and release it once it lands.
309
+ *
310
+ * With no measurable anchor there is nothing to fly to, so the surface is
311
+ * released immediately — whoever owns the media renders its own copy again at
312
+ * that point, and holding a flying copy over it would double the video.
313
+ */
314
+ export function flyBack(id) {
315
+ const flight = registry().flights.get(id);
316
+ if (!flight) return;
317
+ void measureAnchor(id).then(rect => {
318
+ // Re-read: the flight may have been released or retargeted while the
319
+ // measurement was outstanding (`measureInWindow` is asynchronous on both
320
+ // platforms), and landing a stale record would fly the wrong surface.
321
+ const reg = registry();
322
+ if (reg.flights.get(id) !== flight) return;
323
+ if (rect === null) {
324
+ releaseFlight(id);
325
+ return;
326
+ }
327
+ const landing = {
328
+ ...flight,
329
+ from: interpolateRect(flight.from, flight.to, flight.progress.value),
330
+ to: rect,
331
+ landing: true,
332
+ generation: flight.generation + 1
333
+ };
334
+ reg.flights.set(id, landing);
335
+ animate(landing, true);
336
+ publish(reg);
337
+ });
338
+ }
339
+
340
+ /** Drop the surface for `id`. Called when a landing leg settles, and on teardown. */
341
+ export function releaseFlight(id) {
342
+ const reg = registry();
343
+ const status = reg.status.get(id);
344
+ if (status) {
345
+ // A waiter still parked on `flyTo`'s promise would otherwise hang until its
346
+ // own timeout, holding a caller that has nothing left to wait for.
347
+ clearTimers(status);
348
+ resolveMountWaiters(status);
349
+ reg.status.delete(id);
350
+ }
351
+ if (!reg.flights.delete(id)) return;
352
+ publish(reg);
353
+ }
354
+
355
+ /** Test seam — drops every anchor and surface. */
356
+ export function resetMediaFlight() {
357
+ const existing = globalThis.__oxyhq_bloom_media_flight__;
358
+ // Timers outlive a registry swap: an unfired mount timeout from the previous
359
+ // suite would warn — and resolve a waiter nobody is holding — inside the next.
360
+ if (existing) for (const status of existing.status.values()) clearTimers(status);
361
+ globalThis.__oxyhq_bloom_media_flight__ = emptyRegistry();
362
+ hasWarnedNoLayer = false;
363
+ }
364
+ let hasWarnedNoLayer = false;
365
+
366
+ /**
367
+ * One warning per module lifetime, and none in production — the same mechanism
368
+ * as the optional-peer boundaries. A missing `<MediaFlightLayer>` is otherwise
369
+ * completely silent: every `flyTo` resolves on its timeout and the app simply
370
+ * never shows a transition, which looks like the feature not being wired rather
371
+ * than the root not being.
372
+ */
373
+ function warnNoLayerMounted() {
374
+ if (process.env.NODE_ENV === 'production' || hasWarnedNoLayer) return;
375
+ hasWarnedNoLayer = true;
376
+ // eslint-disable-next-line no-console
377
+ console.warn('[Bloom] flyTo() timed out waiting for a media surface to mount. Nothing is ' + 'rendering <MediaFlightLayer>, so no media transition will ever run and a ' + 'video opened from a feed will restart. Mount it ONCE at the app root ' + '(app/_layout.tsx), above the router.');
378
+ }
379
+
380
+ /** Rect at `t` along `from` → `to`, so a retarget resumes rather than snapping. */
381
+ function interpolateRect(from, to, t) {
382
+ const clamped = t < 0 ? 0 : t > 1 ? 1 : t;
383
+ return {
384
+ x: from.x + (to.x - from.x) * clamped,
385
+ y: from.y + (to.y - from.y) * clamped,
386
+ width: from.width + (to.width - from.width) * clamped,
387
+ height: from.height + (to.height - from.height) * clamped
388
+ };
389
+ }
390
+
391
+ /**
392
+ * Run one leg: 0 → 1 on the flight's own value, and on the shared `progress` a
393
+ * consumer reads.
394
+ *
395
+ * Both are driven with the SAME curve rather than one deriving from the other,
396
+ * because deriving would need a `useAnimatedReaction` — a hook, in a module with
397
+ * no component to hang it on. Two animations on two shared values cost a few
398
+ * bytes on the UI thread and keep the driver at the call site.
399
+ *
400
+ * The springs and the web timings are the media gallery's, imported rather than
401
+ * re-tuned: a flight that lands in the gallery and the gallery's own open
402
+ * transition are the same motion, and two copies of a spring config drift.
403
+ */
404
+ function animate(flight, landing) {
405
+ const reg = registry();
406
+ const id = flight.id;
407
+ // EVERY leg reports its settlement, because the release condition is now
408
+ // "settled AND the destination is live" and either can arrive first. A
409
+ // `finished === false` callback means the leg was interrupted by a retarget,
410
+ // which owns the surface from then on.
411
+ //
412
+ // A LANDING leg is the one case that releases on its own: it has flown back to
413
+ // its anchor and there is nothing left to cover.
414
+ const onSettled = finished => {
415
+ 'worklet';
416
+
417
+ if (finished === false) return;
418
+ runOnJS(landing ? releaseFlight : notifySurfaceSettled)(id);
419
+ };
420
+ flight.progress.value = 0;
421
+ reg.progress.value = 0;
422
+ if (Platform.OS === 'web') {
423
+ const duration = landing ? CLOSE_DURATION_WEB : OPEN_DURATION_WEB;
424
+ const easing = landing ? Easing.in(Easing.cubic) : Easing.out(Easing.cubic);
425
+ flight.progress.value = withTiming(1, {
426
+ duration,
427
+ easing
428
+ }, onSettled);
429
+ reg.progress.value = withTiming(1, {
430
+ duration,
431
+ easing
432
+ });
433
+ return;
434
+ }
435
+ const spring = landing ? CLOSE_SPRING : OPEN_SPRING;
436
+ flight.progress.value = withSpring(1, spring, onSettled);
437
+ reg.progress.value = withSpring(1, spring);
438
+ }
439
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","Easing","makeMutable","runOnJS","withSpring","withTiming","RADIUS","SURFACE_MOUNT_TIMEOUT_MS","CLOSE_DURATION_WEB","CLOSE_SPRING","OPEN_DURATION_WEB","OPEN_SPRING","DEFAULT_FLIGHT_CORNER_RADIUS","emptyRegistry","anchors","Map","flights","status","listeners","Set","snapshot","progress","statusFor","id","reg","registry","get","mounted","settled","handedOff","mountWaiters","mountTimer","set","clearTimers","clearTimeout","resolveMountWaiters","waiters","waiter","globalThis","__oxyhq_bloom_media_flight__","publish","values","listener","subscribeToFlights","add","delete","getFlights","flightProgress","registerAnchor","node","measureAnchor","Promise","resolve","measureInWindow","x","y","width","height","hasFlight","has","flyTo","rect","content","options","existing","next","from","interpolateRect","to","value","cornerRadius","contentFit","surfaceType","landing","generation","retargeted","animate","awaitSurfaceMount","flight","push","setTimeout","warnNoLayerMounted","notifySurfaceMounted","notifySurfaceSettled","releaseFlight","handOffFlight","flyBack","then","resetMediaFlight","hasWarnedNoLayer","process","env","NODE_ENV","console","warn","t","clamped","onSettled","finished","OS","duration","easing","in","cubic","out","spring"],"sourceRoot":"../../../src","sources":["media-flight/store.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SACEC,MAAM,EACNC,WAAW,EACXC,OAAO,EACPC,UAAU,EACVC,UAAU,QAEL,yBAAyB;AAEhC,SAASC,MAAM,QAAQ,2BAAkB;AACzC,SAASC,wBAAwB,QAAQ,gBAAa;AACtD,SACEC,kBAAkB,EAClBC,YAAY,EACZC,iBAAiB,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AACgD,KAAK,GAAG,CAAC;EAEtB,IAAIrE,QAAQ,CAACmG,EAAE,KAAK,KAAK,EAAE;IACzB,MAAMC,QAAQ,GAAG3B,OAAO,GAAGjE,kBAAkB,GAAGE,iBAAiB;IACjE,MAAM2F,MAAM,GAAG5B,OAAO,GAAGxE,MAAM,CAACqG,EAAE,CAACrG,MAAM,CAACsG,KAAK,CAAC,GAAGtG,MAAM,CAACuG,GAAG,CAACvG,MAAM,CAACsG,KAAK,CAAC;IAC3EzB,MAAM,CAACzD,QAAQ,CAACgD,KAAK,GAAGhE,UAAU,CAAC,CAAC,EAAE;MAAE+F,QAAQ;MAAEC;IAAO,CAAC,EAAEJ,SAAS,CAAC;IACtEzE,GAAG,CAACH,QAAQ,CAACgD,KAAK,GAAGhE,UAAU,CAAC,CAAC,EAAE;MAAE+F,QAAQ;MAAEC;IAAO,CAAC,CAAC;IACxD;EACF;EAEA,MAAMI,MAAM,GAAGhC,OAAO,GAAGhE,YAAY,GAAGE,WAAW;EACnDmE,MAAM,CAACzD,QAAQ,CAACgD,KAAK,GAAGjE,UAAU,CAAC,CAAC,EAAEqG,MAAM,EAAER,SAAS,CAAC;EACxDzE,GAAG,CAACH,QAAQ,CAACgD,KAAK,GAAGjE,UAAU,CAAC,CAAC,EAAEqG,MAAM,CAAC;AAC5C","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["media-flight/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The consumer-facing handle on the flight layer.
5
+ *
6
+ * Every member is a module-level function over a `globalThis`-anchored registry,
7
+ * so the object is a frozen constant rather than something rebuilt per render:
8
+ * a caller may hold it in a dependency array, a callback ref or a gesture
9
+ * closure without any of them going stale, and there is no provider to mount.
10
+ */
11
+ import { flightProgress, flyBack, flyTo, handOffFlight, measureAnchor, registerAnchor } from "./store.js";
12
+ /**
13
+ * `flyTo` / `flyBack` / `registerAnchor` / `measureAnchor`, plus the shared
14
+ * `progress` value of the most recent leg.
15
+ *
16
+ * `progress` is resolved through a getter rather than captured at module load,
17
+ * because `resetMediaFlight()` (the test seam) replaces the registry — a
18
+ * captured value would keep pointing at the discarded one and every assertion
19
+ * about progress would read a box nothing writes.
20
+ */
21
+ const controller = Object.freeze({
22
+ registerAnchor,
23
+ measureAnchor,
24
+ flyTo,
25
+ flyBack,
26
+ handOff: handOffFlight,
27
+ get progress() {
28
+ return flightProgress();
29
+ }
30
+ });
31
+
32
+ /** The media-flight controller. Stable for the life of the bundle. */
33
+ export function useMediaFlight() {
34
+ return controller;
35
+ }
36
+ //# sourceMappingURL=use-media-flight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["flightProgress","flyBack","flyTo","handOffFlight","measureAnchor","registerAnchor","controller","Object","freeze","handOff","progress","useMediaFlight"],"sourceRoot":"../../../src","sources":["media-flight/use-media-flight.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,cAAc,EACdC,OAAO,EACPC,KAAK,EACLC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,YAAS;AAGhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAiC,GAAGC,MAAM,CAACC,MAAM,CAAC;EACtDH,cAAc;EACdD,aAAa;EACbF,KAAK;EACLD,OAAO;EACPQ,OAAO,EAAEN,aAAa;EACtB,IAAIO,QAAQA,CAAA,EAAG;IACb,OAAOV,cAAc,CAAC,CAAC;EACzB;AACF,CAAC,CAAC;;AAEF;AACA,OAAO,SAASW,cAAcA,CAAA,EAA0B;EACtD,OAAOL,UAAU;AACnB","ignoreList":[]}
@@ -238,7 +238,7 @@ function TabBarBody({
238
238
  // never minimize and the highlight would never move, with no error anywhere.
239
239
  // Native (plugin present) auto-tracks and ignores the extra deps, so listing
240
240
  // them is correct on both platforms. Same rule as `BottomSheetBase` and
241
- // `ZoomableImageGallery`. Do NOT strip these.
241
+ // `ZoomableMediaGallery`. Do NOT strip these.
242
242
  const barStyle = useAnimatedStyle(() => {
243
243
  const height = interpolate(progress.value, [0, 1], [EXPANDED_HEIGHT, MINIMIZED_HEIGHT], Extrapolation.CLAMP);
244
244
  // Revolut-style: the pill shrinks in both dimensions.