@manyducks.co/dolla 2.0.0-alpha.51 → 2.0.0-alpha.52

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