@octane-xplat/lottie 0.13.0 → 0.15.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/web/index.js DELETED
@@ -1,345 +0,0 @@
1
- import { applyEscapeProps } from "./escape-props.web.js";
2
- import { layoutChildProps } from "./layout-child.web.js";
3
- import { __s, bagOf, clone, hookSlots, snapshotSpread, template, useEffect, useImperativeHandle, useRef, useState } from "octane";
4
- import { bindSignalChild, bindSignalHostPropSources, compilerMemoRegion, enableSignalBindings, hookMemoCreate, hookMemoPublishInvariant } from "octane/internal/client";
5
- import lottie from "lottie-web";
6
- //#region src/Lottie.web.tsrx
7
- enableSignalBindings(1, true);
8
- var _t$0 = /* @__PURE__ */ template("<div></div>");
9
- var _hs$ = /* @__PURE__ */ hookSlots(10);
10
- var _rm$1 = [
11
- "s",
12
- "o",
13
- "n"
14
- ];
15
- var PRESERVE = {
16
- contain: "xMidYMid meet",
17
- cover: "xMidYMid slice",
18
- fill: "none"
19
- };
20
- var clamp01 = (n) => Math.min(1, Math.max(0, n));
21
- var Lottie = /* @__PURE__ */ __s(function Lottie(props, __s, __extra) {
22
- const __memoRegion = compilerMemoRegion(__s, _hs$ + 0);
23
- let __hk = __memoRegion.hooks;
24
- if (__hk === void 0) __memoRegion.hooks = __hk = hookMemoCreate(2);
25
- const [animation, setAnimation] = useState(null, _hs$ + 0);
26
- const el = useRef(null, _hs$ + 1);
27
- const anim = useRef(null, _hs$ + 2);
28
- const ready = useRef(false, _hs$ + 3);
29
- const wantPlay = () => props.playing ?? props.autoPlay ?? true;
30
- const build = (host) => {
31
- anim.current?.destroy();
32
- anim.current = null;
33
- setAnimation(null);
34
- ready.current = false;
35
- let animationData;
36
- try {
37
- animationData = props.data ?? (props.src?.startsWith("{") ? JSON.parse(props.src) : void 0);
38
- } catch (error) {
39
- props.onError?.({ message: error instanceof Error ? error.message : String(error) });
40
- return;
41
- }
42
- const path = animationData ? void 0 : props.src;
43
- if (!animationData && !path) return;
44
- let a;
45
- try {
46
- a = lottie.loadAnimation({
47
- container: host,
48
- renderer: "svg",
49
- loop: props.loop ?? false,
50
- autoplay: false,
51
- animationData,
52
- path,
53
- rendererSettings: { preserveAspectRatio: PRESERVE[props.fit ?? "contain"] }
54
- });
55
- } catch (error) {
56
- props.onError?.({ message: error instanceof Error ? error.message : String(error) });
57
- return;
58
- }
59
- anim.current = a;
60
- setAnimation(a);
61
- a.addEventListener("DOMLoaded", () => {
62
- ready.current = true;
63
- if (props.speed !== void 0) a.setSpeed(props.speed);
64
- if (props.progress !== void 0) seekTo(props.progress);
65
- props.onLoaded?.({ duration: a.getDuration() * 1e3 });
66
- if (wantPlay()) a.play();
67
- });
68
- a.addEventListener("complete", () => props.onEnded?.());
69
- a.addEventListener("data_failed", () => props.onError?.({ message: "animation data failed to load" }));
70
- a.addEventListener("error", () => props.onError?.({ message: "animation failed" }));
71
- };
72
- const seekTo = __hk[0] ?? hookMemoPublishInvariant(__hk, 0, (p) => {
73
- const a = anim.current;
74
- if (!a) return;
75
- const frame = clamp01(p) * a.totalFrames;
76
- if (a.isPaused) a.goToAndStop(frame, true);
77
- else a.goToAndPlay(frame, true);
78
- });
79
- useEffect(() => {
80
- const host = el.current;
81
- if (!host) return;
82
- build(host);
83
- return () => {
84
- anim.current?.destroy();
85
- anim.current = null;
86
- ready.current = false;
87
- };
88
- }, [
89
- props.src,
90
- props.data,
91
- props.fit
92
- ], _hs$ + 4);
93
- useEffect(() => {
94
- if (props.loop !== void 0 && anim.current) anim.current.loop = props.loop;
95
- }, [props.loop], _hs$ + 5);
96
- useEffect(() => {
97
- if (props.playing === void 0 || !anim.current || !ready.current) return;
98
- if (props.playing) anim.current.play();
99
- else anim.current.pause();
100
- }, [props.playing], _hs$ + 6);
101
- useEffect(() => {
102
- if (props.progress === void 0) return;
103
- seekTo(props.progress);
104
- }, [props.progress], _hs$ + 7);
105
- useEffect(() => {
106
- if (props.speed !== void 0) anim.current?.setSpeed(props.speed);
107
- }, [props.speed], _hs$ + 8);
108
- const handle = __hk[1] ?? hookMemoPublishInvariant(__hk, 1, (a) => ({
109
- play: () => a.play(),
110
- pause: () => a.pause(),
111
- stop: () => a.stop(),
112
- seekTo,
113
- setSpeed: (n) => a.setSpeed(n),
114
- progress: () => a.totalFrames ? a.currentRawFrame / a.totalFrames : 0,
115
- duration: () => a.getDuration() * 1e3,
116
- isPlaying: () => !a.isPaused,
117
- native: a
118
- }));
119
- useImperativeHandle(props.ref, () => animation ? handle(animation) : null, [animation], _hs$ + 9);
120
- let _b = __s.slots[0];
121
- if (_b === void 0) {
122
- let _m0, _m1, _m2, _m3, _m4, _m5, _m6, _m7, _m8, _m9, _m10, _m11, _m12, _m14;
123
- const _root = clone(_t$0);
124
- _m0 = (v) => {
125
- el.current = v;
126
- if (!v) return;
127
- applyEscapeProps(v, props);
128
- };
129
- _m1 = props.id;
130
- _m2 = props.className;
131
- _m3 = snapshotSpread(layoutChildProps(props, props.style));
132
- _m4 = props.accessibilityRole ?? "img";
133
- _m5 = props.accessibilityLabel;
134
- _m6 = props.accessible === false ? true : void 0;
135
- _m7 = props.accessibilityHint;
136
- _m8 = props.accessibilityValue;
137
- _m9 = props.accessibilityState?.disabled;
138
- _m10 = props.accessibilityState?.selected;
139
- _m11 = props.accessibilityState?.checked;
140
- _m12 = props.accessibilityLiveRegion === "none" ? "off" : props.accessibilityLiveRegion;
141
- _m14 = bindSignalHostPropSources(__s, void 0, _root, [
142
- [
143
- false,
144
- "ref",
145
- _m0
146
- ],
147
- [
148
- false,
149
- "id",
150
- _m1
151
- ],
152
- [
153
- false,
154
- "className",
155
- _m2
156
- ],
157
- [true, _m3],
158
- [
159
- false,
160
- "role",
161
- _m4
162
- ],
163
- [
164
- false,
165
- "aria-label",
166
- _m5
167
- ],
168
- [
169
- false,
170
- "aria-hidden",
171
- _m6
172
- ],
173
- [
174
- false,
175
- "aria-description",
176
- _m7
177
- ],
178
- [
179
- false,
180
- "aria-valuetext",
181
- _m8
182
- ],
183
- [
184
- false,
185
- "aria-disabled",
186
- _m9
187
- ],
188
- [
189
- false,
190
- "aria-selected",
191
- _m10
192
- ],
193
- [
194
- false,
195
- "aria-checked",
196
- _m11
197
- ],
198
- [
199
- false,
200
- "aria-live",
201
- _m12
202
- ]
203
- ], "b:9888aaf9", false);
204
- _b = bagOf(__s, _root, {
205
- a: _m0,
206
- b: _m1,
207
- c: _m2,
208
- d: _m3,
209
- e: _m4,
210
- f: _m5,
211
- g: _m6,
212
- h: _m7,
213
- i: _m8,
214
- j: _m9,
215
- k: _m10,
216
- l: _m11,
217
- m: _m12,
218
- n: _root,
219
- o: _m14,
220
- p: null,
221
- q: __s
222
- });
223
- __s.refFields = _rm$1;
224
- } else {
225
- {
226
- const _v = (v) => {
227
- el.current = v;
228
- if (!v) return;
229
- applyEscapeProps(v, props);
230
- };
231
- if (_b.a !== _v) _b.a = _v;
232
- }
233
- {
234
- const _v = props.id;
235
- if (_b.b !== _v) _b.b = _v;
236
- }
237
- {
238
- const _v = props.className;
239
- if (_b.c !== _v) _b.c = _v;
240
- }
241
- _b.d = snapshotSpread(layoutChildProps(props, props.style));
242
- {
243
- const _v = props.accessibilityRole ?? "img";
244
- if (_b.e !== _v) _b.e = _v;
245
- }
246
- {
247
- const _v = props.accessibilityLabel;
248
- if (_b.f !== _v) _b.f = _v;
249
- }
250
- {
251
- const _v = props.accessible === false ? true : void 0;
252
- if (_b.g !== _v) _b.g = _v;
253
- }
254
- {
255
- const _v = props.accessibilityHint;
256
- if (_b.h !== _v) _b.h = _v;
257
- }
258
- {
259
- const _v = props.accessibilityValue;
260
- if (_b.i !== _v) _b.i = _v;
261
- }
262
- {
263
- const _v = props.accessibilityState?.disabled;
264
- if (_b.j !== _v) _b.j = _v;
265
- }
266
- {
267
- const _v = props.accessibilityState?.selected;
268
- if (_b.k !== _v) _b.k = _v;
269
- }
270
- {
271
- const _v = props.accessibilityState?.checked;
272
- if (_b.l !== _v) _b.l = _v;
273
- }
274
- {
275
- const _v = props.accessibilityLiveRegion === "none" ? "off" : props.accessibilityLiveRegion;
276
- if (_b.m !== _v) _b.m = _v;
277
- }
278
- _b.o = bindSignalHostPropSources(__s, _b.o, _b.n, [
279
- [
280
- false,
281
- "ref",
282
- _b.a
283
- ],
284
- [
285
- false,
286
- "id",
287
- _b.b
288
- ],
289
- [
290
- false,
291
- "className",
292
- _b.c
293
- ],
294
- [true, _b.d],
295
- [
296
- false,
297
- "role",
298
- _b.e
299
- ],
300
- [
301
- false,
302
- "aria-label",
303
- _b.f
304
- ],
305
- [
306
- false,
307
- "aria-hidden",
308
- _b.g
309
- ],
310
- [
311
- false,
312
- "aria-description",
313
- _b.h
314
- ],
315
- [
316
- false,
317
- "aria-valuetext",
318
- _b.i
319
- ],
320
- [
321
- false,
322
- "aria-disabled",
323
- _b.j
324
- ],
325
- [
326
- false,
327
- "aria-selected",
328
- _b.k
329
- ],
330
- [
331
- false,
332
- "aria-checked",
333
- _b.l
334
- ],
335
- [
336
- false,
337
- "aria-live",
338
- _b.m
339
- ]
340
- ], "b:9888aaf9", false);
341
- }
342
- _b.r = bindSignalChild(__s, _b.r, 1, _b.n, Object.prototype.propertyIsEnumerable.call(_b.o.resolved, "children") ? _b.o.resolved.children : void 0, "b:9888aaf9", null, void 0, void 0, void 0, true);
343
- });
344
- //#endregion
345
- export { Lottie };
@@ -1,47 +0,0 @@
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 };
@@ -1,8 +0,0 @@
1
- {
2
- "version": 1,
3
- "buildId": "d701b975-f1a6-4ba8-9be9-d3ee9a8cb5b5",
4
- "mode": "production",
5
- "capabilities": {
6
- "independentHydration": false
7
- }
8
- }
package/src/cx.mobile.ts DELETED
@@ -1,9 +0,0 @@
1
- /** Native renderers now normalize the declarative `className` prop, but
2
- * imperative `view.className` writes still need a pre-joined string — NS
3
- * splits on ' ' only. Native leaves keep normalizing through cx() before
4
- * handing className to an intrinsic so both paths accept the same values.
5
- * (The DOM renderer already flattens arrays, so web leaves don't need
6
- * this.) */
7
- export function cx(...parts: any[]): string {
8
- return parts.flat(Infinity).filter(Boolean).join(' ')
9
- }
@@ -1,7 +0,0 @@
1
- /** Native renderers now normalize the declarative `className` prop, but
2
- * imperative `view.className` writes still need a pre-joined string — NS
3
- * splits on ' ' only. Native leaves keep normalizing through cx() before
4
- * handing className to an intrinsic so both paths accept the same values.
5
- * (The DOM renderer already flattens arrays, so web leaves don't need
6
- * this.) */
7
- export declare function cx(...parts: any[]): string;