@mateosuarezdev/flash 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +32 -0
- package/README.md +945 -0
- package/dist/debug.cjs +11 -0
- package/dist/debug.d.ts +195 -0
- package/dist/debug.js +28 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.ts +600 -0
- package/dist/index.js +1335 -0
- package/dist/jsx-dev-runtime-BfTCjShK.js +65 -0
- package/dist/jsx-dev-runtime-D4XANMVW.cjs +11 -0
- package/dist/jsx-dev-runtime.cjs +11 -0
- package/dist/jsx-dev-runtime.d.ts +90 -0
- package/dist/jsx-dev-runtime.js +17 -0
- package/dist/jsx-runtime.cjs +11 -0
- package/dist/jsx-runtime.d.ts +90 -0
- package/dist/jsx-runtime.js +17 -0
- package/dist/server.cjs +27 -0
- package/dist/server.d.ts +60 -0
- package/dist/server.js +224 -0
- package/dist/utils.cjs +11 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.js +18 -0
- package/package.json +123 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Flash
|
|
4
|
+
* Copyright (c) 2025 Mateo Suarez. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Free to use in your own personal or commercial applications and projects.
|
|
7
|
+
* Unauthorized copying, modification, or distribution is strictly prohibited.
|
|
8
|
+
* See LICENSE file for full terms.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { n as L, s as w, g as I, c as m } from "./jsx-dev-runtime-BfTCjShK.js";
|
|
12
|
+
import { F as $e } from "./jsx-dev-runtime-BfTCjShK.js";
|
|
13
|
+
var R = Symbol.for("preact-signals");
|
|
14
|
+
function T() {
|
|
15
|
+
if (p > 1)
|
|
16
|
+
p--;
|
|
17
|
+
else {
|
|
18
|
+
for (var t, e = !1; S !== void 0; ) {
|
|
19
|
+
var i = S;
|
|
20
|
+
for (S = void 0, A++; i !== void 0; ) {
|
|
21
|
+
var n = i.o;
|
|
22
|
+
if (i.o = void 0, i.f &= -3, !(8 & i.f) && H(i)) try {
|
|
23
|
+
i.c();
|
|
24
|
+
} catch (r) {
|
|
25
|
+
e || (t = r, e = !0);
|
|
26
|
+
}
|
|
27
|
+
i = n;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (A = 0, p--, e) throw t;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function Ce(t) {
|
|
34
|
+
if (p > 0) return t();
|
|
35
|
+
p++;
|
|
36
|
+
try {
|
|
37
|
+
return t();
|
|
38
|
+
} finally {
|
|
39
|
+
T();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var c = void 0;
|
|
43
|
+
function K(t) {
|
|
44
|
+
var e = c;
|
|
45
|
+
c = void 0;
|
|
46
|
+
try {
|
|
47
|
+
return t();
|
|
48
|
+
} finally {
|
|
49
|
+
c = e;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var S = void 0, p = 0, A = 0, E = 0;
|
|
53
|
+
function G(t) {
|
|
54
|
+
if (c !== void 0) {
|
|
55
|
+
var e = t.n;
|
|
56
|
+
if (e === void 0 || e.t !== c)
|
|
57
|
+
return e = { i: 0, S: t, p: c.s, n: void 0, t: c, e: void 0, x: void 0, r: e }, c.s !== void 0 && (c.s.n = e), c.s = e, t.n = e, 32 & c.f && t.S(e), e;
|
|
58
|
+
if (e.i === -1)
|
|
59
|
+
return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = c.s, e.n = void 0, c.s.n = e, c.s = e), e;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function u(t, e) {
|
|
63
|
+
this.v = t, this.i = 0, this.n = void 0, this.t = void 0, this.W = e?.watched, this.Z = e?.unwatched, this.name = e?.name;
|
|
64
|
+
}
|
|
65
|
+
u.prototype.brand = R;
|
|
66
|
+
u.prototype.h = function() {
|
|
67
|
+
return !0;
|
|
68
|
+
};
|
|
69
|
+
u.prototype.S = function(t) {
|
|
70
|
+
var e = this, i = this.t;
|
|
71
|
+
i !== t && t.e === void 0 && (t.x = i, this.t = t, i !== void 0 ? i.e = t : K(function() {
|
|
72
|
+
var n;
|
|
73
|
+
(n = e.W) == null || n.call(e);
|
|
74
|
+
}));
|
|
75
|
+
};
|
|
76
|
+
u.prototype.U = function(t) {
|
|
77
|
+
var e = this;
|
|
78
|
+
if (this.t !== void 0) {
|
|
79
|
+
var i = t.e, n = t.x;
|
|
80
|
+
i !== void 0 && (i.x = n, t.e = void 0), n !== void 0 && (n.e = i, t.x = void 0), t === this.t && (this.t = n, n === void 0 && K(function() {
|
|
81
|
+
var r;
|
|
82
|
+
(r = e.Z) == null || r.call(e);
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
u.prototype.subscribe = function(t) {
|
|
87
|
+
var e = this;
|
|
88
|
+
return g(function() {
|
|
89
|
+
var i = e.value, n = c;
|
|
90
|
+
c = void 0;
|
|
91
|
+
try {
|
|
92
|
+
t(i);
|
|
93
|
+
} finally {
|
|
94
|
+
c = n;
|
|
95
|
+
}
|
|
96
|
+
}, { name: "sub" });
|
|
97
|
+
};
|
|
98
|
+
u.prototype.valueOf = function() {
|
|
99
|
+
return this.value;
|
|
100
|
+
};
|
|
101
|
+
u.prototype.toString = function() {
|
|
102
|
+
return this.value + "";
|
|
103
|
+
};
|
|
104
|
+
u.prototype.toJSON = function() {
|
|
105
|
+
return this.value;
|
|
106
|
+
};
|
|
107
|
+
u.prototype.peek = function() {
|
|
108
|
+
var t = c;
|
|
109
|
+
c = void 0;
|
|
110
|
+
try {
|
|
111
|
+
return this.value;
|
|
112
|
+
} finally {
|
|
113
|
+
c = t;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
Object.defineProperty(u.prototype, "value", { get: function() {
|
|
117
|
+
var t = G(this);
|
|
118
|
+
return t !== void 0 && (t.i = this.i), this.v;
|
|
119
|
+
}, set: function(t) {
|
|
120
|
+
if (t !== this.v) {
|
|
121
|
+
if (A > 100) throw new Error("Cycle detected");
|
|
122
|
+
this.v = t, this.i++, E++, p++;
|
|
123
|
+
try {
|
|
124
|
+
for (var e = this.t; e !== void 0; e = e.x) e.t.N();
|
|
125
|
+
} finally {
|
|
126
|
+
T();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} });
|
|
130
|
+
function we(t, e) {
|
|
131
|
+
return new u(t, e);
|
|
132
|
+
}
|
|
133
|
+
function H(t) {
|
|
134
|
+
for (var e = t.s; e !== void 0; e = e.n) if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i) return !0;
|
|
135
|
+
return !1;
|
|
136
|
+
}
|
|
137
|
+
function X(t) {
|
|
138
|
+
for (var e = t.s; e !== void 0; e = e.n) {
|
|
139
|
+
var i = e.S.n;
|
|
140
|
+
if (i !== void 0 && (e.r = i), e.S.n = e, e.i = -1, e.n === void 0) {
|
|
141
|
+
t.s = e;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function j(t) {
|
|
147
|
+
for (var e = t.s, i = void 0; e !== void 0; ) {
|
|
148
|
+
var n = e.p;
|
|
149
|
+
e.i === -1 ? (e.S.U(e), n !== void 0 && (n.n = e.n), e.n !== void 0 && (e.n.p = n)) : i = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = n;
|
|
150
|
+
}
|
|
151
|
+
t.s = i;
|
|
152
|
+
}
|
|
153
|
+
function y(t, e) {
|
|
154
|
+
u.call(this, void 0), this.x = t, this.s = void 0, this.g = E - 1, this.f = 4, this.W = e?.watched, this.Z = e?.unwatched, this.name = e?.name;
|
|
155
|
+
}
|
|
156
|
+
y.prototype = new u();
|
|
157
|
+
y.prototype.h = function() {
|
|
158
|
+
if (this.f &= -3, 1 & this.f) return !1;
|
|
159
|
+
if ((36 & this.f) == 32 || (this.f &= -5, this.g === E)) return !0;
|
|
160
|
+
if (this.g = E, this.f |= 1, this.i > 0 && !H(this))
|
|
161
|
+
return this.f &= -2, !0;
|
|
162
|
+
var t = c;
|
|
163
|
+
try {
|
|
164
|
+
X(this), c = this;
|
|
165
|
+
var e = this.x();
|
|
166
|
+
(16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
|
|
167
|
+
} catch (i) {
|
|
168
|
+
this.v = i, this.f |= 16, this.i++;
|
|
169
|
+
}
|
|
170
|
+
return c = t, j(this), this.f &= -2, !0;
|
|
171
|
+
};
|
|
172
|
+
y.prototype.S = function(t) {
|
|
173
|
+
if (this.t === void 0) {
|
|
174
|
+
this.f |= 36;
|
|
175
|
+
for (var e = this.s; e !== void 0; e = e.n) e.S.S(e);
|
|
176
|
+
}
|
|
177
|
+
u.prototype.S.call(this, t);
|
|
178
|
+
};
|
|
179
|
+
y.prototype.U = function(t) {
|
|
180
|
+
if (this.t !== void 0 && (u.prototype.U.call(this, t), this.t === void 0)) {
|
|
181
|
+
this.f &= -33;
|
|
182
|
+
for (var e = this.s; e !== void 0; e = e.n) e.S.U(e);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
y.prototype.N = function() {
|
|
186
|
+
if (!(2 & this.f)) {
|
|
187
|
+
this.f |= 6;
|
|
188
|
+
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
Object.defineProperty(y.prototype, "value", { get: function() {
|
|
192
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
193
|
+
var t = G(this);
|
|
194
|
+
if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f) throw this.v;
|
|
195
|
+
return this.v;
|
|
196
|
+
} });
|
|
197
|
+
function Ee(t, e) {
|
|
198
|
+
return new y(t, e);
|
|
199
|
+
}
|
|
200
|
+
function Y(t) {
|
|
201
|
+
var e = t.u;
|
|
202
|
+
if (t.u = void 0, typeof e == "function") {
|
|
203
|
+
p++;
|
|
204
|
+
var i = c;
|
|
205
|
+
c = void 0;
|
|
206
|
+
try {
|
|
207
|
+
e();
|
|
208
|
+
} catch (n) {
|
|
209
|
+
throw t.f &= -2, t.f |= 8, x(t), n;
|
|
210
|
+
} finally {
|
|
211
|
+
c = i, T();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function x(t) {
|
|
216
|
+
for (var e = t.s; e !== void 0; e = e.n) e.S.U(e);
|
|
217
|
+
t.x = void 0, t.s = void 0, Y(t);
|
|
218
|
+
}
|
|
219
|
+
function q(t) {
|
|
220
|
+
if (c !== this) throw new Error("Out-of-order effect");
|
|
221
|
+
j(this), c = t, this.f &= -2, 8 & this.f && x(this), T();
|
|
222
|
+
}
|
|
223
|
+
function v(t, e) {
|
|
224
|
+
this.x = t, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32, this.name = e?.name;
|
|
225
|
+
}
|
|
226
|
+
v.prototype.c = function() {
|
|
227
|
+
var t = this.S();
|
|
228
|
+
try {
|
|
229
|
+
if (8 & this.f || this.x === void 0) return;
|
|
230
|
+
var e = this.x();
|
|
231
|
+
typeof e == "function" && (this.u = e);
|
|
232
|
+
} finally {
|
|
233
|
+
t();
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
v.prototype.S = function() {
|
|
237
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
238
|
+
this.f |= 1, this.f &= -9, Y(this), X(this), p++;
|
|
239
|
+
var t = c;
|
|
240
|
+
return c = this, q.bind(this, t);
|
|
241
|
+
};
|
|
242
|
+
v.prototype.N = function() {
|
|
243
|
+
2 & this.f || (this.f |= 2, this.o = S, S = this);
|
|
244
|
+
};
|
|
245
|
+
v.prototype.d = function() {
|
|
246
|
+
this.f |= 8, 1 & this.f || x(this);
|
|
247
|
+
};
|
|
248
|
+
v.prototype.dispose = function() {
|
|
249
|
+
this.d();
|
|
250
|
+
};
|
|
251
|
+
function g(t, e) {
|
|
252
|
+
var i = new v(t, e);
|
|
253
|
+
try {
|
|
254
|
+
i.c();
|
|
255
|
+
} catch (r) {
|
|
256
|
+
throw i.d(), r;
|
|
257
|
+
}
|
|
258
|
+
var n = i.d.bind(i);
|
|
259
|
+
return n[Symbol.dispose] = n, n;
|
|
260
|
+
}
|
|
261
|
+
function Te(t) {
|
|
262
|
+
return t instanceof u ? t.peek() : t;
|
|
263
|
+
}
|
|
264
|
+
function Ne(t) {
|
|
265
|
+
return t instanceof u ? t.value : t;
|
|
266
|
+
}
|
|
267
|
+
function Ae(t, e) {
|
|
268
|
+
typeof e == "function" ? t.value = e() : t.value = e;
|
|
269
|
+
}
|
|
270
|
+
function xe(t) {
|
|
271
|
+
return t instanceof u ? () => t.value : t;
|
|
272
|
+
}
|
|
273
|
+
function Z(t, e, i = !1) {
|
|
274
|
+
const n = [];
|
|
275
|
+
for (const [r, s] of Object.entries(e))
|
|
276
|
+
if (s != null && !(r === "children" || r === "key" || r === "autoanimate")) {
|
|
277
|
+
if (typeof s == "function" && r !== "ref" && !r.startsWith("on") && r !== "viewTransitionName") {
|
|
278
|
+
const o = g(() => {
|
|
279
|
+
const a = s();
|
|
280
|
+
D(t, r, a, i);
|
|
281
|
+
});
|
|
282
|
+
n.push(o);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
D(t, r, s, i);
|
|
286
|
+
}
|
|
287
|
+
return () => n.forEach((r) => r());
|
|
288
|
+
}
|
|
289
|
+
function D(t, e, i, n) {
|
|
290
|
+
if (e === "ref" && typeof i == "function") {
|
|
291
|
+
i(t);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (e.startsWith("on") && typeof i == "function") {
|
|
295
|
+
const r = e.slice(2).toLowerCase();
|
|
296
|
+
t.addEventListener(r, i);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (e === "class" || e === "className") {
|
|
300
|
+
const r = typeof i == "string" ? i : Array.isArray(i) ? i.filter(Boolean).join(" ") : typeof i == "object" ? Object.entries(i).filter(([s, o]) => o).map(([s]) => s).join(" ") : "";
|
|
301
|
+
n ? t.setAttribute("class", r) : t.className = r;
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (e === "style") {
|
|
305
|
+
typeof i == "string" ? t.setAttribute("style", i) : typeof i == "object" && i && Object.assign(t.style, i);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (e === "viewTransitionName") {
|
|
309
|
+
t.style.viewTransitionName = i;
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (!n && typeof i == "boolean") {
|
|
313
|
+
i ? t.setAttribute(e, "") : t.removeAttribute(e);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
t.setAttribute(e, String(i));
|
|
317
|
+
}
|
|
318
|
+
function J(t, e) {
|
|
319
|
+
const i = document.createTextNode(String(e));
|
|
320
|
+
t.appendChild(i);
|
|
321
|
+
}
|
|
322
|
+
function V(t) {
|
|
323
|
+
return {
|
|
324
|
+
type: "reactive",
|
|
325
|
+
kind: "ReactiveVNode",
|
|
326
|
+
fn: t,
|
|
327
|
+
_id: L(),
|
|
328
|
+
_dispose: null,
|
|
329
|
+
_currentChild: null,
|
|
330
|
+
_currentDom: null,
|
|
331
|
+
_placeholder: null,
|
|
332
|
+
_parent: null,
|
|
333
|
+
_renderedChildren: []
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function k(t, e) {
|
|
337
|
+
if (!t && t !== 0)
|
|
338
|
+
return { vnode: null, dom: null };
|
|
339
|
+
if (typeof t == "string" || typeof t == "number" || typeof t == "boolean")
|
|
340
|
+
return { vnode: null, dom: document.createTextNode(String(t)) };
|
|
341
|
+
if (t instanceof Node)
|
|
342
|
+
return { vnode: null, dom: t };
|
|
343
|
+
if (typeof t == "object" && "type" in t) {
|
|
344
|
+
const i = t;
|
|
345
|
+
i.type !== "reactive" && (i._parent = e), e._renderedChildren.push(i);
|
|
346
|
+
const n = _(i);
|
|
347
|
+
return { vnode: i, dom: n };
|
|
348
|
+
}
|
|
349
|
+
return { vnode: null, dom: null };
|
|
350
|
+
}
|
|
351
|
+
class M {
|
|
352
|
+
_cancelled = !1;
|
|
353
|
+
_cancelCallbacks = [];
|
|
354
|
+
get cancelled() {
|
|
355
|
+
return this._cancelled;
|
|
356
|
+
}
|
|
357
|
+
cancel() {
|
|
358
|
+
this._cancelled || (this._cancelled = !0, this._cancelCallbacks.forEach((e) => {
|
|
359
|
+
try {
|
|
360
|
+
e();
|
|
361
|
+
} catch (i) {
|
|
362
|
+
console.error("Cancel callback error:", i);
|
|
363
|
+
}
|
|
364
|
+
}), this._cancelCallbacks = []);
|
|
365
|
+
}
|
|
366
|
+
onCancel(e) {
|
|
367
|
+
this._cancelled ? e() : this._cancelCallbacks.push(e);
|
|
368
|
+
}
|
|
369
|
+
throwIfCancelled() {
|
|
370
|
+
if (this._cancelled)
|
|
371
|
+
throw new Error("Operation cancelled");
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async function U(t, e) {
|
|
375
|
+
if (!t) return;
|
|
376
|
+
const i = t, n = e || new M();
|
|
377
|
+
if ("_onBeforeExitCallbacks" in i && i._onBeforeExitCallbacks.length > 0)
|
|
378
|
+
for (const r of i._onBeforeExitCallbacks)
|
|
379
|
+
try {
|
|
380
|
+
if (n.cancelled)
|
|
381
|
+
break;
|
|
382
|
+
await r(n);
|
|
383
|
+
} catch (s) {
|
|
384
|
+
console.error("onBeforeExit error:", s);
|
|
385
|
+
}
|
|
386
|
+
if ("_onUnmountCallbacks" in i && i._onUnmountCallbacks.length > 0 && i._onUnmountCallbacks.forEach((r) => {
|
|
387
|
+
try {
|
|
388
|
+
r();
|
|
389
|
+
} catch (s) {
|
|
390
|
+
console.error("onUnmount error:", s);
|
|
391
|
+
}
|
|
392
|
+
}), i.type === "reactive") {
|
|
393
|
+
const r = i;
|
|
394
|
+
r._dispose && (r._dispose(), r._dispose = null);
|
|
395
|
+
}
|
|
396
|
+
"_renderedChildren" in i && i._renderedChildren.forEach((r) => {
|
|
397
|
+
$(r);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
function $(t) {
|
|
401
|
+
if (!t) return;
|
|
402
|
+
const e = t, i = new M();
|
|
403
|
+
if (i.cancel(), "_onBeforeExitCallbacks" in e && e._onBeforeExitCallbacks.length > 0 && e._onBeforeExitCallbacks.forEach((n) => {
|
|
404
|
+
try {
|
|
405
|
+
const r = n(i);
|
|
406
|
+
r instanceof Promise && r.catch((s) => console.error("onBeforeExit error:", s));
|
|
407
|
+
} catch (r) {
|
|
408
|
+
console.error("onBeforeExit error:", r);
|
|
409
|
+
}
|
|
410
|
+
}), "_onUnmountCallbacks" in e && e._onUnmountCallbacks.length > 0 && e._onUnmountCallbacks.forEach((n) => {
|
|
411
|
+
try {
|
|
412
|
+
n();
|
|
413
|
+
} catch (r) {
|
|
414
|
+
console.error("onUnmount error:", r);
|
|
415
|
+
}
|
|
416
|
+
}), e.type === "reactive") {
|
|
417
|
+
const n = e;
|
|
418
|
+
n._dispose && (n._dispose(), n._dispose = null);
|
|
419
|
+
}
|
|
420
|
+
"_renderedChildren" in e && e._renderedChildren.forEach((n) => {
|
|
421
|
+
$(n);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
let Q = 0;
|
|
425
|
+
const h = /* @__PURE__ */ new WeakMap();
|
|
426
|
+
async function O(t, e, i) {
|
|
427
|
+
const n = t._placeholder;
|
|
428
|
+
if (!n?.parentNode) return;
|
|
429
|
+
const r = t._currentChild, s = t._currentDom;
|
|
430
|
+
if (ee(r, e)) {
|
|
431
|
+
const f = h.get(t);
|
|
432
|
+
f && (f.token.cancel(), h.delete(t)), r && "_lifecycleState" in r && (r._lifecycleState = "mounted");
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (s instanceof Text && i instanceof Text) {
|
|
436
|
+
s.nodeValue !== i.nodeValue && (s.nodeValue = i.nodeValue), t._currentDom = s, t._currentChild = e, e && "_lifecycleState" in e && (e._lifecycleState = "mounted"), h.delete(t);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
const o = ++Q, a = h.get(t);
|
|
440
|
+
a && a.token.cancel();
|
|
441
|
+
const l = new M();
|
|
442
|
+
if (h.set(t, { id: o, token: l }), r && "_lifecycleState" in r && (r._lifecycleState = "exiting"), r)
|
|
443
|
+
try {
|
|
444
|
+
await U(r, l);
|
|
445
|
+
} catch (f) {
|
|
446
|
+
console.error(`ReactiveVNode ${t._id}: Unmount threw:`, f);
|
|
447
|
+
}
|
|
448
|
+
const d = h.get(t);
|
|
449
|
+
if (!(!d || d.id !== o)) {
|
|
450
|
+
if (l.cancelled) {
|
|
451
|
+
h.delete(t);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
r && "_lifecycleState" in r && (r._lifecycleState = "exited"), s && s.remove(), i && n.parentNode.insertBefore(i, n.nextSibling), e && "_lifecycleState" in e && (e._lifecycleState = "mounted"), t._currentChild = e, t._currentDom = i, h.delete(t);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
function ee(t, e) {
|
|
458
|
+
if (!t || !e || typeof t != "object" || typeof e != "object" || !("type" in t) || !("type" in e)) return !1;
|
|
459
|
+
if (typeof t.type == "function" && typeof e.type == "function") {
|
|
460
|
+
if (t.type !== e.type) return !1;
|
|
461
|
+
} else if (typeof t.type == "string" && typeof e.type == "string") {
|
|
462
|
+
if (t.type !== e.type) return !1;
|
|
463
|
+
} else
|
|
464
|
+
return !1;
|
|
465
|
+
const i = "props" in t ? t.props?.key : void 0, n = "props" in e ? e.props?.key : void 0;
|
|
466
|
+
return i !== n ? !1 : "_lifecycleState" in t && t._lifecycleState === "exiting";
|
|
467
|
+
}
|
|
468
|
+
function te(t, e) {
|
|
469
|
+
const i = t._listState;
|
|
470
|
+
i ? ne(t, e, i) : ie(t, e);
|
|
471
|
+
}
|
|
472
|
+
function ie(t, e) {
|
|
473
|
+
const i = t._placeholder;
|
|
474
|
+
if (!i?.parentNode) return;
|
|
475
|
+
const n = [];
|
|
476
|
+
for (let r = 0; r < e.length; r++) {
|
|
477
|
+
const s = e[r], o = P(s, r), { vnode: a, dom: l } = k(s, t);
|
|
478
|
+
l && i.parentNode.appendChild(l), n.push({ key: o, vnode: a, dom: l });
|
|
479
|
+
}
|
|
480
|
+
t._listState = { items: n };
|
|
481
|
+
}
|
|
482
|
+
function ne(t, e, i) {
|
|
483
|
+
const n = t._placeholder;
|
|
484
|
+
if (!n?.parentNode) return;
|
|
485
|
+
const r = /* @__PURE__ */ new Map();
|
|
486
|
+
for (const a of i.items)
|
|
487
|
+
r.set(a.key, a);
|
|
488
|
+
const s = /* @__PURE__ */ new Set(), o = [];
|
|
489
|
+
for (let a = 0; a < e.length; a++) {
|
|
490
|
+
const l = e[a], d = P(l, a);
|
|
491
|
+
s.add(d);
|
|
492
|
+
const f = r.get(d);
|
|
493
|
+
f ? (o.push(f), r.delete(d)) : re(t, l, o);
|
|
494
|
+
}
|
|
495
|
+
r.size > 0 && se(r), oe(n, o), t._listState = { items: o };
|
|
496
|
+
}
|
|
497
|
+
function re(t, e, i) {
|
|
498
|
+
const n = P(e, i.length), { vnode: r, dom: s } = k(e, t);
|
|
499
|
+
i.push({ key: n, vnode: r, dom: s });
|
|
500
|
+
}
|
|
501
|
+
function se(t) {
|
|
502
|
+
for (const [e, i] of t)
|
|
503
|
+
i.vnode && U(i.vnode), i.dom?.parentNode && i.dom.parentNode.removeChild(i.dom);
|
|
504
|
+
}
|
|
505
|
+
function oe(t, e) {
|
|
506
|
+
const i = t.parentNode;
|
|
507
|
+
if (!i) return;
|
|
508
|
+
let n = t;
|
|
509
|
+
for (const r of e)
|
|
510
|
+
r.dom && (n.nextSibling !== r.dom && i.insertBefore(r.dom, n.nextSibling), n = r.dom);
|
|
511
|
+
}
|
|
512
|
+
function P(t, e) {
|
|
513
|
+
return t && typeof t == "object" && "key" in t ? t.key ?? e : e;
|
|
514
|
+
}
|
|
515
|
+
function B(t, e, i = null, n = !1) {
|
|
516
|
+
if (!e) return;
|
|
517
|
+
(Array.isArray(e) ? e : [e]).forEach((s) => {
|
|
518
|
+
if (s) {
|
|
519
|
+
if (Array.isArray(s) && B(t, s, i, n), typeof s == "string" || typeof s == "number")
|
|
520
|
+
J(t, s);
|
|
521
|
+
else if (typeof s == "function") {
|
|
522
|
+
const o = V(s);
|
|
523
|
+
o._parent = i, i && i._renderedChildren.push(o);
|
|
524
|
+
const a = document.createComment("reactive");
|
|
525
|
+
t.appendChild(a), o._placeholder = a;
|
|
526
|
+
const l = g(() => {
|
|
527
|
+
const d = s();
|
|
528
|
+
if (Array.isArray(d))
|
|
529
|
+
te(o, d);
|
|
530
|
+
else {
|
|
531
|
+
const { vnode: f, dom: N } = k(d, o);
|
|
532
|
+
O(o, f, N);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
o._dispose = l;
|
|
536
|
+
} else if (s instanceof Node)
|
|
537
|
+
t.append(s);
|
|
538
|
+
else if (s && typeof s == "object" && "type" in s) {
|
|
539
|
+
const o = s;
|
|
540
|
+
"type" in o && o.type !== "reactive" && (o._parent = i), i && i._renderedChildren.push(o);
|
|
541
|
+
const a = _(o, n);
|
|
542
|
+
a && t.append(a);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
const ae = "http://www.w3.org/2000/svg";
|
|
548
|
+
function W(t, e = !1) {
|
|
549
|
+
if (t._dom)
|
|
550
|
+
return t._dom;
|
|
551
|
+
const i = e || t.type === "svg", n = i ? document.createElementNS(ae, t.type) : document.createElement(t.type), r = Z(n, t.props, i);
|
|
552
|
+
return t._onUnmountCallbacks.push(r), t.props.children && B(n, t.props.children, t, i), t._dom = n, t._lifecycleState = "mounted", t._onMountCallbacks.length > 0 && t._onMountCallbacks.forEach((s) => s()), n;
|
|
553
|
+
}
|
|
554
|
+
function _(t, e = !1) {
|
|
555
|
+
if ("type" in t && t.type === "reactive")
|
|
556
|
+
return t._placeholder;
|
|
557
|
+
if (typeof t.type == "string")
|
|
558
|
+
return W(t, e);
|
|
559
|
+
const i = t;
|
|
560
|
+
w(i);
|
|
561
|
+
const n = i.type(i.props);
|
|
562
|
+
if (w(null), !n) return null;
|
|
563
|
+
let r = null;
|
|
564
|
+
if (typeof n == "string" || typeof n == "number" || typeof n == "boolean")
|
|
565
|
+
r = document.createTextNode(String(n));
|
|
566
|
+
else if (n instanceof Node)
|
|
567
|
+
i._element = n, r = n;
|
|
568
|
+
else if (n && typeof n == "object" && "type" in n) {
|
|
569
|
+
const s = n;
|
|
570
|
+
"type" in s && s.type !== "reactive" && (s._parent = i, i._renderedChildren.push(s));
|
|
571
|
+
const o = _(s, e);
|
|
572
|
+
o && (i._element = o), r = o;
|
|
573
|
+
}
|
|
574
|
+
return r && i._onMountCallbacks.length > 0 && i._onMountCallbacks.forEach((s) => {
|
|
575
|
+
s();
|
|
576
|
+
}), r && (i._lifecycleState = "mounted"), r;
|
|
577
|
+
}
|
|
578
|
+
function Me(t, e) {
|
|
579
|
+
const i = t instanceof Node ? t : _(t);
|
|
580
|
+
i && e.append(i);
|
|
581
|
+
}
|
|
582
|
+
function le(t) {
|
|
583
|
+
return document.createTreeWalker(
|
|
584
|
+
t,
|
|
585
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
|
|
586
|
+
null
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
function ce(t, e = "self") {
|
|
590
|
+
const i = le(t);
|
|
591
|
+
return e === "children" && i.firstChild(), {
|
|
592
|
+
walker: i,
|
|
593
|
+
isSVG: !1
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function ue(t, e, i, n) {
|
|
597
|
+
if (e === "class" || e === "className") {
|
|
598
|
+
const r = typeof i == "string" ? i : Array.isArray(i) ? i.filter(Boolean).join(" ") : typeof i == "object" ? Object.entries(i).filter(([s, o]) => o).map(([s]) => s).join(" ") : "";
|
|
599
|
+
n ? t.setAttribute("class", r) : t.className = r;
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (e === "style") {
|
|
603
|
+
typeof i == "string" ? t.setAttribute("style", i) : typeof i == "object" && i && Object.assign(t.style, i);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (e === "viewTransitionName") {
|
|
607
|
+
t.style.viewTransitionName = i;
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
if (!n && typeof i == "boolean") {
|
|
611
|
+
i ? t.setAttribute(e, "") : t.removeAttribute(e);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
t.setAttribute(e, String(i));
|
|
615
|
+
}
|
|
616
|
+
function fe(t, e, i = !1, n) {
|
|
617
|
+
const r = [];
|
|
618
|
+
for (const [s, o] of Object.entries(e))
|
|
619
|
+
if (o != null && !(s === "children" || s === "key" || s === "autoanimate")) {
|
|
620
|
+
if (s === "ref" && typeof o == "function") {
|
|
621
|
+
n && console.log("→ Attaching ref"), o(t);
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
if (s.startsWith("on") && typeof o == "function") {
|
|
625
|
+
const a = s.slice(2).toLowerCase();
|
|
626
|
+
n && console.log(`→ Attaching event: ${a}`), t.addEventListener(a, o);
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
if (typeof o == "function" && s !== "ref" && s !== "viewTransitionName") {
|
|
630
|
+
n && console.log(`→ Reactive prop: ${s}`);
|
|
631
|
+
const a = g(() => {
|
|
632
|
+
const l = o();
|
|
633
|
+
ue(t, s, l, i);
|
|
634
|
+
});
|
|
635
|
+
r.push(a);
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return () => r.forEach((s) => s());
|
|
640
|
+
}
|
|
641
|
+
function de(t, e, i = null, n) {
|
|
642
|
+
if (!e) return;
|
|
643
|
+
const r = Array.isArray(e) ? e : [e];
|
|
644
|
+
if (!n.walker.firstChild() && r.length > 0) {
|
|
645
|
+
console.warn("Hydration mismatch: VNode has children but DOM is empty");
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
for (const o of r)
|
|
649
|
+
!o && o !== 0 || he(o, t, i, n);
|
|
650
|
+
n.walker.parentNode();
|
|
651
|
+
}
|
|
652
|
+
function he(t, e, i, n) {
|
|
653
|
+
if (!(!t && t !== 0)) {
|
|
654
|
+
if (typeof t == "string" || typeof t == "number" || typeof t == "boolean") {
|
|
655
|
+
const r = n.walker.currentNode;
|
|
656
|
+
r.nodeType === Node.TEXT_NODE ? (n.debug && console.log("→ Hydrated text node"), n.walker.nextSibling()) : console.warn(
|
|
657
|
+
`Hydration mismatch: expected text node but found ${r.nodeName}`
|
|
658
|
+
);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
if (typeof t == "function") {
|
|
662
|
+
n.debug && console.log("→ Hydrating reactive child");
|
|
663
|
+
const r = V(t);
|
|
664
|
+
r._parent = i, i && i._renderedChildren.push(r);
|
|
665
|
+
const s = n.walker.currentNode, o = t();
|
|
666
|
+
if (o && typeof o == "object" && "type" in o) {
|
|
667
|
+
const f = o;
|
|
668
|
+
b(f, n), r._currentChild = f, r._currentDom = f._dom ?? f._element;
|
|
669
|
+
} else (typeof o == "string" || typeof o == "number" || typeof o == "boolean") && (r._currentDom = s), n.walker.nextSibling();
|
|
670
|
+
const a = document.createComment("reactive");
|
|
671
|
+
r._currentDom?.parentNode && r._currentDom.parentNode.insertBefore(
|
|
672
|
+
a,
|
|
673
|
+
r._currentDom
|
|
674
|
+
), r._placeholder = a;
|
|
675
|
+
let l = !0;
|
|
676
|
+
const d = g(() => {
|
|
677
|
+
const f = t();
|
|
678
|
+
if (l) {
|
|
679
|
+
l = !1;
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const { vnode: N, dom: z } = k(f, r);
|
|
683
|
+
O(r, N, z);
|
|
684
|
+
});
|
|
685
|
+
r._dispose = d;
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
if (t instanceof Node) {
|
|
689
|
+
n.walker.nextSibling();
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
if (t && typeof t == "object" && "type" in t) {
|
|
693
|
+
const r = t;
|
|
694
|
+
"type" in r && r.type !== "reactive" && r.type !== "suspended" && (r._parent = i), i && i._renderedChildren.push(r), b(r, n);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function pe(t, e) {
|
|
699
|
+
const i = e.walker.currentNode;
|
|
700
|
+
if (i.nodeType !== Node.ELEMENT_NODE)
|
|
701
|
+
return console.warn(
|
|
702
|
+
`Hydration mismatch: expected element <${t.type}> but found ${i.nodeName}`
|
|
703
|
+
), F(t, i, e);
|
|
704
|
+
const n = i, r = n.tagName.toLowerCase();
|
|
705
|
+
if (r !== t.type.toLowerCase())
|
|
706
|
+
return console.warn(
|
|
707
|
+
`Hydration mismatch: expected <${t.type}> but found <${r}>`
|
|
708
|
+
), F(t, i, e);
|
|
709
|
+
const s = e.isSVG || t.type === "svg", o = e.isSVG;
|
|
710
|
+
e.isSVG = s, t._dom = n, e.debug && console.log(`→ Attached existing <${t.type}> DOM`);
|
|
711
|
+
const a = fe(n, t.props, s, e.debug);
|
|
712
|
+
return t._onUnmountCallbacks.push(a), t.props.children && de(n, t.props.children, t, e), t._lifecycleState = "mounted", t._onMountCallbacks.length > 0 && t._onMountCallbacks.forEach((l) => l()), e.isSVG = o, e.walker.nextSibling(), n;
|
|
713
|
+
}
|
|
714
|
+
function F(t, e, i) {
|
|
715
|
+
i.debug && console.log(`→ Fallback: rendering <${t.type}> fresh`);
|
|
716
|
+
const n = e.parentNode, r = e.nextSibling;
|
|
717
|
+
n?.removeChild(e);
|
|
718
|
+
const s = W(t, i.isSVG);
|
|
719
|
+
return n && (r ? n.insertBefore(s, r) : n.appendChild(s)), i.walker.nextSibling(), s;
|
|
720
|
+
}
|
|
721
|
+
function b(t, e) {
|
|
722
|
+
if ("type" in t && t.type === "reactive")
|
|
723
|
+
return e.debug && console.log(`Hydrating ReactiveVNode #${t._id}`), me(t, e);
|
|
724
|
+
if ("type" in t && t.type === "suspended")
|
|
725
|
+
return e.debug && console.log(
|
|
726
|
+
`Hydrating SuspendedVNode: ${t._componentName}`
|
|
727
|
+
), be(t, e);
|
|
728
|
+
if (typeof t.type == "string")
|
|
729
|
+
return e.debug && console.log(`Hydrating <${t.type}>`), pe(t, e);
|
|
730
|
+
const i = t.type.name || "Anonymous";
|
|
731
|
+
return e.debug && console.log(`Hydrating Component: ${i}`), ye(t, e);
|
|
732
|
+
}
|
|
733
|
+
function ye(t, e) {
|
|
734
|
+
w(t);
|
|
735
|
+
const i = t.type(t.props);
|
|
736
|
+
if (w(null), !i) return null;
|
|
737
|
+
if (typeof i == "object" && "type" in i && i.type === "suspended")
|
|
738
|
+
return b(i, e);
|
|
739
|
+
let n = null;
|
|
740
|
+
if (typeof i == "string" || typeof i == "number" || typeof i == "boolean") {
|
|
741
|
+
const r = e.walker.currentNode;
|
|
742
|
+
r.nodeType === Node.TEXT_NODE && (t._element = r, n = r, e.walker.nextSibling());
|
|
743
|
+
} else if (i instanceof Node)
|
|
744
|
+
t._element = i, n = i, e.walker.nextSibling();
|
|
745
|
+
else if (i && typeof i == "object" && "type" in i) {
|
|
746
|
+
const r = i;
|
|
747
|
+
"type" in r && r.type !== "reactive" && (r._parent = t, t._renderedChildren.push(r));
|
|
748
|
+
const s = b(r, e);
|
|
749
|
+
s && (t._element = s), n = s;
|
|
750
|
+
}
|
|
751
|
+
return n && t._onMountCallbacks.length > 0 && (e.debug && console.log(
|
|
752
|
+
`→ Firing ${t._onMountCallbacks.length} onMount callback(s)`
|
|
753
|
+
), t._onMountCallbacks.forEach((r) => r())), n && (t._lifecycleState = "mounted"), n;
|
|
754
|
+
}
|
|
755
|
+
function me(t, e) {
|
|
756
|
+
const i = t.fn(), n = e.walker.currentNode, r = document.createComment("reactive");
|
|
757
|
+
if (n.parentNode?.insertBefore(r, n), t._placeholder = r, i && typeof i == "object" && "type" in i) {
|
|
758
|
+
const a = i;
|
|
759
|
+
b(a, e), t._currentChild = a, t._currentDom = a._dom ?? a._element;
|
|
760
|
+
} else (typeof i == "string" || typeof i == "number" || typeof i == "boolean") && (t._currentDom = n), e.walker.nextSibling();
|
|
761
|
+
let s = !0;
|
|
762
|
+
const o = g(() => {
|
|
763
|
+
const a = t.fn();
|
|
764
|
+
if (s) {
|
|
765
|
+
s = !1, e.debug && console.log("→ Reactive effect setup (skipping initial)");
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
const { vnode: l, dom: d } = k(a, t);
|
|
769
|
+
O(t, l, d);
|
|
770
|
+
});
|
|
771
|
+
return t._dispose = o, t._currentDom;
|
|
772
|
+
}
|
|
773
|
+
function be(t, e) {
|
|
774
|
+
const i = e.walker.currentNode;
|
|
775
|
+
if (i.nodeType === Node.ELEMENT_NODE && i.hasAttribute("data-suspended")) {
|
|
776
|
+
const r = i;
|
|
777
|
+
return r.getAttribute("data-suspended-state") === "resolved" ? (t._state = "resolved", e.walker.firstChild(), t.promise.then((o) => {
|
|
778
|
+
t._state = "resolved";
|
|
779
|
+
}).catch((o) => {
|
|
780
|
+
t._state = "error";
|
|
781
|
+
const a = typeof t.errorFallback == "function" ? t.errorFallback(o) : t.errorFallback;
|
|
782
|
+
r.innerHTML = "";
|
|
783
|
+
const l = C(a, e.isSVG);
|
|
784
|
+
l && r.appendChild(l);
|
|
785
|
+
}), e.walker.parentNode(), e.walker.nextSibling(), r) : (t._state = "pending", t.promise.then((o) => {
|
|
786
|
+
t._state = "resolved", r.innerHTML = "";
|
|
787
|
+
const a = C(o, e.isSVG);
|
|
788
|
+
a && r.appendChild(a);
|
|
789
|
+
}).catch((o) => {
|
|
790
|
+
t._state = "error";
|
|
791
|
+
const a = typeof t.errorFallback == "function" ? t.errorFallback(o) : t.errorFallback;
|
|
792
|
+
r.innerHTML = "";
|
|
793
|
+
const l = C(a, e.isSVG);
|
|
794
|
+
l && r.appendChild(l);
|
|
795
|
+
}), e.walker.nextSibling(), r);
|
|
796
|
+
}
|
|
797
|
+
console.warn("Hydration mismatch: expected suspended container");
|
|
798
|
+
const n = _(t, e.isSVG);
|
|
799
|
+
return e.walker.nextSibling(), n;
|
|
800
|
+
}
|
|
801
|
+
function C(t, e) {
|
|
802
|
+
return !t && t !== 0 ? null : typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? document.createTextNode(String(t)) : t instanceof Node ? t : typeof t == "object" && "type" in t ? _(
|
|
803
|
+
//todo handle suspendedvnode
|
|
804
|
+
//@ts-ignore
|
|
805
|
+
t,
|
|
806
|
+
e
|
|
807
|
+
) : typeof t == "function" ? C(t(), e) : null;
|
|
808
|
+
}
|
|
809
|
+
function Oe(t, e, i = "self") {
|
|
810
|
+
const n = ce(e, i);
|
|
811
|
+
b(t, n);
|
|
812
|
+
}
|
|
813
|
+
function Pe(t, e = "Loading...", i = "Error") {
|
|
814
|
+
return (n) => ({
|
|
815
|
+
type: "suspended",
|
|
816
|
+
kind: "SuspendedVNode",
|
|
817
|
+
promise: t(n),
|
|
818
|
+
fallback: e,
|
|
819
|
+
errorFallback: i,
|
|
820
|
+
_id: L(),
|
|
821
|
+
_componentName: t.name || "AsyncComponent",
|
|
822
|
+
_parent: null,
|
|
823
|
+
_renderedChildren: [],
|
|
824
|
+
_currentChild: null,
|
|
825
|
+
_state: "pending"
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
function De(t) {
|
|
829
|
+
const e = Symbol("context");
|
|
830
|
+
return {
|
|
831
|
+
_id: e,
|
|
832
|
+
_defaultValue: t,
|
|
833
|
+
provide(i) {
|
|
834
|
+
if (typeof document > "u") return;
|
|
835
|
+
const n = I();
|
|
836
|
+
if (!n)
|
|
837
|
+
throw new Error("context.provide() called outside of component render");
|
|
838
|
+
n._contextMap || (n._contextMap = /* @__PURE__ */ new Map()), n._contextMap.set(e, i);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function Fe(t) {
|
|
843
|
+
if (typeof document > "u") return t._defaultValue;
|
|
844
|
+
const e = I();
|
|
845
|
+
if (!e)
|
|
846
|
+
throw new Error("useContext called outside of component render");
|
|
847
|
+
let i = e;
|
|
848
|
+
for (; i; ) {
|
|
849
|
+
if (i.kind === "VNode" && i._contextMap?.has(t._id))
|
|
850
|
+
return i._contextMap.get(t._id);
|
|
851
|
+
i = i._parent;
|
|
852
|
+
}
|
|
853
|
+
return t._defaultValue;
|
|
854
|
+
}
|
|
855
|
+
function Le(t) {
|
|
856
|
+
if (!(typeof document > "u")) {
|
|
857
|
+
if (m === null)
|
|
858
|
+
throw new Error("onMount must be called inside a component during render");
|
|
859
|
+
m._onMountCallbacks.push(t);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function Ie(t) {
|
|
863
|
+
if (!(typeof document > "u")) {
|
|
864
|
+
if (m === null)
|
|
865
|
+
throw new Error(
|
|
866
|
+
"onUnmount must be called inside a component during render"
|
|
867
|
+
);
|
|
868
|
+
m._onUnmountCallbacks.push(t);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
function Ke(t) {
|
|
872
|
+
if (!(typeof document > "u")) {
|
|
873
|
+
if (m === null)
|
|
874
|
+
throw new Error(
|
|
875
|
+
"onBeforeExit must be called inside a component during render"
|
|
876
|
+
);
|
|
877
|
+
m._onBeforeExitCallbacks.push(t);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
function Ge(t) {
|
|
881
|
+
if (!(typeof document > "u"))
|
|
882
|
+
try {
|
|
883
|
+
t();
|
|
884
|
+
} catch (e) {
|
|
885
|
+
console.error(e);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
class He {
|
|
889
|
+
// One-time callbacks
|
|
890
|
+
readCallbacks = /* @__PURE__ */ new Set();
|
|
891
|
+
updateCallbacks = /* @__PURE__ */ new Set();
|
|
892
|
+
renderCallbacks = /* @__PURE__ */ new Set();
|
|
893
|
+
// Keep-alive callbacks (run every frame until cancelled)
|
|
894
|
+
readKeepAlive = /* @__PURE__ */ new Set();
|
|
895
|
+
updateKeepAlive = /* @__PURE__ */ new Set();
|
|
896
|
+
renderKeepAlive = /* @__PURE__ */ new Set();
|
|
897
|
+
isProcessing = !1;
|
|
898
|
+
frameScheduled = !1;
|
|
899
|
+
frameId = null;
|
|
900
|
+
lastTimestamp = 0;
|
|
901
|
+
currentDelta = 0;
|
|
902
|
+
// FPS tracking (optional)
|
|
903
|
+
trackFPS;
|
|
904
|
+
fpsHistorySize;
|
|
905
|
+
fpsHistory = [];
|
|
906
|
+
constructor(e = {}) {
|
|
907
|
+
this.trackFPS = e.trackFPS ?? !1, this.fpsHistorySize = e.fpsHistorySize ?? 60;
|
|
908
|
+
}
|
|
909
|
+
// --------------------------------------------------------------------------
|
|
910
|
+
// Public API
|
|
911
|
+
// --------------------------------------------------------------------------
|
|
912
|
+
/**
|
|
913
|
+
* Schedule a callback to run in the READ phase (for DOM measurements)
|
|
914
|
+
* Use this for: offsetHeight, getBoundingClientRect, getComputedStyle, etc.
|
|
915
|
+
*
|
|
916
|
+
* @param callback - Function to execute during the read phase
|
|
917
|
+
* @param keepAlive - If true, callback runs every frame until cancelled
|
|
918
|
+
* @returns The callback function (can be passed to cancelFrame)
|
|
919
|
+
*
|
|
920
|
+
* @example
|
|
921
|
+
* frame.read(() => {
|
|
922
|
+
* const height = element.offsetHeight;
|
|
923
|
+
* });
|
|
924
|
+
*
|
|
925
|
+
* // With frame data if needed
|
|
926
|
+
* frame.read((data) => {
|
|
927
|
+
* console.log('Delta:', data.delta);
|
|
928
|
+
* });
|
|
929
|
+
*/
|
|
930
|
+
read(e, i = !1) {
|
|
931
|
+
return i ? this.readKeepAlive.add(e) : this.readCallbacks.add(e), this.scheduleFrame(), e;
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Schedule a callback to run in the UPDATE phase (for calculations)
|
|
935
|
+
* Use this for: computing animation values, business logic, etc.
|
|
936
|
+
*
|
|
937
|
+
* @param callback - Function to execute during the update phase
|
|
938
|
+
* @param keepAlive - If true, callback runs every frame until cancelled
|
|
939
|
+
* @returns The callback function (can be passed to cancelFrame)
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* frame.update(() => {
|
|
943
|
+
* position += velocity;
|
|
944
|
+
* });
|
|
945
|
+
*
|
|
946
|
+
* // Delta-time independent animation
|
|
947
|
+
* frame.update((data) => {
|
|
948
|
+
* position += velocity * (data.delta / 1000);
|
|
949
|
+
* }, true);
|
|
950
|
+
*/
|
|
951
|
+
update(e, i = !1) {
|
|
952
|
+
return i ? this.updateKeepAlive.add(e) : this.updateCallbacks.add(e), this.scheduleFrame(), e;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Schedule a callback to run in the RENDER phase (for DOM writes)
|
|
956
|
+
* Use this for: style updates, classList changes, DOM mutations, etc.
|
|
957
|
+
*
|
|
958
|
+
* @param callback - Function to execute during the render phase
|
|
959
|
+
* @param keepAlive - If true, callback runs every frame until cancelled
|
|
960
|
+
* @returns The callback function (can be passed to cancelFrame)
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* frame.render(() => {
|
|
964
|
+
* element.style.transform = `translateX(${x}px)`;
|
|
965
|
+
* });
|
|
966
|
+
*/
|
|
967
|
+
render(e, i = !1) {
|
|
968
|
+
return i ? this.renderKeepAlive.add(e) : this.renderCallbacks.add(e), this.scheduleFrame(), e;
|
|
969
|
+
}
|
|
970
|
+
chain(e) {
|
|
971
|
+
let i, n;
|
|
972
|
+
"read" in e && this.readCallbacks.add((r) => {
|
|
973
|
+
i = e.read(r);
|
|
974
|
+
}), "update" in e ? (this.updateCallbacks.add((r) => {
|
|
975
|
+
n = e.update(
|
|
976
|
+
i,
|
|
977
|
+
r
|
|
978
|
+
);
|
|
979
|
+
}), this.renderCallbacks.add((r) => {
|
|
980
|
+
e.render(n, r);
|
|
981
|
+
})) : this.renderCallbacks.add((r) => {
|
|
982
|
+
e.render(i, r);
|
|
983
|
+
}), this.scheduleFrame();
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Cancel a scheduled callback from all phases
|
|
987
|
+
*
|
|
988
|
+
* @param callback - The callback function to cancel
|
|
989
|
+
*/
|
|
990
|
+
cancel(e) {
|
|
991
|
+
this.readCallbacks.delete(e), this.updateCallbacks.delete(e), this.renderCallbacks.delete(e), this.readKeepAlive.delete(e), this.updateKeepAlive.delete(e), this.renderKeepAlive.delete(e);
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Cancel all scheduled callbacks and stop the frame loop
|
|
995
|
+
*/
|
|
996
|
+
cancelAll() {
|
|
997
|
+
this.frameId !== null && (cancelAnimationFrame(this.frameId), this.frameId = null), this.readCallbacks.clear(), this.updateCallbacks.clear(), this.renderCallbacks.clear(), this.readKeepAlive.clear(), this.updateKeepAlive.clear(), this.renderKeepAlive.clear(), this.isProcessing = !1, this.frameScheduled = !1, this.lastTimestamp = 0, this.currentDelta = 0, this.trackFPS && (this.fpsHistory = []);
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Get current frame data (timestamp and delta)
|
|
1001
|
+
*/
|
|
1002
|
+
get data() {
|
|
1003
|
+
return {
|
|
1004
|
+
timestamp: this.lastTimestamp,
|
|
1005
|
+
delta: this.currentDelta || 16.67
|
|
1006
|
+
// Fallback for first frame
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Check if frame loop is currently running
|
|
1011
|
+
*/
|
|
1012
|
+
get isRunning() {
|
|
1013
|
+
return this.isProcessing || this.readKeepAlive.size > 0 || this.updateKeepAlive.size > 0 || this.renderKeepAlive.size > 0;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Get current instantaneous FPS
|
|
1017
|
+
* Only available if trackFPS is enabled
|
|
1018
|
+
*/
|
|
1019
|
+
get fps() {
|
|
1020
|
+
return this.trackFPS ? this.currentDelta > 0 ? 1e3 / this.currentDelta : 0 : (console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"), 0);
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Get average FPS over the history window
|
|
1024
|
+
* Only available if trackFPS is enabled
|
|
1025
|
+
*/
|
|
1026
|
+
get averageFps() {
|
|
1027
|
+
if (!this.trackFPS)
|
|
1028
|
+
return console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"), 0;
|
|
1029
|
+
if (this.fpsHistory.length === 0) return 0;
|
|
1030
|
+
const e = this.fpsHistory.reduce((i, n) => i + n, 0);
|
|
1031
|
+
return Math.round(e / this.fpsHistory.length);
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Get estimated refresh rate (rounded FPS)
|
|
1035
|
+
* Only available if trackFPS is enabled
|
|
1036
|
+
*/
|
|
1037
|
+
get refreshRate() {
|
|
1038
|
+
return this.trackFPS ? Math.round(this.averageFps) : (console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"), 0);
|
|
1039
|
+
}
|
|
1040
|
+
// --------------------------------------------------------------------------
|
|
1041
|
+
// Private Methods
|
|
1042
|
+
// --------------------------------------------------------------------------
|
|
1043
|
+
scheduleFrame() {
|
|
1044
|
+
this.frameScheduled || this.isProcessing || (this.frameScheduled = !0, this.frameId = requestAnimationFrame((e) => {
|
|
1045
|
+
this.processFrame(e);
|
|
1046
|
+
}));
|
|
1047
|
+
}
|
|
1048
|
+
processFrame(e) {
|
|
1049
|
+
this.isProcessing = !0, this.frameScheduled = !1, this.lastTimestamp === 0 ? this.currentDelta = 16.67 : this.currentDelta = e - this.lastTimestamp, this.lastTimestamp = e, this.trackFPS && this.currentDelta > 0 && (this.fpsHistory.push(1e3 / this.currentDelta), this.fpsHistory.length > this.fpsHistorySize && this.fpsHistory.shift());
|
|
1050
|
+
const i = this.data;
|
|
1051
|
+
this.executeCallbacks(this.readCallbacks, i), this.executeCallbacks(this.readKeepAlive, i), this.executeCallbacks(this.updateCallbacks, i), this.executeCallbacks(this.updateKeepAlive, i), this.executeCallbacks(this.renderCallbacks, i), this.executeCallbacks(this.renderKeepAlive, i), this.isProcessing = !1, this.hasKeepAliveCallbacks() && this.scheduleFrame();
|
|
1052
|
+
}
|
|
1053
|
+
executeCallbacks(e, i) {
|
|
1054
|
+
e.forEach((n) => {
|
|
1055
|
+
try {
|
|
1056
|
+
n(i);
|
|
1057
|
+
} catch (r) {
|
|
1058
|
+
console.error("Frame callback error:", r);
|
|
1059
|
+
}
|
|
1060
|
+
}), this.isKeepAliveSet(e) || e.clear();
|
|
1061
|
+
}
|
|
1062
|
+
hasKeepAliveCallbacks() {
|
|
1063
|
+
return this.readKeepAlive.size > 0 || this.updateKeepAlive.size > 0 || this.renderKeepAlive.size > 0;
|
|
1064
|
+
}
|
|
1065
|
+
isKeepAliveSet(e) {
|
|
1066
|
+
return e === this.readKeepAlive || e === this.updateKeepAlive || e === this.renderKeepAlive;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
class ve {
|
|
1070
|
+
gestureId = 0;
|
|
1071
|
+
activeGestures = /* @__PURE__ */ new Map();
|
|
1072
|
+
disabledGestures = /* @__PURE__ */ new Map();
|
|
1073
|
+
capturedId;
|
|
1074
|
+
gestureWithPriority = /* @__PURE__ */ new Map();
|
|
1075
|
+
maxPriority = -1 / 0;
|
|
1076
|
+
/**
|
|
1077
|
+
* Creates a new gesture ID
|
|
1078
|
+
*/
|
|
1079
|
+
newId() {
|
|
1080
|
+
return ++this.gestureId;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Check if a gesture can start
|
|
1084
|
+
*/
|
|
1085
|
+
canStart(e) {
|
|
1086
|
+
if (this.capturedId !== void 0)
|
|
1087
|
+
return !1;
|
|
1088
|
+
const i = this.disabledGestures.get(e);
|
|
1089
|
+
return !(i && i.size > 0);
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Register a gesture as wanting to start
|
|
1093
|
+
*/
|
|
1094
|
+
start(e, i, n) {
|
|
1095
|
+
return this.canStart(i) ? (this.activeGestures.set(e, i), this.gestureWithPriority.set(e, n), this.maxPriority = Math.max(this.maxPriority, n), !0) : !1;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Attempt to capture control with this gesture
|
|
1099
|
+
*/
|
|
1100
|
+
capture(e, i, n) {
|
|
1101
|
+
return !this.activeGestures.has(e) && !this.start(e, i, n) ? !1 : n >= this.maxPriority ? (this.capturedId = e, this.activeGestures.forEach((r, s) => {
|
|
1102
|
+
s !== e && this.release(s);
|
|
1103
|
+
}), !0) : (this.release(e), !1);
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Release a gesture's attempt to capture
|
|
1107
|
+
*/
|
|
1108
|
+
release(e) {
|
|
1109
|
+
const i = this.activeGestures.get(e);
|
|
1110
|
+
this.activeGestures.delete(e);
|
|
1111
|
+
const n = this.gestureWithPriority.get(e);
|
|
1112
|
+
if (this.gestureWithPriority.delete(e), this.capturedId === e && (this.capturedId = void 0), n === this.maxPriority && (this.maxPriority = -1 / 0, this.gestureWithPriority.forEach((r) => {
|
|
1113
|
+
this.maxPriority = Math.max(this.maxPriority, r);
|
|
1114
|
+
})), i) {
|
|
1115
|
+
const r = this.disabledGestures.get(i);
|
|
1116
|
+
r && (r.delete(e), r.size === 0 && this.disabledGestures.delete(i));
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Disable a specific gesture type
|
|
1121
|
+
*/
|
|
1122
|
+
disableGesture(e, i) {
|
|
1123
|
+
let n = this.disabledGestures.get(e);
|
|
1124
|
+
n || (n = /* @__PURE__ */ new Set(), this.disabledGestures.set(e, n)), n.add(i);
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Enable a previously disabled gesture type
|
|
1128
|
+
*/
|
|
1129
|
+
enableGesture(e, i) {
|
|
1130
|
+
const n = this.disabledGestures.get(e);
|
|
1131
|
+
n && (n.delete(i), n.size === 0 && this.disabledGestures.delete(e));
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Create a gesture through this controller
|
|
1135
|
+
*/
|
|
1136
|
+
createGesture(e, i) {
|
|
1137
|
+
const n = this.newId(), r = i.name || "gesture-" + n, s = i.priority ?? 0;
|
|
1138
|
+
return new _e(this, n, e, r, s, i);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
const ge = new ve();
|
|
1142
|
+
class _e {
|
|
1143
|
+
// Private members
|
|
1144
|
+
el;
|
|
1145
|
+
options;
|
|
1146
|
+
details;
|
|
1147
|
+
minTouches;
|
|
1148
|
+
maxTouches;
|
|
1149
|
+
threshold;
|
|
1150
|
+
direction;
|
|
1151
|
+
lastMoveTime = 0;
|
|
1152
|
+
prevX = 0;
|
|
1153
|
+
prevY = 0;
|
|
1154
|
+
initialDistance = 0;
|
|
1155
|
+
initialAngle = 0;
|
|
1156
|
+
boundOnStart;
|
|
1157
|
+
boundOnMove;
|
|
1158
|
+
boundOnEnd;
|
|
1159
|
+
passive;
|
|
1160
|
+
// future update
|
|
1161
|
+
// private passive: boolean | {onStart: boolean, onMove: boolean, onEnd: boolean};
|
|
1162
|
+
hasPassedThreshold = !1;
|
|
1163
|
+
controller;
|
|
1164
|
+
id;
|
|
1165
|
+
name;
|
|
1166
|
+
priority;
|
|
1167
|
+
useThreshold;
|
|
1168
|
+
constructor(e, i, n, r, s, o) {
|
|
1169
|
+
this.controller = e, this.id = i, this.el = n, this.options = o, this.name = r, this.priority = s * 1e3 + i, this.minTouches = o.minTouches ?? 1, this.maxTouches = o.maxTouches ?? 1 / 0, this.passive = o.passive ?? !0, this.threshold = o.threshold ?? 0, this.direction = o.direction ?? "all", this.useThreshold = this.threshold > 0, this.details = {
|
|
1170
|
+
type: this.name,
|
|
1171
|
+
isTracking: !1,
|
|
1172
|
+
startX: 0,
|
|
1173
|
+
startY: 0,
|
|
1174
|
+
currentX: 0,
|
|
1175
|
+
currentY: 0,
|
|
1176
|
+
deltaX: 0,
|
|
1177
|
+
deltaY: 0,
|
|
1178
|
+
velocityX: 0,
|
|
1179
|
+
velocityY: 0,
|
|
1180
|
+
touchCount: 0,
|
|
1181
|
+
scale: 1,
|
|
1182
|
+
rotation: 0
|
|
1183
|
+
}, this.boundOnStart = this.onStart.bind(this), this.boundOnMove = this.onMove.bind(this), this.boundOnEnd = this.onEnd.bind(this);
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Calculate distance between two touch points
|
|
1187
|
+
*/
|
|
1188
|
+
getDistance(e) {
|
|
1189
|
+
if (e.length < 2) return 0;
|
|
1190
|
+
const i = e[0].clientX - e[1].clientX, n = e[0].clientY - e[1].clientY;
|
|
1191
|
+
return Math.sqrt(i * i + n * n);
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Calculate angle between two touch points in degrees
|
|
1195
|
+
*/
|
|
1196
|
+
getAngle(e) {
|
|
1197
|
+
if (e.length < 2) return 0;
|
|
1198
|
+
const i = e[1].clientX - e[0].clientX, n = e[1].clientY - e[0].clientY;
|
|
1199
|
+
return Math.atan2(n, i) * 180 / Math.PI;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Get center point of all touches
|
|
1203
|
+
*/
|
|
1204
|
+
getCenter(e) {
|
|
1205
|
+
if ("touches" in e) {
|
|
1206
|
+
if (e.touches.length === 0) return { x: 0, y: 0 };
|
|
1207
|
+
let i = 0, n = 0;
|
|
1208
|
+
for (let r = 0; r < e.touches.length; r++)
|
|
1209
|
+
i += e.touches[r].clientX, n += e.touches[r].clientY;
|
|
1210
|
+
return {
|
|
1211
|
+
x: i / e.touches.length,
|
|
1212
|
+
y: n / e.touches.length
|
|
1213
|
+
};
|
|
1214
|
+
} else
|
|
1215
|
+
return { x: e.clientX, y: e.clientY };
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Check if the gesture can start based on touch count
|
|
1219
|
+
*/
|
|
1220
|
+
canStart(e) {
|
|
1221
|
+
const n = "touches" in e ? e.touches.length : 1;
|
|
1222
|
+
return n >= this.minTouches && n <= this.maxTouches && this.controller.canStart(this.name);
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Check if we've moved enough to pass the threshold
|
|
1226
|
+
*/
|
|
1227
|
+
checkThreshold() {
|
|
1228
|
+
if (!this.useThreshold) return !0;
|
|
1229
|
+
const { deltaX: e, deltaY: i } = this.details;
|
|
1230
|
+
return this.direction === "x" ? Math.abs(e) >= this.threshold : this.direction === "y" ? Math.abs(i) >= this.threshold : Math.sqrt(e * e + i * i) >= this.threshold;
|
|
1231
|
+
}
|
|
1232
|
+
onStart(e) {
|
|
1233
|
+
if (!this.canStart(e)) return;
|
|
1234
|
+
const i = "touches" in e, n = this.getCenter(e);
|
|
1235
|
+
this.details.startX = n.x, this.details.startY = n.y, this.details.currentX = n.x, this.details.currentY = n.y, this.details.touchCount = i ? e.touches.length : 1, this.details.event = e, i && e.touches.length >= 2 ? (this.initialDistance = this.getDistance(e.touches), this.initialAngle = this.getAngle(e.touches)) : (this.initialDistance = 0, this.initialAngle = 0), !(this.options.canStart && !this.options.canStart(this.details)) && (this.passive || e.preventDefault(), this.details.isTracking = !0, this.details.deltaX = 0, this.details.deltaY = 0, this.details.velocityX = 0, this.details.velocityY = 0, this.details.scale = 1, this.details.rotation = 0, this.hasPassedThreshold = !this.useThreshold, this.lastMoveTime = Date.now(), this.prevX = n.x, this.prevY = n.y, this.controller.start(this.id, this.name, this.priority), this.useThreshold || this.tryCapture());
|
|
1236
|
+
}
|
|
1237
|
+
onMove(e) {
|
|
1238
|
+
if (!this.details.isTracking) return;
|
|
1239
|
+
this.passive || e.preventDefault();
|
|
1240
|
+
const i = "touches" in e, n = this.getCenter(e), r = Date.now(), s = r - this.lastMoveTime;
|
|
1241
|
+
if (this.details.currentX = n.x, this.details.currentY = n.y, this.details.deltaX = this.details.currentX - this.details.startX, this.details.deltaY = this.details.currentY - this.details.startY, this.details.touchCount = i ? e.touches.length : 1, this.details.event = e, i && e.touches.length >= 2) {
|
|
1242
|
+
const o = this.getDistance(e.touches), a = this.getAngle(e.touches);
|
|
1243
|
+
this.initialDistance > 0 && (this.details.scale = o / this.initialDistance);
|
|
1244
|
+
let l = a - this.initialAngle;
|
|
1245
|
+
l > 180 && (l -= 360), l < -180 && (l += 360), this.details.rotation = l;
|
|
1246
|
+
} else
|
|
1247
|
+
this.details.scale = 1, this.details.rotation = 0;
|
|
1248
|
+
if (s > 0 && (this.details.velocityX = (this.details.currentX - this.prevX) / s, this.details.velocityY = (this.details.currentY - this.prevY) / s), this.prevX = this.details.currentX, this.prevY = this.details.currentY, this.lastMoveTime = r, !this.hasPassedThreshold && this.checkThreshold()) {
|
|
1249
|
+
this.hasPassedThreshold = !0, this.tryCapture();
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
this.hasPassedThreshold && this.options.onMove && this.options.onMove(this.details);
|
|
1253
|
+
}
|
|
1254
|
+
tryCapture() {
|
|
1255
|
+
this.controller.capture(this.id, this.name, this.priority) && this.options.onStart && this.options.onStart(this.details);
|
|
1256
|
+
}
|
|
1257
|
+
onEnd(e) {
|
|
1258
|
+
if (!this.details.isTracking) return;
|
|
1259
|
+
this.passive || e.preventDefault();
|
|
1260
|
+
const i = "touches" in e;
|
|
1261
|
+
this.details.touchCount = i ? e.touches.length : 0, this.details.event = e, this.controller.release(this.id), this.details.isTracking = !1, this.hasPassedThreshold = !this.useThreshold, this.options.onEnd && this.options.onEnd(this.details);
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Public method to initialize the gesture
|
|
1265
|
+
*/
|
|
1266
|
+
init() {
|
|
1267
|
+
if (!this.el) return;
|
|
1268
|
+
const e = { passive: this.passive }, i = { passive: this.passive }, n = { passive: this.passive };
|
|
1269
|
+
this.el.addEventListener("touchstart", this.boundOnStart, e), document.addEventListener("touchmove", this.boundOnMove, i), document.addEventListener("touchend", this.boundOnEnd, n), document.addEventListener("touchcancel", this.boundOnEnd, n), this.el.addEventListener("mousedown", this.boundOnStart, e), document.addEventListener("mousemove", this.boundOnMove, i), document.addEventListener("mouseup", this.boundOnEnd, n), document.addEventListener("mouseleave", this.boundOnEnd, n);
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Public method to clean up the gesture
|
|
1273
|
+
*/
|
|
1274
|
+
destroy() {
|
|
1275
|
+
this.el && (this.el.removeEventListener("touchstart", this.boundOnStart), document.removeEventListener("touchmove", this.boundOnMove), document.removeEventListener("touchend", this.boundOnEnd), document.removeEventListener("touchcancel", this.boundOnEnd), this.el.removeEventListener("mousedown", this.boundOnStart), document.removeEventListener("mousemove", this.boundOnMove), document.removeEventListener("mouseup", this.boundOnEnd), document.removeEventListener("mouseleave", this.boundOnEnd), this.controller.release(this.id));
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
function Xe(t, e) {
|
|
1279
|
+
return ge.createGesture(t, e);
|
|
1280
|
+
}
|
|
1281
|
+
function je(t) {
|
|
1282
|
+
typeof document > "u" || (document.startViewTransition ? document.startViewTransition(t) : t());
|
|
1283
|
+
}
|
|
1284
|
+
let Se = 0;
|
|
1285
|
+
function Ye(t, e = [], i = {
|
|
1286
|
+
duration: 500,
|
|
1287
|
+
namePrefix: "vt"
|
|
1288
|
+
}) {
|
|
1289
|
+
if (!document.startViewTransition) {
|
|
1290
|
+
t();
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
const n = e.map(
|
|
1294
|
+
(s, o) => `${i.namePrefix}-${++Se}-${o}`
|
|
1295
|
+
);
|
|
1296
|
+
e.forEach((s, o) => {
|
|
1297
|
+
s.style.viewTransitionName = n[o];
|
|
1298
|
+
}), document.startViewTransition(() => {
|
|
1299
|
+
t();
|
|
1300
|
+
}).finished.finally(() => {
|
|
1301
|
+
e.forEach((s) => {
|
|
1302
|
+
s.style.viewTransitionName = "";
|
|
1303
|
+
});
|
|
1304
|
+
}), document.documentElement.style.setProperty(
|
|
1305
|
+
"--vt-duration",
|
|
1306
|
+
`${i.duration}ms`
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
export {
|
|
1310
|
+
y as Computed,
|
|
1311
|
+
v as Effect,
|
|
1312
|
+
$e as Fragment,
|
|
1313
|
+
He as FrameScheduler,
|
|
1314
|
+
u as Signal,
|
|
1315
|
+
Ce as batch,
|
|
1316
|
+
Ee as computed,
|
|
1317
|
+
De as createContext,
|
|
1318
|
+
Xe as createGesture,
|
|
1319
|
+
g as effect,
|
|
1320
|
+
Ne as get,
|
|
1321
|
+
Oe as hydrate,
|
|
1322
|
+
xe as link,
|
|
1323
|
+
Ke as onBeforeExit,
|
|
1324
|
+
Ge as onLoad,
|
|
1325
|
+
Le as onMount,
|
|
1326
|
+
Ie as onUnmount,
|
|
1327
|
+
Te as peek,
|
|
1328
|
+
Me as render,
|
|
1329
|
+
Ae as set,
|
|
1330
|
+
we as signal,
|
|
1331
|
+
je as startViewTransition,
|
|
1332
|
+
Pe as suspend,
|
|
1333
|
+
Fe as useContext,
|
|
1334
|
+
Ye as withViewTransition
|
|
1335
|
+
};
|