@octane-xplat/video 0.0.0 → 0.7.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/dist/native/Video.tsrx.js +248 -0
- package/dist/native/cx.mobile.js +11 -0
- package/dist/native/escape-props.js +39 -0
- package/dist/native/index.js +2 -0
- package/dist/native/layout-child.js +38 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/native/video-chrome.tsrx.js +359 -0
- package/dist/web/Video.web.tsrx.js +400 -0
- package/dist/web/escape-props.web.js +17 -0
- package/dist/web/index.js +2 -0
- package/dist/web/layout-child.web.js +47 -0
- package/dist/web/octane-client-build.json +8 -0
- package/dist/web/video-chrome.web.tsrx.js +201 -0
- package/package.json +59 -5
- package/src/Video.macos.tsrx +7 -0
- package/src/Video.tsrx +162 -0
- package/src/Video.web.tsrx +147 -0
- package/src/cx.mobile.ts +8 -0
- package/src/escape-props.ts +65 -0
- package/src/escape-props.web.ts +25 -0
- package/src/index.macos.ts +2 -0
- package/src/index.ts +2 -0
- package/src/index.web.ts +2 -0
- package/src/layout-child.ts +57 -0
- package/src/layout-child.web.ts +108 -0
- package/src/props.ts +125 -0
- package/src/video-chrome.tsrx +117 -0
- package/src/video-chrome.web.tsrx +116 -0
- package/types/index.d.ts +5 -0
- package/types/index.macos.d.ts +4 -0
- package/types/props.d.ts +103 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { applyEscapeProps } from "./escape-props.web.js";
|
|
2
|
+
import { layoutChildProps } from "./layout-child.web.js";
|
|
3
|
+
import { VideoChrome } from "./video-chrome.web.tsrx.js";
|
|
4
|
+
import { __s, bagOf, child, clone, componentSlotVoid, delegateEvents, evt1, evt1e, evt1u, evt2e, evt2u, hookSlots, ifBlock, markDangerouslySetInnerHTMLChildren, queueRefAttach, queueRefDetach, setAttribute, setBooleanAttribute, setEventHandler, setStyleProperty, sibling, snapshotSpread, template, useEffect, useRef, useState } from "octane";
|
|
5
|
+
import { bindSignalAttribute, bindSignalHostPropSources, compilerMemoRegion, enableSignalBindings, hookMemoCreate, hookMemoPublishInvariant, replaceRef, setPlainAttribute, setURLAttribute } from "octane/internal/client";
|
|
6
|
+
//#region src/Video.web.tsrx
|
|
7
|
+
enableSignalBindings(1, true);
|
|
8
|
+
delegateEvents([
|
|
9
|
+
"ended",
|
|
10
|
+
"error",
|
|
11
|
+
"loadedmetadata",
|
|
12
|
+
"pause",
|
|
13
|
+
"play",
|
|
14
|
+
"playing",
|
|
15
|
+
"timeupdate"
|
|
16
|
+
]);
|
|
17
|
+
var _t$0 = /* @__PURE__ */ template("<div><video class=\"vx-video-surface\" playsinline=\"\" preload=\"metadata\"></video><!></div>");
|
|
18
|
+
var _hs$ = /* @__PURE__ */ hookSlots(8);
|
|
19
|
+
var __event = (e, setDuration, props) => {
|
|
20
|
+
const ms = e.currentTarget.duration * 1e3;
|
|
21
|
+
setDuration(Number.isFinite(ms) ? ms : 0);
|
|
22
|
+
props.onReady?.({ duration: Number.isFinite(ms) ? ms : 0 });
|
|
23
|
+
};
|
|
24
|
+
var __event$ = (__eventArg, props, setPlaying) => {
|
|
25
|
+
if (props.loop) return;
|
|
26
|
+
setPlaying(false);
|
|
27
|
+
props.onEnded?.();
|
|
28
|
+
};
|
|
29
|
+
var __event$2 = (e, props) => {
|
|
30
|
+
const code = e.currentTarget?.error?.code ?? 0;
|
|
31
|
+
props.onError?.({ message: MEDIA_ERR[code] ?? "unknown" });
|
|
32
|
+
};
|
|
33
|
+
function __then$0(__props, __s, __extra) {
|
|
34
|
+
const __block = __s.block;
|
|
35
|
+
const duration = __extra[0];
|
|
36
|
+
const el = __extra[1];
|
|
37
|
+
const muted = __extra[2];
|
|
38
|
+
const playing = __extra[3];
|
|
39
|
+
const position = __extra[4];
|
|
40
|
+
const props = __extra[5];
|
|
41
|
+
const setInternalMuted = __extra[6];
|
|
42
|
+
const setPosition = __extra[7];
|
|
43
|
+
const started = __extra[8];
|
|
44
|
+
const togglePlay = __extra[9];
|
|
45
|
+
componentSlotVoid(__s, 0, __block.parentNode, VideoChrome, {
|
|
46
|
+
"poster": props.poster,
|
|
47
|
+
"started": started,
|
|
48
|
+
"playing": playing,
|
|
49
|
+
"position": position,
|
|
50
|
+
"duration": duration,
|
|
51
|
+
"muted": muted,
|
|
52
|
+
"onTogglePlay": togglePlay,
|
|
53
|
+
"onToggleMute": () => {
|
|
54
|
+
const next = !muted;
|
|
55
|
+
setInternalMuted(next);
|
|
56
|
+
if (el.current) el.current.muted = next;
|
|
57
|
+
props.onMutedChange?.(next);
|
|
58
|
+
},
|
|
59
|
+
"onSeek": (ms) => {
|
|
60
|
+
if (el.current) {
|
|
61
|
+
el.current.currentTime = ms / 1e3;
|
|
62
|
+
setPosition(ms);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, __block.endMarker, void 0, 2, void 0, void 0, "c:6f1a737f");
|
|
66
|
+
}
|
|
67
|
+
var _rm$3 = [
|
|
68
|
+
"s",
|
|
69
|
+
"n",
|
|
70
|
+
"m",
|
|
71
|
+
"r",
|
|
72
|
+
"p",
|
|
73
|
+
"o"
|
|
74
|
+
];
|
|
75
|
+
var MEDIA_ERR = {
|
|
76
|
+
1: "aborted",
|
|
77
|
+
2: "network",
|
|
78
|
+
3: "decode",
|
|
79
|
+
4: "source-not-supported"
|
|
80
|
+
};
|
|
81
|
+
var Video = /* @__PURE__ */ __s(function Video(props, __s, __extra) {
|
|
82
|
+
const __memoRegion = compilerMemoRegion(__s, _hs$ + 0);
|
|
83
|
+
let __hk = __memoRegion.hooks;
|
|
84
|
+
if (__hk === void 0) __memoRegion.hooks = __hk = hookMemoCreate(2);
|
|
85
|
+
const el = useRef(null, _hs$ + 0);
|
|
86
|
+
const [playing, setPlaying] = useState(props.playing ?? props.autoPlay ?? false, _hs$ + 1);
|
|
87
|
+
const [started, setStarted] = useState(false, _hs$ + 2);
|
|
88
|
+
const [position, setPosition] = useState(0, _hs$ + 3);
|
|
89
|
+
const [duration, setDuration] = useState(0, _hs$ + 4);
|
|
90
|
+
const [internalMuted, setInternalMuted] = useState(false, _hs$ + 5);
|
|
91
|
+
const muted = props.muted ?? internalMuted;
|
|
92
|
+
const drive = __hk[0] ?? hookMemoPublishInvariant(__hk, 0, (v, next) => {
|
|
93
|
+
if (!v) return;
|
|
94
|
+
if (next) v.play()?.catch(() => setPlaying(false));
|
|
95
|
+
else v.pause();
|
|
96
|
+
});
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (props.playing === void 0) return;
|
|
99
|
+
setPlaying(props.playing);
|
|
100
|
+
drive(el.current, props.playing);
|
|
101
|
+
}, [props.playing], _hs$ + 6);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
const v = el.current;
|
|
104
|
+
if (!v) return;
|
|
105
|
+
v.muted = muted;
|
|
106
|
+
if (props.autoPlay || props.playing) v.play()?.catch(() => setPlaying(false));
|
|
107
|
+
}, [muted], _hs$ + 7);
|
|
108
|
+
const togglePlay = () => {
|
|
109
|
+
const next = !playing;
|
|
110
|
+
setPlaying(next);
|
|
111
|
+
drive(el.current, next);
|
|
112
|
+
props.onPlayingChange?.(next);
|
|
113
|
+
};
|
|
114
|
+
const handle = __hk[1] ?? hookMemoPublishInvariant(__hk, 1, (v) => ({
|
|
115
|
+
play: () => v.play(),
|
|
116
|
+
pause: () => v.pause(),
|
|
117
|
+
seekTo: (ms) => {
|
|
118
|
+
v.currentTime = ms / 1e3;
|
|
119
|
+
},
|
|
120
|
+
currentTime: () => v.currentTime * 1e3,
|
|
121
|
+
duration: () => Number.isFinite(v.duration) ? v.duration * 1e3 : 0,
|
|
122
|
+
native: v
|
|
123
|
+
}));
|
|
124
|
+
if (__s.block.pending && !__s.block.crossRenderUpdate) return;
|
|
125
|
+
let _b = __s.slots[0];
|
|
126
|
+
if (_b === void 0) {
|
|
127
|
+
let _m0, _m1, _m2, _m3, _m4, _m5, _m6, _m7, _m8, _m9, _m10, _m11, _m12, _m13, _m14, _m15, _m21, _m22, _m23, _m24;
|
|
128
|
+
const _root = clone(_t$0);
|
|
129
|
+
_m0 = props.id;
|
|
130
|
+
_m1 = [
|
|
131
|
+
"vx-stack",
|
|
132
|
+
"vx-video",
|
|
133
|
+
props.className
|
|
134
|
+
];
|
|
135
|
+
_m2 = snapshotSpread(layoutChildProps(props, props.style));
|
|
136
|
+
_m3 = props.accessibilityRole;
|
|
137
|
+
_m4 = props.accessibilityLabel;
|
|
138
|
+
_m5 = props.accessible === false ? true : void 0;
|
|
139
|
+
_m6 = props.accessibilityHint;
|
|
140
|
+
_m7 = props.accessibilityValue;
|
|
141
|
+
_m8 = props.accessibilityState?.disabled;
|
|
142
|
+
_m9 = props.accessibilityState?.selected;
|
|
143
|
+
_m10 = props.accessibilityState?.checked;
|
|
144
|
+
_m11 = props.accessibilityLiveRegion === "none" ? "off" : props.accessibilityLiveRegion;
|
|
145
|
+
_m12 = _root;
|
|
146
|
+
_m13 = bindSignalHostPropSources(__s, void 0, _root, [
|
|
147
|
+
[
|
|
148
|
+
false,
|
|
149
|
+
"id",
|
|
150
|
+
_m0
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
false,
|
|
154
|
+
"className",
|
|
155
|
+
_m1
|
|
156
|
+
],
|
|
157
|
+
[true, _m2],
|
|
158
|
+
[
|
|
159
|
+
false,
|
|
160
|
+
"role",
|
|
161
|
+
_m3
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
false,
|
|
165
|
+
"aria-label",
|
|
166
|
+
_m4
|
|
167
|
+
],
|
|
168
|
+
[
|
|
169
|
+
false,
|
|
170
|
+
"aria-hidden",
|
|
171
|
+
_m5
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
false,
|
|
175
|
+
"aria-description",
|
|
176
|
+
_m6
|
|
177
|
+
],
|
|
178
|
+
[
|
|
179
|
+
false,
|
|
180
|
+
"aria-valuetext",
|
|
181
|
+
_m7
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
false,
|
|
185
|
+
"aria-disabled",
|
|
186
|
+
_m8
|
|
187
|
+
],
|
|
188
|
+
[
|
|
189
|
+
false,
|
|
190
|
+
"aria-selected",
|
|
191
|
+
_m9
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
false,
|
|
195
|
+
"aria-checked",
|
|
196
|
+
_m10
|
|
197
|
+
],
|
|
198
|
+
[
|
|
199
|
+
false,
|
|
200
|
+
"aria-live",
|
|
201
|
+
_m11
|
|
202
|
+
]
|
|
203
|
+
], "b:8e28227a", true);
|
|
204
|
+
const _el0 = child(_root);
|
|
205
|
+
queueRefAttach(__s, _m15 = (v) => {
|
|
206
|
+
el.current = v;
|
|
207
|
+
if (!v) return;
|
|
208
|
+
v.muted = muted;
|
|
209
|
+
applyEscapeProps(v, props);
|
|
210
|
+
props.bind?.(handle(v));
|
|
211
|
+
}, _m14 = _el0);
|
|
212
|
+
(__s.cleanups ??= []).push(() => _b && queueRefDetach(_b.p, _b.o));
|
|
213
|
+
evt1(_el0, "$$play", setPlaying, true);
|
|
214
|
+
evt1(_el0, "$$pause", setPlaying, false);
|
|
215
|
+
evt1(_el0, "$$playing", setStarted, true);
|
|
216
|
+
_m21 = evt2e(_el0, "$$loadedmetadata", __event, setDuration, props);
|
|
217
|
+
setEventHandler(_el0, "$$timeupdate", (e) => setPosition(e.currentTarget.currentTime * 1e3));
|
|
218
|
+
_m22 = evt2e(_el0, "$$ended", __event$, props, setPlaying);
|
|
219
|
+
_m23 = evt1e(_el0, "$$error", __event$2, props);
|
|
220
|
+
markDangerouslySetInnerHTMLChildren(_root);
|
|
221
|
+
_m24 = sibling(_el0, 1);
|
|
222
|
+
_b = bagOf(__s, _root, {
|
|
223
|
+
a: _m0,
|
|
224
|
+
b: _m1,
|
|
225
|
+
c: _m2,
|
|
226
|
+
d: _m3,
|
|
227
|
+
e: _m4,
|
|
228
|
+
f: _m5,
|
|
229
|
+
g: _m6,
|
|
230
|
+
h: _m7,
|
|
231
|
+
i: _m8,
|
|
232
|
+
j: _m9,
|
|
233
|
+
k: _m10,
|
|
234
|
+
l: _m11,
|
|
235
|
+
m: _m12,
|
|
236
|
+
n: _m13,
|
|
237
|
+
o: _m14,
|
|
238
|
+
p: _m15,
|
|
239
|
+
q: void 0,
|
|
240
|
+
r: void 0,
|
|
241
|
+
s: void 0,
|
|
242
|
+
t: void 0,
|
|
243
|
+
u: __s,
|
|
244
|
+
v: _m21,
|
|
245
|
+
w: _m22,
|
|
246
|
+
x: _m23,
|
|
247
|
+
y: _m24
|
|
248
|
+
});
|
|
249
|
+
__s.refFields = _rm$3;
|
|
250
|
+
} else {
|
|
251
|
+
{
|
|
252
|
+
const _v = props.id;
|
|
253
|
+
if (_b.a !== _v) _b.a = _v;
|
|
254
|
+
}
|
|
255
|
+
{
|
|
256
|
+
const _v = [
|
|
257
|
+
"vx-stack",
|
|
258
|
+
"vx-video",
|
|
259
|
+
props.className
|
|
260
|
+
];
|
|
261
|
+
if (_b.b !== _v) _b.b = _v;
|
|
262
|
+
}
|
|
263
|
+
_b.c = snapshotSpread(layoutChildProps(props, props.style));
|
|
264
|
+
{
|
|
265
|
+
const _v = props.accessibilityRole;
|
|
266
|
+
if (_b.d !== _v) _b.d = _v;
|
|
267
|
+
}
|
|
268
|
+
{
|
|
269
|
+
const _v = props.accessibilityLabel;
|
|
270
|
+
if (_b.e !== _v) _b.e = _v;
|
|
271
|
+
}
|
|
272
|
+
{
|
|
273
|
+
const _v = props.accessible === false ? true : void 0;
|
|
274
|
+
if (_b.f !== _v) _b.f = _v;
|
|
275
|
+
}
|
|
276
|
+
{
|
|
277
|
+
const _v = props.accessibilityHint;
|
|
278
|
+
if (_b.g !== _v) _b.g = _v;
|
|
279
|
+
}
|
|
280
|
+
{
|
|
281
|
+
const _v = props.accessibilityValue;
|
|
282
|
+
if (_b.h !== _v) _b.h = _v;
|
|
283
|
+
}
|
|
284
|
+
{
|
|
285
|
+
const _v = props.accessibilityState?.disabled;
|
|
286
|
+
if (_b.i !== _v) _b.i = _v;
|
|
287
|
+
}
|
|
288
|
+
{
|
|
289
|
+
const _v = props.accessibilityState?.selected;
|
|
290
|
+
if (_b.j !== _v) _b.j = _v;
|
|
291
|
+
}
|
|
292
|
+
{
|
|
293
|
+
const _v = props.accessibilityState?.checked;
|
|
294
|
+
if (_b.k !== _v) _b.k = _v;
|
|
295
|
+
}
|
|
296
|
+
{
|
|
297
|
+
const _v = props.accessibilityLiveRegion === "none" ? "off" : props.accessibilityLiveRegion;
|
|
298
|
+
if (_b.l !== _v) _b.l = _v;
|
|
299
|
+
}
|
|
300
|
+
_b.n = bindSignalHostPropSources(__s, _b.n, _b.m, [
|
|
301
|
+
[
|
|
302
|
+
false,
|
|
303
|
+
"id",
|
|
304
|
+
_b.a
|
|
305
|
+
],
|
|
306
|
+
[
|
|
307
|
+
false,
|
|
308
|
+
"className",
|
|
309
|
+
_b.b
|
|
310
|
+
],
|
|
311
|
+
[true, _b.c],
|
|
312
|
+
[
|
|
313
|
+
false,
|
|
314
|
+
"role",
|
|
315
|
+
_b.d
|
|
316
|
+
],
|
|
317
|
+
[
|
|
318
|
+
false,
|
|
319
|
+
"aria-label",
|
|
320
|
+
_b.e
|
|
321
|
+
],
|
|
322
|
+
[
|
|
323
|
+
false,
|
|
324
|
+
"aria-hidden",
|
|
325
|
+
_b.f
|
|
326
|
+
],
|
|
327
|
+
[
|
|
328
|
+
false,
|
|
329
|
+
"aria-description",
|
|
330
|
+
_b.g
|
|
331
|
+
],
|
|
332
|
+
[
|
|
333
|
+
false,
|
|
334
|
+
"aria-valuetext",
|
|
335
|
+
_b.h
|
|
336
|
+
],
|
|
337
|
+
[
|
|
338
|
+
false,
|
|
339
|
+
"aria-disabled",
|
|
340
|
+
_b.i
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
false,
|
|
344
|
+
"aria-selected",
|
|
345
|
+
_b.j
|
|
346
|
+
],
|
|
347
|
+
[
|
|
348
|
+
false,
|
|
349
|
+
"aria-checked",
|
|
350
|
+
_b.k
|
|
351
|
+
],
|
|
352
|
+
[
|
|
353
|
+
false,
|
|
354
|
+
"aria-live",
|
|
355
|
+
_b.l
|
|
356
|
+
]
|
|
357
|
+
], "b:8e28227a", true);
|
|
358
|
+
{
|
|
359
|
+
const _r = (v) => {
|
|
360
|
+
el.current = v;
|
|
361
|
+
if (!v) return;
|
|
362
|
+
v.muted = muted;
|
|
363
|
+
applyEscapeProps(v, props);
|
|
364
|
+
props.bind?.(handle(v));
|
|
365
|
+
};
|
|
366
|
+
if (_r !== _b.p) _b.p = replaceRef(__s, _b.p, _r, _b.o);
|
|
367
|
+
}
|
|
368
|
+
evt2u(_b.v, __event, setDuration, props);
|
|
369
|
+
evt2u(_b.w, __event$, props, setPlaying);
|
|
370
|
+
evt1u(_b.x, __event$2, props);
|
|
371
|
+
}
|
|
372
|
+
_b.q = bindSignalAttribute(__s, _b.q, _b.o, "src", props.src, "b:8cc4fe21", setURLAttribute);
|
|
373
|
+
_b.r = bindSignalAttribute(__s, _b.r, _b.o, "poster", props.poster, "b:96cc8ad6", setPlainAttribute);
|
|
374
|
+
_b.s = bindSignalAttribute(__s, _b.s, _b.o, "muted", muted, "b:48ef6972", setAttribute);
|
|
375
|
+
_b.t = bindSignalAttribute(__s, _b.t, _b.o, "loop", props.loop, "b:0e1cb1f0", setBooleanAttribute);
|
|
376
|
+
{
|
|
377
|
+
const _v = props.fit ?? "contain";
|
|
378
|
+
if (_b.u !== _v) {
|
|
379
|
+
setStyleProperty(_b.o, "objectFit", _v, "", _b.u);
|
|
380
|
+
_b.u = _v;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
{
|
|
384
|
+
const __ifCondition = props.controls !== false;
|
|
385
|
+
ifBlock(__s, 1, _b.m, __ifCondition, __then$0, null, _b.y, __ifCondition ? [
|
|
386
|
+
duration,
|
|
387
|
+
el,
|
|
388
|
+
muted,
|
|
389
|
+
playing,
|
|
390
|
+
position,
|
|
391
|
+
props,
|
|
392
|
+
setInternalMuted,
|
|
393
|
+
setPosition,
|
|
394
|
+
started,
|
|
395
|
+
togglePlay
|
|
396
|
+
] : void 0);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
//#endregion
|
|
400
|
+
export { Video };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/escape-props.web.ts
|
|
2
|
+
/** Apply DOM escape props after the primitive's own props. Dash-named keys
|
|
3
|
+
* are attributes; other keys use the DOM property where available. */
|
|
4
|
+
function applyEscapeProps(element, props) {
|
|
5
|
+
if (!element || !props.web) return;
|
|
6
|
+
for (const [key, value] of Object.entries(props.web)) if (key.includes("-")) {
|
|
7
|
+
if (value == null || value === false) element.removeAttribute(key);
|
|
8
|
+
else element.setAttribute(key, value === true ? "" : String(value));
|
|
9
|
+
} else if (key in element) try {
|
|
10
|
+
element[key] = value;
|
|
11
|
+
} catch {
|
|
12
|
+
element.setAttribute(key, String(value));
|
|
13
|
+
}
|
|
14
|
+
else if (value != null) element.setAttribute(key, String(value));
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { applyEscapeProps };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/layout-child.web.ts
|
|
2
|
+
/** The shared contract is "numbers are dips" (RN semantics), but octane's DOM
|
|
3
|
+
* renderer keeps React's unitless list — lineHeight is unitless there, so
|
|
4
|
+
* `style={{lineHeight: 40}}` would render a 40× multiplier instead of 40px.
|
|
5
|
+
* lineHeight is the one unitless-in-React prop that is a length in the
|
|
6
|
+
* shared vocabulary; force the px suffix. */
|
|
7
|
+
function normStyle(style) {
|
|
8
|
+
if (style && typeof style.lineHeight === "number") return {
|
|
9
|
+
...style,
|
|
10
|
+
lineHeight: style.lineHeight + "px"
|
|
11
|
+
};
|
|
12
|
+
return style;
|
|
13
|
+
}
|
|
14
|
+
var FLEX_JUSTIFY = {
|
|
15
|
+
start: "flex-start",
|
|
16
|
+
end: "flex-end"
|
|
17
|
+
};
|
|
18
|
+
var FLEX_ALIGN = {
|
|
19
|
+
start: "flex-start",
|
|
20
|
+
end: "flex-end"
|
|
21
|
+
};
|
|
22
|
+
/** Convert parent-layout metadata to CSS on the web leaf. Native's `dock`
|
|
23
|
+
* attribute has no CSS equivalent and is ignored on web. Grid indices are
|
|
24
|
+
* zero-based in the shared API, matching NativeScript. */
|
|
25
|
+
function layoutChildProps(props, baseStyle = props.style) {
|
|
26
|
+
const style = { ...normStyle(baseStyle) };
|
|
27
|
+
if (props.row !== void 0) style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`;
|
|
28
|
+
else if (props.rowSpan !== void 0) style.gridRow = `span ${props.rowSpan}`;
|
|
29
|
+
if (props.col !== void 0) style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`;
|
|
30
|
+
else if (props.colSpan !== void 0) style.gridColumn = `span ${props.colSpan}`;
|
|
31
|
+
if (props.left !== void 0) style.left = props.left;
|
|
32
|
+
if (props.top !== void 0) style.top = props.top;
|
|
33
|
+
if (props.flexGrow !== void 0) style.flexGrow = props.flexGrow;
|
|
34
|
+
if (props.flexShrink !== void 0) style.flexShrink = props.flexShrink;
|
|
35
|
+
if (props.alignSelf !== void 0) style.alignSelf = props.alignSelf;
|
|
36
|
+
if (props.order !== void 0) style.order = props.order;
|
|
37
|
+
if (props.justifyContent !== void 0) style.justifyContent = FLEX_JUSTIFY[props.justifyContent] ?? props.justifyContent;
|
|
38
|
+
if (props.alignItems !== void 0) style.alignItems = FLEX_ALIGN[props.alignItems] ?? props.alignItems;
|
|
39
|
+
if (props.flexWrap !== void 0) style.flexWrap = props.flexWrap === true ? "wrap" : props.flexWrap === false ? "nowrap" : props.flexWrap;
|
|
40
|
+
if (props.gap !== void 0) style.gap = props.gap;
|
|
41
|
+
if (props.rowGap !== void 0) style.rowGap = props.rowGap;
|
|
42
|
+
if (props.columnGap !== void 0) style.columnGap = props.columnGap;
|
|
43
|
+
if (typeof style.lineHeight === "number") style.lineHeight = style.lineHeight + "px";
|
|
44
|
+
return { style };
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { layoutChildProps, normStyle };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { bag4, child, clone, componentSlot, drainFrag, hookSlots, ifBlock, markChildrenBlock, markWarm, registerWarmPlan, template, useEffect, useState, warmChild } from "octane";
|
|
2
|
+
import { textHoleUpdate } from "octane/internal/client";
|
|
3
|
+
import { Icon, Image, Pressable, Row, Slider, Text, View } from "@octane-xplat/ui";
|
|
4
|
+
//#region src/video-chrome.web.tsrx
|
|
5
|
+
var _t$0 = /* @__PURE__ */ template("<!>", 0, 1);
|
|
6
|
+
var _hs$ = /* @__PURE__ */ hookSlots(12);
|
|
7
|
+
function __then$0(__props, __s, __extra) {
|
|
8
|
+
const __block = __s.block;
|
|
9
|
+
const props = __extra[0];
|
|
10
|
+
componentSlot(__s, 0, __block.parentNode, Image, {
|
|
11
|
+
"className": "vx-video-poster",
|
|
12
|
+
"src": props.poster,
|
|
13
|
+
"ios": { stretch: "aspectFill" },
|
|
14
|
+
"android": { stretch: "aspectFill" }
|
|
15
|
+
}, __block.endMarker, void 0, 2, void 0, void 0, "c:afd81fd1");
|
|
16
|
+
}
|
|
17
|
+
var __childrenBody = {};
|
|
18
|
+
var __childrenBody$ = {};
|
|
19
|
+
function __then$5(__props, __s, __extra) {
|
|
20
|
+
const __block = __s.block;
|
|
21
|
+
const props = __extra[0];
|
|
22
|
+
function __children$7(__props, __s, __extra) {
|
|
23
|
+
const __block = __s.block;
|
|
24
|
+
function __children$9(__props, __s, __extra) {
|
|
25
|
+
const __block = __s.block;
|
|
26
|
+
componentSlot(__s, 0, __block.parentNode, Icon, {
|
|
27
|
+
"name": "xplat-play",
|
|
28
|
+
"size": 28,
|
|
29
|
+
"color": "#fff"
|
|
30
|
+
}, __block.endMarker, void 0, 2, void 0, void 0, "c:8182c208");
|
|
31
|
+
}
|
|
32
|
+
componentSlot(__s, 0, __block.parentNode, View, {
|
|
33
|
+
"className": "vx-video-centerbtn",
|
|
34
|
+
"children": markChildrenBlock(__children$9, __childrenBody)
|
|
35
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:cb7b2c3f");
|
|
36
|
+
}
|
|
37
|
+
componentSlot(__s, 0, __block.parentNode, Pressable, {
|
|
38
|
+
"className": "vx-video-center",
|
|
39
|
+
"justifyContent": "center",
|
|
40
|
+
"alignItems": "center",
|
|
41
|
+
"accessibilityRole": "button",
|
|
42
|
+
"accessibilityLabel": "Play",
|
|
43
|
+
"onPress": props.onTogglePlay,
|
|
44
|
+
"children": markChildrenBlock(__children$7, __childrenBody$)
|
|
45
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:4f97cdfe");
|
|
46
|
+
}
|
|
47
|
+
var __childrenBody$2 = {};
|
|
48
|
+
var __childrenBody$3 = {};
|
|
49
|
+
var __childrenBody$4 = {};
|
|
50
|
+
var __childrenBody$5 = {};
|
|
51
|
+
var __childrenBody$6 = {};
|
|
52
|
+
var __childrenBody$7 = {};
|
|
53
|
+
function __then$4(__props, __s, __extra) {
|
|
54
|
+
const __block = __s.block;
|
|
55
|
+
const props = __extra[0];
|
|
56
|
+
function __children$13(__props, __s, __extra) {
|
|
57
|
+
const __block = __s.block;
|
|
58
|
+
function __children$15(__props, __s, __extra) {
|
|
59
|
+
const __block = __s.block;
|
|
60
|
+
function __children$17(__props, __s, __extra) {
|
|
61
|
+
const __block = __s.block;
|
|
62
|
+
componentSlot(__s, 0, __block.parentNode, Icon, {
|
|
63
|
+
"name": props.playing ? "xplat-pause" : "xplat-play",
|
|
64
|
+
"size": 20,
|
|
65
|
+
"color": "#fff"
|
|
66
|
+
}, __block.endMarker, void 0, 2, void 0, void 0, "c:a4e0e905");
|
|
67
|
+
}
|
|
68
|
+
function __children$20(__props, __s, __extra) {
|
|
69
|
+
const __block = __s.block;
|
|
70
|
+
let _b = __s.slots[0];
|
|
71
|
+
if (_b === void 0) {
|
|
72
|
+
let _m0, _m1;
|
|
73
|
+
const _root = clone(_t$0);
|
|
74
|
+
_m0 = __block.parentNode;
|
|
75
|
+
_m1 = child(_root);
|
|
76
|
+
drainFrag(_root, __block.parentNode, __block.endMarker);
|
|
77
|
+
_b = bag4(__s, null, _m0, _m1, null, void 0);
|
|
78
|
+
}
|
|
79
|
+
{
|
|
80
|
+
const _v = stamp(props.position);
|
|
81
|
+
_b.c = textHoleUpdate(__s, 1, _b.a, _v, _b.c, _b.d, _b.b, true, true);
|
|
82
|
+
_b.d = _v;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function __children$24(__props, __s, __extra) {
|
|
86
|
+
const __block = __s.block;
|
|
87
|
+
let _b = __s.slots[0];
|
|
88
|
+
if (_b === void 0) {
|
|
89
|
+
let _m0, _m1;
|
|
90
|
+
const _root = clone(_t$0);
|
|
91
|
+
_m0 = __block.parentNode;
|
|
92
|
+
_m1 = child(_root);
|
|
93
|
+
drainFrag(_root, __block.parentNode, __block.endMarker);
|
|
94
|
+
_b = bag4(__s, null, _m0, _m1, null, void 0);
|
|
95
|
+
}
|
|
96
|
+
{
|
|
97
|
+
const _v = stamp(props.duration);
|
|
98
|
+
_b.c = textHoleUpdate(__s, 1, _b.a, _v, _b.c, _b.d, _b.b, true, true);
|
|
99
|
+
_b.d = _v;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function __children$27(__props, __s, __extra) {
|
|
103
|
+
const __block = __s.block;
|
|
104
|
+
componentSlot(__s, 0, __block.parentNode, Icon, {
|
|
105
|
+
"name": props.muted ? "xplat-volume-off" : "xplat-volume",
|
|
106
|
+
"size": 20,
|
|
107
|
+
"color": "#fff"
|
|
108
|
+
}, __block.endMarker, void 0, 2, void 0, void 0, "c:78a524c0");
|
|
109
|
+
}
|
|
110
|
+
componentSlot(__s, 0, __block.parentNode, Pressable, {
|
|
111
|
+
"className": "vx-video-btn",
|
|
112
|
+
"accessibilityRole": "button",
|
|
113
|
+
"accessibilityLabel": props.playing ? "Pause" : "Play",
|
|
114
|
+
"onPress": props.onTogglePlay,
|
|
115
|
+
"children": markChildrenBlock(__children$17, __childrenBody$2)
|
|
116
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:cf122bea");
|
|
117
|
+
componentSlot(__s, 1, __block.parentNode, Text, {
|
|
118
|
+
"className": "vx-video-time",
|
|
119
|
+
"children": markChildrenBlock(__children$20, __childrenBody$3)
|
|
120
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:63f67e7a");
|
|
121
|
+
componentSlot(__s, 2, __block.parentNode, Slider, {
|
|
122
|
+
"className": "vx-video-slider",
|
|
123
|
+
"style": { flexGrow: 1 },
|
|
124
|
+
"value": props.position,
|
|
125
|
+
"minValue": 0,
|
|
126
|
+
"maxValue": props.duration > 0 ? props.duration : 1,
|
|
127
|
+
"onValueChange": props.onSeek
|
|
128
|
+
}, __block.endMarker, void 0, 2, void 0, void 0, "c:2b300510");
|
|
129
|
+
componentSlot(__s, 3, __block.parentNode, Text, {
|
|
130
|
+
"className": "vx-video-time",
|
|
131
|
+
"children": markChildrenBlock(__children$24, __childrenBody$4)
|
|
132
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:37a813f4");
|
|
133
|
+
componentSlot(__s, 4, __block.parentNode, Pressable, {
|
|
134
|
+
"className": "vx-video-btn",
|
|
135
|
+
"accessibilityRole": "button",
|
|
136
|
+
"accessibilityLabel": props.muted ? "Unmute" : "Mute",
|
|
137
|
+
"onPress": props.onToggleMute,
|
|
138
|
+
"children": markChildrenBlock(__children$27, __childrenBody$5)
|
|
139
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:9bf9319c");
|
|
140
|
+
}
|
|
141
|
+
componentSlot(__s, 0, __block.parentNode, Row, {
|
|
142
|
+
"className": "vx-video-bar",
|
|
143
|
+
"alignItems": "center",
|
|
144
|
+
"gap": 8,
|
|
145
|
+
"children": markChildrenBlock(__children$15, __childrenBody$6)
|
|
146
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:455e7102");
|
|
147
|
+
}
|
|
148
|
+
ifBlock(__s, 0, __block.parentNode, !props.playing, __then$5, null, __block.endMarker, __extra);
|
|
149
|
+
componentSlot(__s, 1, __block.parentNode, View, {
|
|
150
|
+
"className": "vx-video-barwrap",
|
|
151
|
+
"justifyContent": "end",
|
|
152
|
+
"children": markChildrenBlock(__children$13, __childrenBody$7)
|
|
153
|
+
}, __block.endMarker, void 0, void 0, void 0, void 0, "c:4aa1741f");
|
|
154
|
+
}
|
|
155
|
+
function stamp(ms) {
|
|
156
|
+
const total = Math.max(0, Math.floor(ms / 1e3));
|
|
157
|
+
return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, "0")}`;
|
|
158
|
+
}
|
|
159
|
+
var VideoChrome = /* @__PURE__ */ markWarm(function VideoChrome(props, __s, __extra) {
|
|
160
|
+
const __block = __s.block;
|
|
161
|
+
const [visible, setVisible] = useState(true, _hs$ + 0);
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!props.playing || !visible) return;
|
|
164
|
+
const t = setTimeout(() => setVisible(false), 2500);
|
|
165
|
+
return () => clearTimeout(t);
|
|
166
|
+
}, [props.playing, visible], _hs$ + 1);
|
|
167
|
+
const __warmPlan = VideoChrome.__warm;
|
|
168
|
+
if (typeof __warmPlan === "function") registerWarmPlan(__warmPlan, props);
|
|
169
|
+
else registerWarmPlan(() => {
|
|
170
|
+
if (props.poster && !props.started) warmChild(Image, {
|
|
171
|
+
className: "vx-video-poster",
|
|
172
|
+
src: props.poster,
|
|
173
|
+
ios: { stretch: "aspectFill" },
|
|
174
|
+
android: { stretch: "aspectFill" }
|
|
175
|
+
});
|
|
176
|
+
}, void 0);
|
|
177
|
+
{
|
|
178
|
+
const __ifCondition = props.poster && !props.started;
|
|
179
|
+
ifBlock(__s, 0, __block.parentNode, __ifCondition, __then$0, null, __block.endMarker, __ifCondition ? [props] : void 0);
|
|
180
|
+
}
|
|
181
|
+
componentSlot(__s, 1, __block.parentNode, Pressable, {
|
|
182
|
+
"className": "vx-video-tap",
|
|
183
|
+
"accessibilityRole": "button",
|
|
184
|
+
"accessibilityLabel": visible ? "Hide video controls" : "Show video controls",
|
|
185
|
+
"onPress": () => setVisible(props.playing ? !visible : true)
|
|
186
|
+
}, __block.endMarker, void 0, 2, void 0, void 0, "c:45f0b642");
|
|
187
|
+
{
|
|
188
|
+
const __ifCondition$ = visible;
|
|
189
|
+
ifBlock(__s, 2, __block.parentNode, __ifCondition$, __then$4, null, __block.endMarker, __ifCondition$ ? [props] : void 0);
|
|
190
|
+
}
|
|
191
|
+
}, (__wp) => {
|
|
192
|
+
const props = __wp;
|
|
193
|
+
if (props.poster && !props.started) warmChild(Image, {
|
|
194
|
+
className: "vx-video-poster",
|
|
195
|
+
src: props.poster,
|
|
196
|
+
ios: { stretch: "aspectFill" },
|
|
197
|
+
android: { stretch: "aspectFill" }
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
//#endregion
|
|
201
|
+
export { VideoChrome };
|