@liiift-studio/threadtext 0.0.1 → 0.1.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/README.md +24 -16
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +34 -20
- package/dist/index.js +435 -348
- package/dist/threadtext.webflow.min.js +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,439 +1,526 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { jsx as
|
|
3
|
-
const
|
|
4
|
-
/** Base canvas:
|
|
1
|
+
import { useRef as vt, useLayoutEffect as Te, useEffect as ee, forwardRef as Ae, useCallback as Ee } from "react";
|
|
2
|
+
import { jsx as Se } from "react/jsx-runtime";
|
|
3
|
+
const Dt = {
|
|
4
|
+
/** Base canvas: the baked satin stitches (transparent ground). */
|
|
5
5
|
bg: "tt-bg",
|
|
6
6
|
/** Overlay canvas: cursor sheen (`mix-blend-mode: screen`). */
|
|
7
|
-
fx: "tt-fx"
|
|
7
|
+
fx: "tt-fx",
|
|
8
|
+
/** Blinking text caret shown in editable mode. */
|
|
9
|
+
caret: "tt-caret"
|
|
8
10
|
};
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
return
|
|
11
|
+
function H(h, e) {
|
|
12
|
+
let n = Math.imul(h | 0, 374761393) + Math.imul(e | 0, 668265263) | 0;
|
|
13
|
+
return n = Math.imul(n ^ n >>> 13, 1274126177), ((n ^ n >>> 16) >>> 0) / 4294967295;
|
|
12
14
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
return S + (
|
|
15
|
+
function ne(h, e) {
|
|
16
|
+
const n = Math.floor(h), r = Math.floor(e), i = h - n, a = e - r, u = i * i * (3 - 2 * i), b = a * a * (3 - 2 * a), S = H(n, r), A = H(n + 1, r), c = H(n, r + 1), m = H(n + 1, r + 1);
|
|
17
|
+
return S + (A - S) * u + (c - S) * b + (S - A - c + m) * u * b;
|
|
16
18
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
for (let
|
|
22
|
-
let
|
|
23
|
-
for (;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
for (let
|
|
29
|
-
for (;
|
|
30
|
-
|
|
19
|
+
const Tt = 1e20;
|
|
20
|
+
function oe(h, e, n, r, i) {
|
|
21
|
+
let a = 0;
|
|
22
|
+
r[0] = 0, i[0] = -Tt, i[1] = Tt;
|
|
23
|
+
for (let u = 1; u < e; u++) {
|
|
24
|
+
let b = (h[u] + u * u - (h[r[a]] + r[a] * r[a])) / (2 * u - 2 * r[a]);
|
|
25
|
+
for (; b <= i[a]; )
|
|
26
|
+
a--, b = (h[u] + u * u - (h[r[a]] + r[a] * r[a])) / (2 * u - 2 * r[a]);
|
|
27
|
+
a++, r[a] = u, i[a] = b, i[a + 1] = Tt;
|
|
28
|
+
}
|
|
29
|
+
a = 0;
|
|
30
|
+
for (let u = 0; u < e; u++) {
|
|
31
|
+
for (; i[a + 1] < u; ) a++;
|
|
32
|
+
n[u] = (u - r[a]) * (u - r[a]) + h[r[a]];
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
for (let
|
|
36
|
-
const
|
|
37
|
-
for (let
|
|
38
|
-
for (let
|
|
39
|
-
|
|
40
|
-
for (let
|
|
41
|
-
}
|
|
42
|
-
for (let
|
|
43
|
-
for (let
|
|
44
|
-
|
|
45
|
-
for (let
|
|
46
|
-
}
|
|
47
|
-
const
|
|
48
|
-
for (let
|
|
49
|
-
return
|
|
35
|
+
function Fe(h, e, n) {
|
|
36
|
+
const r = new Float64Array(e * n);
|
|
37
|
+
for (let c = 0; c < e * n; c++) r[c] = h[c] ? Tt : 0;
|
|
38
|
+
const i = Math.max(e, n), a = new Float64Array(i), u = new Float64Array(i), b = new Int32Array(i), S = new Float64Array(i + 1);
|
|
39
|
+
for (let c = 0; c < e; c++) {
|
|
40
|
+
for (let m = 0; m < n; m++) a[m] = r[m * e + c];
|
|
41
|
+
oe(a, n, u, b, S);
|
|
42
|
+
for (let m = 0; m < n; m++) r[m * e + c] = u[m];
|
|
43
|
+
}
|
|
44
|
+
for (let c = 0; c < n; c++) {
|
|
45
|
+
for (let m = 0; m < e; m++) a[m] = r[c * e + m];
|
|
46
|
+
oe(a, e, u, b, S);
|
|
47
|
+
for (let m = 0; m < e; m++) r[c * e + m] = u[m];
|
|
48
|
+
}
|
|
49
|
+
const A = new Float32Array(e * n);
|
|
50
|
+
for (let c = 0; c < e * n; c++) A[c] = Math.sqrt(r[c]);
|
|
51
|
+
return A;
|
|
50
52
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
53
|
-
const
|
|
54
|
-
for (let
|
|
55
|
-
for (let
|
|
56
|
-
const
|
|
57
|
-
let
|
|
58
|
-
for (let
|
|
59
|
-
for (let
|
|
60
|
-
|
|
53
|
+
function re(h, e, n, r, i) {
|
|
54
|
+
let a = Float32Array.from(h);
|
|
55
|
+
const u = new Float32Array(e * n), b = 1 / (2 * r + 1), S = (A, c) => A < 0 ? 0 : A > c ? c : A;
|
|
56
|
+
for (let A = 0; A < i; A++) {
|
|
57
|
+
for (let c = 0; c < n; c++) {
|
|
58
|
+
const m = c * e;
|
|
59
|
+
let I = 0;
|
|
60
|
+
for (let O = -r; O <= r; O++) I += a[m + S(O, e - 1)];
|
|
61
|
+
for (let O = 0; O < e; O++)
|
|
62
|
+
u[m + O] = I * b, I += a[m + S(O + r + 1, e - 1)] - a[m + S(O - r, e - 1)];
|
|
61
63
|
}
|
|
62
|
-
for (let
|
|
63
|
-
let
|
|
64
|
-
for (let
|
|
65
|
-
for (let
|
|
66
|
-
|
|
64
|
+
for (let c = 0; c < e; c++) {
|
|
65
|
+
let m = 0;
|
|
66
|
+
for (let I = -r; I <= r; I++) m += u[S(I, n - 1) * e + c];
|
|
67
|
+
for (let I = 0; I < n; I++)
|
|
68
|
+
a[I * e + c] = m * b, m += u[S(I + r + 1, n - 1) * e + c] - u[S(I - r, n - 1) * e + c];
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
|
-
return
|
|
71
|
+
return a;
|
|
70
72
|
}
|
|
71
|
-
function
|
|
72
|
-
if (!
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
let
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
if (!Number.isNaN(
|
|
73
|
+
function ie(h, e) {
|
|
74
|
+
if (!h) return e;
|
|
75
|
+
const n = h.trim();
|
|
76
|
+
if (n[0] === "#") {
|
|
77
|
+
let i = n.slice(1);
|
|
78
|
+
if (i.length === 3 && (i = i[0] + i[0] + i[1] + i[1] + i[2] + i[2]), i.length >= 6) {
|
|
79
|
+
const a = parseInt(i.slice(0, 2), 16), u = parseInt(i.slice(2, 4), 16), b = parseInt(i.slice(4, 6), 16);
|
|
80
|
+
if (!Number.isNaN(a) && !Number.isNaN(u) && !Number.isNaN(b)) return [a, u, b];
|
|
79
81
|
}
|
|
80
|
-
return
|
|
82
|
+
return e;
|
|
81
83
|
}
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
return [Math.round(
|
|
84
|
+
const r = n.match(/rgba?\(([^)]+)\)/i);
|
|
85
|
+
if (r) {
|
|
86
|
+
const i = r[1].split(",").map((a) => parseFloat(a));
|
|
87
|
+
if (i.length >= 3 && i.slice(0, 3).every((a) => !Number.isNaN(a)))
|
|
88
|
+
return [Math.round(i[0]), Math.round(i[1]), Math.round(i[2])];
|
|
87
89
|
}
|
|
88
|
-
return
|
|
90
|
+
return e;
|
|
89
91
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
92
|
+
function K(h) {
|
|
93
|
+
return h < 0 ? 0 : h > 255 ? 255 : Math.round(h);
|
|
92
94
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
+
function bt(h, e, n) {
|
|
96
|
+
return h < e ? e : h > n ? n : h;
|
|
97
|
+
}
|
|
98
|
+
function ae(h) {
|
|
99
|
+
return (h.split(",")[0] || "serif").trim().replace(/^["']|["']$/g, "");
|
|
100
|
+
}
|
|
101
|
+
function Le(h, e) {
|
|
102
|
+
if (typeof window > "u" || typeof document > "u" || !h)
|
|
95
103
|
return { setText() {
|
|
96
104
|
}, replay() {
|
|
97
105
|
}, resize() {
|
|
106
|
+
}, update() {
|
|
107
|
+
}, focus() {
|
|
98
108
|
}, destroy() {
|
|
99
109
|
}, get text() {
|
|
100
|
-
return
|
|
110
|
+
return e.text ?? "";
|
|
101
111
|
} };
|
|
102
|
-
let
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
let n = e.text ?? "", r = e.font ?? "Georgia, serif", i = bt(e.weight ?? 680, 1, 1e3), a = bt(e.fill ?? 0.9, 0.05, 1), u = Math.max(1, e.sewRate ?? 110), b = e.sheen ?? !0, S = e.animate ?? !0, A = e.editable ?? !1, c = e.pitch, m = e.onTextChange, I = ae(r);
|
|
113
|
+
const O = e.reducedMotion ?? !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
114
|
+
let B = ie(e.threadColor ?? "#fffbf3", [255, 251, 243]), it = [0, 0, 0], D = [0, 0, 0];
|
|
115
|
+
function at(t) {
|
|
116
|
+
B = ie(t, [255, 251, 243]), it = [B[0] * 0.585, B[1] * 0.585, B[2] * 0.585], D = [B[0] * 0.47, B[1] * 0.47, B[2] * 0.47];
|
|
117
|
+
}
|
|
118
|
+
at(e.threadColor ?? "#fffbf3");
|
|
119
|
+
const U = [];
|
|
120
|
+
let k, R;
|
|
121
|
+
h instanceof HTMLCanvasElement ? (k = h, R = h.parentElement ?? h) : (R = h, k = document.createElement("canvas"), U.push(k), R.appendChild(k)), k.classList.add(Dt.bg);
|
|
122
|
+
const j = document.createElement("canvas");
|
|
123
|
+
U.push(j), j.classList.add(Dt.fx), R.appendChild(j), getComputedStyle(R).position === "static" && (R.style.position = "relative"), k.style.display = "block", k.style.width = "100%", Object.assign(j.style, { position: "absolute", inset: "0", width: "100%", pointerEvents: "none", mixBlendMode: "screen" });
|
|
124
|
+
let y = null, E = null, Q = !1, s = 0, x = 0, W = 0, At = 0, tt = 4, et = [], lt = 0, st = 0, jt = -1, zt = "", qt = -1, _t = -1, Et = new Uint8Array(0), St = new Float32Array(0), ht = new Float32Array(0), mt = new Float32Array(0), V = null, nt = null, xt = null, yt = [], gt = 3;
|
|
125
|
+
const $ = { rows: [], idx: 0, acc: 0, rate: 0, on: !1 }, X = { x: 0, y: 0, set: !1 };
|
|
126
|
+
let Z = !0, Ft = 0, ct = !1, ft = 0, z = !1, Y = !1;
|
|
127
|
+
function le() {
|
|
128
|
+
const t = R.getBoundingClientRect(), o = Math.max(1, Math.round(t.width || Math.min(window.innerWidth * 0.95, 1240))), l = n || "Ag", f = k.getContext("2d");
|
|
129
|
+
f && (f.textBaseline = "middle");
|
|
130
|
+
let T = 100;
|
|
131
|
+
f && (f.font = `${i} 100px ${r}`, T = f.measureText(l).width || 100);
|
|
132
|
+
const C = Math.max(8, 100 * (o * a) / T);
|
|
133
|
+
let v = C * 0.62, F = C * 0.62, P = o * a;
|
|
134
|
+
if (f) {
|
|
135
|
+
f.font = `${i} ${C}px ${r}`;
|
|
136
|
+
const w = f.measureText(l);
|
|
137
|
+
P = w.width || P, w.actualBoundingBoxAscent > 0 && (v = w.actualBoundingBoxAscent), w.actualBoundingBoxDescent > 0 && (F = w.actualBoundingBoxDescent);
|
|
138
|
+
}
|
|
139
|
+
const p = Math.max(1, Math.round(2 * Math.max(v, F) * 1.1));
|
|
113
140
|
let d = Math.min(window.devicePixelRatio || 1, 1.7);
|
|
114
|
-
for (;
|
|
115
|
-
|
|
116
|
-
for (const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
141
|
+
for (; o * d * p * d > 9e5 && d > 0.4; ) d -= 0.1;
|
|
142
|
+
s = Math.max(1, Math.round(o * d)), x = Math.max(1, Math.round(p * d)), W = Math.max(4, Math.round(C * d)), At = Math.round(s / 2 - P * d / 2);
|
|
143
|
+
for (const w of [k, j])
|
|
144
|
+
w.width = s, w.height = x, w.style.height = p + "px";
|
|
145
|
+
R.style.height = p + "px", tt = c ?? Math.max(3, x * 95e-4);
|
|
146
|
+
}
|
|
147
|
+
function se() {
|
|
148
|
+
nt && qt === s && _t === x || (nt = document.createElement("canvas"), nt.width = s, nt.height = x, xt = nt.getContext("2d", { willReadFrequently: !0 }), qt = s, _t = x);
|
|
149
|
+
}
|
|
150
|
+
function Gt() {
|
|
151
|
+
const t = Math.max(7, tt * 2.5), o = Math.max(3.2, tt * 1.3);
|
|
152
|
+
lt = Math.ceil(t) + 2, st = Math.ceil(o) + 2, et = [];
|
|
153
|
+
for (let l = 0; l < 20; l++) {
|
|
154
|
+
const f = 0.34 + l / 19 * 0.82, T = document.createElement("canvas");
|
|
155
|
+
T.width = lt, T.height = st;
|
|
156
|
+
const C = T.getContext("2d");
|
|
157
|
+
if (!C) {
|
|
158
|
+
et.push(T);
|
|
129
159
|
continue;
|
|
130
160
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
161
|
+
const v = lt / 2, F = st / 2, P = C.createLinearGradient(0, F - o / 2, 0, F + o / 2), p = (N, q) => `rgba(${K(N[0] * f)},${K(N[1] * f)},${K(N[2] * f)},${q})`;
|
|
162
|
+
P.addColorStop(0, p(D, 0)), P.addColorStop(0.16, p(it, 1)), P.addColorStop(0.5, p(B, 1)), P.addColorStop(0.84, p(it, 1)), P.addColorStop(1, p(D, 0)), C.fillStyle = P, C.beginPath();
|
|
163
|
+
const d = o / 2;
|
|
164
|
+
C.moveTo(v - t / 2 + d, F - d), C.lineTo(v + t / 2 - d, F - d), C.arc(v + t / 2 - d, F, d, -Math.PI / 2, Math.PI / 2), C.lineTo(v - t / 2 + d, F + d), C.arc(v - t / 2 + d, F, d, Math.PI / 2, -Math.PI / 2), C.closePath(), C.fill(), C.globalCompositeOperation = "destination-in";
|
|
165
|
+
const w = C.createLinearGradient(v - t / 2, 0, v + t / 2, 0);
|
|
166
|
+
w.addColorStop(0, "rgba(0,0,0,0)"), w.addColorStop(0.22, "rgba(0,0,0,1)"), w.addColorStop(0.78, "rgba(0,0,0,1)"), w.addColorStop(1, "rgba(0,0,0,0)"), C.fillStyle = w, C.fillRect(0, 0, lt, st), et.push(T);
|
|
137
167
|
}
|
|
168
|
+
jt = tt, zt = B.join(",");
|
|
169
|
+
}
|
|
170
|
+
function ce() {
|
|
171
|
+
et.length && jt === tt && zt === B.join(",") || Gt();
|
|
138
172
|
}
|
|
139
|
-
function
|
|
140
|
-
if (!
|
|
141
|
-
const t =
|
|
142
|
-
t.clearRect(0, 0,
|
|
143
|
-
const
|
|
144
|
-
for (let g = 0; g <
|
|
145
|
-
const
|
|
146
|
-
|
|
173
|
+
function fe() {
|
|
174
|
+
if (!xt) return;
|
|
175
|
+
const t = xt;
|
|
176
|
+
t.clearRect(0, 0, s, x), t.fillStyle = "#fff", t.textAlign = "left", t.textBaseline = "middle", t.font = `${i} ${W}px ${r}`, t.fillText(n, At, x * 0.5);
|
|
177
|
+
const o = t.getImageData(0, 0, s, x).data, l = new Uint8Array(s * x);
|
|
178
|
+
for (let g = 0; g < x; g++) for (let M = 0; M < s; M++) {
|
|
179
|
+
const L = g * s + M, _ = o[L * 4 + 3] / 255, G = ne(M * 0.5, g * 0.5) * 0.22 + ne(M * 1.8, g * 1.8) * 0.1;
|
|
180
|
+
l[L] = _ > 0.5 + (G - 0.16) ? 1 : 0;
|
|
147
181
|
}
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
for (let g = 1; g <
|
|
151
|
-
const
|
|
152
|
-
|
|
182
|
+
Et = l;
|
|
183
|
+
const f = Fe(l, s, x), T = new Float32Array(s * x);
|
|
184
|
+
for (let g = 1; g < x - 1; g++) for (let M = 1; M < s - 1; M++) {
|
|
185
|
+
const L = g * s + M;
|
|
186
|
+
T[L] = (f[L] * 4 + f[L - 1] + f[L + 1] + f[L - s] + f[L + s]) / 8;
|
|
153
187
|
}
|
|
154
|
-
const
|
|
155
|
-
for (let g = 1; g <
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
const
|
|
159
|
-
|
|
188
|
+
const C = new Float32Array(s * x), v = new Float32Array(s * x), F = new Float32Array(s * x), P = new Float32Array(s * x);
|
|
189
|
+
for (let g = 1; g < x - 1; g++) for (let M = 1; M < s - 1; M++) {
|
|
190
|
+
const L = g * s + M;
|
|
191
|
+
if (!l[L]) continue;
|
|
192
|
+
const _ = (T[L + 1] - T[L - 1]) * 0.5, G = (T[L + s] - T[L - s]) * 0.5;
|
|
193
|
+
F[L] = _, P[L] = G, C[L] = _ * _ - G * G, v[L] = 2 * _ * G;
|
|
160
194
|
}
|
|
161
|
-
const p = Math.max(7, Math.round(
|
|
162
|
-
|
|
163
|
-
for (let g = 0; g <
|
|
164
|
-
if (!
|
|
165
|
-
const
|
|
166
|
-
|
|
195
|
+
const p = Math.max(7, Math.round(x * 0.05)), d = re(C, s, x, p, 2), w = re(v, s, x, p, 2);
|
|
196
|
+
ht = new Float32Array(s * x), mt = new Float32Array(s * x);
|
|
197
|
+
for (let g = 0; g < s * x; g++) {
|
|
198
|
+
if (!l[g]) continue;
|
|
199
|
+
const M = 0.5 * Math.atan2(w[g], d[g]);
|
|
200
|
+
ht[g] = Math.cos(M), mt[g] = Math.sin(M);
|
|
167
201
|
}
|
|
168
|
-
const
|
|
169
|
-
for (let g = 1; g <
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
172
|
-
let
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
let
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
let
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
202
|
+
const N = Math.max(9, x * 0.04), q = new Float32Array(s * x), ut = -0.45, dt = -0.62, Ct = 0.64;
|
|
203
|
+
for (let g = 1; g < x - 1; g++) for (let M = 1; M < s - 1; M++) {
|
|
204
|
+
const L = g * s + M;
|
|
205
|
+
if (!l[L]) continue;
|
|
206
|
+
let _ = F[L], G = P[L];
|
|
207
|
+
const Zt = Math.hypot(_, G) || 1;
|
|
208
|
+
_ /= Zt, G /= Zt;
|
|
209
|
+
const Ht = T[L], Wt = (1 - Math.min(Ht / N, 1)) * 1.25;
|
|
210
|
+
let Bt = -_ * Wt, kt = -G * Wt;
|
|
211
|
+
const te = 1.5, Nt = Math.hypot(Bt, kt, te);
|
|
212
|
+
Bt /= Nt, kt /= Nt;
|
|
213
|
+
let Ot = Bt * ut + kt * dt + te / Nt * Ct;
|
|
214
|
+
Ot < 0 && (Ot = 0);
|
|
215
|
+
const be = Math.min(1, 0.45 + 0.55 * Math.min(Ht / (N * 0.7), 1));
|
|
216
|
+
q[L] = Math.min(1.12, (0.5 + 0.75 * Ot) * be);
|
|
183
217
|
}
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
for (let y = 0; y < e * i; y++) o[y] && (g.data[y * 4] = 255, g.data[y * 4 + 1] = 255, g.data[y * 4 + 2] = 255, g.data[y * 4 + 3] = 255, F.data[y * 4 + 3] = 255);
|
|
191
|
-
X.putImageData(g, 0, 0), W.putImageData(F, 0, 0);
|
|
218
|
+
St = q, V = document.createElement("canvas"), V.width = s, V.height = x;
|
|
219
|
+
const J = V.getContext("2d");
|
|
220
|
+
if (J) {
|
|
221
|
+
const g = J.createImageData(s, x);
|
|
222
|
+
for (let M = 0; M < s * x; M++) l[M] && (g.data[M * 4] = 255, g.data[M * 4 + 1] = 255, g.data[M * 4 + 2] = 255, g.data[M * 4 + 3] = 255);
|
|
223
|
+
J.putImageData(g, 0, 0);
|
|
192
224
|
}
|
|
193
225
|
}
|
|
194
|
-
function
|
|
195
|
-
V = document.createElement("canvas"), V.width = e, V.height = i;
|
|
196
|
-
const t = V.getContext("2d", { willReadFrequently: !0 });
|
|
197
|
-
if (t) {
|
|
198
|
-
const n = t.createRadialGradient(e * 0.5, i * 0.4, 0, e * 0.5, i * 0.5, e * 0.72);
|
|
199
|
-
n.addColorStop(0, j(wt)), n.addColorStop(1, j(Z)), t.fillStyle = n, t.fillRect(0, 0, e, i);
|
|
200
|
-
const o = t.getImageData(0, 0, e, i), d = o.data;
|
|
201
|
-
for (let m = 0; m < i; m++) for (let M = 0; M < e; M++) {
|
|
202
|
-
const C = (m * e + M) * 4, T = Math.sin(M * 1.9) * 0.5 + 0.5, R = Math.sin(m * 1.9) * 0.5 + 0.5, p = T * R * 9 - 4.5 + (Nt(M * 0.18, m * 0.18) - 0.5) * 15;
|
|
203
|
-
d[C] = D(d[C] + p), d[C + 1] = D(d[C + 1] + p), d[C + 2] = D(d[C + 2] + p * 1.1);
|
|
204
|
-
}
|
|
205
|
-
t.putImageData(o, 0, 0);
|
|
206
|
-
}
|
|
207
|
-
rt = document.createElement("canvas"), rt.width = e, rt.height = i, dt = rt.getContext("2d", { willReadFrequently: !0 });
|
|
208
|
-
}
|
|
209
|
-
function Ft() {
|
|
226
|
+
function ue() {
|
|
210
227
|
const t = Math.max(1.6, tt * 0.6);
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
for (let
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
if (!
|
|
218
|
-
const p = Math.atan2(
|
|
219
|
-
let
|
|
220
|
-
|
|
228
|
+
gt = t;
|
|
229
|
+
const o = [];
|
|
230
|
+
for (let l = 0; l < x; l += t) for (let f = 0; f < s; f += t) {
|
|
231
|
+
const T = (H(Math.floor(f), Math.floor(l)) - 0.5) * t * 0.9, C = (H(Math.floor(l), Math.floor(f)) - 0.5) * t * 0.9, v = Math.round(f + T), F = Math.round(l + C);
|
|
232
|
+
if (v < 1 || F < 1 || v >= s - 1 || F >= x - 1) continue;
|
|
233
|
+
const P = F * s + v;
|
|
234
|
+
if (!Et[P]) continue;
|
|
235
|
+
const p = Math.atan2(mt[P], ht[P]), d = 0.86 + H(v * 7, F * 13) * 0.18;
|
|
236
|
+
let w = St[P] * d;
|
|
237
|
+
w = w < 0 ? 0 : w > 1.12 ? 1.12 : w, o.push({ x: v, y: F, ang: p, idx: Math.min(19, Math.max(0, Math.round(w / 1.12 * 19))) });
|
|
221
238
|
}
|
|
222
|
-
|
|
239
|
+
yt = o;
|
|
223
240
|
}
|
|
224
|
-
function
|
|
225
|
-
t.save(), t.translate(
|
|
241
|
+
function Ut(t, o) {
|
|
242
|
+
t.save(), t.translate(o.x, o.y), t.rotate(o.ang), t.drawImage(et[o.idx], -lt / 2, -st / 2), t.restore();
|
|
226
243
|
}
|
|
227
|
-
function
|
|
228
|
-
const t =
|
|
244
|
+
function Lt() {
|
|
245
|
+
const t = k.getContext("2d");
|
|
229
246
|
if (t)
|
|
230
|
-
for (const
|
|
231
|
-
}
|
|
232
|
-
function _t() {
|
|
233
|
-
return k.length ? k[k.length - 1].x : 0;
|
|
247
|
+
for (const o of yt) Ut(t, o);
|
|
234
248
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
249
|
+
function Rt() {
|
|
250
|
+
const t = k.getContext("2d");
|
|
251
|
+
t && t.clearRect(0, 0, s, x);
|
|
237
252
|
}
|
|
238
|
-
function
|
|
239
|
-
const t = $.getContext("2d");
|
|
240
|
-
!t || !V || (t.drawImage(V, 0, 0), U && (t.save(), t.globalAlpha = 0.85, t.filter = `blur(${Math.round(i * 0.018)}px)`, t.drawImage(U, 0, Math.round(i * 0.02)), t.restore()));
|
|
241
|
-
}
|
|
242
|
-
function Wt(t) {
|
|
253
|
+
function de(t) {
|
|
243
254
|
if (!t.length) return [];
|
|
244
|
-
const
|
|
245
|
-
t.forEach((p,
|
|
246
|
-
const
|
|
247
|
-
let
|
|
248
|
-
|
|
255
|
+
const o = Math.max(4, gt * 1.5), l = /* @__PURE__ */ new Map(), f = (p, d) => p + "," + d;
|
|
256
|
+
t.forEach((p, d) => {
|
|
257
|
+
const w = f(Math.floor(p.x / o), Math.floor(p.y / o));
|
|
258
|
+
let N = l.get(w);
|
|
259
|
+
N || l.set(w, N = []), N.push(d);
|
|
249
260
|
});
|
|
250
|
-
const
|
|
251
|
-
function
|
|
252
|
-
const
|
|
253
|
-
for (let
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
256
|
-
for (const
|
|
257
|
-
if (
|
|
258
|
-
const
|
|
259
|
-
|
|
261
|
+
const T = gt * 1.8 * (gt * 1.8);
|
|
262
|
+
function C(p) {
|
|
263
|
+
const d = t[p], w = Math.floor(d.x / o), N = Math.floor(d.y / o), q = [];
|
|
264
|
+
for (let ut = -1; ut <= 1; ut++) for (let dt = -1; dt <= 1; dt++) {
|
|
265
|
+
const Ct = l.get(f(w + ut, N + dt));
|
|
266
|
+
if (Ct)
|
|
267
|
+
for (const J of Ct) {
|
|
268
|
+
if (J === p) continue;
|
|
269
|
+
const g = t[J].x - d.x, M = t[J].y - d.y;
|
|
270
|
+
g * g + M * M <= T && q.push(J);
|
|
260
271
|
}
|
|
261
272
|
}
|
|
262
|
-
return
|
|
273
|
+
return q;
|
|
263
274
|
}
|
|
264
|
-
const
|
|
265
|
-
for (const p of
|
|
266
|
-
if (
|
|
267
|
-
let
|
|
268
|
-
for (
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
for (const
|
|
272
|
-
|
|
275
|
+
const v = new Uint8Array(t.length), F = [], P = t.map((p, d) => d).sort((p, d) => t[p].x + t[p].y - (t[d].x + t[d].y));
|
|
276
|
+
for (const p of P) {
|
|
277
|
+
if (v[p]) continue;
|
|
278
|
+
let d = [p];
|
|
279
|
+
for (v[p] = 1; d.length; ) {
|
|
280
|
+
F.push(d.map((N) => t[N]));
|
|
281
|
+
const w = [];
|
|
282
|
+
for (const N of d) for (const q of C(N)) v[q] || (v[q] = 1, w.push(q));
|
|
283
|
+
d = w;
|
|
273
284
|
}
|
|
274
285
|
}
|
|
275
|
-
return
|
|
276
|
-
}
|
|
277
|
-
function
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (!o) return;
|
|
281
|
-
const d = [];
|
|
282
|
-
for (const m of k)
|
|
283
|
-
m.x <= t ? mt(o, m) : d.push(m);
|
|
284
|
-
if (f) {
|
|
285
|
-
for (const m of d) mt(o, m);
|
|
286
|
-
b.on = !1;
|
|
286
|
+
return F;
|
|
287
|
+
}
|
|
288
|
+
function he() {
|
|
289
|
+
if (Rt(), O || !S) {
|
|
290
|
+
Lt(), $.on = !1;
|
|
287
291
|
return;
|
|
288
292
|
}
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
function
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
for (t >
|
|
295
|
-
const
|
|
296
|
-
for (const
|
|
293
|
+
$.rows = de(yt), $.idx = 0, $.acc = 0, $.rate = u, $.on = $.rows.length > 0;
|
|
294
|
+
}
|
|
295
|
+
function me(t) {
|
|
296
|
+
const o = k.getContext("2d");
|
|
297
|
+
if (o)
|
|
298
|
+
for (t > $.rows.length && (t = $.rows.length); $.idx < t; ) {
|
|
299
|
+
const l = $.rows[$.idx++];
|
|
300
|
+
for (const f of l) Ut(o, f);
|
|
297
301
|
}
|
|
298
302
|
}
|
|
299
|
-
function
|
|
300
|
-
const
|
|
301
|
-
if (!
|
|
302
|
-
const
|
|
303
|
-
|
|
303
|
+
function xe(t, o) {
|
|
304
|
+
const l = j.getContext("2d");
|
|
305
|
+
if (!l || (l.clearRect(0, 0, s, x), !b || !V)) return;
|
|
306
|
+
const f = s * 0.32, T = l.createRadialGradient(t, o, 0, t, o, f);
|
|
307
|
+
T.addColorStop(0, "rgba(255,250,238,0.18)"), T.addColorStop(0.5, "rgba(255,250,238,0.055)"), T.addColorStop(1, "rgba(255,250,238,0)"), l.fillStyle = T, l.fillRect(0, 0, s, x), l.globalCompositeOperation = "destination-in", l.drawImage(V, 0, 0), l.globalCompositeOperation = "source-over";
|
|
308
|
+
}
|
|
309
|
+
function ye() {
|
|
310
|
+
E || !A || (E = document.createElement("span"), E.className = Dt.caret, E.setAttribute("aria-hidden", "true"), Object.assign(E.style, { position: "absolute", pointerEvents: "none", borderRadius: "1px", opacity: "0", background: `rgb(${K(B[0])},${K(B[1])},${K(B[2])})` }), R.appendChild(E), U.push(E));
|
|
311
|
+
}
|
|
312
|
+
function $t() {
|
|
313
|
+
if (!A || !E) return;
|
|
314
|
+
const t = k.getContext("2d");
|
|
315
|
+
if (!t) return;
|
|
316
|
+
t.font = `${i} ${W}px ${r}`;
|
|
317
|
+
const o = t.measureText(n).width, l = (k.clientWidth || s) / s, f = W * 0.7;
|
|
318
|
+
E.style.left = (At + o + W * 0.05) * l + "px", E.style.top = 0.5 * (k.clientHeight || x) - f * l / 2 + "px", E.style.height = f * l + "px", E.style.width = Math.max(2, Math.round(W * 0.02 * l)) + "px", E.style.background = `rgb(${K(B[0])},${K(B[1])},${K(B[2])})`;
|
|
304
319
|
}
|
|
305
|
-
function
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
320
|
+
function ot() {
|
|
321
|
+
z || ct || (ct = !0, ft = 0, Ft = requestAnimationFrame(Xt));
|
|
322
|
+
}
|
|
323
|
+
function Xt(t) {
|
|
324
|
+
if (z) {
|
|
325
|
+
ct = !1;
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
ft || (ft = t);
|
|
329
|
+
const o = Math.min(0.25, (t - ft) / 1e3);
|
|
330
|
+
ft = t, $.on && ($.acc += $.rate * o, me($.acc), $.idx >= $.rows.length && ($.on = !1)), Z && V && (xe(X.set ? X.x : s * 0.5, X.set ? X.y : x * 0.45), Z = !1);
|
|
331
|
+
const l = A && Q;
|
|
332
|
+
if (E && (E.style.opacity = l && Math.floor(t / 530) % 2 === 0 ? "1" : "0"), !$.on && !Z && !l) {
|
|
333
|
+
ct = !1;
|
|
309
334
|
return;
|
|
310
335
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
Ft = requestAnimationFrame(Xt);
|
|
337
|
+
}
|
|
338
|
+
function pt(t) {
|
|
339
|
+
const o = R.getBoundingClientRect();
|
|
340
|
+
X.x = (t.clientX - o.left) / (o.width || 1) * s, X.y = (t.clientY - o.top) / (o.height || 1) * x, X.set = !0, Z = !0, ot();
|
|
341
|
+
}
|
|
342
|
+
function wt() {
|
|
343
|
+
X.set = !1, Z = !0, ot();
|
|
344
|
+
}
|
|
345
|
+
function ge() {
|
|
346
|
+
y && Vt(y.value, !0);
|
|
347
|
+
}
|
|
348
|
+
function pe(t) {
|
|
349
|
+
t.key === "Enter" && (t.preventDefault(), Pt.replay());
|
|
350
|
+
}
|
|
351
|
+
function we() {
|
|
352
|
+
Q = !0, ot();
|
|
353
|
+
}
|
|
354
|
+
function Me() {
|
|
355
|
+
Q = !1, E && (E.style.opacity = "0");
|
|
356
|
+
}
|
|
357
|
+
function Kt(t) {
|
|
358
|
+
t === A && y || (A = t, t ? (y || (y = document.createElement("input"), y.type = "text", y.value = n, y.maxLength = 64, y.setAttribute("aria-label", "Embroidered text — type to change it"), y.setAttribute("autocomplete", "off"), y.setAttribute("autocapitalize", "off"), y.spellcheck = !1, Object.assign(y.style, { position: "absolute", inset: "0", width: "100%", height: "100%", margin: "0", padding: "0", border: "0", outline: "none", background: "transparent", color: "transparent", caretColor: "transparent", font: "inherit", textAlign: "center", cursor: "text" }), y.addEventListener("input", ge), y.addEventListener("keydown", pe), y.addEventListener("focus", we), y.addEventListener("blur", Me), R.appendChild(y), U.push(y)), ye(), $t()) : (y && (y.remove(), y = null), Q = !1, E && (E.style.opacity = "0")));
|
|
359
|
+
}
|
|
360
|
+
function Ce(t) {
|
|
361
|
+
if (t !== b)
|
|
362
|
+
if (b = t, t)
|
|
363
|
+
R.addEventListener("pointermove", pt, { passive: !0 }), R.addEventListener("pointerleave", wt, { passive: !0 }), X.set = !1, Z = !0, ot();
|
|
364
|
+
else {
|
|
365
|
+
R.removeEventListener("pointermove", pt), R.removeEventListener("pointerleave", wt);
|
|
366
|
+
const o = j.getContext("2d");
|
|
367
|
+
o && o.clearRect(0, 0, s, x);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
function rt(t) {
|
|
371
|
+
le(), se(), ce(), fe(), ue(), t ? he() : (Rt(), Lt(), $.on = !1), y && y.value !== n && (y.value = n), $t(), Z = !0, ot();
|
|
372
|
+
}
|
|
373
|
+
function Vt(t, o) {
|
|
374
|
+
t = t ?? "", !(t === n && Y) && (n = t, Y && (rt(!1), o && m && m(n)));
|
|
375
|
+
}
|
|
376
|
+
const Mt = /* @__PURE__ */ new Set();
|
|
377
|
+
function Yt(t, o, l) {
|
|
378
|
+
const f = `${o} 200px ${t}`;
|
|
379
|
+
let T = !1;
|
|
337
380
|
try {
|
|
338
|
-
|
|
381
|
+
T = !!document.fonts && document.fonts.check(f);
|
|
339
382
|
} catch {
|
|
340
|
-
|
|
383
|
+
T = !0;
|
|
341
384
|
}
|
|
342
|
-
if (!document.fonts ||
|
|
343
|
-
|
|
385
|
+
if (!document.fonts || T) {
|
|
386
|
+
l();
|
|
344
387
|
return;
|
|
345
388
|
}
|
|
346
|
-
let
|
|
347
|
-
const
|
|
348
|
-
|
|
389
|
+
let C = !1, v;
|
|
390
|
+
const F = () => {
|
|
391
|
+
C || (C = !0, clearTimeout(v), Mt.delete(v), z || l());
|
|
349
392
|
};
|
|
350
|
-
document.fonts.load(
|
|
393
|
+
document.fonts.load(f, n).then(() => document.fonts.ready).then(F, F), v = setTimeout(F, 1500), Mt.add(v);
|
|
394
|
+
}
|
|
395
|
+
function ve() {
|
|
396
|
+
z || (rt(!0), Y = !0);
|
|
351
397
|
}
|
|
352
|
-
|
|
353
|
-
let It;
|
|
354
|
-
function
|
|
355
|
-
clearTimeout(It), It = setTimeout(() =>
|
|
398
|
+
A && (A = !1, Kt(!0)), b && (R.addEventListener("pointermove", pt, { passive: !0 }), R.addEventListener("pointerleave", wt, { passive: !0 })), Yt(I, i, ve);
|
|
399
|
+
let It, Jt = -1;
|
|
400
|
+
function Qt() {
|
|
401
|
+
clearTimeout(It), It = setTimeout(() => {
|
|
402
|
+
if (z || !Y) return;
|
|
403
|
+
const t = Math.round(R.getBoundingClientRect().width);
|
|
404
|
+
t !== Jt && (Jt = t, rt(!1));
|
|
405
|
+
}, 200);
|
|
356
406
|
}
|
|
357
|
-
window.addEventListener("resize",
|
|
358
|
-
const
|
|
407
|
+
window.addEventListener("resize", Qt);
|
|
408
|
+
const Pt = {
|
|
359
409
|
get text() {
|
|
360
|
-
return
|
|
410
|
+
return n;
|
|
361
411
|
},
|
|
362
412
|
setText(t) {
|
|
363
|
-
if (
|
|
364
|
-
|
|
365
|
-
|
|
413
|
+
if (!z) {
|
|
414
|
+
if (!Y) {
|
|
415
|
+
n = t ?? "", y && (y.value = n);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
Vt(t, !1);
|
|
366
419
|
}
|
|
367
|
-
t = t ?? "";
|
|
368
|
-
const n = t.length > a.length && a.length > 0 && t.startsWith(a), o = n ? _t() : -1;
|
|
369
|
-
a = t, bt(), Ft(), f || !S ? (at(), gt(), b.on = !1) : Et(n && o > 0 ? Math.min(o, _t()) : Tt() - 1, n ? 320 : h), Y = !0;
|
|
370
420
|
},
|
|
371
421
|
replay() {
|
|
372
|
-
|
|
422
|
+
z || !Y || rt(!0);
|
|
373
423
|
},
|
|
374
424
|
resize() {
|
|
375
|
-
|
|
425
|
+
z || !Y || rt(!1);
|
|
426
|
+
},
|
|
427
|
+
update(t) {
|
|
428
|
+
if (z) return;
|
|
429
|
+
t.text !== void 0 && Pt.setText(t.text);
|
|
430
|
+
let o = !1, l = !1;
|
|
431
|
+
if (t.font !== void 0 && t.font !== r && (r = t.font, I = ae(r), o = !0), t.weight !== void 0) {
|
|
432
|
+
const f = bt(t.weight, 1, 1e3);
|
|
433
|
+
f !== i && (i = f, o = !0);
|
|
434
|
+
}
|
|
435
|
+
if (t.fill !== void 0) {
|
|
436
|
+
const f = bt(t.fill, 0.05, 1);
|
|
437
|
+
f !== a && (a = f, o = !0);
|
|
438
|
+
}
|
|
439
|
+
t.pitch !== void 0 && t.pitch !== c && (c = t.pitch, o = !0), t.threadColor !== void 0 && (at(t.threadColor), l = !0), t.sewRate !== void 0 && (u = Math.max(1, t.sewRate)), t.animate !== void 0 && (S = t.animate), t.onTextChange !== void 0 && (m = t.onTextChange), t.sheen !== void 0 && Ce(t.sheen), t.editable !== void 0 && Kt(t.editable), Y && (o ? Yt(I, i, () => {
|
|
440
|
+
z || rt(!1);
|
|
441
|
+
}) : l && (Gt(), Rt(), Lt(), $t(), ot()));
|
|
442
|
+
},
|
|
443
|
+
focus() {
|
|
444
|
+
!z && A && (y == null || y.focus());
|
|
376
445
|
},
|
|
377
446
|
destroy() {
|
|
378
|
-
if (!
|
|
379
|
-
|
|
380
|
-
for (const t of
|
|
381
|
-
|
|
447
|
+
if (!z) {
|
|
448
|
+
z = !0, ct = !1, cancelAnimationFrame(Ft), clearTimeout(It);
|
|
449
|
+
for (const t of Mt) clearTimeout(t);
|
|
450
|
+
Mt.clear(), window.removeEventListener("resize", Qt), R.removeEventListener("pointermove", pt), R.removeEventListener("pointerleave", wt);
|
|
451
|
+
for (const t of U) t.remove();
|
|
452
|
+
et = [], yt = [], $.rows = [], Et = new Uint8Array(0), St = new Float32Array(0), ht = new Float32Array(0), mt = new Float32Array(0), V = nt = null, xt = null, E = null, y = null;
|
|
382
453
|
}
|
|
383
454
|
}
|
|
384
455
|
};
|
|
385
|
-
return
|
|
456
|
+
return Pt;
|
|
386
457
|
}
|
|
387
|
-
function
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
var
|
|
401
|
-
return (
|
|
458
|
+
function Re(h) {
|
|
459
|
+
const e = vt(null), n = vt(null), r = vt(h);
|
|
460
|
+
r.current = h;
|
|
461
|
+
const i = vt(h.onTextChange);
|
|
462
|
+
i.current = h.onTextChange;
|
|
463
|
+
const { text: a, font: u, weight: b, threadColor: S, pitch: A, fill: c, animate: m, sewRate: I, sheen: O, editable: B, reducedMotion: it } = h;
|
|
464
|
+
return Te(() => {
|
|
465
|
+
const D = e.current;
|
|
466
|
+
if (!D) return;
|
|
467
|
+
const at = Le(D, {
|
|
468
|
+
...r.current,
|
|
469
|
+
// Stable callback wrapper so typing edits always reach the latest handler.
|
|
470
|
+
onTextChange: (y) => {
|
|
471
|
+
var E;
|
|
472
|
+
return (E = i.current) == null ? void 0 : E.call(i, y);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
n.current = at;
|
|
476
|
+
let U = 0, k = 0, R = !0, j;
|
|
477
|
+
return typeof ResizeObserver < "u" && (j = new ResizeObserver((y) => {
|
|
478
|
+
const E = Math.round(y[0].contentRect.width);
|
|
479
|
+
if (R) {
|
|
480
|
+
R = !1, k = E;
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
E !== k && (k = E, cancelAnimationFrame(U), U = requestAnimationFrame(() => {
|
|
484
|
+
var Q;
|
|
485
|
+
return (Q = n.current) == null ? void 0 : Q.resize();
|
|
402
486
|
}));
|
|
403
|
-
}),
|
|
404
|
-
|
|
487
|
+
}), j.observe(D)), () => {
|
|
488
|
+
j == null || j.disconnect(), cancelAnimationFrame(U), at.destroy(), n.current = null;
|
|
405
489
|
};
|
|
406
|
-
}, [
|
|
407
|
-
var
|
|
408
|
-
(
|
|
409
|
-
}, [
|
|
490
|
+
}, [it]), ee(() => {
|
|
491
|
+
var D;
|
|
492
|
+
(D = n.current) == null || D.update({ font: u, weight: b, threadColor: S, pitch: A, fill: c, animate: m, sewRate: I, sheen: O, editable: B });
|
|
493
|
+
}, [u, b, S, A, c, m, I, O, B]), ee(() => {
|
|
494
|
+
var D;
|
|
495
|
+
(D = n.current) == null || D.setText(a);
|
|
496
|
+
}, [a]), e;
|
|
410
497
|
}
|
|
411
|
-
const
|
|
412
|
-
function({ className:
|
|
413
|
-
const
|
|
414
|
-
(
|
|
415
|
-
|
|
498
|
+
const $e = Ae(
|
|
499
|
+
function({ className: e, style: n, as: r = "div", "aria-label": i, role: a, "aria-describedby": u, ...b }, S) {
|
|
500
|
+
const A = Re(b), c = Ee(
|
|
501
|
+
(m) => {
|
|
502
|
+
A.current = m, typeof S == "function" ? S(m) : S && (S.current = m);
|
|
416
503
|
},
|
|
417
504
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
418
|
-
[
|
|
505
|
+
[A, S]
|
|
419
506
|
);
|
|
420
|
-
return /* @__PURE__ */
|
|
421
|
-
|
|
507
|
+
return /* @__PURE__ */ Se(
|
|
508
|
+
r,
|
|
422
509
|
{
|
|
423
|
-
ref:
|
|
424
|
-
className:
|
|
425
|
-
style:
|
|
426
|
-
role:
|
|
427
|
-
"aria-label":
|
|
428
|
-
"aria-describedby":
|
|
510
|
+
ref: c,
|
|
511
|
+
className: e,
|
|
512
|
+
style: n,
|
|
513
|
+
role: b.editable ? a : a ?? "img",
|
|
514
|
+
"aria-label": b.editable ? i : i ?? b.text,
|
|
515
|
+
"aria-describedby": u
|
|
429
516
|
}
|
|
430
517
|
);
|
|
431
518
|
}
|
|
432
519
|
);
|
|
433
|
-
|
|
520
|
+
$e.displayName = "ThreadText";
|
|
434
521
|
export {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
522
|
+
Dt as THREAD_TEXT_CLASSES,
|
|
523
|
+
$e as ThreadText,
|
|
524
|
+
Le as createThreadText,
|
|
525
|
+
Re as useThreadText
|
|
439
526
|
};
|