@ikonai/sdk-react-ui-rive 0.0.11
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/components/rive-canvas.d.ts +2 -0
- package/index.d.ts +2 -0
- package/index.js +779 -0
- package/package.json +20 -0
- package/rive-module.d.ts +5 -0
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
import me, { useMemo as B, useRef as oe, useEffect as V, useCallback as Y } from "react";
|
|
2
|
+
import { Fit as T, Alignment as O, Layout as ge, useRive as be, EventType as G } from "@rive-app/react-canvas";
|
|
3
|
+
var q = { exports: {} }, D = {};
|
|
4
|
+
/**
|
|
5
|
+
* @license React
|
|
6
|
+
* react-jsx-runtime.production.js
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
var ie;
|
|
14
|
+
function he() {
|
|
15
|
+
if (ie) return D;
|
|
16
|
+
ie = 1;
|
|
17
|
+
var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
18
|
+
function o(a, i, r) {
|
|
19
|
+
var l = null;
|
|
20
|
+
if (r !== void 0 && (l = "" + r), i.key !== void 0 && (l = "" + i.key), "key" in i) {
|
|
21
|
+
r = {};
|
|
22
|
+
for (var p in i)
|
|
23
|
+
p !== "key" && (r[p] = i[p]);
|
|
24
|
+
} else r = i;
|
|
25
|
+
return i = r.ref, {
|
|
26
|
+
$$typeof: e,
|
|
27
|
+
type: a,
|
|
28
|
+
key: l,
|
|
29
|
+
ref: i !== void 0 ? i : null,
|
|
30
|
+
props: r
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return D.Fragment = n, D.jsx = o, D.jsxs = o, D;
|
|
34
|
+
}
|
|
35
|
+
var z = {};
|
|
36
|
+
/**
|
|
37
|
+
* @license React
|
|
38
|
+
* react-jsx-runtime.development.js
|
|
39
|
+
*
|
|
40
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the MIT license found in the
|
|
43
|
+
* LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/
|
|
45
|
+
var se;
|
|
46
|
+
function ve() {
|
|
47
|
+
return se || (se = 1, process.env.NODE_ENV !== "production" && function() {
|
|
48
|
+
function e(t) {
|
|
49
|
+
if (t == null) return null;
|
|
50
|
+
if (typeof t == "function")
|
|
51
|
+
return t.$$typeof === le ? null : t.displayName || t.name || null;
|
|
52
|
+
if (typeof t == "string") return t;
|
|
53
|
+
switch (t) {
|
|
54
|
+
case M:
|
|
55
|
+
return "Fragment";
|
|
56
|
+
case S:
|
|
57
|
+
return "Profiler";
|
|
58
|
+
case P:
|
|
59
|
+
return "StrictMode";
|
|
60
|
+
case g:
|
|
61
|
+
return "Suspense";
|
|
62
|
+
case b:
|
|
63
|
+
return "SuspenseList";
|
|
64
|
+
case ue:
|
|
65
|
+
return "Activity";
|
|
66
|
+
}
|
|
67
|
+
if (typeof t == "object")
|
|
68
|
+
switch (typeof t.tag == "number" && console.error(
|
|
69
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
|
+
), t.$$typeof) {
|
|
71
|
+
case L:
|
|
72
|
+
return "Portal";
|
|
73
|
+
case c:
|
|
74
|
+
return (t.displayName || "Context") + ".Provider";
|
|
75
|
+
case u:
|
|
76
|
+
return (t._context.displayName || "Context") + ".Consumer";
|
|
77
|
+
case f:
|
|
78
|
+
var s = t.render;
|
|
79
|
+
return t = t.displayName, t || (t = s.displayName || s.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
80
|
+
case d:
|
|
81
|
+
return s = t.displayName || null, s !== null ? s : e(t.type) || "Memo";
|
|
82
|
+
case h:
|
|
83
|
+
s = t._payload, t = t._init;
|
|
84
|
+
try {
|
|
85
|
+
return e(t(s));
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function n(t) {
|
|
92
|
+
return "" + t;
|
|
93
|
+
}
|
|
94
|
+
function o(t) {
|
|
95
|
+
try {
|
|
96
|
+
n(t);
|
|
97
|
+
var s = !1;
|
|
98
|
+
} catch {
|
|
99
|
+
s = !0;
|
|
100
|
+
}
|
|
101
|
+
if (s) {
|
|
102
|
+
s = console;
|
|
103
|
+
var m = s.error, y = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
104
|
+
return m.call(
|
|
105
|
+
s,
|
|
106
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
|
+
y
|
|
108
|
+
), n(t);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function a(t) {
|
|
112
|
+
if (t === M) return "<>";
|
|
113
|
+
if (typeof t == "object" && t !== null && t.$$typeof === h)
|
|
114
|
+
return "<...>";
|
|
115
|
+
try {
|
|
116
|
+
var s = e(t);
|
|
117
|
+
return s ? "<" + s + ">" : "<...>";
|
|
118
|
+
} catch {
|
|
119
|
+
return "<...>";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function i() {
|
|
123
|
+
var t = $.A;
|
|
124
|
+
return t === null ? null : t.getOwner();
|
|
125
|
+
}
|
|
126
|
+
function r() {
|
|
127
|
+
return Error("react-stack-top-frame");
|
|
128
|
+
}
|
|
129
|
+
function l(t) {
|
|
130
|
+
if (Z.call(t, "key")) {
|
|
131
|
+
var s = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
132
|
+
if (s && s.isReactWarning) return !1;
|
|
133
|
+
}
|
|
134
|
+
return t.key !== void 0;
|
|
135
|
+
}
|
|
136
|
+
function p(t, s) {
|
|
137
|
+
function m() {
|
|
138
|
+
Q || (Q = !0, console.error(
|
|
139
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
140
|
+
s
|
|
141
|
+
));
|
|
142
|
+
}
|
|
143
|
+
m.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
144
|
+
get: m,
|
|
145
|
+
configurable: !0
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function _() {
|
|
149
|
+
var t = e(this.type);
|
|
150
|
+
return ee[t] || (ee[t] = !0, console.error(
|
|
151
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
152
|
+
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
153
|
+
}
|
|
154
|
+
function k(t, s, m, y, N, A, W, H) {
|
|
155
|
+
return m = A.ref, t = {
|
|
156
|
+
$$typeof: I,
|
|
157
|
+
type: t,
|
|
158
|
+
key: s,
|
|
159
|
+
props: A,
|
|
160
|
+
_owner: N
|
|
161
|
+
}, (m !== void 0 ? m : null) !== null ? Object.defineProperty(t, "ref", {
|
|
162
|
+
enumerable: !1,
|
|
163
|
+
get: _
|
|
164
|
+
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
165
|
+
configurable: !1,
|
|
166
|
+
enumerable: !1,
|
|
167
|
+
writable: !0,
|
|
168
|
+
value: 0
|
|
169
|
+
}), Object.defineProperty(t, "_debugInfo", {
|
|
170
|
+
configurable: !1,
|
|
171
|
+
enumerable: !1,
|
|
172
|
+
writable: !0,
|
|
173
|
+
value: null
|
|
174
|
+
}), Object.defineProperty(t, "_debugStack", {
|
|
175
|
+
configurable: !1,
|
|
176
|
+
enumerable: !1,
|
|
177
|
+
writable: !0,
|
|
178
|
+
value: W
|
|
179
|
+
}), Object.defineProperty(t, "_debugTask", {
|
|
180
|
+
configurable: !1,
|
|
181
|
+
enumerable: !1,
|
|
182
|
+
writable: !0,
|
|
183
|
+
value: H
|
|
184
|
+
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
185
|
+
}
|
|
186
|
+
function v(t, s, m, y, N, A, W, H) {
|
|
187
|
+
var R = s.children;
|
|
188
|
+
if (R !== void 0)
|
|
189
|
+
if (y)
|
|
190
|
+
if (fe(R)) {
|
|
191
|
+
for (y = 0; y < R.length; y++)
|
|
192
|
+
E(R[y]);
|
|
193
|
+
Object.freeze && Object.freeze(R);
|
|
194
|
+
} else
|
|
195
|
+
console.error(
|
|
196
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
|
+
);
|
|
198
|
+
else E(R);
|
|
199
|
+
if (Z.call(s, "key")) {
|
|
200
|
+
R = e(t);
|
|
201
|
+
var F = Object.keys(s).filter(function(de) {
|
|
202
|
+
return de !== "key";
|
|
203
|
+
});
|
|
204
|
+
y = 0 < F.length ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}", ne[R + y] || (F = 0 < F.length ? "{" + F.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
206
|
+
let props = %s;
|
|
207
|
+
<%s {...props} />
|
|
208
|
+
React keys must be passed directly to JSX without using spread:
|
|
209
|
+
let props = %s;
|
|
210
|
+
<%s key={someKey} {...props} />`,
|
|
211
|
+
y,
|
|
212
|
+
R,
|
|
213
|
+
F,
|
|
214
|
+
R
|
|
215
|
+
), ne[R + y] = !0);
|
|
216
|
+
}
|
|
217
|
+
if (R = null, m !== void 0 && (o(m), R = "" + m), l(s) && (o(s.key), R = "" + s.key), "key" in s) {
|
|
218
|
+
m = {};
|
|
219
|
+
for (var J in s)
|
|
220
|
+
J !== "key" && (m[J] = s[J]);
|
|
221
|
+
} else m = s;
|
|
222
|
+
return R && p(
|
|
223
|
+
m,
|
|
224
|
+
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
225
|
+
), k(
|
|
226
|
+
t,
|
|
227
|
+
R,
|
|
228
|
+
A,
|
|
229
|
+
N,
|
|
230
|
+
i(),
|
|
231
|
+
m,
|
|
232
|
+
W,
|
|
233
|
+
H
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
function E(t) {
|
|
237
|
+
typeof t == "object" && t !== null && t.$$typeof === I && t._store && (t._store.validated = 1);
|
|
238
|
+
}
|
|
239
|
+
var j = me, I = Symbol.for("react.transitional.element"), L = Symbol.for("react.portal"), M = Symbol.for("react.fragment"), P = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), u = Symbol.for("react.consumer"), c = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), b = Symbol.for("react.suspense_list"), d = Symbol.for("react.memo"), h = Symbol.for("react.lazy"), ue = Symbol.for("react.activity"), le = Symbol.for("react.client.reference"), $ = j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, fe = Array.isArray, K = console.createTask ? console.createTask : function() {
|
|
240
|
+
return null;
|
|
241
|
+
};
|
|
242
|
+
j = {
|
|
243
|
+
"react-stack-bottom-frame": function(t) {
|
|
244
|
+
return t();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
var Q, ee = {}, te = j["react-stack-bottom-frame"].bind(
|
|
248
|
+
j,
|
|
249
|
+
r
|
|
250
|
+
)(), re = K(a(r)), ne = {};
|
|
251
|
+
z.Fragment = M, z.jsx = function(t, s, m, y, N) {
|
|
252
|
+
var A = 1e4 > $.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return v(
|
|
254
|
+
t,
|
|
255
|
+
s,
|
|
256
|
+
m,
|
|
257
|
+
!1,
|
|
258
|
+
y,
|
|
259
|
+
N,
|
|
260
|
+
A ? Error("react-stack-top-frame") : te,
|
|
261
|
+
A ? K(a(t)) : re
|
|
262
|
+
);
|
|
263
|
+
}, z.jsxs = function(t, s, m, y, N) {
|
|
264
|
+
var A = 1e4 > $.recentlyCreatedOwnerStacks++;
|
|
265
|
+
return v(
|
|
266
|
+
t,
|
|
267
|
+
s,
|
|
268
|
+
m,
|
|
269
|
+
!0,
|
|
270
|
+
y,
|
|
271
|
+
N,
|
|
272
|
+
A ? Error("react-stack-top-frame") : te,
|
|
273
|
+
A ? K(a(t)) : re
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
}()), z;
|
|
277
|
+
}
|
|
278
|
+
var ae;
|
|
279
|
+
function pe() {
|
|
280
|
+
return ae || (ae = 1, process.env.NODE_ENV === "production" ? q.exports = he() : q.exports = ve()), q.exports;
|
|
281
|
+
}
|
|
282
|
+
var X = pe();
|
|
283
|
+
function C(e) {
|
|
284
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
285
|
+
}
|
|
286
|
+
function w(e) {
|
|
287
|
+
if (typeof e == "string") {
|
|
288
|
+
const n = e.trim();
|
|
289
|
+
return n.length > 0 ? n : void 0;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function x(e) {
|
|
293
|
+
if (typeof e == "boolean")
|
|
294
|
+
return e;
|
|
295
|
+
if (typeof e == "string") {
|
|
296
|
+
if (e === "true")
|
|
297
|
+
return !0;
|
|
298
|
+
if (e === "false")
|
|
299
|
+
return !1;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function U(e) {
|
|
303
|
+
if (typeof e == "number" && Number.isFinite(e))
|
|
304
|
+
return e;
|
|
305
|
+
if (typeof e == "string") {
|
|
306
|
+
const n = Number(e.trim());
|
|
307
|
+
return Number.isFinite(n) ? n : void 0;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function ce(e) {
|
|
311
|
+
if (typeof e == "number" && Number.isFinite(e))
|
|
312
|
+
return `${e}px`;
|
|
313
|
+
if (typeof e == "string") {
|
|
314
|
+
const n = e.trim();
|
|
315
|
+
return n.length > 0 ? n : void 0;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function ye(e, n, o) {
|
|
319
|
+
const a = [];
|
|
320
|
+
for (const i of e)
|
|
321
|
+
if (typeof i == "string") {
|
|
322
|
+
const r = i.trim();
|
|
323
|
+
r.length > 0 && a.push(r);
|
|
324
|
+
}
|
|
325
|
+
if (typeof n == "string") {
|
|
326
|
+
const i = n.trim();
|
|
327
|
+
i.length > 0 && a.push(i);
|
|
328
|
+
}
|
|
329
|
+
if (typeof o == "string") {
|
|
330
|
+
const i = o.trim();
|
|
331
|
+
i.length > 0 && a.push(i);
|
|
332
|
+
}
|
|
333
|
+
return a.length > 0 ? a.join(" ") : void 0;
|
|
334
|
+
}
|
|
335
|
+
function Re(e) {
|
|
336
|
+
if (typeof e == "string") {
|
|
337
|
+
const n = e.trim();
|
|
338
|
+
return n.length > 0 ? [n] : void 0;
|
|
339
|
+
}
|
|
340
|
+
if (Array.isArray(e)) {
|
|
341
|
+
const n = e.map((o) => typeof o == "string" ? o.trim() : "").filter((o) => o.length > 0);
|
|
342
|
+
return n.length > 0 ? Array.from(new Set(n)) : void 0;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const Ee = {
|
|
346
|
+
contain: T.Contain,
|
|
347
|
+
cover: T.Cover,
|
|
348
|
+
fill: T.Fill,
|
|
349
|
+
fitwidth: T.FitWidth,
|
|
350
|
+
fitheight: T.FitHeight,
|
|
351
|
+
width: T.FitWidth,
|
|
352
|
+
height: T.FitHeight,
|
|
353
|
+
scaledown: T.ScaleDown,
|
|
354
|
+
layout: T.Layout,
|
|
355
|
+
stretch: T.Fill,
|
|
356
|
+
none: T.None
|
|
357
|
+
};
|
|
358
|
+
function we(e) {
|
|
359
|
+
if (typeof e != "string")
|
|
360
|
+
return;
|
|
361
|
+
const n = e.replace(/[-_\s]/g, "").toLowerCase();
|
|
362
|
+
return Ee[n];
|
|
363
|
+
}
|
|
364
|
+
const ke = {
|
|
365
|
+
center: O.Center,
|
|
366
|
+
topleft: O.TopLeft,
|
|
367
|
+
topcenter: O.TopCenter,
|
|
368
|
+
topright: O.TopRight,
|
|
369
|
+
centerleft: O.CenterLeft,
|
|
370
|
+
centerright: O.CenterRight,
|
|
371
|
+
bottomleft: O.BottomLeft,
|
|
372
|
+
bottomcenter: O.BottomCenter,
|
|
373
|
+
bottomright: O.BottomRight
|
|
374
|
+
};
|
|
375
|
+
function Te(e) {
|
|
376
|
+
if (typeof e != "string")
|
|
377
|
+
return;
|
|
378
|
+
const n = e.replace(/[-_\s]/g, "").toLowerCase();
|
|
379
|
+
return ke[n];
|
|
380
|
+
}
|
|
381
|
+
function _e(e) {
|
|
382
|
+
if (!C(e))
|
|
383
|
+
return;
|
|
384
|
+
const n = {};
|
|
385
|
+
let o = !1;
|
|
386
|
+
for (const [a, i] of Object.entries(e)) {
|
|
387
|
+
const r = a.trim();
|
|
388
|
+
if (!r)
|
|
389
|
+
continue;
|
|
390
|
+
const l = x(i);
|
|
391
|
+
l !== void 0 && (n[r] = l, o = !0);
|
|
392
|
+
}
|
|
393
|
+
return o ? n : void 0;
|
|
394
|
+
}
|
|
395
|
+
function Ae(e) {
|
|
396
|
+
if (!C(e))
|
|
397
|
+
return;
|
|
398
|
+
const n = {};
|
|
399
|
+
let o = !1;
|
|
400
|
+
for (const [a, i] of Object.entries(e)) {
|
|
401
|
+
const r = a.trim();
|
|
402
|
+
if (!r)
|
|
403
|
+
continue;
|
|
404
|
+
const l = U(i);
|
|
405
|
+
l !== void 0 && (n[r] = l, o = !0);
|
|
406
|
+
}
|
|
407
|
+
return o ? n : void 0;
|
|
408
|
+
}
|
|
409
|
+
function Oe(e) {
|
|
410
|
+
if (!C(e))
|
|
411
|
+
return;
|
|
412
|
+
const n = {};
|
|
413
|
+
let o = !1;
|
|
414
|
+
for (const [a, i] of Object.entries(e)) {
|
|
415
|
+
const r = a.trim();
|
|
416
|
+
if (!r)
|
|
417
|
+
continue;
|
|
418
|
+
const l = w(i);
|
|
419
|
+
l && (n[r] = l, o = !0);
|
|
420
|
+
}
|
|
421
|
+
return o ? n : void 0;
|
|
422
|
+
}
|
|
423
|
+
function Se(e) {
|
|
424
|
+
if (!C(e))
|
|
425
|
+
return;
|
|
426
|
+
const n = _e(e.booleans), o = Ae(e.numbers), a = Oe(e.strings);
|
|
427
|
+
if (!(!n && !o && !a))
|
|
428
|
+
return { booleans: n, numbers: o, strings: a };
|
|
429
|
+
}
|
|
430
|
+
function Ce(e) {
|
|
431
|
+
if (!Array.isArray(e))
|
|
432
|
+
return;
|
|
433
|
+
const n = [];
|
|
434
|
+
for (const o of e) {
|
|
435
|
+
if (!C(o))
|
|
436
|
+
continue;
|
|
437
|
+
const a = w(o.name), i = U(o.sequence);
|
|
438
|
+
!a || i === void 0 || n.push({ name: a, sequence: i });
|
|
439
|
+
}
|
|
440
|
+
if (n.length !== 0)
|
|
441
|
+
return n;
|
|
442
|
+
}
|
|
443
|
+
function je(e) {
|
|
444
|
+
if (!C(e))
|
|
445
|
+
return;
|
|
446
|
+
const n = {};
|
|
447
|
+
let o = !1;
|
|
448
|
+
for (const [a, i] of Object.entries(e)) {
|
|
449
|
+
const r = a.trim();
|
|
450
|
+
if (r) {
|
|
451
|
+
if (typeof i == "boolean") {
|
|
452
|
+
n[r] = i, o = !0;
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (typeof i == "number" && Number.isFinite(i)) {
|
|
456
|
+
n[r] = i, o = !0;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (typeof i == "string") {
|
|
460
|
+
const l = i.trim();
|
|
461
|
+
if (!l)
|
|
462
|
+
continue;
|
|
463
|
+
n[r] = l, o = !0;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return o ? n : void 0;
|
|
468
|
+
}
|
|
469
|
+
function Pe(e) {
|
|
470
|
+
if (!C(e))
|
|
471
|
+
return;
|
|
472
|
+
const n = w(e.name);
|
|
473
|
+
if (!n)
|
|
474
|
+
return;
|
|
475
|
+
const o = U(e.type), a = U(e.delay), i = w(e.url), r = w(e.target), l = je(e.properties);
|
|
476
|
+
return {
|
|
477
|
+
name: n,
|
|
478
|
+
type: o === void 0 ? void 0 : Math.trunc(o),
|
|
479
|
+
delay: a,
|
|
480
|
+
url: i,
|
|
481
|
+
target: r,
|
|
482
|
+
properties: l
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function Ne(e) {
|
|
486
|
+
if (!C(e))
|
|
487
|
+
return;
|
|
488
|
+
const n = {};
|
|
489
|
+
let o = !1;
|
|
490
|
+
for (const [a, i] of Object.entries(e)) {
|
|
491
|
+
const r = a.trim();
|
|
492
|
+
if (!r)
|
|
493
|
+
continue;
|
|
494
|
+
const l = w(i);
|
|
495
|
+
l && (n[r] = l, o = !0);
|
|
496
|
+
}
|
|
497
|
+
return o ? n : void 0;
|
|
498
|
+
}
|
|
499
|
+
function xe(e) {
|
|
500
|
+
if (!Array.isArray(e))
|
|
501
|
+
return;
|
|
502
|
+
const n = [];
|
|
503
|
+
for (const o of e) {
|
|
504
|
+
if (!C(o))
|
|
505
|
+
continue;
|
|
506
|
+
const a = w(o.key), i = w(o.input), r = w(o.kind);
|
|
507
|
+
if (!a || !i || !r)
|
|
508
|
+
continue;
|
|
509
|
+
const l = a.replace(/[-_\s]+/g, "").toLowerCase();
|
|
510
|
+
let p;
|
|
511
|
+
switch (l) {
|
|
512
|
+
case "arrowup":
|
|
513
|
+
case "up":
|
|
514
|
+
p = "ArrowUp";
|
|
515
|
+
break;
|
|
516
|
+
case "arrowdown":
|
|
517
|
+
case "down":
|
|
518
|
+
p = "ArrowDown";
|
|
519
|
+
break;
|
|
520
|
+
case "arrowleft":
|
|
521
|
+
case "left":
|
|
522
|
+
p = "ArrowLeft";
|
|
523
|
+
break;
|
|
524
|
+
case "arrowright":
|
|
525
|
+
case "right":
|
|
526
|
+
p = "ArrowRight";
|
|
527
|
+
break;
|
|
528
|
+
default:
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
const _ = r.replace(/[-_\s]+/g, "").toLowerCase();
|
|
532
|
+
let k;
|
|
533
|
+
_ === "boolean" ? k = "boolean" : _ === "trigger" && (k = "trigger"), k && n.push({ key: p, input: i, kind: k });
|
|
534
|
+
}
|
|
535
|
+
return n.length > 0 ? n : void 0;
|
|
536
|
+
}
|
|
537
|
+
function Me(e, n) {
|
|
538
|
+
return n.byteLength > 0 ? (e.decode(n), !0) : !1;
|
|
539
|
+
}
|
|
540
|
+
function Ie() {
|
|
541
|
+
if (typeof globalThis > "u")
|
|
542
|
+
return !1;
|
|
543
|
+
const e = globalThis, n = typeof e.OffscreenCanvas < "u", o = typeof e.crossOriginIsolated == "boolean" ? e.crossOriginIsolated : !1;
|
|
544
|
+
return n && o;
|
|
545
|
+
}
|
|
546
|
+
function Fe(e) {
|
|
547
|
+
const n = B(
|
|
548
|
+
() => new ge({
|
|
549
|
+
fit: e.layoutFit ?? T.Contain,
|
|
550
|
+
alignment: e.layoutAlignment ?? O.Center
|
|
551
|
+
}),
|
|
552
|
+
[e.layoutFit, e.layoutAlignment]
|
|
553
|
+
), o = B(() => Ie(), []), a = (e.useOffscreenRenderer ?? !0) && o, i = {
|
|
554
|
+
src: e.src,
|
|
555
|
+
stateMachines: e.stateMachines,
|
|
556
|
+
autoplay: e.autoplay ?? !0,
|
|
557
|
+
useOffscreenRenderer: a,
|
|
558
|
+
autoBind: e.autoBind ?? !0,
|
|
559
|
+
enableMultiTouch: e.enableMultiTouch,
|
|
560
|
+
dispatchPointerExit: e.dispatchPointerExit,
|
|
561
|
+
isTouchScrollEnabled: e.isTouchScrollEnabled,
|
|
562
|
+
shouldDisableRiveListeners: e.shouldDisableRiveListeners,
|
|
563
|
+
layout: n,
|
|
564
|
+
assetLoader: Me
|
|
565
|
+
}, { rive: r, RiveComponent: l } = be(i), p = oe(/* @__PURE__ */ new Map()), { dispatchAction: _ } = e, k = B(() => {
|
|
566
|
+
if (!e.eventHandlers)
|
|
567
|
+
return;
|
|
568
|
+
const u = Object.entries(e.eventHandlers);
|
|
569
|
+
if (u.length === 0)
|
|
570
|
+
return;
|
|
571
|
+
const c = /* @__PURE__ */ new Map();
|
|
572
|
+
for (const [f, g] of u) {
|
|
573
|
+
const b = f.trim();
|
|
574
|
+
if (!b)
|
|
575
|
+
continue;
|
|
576
|
+
const d = g.trim();
|
|
577
|
+
d && c.set(b, d);
|
|
578
|
+
}
|
|
579
|
+
return c.size > 0 ? c : void 0;
|
|
580
|
+
}, [e.eventHandlers]), v = B(() => {
|
|
581
|
+
if (!e.keyboardBindings || e.keyboardBindings.length === 0)
|
|
582
|
+
return;
|
|
583
|
+
const u = /* @__PURE__ */ new Map();
|
|
584
|
+
for (const c of e.keyboardBindings) {
|
|
585
|
+
const f = u.get(c.key);
|
|
586
|
+
f ? f.push(c) : u.set(c.key, [c]);
|
|
587
|
+
}
|
|
588
|
+
return u;
|
|
589
|
+
}, [e.keyboardBindings]), E = oe(/* @__PURE__ */ new Set());
|
|
590
|
+
V(() => {
|
|
591
|
+
E.current.clear();
|
|
592
|
+
}, [v]), V(() => {
|
|
593
|
+
const u = r?.viewModelInstance;
|
|
594
|
+
if (!u)
|
|
595
|
+
return;
|
|
596
|
+
const c = e.viewModel?.booleans;
|
|
597
|
+
if (c)
|
|
598
|
+
for (const [b, d] of Object.entries(c)) {
|
|
599
|
+
const h = u.boolean(b);
|
|
600
|
+
h && (h.value = d);
|
|
601
|
+
}
|
|
602
|
+
const f = e.viewModel?.numbers;
|
|
603
|
+
if (f)
|
|
604
|
+
for (const [b, d] of Object.entries(f)) {
|
|
605
|
+
const h = u.number(b);
|
|
606
|
+
h && (h.value = d);
|
|
607
|
+
}
|
|
608
|
+
const g = e.viewModel?.strings;
|
|
609
|
+
if (g)
|
|
610
|
+
for (const [b, d] of Object.entries(g)) {
|
|
611
|
+
const h = u.string(b);
|
|
612
|
+
h && (h.value = d);
|
|
613
|
+
}
|
|
614
|
+
}, [e.viewModel, r]), V(() => {
|
|
615
|
+
const u = r?.viewModelInstance;
|
|
616
|
+
if (!(!u || !e.triggerRequests))
|
|
617
|
+
for (const c of e.triggerRequests) {
|
|
618
|
+
const f = p.current.get(c.name);
|
|
619
|
+
if (f !== void 0 && c.sequence <= f)
|
|
620
|
+
continue;
|
|
621
|
+
p.current.set(c.name, c.sequence), u.trigger(c.name)?.trigger();
|
|
622
|
+
}
|
|
623
|
+
}, [e.triggerRequests, r]), V(() => {
|
|
624
|
+
if (!r || !k || !_)
|
|
625
|
+
return;
|
|
626
|
+
const u = (c) => {
|
|
627
|
+
if (c.type !== G.RiveEvent)
|
|
628
|
+
return;
|
|
629
|
+
const f = Pe(c.data);
|
|
630
|
+
if (!f)
|
|
631
|
+
return;
|
|
632
|
+
const g = k.get(f.name);
|
|
633
|
+
g && _(g, f);
|
|
634
|
+
};
|
|
635
|
+
return r.on?.(G.RiveEvent, u), () => {
|
|
636
|
+
r.off?.(G.RiveEvent, u);
|
|
637
|
+
};
|
|
638
|
+
}, [r, k, _]);
|
|
639
|
+
const j = Y(
|
|
640
|
+
(u) => {
|
|
641
|
+
v && u.currentTarget.focus();
|
|
642
|
+
},
|
|
643
|
+
[v]
|
|
644
|
+
), I = Y(
|
|
645
|
+
(u) => {
|
|
646
|
+
if (!v)
|
|
647
|
+
return;
|
|
648
|
+
const c = u.key, f = v.get(c);
|
|
649
|
+
if (!f || f.length === 0)
|
|
650
|
+
return;
|
|
651
|
+
if (E.current.has(c)) {
|
|
652
|
+
u.preventDefault();
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
const g = r?.viewModelInstance;
|
|
656
|
+
if (!g)
|
|
657
|
+
return;
|
|
658
|
+
let b = !1;
|
|
659
|
+
for (const d of f)
|
|
660
|
+
if (d.kind === "boolean") {
|
|
661
|
+
const h = g.boolean(d.input);
|
|
662
|
+
h && (h.value = !0, b = !0);
|
|
663
|
+
} else if (d.kind === "trigger") {
|
|
664
|
+
const h = g.trigger(d.input);
|
|
665
|
+
h && (h.trigger(), b = !0);
|
|
666
|
+
}
|
|
667
|
+
b && (E.current.add(c), u.preventDefault());
|
|
668
|
+
},
|
|
669
|
+
[v, r]
|
|
670
|
+
), L = Y(
|
|
671
|
+
(u) => {
|
|
672
|
+
if (!v)
|
|
673
|
+
return;
|
|
674
|
+
const c = u.key, f = v.get(c);
|
|
675
|
+
if (!f || f.length === 0)
|
|
676
|
+
return;
|
|
677
|
+
const g = r?.viewModelInstance;
|
|
678
|
+
if (!g) {
|
|
679
|
+
E.current.delete(c);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
E.current.delete(c);
|
|
683
|
+
let b = !1;
|
|
684
|
+
for (const d of f) {
|
|
685
|
+
if (d.kind !== "boolean")
|
|
686
|
+
continue;
|
|
687
|
+
const h = g.boolean(d.input);
|
|
688
|
+
h && (h.value = !1, b = !0);
|
|
689
|
+
}
|
|
690
|
+
b && u.preventDefault();
|
|
691
|
+
},
|
|
692
|
+
[v, r]
|
|
693
|
+
), M = Y(() => {
|
|
694
|
+
if (!v || v.size === 0) {
|
|
695
|
+
E.current.clear();
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
const u = r?.viewModelInstance, c = Array.from(E.current);
|
|
699
|
+
if (E.current.clear(), !!u)
|
|
700
|
+
for (const f of c) {
|
|
701
|
+
const g = v.get(f);
|
|
702
|
+
if (g)
|
|
703
|
+
for (const b of g) {
|
|
704
|
+
if (b.kind !== "boolean")
|
|
705
|
+
continue;
|
|
706
|
+
const d = u.boolean(b.input);
|
|
707
|
+
d && (d.value = !1);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}, [v, r]), P = {};
|
|
711
|
+
e.backgroundColor && (P.backgroundColor = e.backgroundColor), e.width && (P.width = e.width), e.height && (P.height = e.height);
|
|
712
|
+
const S = !!v;
|
|
713
|
+
return /* @__PURE__ */ X.jsx("div", { className: e.className, style: P, children: /* @__PURE__ */ X.jsx(
|
|
714
|
+
l,
|
|
715
|
+
{
|
|
716
|
+
style: { width: "100%", height: "100%", backgroundColor: "transparent" },
|
|
717
|
+
tabIndex: S ? 0 : void 0,
|
|
718
|
+
onPointerDown: S ? j : void 0,
|
|
719
|
+
onKeyDown: S ? I : void 0,
|
|
720
|
+
onKeyUp: S ? L : void 0,
|
|
721
|
+
onBlur: S ? M : void 0
|
|
722
|
+
}
|
|
723
|
+
) });
|
|
724
|
+
}
|
|
725
|
+
function Le() {
|
|
726
|
+
return (e) => {
|
|
727
|
+
if (e.type !== "rive-canvas")
|
|
728
|
+
return;
|
|
729
|
+
const n = w(e.props.src);
|
|
730
|
+
if (n)
|
|
731
|
+
return ({ node: o, context: a, className: i }) => {
|
|
732
|
+
const r = o ?? e, l = w(r.props.src) ?? n, p = Re(r.props.stateMachines), _ = x(r.props.autoplay), k = x(r.props.autoBind), v = x(r.props.useOffscreenRenderer), E = x(r.props.enableMultiTouch), j = x(r.props.dispatchPointerExit), I = x(r.props.isTouchScrollEnabled), L = x(r.props.shouldDisableRiveListeners), M = xe(r.props.keyboardBindings), P = we(r.props.layoutFit), S = Te(r.props.layoutAlignment), u = w(r.props.backgroundColor), c = ce(r.props.width), f = ce(r.props.height), g = Se(r.props.viewModel), b = Ce(r.props.triggerRequests), d = Ne(r.props.eventHandlers), h = ye(
|
|
733
|
+
r.styleIds,
|
|
734
|
+
i,
|
|
735
|
+
w(r.props.style)
|
|
736
|
+
);
|
|
737
|
+
return /* @__PURE__ */ X.jsx(
|
|
738
|
+
Fe,
|
|
739
|
+
{
|
|
740
|
+
src: l,
|
|
741
|
+
stateMachines: p,
|
|
742
|
+
autoplay: _,
|
|
743
|
+
autoBind: k,
|
|
744
|
+
useOffscreenRenderer: v,
|
|
745
|
+
enableMultiTouch: E,
|
|
746
|
+
dispatchPointerExit: j,
|
|
747
|
+
isTouchScrollEnabled: I,
|
|
748
|
+
shouldDisableRiveListeners: L,
|
|
749
|
+
keyboardBindings: M,
|
|
750
|
+
layoutFit: P,
|
|
751
|
+
layoutAlignment: S,
|
|
752
|
+
backgroundColor: u,
|
|
753
|
+
width: c,
|
|
754
|
+
height: f,
|
|
755
|
+
viewModel: g,
|
|
756
|
+
triggerRequests: b,
|
|
757
|
+
eventHandlers: d,
|
|
758
|
+
dispatchAction: a.dispatchAction,
|
|
759
|
+
className: h
|
|
760
|
+
}
|
|
761
|
+
);
|
|
762
|
+
};
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
const De = "rive";
|
|
766
|
+
function ze() {
|
|
767
|
+
return [Le()];
|
|
768
|
+
}
|
|
769
|
+
const Be = () => ze();
|
|
770
|
+
function qe(e) {
|
|
771
|
+
e.registerModule(De, Be);
|
|
772
|
+
}
|
|
773
|
+
export {
|
|
774
|
+
De as IKON_UI_RIVE_MODULE,
|
|
775
|
+
Le as createRiveCanvasResolver,
|
|
776
|
+
ze as createRiveResolvers,
|
|
777
|
+
Be as loadRiveModule,
|
|
778
|
+
qe as registerRiveModule
|
|
779
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ikonai/sdk-react-ui-rive",
|
|
3
|
+
"version": "0.0.11",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.js",
|
|
10
|
+
"types": "./index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@ikonai/sdk-react-ui": "*",
|
|
15
|
+
"@rive-app/canvas": "*",
|
|
16
|
+
"@rive-app/react-canvas": "*",
|
|
17
|
+
"react": "*",
|
|
18
|
+
"react-dom": "*"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/rive-module.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IkonUiComponentResolver, IkonUiModuleLoader, IkonUiRegistry } from '../../sdk-react-ui/src/index.ts';
|
|
2
|
+
export declare const IKON_UI_RIVE_MODULE = "rive";
|
|
3
|
+
export declare function createRiveResolvers(): IkonUiComponentResolver[];
|
|
4
|
+
export declare const loadRiveModule: IkonUiModuleLoader;
|
|
5
|
+
export declare function registerRiveModule(registry: IkonUiRegistry): void;
|