@octane-xplat/video 0.0.0 → 0.7.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Alec Larson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,248 @@
1
+ import { cx } from "./cx.mobile.js";
2
+ import { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState } from "./escape-props.js";
3
+ import { layoutChildProps } from "./layout-child.js";
4
+ import { VideoChrome } from "./video-chrome.tsrx.js";
5
+ import { defineUniversalComponent, hookSlots, registerElement, universalComponent, universalIf, universalPlan, universalProps, universalValue, useCallback, useEffect, useRef, useState } from "@nativescript-community/octane";
6
+ import { Video, VideoFill } from "@nstudio/nativescript-exoplayer";
7
+ //#region src/Video.tsrx
8
+ var _hs$ = /* @__PURE__ */ hookSlots(11);
9
+ var _h$0 = /* @__PURE__ */ Symbol(_hs$);
10
+ var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
11
+ var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
12
+ var _h$3 = /* @__PURE__ */ Symbol(_hs$ + 3);
13
+ var _h$4 = /* @__PURE__ */ Symbol(_hs$ + 4);
14
+ var _h$5 = /* @__PURE__ */ Symbol(_hs$ + 5);
15
+ var _h$6 = /* @__PURE__ */ Symbol(_hs$ + 6);
16
+ var _h$7 = /* @__PURE__ */ Symbol(_hs$ + 7);
17
+ var _h$8 = /* @__PURE__ */ Symbol(_hs$ + 8);
18
+ var _h$9 = /* @__PURE__ */ Symbol(_hs$ + 9);
19
+ var _h$10 = /* @__PURE__ */ Symbol(_hs$ + 10);
20
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
21
+ "kind": "slot",
22
+ "slot": 0
23
+ });
24
+ var __octaneUniversalPlan1 = universalPlan("nativescript", {
25
+ "kind": "host",
26
+ "type": "gridlayout",
27
+ "propsSlot": 0,
28
+ "children": [{
29
+ "kind": "host",
30
+ "type": "xplatvideo",
31
+ "props": { "controls": false },
32
+ "bindings": [
33
+ ["ref", 1],
34
+ ["autoplay", 2],
35
+ ["loop", 3],
36
+ ["muted", 4],
37
+ ["fill", 5],
38
+ ["observeCurrentTime", 6],
39
+ ["onFinished", 7],
40
+ ["onPlaybackReady", 8],
41
+ ["onPlaybackStart", 9],
42
+ ["onCurrentTimeUpdated", 10]
43
+ ]
44
+ }, {
45
+ "kind": "slot",
46
+ "slot": 11
47
+ }]
48
+ });
49
+ registerElement("xplatvideo", Video);
50
+ var FILLS = {
51
+ contain: VideoFill.aspect,
52
+ cover: VideoFill.aspectFill,
53
+ fill: VideoFill.fill
54
+ };
55
+ var Video$1 = defineUniversalComponent("nativescript", function Video(props) {
56
+ const host = useRef(null, _h$0);
57
+ const [playing, setPlaying] = useState(props.playing ?? props.autoPlay ?? false, _h$1);
58
+ const [started, setStarted] = useState(false, _h$2);
59
+ const [position, setPosition] = useState(0, _h$3);
60
+ const [duration, setDuration] = useState(0, _h$4);
61
+ const [internalMuted, setInternalMuted] = useState(false, _h$5);
62
+ const muted = props.muted ?? internalMuted;
63
+ const appliedSrc = useRef(void 0, _h$6);
64
+ const bindHost = useCallback((v) => {
65
+ host.current = v;
66
+ }, [], _h$7);
67
+ const drive = (v, next) => {
68
+ if (!v) return;
69
+ if (next) v.play();
70
+ else v.pause();
71
+ };
72
+ useEffect(() => {
73
+ const v = host.current;
74
+ if (!v) return;
75
+ applyEscapeProps(v, props);
76
+ props.bind?.(handle(v));
77
+ }, [], _h$8);
78
+ useEffect(() => {
79
+ const v = host.current;
80
+ if (!v || props.src === appliedSrc.current) return;
81
+ appliedSrc.current = props.src;
82
+ v.src = props.src;
83
+ }, [props.src], _h$9);
84
+ useEffect(() => {
85
+ if (props.playing === void 0) return;
86
+ setPlaying(props.playing);
87
+ drive(host.current, props.playing);
88
+ }, [props.playing], _h$10);
89
+ const togglePlay = () => {
90
+ const next = !playing;
91
+ setPlaying(next);
92
+ drive(host.current, next);
93
+ props.onPlayingChange?.(next);
94
+ };
95
+ const handle = (v) => ({
96
+ play: () => v.play(),
97
+ pause: () => v.pause(),
98
+ seekTo: (ms) => v.seekToTime(ms / 1e3),
99
+ currentTime: () => v.getCurrentTime(),
100
+ duration: () => v.getDuration(),
101
+ native: v
102
+ });
103
+ return universalValue(__octaneUniversalPlan1, [
104
+ universalProps([
105
+ [
106
+ "set",
107
+ "id",
108
+ props.id
109
+ ],
110
+ [
111
+ "set",
112
+ "rows",
113
+ "*"
114
+ ],
115
+ [
116
+ "set",
117
+ "columns",
118
+ "*"
119
+ ],
120
+ [
121
+ "set",
122
+ "className",
123
+ cx("vx-stack", "vx-video", props.className)
124
+ ],
125
+ [
126
+ "set",
127
+ "style",
128
+ props.style
129
+ ],
130
+ ["spread", layoutChildProps(props)],
131
+ [
132
+ "set",
133
+ "accessible",
134
+ props.accessible
135
+ ],
136
+ [
137
+ "set",
138
+ "accessibilityLabel",
139
+ props.accessibilityLabel
140
+ ],
141
+ [
142
+ "set",
143
+ "accessibilityRole",
144
+ nativeAccessibilityRole(props.accessibilityRole)
145
+ ],
146
+ [
147
+ "set",
148
+ "accessibilityHint",
149
+ props.accessibilityHint
150
+ ],
151
+ [
152
+ "set",
153
+ "accessibilityValue",
154
+ props.accessibilityValue
155
+ ],
156
+ [
157
+ "set",
158
+ "accessibilityState",
159
+ nativeAccessibilityState(props.accessibilityState)
160
+ ],
161
+ [
162
+ "set",
163
+ "accessibilityLiveRegion",
164
+ props.accessibilityLiveRegion
165
+ ]
166
+ ]),
167
+ bindHost,
168
+ props.playing ?? props.autoPlay ?? false,
169
+ props.loop,
170
+ muted,
171
+ FILLS[props.fit ?? "contain"],
172
+ props.controls !== false,
173
+ () => {
174
+ if (!props.loop) {
175
+ setPlaying(false);
176
+ props.onEnded?.();
177
+ }
178
+ },
179
+ () => {
180
+ const ms = host.current?.getDuration?.() ?? 0;
181
+ setDuration(ms);
182
+ props.onReady?.({ duration: ms });
183
+ },
184
+ () => setStarted(true),
185
+ (e) => setPosition(e.position ?? 0),
186
+ universalIf(props.controls !== false, () => {
187
+ return universalValue(__octaneUniversalPlan0, [universalComponent("nativescript", VideoChrome, universalProps([
188
+ [
189
+ "set",
190
+ "poster",
191
+ props.poster
192
+ ],
193
+ [
194
+ "set",
195
+ "started",
196
+ started
197
+ ],
198
+ [
199
+ "set",
200
+ "playing",
201
+ playing
202
+ ],
203
+ [
204
+ "set",
205
+ "position",
206
+ position
207
+ ],
208
+ [
209
+ "set",
210
+ "duration",
211
+ duration
212
+ ],
213
+ [
214
+ "set",
215
+ "muted",
216
+ muted
217
+ ],
218
+ [
219
+ "set",
220
+ "onTogglePlay",
221
+ togglePlay
222
+ ],
223
+ [
224
+ "set",
225
+ "onToggleMute",
226
+ () => {
227
+ const next = !muted;
228
+ setInternalMuted(next);
229
+ if (host.current) host.current.muted = next;
230
+ props.onMutedChange?.(next);
231
+ }
232
+ ],
233
+ [
234
+ "set",
235
+ "onSeek",
236
+ (ms) => {
237
+ if (host.current) {
238
+ host.current.seekToTime(ms / 1e3);
239
+ setPosition(ms);
240
+ }
241
+ }
242
+ ]
243
+ ]))]);
244
+ })
245
+ ]);
246
+ }, { "module": "@nativescript-community/octane" });
247
+ //#endregion
248
+ export { Video$1 as Video };
@@ -0,0 +1,11 @@
1
+ //#region src/cx.mobile.ts
2
+ /** NS `className` splits on ' ' only, and the universal driver applies the
3
+ * prop via `String(value)` — an array would arrive comma-joined and match
4
+ * no class at all. Native leaves normalize through cx() before handing
5
+ * className to an intrinsic. (The DOM renderer already flattens arrays,
6
+ * so web leaves don't need this.) */
7
+ function cx(...parts) {
8
+ return parts.flat(Infinity).filter(Boolean).join(" ");
9
+ }
10
+ //#endregion
11
+ export { cx };
@@ -0,0 +1,39 @@
1
+ import { isAndroid, isIOS } from "@nativescript/core";
2
+ //#region src/escape-props.ts
3
+ /** Apply only the active device's escape bag after the primitive's own props. */
4
+ function applyEscapeProps(view, props) {
5
+ if (!view) return;
6
+ const bag = isIOS ? props.ios : isAndroid ? props.android : void 0;
7
+ if (bag) Object.assign(view, bag);
8
+ }
9
+ var NATIVE_ACCESSIBILITY_ROLES = {
10
+ button: "button",
11
+ link: "link",
12
+ search: "search",
13
+ image: "image",
14
+ heading: "header",
15
+ adjustable: "adjustable",
16
+ summary: "summary",
17
+ text: "text",
18
+ none: "none",
19
+ progressbar: "progressBar",
20
+ checkbox: "checkbox",
21
+ switch: "switch",
22
+ radio: "radioButton",
23
+ spinbutton: "spinButton",
24
+ tab: "button"
25
+ };
26
+ /** Translate the shared/ARIA spelling to NativeScript's narrower role enum. */
27
+ function nativeAccessibilityRole(role) {
28
+ return role ? NATIVE_ACCESSIBILITY_ROLES[role] : void 0;
29
+ }
30
+ /** NativeScript's AccessibilityState is a single enum value, unlike the
31
+ * web's independent ARIA booleans. Priority follows the strongest state. */
32
+ function nativeAccessibilityState(state) {
33
+ if (state?.disabled) return "disabled";
34
+ if (state?.selected) return "selected";
35
+ if (state?.checked === true) return "checked";
36
+ if (state?.checked === false) return "unchecked";
37
+ }
38
+ //#endregion
39
+ export { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState };
@@ -0,0 +1,2 @@
1
+ import { Video } from "./Video.tsrx.js";
2
+ export { Video };
@@ -0,0 +1,38 @@
1
+ //#region src/layout-child.ts
2
+ var FLEX_JUSTIFY = {
3
+ start: "flex-start",
4
+ end: "flex-end"
5
+ };
6
+ var FLEX_ALIGN = {
7
+ start: "flex-start",
8
+ end: "flex-end"
9
+ };
10
+ /** NativeScript reads these attributes from each child view during parent
11
+ * layout. Values are forwarded with NativeScript's own property names.
12
+ * The flex-container props (justifyContent/alignItems/flexWrap/gap) land on
13
+ * the host flexboxlayout itself — its own attributes, not child metadata. */
14
+ function layoutChildProps(props) {
15
+ const result = {};
16
+ for (const key of [
17
+ "row",
18
+ "col",
19
+ "rowSpan",
20
+ "colSpan",
21
+ "dock",
22
+ "left",
23
+ "top",
24
+ "flexGrow",
25
+ "flexShrink",
26
+ "alignSelf",
27
+ "order"
28
+ ]) if (props[key] !== void 0) result[key] = props[key];
29
+ if (props.justifyContent !== void 0) result.justifyContent = FLEX_JUSTIFY[props.justifyContent] ?? props.justifyContent;
30
+ if (props.alignItems !== void 0) result.alignItems = FLEX_ALIGN[props.alignItems] ?? props.alignItems;
31
+ if (props.flexWrap !== void 0) result.flexWrap = props.flexWrap === true ? "wrap" : props.flexWrap === false ? "nowrap" : props.flexWrap;
32
+ if (props.gap !== void 0) result.gap = props.gap;
33
+ if (props.rowGap !== void 0) result.rowGap = props.rowGap;
34
+ if (props.columnGap !== void 0) result.columnGap = props.columnGap;
35
+ return result;
36
+ }
37
+ //#endregion
38
+ export { layoutChildProps };
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 1,
3
+ "buildId": "e070897b-99fd-4d2b-b98e-af2be6296830",
4
+ "mode": "production",
5
+ "capabilities": {
6
+ "independentHydration": false
7
+ }
8
+ }