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