@pieai/swimmer-ui-kit 2.8.0 → 2.9.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.
@@ -0,0 +1,450 @@
1
+ import { useEffect as e, useState as t } from "react";
2
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ //#region src/liquidGooeyBudget.ts
4
+ var a = 2, o = 48e4, s = 2, c = o, l = 0;
5
+ function u(e, t) {
6
+ return Number.isFinite(e) ? Math.max(0, Math.floor(e)) : t;
7
+ }
8
+ function d() {
9
+ return {
10
+ maxAnimatedGroups: s,
11
+ maxFilterArea: c,
12
+ activeGroups: l
13
+ };
14
+ }
15
+ function f(e) {
16
+ if (typeof e == "number") {
17
+ s = u(e, 0);
18
+ return;
19
+ }
20
+ e.maxAnimatedGroups !== void 0 && (s = u(e.maxAnimatedGroups, 0)), e.maxFilterArea !== void 0 && (c = u(e.maxFilterArea, 0));
21
+ }
22
+ function p(e) {
23
+ return l >= s || (Number.isFinite(e) ? Math.max(0, e) : Infinity) > c ? !1 : (l += 1, !0);
24
+ }
25
+ function m() {
26
+ l > 0 && --l;
27
+ }
28
+ //#endregion
29
+ //#region src/liquidGooeyFilter.tsx
30
+ var h = "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 60 -29.5", g = 1.3, _ = 1 / .3902;
31
+ function v(e, t) {
32
+ return e <= 0 ? t : Math.min(t, _ * e / g);
33
+ }
34
+ var y = {
35
+ waviness: 0,
36
+ wavinessFreq: .018
37
+ };
38
+ function b(e) {
39
+ return e.spread === 0 ? "shape" : "bin";
40
+ }
41
+ function x(e, t) {
42
+ return t !== null || e.some((e) => e.spread !== 0);
43
+ }
44
+ function S({ index: e, shadow: t }) {
45
+ let i = [], a = b(t), o = a;
46
+ return t.spread !== 0 && (i.push(/* @__PURE__ */ r("feMorphology", {
47
+ in: o,
48
+ operator: t.spread > 0 ? "erode" : "dilate",
49
+ radius: Math.abs(t.spread),
50
+ result: `shadow-${e}-erode`
51
+ }, "erode")), o = `shadow-${e}-erode`), (t.x !== 0 || t.y !== 0) && (i.push(/* @__PURE__ */ r("feOffset", {
52
+ in: o,
53
+ dx: t.x,
54
+ dy: t.y,
55
+ result: `shadow-${e}-offset`
56
+ }, "offset")), o = `shadow-${e}-offset`), t.blur > 0 && (i.push(/* @__PURE__ */ r("feGaussianBlur", {
57
+ in: o,
58
+ stdDeviation: t.blur / 2,
59
+ result: `shadow-${e}-blur`
60
+ }, "blur")), o = `shadow-${e}-blur`), i.push(/* @__PURE__ */ r("feComposite", {
61
+ in: a,
62
+ in2: o,
63
+ operator: "out",
64
+ result: `shadow-${e}-band`
65
+ }, "band"), /* @__PURE__ */ r("feFlood", {
66
+ floodColor: t.color,
67
+ result: `shadow-${e}-color`
68
+ }, "color"), /* @__PURE__ */ r("feComposite", {
69
+ in: `shadow-${e}-color`,
70
+ in2: `shadow-${e}-band`,
71
+ operator: "in",
72
+ result: `shadow-${e}`
73
+ }, "fill")), /* @__PURE__ */ r(n, { children: i });
74
+ }
75
+ function C({ index: e, shadow: t }) {
76
+ let i = [], a = "shape";
77
+ return t.spread !== 0 && (i.push(/* @__PURE__ */ r("feMorphology", {
78
+ in: "bin",
79
+ operator: t.spread > 0 ? "dilate" : "erode",
80
+ radius: Math.abs(t.spread),
81
+ result: `shadow-${e}-spread`
82
+ }, "spread")), a = `shadow-${e}-spread`), t.blur > 0 && (i.push(/* @__PURE__ */ r("feGaussianBlur", {
83
+ in: a,
84
+ stdDeviation: t.blur / 2,
85
+ result: `shadow-${e}-blur`
86
+ }, "blur")), a = `shadow-${e}-blur`), (t.x !== 0 || t.y !== 0) && (i.push(/* @__PURE__ */ r("feOffset", {
87
+ in: a,
88
+ dx: t.x,
89
+ dy: t.y,
90
+ result: `shadow-${e}-offset`
91
+ }, "offset")), a = `shadow-${e}-offset`), i.push(/* @__PURE__ */ r("feFlood", {
92
+ floodColor: t.color,
93
+ result: `shadow-${e}-color`
94
+ }, "color"), /* @__PURE__ */ r("feComposite", {
95
+ in: `shadow-${e}-color`,
96
+ in2: a,
97
+ operator: "in",
98
+ result: `shadow-${e}`
99
+ }, "fill")), /* @__PURE__ */ r(n, { children: i });
100
+ }
101
+ function w({ stroke: e }) {
102
+ let t = [];
103
+ return t.push(/* @__PURE__ */ r("feMorphology", {
104
+ in: "bin",
105
+ operator: "erode",
106
+ radius: e.width,
107
+ result: "stroke-erode"
108
+ }, "erode"), /* @__PURE__ */ r("feComposite", {
109
+ in: "bin",
110
+ in2: "stroke-erode",
111
+ operator: "out",
112
+ result: "stroke-band"
113
+ }, "band"), /* @__PURE__ */ r("feFlood", {
114
+ floodColor: e.color,
115
+ result: "stroke-color"
116
+ }, "color"), /* @__PURE__ */ r("feComposite", {
117
+ in: "stroke-color",
118
+ in2: "stroke-band",
119
+ operator: "in",
120
+ result: "stroke-out"
121
+ }, "fill")), /* @__PURE__ */ r(n, { children: t });
122
+ }
123
+ function T({ blur: e, contrast: t, shadows: a, stroke: o, gloss: s = 0, waviness: c = y.waviness, wavinessFreq: l = y.wavinessFreq }) {
124
+ let u = v(e, t), d = Math.round((.5 - 5 / 12 * u) * 100) / 100, f = c > 0;
125
+ return /* @__PURE__ */ i(n, { children: [
126
+ /* @__PURE__ */ r("feGaussianBlur", {
127
+ in: "SourceGraphic",
128
+ stdDeviation: e,
129
+ result: "blur"
130
+ }),
131
+ /* @__PURE__ */ r("feColorMatrix", {
132
+ in: "blur",
133
+ type: "matrix",
134
+ values: `1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${u} ${d}`,
135
+ result: "goo"
136
+ }),
137
+ /* @__PURE__ */ r("feComposite", {
138
+ in: "SourceGraphic",
139
+ in2: "goo",
140
+ operator: "atop",
141
+ result: f ? "shape-raw" : "shape"
142
+ }),
143
+ f ? /* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r("feTurbulence", {
144
+ type: "fractalNoise",
145
+ baseFrequency: l,
146
+ numOctaves: 1,
147
+ seed: "7",
148
+ result: "wave-noise"
149
+ }), /* @__PURE__ */ r("feDisplacementMap", {
150
+ in: "shape-raw",
151
+ in2: "wave-noise",
152
+ scale: c * 2,
153
+ xChannelSelector: "R",
154
+ yChannelSelector: "G",
155
+ result: "shape"
156
+ })] }) : null,
157
+ s > 0 ? /* @__PURE__ */ i(n, { children: [
158
+ /* @__PURE__ */ r("feGaussianBlur", {
159
+ in: "shape",
160
+ stdDeviation: 2.5,
161
+ result: "gloss-bump"
162
+ }),
163
+ /* @__PURE__ */ r("feSpecularLighting", {
164
+ in: "gloss-bump",
165
+ surfaceScale: s,
166
+ specularConstant: .78,
167
+ specularExponent: 20,
168
+ lightingColor: "#ffffff",
169
+ result: "gloss-light",
170
+ children: /* @__PURE__ */ r("feDistantLight", {
171
+ azimuth: 235,
172
+ elevation: 22
173
+ })
174
+ }),
175
+ /* @__PURE__ */ r("feComposite", {
176
+ in: "gloss-light",
177
+ in2: "shape",
178
+ operator: "in",
179
+ result: "gloss-clip"
180
+ }),
181
+ /* @__PURE__ */ r("feComposite", {
182
+ in: "shape",
183
+ in2: "gloss-clip",
184
+ operator: "arithmetic",
185
+ k1: "0",
186
+ k2: "1",
187
+ k3: "1",
188
+ k4: "0",
189
+ result: "shape"
190
+ })
191
+ ] }) : null,
192
+ x(a, o) ? /* @__PURE__ */ r("feColorMatrix", {
193
+ in: "shape",
194
+ type: "matrix",
195
+ values: h,
196
+ result: "bin"
197
+ }) : null,
198
+ a.map((e, t) => e.inset ? /* @__PURE__ */ r(S, {
199
+ index: t,
200
+ shadow: e
201
+ }, t) : /* @__PURE__ */ r(C, {
202
+ index: t,
203
+ shadow: e
204
+ }, t)),
205
+ o ? /* @__PURE__ */ r(w, { stroke: o }) : null,
206
+ a.length > 0 || o ? /* @__PURE__ */ i("feMerge", { children: [
207
+ a.map((e, t) => e.inset ? -1 : t).filter((e) => e >= 0).reverse().map((e) => /* @__PURE__ */ r("feMergeNode", { in: `shadow-${e}` }, e)),
208
+ /* @__PURE__ */ r("feMergeNode", { in: "shape" }),
209
+ o ? /* @__PURE__ */ r("feMergeNode", { in: "stroke-out" }) : null,
210
+ a.map((e, t) => e.inset ? /* @__PURE__ */ r("feMergeNode", { in: `shadow-${t}` }, t) : null)
211
+ ] }) : null
212
+ ] });
213
+ }
214
+ //#endregion
215
+ //#region src/liquidGooeyGeometry.ts
216
+ function E(e, t) {
217
+ let n = 0, r = 0, i = e;
218
+ for (; i && i !== t && t.contains(i);) n += i.offsetLeft, r += i.offsetTop, i = i.offsetParent;
219
+ return {
220
+ x: n,
221
+ y: r
222
+ };
223
+ }
224
+ function D(e, t, n) {
225
+ let r = getComputedStyle(e), i = (e) => {
226
+ let r = e.split(" ")[0] ?? "";
227
+ return r.endsWith("%") ? (parseFloat(r) || 0) / 100 * Math.min(t, n) : parseFloat(r) || 0;
228
+ };
229
+ return [
230
+ i(r.borderTopLeftRadius),
231
+ i(r.borderTopRightRadius),
232
+ i(r.borderBottomRightRadius),
233
+ i(r.borderBottomLeftRadius)
234
+ ];
235
+ }
236
+ function O(e) {
237
+ return typeof e == "number" ? [
238
+ e,
239
+ e,
240
+ e,
241
+ e
242
+ ] : e;
243
+ }
244
+ function k(e, t, n, r, i) {
245
+ let [a, o, s, c] = i.map((e) => Math.max(0, e)), l = Math.min(1, n / Math.max(1e-6, a + o), n / Math.max(1e-6, c + s), r / Math.max(1e-6, a + c), r / Math.max(1e-6, o + s));
246
+ return a *= l, o *= l, s *= l, c *= l, `M ${e + a} ${t} H ${e + n - o} A ${o} ${o} 0 0 1 ${e + n} ${t + o} V ${t + r - s} A ${s} ${s} 0 0 1 ${e + n - s} ${t + r} H ${e + c} A ${c} ${c} 0 0 1 ${e} ${t + r - c} V ${t + a} A ${a} ${a} 0 0 1 ${e + a} ${t} Z`;
247
+ }
248
+ var A = 44;
249
+ function j(e) {
250
+ let t = e + 1831565813 >>> 0;
251
+ return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
252
+ }
253
+ function M(e, t, n, r) {
254
+ let i = Math.max(0, e - 2 * n), a = Math.max(0, t - 2 * n), o = Math.PI / 2 * n, s = [
255
+ i,
256
+ o,
257
+ a,
258
+ o,
259
+ i,
260
+ o,
261
+ a,
262
+ o
263
+ ], c = r * (s.reduce((e, t) => e + t, 0) || 1), l = 0;
264
+ for (; l < s.length - 1 && c > s[l];) c -= s[l], l += 1;
265
+ let u = s[l], d = u === 0 ? 0 : c / u, f = (e, t, r) => {
266
+ let i = e + Math.PI / 2 * d;
267
+ return {
268
+ x: t + n * Math.cos(i),
269
+ y: r + n * Math.sin(i),
270
+ nx: Math.cos(i),
271
+ ny: Math.sin(i)
272
+ };
273
+ };
274
+ switch (l) {
275
+ case 0: return {
276
+ x: n + d * i,
277
+ y: 0,
278
+ nx: 0,
279
+ ny: -1
280
+ };
281
+ case 1: return f(-Math.PI / 2, e - n, n);
282
+ case 2: return {
283
+ x: e,
284
+ y: n + d * a,
285
+ nx: 1,
286
+ ny: 0
287
+ };
288
+ case 3: return f(0, e - n, t - n);
289
+ case 4: return {
290
+ x: e - n - d * i,
291
+ y: t,
292
+ nx: 0,
293
+ ny: 1
294
+ };
295
+ case 5: return f(Math.PI / 2, n, t - n);
296
+ case 6: return {
297
+ x: 0,
298
+ y: t - n - d * a,
299
+ nx: -1,
300
+ ny: 0
301
+ };
302
+ default: return f(Math.PI, n, n);
303
+ }
304
+ }
305
+ var N = .18;
306
+ function P(e, t, n, r, i, a) {
307
+ let o = Math.min(n, r), s = Math.min(Math.max(0, a.amplitude), o * N);
308
+ if (s < .15 || o <= 0) return k(e, t, n, r, i);
309
+ let c = Math.min(Math.max(...i, 0), o / 2), l = a.seed ?? 7, u = Math.max(2, Math.round(a.lobes ?? 3)), d = a.phase ?? 0, f = [];
310
+ for (let e = 0; e < u; e += 1) f.push({
311
+ k: e + 2,
312
+ a: j(l * 31 + e) * .6 + .4,
313
+ p: j(l * 57 + e) * Math.PI * 2
314
+ });
315
+ let p = f.reduce((e, t) => e + t.a, 0) || 1, m = [];
316
+ for (let i = 0; i < A; i += 1) {
317
+ let a = i / A, o = M(n, r, c, a), l = 0;
318
+ for (let { k: e, a: t, p: n } of f) l += t * Math.sin(2 * Math.PI * e * a + n + d);
319
+ let u = (l / p + 1) / 2 * s;
320
+ m.push([e + o.x + o.nx * u, t + o.y + o.ny * u]);
321
+ }
322
+ let h = m.length, g = (e) => m[(e % h + h) % h], _ = (e) => (Math.round(e * 100) / 100).toString(), v = `M ${_(g(0)[0])} ${_(g(0)[1])}`;
323
+ for (let e = 0; e < h; e += 1) {
324
+ let t = g(e - 1), n = g(e), r = g(e + 1), i = g(e + 2), a = n[0] + (r[0] - t[0]) / 6, o = n[1] + (r[1] - t[1]) / 6, s = r[0] - (i[0] - n[0]) / 6, c = r[1] - (i[1] - n[1]) / 6;
325
+ v += ` C ${_(a)} ${_(o)} ${_(s)} ${_(c)} ${_(r[0])} ${_(r[1])}`;
326
+ }
327
+ return `${v} Z`;
328
+ }
329
+ function F(e, t, n, r, i, a) {
330
+ return !a || a.amplitude <= 0 ? k(e, t, n, r, i) : P(e, t, n, r, i, a);
331
+ }
332
+ //#endregion
333
+ //#region src/liquidGooeySpring.ts
334
+ var I = {
335
+ snappy: {
336
+ stiffness: 480,
337
+ damping: 34,
338
+ mass: 1
339
+ },
340
+ smooth: {
341
+ stiffness: 190,
342
+ damping: 26,
343
+ mass: 1
344
+ },
345
+ bouncy: {
346
+ stiffness: 320,
347
+ damping: 17,
348
+ mass: 1
349
+ },
350
+ wobbly: {
351
+ stiffness: 400,
352
+ damping: 9.6,
353
+ mass: 1
354
+ }
355
+ }, L = 1 / 240;
356
+ function R(e) {
357
+ let t = 0, n = 0, r = 0, i = -1, a = 0, o = [0];
358
+ for (; r < 10;) {
359
+ let s = (-e.stiffness * (t - 1) - e.damping * n) / e.mass;
360
+ if (n += s * L, t += n * L, r += L, o.push(t), t > a && (a = t), Math.abs(t - 1) < .001 && Math.abs(n) < .02) {
361
+ if (i < 0 && (i = r), r - i >= .064) break;
362
+ } else i = -1;
363
+ }
364
+ let s = i > 0 ? i : r, c = Math.round(Math.min(120, Math.max(24, s * 90))), l = Math.min(o.length - 1, s / L), u = [];
365
+ for (let e = 0; e <= c; e += 1) {
366
+ let t = Math.min(o.length - 1, Math.round(e / c * l));
367
+ u.push(Math.round((o[t] ?? 1) * 1e4) / 1e4);
368
+ }
369
+ return u[u.length - 1] = 1, {
370
+ duration: s,
371
+ values: u,
372
+ overshoots: a > 1.001
373
+ };
374
+ }
375
+ var z = null;
376
+ function B() {
377
+ return z === null && (z = typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("transition-timing-function", "linear(0, 1)")), z;
378
+ }
379
+ var V = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map();
380
+ function U(e) {
381
+ let t = H.get(e);
382
+ if (t) return t;
383
+ let n = /^linear\(([^)]+)\)$/.exec(e.trim()), r = /^cubic-bezier\(([^)]+)\)$/.exec(e.trim()), i;
384
+ if (n) {
385
+ let e = (n[1] ?? "").split(",").map(Number);
386
+ i = (t) => {
387
+ if (t <= 0) return e[0] ?? 0;
388
+ if (t >= 1) return e[e.length - 1] ?? 1;
389
+ let n = t * (e.length - 1), r = Math.floor(n), i = e[r] ?? 0;
390
+ return i + ((e[r + 1] ?? i) - i) * (n - r);
391
+ };
392
+ } else if (r) {
393
+ let [e = 0, t = 0, n = 1, a = 1] = (r[1] ?? "").split(",").map(Number);
394
+ i = (r) => {
395
+ if (r <= 0) return 0;
396
+ if (r >= 1) return 1;
397
+ let i = 0, o = 1;
398
+ for (let t = 0; t < 24; t += 1) {
399
+ let t = (i + o) / 2;
400
+ 3 * t * (1 - t) * (1 - t) * e + 3 * t * t * (1 - t) * n + t ** 3 < r ? i = t : o = t;
401
+ }
402
+ let s = (i + o) / 2;
403
+ return 3 * s * (1 - s) * (1 - s) * t + 3 * s * s * (1 - s) * a + s ** 3;
404
+ };
405
+ } else i = e === "ease" ? U("cubic-bezier(0.25, 0.1, 0.25, 1)") : e === "ease-in" ? U("cubic-bezier(0.42, 0, 1, 1)") : e === "ease-out" ? U("cubic-bezier(0, 0, 0.58, 1)") : e === "ease-in-out" ? U("cubic-bezier(0.42, 0, 0.58, 1)") : (e) => Math.min(1, Math.max(0, e));
406
+ return H.set(e, i), i;
407
+ }
408
+ function W(e, t = !1) {
409
+ if (t) return {
410
+ duration: 0,
411
+ easing: "linear"
412
+ };
413
+ let n = e ?? "smooth";
414
+ if (typeof n == "object" && "duration" in n) return {
415
+ duration: Math.max(0, n.duration),
416
+ easing: n.ease ?? "cubic-bezier(0.22, 1, 0.36, 1)"
417
+ };
418
+ let r = typeof n == "string" ? I[n] : {
419
+ stiffness: 300,
420
+ damping: 24,
421
+ mass: 1,
422
+ ...n
423
+ }, i = `${r.stiffness}/${r.damping}/${r.mass}/${B()}`, a = V.get(i);
424
+ if (!a) {
425
+ let e = R(r);
426
+ a = {
427
+ duration: Math.round(e.duration * 1e3),
428
+ easing: B() ? `linear(${e.values.join(", ")})` : e.overshoots ? "cubic-bezier(0.34, 1.56, 0.64, 1)" : "cubic-bezier(0.22, 1, 0.36, 1)"
429
+ }, V.set(i, a);
430
+ }
431
+ return a;
432
+ }
433
+ //#endregion
434
+ //#region src/reducedMotion.ts
435
+ function G() {
436
+ return typeof window > "u" || typeof window.matchMedia != "function" ? null : window.matchMedia("(prefers-reduced-motion: reduce)");
437
+ }
438
+ function K(e, t) {
439
+ let n = e;
440
+ return typeof e.addEventListener == "function" ? (e.addEventListener("change", t), () => e.removeEventListener("change", t)) : typeof n.addListener == "function" ? (n.addListener(t), () => n.removeListener?.(t)) : () => {};
441
+ }
442
+ function q() {
443
+ let [n, r] = t(() => G()?.matches ?? !1);
444
+ return e(() => {
445
+ let e = G();
446
+ if (e) return r(e.matches), K(e, (e) => r(e.matches));
447
+ }, []), n;
448
+ }
449
+ //#endregion
450
+ export { p as _, D as a, k as c, T as d, a as f, f as g, m as h, P as i, F as l, d as m, U as n, O as o, o as p, W as r, E as s, q as t, y as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pieai/swimmer-ui-kit",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "Token-driven React game UI kit for web and wrapped PieAI game surfaces.",
5
5
  "keywords": [
6
6
  "design-system",
@@ -42,6 +42,11 @@
42
42
  "types": "./dist/index.d.ts",
43
43
  "default": "./dist/index.js"
44
44
  },
45
+ "./liquid-presence": {
46
+ "types": "./dist/liquid-presence.d.ts",
47
+ "default": "./dist/liquid-presence.js"
48
+ },
49
+ "./liquid-presence.css": "./dist/liquid-presence.css",
45
50
  "./assets/*": "./dist/assets/*",
46
51
  "./styles.css": "./dist/styles.css",
47
52
  "./preview.css": "./dist/preview.css",