@oxyhq/bloom 1.2.2 → 1.4.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.
- package/docs/media-flight.mdx +133 -0
- package/lib/commonjs/media-flight/MediaFlightHost.js +58 -0
- package/lib/commonjs/media-flight/MediaFlightHost.js.map +1 -0
- package/lib/commonjs/media-flight/MediaFlightHost.web.js +87 -0
- package/lib/commonjs/media-flight/MediaFlightHost.web.js.map +1 -0
- package/lib/commonjs/media-flight/MediaFlightLayer.js +4 -2
- package/lib/commonjs/media-flight/MediaFlightLayer.js.map +1 -1
- package/lib/commonjs/media-flight/MediaFlightLayer.web.js +198 -0
- package/lib/commonjs/media-flight/MediaFlightLayer.web.js.map +1 -0
- package/lib/commonjs/media-flight/MediaSurface.js +13 -5
- package/lib/commonjs/media-flight/MediaSurface.js.map +1 -1
- package/lib/commonjs/media-flight/index.js +8 -1
- package/lib/commonjs/media-flight/index.js.map +1 -1
- package/lib/commonjs/media-flight/index.web.js +115 -0
- package/lib/commonjs/media-flight/index.web.js.map +1 -0
- package/lib/commonjs/media-flight/media-node.web.js +314 -0
- package/lib/commonjs/media-flight/media-node.web.js.map +1 -0
- package/lib/commonjs/media-flight/store.js +19 -4
- package/lib/commonjs/media-flight/store.js.map +1 -1
- package/lib/module/media-flight/MediaFlightHost.js +53 -0
- package/lib/module/media-flight/MediaFlightHost.js.map +1 -0
- package/lib/module/media-flight/MediaFlightHost.web.js +82 -0
- package/lib/module/media-flight/MediaFlightHost.web.js.map +1 -0
- package/lib/module/media-flight/MediaFlightLayer.js +4 -2
- package/lib/module/media-flight/MediaFlightLayer.js.map +1 -1
- package/lib/module/media-flight/MediaFlightLayer.web.js +192 -0
- package/lib/module/media-flight/MediaFlightLayer.web.js.map +1 -0
- package/lib/module/media-flight/MediaSurface.js +13 -5
- package/lib/module/media-flight/MediaSurface.js.map +1 -1
- package/lib/module/media-flight/index.js +2 -1
- package/lib/module/media-flight/index.js.map +1 -1
- package/lib/module/media-flight/index.web.js +19 -0
- package/lib/module/media-flight/index.web.js.map +1 -0
- package/lib/module/media-flight/media-node.web.js +304 -0
- package/lib/module/media-flight/media-node.web.js.map +1 -0
- package/lib/module/media-flight/store.js +19 -4
- package/lib/module/media-flight/store.js.map +1 -1
- package/lib/typescript/commonjs/media-flight/MediaFlightHost.d.ts +6 -0
- package/lib/typescript/commonjs/media-flight/MediaFlightHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-flight/MediaFlightHost.web.d.ts +6 -0
- package/lib/typescript/commonjs/media-flight/MediaFlightHost.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-flight/MediaFlightLayer.web.d.ts +5 -0
- package/lib/typescript/commonjs/media-flight/MediaFlightLayer.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-flight/MediaSurface.d.ts +19 -7
- package/lib/typescript/commonjs/media-flight/MediaSurface.d.ts.map +1 -1
- package/lib/typescript/commonjs/media-flight/index.d.ts +2 -1
- package/lib/typescript/commonjs/media-flight/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/media-flight/index.web.d.ts +19 -0
- package/lib/typescript/commonjs/media-flight/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-flight/media-node.web.d.ts +93 -0
- package/lib/typescript/commonjs/media-flight/media-node.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-flight/store.d.ts +19 -4
- package/lib/typescript/commonjs/media-flight/store.d.ts.map +1 -1
- package/lib/typescript/commonjs/media-flight/types.d.ts +93 -0
- package/lib/typescript/commonjs/media-flight/types.d.ts.map +1 -1
- package/lib/typescript/module/media-flight/MediaFlightHost.d.ts +6 -0
- package/lib/typescript/module/media-flight/MediaFlightHost.d.ts.map +1 -0
- package/lib/typescript/module/media-flight/MediaFlightHost.web.d.ts +6 -0
- package/lib/typescript/module/media-flight/MediaFlightHost.web.d.ts.map +1 -0
- package/lib/typescript/module/media-flight/MediaFlightLayer.web.d.ts +5 -0
- package/lib/typescript/module/media-flight/MediaFlightLayer.web.d.ts.map +1 -0
- package/lib/typescript/module/media-flight/MediaSurface.d.ts +19 -7
- package/lib/typescript/module/media-flight/MediaSurface.d.ts.map +1 -1
- package/lib/typescript/module/media-flight/index.d.ts +2 -1
- package/lib/typescript/module/media-flight/index.d.ts.map +1 -1
- package/lib/typescript/module/media-flight/index.web.d.ts +19 -0
- package/lib/typescript/module/media-flight/index.web.d.ts.map +1 -0
- package/lib/typescript/module/media-flight/media-node.web.d.ts +93 -0
- package/lib/typescript/module/media-flight/media-node.web.d.ts.map +1 -0
- package/lib/typescript/module/media-flight/store.d.ts +19 -4
- package/lib/typescript/module/media-flight/store.d.ts.map +1 -1
- package/lib/typescript/module/media-flight/types.d.ts +93 -0
- package/lib/typescript/module/media-flight/types.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/media-flight/MediaFlightHost.tsx +56 -0
- package/src/media-flight/MediaFlightHost.web.tsx +85 -0
- package/src/media-flight/MediaFlightLayer.tsx +4 -2
- package/src/media-flight/MediaFlightLayer.web.tsx +191 -0
- package/src/media-flight/MediaSurface.tsx +36 -12
- package/src/media-flight/index.ts +2 -0
- package/src/media-flight/index.web.ts +45 -0
- package/src/media-flight/media-node.web.ts +373 -0
- package/src/media-flight/store.ts +19 -4
- package/src/media-flight/types.ts +96 -0
package/docs/media-flight.mdx
CHANGED
|
@@ -130,6 +130,15 @@ reports that itself (expo-video's `onFirstFrameRender`, expo-image's `onLoad`).
|
|
|
130
130
|
Called mid-flight, a hand-off is remembered rather than obeyed — the surface
|
|
131
131
|
finishes travelling first, or it would vanish between the two rects.
|
|
132
132
|
|
|
133
|
+
On web the release then renders one commit with `player={null}` before the node
|
|
134
|
+
leaves the DOM. What that buys is **not** the unbind beside it: expo-video
|
|
135
|
+
answers a null player with `removeAttribute('src'); load()`, and the media
|
|
136
|
+
element load algorithm pauses WITHOUT firing `pause`, so the outgoing element
|
|
137
|
+
goes quiet and its removal mirrors nothing. Unbinding alone would not help —
|
|
138
|
+
`unmountVideoView` never clears the `onpause` it installed. Measured in real
|
|
139
|
+
Chrome with controls, and against real builds: without that commit the
|
|
140
|
+
destination ends stopped, with it playing and in position.
|
|
141
|
+
|
|
133
142
|
**The success criterion is continuity, not speed.** With a shared player the
|
|
134
143
|
frame is already on screen before the tap; the flight does not make the video
|
|
135
144
|
appear sooner, it makes it never disappear. Measure "was there ever no frame?"
|
|
@@ -198,10 +207,134 @@ Concretely:
|
|
|
198
207
|
| `flyBack(id)` | flies it to its anchor and releases it on landing |
|
|
199
208
|
| `progress` | `SharedValue<number>`, 0 → 1 for the most recent leg |
|
|
200
209
|
|
|
210
|
+
And one component, `<MediaFlightHost id content style … />` — where the media
|
|
211
|
+
lives when it is not flying. See below.
|
|
212
|
+
|
|
201
213
|
The most recently registered node for an id **is** the anchor, which is what
|
|
202
214
|
makes a destination mounting over an origin take over as the fly-back target
|
|
203
215
|
without either of them coordinating.
|
|
204
216
|
|
|
217
|
+
## `MediaFlightHost`: one element for the whole flight, on web
|
|
218
|
+
|
|
219
|
+
Everything above is what a flight does with a **picture**. A video needs one
|
|
220
|
+
more thing, and it is not a matter of ordering: on web the pause and the
|
|
221
|
+
restart are properties of TWO elements sharing one player.
|
|
222
|
+
|
|
223
|
+
Measured against expo-video's real `VideoPlayerWeb` (57.0.2), across every
|
|
224
|
+
element topology a consumer can produce on one player:
|
|
225
|
+
|
|
226
|
+
| topology | position | playback |
|
|
227
|
+
| ------------------------------------------ | -------- | -------- |
|
|
228
|
+
| origin dies BEFORE the destination mounts | `ct=0` | playing |
|
|
229
|
+
| origin dies AFTER the destination mounts | `ct=4.28`| paused |
|
|
230
|
+
| one element, re-parented | `ct=4.28`| playing |
|
|
231
|
+
|
|
232
|
+
The first two rows contain no Bloom surface at all — a feed row and a fullscreen
|
|
233
|
+
player sharing a player produce them on their own. Two elements give you the
|
|
234
|
+
position or the playback, never both, because `mountVideoView` seeds a new
|
|
235
|
+
element from the first one already mounted and `_addListeners` gives every
|
|
236
|
+
element an `onpause` that pauses all the others — handlers `unmountVideoView`
|
|
237
|
+
never removes. An element on its way out still governs the player.
|
|
238
|
+
|
|
239
|
+
So on web, Bloom paints the media **once**, into a wrapper it created outside
|
|
240
|
+
React, and moves that wrapper between the boxes that want it:
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
// The feed row
|
|
244
|
+
<MediaFlightHost id={mediaId} content={{ kind: 'video', player }} contentFit="cover"
|
|
245
|
+
style={{ width: 320, height: 180, borderRadius: 12, overflow: 'hidden' }} />
|
|
246
|
+
|
|
247
|
+
// The fullscreen route, later, with the same id and the same player
|
|
248
|
+
<MediaFlightHost id={mediaId} content={{ kind: 'video', player }} contentFit="contain"
|
|
249
|
+
style={StyleSheet.absoluteFill} />
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
A host **declares a box**; it does not own the media. It also registers itself
|
|
253
|
+
as the flight's anchor, so `flyTo`/`flyBack` measure the box the media actually
|
|
254
|
+
paints in rather than a box the consumer measured separately.
|
|
255
|
+
|
|
256
|
+
On **native** `MediaFlightHost` renders its own `MediaSurface` inline, exactly
|
|
257
|
+
as consumers did before it existed. One API, two implementations, and nothing
|
|
258
|
+
about the call site says which one you got.
|
|
259
|
+
|
|
260
|
+
### Why it works, in three parts
|
|
261
|
+
|
|
262
|
+
- **React never sees the move.** The media is rendered with `createPortal` into
|
|
263
|
+
a container whose identity never changes, and a portal's container is not part
|
|
264
|
+
of React's tree. `createPortal` to a container that *changes* unmounts and
|
|
265
|
+
remounts — the thing being avoided — so the container is created once, outside
|
|
266
|
+
React, and only its position in the document changes.
|
|
267
|
+
- **The browser never sees a removal.** HTML's removal steps for a media element
|
|
268
|
+
await a stable state and then abort if the element is back in a document, so a
|
|
269
|
+
synchronous `appendChild` from one parent to another does not pause playback.
|
|
270
|
+
(This is why re-parenting a `<video>` works and re-parenting an `<iframe>`
|
|
271
|
+
does not: an iframe reloads.)
|
|
272
|
+
- **A node with no host waits IN the document.** It parks in a 1×1 transparent
|
|
273
|
+
holder, because a detached `<video>` is auto-paused. It is disposed when
|
|
274
|
+
nothing can want it back — no claim and no flight live for that id — which is
|
|
275
|
+
a fact the registry reads rather than a timeout it guesses.
|
|
276
|
+
|
|
277
|
+
### Paint the video yourself
|
|
278
|
+
|
|
279
|
+
`MediaFlightHost` mounts a `VideoView` with the handful of props Bloom knows
|
|
280
|
+
about. That is not enough the moment a consumer needs something only its OWN
|
|
281
|
+
element can give it — a `ref` for `startPictureInPicture()` or
|
|
282
|
+
`enterFullscreen()`, expo-video's picture-in-picture callbacks,
|
|
283
|
+
`onFirstFrameRender`, anything expo-video adds next. Measured in a consuming
|
|
284
|
+
app: adopting the host without this left a picture-in-picture BUTTON on screen
|
|
285
|
+
whose ref was attached to nothing. It rendered, it was pressable, and it did
|
|
286
|
+
nothing, silently.
|
|
287
|
+
|
|
288
|
+
So build the element yourself and let Bloom decide only what it must:
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
<MediaFlightHost
|
|
292
|
+
id={mediaId}
|
|
293
|
+
content={{ kind: 'video', player }}
|
|
294
|
+
renderVideo={useCallback((props) => (
|
|
295
|
+
<VideoView
|
|
296
|
+
{...props} // player, style, contentFit
|
|
297
|
+
ref={videoViewRef}
|
|
298
|
+
allowsPictureInPicture={isWatched}
|
|
299
|
+
onFirstFrameRender={handleFirstFrame}
|
|
300
|
+
/>
|
|
301
|
+
), [isWatched, handleFirstFrame])}
|
|
302
|
+
/>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Three things about the props Bloom passes:
|
|
306
|
+
|
|
307
|
+
- **Spread `style`.** A DOM `<video>` is a replaced element: `inset: 0` with
|
|
308
|
+
`width/height: auto` paints it at its intrinsic 300×150 inside whatever box it
|
|
309
|
+
was given. Bloom's style carries the sizing.
|
|
310
|
+
- **Pass `player` straight through, including `null`.** Null means unbind now,
|
|
311
|
+
and expo-video answers it by emptying the source — which pauses the element
|
|
312
|
+
without an event, which is what stops an outgoing surface from pausing the one
|
|
313
|
+
the viewer just landed on.
|
|
314
|
+
- **Memoise the slot.** It is part of what a host publishes to the layer,
|
|
315
|
+
compared by identity.
|
|
316
|
+
|
|
317
|
+
The flight itself never brings an element. Its claim on a shared node says only
|
|
318
|
+
WHERE the node lives — a flight that published its own render would swap a
|
|
319
|
+
consumer's element out for Bloom's and back again, which is two remounts in the
|
|
320
|
+
middle of the one operation whose whole point is that the element is never
|
|
321
|
+
rebuilt.
|
|
322
|
+
|
|
323
|
+
### The flight outranks every host
|
|
324
|
+
|
|
325
|
+
A destination that mounts mid-flight claims its id, and the layer keeps the node
|
|
326
|
+
anyway until the leg ends — otherwise the media would jump to its landing place
|
|
327
|
+
while still travelling. That claim IS the hand-off: with one element there is no
|
|
328
|
+
first frame to wait for, because the element the destination just claimed has
|
|
329
|
+
been playing since the origin. `flightId` and `handOff` remain for native and
|
|
330
|
+
for a destination that paints its own surface.
|
|
331
|
+
|
|
332
|
+
### What it does not change
|
|
333
|
+
|
|
334
|
+
`flyTo` with an id that has no host still paints its own `MediaSurface`, which
|
|
335
|
+
is what every image flight does. Nothing about the gallery, the anchors or the
|
|
336
|
+
animation changes.
|
|
337
|
+
|
|
205
338
|
## It never takes a click
|
|
206
339
|
|
|
207
340
|
Every node the layer renders is `pointerEvents="none"`, inside an `OverlayRoot`
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MediaFlightHost = MediaFlightHost;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _MediaSurface = require("./MediaSurface.js");
|
|
10
|
+
var _store = require("./store.js");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
/**
|
|
13
|
+
* A place a media surface lives — NATIVE.
|
|
14
|
+
*
|
|
15
|
+
* Here a host is exactly what it looks like: a box that renders its own
|
|
16
|
+
* `MediaSurface`. Native has no equivalent of the web problem this component
|
|
17
|
+
* exists for (a DOM `<video>` that must survive its React owner), and expo-video
|
|
18
|
+
* on native hands a player between views without the pause mirroring that makes
|
|
19
|
+
* two web elements mutually destructive. So this is the plain implementation,
|
|
20
|
+
* and `MediaFlightHost.web.tsx` is the one that re-parents.
|
|
21
|
+
*
|
|
22
|
+
* ONE API, two implementations. A consumer writes the same JSX on both
|
|
23
|
+
* platforms and never learns which one it got.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
function MediaFlightHost({
|
|
27
|
+
id,
|
|
28
|
+
content,
|
|
29
|
+
style,
|
|
30
|
+
contentFit = 'cover',
|
|
31
|
+
renderVideo,
|
|
32
|
+
nativeControls = false,
|
|
33
|
+
accessibilityLabel,
|
|
34
|
+
surfaceType,
|
|
35
|
+
pointerEvents,
|
|
36
|
+
flightId
|
|
37
|
+
}) {
|
|
38
|
+
// A callback ref rather than an effect: the anchor must be measurable the
|
|
39
|
+
// moment the box is on screen, and a tap can come one frame later.
|
|
40
|
+
const setNode = (0, _react.useCallback)(node => (0, _store.registerAnchor)(id, node), [id]);
|
|
41
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
42
|
+
ref: setNode,
|
|
43
|
+
style: style,
|
|
44
|
+
pointerEvents: pointerEvents,
|
|
45
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaSurface.MediaSurface, {
|
|
46
|
+
content: content,
|
|
47
|
+
contentFit: contentFit,
|
|
48
|
+
renderVideo: renderVideo,
|
|
49
|
+
nativeControls: nativeControls,
|
|
50
|
+
accessibilityLabel: accessibilityLabel,
|
|
51
|
+
surfaceType: surfaceType,
|
|
52
|
+
flightId: flightId,
|
|
53
|
+
style: _reactNative.StyleSheet.absoluteFill
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
MediaFlightHost.displayName = 'MediaFlightHost';
|
|
58
|
+
//# sourceMappingURL=MediaFlightHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_MediaSurface","_store","_jsxRuntime","MediaFlightHost","id","content","style","contentFit","renderVideo","nativeControls","accessibilityLabel","surfaceType","pointerEvents","flightId","setNode","useCallback","node","registerAnchor","jsx","View","ref","children","MediaSurface","StyleSheet","absoluteFill","displayName"],"sourceRoot":"../../../src","sources":["media-flight/MediaFlightHost.tsx"],"mappings":";;;;;;AAaA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAyC,IAAAI,WAAA,GAAAJ,OAAA;AAjBzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQO,SAASK,eAAeA,CAAC;EAC9BC,EAAE;EACFC,OAAO;EACPC,KAAK;EACLC,UAAU,GAAG,OAAO;EACpBC,WAAW;EACXC,cAAc,GAAG,KAAK;EACtBC,kBAAkB;EAClBC,WAAW;EACXC,aAAa;EACbC;AACoB,CAAC,EAAE;EACvB;EACA;EACA,MAAMC,OAAO,GAAG,IAAAC,kBAAW,EACxBC,IAAiB,IAAK,IAAAC,qBAAc,EAACb,EAAE,EAAEY,IAAI,CAAC,EAC/C,CAACZ,EAAE,CACL,CAAC;EAED,oBACE,IAAAF,WAAA,CAAAgB,GAAA,EAACnB,YAAA,CAAAoB,IAAI;IAACC,GAAG,EAAEN,OAAQ;IAACR,KAAK,EAAEA,KAAM;IAACM,aAAa,EAAEA,aAAc;IAAAS,QAAA,eAC7D,IAAAnB,WAAA,CAAAgB,GAAA,EAAClB,aAAA,CAAAsB,YAAY;MACXjB,OAAO,EAAEA,OAAQ;MACjBE,UAAU,EAAEA,UAAW;MACvBC,WAAW,EAAEA,WAAY;MACzBC,cAAc,EAAEA,cAAe;MAC/BC,kBAAkB,EAAEA,kBAAmB;MACvCC,WAAW,EAAEA,WAAY;MACzBE,QAAQ,EAAEA,QAAS;MACnBP,KAAK,EAAEiB,uBAAU,CAACC;IAAa,CAChC;EAAC,CACE,CAAC;AAEX;AAEArB,eAAe,CAACsB,WAAW,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MediaFlightHost = MediaFlightHost;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _mediaNodeWeb = require("./media-node.web.js");
|
|
10
|
+
var _store = require("./store.js");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
/**
|
|
13
|
+
* A place a media surface lives — WEB, where it does NOT render the media.
|
|
14
|
+
*
|
|
15
|
+
* This host renders an empty box and CLAIMS the shared node for its id. The
|
|
16
|
+
* media itself is one DOM node the layer paints once and moves between hosts
|
|
17
|
+
* with `appendChild`, so a video keeps its element, its decoder and its
|
|
18
|
+
* position when the origin route unmounts mid-flight. See `media-node.web.ts`
|
|
19
|
+
* for why one element is the only topology that keeps both the position and the
|
|
20
|
+
* playback.
|
|
21
|
+
*
|
|
22
|
+
* The consumer writes the same JSX as on native and never learns the
|
|
23
|
+
* difference — including that here, `flightId` is not needed: a flight ends
|
|
24
|
+
* when a destination host claims the node, and the node it claims has been
|
|
25
|
+
* showing the media all along.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
function MediaFlightHost({
|
|
29
|
+
id,
|
|
30
|
+
content,
|
|
31
|
+
style,
|
|
32
|
+
contentFit = 'cover',
|
|
33
|
+
renderVideo,
|
|
34
|
+
nativeControls = false,
|
|
35
|
+
accessibilityLabel,
|
|
36
|
+
pointerEvents,
|
|
37
|
+
flightId
|
|
38
|
+
}) {
|
|
39
|
+
// State rather than a ref, because the claim runs in a layout effect and an
|
|
40
|
+
// effect cannot depend on a ref's mutation. One extra render at mount.
|
|
41
|
+
const [node, setNode] = (0, _react.useState)(null);
|
|
42
|
+
const setHost = (0, _react.useCallback)(next => {
|
|
43
|
+
(0, _store.registerAnchor)(id, next);
|
|
44
|
+
setNode(next);
|
|
45
|
+
}, [id]);
|
|
46
|
+
const render = (0, _react.useMemo)(() => ({
|
|
47
|
+
content,
|
|
48
|
+
contentFit,
|
|
49
|
+
renderVideo,
|
|
50
|
+
nativeControls,
|
|
51
|
+
accessibilityLabel,
|
|
52
|
+
flightId
|
|
53
|
+
}), [content, contentFit, renderVideo, nativeControls, accessibilityLabel, flightId]);
|
|
54
|
+
const renderRef = (0, _react.useRef)(render);
|
|
55
|
+
|
|
56
|
+
// Declared FIRST so it runs first on mount: it seeds the ref the claim below
|
|
57
|
+
// reads, and afterwards it is what pushes prop changes into a live claim —
|
|
58
|
+
// in place, without releasing, because a release would move the node and a
|
|
59
|
+
// move away and back is a removal, which is what pauses a video.
|
|
60
|
+
(0, _react.useLayoutEffect)(() => {
|
|
61
|
+
renderRef.current = render;
|
|
62
|
+
const el = node;
|
|
63
|
+
if (el !== null) (0, _mediaNodeWeb.claimMediaNode)(id, el, _mediaNodeWeb.HOST_RANK, render);
|
|
64
|
+
}, [id, node, render]);
|
|
65
|
+
|
|
66
|
+
// Owns the claim's LIFETIME, and only that: its cleanup must run when the
|
|
67
|
+
// host really goes away, never on a prop change.
|
|
68
|
+
(0, _react.useLayoutEffect)(() => {
|
|
69
|
+
const el = node;
|
|
70
|
+
if (el === null) return undefined;
|
|
71
|
+
(0, _mediaNodeWeb.claimMediaNode)(id, el, _mediaNodeWeb.HOST_RANK, renderRef.current);
|
|
72
|
+
// A new host appearing mid-flight IS the hand-off. On native the
|
|
73
|
+
// destination has to decode a first frame before it can say this; here the
|
|
74
|
+
// node it just claimed is the one that has been playing since the origin,
|
|
75
|
+
// so mounting is the whole signal. An origin host does not reach this with
|
|
76
|
+
// a flight live — it claimed before the flight began.
|
|
77
|
+
if ((0, _store.hasFlight)(id)) (0, _store.handOffFlight)(id);
|
|
78
|
+
return () => (0, _mediaNodeWeb.releaseMediaNode)(id, el, _mediaNodeWeb.HOST_RANK);
|
|
79
|
+
}, [id, node]);
|
|
80
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
81
|
+
ref: setHost,
|
|
82
|
+
style: style,
|
|
83
|
+
pointerEvents: pointerEvents
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
MediaFlightHost.displayName = 'MediaFlightHost';
|
|
87
|
+
//# sourceMappingURL=MediaFlightHost.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_mediaNodeWeb","_store","_jsxRuntime","MediaFlightHost","id","content","style","contentFit","renderVideo","nativeControls","accessibilityLabel","pointerEvents","flightId","node","setNode","useState","setHost","useCallback","next","registerAnchor","render","useMemo","renderRef","useRef","useLayoutEffect","current","el","claimMediaNode","HOST_RANK","undefined","hasFlight","handOffFlight","releaseMediaNode","jsx","View","ref","displayName"],"sourceRoot":"../../../src","sources":["media-flight/MediaFlightHost.web.tsx"],"mappings":";;;;;;AAeA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAMA,IAAAG,MAAA,GAAAH,OAAA;AAAmE,IAAAI,WAAA,GAAAJ,OAAA;AAxBnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaO,SAASK,eAAeA,CAAC;EAC9BC,EAAE;EACFC,OAAO;EACPC,KAAK;EACLC,UAAU,GAAG,OAAO;EACpBC,WAAW;EACXC,cAAc,GAAG,KAAK;EACtBC,kBAAkB;EAClBC,aAAa;EACbC;AACoB,CAAC,EAAE;EACvB;EACA;EACA,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAG,IAAAC,eAAQ,EAAc,IAAI,CAAC;EA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ACxB,EAAE,EAAES,IAAI,CAAC,CAAC;EAEd,oBAAO,IAAAX,WAAA,CAAA+B,GAAA,EAAClC,YAAA,CAAAmC,IAAI;IAACC,GAAG,EAAEnB,OAAQ;IAACV,KAAK,EAAEA,KAAM;IAACK,aAAa,EAAEA;EAAc,CAAE,CAAC;AAC3E;AAEAR,eAAe,CAACiC,WAAW,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -133,8 +133,10 @@ function MediaFlightSurface({
|
|
|
133
133
|
contentFit: contentFit,
|
|
134
134
|
surfaceType: surfaceType
|
|
135
135
|
// One commit with no player before this node leaves the DOM — see
|
|
136
|
-
// `releaseFlight
|
|
137
|
-
//
|
|
136
|
+
// `releaseFlight`, and note there that what it buys is expo-video
|
|
137
|
+
// emptying the source, not the unbind. Without it the dying element's
|
|
138
|
+
// auto-pause mirrors through expo-video and stops the video the viewer
|
|
139
|
+
// just landed on.
|
|
138
140
|
,
|
|
139
141
|
detached: unbinding
|
|
140
142
|
// A flying surface is a picture, never a control: it must not intercept
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_index","_portal","_MediaSurface","_store","_jsxRuntime","MediaFlightLayer","flights","useSyncExternalStore","subscribeToFlights","getFlights","length","jsx","Portal","children","OverlayRoot","map","flight","MediaFlightSurface","id","displayName","from","to","progress","content","cornerRadius","contentFit","surfaceType","unbinding","useEffect","notifySurfaceMounted","originX","x","originY","y","boxStyle","useAnimatedStyle","transform","translateX","interpolate","value","translateY","width","height","MediaSurface","detached","pointerEvents","style","styles","box","left","top","borderRadius","StyleSheet","create","position","overflow"],"sourceRoot":"../../../src","sources":["media-flight/MediaFlightLayer.tsx"],"mappings":";;;;;;AAqCA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;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;IACjBE,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA;IACb;IACA;IACA;IAAA;IACAkB,QAAQ,EAAEjB;IACV;IACA;IAAA;IACAkB,aAAa,EAAC,MAAM;IACpBC,KAAK,EAAE,CAACC,MAAM,CAACC,GAAG,EAAE;MAAEC,IAAI,EAAE5B,EAAE,CAACU,CAAC;MAAEmB,GAAG,EAAE7B,EAAE,CAACY,CAAC;MAAEkB,YAAY,EAAE3B;IAAa,CAAC,EAAEU,QAAQ;EAAE,CACtF,CAAC;AAEN;AAEA,MAAMa,MAAM,GAAGK,uBAAU,CAACC,MAAM,CAAC;EAC/BL,GAAG,EAAE;IACHM,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_index","_portal","_MediaSurface","_store","_jsxRuntime","MediaFlightLayer","flights","useSyncExternalStore","subscribeToFlights","getFlights","length","jsx","Portal","children","OverlayRoot","map","flight","MediaFlightSurface","id","displayName","from","to","progress","content","cornerRadius","contentFit","surfaceType","unbinding","useEffect","notifySurfaceMounted","originX","x","originY","y","boxStyle","useAnimatedStyle","transform","translateX","interpolate","value","translateY","width","height","MediaSurface","detached","pointerEvents","style","styles","box","left","top","borderRadius","StyleSheet","create","position","overflow"],"sourceRoot":"../../../src","sources":["media-flight/MediaFlightLayer.tsx"],"mappings":";;;;;;AAqCA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA+E,IAAAO,WAAA,GAAAP,OAAA;AA5C/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AM,CAACC,GAAG,EAAE;MAAEC,IAAI,EAAE5B,EAAE,CAACU,CAAC;MAAEmB,GAAG,EAAE7B,EAAE,CAACY,CAAC;MAAEkB,YAAY,EAAE3B;IAAa,CAAC,EAAEU,QAAQ;EAAE,CACtF,CAAC;AAEN;AAEA,MAAMa,MAAM,GAAGK,uBAAU,CAACC,MAAM,CAAC;EAC/BL,GAAG,EAAE;IACHM,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MediaFlightLayer = MediaFlightLayer;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactDom = require("react-dom");
|
|
10
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
11
|
+
var _index = require("../overlay/index.js");
|
|
12
|
+
var _indexWeb = require("../portal/index.web.js");
|
|
13
|
+
var _MediaSurface = require("./MediaSurface.js");
|
|
14
|
+
var _mediaNodeWeb = require("./media-node.web.js");
|
|
15
|
+
var _store = require("./store.js");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
+
/**
|
|
19
|
+
* The layer that survives navigation — WEB, where it also OWNS the media.
|
|
20
|
+
*
|
|
21
|
+
* Everything in `MediaFlightLayer.tsx` still holds: mounted once at the app
|
|
22
|
+
* root, painting through `Portal` so a flying surface belongs to neither route.
|
|
23
|
+
* What this fork adds is the other half of the web story.
|
|
24
|
+
*
|
|
25
|
+
* ## It paints each shared node exactly once, forever
|
|
26
|
+
*
|
|
27
|
+
* `createPortal(<MediaSurface …/>, wrapper)` for every id a host has claimed.
|
|
28
|
+
* The wrapper is a plain `<div>` created OUTSIDE React by `media-node.web.ts`,
|
|
29
|
+
* so React reconciles the media against a container whose identity never
|
|
30
|
+
* changes while the registry moves that container between hosts with
|
|
31
|
+
* `appendChild`. React never sees the move; the browser never sees a removal;
|
|
32
|
+
* the video never loses its element, its decoder or its position.
|
|
33
|
+
*
|
|
34
|
+
* That is why the layer, and not the host, renders the media on web: the media
|
|
35
|
+
* has to be rendered by a tree that outlives every host, and the app root is
|
|
36
|
+
* the only such tree.
|
|
37
|
+
*
|
|
38
|
+
* ## A flying surface with a shared node paints nothing itself
|
|
39
|
+
*
|
|
40
|
+
* It becomes a positioned, animated BOX that claims the node — one more host,
|
|
41
|
+
* outranking the others for the length of the leg. A flight for an id with no
|
|
42
|
+
* shared node (an image gallery, any consumer that has not adopted a host)
|
|
43
|
+
* falls back to painting its own `MediaSurface`, which is what every flight did
|
|
44
|
+
* before hosts existed.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
function MediaFlightLayer() {
|
|
48
|
+
const flights = (0, _react.useSyncExternalStore)(_store.subscribeToFlights, _store.getFlights, _store.getFlights);
|
|
49
|
+
const nodes = (0, _react.useSyncExternalStore)(_mediaNodeWeb.subscribeToMediaNodes, _mediaNodeWeb.getMediaNodes, _mediaNodeWeb.getMediaNodes);
|
|
50
|
+
if (flights.length === 0 && nodes.length === 0) return null;
|
|
51
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
52
|
+
children: [nodes.map(node => /*#__PURE__*/(0, _jsxRuntime.jsx)(SharedMediaNode, {
|
|
53
|
+
node: node
|
|
54
|
+
}, node.id)), flights.length === 0 ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_indexWeb.Portal, {
|
|
55
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.OverlayRoot, {
|
|
56
|
+
children: flights.map(flight => /*#__PURE__*/(0, _jsxRuntime.jsx)(MediaFlightSurface, {
|
|
57
|
+
flight: flight
|
|
58
|
+
// Read from the SNAPSHOT, never from the registry: a lookup
|
|
59
|
+
// during render is external mutable state in a memoized
|
|
60
|
+
// position, which the React Compiler is allowed to freeze.
|
|
61
|
+
,
|
|
62
|
+
shared: nodes.some(node => node.id === flight.id)
|
|
63
|
+
}, flight.id))
|
|
64
|
+
})
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
MediaFlightLayer.displayName = 'MediaFlightLayer';
|
|
69
|
+
|
|
70
|
+
/** One media element, painted into the wrapper its id owns, and never again. */
|
|
71
|
+
function SharedMediaNode({
|
|
72
|
+
node
|
|
73
|
+
}) {
|
|
74
|
+
const {
|
|
75
|
+
content,
|
|
76
|
+
contentFit,
|
|
77
|
+
renderVideo,
|
|
78
|
+
nativeControls,
|
|
79
|
+
accessibilityLabel,
|
|
80
|
+
flightId
|
|
81
|
+
} = node.render;
|
|
82
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaSurface.MediaSurface, {
|
|
83
|
+
content: content,
|
|
84
|
+
contentFit: contentFit,
|
|
85
|
+
renderVideo: renderVideo,
|
|
86
|
+
nativeControls: nativeControls,
|
|
87
|
+
accessibilityLabel: accessibilityLabel,
|
|
88
|
+
flightId: flightId,
|
|
89
|
+
style: _reactNative.StyleSheet.absoluteFill
|
|
90
|
+
}), node.wrapper);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* One flying surface. See `MediaFlightLayer.tsx` for why the size is animated
|
|
95
|
+
* rather than scaled.
|
|
96
|
+
*/
|
|
97
|
+
function MediaFlightSurface({
|
|
98
|
+
flight,
|
|
99
|
+
shared
|
|
100
|
+
}) {
|
|
101
|
+
const {
|
|
102
|
+
id,
|
|
103
|
+
from,
|
|
104
|
+
to,
|
|
105
|
+
progress,
|
|
106
|
+
content,
|
|
107
|
+
cornerRadius,
|
|
108
|
+
contentFit,
|
|
109
|
+
surfaceType,
|
|
110
|
+
unbinding
|
|
111
|
+
} = flight;
|
|
112
|
+
(0, _react.useEffect)(() => {
|
|
113
|
+
(0, _store.notifySurfaceMounted)(id);
|
|
114
|
+
}, [id]);
|
|
115
|
+
const originX = from.x - to.x;
|
|
116
|
+
const originY = from.y - to.y;
|
|
117
|
+
|
|
118
|
+
// CRITICAL — every shared value a mapper READS must be listed in its deps.
|
|
119
|
+
// On web WITHOUT the react-native-worklets babel plugin, reanimated drives a
|
|
120
|
+
// mapper off its deps array rather than off the reads it detects: with none,
|
|
121
|
+
// it runs ONCE and freezes at the opening frame. See `MediaFlightLayer.tsx`.
|
|
122
|
+
const boxStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
123
|
+
transform: [{
|
|
124
|
+
translateX: (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [originX, 0])
|
|
125
|
+
}, {
|
|
126
|
+
translateY: (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [originY, 0])
|
|
127
|
+
}],
|
|
128
|
+
width: (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [from.width, to.width]),
|
|
129
|
+
height: (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [from.height, to.height])
|
|
130
|
+
}), [progress, originX, originY, from.width, from.height, to.width, to.height]);
|
|
131
|
+
const box = [styles.box, {
|
|
132
|
+
left: to.x,
|
|
133
|
+
top: to.y,
|
|
134
|
+
borderRadius: cornerRadius
|
|
135
|
+
}, boxStyle];
|
|
136
|
+
|
|
137
|
+
// The shared node is already painting this media. The flight is then a BOX
|
|
138
|
+
// that borrows it for the length of the leg, never a second copy.
|
|
139
|
+
if (shared) return /*#__PURE__*/(0, _jsxRuntime.jsx)(FlyingSharedNode, {
|
|
140
|
+
id: id,
|
|
141
|
+
style: box
|
|
142
|
+
});
|
|
143
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaSurface.MediaSurface, {
|
|
144
|
+
content: content,
|
|
145
|
+
contentFit: contentFit,
|
|
146
|
+
surfaceType: surfaceType
|
|
147
|
+
// One commit with no player before this node leaves the DOM — see
|
|
148
|
+
// `releaseFlight`. Only the no-shared-node path can need it: a shared
|
|
149
|
+
// node is never removed, which is the point of the whole mechanism.
|
|
150
|
+
,
|
|
151
|
+
detached: unbinding
|
|
152
|
+
// A flying surface is a picture, never a control.
|
|
153
|
+
,
|
|
154
|
+
pointerEvents: "none",
|
|
155
|
+
style: box
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The flight's own claim on a shared node.
|
|
161
|
+
*
|
|
162
|
+
* `pointerEvents` stays `none` on the BOX: a flying surface must not take the
|
|
163
|
+
* press travelling to whatever is underneath it. The wrapper inside sets
|
|
164
|
+
* `pointer-events: auto` for the media's sake, which is what a host needs and
|
|
165
|
+
* is inert here — a descendant asking for `auto` does not override a `none`
|
|
166
|
+
* ancestor.
|
|
167
|
+
*/
|
|
168
|
+
function FlyingSharedNode({
|
|
169
|
+
id,
|
|
170
|
+
style
|
|
171
|
+
}) {
|
|
172
|
+
const [node, setNode] = (0, _react.useState)(null);
|
|
173
|
+
const setBox = (0, _react.useCallback)(next => setNode(next), []);
|
|
174
|
+
|
|
175
|
+
// A POSITION-ONLY claim: it says where the node lives for the length of the
|
|
176
|
+
// leg and nothing about what is painted in it. A flight that published a
|
|
177
|
+
// render of its own would replace the hosts' — and swap a consumer's own
|
|
178
|
+
// element out and back, which is two remounts in the middle of the one
|
|
179
|
+
// operation whose whole point is that the element is never rebuilt.
|
|
180
|
+
(0, _react.useLayoutEffect)(() => {
|
|
181
|
+
const el = node;
|
|
182
|
+
if (el === null) return undefined;
|
|
183
|
+
(0, _mediaNodeWeb.claimMediaNode)(id, el, _mediaNodeWeb.FLIGHT_RANK);
|
|
184
|
+
return () => (0, _mediaNodeWeb.releaseMediaNode)(id, el, _mediaNodeWeb.FLIGHT_RANK);
|
|
185
|
+
}, [id, node]);
|
|
186
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
187
|
+
ref: setBox,
|
|
188
|
+
style: style,
|
|
189
|
+
pointerEvents: "none"
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const styles = _reactNative.StyleSheet.create({
|
|
193
|
+
box: {
|
|
194
|
+
position: 'absolute',
|
|
195
|
+
overflow: 'hidden'
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
//# sourceMappingURL=MediaFlightLayer.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactDom","_reactNativeReanimated","_interopRequireWildcard","_index","_indexWeb","_MediaSurface","_mediaNodeWeb","_store","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MediaFlightLayer","flights","useSyncExternalStore","subscribeToFlights","getFlights","nodes","subscribeToMediaNodes","getMediaNodes","length","jsxs","Fragment","children","map","node","jsx","SharedMediaNode","id","Portal","OverlayRoot","flight","MediaFlightSurface","shared","some","displayName","content","contentFit","renderVideo","nativeControls","accessibilityLabel","flightId","render","createPortal","MediaSurface","style","StyleSheet","absoluteFill","wrapper","from","to","progress","cornerRadius","surfaceType","unbinding","useEffect","notifySurfaceMounted","originX","x","originY","y","boxStyle","useAnimatedStyle","transform","translateX","interpolate","value","translateY","width","height","box","styles","left","top","borderRadius","FlyingSharedNode","detached","pointerEvents","setNode","useState","setBox","useCallback","next","useLayoutEffect","el","undefined","claimMediaNode","FLIGHT_RANK","releaseMediaNode","View","ref","create","position","overflow"],"sourceRoot":"../../../src","sources":["media-flight/MediaFlightLayer.web.tsx"],"mappings":";;;;;;AA4BA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAQA,IAAAS,MAAA,GAAAT,OAAA;AAA+E,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAI,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,C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IACHsB,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -64,6 +64,7 @@ const MediaSurface = exports.MediaSurface = /*#__PURE__*/(0, _react.memo)(functi
|
|
|
64
64
|
style,
|
|
65
65
|
contentFit = 'contain',
|
|
66
66
|
surfaceType = 'textureView',
|
|
67
|
+
renderVideo,
|
|
67
68
|
nativeControls = false,
|
|
68
69
|
accessibilityLabel,
|
|
69
70
|
pointerEvents,
|
|
@@ -83,10 +84,11 @@ const MediaSurface = exports.MediaSurface = /*#__PURE__*/(0, _react.memo)(functi
|
|
|
83
84
|
if (flightId !== undefined) (0, _store.handOffFlight)(flightId);
|
|
84
85
|
}, [flightId]);
|
|
85
86
|
const still = content.kind === 'video' ? content.poster : content.uri;
|
|
86
|
-
// Loaded for the video arm only, and only when
|
|
87
|
-
// surface must never make an app resolve an optional
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
// Loaded for the video arm only, and only when Bloom is the one building the
|
|
88
|
+
// element — an image surface must never make an app resolve an optional
|
|
89
|
+
// native peer, and neither must a consumer that brought its own view.
|
|
90
|
+
const expoVideo = content.kind === 'video' && renderVideo === undefined ? (0, _expoVideoModule.loadExpoVideo)() : null;
|
|
91
|
+
if (content.kind === 'video' && renderVideo === undefined && expoVideo === null) {
|
|
90
92
|
// Degrade to the poster rather than to nothing: a black hole where a video
|
|
91
93
|
// should be reads as a broken app, a still frame reads as a video that has
|
|
92
94
|
// not started. The warning is what makes the difference visible to the
|
|
@@ -118,7 +120,13 @@ const MediaSurface = exports.MediaSurface = /*#__PURE__*/(0, _react.memo)(functi
|
|
|
118
120
|
,
|
|
119
121
|
onLoad: content.kind === 'video' ? undefined : reportLive,
|
|
120
122
|
...webDraggableProps
|
|
121
|
-
}), content.kind === 'video' &&
|
|
123
|
+
}), content.kind === 'video' && renderVideo !== undefined ? renderVideo({
|
|
124
|
+
player: detached ? null : content.player,
|
|
125
|
+
// The same style Bloom's own view gets, for the same reason: a
|
|
126
|
+
// replaced element that is not told its size paints at 300x150.
|
|
127
|
+
style: [_reactNative.StyleSheet.absoluteFill, styles.fillReplaced],
|
|
128
|
+
contentFit
|
|
129
|
+
}) : null, content.kind === 'video' && renderVideo === undefined && expoVideo !== null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(expoVideo.VideoView, {
|
|
122
130
|
player: detached ? null : content.player,
|
|
123
131
|
contentFit: contentFit,
|
|
124
132
|
surfaceType: mountedSurfaceType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_expoImage","_reactNativeReanimated","_interopRequireDefault","_store","_expoVideoModule","_jsxRuntime","e","__esModule","default","webDraggableProps","Platform","OS","draggable","MediaSurface","exports","memo","content","style","contentFit","surfaceType","nativeControls","accessibilityLabel","pointerEvents","flightId","detached","mountedSurfaceType","useState","reportLive","useCallback","undefined","handOffFlight","still","kind","poster","uri","expoVideo","loadExpoVideo","warnExpoVideoUnavailable","jsxs","View","styles","box","children","jsx","Image","source","StyleSheet","absoluteFill","transition","onLoad","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_expoImage","_reactNativeReanimated","_interopRequireDefault","_store","_expoVideoModule","_jsxRuntime","e","__esModule","default","webDraggableProps","Platform","OS","draggable","MediaSurface","exports","memo","content","style","contentFit","surfaceType","renderVideo","nativeControls","accessibilityLabel","pointerEvents","flightId","detached","mountedSurfaceType","useState","reportLive","useCallback","undefined","handOffFlight","still","kind","poster","uri","expoVideo","loadExpoVideo","warnExpoVideoUnavailable","jsxs","View","styles","box","children","jsx","Image","source","StyleSheet","absoluteFill","transition","onLoad","player","fillReplaced","VideoView","onFirstFrameRender","displayName","MediaPoster","EmptyMediaSurface","empty","create","width","height","overflow","backgroundColor"],"sourceRoot":"../../../src","sources":["media-flight/MediaSurface.tsx"],"mappings":";;;;;;;;AAeA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,I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