@manyducks.co/dolla 2.0.0-alpha.32 → 2.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/context.d.ts +21 -22
- package/dist/core/dolla.d.ts +11 -11
- package/dist/index.js +120 -117
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/markup-B3FV_fq9.js +1525 -0
- package/dist/markup-B3FV_fq9.js.map +1 -0
- package/docs/stores.md +15 -14
- package/docs/views.md +4 -4
- package/notes/readme-scratch.md +29 -7
- package/notes/stores.md +6 -8
- package/notes/viewstate.md +15 -0
- package/package.json +1 -1
- package/dist/markup-C-1VlVZi.js +0 -1533
- package/dist/markup-C-1VlVZi.js.map +0 -1
package/dist/markup-C-1VlVZi.js
DELETED
|
@@ -1,1533 +0,0 @@
|
|
|
1
|
-
var It = Object.defineProperty;
|
|
2
|
-
var it = (s) => {
|
|
3
|
-
throw TypeError(s);
|
|
4
|
-
};
|
|
5
|
-
var jt = (s, t, e) => t in s ? It(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
6
|
-
var o = (s, t, e) => jt(s, typeof t != "symbol" ? t + "" : t, e), ot = (s, t, e) => t.has(s) || it("Cannot " + e);
|
|
7
|
-
var O = (s, t, e) => (ot(s, t, "read from private field"), e ? e.call(s) : t.get(s)), P = (s, t, e) => t.has(s) ? it("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), T = (s, t, e, n) => (ot(s, t, "write to private field"), n ? n.call(s, e) : t.set(s, e), e);
|
|
8
|
-
function Mt(s) {
|
|
9
|
-
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
10
|
-
}
|
|
11
|
-
var q = { exports: {} }, ut;
|
|
12
|
-
function Ut() {
|
|
13
|
-
return ut || (ut = 1, function(s, t) {
|
|
14
|
-
Object.defineProperty(t, "__esModule", { value: !0 });
|
|
15
|
-
var e = /* @__PURE__ */ function() {
|
|
16
|
-
function h(a, f) {
|
|
17
|
-
var l = [], d = !0, p = !1, _ = void 0;
|
|
18
|
-
try {
|
|
19
|
-
for (var x, y = a[Symbol.iterator](); !(d = (x = y.next()).done) && (l.push(x.value), !(f && l.length === f)); d = !0) ;
|
|
20
|
-
} catch (w) {
|
|
21
|
-
p = !0, _ = w;
|
|
22
|
-
} finally {
|
|
23
|
-
try {
|
|
24
|
-
!d && y.return && y.return();
|
|
25
|
-
} finally {
|
|
26
|
-
if (p) throw _;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return l;
|
|
30
|
-
}
|
|
31
|
-
return function(a, f) {
|
|
32
|
-
if (Array.isArray(a)) return a;
|
|
33
|
-
if (Symbol.iterator in Object(a)) return h(a, f);
|
|
34
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
35
|
-
};
|
|
36
|
-
}(), n = function(h) {
|
|
37
|
-
return h.reduce(function(a, f) {
|
|
38
|
-
return 16 > f ? a + "0" + f.toString(16) : a + f.toString(16);
|
|
39
|
-
}, "#");
|
|
40
|
-
}, r = function(h, a, f) {
|
|
41
|
-
var l = 0.5 > f ? f * (1 + a) : f + a - f * a, d = 2 * f - l, p = function(w, C, v) {
|
|
42
|
-
var z = Math.round, g = 0 > v ? v + 1 : 1 < v ? v - 1 : v;
|
|
43
|
-
return g = g < 1 / 6 ? w + 6 * (C - w) * g : g < 1 / 2 ? C : g < 2 / 3 ? w + 6 * (C - w) * (2 / 3 - g) : w, z(255 * g);
|
|
44
|
-
}, _ = p(d, l, h + 1 / 3), x = p(d, l, h), y = p(d, l, h - 1 / 3);
|
|
45
|
-
return [_, x, y];
|
|
46
|
-
}, i = function(h, a, f, l) {
|
|
47
|
-
var d = h % 1007 / 1007, p = function(w, C, v) {
|
|
48
|
-
return w * (v - C) + C;
|
|
49
|
-
}, _ = p(d, a.min, a.max), x = p(d, f.min, f.max), y = p(d, l.max, l.min);
|
|
50
|
-
return [_, x, y];
|
|
51
|
-
}, u = function(h) {
|
|
52
|
-
return h.split("").reduce(function(a, f, l) {
|
|
53
|
-
return a * f.charCodeAt(0) * l + 1;
|
|
54
|
-
}, 1);
|
|
55
|
-
}, c = function(h) {
|
|
56
|
-
var a = h.str, f = h.hue, l = f === void 0 ? { min: 0, max: 360 } : f, d = h.sat, p = d === void 0 ? { min: 0.35, max: 0.65 } : d, _ = h.light, x = _ === void 0 ? { min: 0.3, max: 0.7 } : _, y = h.hashFunction, w = y === void 0 ? u : y, C = h.scheme, v = C === void 0 ? "hex" : C, z = i(w(a), l, p, x), g = e(z, 3), et = g[0], nt = g[1], st = g[2], rt = r(et / 360, nt, st), Ft = n(rt);
|
|
57
|
-
return v === "hsl" ? [et, nt, st] : v === "rgb" ? rt : Ft;
|
|
58
|
-
};
|
|
59
|
-
t.default = c, s.exports = t.default;
|
|
60
|
-
}(q, q.exports)), q.exports;
|
|
61
|
-
}
|
|
62
|
-
var Rt = Ut();
|
|
63
|
-
const Dt = /* @__PURE__ */ Mt(Rt);
|
|
64
|
-
function $(s) {
|
|
65
|
-
const t = typeof s;
|
|
66
|
-
switch (t) {
|
|
67
|
-
case "undefined":
|
|
68
|
-
return t;
|
|
69
|
-
case "number":
|
|
70
|
-
return isNaN(s) ? "NaN" : t;
|
|
71
|
-
case "function":
|
|
72
|
-
return /^\s*class\s+/.test(s.toString()) ? "class" : t;
|
|
73
|
-
case "object":
|
|
74
|
-
return s === null ? "null" : s instanceof Promise ? "promise" : s instanceof Map ? "map" : s instanceof Set ? "set" : Array.isArray(s) ? "array" : t;
|
|
75
|
-
default:
|
|
76
|
-
return t;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function A(s) {
|
|
80
|
-
return Array.isArray(s);
|
|
81
|
-
}
|
|
82
|
-
function bt(...s) {
|
|
83
|
-
const t = s[0], e = (n) => A(n) && n.every((r) => t(r));
|
|
84
|
-
return s.length < 2 ? e : e(s[1]);
|
|
85
|
-
}
|
|
86
|
-
function ye(...s) {
|
|
87
|
-
const t = s[0], e = k(s[2]) ? s[2] : "Expected an array of valid items. Got type: %t, value: %v", n = (r) => {
|
|
88
|
-
if (A(r) && r.every((i) => t(i)))
|
|
89
|
-
return !0;
|
|
90
|
-
throw new TypeError(R(r, e));
|
|
91
|
-
};
|
|
92
|
-
return s.length < 2 ? n : n(s[1]);
|
|
93
|
-
}
|
|
94
|
-
function k(s) {
|
|
95
|
-
return typeof s == "string";
|
|
96
|
-
}
|
|
97
|
-
function ve(s, t) {
|
|
98
|
-
if (k(s))
|
|
99
|
-
return !0;
|
|
100
|
-
throw new TypeError(R(s, t ?? "Expected a string. Got type: %t, value: %v"));
|
|
101
|
-
}
|
|
102
|
-
function V(s) {
|
|
103
|
-
return typeof s == "function" && !Gt(s);
|
|
104
|
-
}
|
|
105
|
-
function zt(s) {
|
|
106
|
-
return typeof s == "number" && !isNaN(s);
|
|
107
|
-
}
|
|
108
|
-
function Gt(s) {
|
|
109
|
-
return typeof s == "function" && /^\s*class\s+/.test(s.toString());
|
|
110
|
-
}
|
|
111
|
-
function Se(...s) {
|
|
112
|
-
const t = s[0], e = k(s[2]) ? s[2] : `Expected instance of ${t.name}. Got type: %t, value: %v`, n = (r) => {
|
|
113
|
-
if (r instanceof t)
|
|
114
|
-
return !0;
|
|
115
|
-
throw new TypeError(R(r, e));
|
|
116
|
-
};
|
|
117
|
-
return s.length < 2 ? n : n(s[1]);
|
|
118
|
-
}
|
|
119
|
-
function Z(s) {
|
|
120
|
-
return s != null && typeof s == "object" && !A(s);
|
|
121
|
-
}
|
|
122
|
-
function Ce(s, t) {
|
|
123
|
-
if (Z(s))
|
|
124
|
-
return !0;
|
|
125
|
-
throw new TypeError(R(s, t));
|
|
126
|
-
}
|
|
127
|
-
function R(s, t) {
|
|
128
|
-
var r;
|
|
129
|
-
const e = $(s), n = ((r = s == null ? void 0 : s.toString) == null ? void 0 : r.call(s)) || String(s);
|
|
130
|
-
return t.replaceAll("%t", e).replaceAll("%v", n);
|
|
131
|
-
}
|
|
132
|
-
var G, ct;
|
|
133
|
-
function Kt() {
|
|
134
|
-
return ct || (ct = 1, G = function s(t, e) {
|
|
135
|
-
if (t === e) return !0;
|
|
136
|
-
if (t && e && typeof t == "object" && typeof e == "object") {
|
|
137
|
-
if (t.constructor !== e.constructor) return !1;
|
|
138
|
-
var n, r, i;
|
|
139
|
-
if (Array.isArray(t)) {
|
|
140
|
-
if (n = t.length, n != e.length) return !1;
|
|
141
|
-
for (r = n; r-- !== 0; )
|
|
142
|
-
if (!s(t[r], e[r])) return !1;
|
|
143
|
-
return !0;
|
|
144
|
-
}
|
|
145
|
-
if (t instanceof Map && e instanceof Map) {
|
|
146
|
-
if (t.size !== e.size) return !1;
|
|
147
|
-
for (r of t.entries())
|
|
148
|
-
if (!e.has(r[0])) return !1;
|
|
149
|
-
for (r of t.entries())
|
|
150
|
-
if (!s(r[1], e.get(r[0]))) return !1;
|
|
151
|
-
return !0;
|
|
152
|
-
}
|
|
153
|
-
if (t instanceof Set && e instanceof Set) {
|
|
154
|
-
if (t.size !== e.size) return !1;
|
|
155
|
-
for (r of t.entries())
|
|
156
|
-
if (!e.has(r[0])) return !1;
|
|
157
|
-
return !0;
|
|
158
|
-
}
|
|
159
|
-
if (ArrayBuffer.isView(t) && ArrayBuffer.isView(e)) {
|
|
160
|
-
if (n = t.length, n != e.length) return !1;
|
|
161
|
-
for (r = n; r-- !== 0; )
|
|
162
|
-
if (t[r] !== e[r]) return !1;
|
|
163
|
-
return !0;
|
|
164
|
-
}
|
|
165
|
-
if (t.constructor === RegExp) return t.source === e.source && t.flags === e.flags;
|
|
166
|
-
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === e.valueOf();
|
|
167
|
-
if (t.toString !== Object.prototype.toString) return t.toString() === e.toString();
|
|
168
|
-
if (i = Object.keys(t), n = i.length, n !== Object.keys(e).length) return !1;
|
|
169
|
-
for (r = n; r-- !== 0; )
|
|
170
|
-
if (!Object.prototype.hasOwnProperty.call(e, i[r])) return !1;
|
|
171
|
-
for (r = n; r-- !== 0; ) {
|
|
172
|
-
var u = i[r];
|
|
173
|
-
if (!s(t[u], e[u])) return !1;
|
|
174
|
-
}
|
|
175
|
-
return !0;
|
|
176
|
-
}
|
|
177
|
-
return t !== t && e !== e;
|
|
178
|
-
}), G;
|
|
179
|
-
}
|
|
180
|
-
var Bt = Kt();
|
|
181
|
-
const Ht = /* @__PURE__ */ Mt(Bt), Zt = () => {
|
|
182
|
-
};
|
|
183
|
-
let K = 1;
|
|
184
|
-
function kt() {
|
|
185
|
-
return K = K % Number.MAX_SAFE_INTEGER + 1, K.toString(36) + Date.now().toString(36);
|
|
186
|
-
}
|
|
187
|
-
function Et(s, t) {
|
|
188
|
-
return Object.is(s, t);
|
|
189
|
-
}
|
|
190
|
-
function xe(s, t) {
|
|
191
|
-
if (Object.is(s, t)) return !0;
|
|
192
|
-
const e = $(s);
|
|
193
|
-
if (e !== $(t))
|
|
194
|
-
return !1;
|
|
195
|
-
switch (e) {
|
|
196
|
-
case "object":
|
|
197
|
-
let n = 0;
|
|
198
|
-
for (const r in s) {
|
|
199
|
-
if (s[r] !== t[r]) return !1;
|
|
200
|
-
n++;
|
|
201
|
-
}
|
|
202
|
-
return Object.keys(t).length === n;
|
|
203
|
-
case "array":
|
|
204
|
-
if (s.length !== t.length) return !1;
|
|
205
|
-
for (let r = 0; r < s.length; r++)
|
|
206
|
-
if (s[r] !== t[r]) return !1;
|
|
207
|
-
return !0;
|
|
208
|
-
case "map":
|
|
209
|
-
if (s.size !== t.size) return !1;
|
|
210
|
-
for (const r of s.keys())
|
|
211
|
-
if (s[r] !== t[r]) return !1;
|
|
212
|
-
return !0;
|
|
213
|
-
case "set":
|
|
214
|
-
if (V(s.symmetricDifference))
|
|
215
|
-
return s.symmetricDifference(t).size === 0;
|
|
216
|
-
for (const r of s.keys())
|
|
217
|
-
if (s[r] !== t.get(r)) return !1;
|
|
218
|
-
return !0;
|
|
219
|
-
}
|
|
220
|
-
return !1;
|
|
221
|
-
}
|
|
222
|
-
const Me = Ht;
|
|
223
|
-
function Yt(s, t) {
|
|
224
|
-
const e = (n) => {
|
|
225
|
-
const r = {};
|
|
226
|
-
for (const i in n)
|
|
227
|
-
s.includes(i) || (r[i] = n[i]);
|
|
228
|
-
return r;
|
|
229
|
-
};
|
|
230
|
-
return t == null ? e : e(t);
|
|
231
|
-
}
|
|
232
|
-
function be(s) {
|
|
233
|
-
return Dt({
|
|
234
|
-
str: s,
|
|
235
|
-
sat: { min: 0.35, max: 0.55 },
|
|
236
|
-
light: { min: 0.6, max: 0.6 }
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
function ke(s) {
|
|
240
|
-
if (s instanceof RegExp)
|
|
241
|
-
return (n) => s.test(n);
|
|
242
|
-
const t = {
|
|
243
|
-
positive: [],
|
|
244
|
-
negative: []
|
|
245
|
-
}, e = s.split(",").map((n) => n.trim()).filter((n) => n !== "");
|
|
246
|
-
for (let n of e) {
|
|
247
|
-
let r = "positive";
|
|
248
|
-
n.startsWith("-") && (r = "negative", n = n.slice(1)), n === "*" ? t[r].push(function() {
|
|
249
|
-
return !0;
|
|
250
|
-
}) : n.endsWith("*") ? t[r].push(function(i) {
|
|
251
|
-
return i.startsWith(n.slice(0, n.length - 1));
|
|
252
|
-
}) : t[r].push(function(i) {
|
|
253
|
-
return i === n;
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return function(n) {
|
|
257
|
-
const { positive: r, negative: i } = t;
|
|
258
|
-
return !(i.some((u) => u(n)) || r.length > 0 && !r.some((u) => u(n)));
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
var Xt = Object.defineProperty, Jt = (s, t, e) => t in s ? Xt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, at = (s, t, e) => Jt(s, typeof t != "symbol" ? t + "" : t, e);
|
|
262
|
-
class I {
|
|
263
|
-
constructor() {
|
|
264
|
-
at(this, "_l", /* @__PURE__ */ new Map()), at(this, "_a", (t) => {
|
|
265
|
-
if (typeof t != "string" && !(t instanceof Symbol))
|
|
266
|
-
throw new TypeError("Emitter: eventName should be a string or symbol");
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
emit(t, ...e) {
|
|
270
|
-
let n = this.listeners(t);
|
|
271
|
-
for (const r of n)
|
|
272
|
-
try {
|
|
273
|
-
r(...e);
|
|
274
|
-
} catch (i) {
|
|
275
|
-
let u = this._l.get("error");
|
|
276
|
-
if (u != null && u.length)
|
|
277
|
-
for (const c of u)
|
|
278
|
-
c(i, t, r, ...e);
|
|
279
|
-
else throw i;
|
|
280
|
-
}
|
|
281
|
-
return t != "*" && this.emit("*", t, ...e) || n.length > 0;
|
|
282
|
-
}
|
|
283
|
-
on(t, e) {
|
|
284
|
-
return this.listeners(t).push(e), this;
|
|
285
|
-
}
|
|
286
|
-
off(t, e) {
|
|
287
|
-
const n = this.listeners(t);
|
|
288
|
-
return n.splice(n.indexOf(e), 1), this;
|
|
289
|
-
}
|
|
290
|
-
once(t, e) {
|
|
291
|
-
return this.on(t, (...n) => {
|
|
292
|
-
e(...n), this.off(t, e);
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
clear() {
|
|
296
|
-
this._l.clear();
|
|
297
|
-
}
|
|
298
|
-
listeners(t) {
|
|
299
|
-
return this._l.get(t) ?? (this._a(t), this._l.set(t, []).get(t));
|
|
300
|
-
}
|
|
301
|
-
events() {
|
|
302
|
-
return [...this._l.entries()].filter(([, t]) => t.length).map(([t]) => t);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
var L, E;
|
|
306
|
-
class Ee {
|
|
307
|
-
constructor(t) {
|
|
308
|
-
// #dolla;
|
|
309
|
-
P(this, L);
|
|
310
|
-
P(this, E);
|
|
311
|
-
T(this, L, t.createLogger("Dolla.stats")), T(this, E, W());
|
|
312
|
-
let e;
|
|
313
|
-
O(this, E).emitter.on("statsChanged", () => {
|
|
314
|
-
e && clearTimeout(e), e = setTimeout(() => {
|
|
315
|
-
O(this, L).info(O(this, E).stats);
|
|
316
|
-
}, 200);
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
L = new WeakMap(), E = new WeakMap();
|
|
321
|
-
const B = Symbol.for("DollaStatsStore");
|
|
322
|
-
function ht() {
|
|
323
|
-
const s = new I(), t = {
|
|
324
|
-
watcherCount: 0,
|
|
325
|
-
viewCount: 0
|
|
326
|
-
};
|
|
327
|
-
return s.on("_incrementViewCount", (e) => {
|
|
328
|
-
t.viewCount += e, s.emit("statsChanged");
|
|
329
|
-
}), s.on("_incrementWatcherCount", (e) => {
|
|
330
|
-
t.watcherCount += e, s.emit("statsChanged");
|
|
331
|
-
}), { emitter: s, stats: t };
|
|
332
|
-
}
|
|
333
|
-
function W() {
|
|
334
|
-
return typeof window < "u" ? (window[B] || (window[B] = ht()), window[B]) : ht();
|
|
335
|
-
}
|
|
336
|
-
function At() {
|
|
337
|
-
W().emitter.emit("_incrementWatcherCount", 1);
|
|
338
|
-
}
|
|
339
|
-
function Ot() {
|
|
340
|
-
W().emitter.emit("_incrementWatcherCount", -1);
|
|
341
|
-
}
|
|
342
|
-
function Qt() {
|
|
343
|
-
W().emitter.emit("_incrementViewCount", 1);
|
|
344
|
-
}
|
|
345
|
-
function te() {
|
|
346
|
-
W().emitter.emit("_incrementViewCount", -1);
|
|
347
|
-
}
|
|
348
|
-
const $t = Symbol.for("DollaState"), Vt = Symbol.for("DollaRef"), Lt = Symbol.for("DollaMarkup"), M = Symbol.for("DollaMarkupElement"), Ae = Symbol.for("DollaRouter");
|
|
349
|
-
function m(s) {
|
|
350
|
-
return (s == null ? void 0 : s[$t]) === !0;
|
|
351
|
-
}
|
|
352
|
-
function ee(s) {
|
|
353
|
-
return m(s) ? s.get() : s;
|
|
354
|
-
}
|
|
355
|
-
function Y(s) {
|
|
356
|
-
return m(s) ? s : new X({
|
|
357
|
-
get() {
|
|
358
|
-
return s;
|
|
359
|
-
},
|
|
360
|
-
watch(t, e = {}) {
|
|
361
|
-
return e != null && e.lazy || t(s), Zt;
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
class ne {
|
|
366
|
-
constructor(t, e) {
|
|
367
|
-
o(this, "value");
|
|
368
|
-
o(this, "watchers", []);
|
|
369
|
-
o(this, "equals", Et);
|
|
370
|
-
this.value = t, e != null && e.equals && (this.equals = e.equals);
|
|
371
|
-
}
|
|
372
|
-
get() {
|
|
373
|
-
return this.value;
|
|
374
|
-
}
|
|
375
|
-
set(t) {
|
|
376
|
-
if (typeof t == "function" && (t = t(this.value)), !this.equals(t, this.value)) {
|
|
377
|
-
this.value = t;
|
|
378
|
-
try {
|
|
379
|
-
for (const e of this.watchers)
|
|
380
|
-
e(t);
|
|
381
|
-
} catch (e) {
|
|
382
|
-
throw console.error("Error in watcher", e), e;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
watch(t, e) {
|
|
387
|
-
return this.watchers.push(t), e != null && e.lazy || t(this.value), At(), () => {
|
|
388
|
-
const n = this.watchers.indexOf(t);
|
|
389
|
-
n > -1 && this.watchers.splice(n, 1), Ot();
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
var mt;
|
|
394
|
-
mt = $t;
|
|
395
|
-
class X {
|
|
396
|
-
constructor(t) {
|
|
397
|
-
o(this, mt, !0);
|
|
398
|
-
o(this, "__value");
|
|
399
|
-
this.__value = t;
|
|
400
|
-
}
|
|
401
|
-
get() {
|
|
402
|
-
return this.__value.get();
|
|
403
|
-
}
|
|
404
|
-
watch(t, e) {
|
|
405
|
-
return this.__value.watch(t, e);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
function H(s, t) {
|
|
409
|
-
const e = new ne(s, t);
|
|
410
|
-
return [new X(e), (r) => e.set(r)];
|
|
411
|
-
}
|
|
412
|
-
const lt = Symbol("EMPTY");
|
|
413
|
-
class se {
|
|
414
|
-
constructor(t, e, n) {
|
|
415
|
-
o(this, "equals", Et);
|
|
416
|
-
/**
|
|
417
|
-
* Array of states this holder's value is derived from.
|
|
418
|
-
*/
|
|
419
|
-
o(this, "sources", []);
|
|
420
|
-
/**
|
|
421
|
-
* The function that does the deriving. Receives source values and returns a derived value.
|
|
422
|
-
*/
|
|
423
|
-
o(this, "fn");
|
|
424
|
-
/**
|
|
425
|
-
*
|
|
426
|
-
*/
|
|
427
|
-
o(this, "sourceWatcher", D());
|
|
428
|
-
/**
|
|
429
|
-
* Array of functions awaiting notification when this holder's value changes.
|
|
430
|
-
*/
|
|
431
|
-
o(this, "watchers", []);
|
|
432
|
-
/**
|
|
433
|
-
* True when this holder is actively watching sources.
|
|
434
|
-
*/
|
|
435
|
-
o(this, "isWatchingSources", !1);
|
|
436
|
-
/**
|
|
437
|
-
* Latest values as received from sources.
|
|
438
|
-
*/
|
|
439
|
-
o(this, "previousSourceValues");
|
|
440
|
-
/**
|
|
441
|
-
* The current value as returned from `fn` (may be a State)
|
|
442
|
-
*/
|
|
443
|
-
o(this, "value", lt);
|
|
444
|
-
/**
|
|
445
|
-
* The current unwrapped value.
|
|
446
|
-
*/
|
|
447
|
-
o(this, "rawValue");
|
|
448
|
-
/**
|
|
449
|
-
* When value is a State, this function will stop watching its value.
|
|
450
|
-
*/
|
|
451
|
-
o(this, "stopWatchingCurrentValue");
|
|
452
|
-
this.sources = t.map(Y), this.fn = e, n != null && n.equals && (this.equals = n.equals), this.previousSourceValues = new Array(t.length).fill(lt, 0, t.length);
|
|
453
|
-
}
|
|
454
|
-
/*==========================*\
|
|
455
|
-
|| "Public" methods ||
|
|
456
|
-
\*==========================*/
|
|
457
|
-
get() {
|
|
458
|
-
return this.getValue();
|
|
459
|
-
}
|
|
460
|
-
watch(t, e) {
|
|
461
|
-
this.isWatchingSources || this.startWatchingSources();
|
|
462
|
-
const n = this.watchers;
|
|
463
|
-
return n.push(t), e != null && e.lazy || t(this.rawValue), At(), () => {
|
|
464
|
-
n.splice(n.indexOf(t), 1), this.isWatchingSources && n.length === 0 && this.stopWatchingSources(), Ot();
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
/*==========================*\
|
|
468
|
-
|| Internal ||
|
|
469
|
-
\*==========================*/
|
|
470
|
-
notify(t) {
|
|
471
|
-
for (const e of this.watchers)
|
|
472
|
-
e(t);
|
|
473
|
-
}
|
|
474
|
-
update() {
|
|
475
|
-
const t = this.sources, e = this.previousSourceValues;
|
|
476
|
-
let n = !1, r;
|
|
477
|
-
for (let i = 0; i < t.length; i++)
|
|
478
|
-
r = t[i].get(), !n && !this.equals(r, e[i]) && (n = !0), e[i] = r;
|
|
479
|
-
n && this.setValue(this.fn(...e));
|
|
480
|
-
}
|
|
481
|
-
getValue() {
|
|
482
|
-
return this.isWatchingSources || this.update(), this.rawValue;
|
|
483
|
-
}
|
|
484
|
-
setValue(t) {
|
|
485
|
-
this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.value = t, this.rawValue = ee(t), this.isWatchingSources && m(t) ? this.stopWatchingCurrentValue = t.watch((e) => {
|
|
486
|
-
this.rawValue = e, this.notify(e);
|
|
487
|
-
}) : this.notify(this.rawValue);
|
|
488
|
-
}
|
|
489
|
-
startWatchingSources() {
|
|
490
|
-
const t = this.previousSourceValues;
|
|
491
|
-
for (let n = 0; n < this.sources.length; n++)
|
|
492
|
-
this.sourceWatcher.watch([this.sources[n]], (r) => {
|
|
493
|
-
if (t[n] = r, this.isWatchingSources) {
|
|
494
|
-
const i = this.fn(...t);
|
|
495
|
-
this.equals(i, this.value) || this.setValue(i);
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
this.isWatchingSources = !0;
|
|
499
|
-
const e = this.fn(...t);
|
|
500
|
-
this.equals(e, this.value) || this.setValue(e);
|
|
501
|
-
}
|
|
502
|
-
stopWatchingSources() {
|
|
503
|
-
this.sourceWatcher.stopAll(), this.stopWatchingCurrentValue && (this.stopWatchingCurrentValue(), this.stopWatchingCurrentValue = void 0), this.isWatchingSources = !1;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
function re(s, t, e) {
|
|
507
|
-
const n = new se(s, t, e);
|
|
508
|
-
return new X(n);
|
|
509
|
-
}
|
|
510
|
-
function D() {
|
|
511
|
-
const s = [];
|
|
512
|
-
return {
|
|
513
|
-
watch(t, e) {
|
|
514
|
-
if (t.length === 0)
|
|
515
|
-
throw new TypeError("Expected at least one state to watch.");
|
|
516
|
-
t = t.map(Y);
|
|
517
|
-
let n;
|
|
518
|
-
return t.length > 1 ? n = re(t, e).watch(() => null) : n = t[0].watch(e), s.push(n), () => {
|
|
519
|
-
let r = s.indexOf(n);
|
|
520
|
-
r > -1 && s.splice(r, 1), n();
|
|
521
|
-
};
|
|
522
|
-
},
|
|
523
|
-
stopAll() {
|
|
524
|
-
for (; s.length > 0; )
|
|
525
|
-
s.pop()();
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
function Oe(s) {
|
|
530
|
-
function t() {
|
|
531
|
-
if (arguments.length === 1)
|
|
532
|
-
s = arguments[0];
|
|
533
|
-
else if (arguments.length > 1)
|
|
534
|
-
throw new Error(`Too many arguments. Expected 0 or 1. Got: ${arguments.length}`);
|
|
535
|
-
return s;
|
|
536
|
-
}
|
|
537
|
-
return t[Vt] = !0, t;
|
|
538
|
-
}
|
|
539
|
-
function ie(s) {
|
|
540
|
-
return (s == null ? void 0 : s[Vt]) === !0;
|
|
541
|
-
}
|
|
542
|
-
function $e(s, t) {
|
|
543
|
-
return t.outlet();
|
|
544
|
-
}
|
|
545
|
-
function oe(s) {
|
|
546
|
-
for (var t, e, n = arguments, r = 1, i = "", u = "", c = [0], h = function(l) {
|
|
547
|
-
r === 1 && (l || (i = i.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? c.push(l ? n[l] : i) : r === 3 && (l || i) ? (c[1] = l ? n[l] : i, r = 2) : r === 2 && i === "..." && l ? c[2] = Object.assign(c[2] || {}, n[l]) : r === 2 && i && !l ? (c[2] = c[2] || {})[i] = !0 : r >= 5 && (r === 5 ? ((c[2] = c[2] || {})[e] = l ? i ? i + n[l] : n[l] : i, r = 6) : (l || i) && (c[2][e] += l ? i + n[l] : i)), i = "";
|
|
548
|
-
}, a = 0; a < s.length; a++) {
|
|
549
|
-
a && (r === 1 && h(), h(a));
|
|
550
|
-
for (var f = 0; f < s[a].length; f++) t = s[a][f], r === 1 ? t === "<" ? (h(), c = [c, "", null], r = 3) : i += t : r === 4 ? i === "--" && t === ">" ? (r = 1, i = "") : i = t + i[0] : u ? t === u ? u = "" : i += t : t === '"' || t === "'" ? u = t : t === ">" ? (h(), r = 1) : r && (t === "=" ? (r = 5, e = i, i = "") : t === "/" && (r < 5 || s[a][f + 1] === ">") ? (h(), r === 3 && (c = c[0]), r = c, (c = c[0]).push(this.apply(null, r.slice(1))), r = 0) : t === " " || t === " " || t === `
|
|
551
|
-
` || t === "\r" ? (h(), r = 2) : i += t), r === 3 && i === "!--" && (r = 4, c = c[0]);
|
|
552
|
-
}
|
|
553
|
-
return h(), c.length > 2 ? c.slice(1) : c[1];
|
|
554
|
-
}
|
|
555
|
-
var _t;
|
|
556
|
-
_t = M;
|
|
557
|
-
class ft {
|
|
558
|
-
constructor(t) {
|
|
559
|
-
o(this, _t, !0);
|
|
560
|
-
o(this, "node");
|
|
561
|
-
this.node = t;
|
|
562
|
-
}
|
|
563
|
-
get isMounted() {
|
|
564
|
-
return this.node.parentNode != null;
|
|
565
|
-
}
|
|
566
|
-
mount(t, e) {
|
|
567
|
-
t.insertBefore(this.node, (e == null ? void 0 : e.nextSibling) ?? null);
|
|
568
|
-
}
|
|
569
|
-
unmount(t = !1) {
|
|
570
|
-
this.node.parentNode && !t && this.node.parentNode.removeChild(this.node);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
const ue = (s) => /^on[A-Z]/.test(s);
|
|
574
|
-
var wt;
|
|
575
|
-
wt = M;
|
|
576
|
-
class ce {
|
|
577
|
-
constructor({ tag: t, props: e, children: n, elementContext: r }) {
|
|
578
|
-
o(this, wt, !0);
|
|
579
|
-
o(this, "node");
|
|
580
|
-
o(this, "props");
|
|
581
|
-
o(this, "childMarkup", []);
|
|
582
|
-
o(this, "children", []);
|
|
583
|
-
o(this, "stopCallbacks", []);
|
|
584
|
-
o(this, "elementContext");
|
|
585
|
-
o(this, "uniqueId", kt());
|
|
586
|
-
o(this, "_batchWrite");
|
|
587
|
-
// Track the ref so we can nullify it on unmount.
|
|
588
|
-
o(this, "ref");
|
|
589
|
-
// Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
|
|
590
|
-
o(this, "canClickAway", !1);
|
|
591
|
-
if (r = { ...r }, this._batchWrite = r.root.batch.write.bind(r.root.batch), t.toLowerCase() === "svg" && (r.isSVG = !0), r.isSVG ? this.node = document.createElementNS("http://www.w3.org/2000/svg", t) : this.node = document.createElement(t), e.ref)
|
|
592
|
-
if (ie(e.ref))
|
|
593
|
-
this.ref = e.ref, this.ref(this.node);
|
|
594
|
-
else
|
|
595
|
-
throw new Error("Expected ref to be a function. Got: " + e.ref);
|
|
596
|
-
this.props = {
|
|
597
|
-
...Yt(["ref", "class", "className"], e),
|
|
598
|
-
class: e.className ?? e.class
|
|
599
|
-
}, n && (this.childMarkup = n), this.elementContext = r, this.children = b(this.elementContext, this.childMarkup);
|
|
600
|
-
}
|
|
601
|
-
get isMounted() {
|
|
602
|
-
return this.node.parentNode != null;
|
|
603
|
-
}
|
|
604
|
-
mount(t, e) {
|
|
605
|
-
if (t == null)
|
|
606
|
-
throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${t}`);
|
|
607
|
-
if (!this.isMounted) {
|
|
608
|
-
for (let n = 0; n < this.children.length; n++) {
|
|
609
|
-
const r = this.children[n], i = n > 0 ? this.children[n - 1].node : void 0;
|
|
610
|
-
r.mount(this.node, i);
|
|
611
|
-
}
|
|
612
|
-
this.applyProps(this.node, this.props), this.props.style && this.applyStyles(this.node, this.props.style, this.stopCallbacks), this.props.class && this.applyClasses(this.node, this.props.class, this.stopCallbacks);
|
|
613
|
-
}
|
|
614
|
-
t.insertBefore(this.node, (e == null ? void 0 : e.nextSibling) ?? null), setTimeout(() => {
|
|
615
|
-
this.canClickAway = !0;
|
|
616
|
-
}, 0);
|
|
617
|
-
}
|
|
618
|
-
unmount(t = !1) {
|
|
619
|
-
var e;
|
|
620
|
-
if (this.isMounted) {
|
|
621
|
-
for (const n of this.children)
|
|
622
|
-
n.unmount(!0);
|
|
623
|
-
t || (e = this.node.parentNode) == null || e.removeChild(this.node), this.ref && this.ref(void 0), this.canClickAway = !1;
|
|
624
|
-
for (const n of this.stopCallbacks)
|
|
625
|
-
n();
|
|
626
|
-
this.stopCallbacks = [];
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
getUpdateKey(t, e) {
|
|
630
|
-
return `${this.uniqueId}:${t}:${e}`;
|
|
631
|
-
}
|
|
632
|
-
_mutate(t, e) {
|
|
633
|
-
this.isMounted ? this._batchWrite(t, e) : t();
|
|
634
|
-
}
|
|
635
|
-
attachProp(t, e, n) {
|
|
636
|
-
m(t) ? this.stopCallbacks.push(
|
|
637
|
-
t.watch((r) => {
|
|
638
|
-
this._mutate(() => e(r), n);
|
|
639
|
-
})
|
|
640
|
-
) : this._mutate(() => e(t), n);
|
|
641
|
-
}
|
|
642
|
-
applyProps(t, e) {
|
|
643
|
-
for (const n in e) {
|
|
644
|
-
const r = e[n];
|
|
645
|
-
if (n === "attributes") {
|
|
646
|
-
const i = r;
|
|
647
|
-
for (const u in i)
|
|
648
|
-
this.attachProp(
|
|
649
|
-
i[u],
|
|
650
|
-
(c) => {
|
|
651
|
-
c == null ? t.removeAttribute(u) : t.setAttribute(u, String(c));
|
|
652
|
-
},
|
|
653
|
-
this.getUpdateKey("attr", u)
|
|
654
|
-
);
|
|
655
|
-
} else if (n === "eventListeners") {
|
|
656
|
-
const i = r;
|
|
657
|
-
for (const u in i) {
|
|
658
|
-
const c = m(r) ? (h) => r.get()(h) : r;
|
|
659
|
-
t.addEventListener(u, c), this.stopCallbacks.push(() => {
|
|
660
|
-
t.removeEventListener(u, c);
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
} else if (n === "onClickOutside" || n === "onclickoutside") {
|
|
664
|
-
const i = (c) => {
|
|
665
|
-
this.canClickAway && !t.contains(c.target) && (m(r) ? r.get()(c) : r(c));
|
|
666
|
-
}, u = { capture: !0 };
|
|
667
|
-
window.addEventListener("click", i, u), this.stopCallbacks.push(() => {
|
|
668
|
-
window.removeEventListener("click", i, u);
|
|
669
|
-
});
|
|
670
|
-
} else if (ue(n)) {
|
|
671
|
-
const i = n.slice(2).toLowerCase(), u = m(r) ? (c) => r.get()(c) : r;
|
|
672
|
-
t.addEventListener(i, u), this.stopCallbacks.push(() => {
|
|
673
|
-
t.removeEventListener(i, u);
|
|
674
|
-
});
|
|
675
|
-
} else if (n.includes("-"))
|
|
676
|
-
this.attachProp(
|
|
677
|
-
r,
|
|
678
|
-
(i) => {
|
|
679
|
-
i == null ? t.removeAttribute(n) : t.setAttribute(n, String(i));
|
|
680
|
-
},
|
|
681
|
-
this.getUpdateKey("attr", n)
|
|
682
|
-
);
|
|
683
|
-
else if (!ae.includes(n))
|
|
684
|
-
if (this.elementContext.isSVG)
|
|
685
|
-
this.attachProp(
|
|
686
|
-
r,
|
|
687
|
-
(i) => {
|
|
688
|
-
i != null ? t.setAttribute(n, String(e[n])) : t.removeAttribute(n);
|
|
689
|
-
},
|
|
690
|
-
this.getUpdateKey("attr", n)
|
|
691
|
-
);
|
|
692
|
-
else
|
|
693
|
-
switch (n) {
|
|
694
|
-
case "contentEditable":
|
|
695
|
-
case "value":
|
|
696
|
-
this.attachProp(
|
|
697
|
-
r,
|
|
698
|
-
(i) => {
|
|
699
|
-
t[n] = String(i);
|
|
700
|
-
},
|
|
701
|
-
this.getUpdateKey("prop", n)
|
|
702
|
-
);
|
|
703
|
-
break;
|
|
704
|
-
case "for":
|
|
705
|
-
this.attachProp(
|
|
706
|
-
r,
|
|
707
|
-
(i) => {
|
|
708
|
-
t.htmlFor = i;
|
|
709
|
-
},
|
|
710
|
-
this.getUpdateKey("prop", "htmlFor")
|
|
711
|
-
);
|
|
712
|
-
break;
|
|
713
|
-
case "checked":
|
|
714
|
-
this.attachProp(
|
|
715
|
-
r,
|
|
716
|
-
(i) => {
|
|
717
|
-
t.checked = i, i ? t.setAttribute("checked", "") : t.removeAttribute("checked");
|
|
718
|
-
},
|
|
719
|
-
this.getUpdateKey("prop", "checked")
|
|
720
|
-
);
|
|
721
|
-
break;
|
|
722
|
-
// Attribute-aliased props
|
|
723
|
-
case "exportParts":
|
|
724
|
-
case "part":
|
|
725
|
-
case "translate":
|
|
726
|
-
case "type":
|
|
727
|
-
case "title": {
|
|
728
|
-
const i = n.toLowerCase();
|
|
729
|
-
this.attachProp(
|
|
730
|
-
r,
|
|
731
|
-
(u) => {
|
|
732
|
-
u == null ? t.removeAttribute(i) : t.setAttribute(i, String(u));
|
|
733
|
-
},
|
|
734
|
-
this.getUpdateKey("attr", i)
|
|
735
|
-
);
|
|
736
|
-
break;
|
|
737
|
-
}
|
|
738
|
-
case "autocomplete":
|
|
739
|
-
case "autocapitalize":
|
|
740
|
-
this.attachProp(
|
|
741
|
-
r,
|
|
742
|
-
(i) => {
|
|
743
|
-
typeof i == "string" ? t.autocomplete = i : i ? t.autocomplete = "on" : t.autocomplete = "off";
|
|
744
|
-
},
|
|
745
|
-
this.getUpdateKey("prop", n)
|
|
746
|
-
);
|
|
747
|
-
break;
|
|
748
|
-
default: {
|
|
749
|
-
this.attachProp(
|
|
750
|
-
r,
|
|
751
|
-
(i) => {
|
|
752
|
-
t[n] = i;
|
|
753
|
-
},
|
|
754
|
-
this.getUpdateKey("prop", n)
|
|
755
|
-
);
|
|
756
|
-
break;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
applyStyles(t, e, n) {
|
|
762
|
-
const r = [];
|
|
763
|
-
if (m(e)) {
|
|
764
|
-
let i;
|
|
765
|
-
const u = e.watch((c) => {
|
|
766
|
-
this._mutate(
|
|
767
|
-
() => {
|
|
768
|
-
V(i) && i(), t.style.cssText = "", i = this.applyStyles(t, c, n);
|
|
769
|
-
},
|
|
770
|
-
this.getUpdateKey("styles", "*")
|
|
771
|
-
);
|
|
772
|
-
});
|
|
773
|
-
n.push(u), r.push(u);
|
|
774
|
-
} else {
|
|
775
|
-
const i = Wt(e);
|
|
776
|
-
for (const u in i) {
|
|
777
|
-
const { value: c, priority: h } = i[u];
|
|
778
|
-
if (m(c)) {
|
|
779
|
-
const a = c.watch((f) => {
|
|
780
|
-
this._mutate(() => {
|
|
781
|
-
f ? t.style.setProperty(u, String(f), h) : t.style.removeProperty(u);
|
|
782
|
-
});
|
|
783
|
-
});
|
|
784
|
-
n.push(a), r.push(a);
|
|
785
|
-
} else c != null && t.style.setProperty(u, String(c));
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
return function() {
|
|
789
|
-
for (const u of r)
|
|
790
|
-
u(), n.splice(n.indexOf(u), 1);
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
applyClasses(t, e, n) {
|
|
794
|
-
const r = [];
|
|
795
|
-
if (m(e)) {
|
|
796
|
-
let i;
|
|
797
|
-
const u = e.watch((c) => {
|
|
798
|
-
this._mutate(
|
|
799
|
-
() => {
|
|
800
|
-
V(i) && i(), t.removeAttribute("class"), i = this.applyClasses(t, c, n);
|
|
801
|
-
},
|
|
802
|
-
this.getUpdateKey("attr", "class")
|
|
803
|
-
);
|
|
804
|
-
});
|
|
805
|
-
n.push(u), r.push(u);
|
|
806
|
-
} else {
|
|
807
|
-
const i = Nt(e);
|
|
808
|
-
for (const u in i) {
|
|
809
|
-
const c = i[u];
|
|
810
|
-
if (m(c)) {
|
|
811
|
-
const h = c.watch((a) => {
|
|
812
|
-
this._mutate(() => {
|
|
813
|
-
a ? t.classList.add(u) : t.classList.remove(u);
|
|
814
|
-
});
|
|
815
|
-
});
|
|
816
|
-
n.push(h), r.push(h);
|
|
817
|
-
} else c && t.classList.add(u);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
return function() {
|
|
821
|
-
for (const u of r)
|
|
822
|
-
u(), n.splice(n.indexOf(u), 1);
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
function Nt(s) {
|
|
827
|
-
let t = {};
|
|
828
|
-
if (k(s)) {
|
|
829
|
-
const e = s.split(" ");
|
|
830
|
-
for (const n of e)
|
|
831
|
-
t[n] = !0;
|
|
832
|
-
} else Z(s) ? Object.assign(t, s) : Array.isArray(s) && Array.from(s).filter(Boolean).forEach((e) => {
|
|
833
|
-
Object.assign(t, Nt(e));
|
|
834
|
-
});
|
|
835
|
-
return delete t.undefined, t;
|
|
836
|
-
}
|
|
837
|
-
function Wt(s) {
|
|
838
|
-
let t = {};
|
|
839
|
-
if (k(s)) {
|
|
840
|
-
const e = s.split(";").filter((n) => n.trim() !== "");
|
|
841
|
-
for (const n of e) {
|
|
842
|
-
const [r, i] = n.split(":"), u = {
|
|
843
|
-
value: i
|
|
844
|
-
};
|
|
845
|
-
i.includes("!important") ? (u.priority = "important", u.value = i.replace("!important", "").trim()) : u.value = i.trim(), t[dt(r.trim())] = u;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
if (Z(s))
|
|
849
|
-
for (const e in s)
|
|
850
|
-
e.startsWith("--") ? t[e] = { value: s[e] } : t[dt(e)] = { value: s[e] };
|
|
851
|
-
else Array.isArray(s) && Array.from(s).filter((e) => e != null).forEach((e) => {
|
|
852
|
-
Object.assign(t, Wt(e));
|
|
853
|
-
});
|
|
854
|
-
return t;
|
|
855
|
-
}
|
|
856
|
-
function dt(s) {
|
|
857
|
-
return s.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, e) => (e ? "-" : "") + t.toLowerCase());
|
|
858
|
-
}
|
|
859
|
-
const ae = ["ref", "children", "class", "style", "data"];
|
|
860
|
-
var gt;
|
|
861
|
-
gt = M;
|
|
862
|
-
class he {
|
|
863
|
-
constructor({ sources: t, renderFn: e, elementContext: n }) {
|
|
864
|
-
o(this, gt, !0);
|
|
865
|
-
o(this, "node", document.createTextNode(""));
|
|
866
|
-
o(this, "children", []);
|
|
867
|
-
o(this, "renderFn");
|
|
868
|
-
o(this, "elementContext");
|
|
869
|
-
o(this, "watcher", D());
|
|
870
|
-
o(this, "sources");
|
|
871
|
-
this.sources = t, this.renderFn = e, this.elementContext = n;
|
|
872
|
-
}
|
|
873
|
-
get isMounted() {
|
|
874
|
-
return this.node.parentNode != null;
|
|
875
|
-
}
|
|
876
|
-
mount(t, e) {
|
|
877
|
-
this.isMounted || (t.insertBefore(this.node, (e == null ? void 0 : e.nextSibling) ?? null), this.watcher.watch(this.sources, (...n) => {
|
|
878
|
-
const r = this.renderFn(...n);
|
|
879
|
-
if (!qt(r))
|
|
880
|
-
throw console.error(r, n), new TypeError(
|
|
881
|
-
`Observer received invalid value to render. Got type: ${$(r)}, value: ${r}`
|
|
882
|
-
);
|
|
883
|
-
this.update(A(r) ? r : [r]);
|
|
884
|
-
}));
|
|
885
|
-
}
|
|
886
|
-
unmount(t = !1) {
|
|
887
|
-
var e;
|
|
888
|
-
this.watcher.stopAll(), this.isMounted && (this.cleanup(t), (e = this.node.parentNode) == null || e.removeChild(this.node));
|
|
889
|
-
}
|
|
890
|
-
cleanup(t) {
|
|
891
|
-
for (const e of this.children)
|
|
892
|
-
e.unmount(t);
|
|
893
|
-
this.children = [];
|
|
894
|
-
}
|
|
895
|
-
update(t) {
|
|
896
|
-
var i, u, c;
|
|
897
|
-
if (this.cleanup(!1), t == null || t.length === 0 || !this.isMounted)
|
|
898
|
-
return;
|
|
899
|
-
const e = t.flatMap((h) => Tt(h) ? h : b(this.elementContext, Q(h)));
|
|
900
|
-
for (const h of e) {
|
|
901
|
-
const a = ((i = this.children.at(-1)) == null ? void 0 : i.node) || this.node;
|
|
902
|
-
h.mount(this.node.parentNode, a), this.children.push(h);
|
|
903
|
-
}
|
|
904
|
-
const n = this.node.parentNode, r = ((c = (u = this.children.at(-1)) == null ? void 0 : u.node) == null ? void 0 : c.nextSibling) ?? null;
|
|
905
|
-
n.insertBefore(this.node, r);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
var yt;
|
|
909
|
-
yt = M;
|
|
910
|
-
class Pt {
|
|
911
|
-
constructor(t) {
|
|
912
|
-
o(this, yt, !0);
|
|
913
|
-
o(this, "node", document.createTextNode(""));
|
|
914
|
-
o(this, "isMounted", !1);
|
|
915
|
-
o(this, "source");
|
|
916
|
-
o(this, "elements", []);
|
|
917
|
-
o(this, "stopCallback");
|
|
918
|
-
this.source = t;
|
|
919
|
-
}
|
|
920
|
-
mount(t, e) {
|
|
921
|
-
this.isMounted || (this.isMounted = !0, t.insertBefore(this.node, (e == null ? void 0 : e.nextSibling) ?? null), m(this.source) ? this.stopCallback = this.source.watch((n) => {
|
|
922
|
-
this.update(n);
|
|
923
|
-
}) : this.update(this.elements));
|
|
924
|
-
}
|
|
925
|
-
unmount(t = !1) {
|
|
926
|
-
this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), this.isMounted && (this.cleanup(t), this.isMounted = !1);
|
|
927
|
-
}
|
|
928
|
-
cleanup(t) {
|
|
929
|
-
for (const e of this.elements)
|
|
930
|
-
e.unmount(t);
|
|
931
|
-
this.elements = [];
|
|
932
|
-
}
|
|
933
|
-
update(t) {
|
|
934
|
-
var e, n;
|
|
935
|
-
if (this.cleanup(!1), t.length > 0) {
|
|
936
|
-
for (let r = 0; r < t.length; r++) {
|
|
937
|
-
const i = t[r], u = r > 0 ? this.elements[r - 1] : void 0;
|
|
938
|
-
i.mount(this.node.parentElement, u == null ? void 0 : u.node), this.elements.push(i);
|
|
939
|
-
}
|
|
940
|
-
(n = this.node.parentNode) == null || n.insertBefore(this.node, ((e = this.elements.at(-1)) == null ? void 0 : e.node) ?? null);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
var vt;
|
|
945
|
-
vt = M;
|
|
946
|
-
class le {
|
|
947
|
-
constructor(t) {
|
|
948
|
-
o(this, vt, !0);
|
|
949
|
-
o(this, "config");
|
|
950
|
-
o(this, "element");
|
|
951
|
-
this.config = t;
|
|
952
|
-
}
|
|
953
|
-
get isMounted() {
|
|
954
|
-
return this.element ? this.element.isMounted : !1;
|
|
955
|
-
}
|
|
956
|
-
mount(t, e) {
|
|
957
|
-
const { content: n, parent: r } = this.config;
|
|
958
|
-
Tt(n) ? this.element = n : this.element = F(b(this.config.elementContext, Q(n))), this.element.mount(r);
|
|
959
|
-
}
|
|
960
|
-
unmount(t = !1) {
|
|
961
|
-
var e;
|
|
962
|
-
(e = this.element) != null && e.isMounted && this.element.unmount(t);
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
var N;
|
|
966
|
-
class J {
|
|
967
|
-
constructor(t, e) {
|
|
968
|
-
o(this, "type");
|
|
969
|
-
o(this, "detail");
|
|
970
|
-
P(this, N, !1);
|
|
971
|
-
this.type = t, this.detail = e;
|
|
972
|
-
}
|
|
973
|
-
get propagationStopped() {
|
|
974
|
-
return O(this, N);
|
|
975
|
-
}
|
|
976
|
-
stopPropagation() {
|
|
977
|
-
T(this, N, !0);
|
|
978
|
-
}
|
|
979
|
-
get [Symbol.toStringTag]() {
|
|
980
|
-
return "ContextEvent";
|
|
981
|
-
}
|
|
982
|
-
// stopImmediatePropagation() {}
|
|
983
|
-
}
|
|
984
|
-
N = new WeakMap();
|
|
985
|
-
let fe = class {
|
|
986
|
-
constructor(t) {
|
|
987
|
-
o(this, "__store");
|
|
988
|
-
this.__store = t;
|
|
989
|
-
const e = Object.getOwnPropertyDescriptors(this.__store._logger);
|
|
990
|
-
for (const n in e)
|
|
991
|
-
n !== "setName" && Object.defineProperty(this, n, e[n]);
|
|
992
|
-
}
|
|
993
|
-
get isMounted() {
|
|
994
|
-
return this.__store.isMounted;
|
|
995
|
-
}
|
|
996
|
-
setName(t) {
|
|
997
|
-
return this.__store._logger.setName(t), this;
|
|
998
|
-
}
|
|
999
|
-
set(t, e) {
|
|
1000
|
-
return this.__store._elementContext.data[t] = e, e;
|
|
1001
|
-
}
|
|
1002
|
-
get(t) {
|
|
1003
|
-
let e = this.__store._elementContext;
|
|
1004
|
-
for (; ; ) {
|
|
1005
|
-
if (t in e.data)
|
|
1006
|
-
return e.data[t];
|
|
1007
|
-
if (e.parent)
|
|
1008
|
-
e = e.parent;
|
|
1009
|
-
else
|
|
1010
|
-
break;
|
|
1011
|
-
}
|
|
1012
|
-
return null;
|
|
1013
|
-
}
|
|
1014
|
-
on(t, e) {
|
|
1015
|
-
if (t === "*") {
|
|
1016
|
-
const n = (r, i) => {
|
|
1017
|
-
e(i);
|
|
1018
|
-
};
|
|
1019
|
-
this.__store._elementContext.emitter.on(t, n), this.__store._wildcardListeners.set(e, n);
|
|
1020
|
-
} else
|
|
1021
|
-
this.__store._elementContext.emitter.on(t, e);
|
|
1022
|
-
}
|
|
1023
|
-
off(t, e) {
|
|
1024
|
-
if (t === "*") {
|
|
1025
|
-
const n = this.__store._wildcardListeners.get(e);
|
|
1026
|
-
n && (this.__store._elementContext.emitter.off(t, n), this.__store._wildcardListeners.delete(e));
|
|
1027
|
-
} else
|
|
1028
|
-
this.__store._elementContext.emitter.off(t, e);
|
|
1029
|
-
}
|
|
1030
|
-
once(t, e) {
|
|
1031
|
-
if (t === "*") {
|
|
1032
|
-
const n = (r, i) => {
|
|
1033
|
-
this.__store._wildcardListeners.delete(e), e(i);
|
|
1034
|
-
};
|
|
1035
|
-
this.__store._elementContext.emitter.once(t, n), this.__store._wildcardListeners.set(e, n);
|
|
1036
|
-
} else
|
|
1037
|
-
this.__store._elementContext.emitter.once(t, e);
|
|
1038
|
-
}
|
|
1039
|
-
emit(t, e) {
|
|
1040
|
-
return this.__store._elementContext.emitter.emit(t, new J(t, e));
|
|
1041
|
-
}
|
|
1042
|
-
onMount(t) {
|
|
1043
|
-
this.__store._emitter.on("mounted", t);
|
|
1044
|
-
}
|
|
1045
|
-
onUnmount(t) {
|
|
1046
|
-
this.__store._emitter.on("unmounted", t);
|
|
1047
|
-
}
|
|
1048
|
-
watch(t, e) {
|
|
1049
|
-
const n = this.__store;
|
|
1050
|
-
if (n.isMounted)
|
|
1051
|
-
return n._watcher.watch(t, e);
|
|
1052
|
-
{
|
|
1053
|
-
let r, i = !1;
|
|
1054
|
-
return n._emitter.on("mounted", () => {
|
|
1055
|
-
i || (r = n._watcher.watch(t, e));
|
|
1056
|
-
}), () => {
|
|
1057
|
-
r != null && (i = !0, r());
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
};
|
|
1062
|
-
class de {
|
|
1063
|
-
constructor(t, e) {
|
|
1064
|
-
o(this, "fn");
|
|
1065
|
-
o(this, "_options");
|
|
1066
|
-
/**
|
|
1067
|
-
* Value is guaranteed to be set after `attach` is called.
|
|
1068
|
-
*/
|
|
1069
|
-
o(this, "value");
|
|
1070
|
-
o(this, "isMounted", !1);
|
|
1071
|
-
o(this, "_elementContext");
|
|
1072
|
-
o(this, "_emitter", new I());
|
|
1073
|
-
o(this, "_wildcardListeners", /* @__PURE__ */ new Map());
|
|
1074
|
-
o(this, "_logger");
|
|
1075
|
-
o(this, "_watcher", D());
|
|
1076
|
-
this.fn = t, this._options = e;
|
|
1077
|
-
}
|
|
1078
|
-
get name() {
|
|
1079
|
-
return this.fn.name;
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Attaches this Store to the elementContext.
|
|
1083
|
-
* Returns false if there was already an instance attached, and true otherwise.
|
|
1084
|
-
*/
|
|
1085
|
-
attach(t) {
|
|
1086
|
-
if (t.stores.has(this.fn))
|
|
1087
|
-
return !1;
|
|
1088
|
-
this._elementContext = t, this._logger = t.root.createLogger(this.fn.name), this._emitter.on("error", (n, r, ...i) => {
|
|
1089
|
-
console.log({ error: n, eventName: r, args: i }), this._logger.crash(n);
|
|
1090
|
-
});
|
|
1091
|
-
const e = new fe(this);
|
|
1092
|
-
try {
|
|
1093
|
-
this.value = this.fn.call(e, this._options, e);
|
|
1094
|
-
} catch (n) {
|
|
1095
|
-
this._logger.crash(n);
|
|
1096
|
-
}
|
|
1097
|
-
return t.stores.set(this.fn, this), !0;
|
|
1098
|
-
}
|
|
1099
|
-
handleMount() {
|
|
1100
|
-
this.isMounted = !0, this._emitter.emit("mounted");
|
|
1101
|
-
}
|
|
1102
|
-
handleUnmount() {
|
|
1103
|
-
this.isMounted = !1, this._emitter.emit("unmounted"), this._emitter.clear(), this._watcher.stopAll();
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
class pt extends Error {
|
|
1107
|
-
}
|
|
1108
|
-
class pe {
|
|
1109
|
-
constructor(t) {
|
|
1110
|
-
o(this, "__view");
|
|
1111
|
-
this.__view = t;
|
|
1112
|
-
const e = Object.getOwnPropertyDescriptors(this.__view._logger);
|
|
1113
|
-
for (const n in e)
|
|
1114
|
-
n !== "setName" && Object.defineProperty(this, n, e[n]);
|
|
1115
|
-
}
|
|
1116
|
-
get uid() {
|
|
1117
|
-
return this.__view.uniqueId;
|
|
1118
|
-
}
|
|
1119
|
-
get isMounted() {
|
|
1120
|
-
return this.__view.isMounted;
|
|
1121
|
-
}
|
|
1122
|
-
setName(t) {
|
|
1123
|
-
return this.__view._logger.setName(t), this.__view._elementContext.viewName = t, this;
|
|
1124
|
-
}
|
|
1125
|
-
set(t, e) {
|
|
1126
|
-
return this.__view._elementContext.data[t] = e, e;
|
|
1127
|
-
}
|
|
1128
|
-
get(t) {
|
|
1129
|
-
let e = this.__view._elementContext;
|
|
1130
|
-
for (; ; ) {
|
|
1131
|
-
if (t in e.data)
|
|
1132
|
-
return e.data[t];
|
|
1133
|
-
if (e.parent)
|
|
1134
|
-
e = e.parent;
|
|
1135
|
-
else
|
|
1136
|
-
break;
|
|
1137
|
-
}
|
|
1138
|
-
return null;
|
|
1139
|
-
}
|
|
1140
|
-
// on<T = unknown>(eventName: string, listener: (...args: any) => void): void {
|
|
1141
|
-
// this.__view._elementContext.emitter.on(eventName, listener);
|
|
1142
|
-
// }
|
|
1143
|
-
// off<T = unknown>(eventName: string, listener: (...args: any) => void): void {
|
|
1144
|
-
// this.__view._elementContext.emitter.off(eventName, listener);
|
|
1145
|
-
// }
|
|
1146
|
-
// once<T = unknown>(eventName: string, listener: (...args: any) => void): void {
|
|
1147
|
-
// this.__view._elementContext.emitter.once(eventName, listener);
|
|
1148
|
-
// }
|
|
1149
|
-
on(t, e) {
|
|
1150
|
-
if (t === "*") {
|
|
1151
|
-
const n = (r, i) => {
|
|
1152
|
-
e(i);
|
|
1153
|
-
};
|
|
1154
|
-
this.__view._elementContext.emitter.on(t, n), this.__view._wildcardListeners.set(e, n);
|
|
1155
|
-
} else
|
|
1156
|
-
this.__view._elementContext.emitter.on(t, e);
|
|
1157
|
-
}
|
|
1158
|
-
off(t, e) {
|
|
1159
|
-
if (t === "*") {
|
|
1160
|
-
const n = this.__view._wildcardListeners.get(e);
|
|
1161
|
-
n && (this.__view._elementContext.emitter.off(t, n), this.__view._wildcardListeners.delete(e));
|
|
1162
|
-
} else
|
|
1163
|
-
this.__view._elementContext.emitter.off(t, e);
|
|
1164
|
-
}
|
|
1165
|
-
once(t, e) {
|
|
1166
|
-
if (t === "*") {
|
|
1167
|
-
const n = (r, i) => {
|
|
1168
|
-
this.__view._wildcardListeners.delete(e), e(i);
|
|
1169
|
-
};
|
|
1170
|
-
this.__view._elementContext.emitter.once(t, n), this.__view._wildcardListeners.set(e, n);
|
|
1171
|
-
} else
|
|
1172
|
-
this.__view._elementContext.emitter.once(t, e);
|
|
1173
|
-
}
|
|
1174
|
-
emit(t, e) {
|
|
1175
|
-
return this.__view._elementContext.emitter.emit(t, new J(t, e));
|
|
1176
|
-
}
|
|
1177
|
-
attachStore(t, e) {
|
|
1178
|
-
const n = new de(t, e);
|
|
1179
|
-
if (n.attach(this.__view._elementContext))
|
|
1180
|
-
this.__view._emitter.on("mounted", () => {
|
|
1181
|
-
n.handleMount();
|
|
1182
|
-
}), this.__view._emitter.on("unmounted", () => {
|
|
1183
|
-
n.handleUnmount();
|
|
1184
|
-
});
|
|
1185
|
-
else {
|
|
1186
|
-
let i = t.name ? `'${t.name}'` : "this store";
|
|
1187
|
-
this.__view._logger.warn(`An instance of ${i} was already attached to this context.`);
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
useStore(t) {
|
|
1191
|
-
if (V(t)) {
|
|
1192
|
-
let e = this.__view._elementContext, n;
|
|
1193
|
-
for (; n = e.stores.get(t), n == null && e.parent != null; )
|
|
1194
|
-
e = e.parent;
|
|
1195
|
-
if (n == null)
|
|
1196
|
-
throw new pt("Store not found on this context.");
|
|
1197
|
-
return n.value;
|
|
1198
|
-
} else
|
|
1199
|
-
throw new pt("Invalid store.");
|
|
1200
|
-
}
|
|
1201
|
-
beforeMount(t) {
|
|
1202
|
-
this.__view._emitter.on("beforeMount", t);
|
|
1203
|
-
}
|
|
1204
|
-
onMount(t) {
|
|
1205
|
-
this.__view._emitter.on("mounted", t);
|
|
1206
|
-
}
|
|
1207
|
-
beforeUnmount(t) {
|
|
1208
|
-
this.__view._emitter.on("beforeUnmount", t);
|
|
1209
|
-
}
|
|
1210
|
-
onUnmount(t) {
|
|
1211
|
-
this.__view._emitter.on("unmounted", t);
|
|
1212
|
-
}
|
|
1213
|
-
watch(t, e) {
|
|
1214
|
-
const n = this.__view;
|
|
1215
|
-
if (n.isMounted)
|
|
1216
|
-
return n._watcher.watch(t, e);
|
|
1217
|
-
{
|
|
1218
|
-
let r, i = !1;
|
|
1219
|
-
return n._emitter.on("mounted", () => {
|
|
1220
|
-
i || (r = n._watcher.watch(t, e));
|
|
1221
|
-
}), () => {
|
|
1222
|
-
r != null && (i = !0, r());
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
outlet() {
|
|
1227
|
-
return S("$outlet", { $children: this.__view._$children });
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
var St;
|
|
1231
|
-
St = M;
|
|
1232
|
-
const tt = class tt {
|
|
1233
|
-
constructor(t, e, n, r = []) {
|
|
1234
|
-
o(this, St, !0);
|
|
1235
|
-
o(this, "uniqueId", kt());
|
|
1236
|
-
o(this, "_elementContext");
|
|
1237
|
-
o(this, "_logger");
|
|
1238
|
-
o(this, "_view");
|
|
1239
|
-
o(this, "_props");
|
|
1240
|
-
o(this, "_element");
|
|
1241
|
-
o(this, "_childMarkup");
|
|
1242
|
-
o(this, "_$children");
|
|
1243
|
-
o(this, "_setChildren");
|
|
1244
|
-
o(this, "_watcher", D());
|
|
1245
|
-
o(this, "_emitter", new I());
|
|
1246
|
-
o(this, "_wildcardListeners", /* @__PURE__ */ new Map());
|
|
1247
|
-
o(this, "isMounted", !1);
|
|
1248
|
-
this._elementContext = {
|
|
1249
|
-
...t,
|
|
1250
|
-
data: {},
|
|
1251
|
-
parent: t,
|
|
1252
|
-
viewName: e.name,
|
|
1253
|
-
emitter: new I(),
|
|
1254
|
-
stores: /* @__PURE__ */ new Map()
|
|
1255
|
-
}, this._logger = t.root.createLogger(e.name || "🌇 anonymous view", { uid: this.uniqueId }), this._view = e, this._props = n, this._childMarkup = r, [this._$children, this._setChildren] = H([]), this._emitter.on("error", (i, u, ...c) => {
|
|
1256
|
-
this._logger.error({ error: i, eventName: u, args: c }), this._logger.crash(i);
|
|
1257
|
-
}), this._elementContext.emitter.on("*", (i, u) => {
|
|
1258
|
-
var c;
|
|
1259
|
-
u instanceof J && (u.propagationStopped || (c = this._elementContext.parent) == null || c.emitter.emit(i, u));
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
/*===============================*\
|
|
1263
|
-
|| "Public" API ||
|
|
1264
|
-
\*===============================*/
|
|
1265
|
-
get node() {
|
|
1266
|
-
var t;
|
|
1267
|
-
return (t = this._element) == null ? void 0 : t.node;
|
|
1268
|
-
}
|
|
1269
|
-
mount(t, e) {
|
|
1270
|
-
const n = this.isMounted;
|
|
1271
|
-
n || (this._initialize(), this._emitter.emit("beforeMount")), this._element && this._element.mount(t, e), n || (this.isMounted = !0, Qt(), requestAnimationFrame(() => {
|
|
1272
|
-
this._emitter.emit("mounted");
|
|
1273
|
-
}));
|
|
1274
|
-
}
|
|
1275
|
-
unmount(t = !1) {
|
|
1276
|
-
this._emitter.emit("beforeUnmount"), this._element && this._element.unmount(t), this.isMounted && te(), this.isMounted = !1, this._emitter.emit("unmounted"), this._emitter.clear(), this._watcher.stopAll();
|
|
1277
|
-
}
|
|
1278
|
-
setChildView(t) {
|
|
1279
|
-
this._childMarkup = [];
|
|
1280
|
-
const e = new tt(this._elementContext, t, {});
|
|
1281
|
-
return this._setChildren([e]), e;
|
|
1282
|
-
}
|
|
1283
|
-
/*===============================*\
|
|
1284
|
-
|| Internal ||
|
|
1285
|
-
\*===============================*/
|
|
1286
|
-
_initialize() {
|
|
1287
|
-
const t = new pe(this);
|
|
1288
|
-
let e;
|
|
1289
|
-
try {
|
|
1290
|
-
e = this._view.call(t, this._props, t), this._childMarkup.length && this._setChildren(b(this._elementContext, this._childMarkup));
|
|
1291
|
-
} catch (n) {
|
|
1292
|
-
throw n instanceof Error && this._logger.crash(n), n;
|
|
1293
|
-
}
|
|
1294
|
-
if (e !== null) if (e instanceof Node)
|
|
1295
|
-
this._element = F(b(this._elementContext, S("$node", { value: e })));
|
|
1296
|
-
else if (U(e) || bt(U, e))
|
|
1297
|
-
this._element = F(b(this._elementContext, e));
|
|
1298
|
-
else if (m(e))
|
|
1299
|
-
this._element = F(
|
|
1300
|
-
b(this._elementContext, S("$observer", { sources: [e], renderFn: (n) => n }))
|
|
1301
|
-
);
|
|
1302
|
-
else {
|
|
1303
|
-
const n = new TypeError(
|
|
1304
|
-
`Expected '${this._view.name}' function to return a DOM node, Markup element, Readable or null. Got: ${$(e)}`
|
|
1305
|
-
);
|
|
1306
|
-
this._logger.crash(n);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
let j = tt;
|
|
1311
|
-
var Ct;
|
|
1312
|
-
Ct = M;
|
|
1313
|
-
class me {
|
|
1314
|
-
constructor({ elementContext: t, $items: e, renderFn: n, keyFn: r }) {
|
|
1315
|
-
o(this, Ct, !0);
|
|
1316
|
-
o(this, "node", document.createTextNode(""));
|
|
1317
|
-
o(this, "$items");
|
|
1318
|
-
o(this, "stopCallback");
|
|
1319
|
-
o(this, "connectedItems", []);
|
|
1320
|
-
o(this, "elementContext");
|
|
1321
|
-
o(this, "renderFn");
|
|
1322
|
-
o(this, "keyFn");
|
|
1323
|
-
this.elementContext = t, this.$items = e, this.renderFn = n, this.keyFn = r;
|
|
1324
|
-
}
|
|
1325
|
-
get isMounted() {
|
|
1326
|
-
return this.node.parentNode != null;
|
|
1327
|
-
}
|
|
1328
|
-
mount(t, e) {
|
|
1329
|
-
this.isMounted || (t.insertBefore(this.node, (e == null ? void 0 : e.nextSibling) ?? null), this.stopCallback = this.$items.watch((n) => {
|
|
1330
|
-
this.isMounted ? this.elementContext.root.batch.write(() => {
|
|
1331
|
-
this._update(Array.from(n));
|
|
1332
|
-
}) : this._update(Array.from(n));
|
|
1333
|
-
}));
|
|
1334
|
-
}
|
|
1335
|
-
unmount(t = !1) {
|
|
1336
|
-
var e;
|
|
1337
|
-
this.stopCallback && (this.stopCallback(), this.stopCallback = void 0), !t && this.isMounted && ((e = this.node.parentNode) == null || e.removeChild(this.node)), this._cleanup(t);
|
|
1338
|
-
}
|
|
1339
|
-
_cleanup(t) {
|
|
1340
|
-
for (const e of this.connectedItems)
|
|
1341
|
-
e.element.unmount(t);
|
|
1342
|
-
this.connectedItems = [];
|
|
1343
|
-
}
|
|
1344
|
-
_update(t) {
|
|
1345
|
-
var u, c, h;
|
|
1346
|
-
if (t.length === 0 || !this.isMounted)
|
|
1347
|
-
return this._cleanup(!1);
|
|
1348
|
-
const e = [];
|
|
1349
|
-
let n = 0;
|
|
1350
|
-
for (const a of t)
|
|
1351
|
-
e.push({
|
|
1352
|
-
key: this.keyFn(a, n),
|
|
1353
|
-
value: a,
|
|
1354
|
-
index: n++
|
|
1355
|
-
});
|
|
1356
|
-
const r = [];
|
|
1357
|
-
for (const a of this.connectedItems)
|
|
1358
|
-
e.find((l) => l.key === a.key) || a.element.unmount(!1);
|
|
1359
|
-
for (const a of e) {
|
|
1360
|
-
const f = this.connectedItems.find((l) => l.key === a.key);
|
|
1361
|
-
if (f)
|
|
1362
|
-
f.setValue(a.value), f.setIndex(a.index), r[a.index] = f;
|
|
1363
|
-
else {
|
|
1364
|
-
const [l, d] = H(a.value), [p, _] = H(a.index);
|
|
1365
|
-
r[a.index] = {
|
|
1366
|
-
key: a.key,
|
|
1367
|
-
$value: l,
|
|
1368
|
-
setValue: d,
|
|
1369
|
-
$index: p,
|
|
1370
|
-
setIndex: _,
|
|
1371
|
-
element: new j(this.elementContext, _e, {
|
|
1372
|
-
$value: l,
|
|
1373
|
-
$index: p,
|
|
1374
|
-
renderFn: this.renderFn
|
|
1375
|
-
})
|
|
1376
|
-
};
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
for (let a = 0; a < r.length; a++) {
|
|
1380
|
-
const f = r[a], l = ((u = r[a - 1]) == null ? void 0 : u.element.node) ?? this.node;
|
|
1381
|
-
f.element.mount(this.node.parentNode, l);
|
|
1382
|
-
}
|
|
1383
|
-
this.connectedItems = r;
|
|
1384
|
-
const i = ((c = r.at(-1)) == null ? void 0 : c.element.node) ?? this.node;
|
|
1385
|
-
(h = this.node.parentNode) == null || h.insertBefore(this.node, i.nextSibling);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
function _e({ $value: s, $index: t, renderFn: e }, n) {
|
|
1389
|
-
return n.setName("@RepeatItem"), e.call(n, s, t, n);
|
|
1390
|
-
}
|
|
1391
|
-
function U(s) {
|
|
1392
|
-
return (s == null ? void 0 : s[Lt]) === !0;
|
|
1393
|
-
}
|
|
1394
|
-
function Tt(s) {
|
|
1395
|
-
return (s == null ? void 0 : s[M]) === !0;
|
|
1396
|
-
}
|
|
1397
|
-
function Q(s) {
|
|
1398
|
-
return A(s) || (s = [s]), s.flat(1 / 0).filter((t) => t != null && t !== !1).map((t) => U(t) ? t : t instanceof Node ? S("$node", { value: t }) : m(t) ? S("$observer", {
|
|
1399
|
-
sources: [t],
|
|
1400
|
-
renderFn: (e) => e
|
|
1401
|
-
}) : S("$text", { value: t }));
|
|
1402
|
-
}
|
|
1403
|
-
function S(s, t, ...e) {
|
|
1404
|
-
return new we(s, t, ...e);
|
|
1405
|
-
}
|
|
1406
|
-
var xt;
|
|
1407
|
-
xt = Lt;
|
|
1408
|
-
class we {
|
|
1409
|
-
constructor(t, e, ...n) {
|
|
1410
|
-
o(this, xt, !0);
|
|
1411
|
-
o(this, "type");
|
|
1412
|
-
o(this, "props");
|
|
1413
|
-
o(this, "children");
|
|
1414
|
-
this.type = t, this.props = e, this.children = Q(n);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
const Le = oe.bind(S);
|
|
1418
|
-
function Ne(s, t, e) {
|
|
1419
|
-
return S("$observer", {
|
|
1420
|
-
sources: [s],
|
|
1421
|
-
renderFn: (n) => n && t ? t : !n && e ? e : null
|
|
1422
|
-
});
|
|
1423
|
-
}
|
|
1424
|
-
function We(s, t, e) {
|
|
1425
|
-
const n = Y(s);
|
|
1426
|
-
return S("$repeat", { $items: n, keyFn: t, renderFn: e });
|
|
1427
|
-
}
|
|
1428
|
-
function Pe(s, t) {
|
|
1429
|
-
return S("$portal", { parent: s, content: t });
|
|
1430
|
-
}
|
|
1431
|
-
function b(s, t) {
|
|
1432
|
-
return (A(t) ? t : [t]).map((n) => {
|
|
1433
|
-
if (V(n.type))
|
|
1434
|
-
return new j(s, n.type, n.props, n.children);
|
|
1435
|
-
if (k(n.type))
|
|
1436
|
-
switch (n.type) {
|
|
1437
|
-
case "$node": {
|
|
1438
|
-
const r = n.props;
|
|
1439
|
-
return new ft(r.value);
|
|
1440
|
-
}
|
|
1441
|
-
case "$text": {
|
|
1442
|
-
const r = n.props;
|
|
1443
|
-
return new ft(document.createTextNode(String(r.value)));
|
|
1444
|
-
}
|
|
1445
|
-
case "$repeat": {
|
|
1446
|
-
const r = n.props;
|
|
1447
|
-
return new me({
|
|
1448
|
-
$items: r.$items,
|
|
1449
|
-
keyFn: r.keyFn,
|
|
1450
|
-
renderFn: r.renderFn,
|
|
1451
|
-
elementContext: s
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
case "$observer": {
|
|
1455
|
-
const r = n.props;
|
|
1456
|
-
return new he({
|
|
1457
|
-
sources: r.sources,
|
|
1458
|
-
renderFn: r.renderFn,
|
|
1459
|
-
elementContext: s
|
|
1460
|
-
});
|
|
1461
|
-
}
|
|
1462
|
-
case "$outlet": {
|
|
1463
|
-
const r = n.props;
|
|
1464
|
-
return new Pt(r.$children);
|
|
1465
|
-
}
|
|
1466
|
-
case "$portal": {
|
|
1467
|
-
const r = n.props;
|
|
1468
|
-
return new le({
|
|
1469
|
-
content: r.content,
|
|
1470
|
-
parent: r.parent,
|
|
1471
|
-
elementContext: s
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
default:
|
|
1475
|
-
if (n.type.startsWith("$"))
|
|
1476
|
-
throw new Error(`Unknown markup type: ${n.type}`);
|
|
1477
|
-
return new ce({
|
|
1478
|
-
tag: n.type,
|
|
1479
|
-
props: n.props ?? {},
|
|
1480
|
-
children: n.children,
|
|
1481
|
-
elementContext: s
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
else
|
|
1485
|
-
throw new TypeError(`Expected a string or view function. Got: ${n.type}`);
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
function F(s) {
|
|
1489
|
-
return s.length === 1 ? s[0] : new Pt(s);
|
|
1490
|
-
}
|
|
1491
|
-
function qt(s) {
|
|
1492
|
-
return s == null || s === !1 || k(s) || zt(s) || U(s) || m(s) || bt(qt, s);
|
|
1493
|
-
}
|
|
1494
|
-
export {
|
|
1495
|
-
F as A,
|
|
1496
|
-
b as B,
|
|
1497
|
-
J as C,
|
|
1498
|
-
de as D,
|
|
1499
|
-
Et as E,
|
|
1500
|
-
Pe as F,
|
|
1501
|
-
We as G,
|
|
1502
|
-
Ae as I,
|
|
1503
|
-
$e as P,
|
|
1504
|
-
Ee as S,
|
|
1505
|
-
j as V,
|
|
1506
|
-
ve as a,
|
|
1507
|
-
ye as b,
|
|
1508
|
-
Ce as c,
|
|
1509
|
-
H as d,
|
|
1510
|
-
re as e,
|
|
1511
|
-
k as f,
|
|
1512
|
-
Z as g,
|
|
1513
|
-
Me as h,
|
|
1514
|
-
V as i,
|
|
1515
|
-
Le as j,
|
|
1516
|
-
Ne as k,
|
|
1517
|
-
D as l,
|
|
1518
|
-
ke as m,
|
|
1519
|
-
Y as n,
|
|
1520
|
-
ee as o,
|
|
1521
|
-
I as p,
|
|
1522
|
-
m as q,
|
|
1523
|
-
Oe as r,
|
|
1524
|
-
xe as s,
|
|
1525
|
-
$ as t,
|
|
1526
|
-
ie as u,
|
|
1527
|
-
pt as v,
|
|
1528
|
-
Se as w,
|
|
1529
|
-
S as x,
|
|
1530
|
-
Zt as y,
|
|
1531
|
-
be as z
|
|
1532
|
-
};
|
|
1533
|
-
//# sourceMappingURL=markup-C-1VlVZi.js.map
|