@manyducks.co/dolla 2.0.0-alpha.61 → 2.0.0-alpha.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -26
- package/dist/core/context.d.ts +23 -4
- package/dist/core/index.d.ts +5 -3
- package/dist/core/markup.d.ts +6 -11
- package/dist/core/nodes/dynamic.d.ts +3 -3
- package/dist/core/nodes/element.d.ts +2 -0
- package/dist/core/nodes/repeat.d.ts +1 -1
- package/dist/core/nodes/view.d.ts +4 -4
- package/dist/core/scheduler.d.ts +17 -0
- package/dist/core/signals.d.ts +48 -14
- package/dist/core/views/default-crash-view.d.ts +1 -1
- package/dist/core/views/for.d.ts +23 -0
- package/dist/core/views/show.d.ts +26 -0
- package/dist/hooks/index.d.ts +5 -8
- package/dist/hooks.js +26 -31
- package/dist/hooks.js.map +1 -1
- package/dist/i18n.js +23 -23
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +69 -53
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/logger-B7RBYtzP.js +82 -0
- package/dist/logger-B7RBYtzP.js.map +1 -0
- package/dist/{markup-CX27GJ1M.js → markup-CW_lWDfq.js} +410 -325
- package/dist/markup-CW_lWDfq.js.map +1 -0
- package/dist/router/router.d.ts +10 -5
- package/dist/{router-CjCkk4dA.js → router-CBGsADQ4.js} +100 -100
- package/dist/router-CBGsADQ4.js.map +1 -0
- package/dist/router.js +1 -1
- package/dist/{signals-gCwiIe5X.js → signals-DbDmN2gr.js} +190 -161
- package/dist/signals-DbDmN2gr.js.map +1 -0
- package/docs/signals.md +16 -14
- package/notes/scratch.md +23 -1
- package/package.json +3 -2
- package/dist/logger-Bl496yfY.js +0 -91
- package/dist/logger-Bl496yfY.js.map +0 -1
- package/dist/markup-CX27GJ1M.js.map +0 -1
- package/dist/router-CjCkk4dA.js.map +0 -1
- package/dist/signals-gCwiIe5X.js.map +0 -1
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var nt = Object.defineProperty;
|
|
2
|
+
var K = (o) => {
|
|
3
|
+
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var a = (
|
|
7
|
-
var
|
|
8
|
-
import { c as m, t as
|
|
9
|
-
import { u as
|
|
10
|
-
import { c as
|
|
11
|
-
var
|
|
12
|
-
const U = Symbol("name"), d = Symbol("lifecycle"),
|
|
13
|
-
class
|
|
14
|
-
constructor(
|
|
5
|
+
var rt = (o, i, t) => i in o ? nt(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
|
|
6
|
+
var a = (o, i, t) => rt(o, typeof i != "symbol" ? i + "" : i, t), j = (o, i, t) => i.has(o) || K("Cannot " + t);
|
|
7
|
+
var _ = (o, i, t) => (j(o, i, "read from private field"), t ? t.call(o) : i.get(o)), V = (o, i, t) => i.has(o) ? K("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(o) : i.set(o, t), T = (o, i, t, e) => (j(o, i, "write to private field"), e ? e.call(o, t) : i.set(o, t), t);
|
|
8
|
+
import { c as m, t as ct, i as D, b as R } from "./typeChecking-CbltMOUt.js";
|
|
9
|
+
import { u as L, g as x, i as $, j as S, e as w, I as v, t as Q, c as at, o as ht, k as ut, b as lt, w as F, d as dt, m as ft } from "./signals-DbDmN2gr.js";
|
|
10
|
+
import { c as mt } from "./logger-B7RBYtzP.js";
|
|
11
|
+
var b = /* @__PURE__ */ ((o) => (o[o.WILL_MOUNT = 0] = "WILL_MOUNT", o[o.DID_MOUNT = 1] = "DID_MOUNT", o[o.WILL_UNMOUNT = 2] = "WILL_UNMOUNT", o[o.DID_UNMOUNT = 3] = "DID_UNMOUNT", o[o.DISPOSE = 4] = "DISPOSE", o))(b || {});
|
|
12
|
+
const U = Symbol("name"), d = Symbol("lifecycle"), g = Symbol("parent"), N = Symbol("stores"), y = Symbol("state");
|
|
13
|
+
class pt {
|
|
14
|
+
constructor(i) {
|
|
15
15
|
a(this, "context");
|
|
16
16
|
a(this, "state", 0);
|
|
17
17
|
a(this, "listeners", /* @__PURE__ */ new Map());
|
|
18
18
|
a(this, "bound");
|
|
19
|
-
this.context =
|
|
19
|
+
this.context = i;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Listen for a certain event to be emitted. Listeners are called when the event results in a state change.
|
|
23
23
|
*/
|
|
24
|
-
on(
|
|
25
|
-
const e = this.listeners.get(
|
|
26
|
-
e ? e.add(t) : this.listeners.set(
|
|
24
|
+
on(i, t) {
|
|
25
|
+
const e = this.listeners.get(i);
|
|
26
|
+
e ? e.add(t) : this.listeners.set(i, /* @__PURE__ */ new Set([t]));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Stop a particular listener from being called when an event is emitted.
|
|
30
30
|
*/
|
|
31
|
-
off(
|
|
32
|
-
const e = this.listeners.get(
|
|
33
|
-
e && (e.delete(t), e.size === 0 && this.listeners.delete(
|
|
31
|
+
off(i, t) {
|
|
32
|
+
const e = this.listeners.get(i);
|
|
33
|
+
e && (e.delete(t), e.size === 0 && this.listeners.delete(i));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Advance the lifecycle state machine.
|
|
37
37
|
*/
|
|
38
|
-
emit(
|
|
39
|
-
switch (
|
|
38
|
+
emit(i) {
|
|
39
|
+
switch (i) {
|
|
40
40
|
case 0: {
|
|
41
|
-
this.state < 1 ? (this.state = 1, this.notify(
|
|
41
|
+
this.state < 1 ? (this.state = 1, this.notify(i)) : this.context.crash(new Error(`Tried to WILL_MOUNT context at state ${this.state}`));
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
44
|
case 1: {
|
|
45
|
-
this.state >= 1 && this.state < 2 ? (this.state = 2, this.notify(
|
|
45
|
+
this.state >= 1 && this.state < 2 ? (this.state = 2, this.notify(i)) : this.context.crash(new Error(`Tried to WILL_UNMOUNT context at state ${this.state}`));
|
|
46
46
|
break;
|
|
47
47
|
}
|
|
48
48
|
case 2: {
|
|
49
|
-
this.state >= 2 && this.state < 3 ? (this.notify(
|
|
49
|
+
this.state >= 2 && this.state < 3 ? (this.notify(i), this.state = 3) : this.context.crash(new Error(`Tried to WILL_UNMOUNT context at state ${this.state}`));
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
case 3: {
|
|
53
|
-
this.state >= 3 && this.state < 4 ? (this.state = 4 % 4, this.notify(
|
|
53
|
+
this.state >= 3 && this.state < 4 ? (this.state = 4 % 4, this.notify(i)) : this.context.crash(new Error(`Tried to DID_UNMOUNT context at state ${this.state}`));
|
|
54
54
|
break;
|
|
55
55
|
}
|
|
56
56
|
case 4: {
|
|
57
|
-
this.state === 0 ? (this.notify(
|
|
57
|
+
this.state === 0 ? (this.notify(i), this.listeners.clear(), this.bound = void 0, this.context[y] = void 0, this.context[N] = void 0, this.state = 5) : this.context.crash(new Error(`Tried to DISPOSE context at state ${this.state}`));
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -62,93 +62,96 @@ class ft {
|
|
|
62
62
|
/**
|
|
63
63
|
* Bind `context` to this lifecycle; when any event is emitted here it will be emitted for `context` as well.
|
|
64
64
|
*/
|
|
65
|
-
bind(
|
|
66
|
-
this.bound ? this.bound.add(
|
|
65
|
+
bind(i) {
|
|
66
|
+
this.bound ? this.bound.add(i) : this.bound = /* @__PURE__ */ new Set([i]);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Call all the event's listeners and re-emit to bound contexts.
|
|
70
70
|
*/
|
|
71
|
-
notify(
|
|
72
|
-
const t = this.listeners.get(
|
|
71
|
+
notify(i) {
|
|
72
|
+
const t = this.listeners.get(i);
|
|
73
73
|
if (t)
|
|
74
74
|
for (const e of t)
|
|
75
75
|
e();
|
|
76
76
|
if (this.bound)
|
|
77
77
|
for (const e of this.bound)
|
|
78
|
-
e[d].emit(
|
|
78
|
+
e[d].emit(i);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
var z,
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
constructor(
|
|
85
|
-
|
|
86
|
-
a(this,
|
|
87
|
-
a(this,
|
|
81
|
+
var z, H, Z, Y, J, k;
|
|
82
|
+
J = U, Y = d, Z = g, H = N, z = y;
|
|
83
|
+
const O = class O {
|
|
84
|
+
constructor(i, t) {
|
|
85
|
+
V(this, k);
|
|
86
|
+
a(this, J);
|
|
87
|
+
a(this, Y, new pt(this));
|
|
88
|
+
a(this, Z);
|
|
88
89
|
a(this, H);
|
|
89
|
-
a(this, F);
|
|
90
90
|
a(this, z);
|
|
91
|
-
T(this,
|
|
92
|
-
const e =
|
|
91
|
+
T(this, k, i), this[U] = L(i);
|
|
92
|
+
const e = mt(() => x(_(this, k)), t == null ? void 0 : t.logger), s = Object.getOwnPropertyDescriptors(e);
|
|
93
93
|
for (const n in s)
|
|
94
94
|
Object.defineProperty(this, n, s[n]);
|
|
95
95
|
}
|
|
96
96
|
get isMounted() {
|
|
97
|
-
const { state:
|
|
98
|
-
return
|
|
97
|
+
const { state: i } = this[d];
|
|
98
|
+
return i >= 2 && i < 4;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Returns a new Context with this one as its parent.
|
|
102
102
|
*/
|
|
103
|
-
static linked(
|
|
104
|
-
const s = new
|
|
105
|
-
return s[
|
|
103
|
+
static linked(i, t, e) {
|
|
104
|
+
const s = new O(t, e);
|
|
105
|
+
return s[g] = i, e != null && e.bindLifecycleToParent && i[d].bind(s), s;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Emit a lifecycle event to `context`.
|
|
109
109
|
*/
|
|
110
|
-
static emit(
|
|
111
|
-
|
|
110
|
+
static emit(i, t) {
|
|
111
|
+
i[d].emit(t);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* Traverses _parent contexts until arriving at one that doesn't have a parent itself.
|
|
115
115
|
* Returns null if this context is the parent.
|
|
116
116
|
*/
|
|
117
|
-
static getRoot(
|
|
118
|
-
let t =
|
|
119
|
-
for (; t != null && t[
|
|
120
|
-
t = t[
|
|
117
|
+
static getRoot(i) {
|
|
118
|
+
let t = i[g];
|
|
119
|
+
for (; t != null && t[g]; )
|
|
120
|
+
t = t[g];
|
|
121
121
|
return t ?? null;
|
|
122
122
|
}
|
|
123
|
+
// nextTick(callback: () => void) {
|
|
124
|
+
// scheduler.nextTick(callback);
|
|
125
|
+
// }
|
|
123
126
|
/**
|
|
124
127
|
* Returns the current name of this context.
|
|
125
128
|
*/
|
|
126
129
|
getName() {
|
|
127
|
-
return
|
|
130
|
+
return L(_(this, k));
|
|
128
131
|
}
|
|
129
132
|
/**
|
|
130
133
|
* Sets a new name for this context.
|
|
131
134
|
*/
|
|
132
|
-
setName(
|
|
133
|
-
T(this,
|
|
135
|
+
setName(i) {
|
|
136
|
+
T(this, k, i), this[U] = L(i);
|
|
134
137
|
}
|
|
135
138
|
/**
|
|
136
139
|
* Creates an instance of a store and attaches it to this context.
|
|
137
140
|
*/
|
|
138
|
-
addStore(
|
|
141
|
+
addStore(i, t) {
|
|
139
142
|
var s;
|
|
140
|
-
if ((s = this[
|
|
141
|
-
let n =
|
|
143
|
+
if ((s = this[N]) != null && s.get(i)) {
|
|
144
|
+
let n = i.name ? `'${i.name}'` : "this store";
|
|
142
145
|
throw this.crash(new Error(`An instance of ${n} was already added on this context.`));
|
|
143
146
|
}
|
|
144
|
-
const e =
|
|
147
|
+
const e = O.linked(this, i.name, {
|
|
145
148
|
bindLifecycleToParent: !0,
|
|
146
|
-
logger: { tag:
|
|
149
|
+
logger: { tag: $(), tagName: "uid" }
|
|
147
150
|
});
|
|
148
151
|
try {
|
|
149
|
-
this[
|
|
150
|
-
const n =
|
|
151
|
-
|
|
152
|
+
this[N] || (this[N] = /* @__PURE__ */ new Map());
|
|
153
|
+
const n = S(e), c = i.call(e, t, e);
|
|
154
|
+
S(n), this[N].set(i, c);
|
|
152
155
|
} catch (n) {
|
|
153
156
|
throw this.crash(n);
|
|
154
157
|
}
|
|
@@ -159,98 +162,104 @@ const L = class L {
|
|
|
159
162
|
* 1. An instance of the store is found and returned.
|
|
160
163
|
* 2. No instance is found and an error is thrown.
|
|
161
164
|
*/
|
|
162
|
-
getStore(
|
|
165
|
+
getStore(i) {
|
|
163
166
|
var s;
|
|
164
|
-
if (!m(
|
|
167
|
+
if (!m(i))
|
|
165
168
|
throw new Error("Invalid store.");
|
|
166
169
|
let t = this, e;
|
|
167
|
-
for (; e = (s = t[
|
|
168
|
-
t = t[
|
|
170
|
+
for (; e = (s = t[N]) == null ? void 0 : s.get(i), e == null && t[g] != null; )
|
|
171
|
+
t = t[g];
|
|
169
172
|
if (e == null)
|
|
170
|
-
throw this.crash(new Error(`Store '${
|
|
173
|
+
throw this.crash(new Error(`Store '${i.name}' is not provided by this context.`));
|
|
171
174
|
return e;
|
|
172
175
|
}
|
|
173
176
|
/**
|
|
174
177
|
* Schedule a callback function to run just before this context is mounted.
|
|
175
178
|
*/
|
|
176
|
-
beforeMount(
|
|
177
|
-
return this[d].on(0,
|
|
179
|
+
beforeMount(i) {
|
|
180
|
+
return this[d].on(0, i), () => this[d].off(0, i);
|
|
178
181
|
}
|
|
179
182
|
/**
|
|
180
183
|
* Schedule a callback function to run after this context is mounted.
|
|
181
184
|
*/
|
|
182
|
-
onMount(
|
|
183
|
-
return this[d].on(1,
|
|
185
|
+
onMount(i) {
|
|
186
|
+
return this[d].on(1, i), () => this[d].off(1, i);
|
|
184
187
|
}
|
|
185
188
|
/**
|
|
186
189
|
* Schedule a callback function to run just before this context is unmounted.
|
|
187
190
|
*/
|
|
188
|
-
beforeUnmount(
|
|
189
|
-
return this[d].on(2,
|
|
191
|
+
beforeUnmount(i) {
|
|
192
|
+
return this[d].on(2, i), () => this[d].off(2, i);
|
|
190
193
|
}
|
|
191
194
|
/**
|
|
192
195
|
* Schedule a callback function to run after this context is unmounted.
|
|
193
196
|
*/
|
|
194
|
-
onUnmount(
|
|
195
|
-
return this[d].on(3,
|
|
197
|
+
onUnmount(i) {
|
|
198
|
+
return this[d].on(3, i), () => this[d].off(3, i);
|
|
196
199
|
}
|
|
197
|
-
effect(
|
|
200
|
+
effect(i) {
|
|
198
201
|
const t = () => {
|
|
199
202
|
try {
|
|
200
|
-
return
|
|
203
|
+
return i();
|
|
201
204
|
} catch (e) {
|
|
202
205
|
this.error(e), e instanceof Error ? this.crash(e) : typeof e == "string" ? this.crash(new Error(e)) : this.crash(new Error("Unknown error thrown in effect callback"));
|
|
203
206
|
}
|
|
204
207
|
};
|
|
205
208
|
if (this[d].state >= 1) {
|
|
206
|
-
const e =
|
|
209
|
+
const e = w(t, { _type: v });
|
|
207
210
|
return this[d].on(3, e), e;
|
|
208
211
|
} else {
|
|
209
212
|
let e, s = !1;
|
|
210
213
|
return this[d].on(0, () => {
|
|
211
|
-
s || (e =
|
|
214
|
+
s || (e = w(t, { _type: v }), this[d].on(3, e));
|
|
212
215
|
}), () => {
|
|
213
216
|
e != null && (s = !0, e());
|
|
214
217
|
};
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
|
-
getState(
|
|
218
|
-
var
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
return n;
|
|
229
|
-
} else {
|
|
230
|
-
let s = this;
|
|
231
|
-
const n = [];
|
|
232
|
-
for (; s[w] && n.push(...s[w].entries()), s[b] != null; )
|
|
233
|
-
s = s[b];
|
|
234
|
-
return new Map(n.reverse());
|
|
220
|
+
getState(i, t) {
|
|
221
|
+
var c;
|
|
222
|
+
const e = (t == null ? void 0 : t.immediate) ?? !1;
|
|
223
|
+
let s = this, n;
|
|
224
|
+
for (; n = (c = s[y]) == null ? void 0 : c.get(i), n === void 0 && !e && s[g] != null; )
|
|
225
|
+
s = s[g];
|
|
226
|
+
if (n === void 0) {
|
|
227
|
+
if (t != null && Object.hasOwn(t, "fallback"))
|
|
228
|
+
return t.fallback;
|
|
229
|
+
throw new Error(`Expected a value for '${String(i)}' but got undefined.`);
|
|
235
230
|
}
|
|
231
|
+
return n;
|
|
236
232
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Returns a Map containing all state values available to this context.
|
|
235
|
+
*
|
|
236
|
+
* Pass `options.immediate` to only include state stored on this context.
|
|
237
|
+
* By default all state stored on parent contexts is also included.
|
|
238
|
+
*/
|
|
239
|
+
getStateMap(i) {
|
|
240
|
+
let t = this;
|
|
241
|
+
const e = (i == null ? void 0 : i.immediate) ?? !1, s = [];
|
|
242
|
+
for (; t[y] && s.push(...t[y].entries()), !e && t[g] != null; )
|
|
243
|
+
t = t[g];
|
|
244
|
+
return new Map(s.reverse());
|
|
245
|
+
}
|
|
246
|
+
setState(...i) {
|
|
247
|
+
if (this[y] || (this[y] = /* @__PURE__ */ new Map()), i.length === 2)
|
|
248
|
+
this[y].set(i[0], i[1]);
|
|
249
|
+
else if (ct(i[0]) === "array")
|
|
250
|
+
for (const [t, e] of i[0])
|
|
251
|
+
e === void 0 ? this[y].delete(t) : this[y].set(t, e);
|
|
243
252
|
else
|
|
244
253
|
throw new Error("Invalid arguments.");
|
|
245
254
|
return this;
|
|
246
255
|
}
|
|
247
256
|
};
|
|
248
|
-
|
|
249
|
-
let f =
|
|
250
|
-
function
|
|
251
|
-
return new f(
|
|
257
|
+
k = new WeakMap();
|
|
258
|
+
let f = O;
|
|
259
|
+
function _t(o, i) {
|
|
260
|
+
return new f(o, i);
|
|
252
261
|
}
|
|
253
|
-
class
|
|
262
|
+
class M {
|
|
254
263
|
/**
|
|
255
264
|
* Returns a single DOM node to represent this MarkupNode's position in the DOM.
|
|
256
265
|
* Usually the parent element, but it can be an empty Text node used as a marker.
|
|
@@ -270,7 +279,7 @@ class k {
|
|
|
270
279
|
* Mount this node to a `parent` element.
|
|
271
280
|
* If passed, this node will be mounted as the next sibling of `after`.
|
|
272
281
|
*/
|
|
273
|
-
mount(
|
|
282
|
+
mount(i, t) {
|
|
274
283
|
throw new Error("mount method is not implemented");
|
|
275
284
|
}
|
|
276
285
|
/**
|
|
@@ -281,17 +290,17 @@ class k {
|
|
|
281
290
|
*
|
|
282
291
|
* @param skipDOM - No DOM updates will be performed when true. Lifecycle methods will be called regardless.
|
|
283
292
|
*/
|
|
284
|
-
unmount(
|
|
293
|
+
unmount(i) {
|
|
285
294
|
throw new Error("unmount method is not implemented");
|
|
286
295
|
}
|
|
287
296
|
/**
|
|
288
297
|
* Moves a node without unmounting and remounting (if the browser supports Element.moveBefore).
|
|
289
298
|
*/
|
|
290
|
-
move(
|
|
299
|
+
move(i, t) {
|
|
291
300
|
throw new Error("move method is not implemented");
|
|
292
301
|
}
|
|
293
302
|
}
|
|
294
|
-
class
|
|
303
|
+
class P extends M {
|
|
295
304
|
constructor(t) {
|
|
296
305
|
super();
|
|
297
306
|
a(this, "root");
|
|
@@ -320,15 +329,15 @@ class $ extends k {
|
|
|
320
329
|
this.mount(t, e);
|
|
321
330
|
}
|
|
322
331
|
}
|
|
323
|
-
class
|
|
332
|
+
class C extends M {
|
|
324
333
|
constructor(t, e) {
|
|
325
334
|
super();
|
|
326
335
|
a(this, "root", document.createTextNode(""));
|
|
327
336
|
a(this, "children", []);
|
|
328
337
|
a(this, "context");
|
|
329
|
-
a(this, "
|
|
338
|
+
a(this, "slot");
|
|
330
339
|
a(this, "unsubscribe");
|
|
331
|
-
this.context = t, this
|
|
340
|
+
this.context = t, this.slot = e;
|
|
332
341
|
}
|
|
333
342
|
getRoot() {
|
|
334
343
|
return this.root;
|
|
@@ -337,16 +346,17 @@ class A extends k {
|
|
|
337
346
|
return this.root.parentElement != null;
|
|
338
347
|
}
|
|
339
348
|
mount(t, e) {
|
|
340
|
-
this.isMounted() || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe =
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
this.update(
|
|
345
|
-
})
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
|
|
349
|
+
this.isMounted() || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe = w(
|
|
350
|
+
() => {
|
|
351
|
+
try {
|
|
352
|
+
const s = this.slot();
|
|
353
|
+
this.update(Q(s));
|
|
354
|
+
} catch (s) {
|
|
355
|
+
this.context.crash(s);
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
{ _type: v, deps: [this.slot] }
|
|
359
|
+
));
|
|
350
360
|
}
|
|
351
361
|
unmount(t = !1) {
|
|
352
362
|
var e, s;
|
|
@@ -374,7 +384,7 @@ class A extends k {
|
|
|
374
384
|
update(t) {
|
|
375
385
|
var c, r, h;
|
|
376
386
|
if (this.cleanup(!1), t.length === 0 || !this.isMounted()) return;
|
|
377
|
-
const e =
|
|
387
|
+
const e = B(this.context, t);
|
|
378
388
|
for (const u of e) {
|
|
379
389
|
const l = ((c = this.children.at(-1)) == null ? void 0 : c.getRoot()) || this.root;
|
|
380
390
|
u.mount(this.root.parentElement, l), this.children.push(u);
|
|
@@ -383,8 +393,8 @@ class A extends k {
|
|
|
383
393
|
"moveBefore" in s ? s.moveBefore(this.root, n) : s.insertBefore(this.root, n);
|
|
384
394
|
}
|
|
385
395
|
}
|
|
386
|
-
const
|
|
387
|
-
class
|
|
396
|
+
const X = Symbol("ViewNode");
|
|
397
|
+
class tt extends M {
|
|
388
398
|
/**
|
|
389
399
|
* @param context - Parent contenxt to link to.
|
|
390
400
|
* @param view - View function to mount.
|
|
@@ -392,17 +402,17 @@ class X extends k {
|
|
|
392
402
|
*/
|
|
393
403
|
constructor(t, e, s) {
|
|
394
404
|
super();
|
|
395
|
-
a(this, "
|
|
396
|
-
a(this, "context");
|
|
405
|
+
a(this, "id", $());
|
|
397
406
|
a(this, "props");
|
|
407
|
+
a(this, "context");
|
|
398
408
|
a(this, "view");
|
|
399
409
|
a(this, "node");
|
|
400
410
|
this.context = f.linked(t, e.name ?? "anonymous view", {
|
|
401
411
|
logger: {
|
|
402
|
-
tag: this.
|
|
412
|
+
tag: this.id,
|
|
403
413
|
tagName: "uid"
|
|
404
414
|
}
|
|
405
|
-
}), this.context.setState(
|
|
415
|
+
}), this.context.setState(X, this), this.props = s, this.view = e;
|
|
406
416
|
}
|
|
407
417
|
getRoot() {
|
|
408
418
|
var t;
|
|
@@ -417,28 +427,29 @@ class X extends k {
|
|
|
417
427
|
if (!s) {
|
|
418
428
|
const { context: n, props: c, view: r } = this;
|
|
419
429
|
try {
|
|
420
|
-
const h =
|
|
421
|
-
|
|
430
|
+
const h = S(n), u = r.call(n, c, n);
|
|
431
|
+
S(h), u != null && u !== !1 && (this.node = ot(u, n));
|
|
422
432
|
} catch (h) {
|
|
423
433
|
throw h instanceof Error && n.crash(h), h;
|
|
424
434
|
}
|
|
425
|
-
f.emit(this.context,
|
|
435
|
+
f.emit(this.context, b.WILL_MOUNT);
|
|
426
436
|
}
|
|
427
|
-
this.node && this.node.mount(t, e), s || f.emit(this.context,
|
|
437
|
+
this.node && this.node.mount(t, e), s || f.emit(this.context, b.DID_MOUNT);
|
|
428
438
|
}
|
|
429
439
|
unmount(t = !1) {
|
|
430
|
-
f.emit(this.context,
|
|
440
|
+
f.emit(this.context, b.WILL_UNMOUNT), this.node && this.node.unmount(t), f.emit(this.context, b.DID_UNMOUNT), f.emit(this.context, b.DISPOSE);
|
|
431
441
|
}
|
|
432
442
|
move(t, e) {
|
|
433
443
|
var s;
|
|
434
444
|
(s = this.node) == null || s.move(t, e);
|
|
435
445
|
}
|
|
436
446
|
}
|
|
437
|
-
const
|
|
438
|
-
class
|
|
447
|
+
const gt = (o) => /^on[A-Z]/.test(o), A = Symbol("HTML.isSVG"), bt = ["class", "className", "ref", "mixin", "children"];
|
|
448
|
+
class yt extends M {
|
|
439
449
|
constructor(t, e, s) {
|
|
440
450
|
super();
|
|
441
451
|
a(this, "root");
|
|
452
|
+
a(this, "id", $());
|
|
442
453
|
a(this, "tag");
|
|
443
454
|
a(this, "props");
|
|
444
455
|
a(this, "context");
|
|
@@ -448,17 +459,17 @@ class bt extends k {
|
|
|
448
459
|
a(this, "ref");
|
|
449
460
|
// Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
|
|
450
461
|
a(this, "canClickAway", !1);
|
|
451
|
-
if (this.tag = e, this.props = s, this.context = f.linked(t,
|
|
452
|
-
const c = this.context.getState(
|
|
462
|
+
if (this.tag = e, this.props = s, this.context = f.linked(t, G.bind(this)), e.toLowerCase() === "svg" && this.context.setState(A, !0), this.context.getState(A, { fallback: !1 }) ? this.root = document.createElementNS("http://www.w3.org/2000/svg", e) : this.root = document.createElement(e), at() === "development") {
|
|
463
|
+
const c = this.context.getState(X, { fallback: null });
|
|
453
464
|
c && (this.root.dataset.view = c.context.getName());
|
|
454
465
|
}
|
|
455
466
|
if (s.mixin)
|
|
456
|
-
for (const c of
|
|
457
|
-
const r = f.linked(this.context,
|
|
467
|
+
for (const c of Q(s.mixin)) {
|
|
468
|
+
const r = f.linked(this.context, G.bind(this), {
|
|
458
469
|
bindLifecycleToParent: !0,
|
|
459
470
|
logger: { tagName: c.name === "mixin" ? void 0 : "mixin", tag: c.name }
|
|
460
|
-
}), h =
|
|
461
|
-
c(this.root, r),
|
|
471
|
+
}), h = S(r);
|
|
472
|
+
c(this.root, r), S(h);
|
|
462
473
|
}
|
|
463
474
|
const n = s.className ?? s.class;
|
|
464
475
|
if (this.applyProps(this.root, s), s.style && this.applyStyles(this.root, s.style, this.unsubscribers), n && this.applyClasses(this.root, n, this.unsubscribers), s.ref)
|
|
@@ -466,7 +477,7 @@ class bt extends k {
|
|
|
466
477
|
this.ref = s.ref, this.ref(this.root);
|
|
467
478
|
else
|
|
468
479
|
throw new Error("Expected ref to be a function. Got: " + s.ref);
|
|
469
|
-
s.children && (this.childNodes =
|
|
480
|
+
s.children && (this.childNodes = B(this.context, s.children));
|
|
470
481
|
}
|
|
471
482
|
getRoot() {
|
|
472
483
|
return this.root;
|
|
@@ -477,23 +488,23 @@ class bt extends k {
|
|
|
477
488
|
mount(t, e) {
|
|
478
489
|
const s = this.isMounted();
|
|
479
490
|
if (!s) {
|
|
480
|
-
f.emit(this.context,
|
|
491
|
+
f.emit(this.context, b.WILL_MOUNT);
|
|
481
492
|
for (let n = 0; n < this.childNodes.length; n++) {
|
|
482
493
|
const c = this.childNodes[n], r = n > 0 ? this.childNodes[n - 1].getRoot() : void 0;
|
|
483
494
|
c.mount(this.root, r);
|
|
484
495
|
}
|
|
485
496
|
}
|
|
486
|
-
t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.canClickAway = !0, s || f.emit(this.context,
|
|
497
|
+
t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.canClickAway = !0, s || f.emit(this.context, b.DID_MOUNT);
|
|
487
498
|
}
|
|
488
499
|
unmount(t = !1) {
|
|
489
500
|
var e;
|
|
490
|
-
f.emit(this.context,
|
|
501
|
+
f.emit(this.context, b.WILL_UNMOUNT), t || (e = this.root.parentNode) == null || e.removeChild(this.root);
|
|
491
502
|
for (const s of this.childNodes)
|
|
492
503
|
s.unmount(!0);
|
|
493
504
|
this.canClickAway = !1;
|
|
494
505
|
for (const s of this.unsubscribers)
|
|
495
506
|
s();
|
|
496
|
-
this.unsubscribers.length = 0, this.ref && this.ref(void 0), f.emit(this.context,
|
|
507
|
+
this.unsubscribers.length = 0, this.ref && this.ref(void 0), f.emit(this.context, b.DID_UNMOUNT), f.emit(this.context, b.DISPOSE);
|
|
497
508
|
}
|
|
498
509
|
move(t, e) {
|
|
499
510
|
if ("moveBefore" in t)
|
|
@@ -505,19 +516,25 @@ class bt extends k {
|
|
|
505
516
|
else
|
|
506
517
|
this.mount(t, e);
|
|
507
518
|
}
|
|
508
|
-
attachProp(t, e) {
|
|
519
|
+
attachProp(t, e, s) {
|
|
509
520
|
m(t) ? this.unsubscribers.push(
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
521
|
+
w(
|
|
522
|
+
() => {
|
|
523
|
+
try {
|
|
524
|
+
e(t());
|
|
525
|
+
} catch (n) {
|
|
526
|
+
this.context.error(n), this.context.crash(n);
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
{ _type: v }
|
|
530
|
+
)
|
|
517
531
|
) : e(t);
|
|
518
532
|
}
|
|
533
|
+
getKey(t) {
|
|
534
|
+
return this.id + ":" + t;
|
|
535
|
+
}
|
|
519
536
|
applyProps(t, e) {
|
|
520
|
-
for (const s in
|
|
537
|
+
for (const s in ht(bt, e)) {
|
|
521
538
|
const n = e[s];
|
|
522
539
|
if (s === "on:clickoutside" || s === "onClickOutside" || s === "onclickoutside") {
|
|
523
540
|
const c = (h) => {
|
|
@@ -528,92 +545,144 @@ class bt extends k {
|
|
|
528
545
|
});
|
|
529
546
|
} else if (s.startsWith("prop:")) {
|
|
530
547
|
const c = s.substring(5);
|
|
531
|
-
this.attachProp(
|
|
532
|
-
|
|
533
|
-
|
|
548
|
+
this.attachProp(
|
|
549
|
+
n,
|
|
550
|
+
(r) => {
|
|
551
|
+
t[c] = r;
|
|
552
|
+
},
|
|
553
|
+
this.getKey(c)
|
|
554
|
+
);
|
|
534
555
|
} else if (s.startsWith("on:")) {
|
|
535
556
|
const c = s.substring(3);
|
|
536
557
|
let r;
|
|
537
558
|
m(n) ? (t.addEventListener(c, n), this.unsubscribers.push(() => {
|
|
538
559
|
t.removeEventListener(c, n);
|
|
539
|
-
})) : this.attachProp(
|
|
540
|
-
|
|
541
|
-
|
|
560
|
+
})) : this.attachProp(
|
|
561
|
+
n,
|
|
562
|
+
(h) => {
|
|
563
|
+
!h && r ? t.removeEventListener(c, r) : h != null && (r && r !== h && t.removeEventListener(c, r), t.addEventListener(c, h)), r = h;
|
|
564
|
+
},
|
|
565
|
+
this.getKey(c)
|
|
566
|
+
);
|
|
542
567
|
} else if (s.startsWith("attr:")) {
|
|
543
568
|
const c = s.substring(5).toLowerCase();
|
|
544
|
-
this.attachProp(
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
569
|
+
this.attachProp(
|
|
570
|
+
n,
|
|
571
|
+
(r) => {
|
|
572
|
+
r != null ? t.setAttribute(c, String(r)) : t.removeAttribute(c);
|
|
573
|
+
},
|
|
574
|
+
this.getKey(c)
|
|
575
|
+
);
|
|
576
|
+
} else if (m(n) && gt(s)) {
|
|
548
577
|
const c = s.slice(2).toLowerCase(), r = n;
|
|
549
578
|
t.addEventListener(c, r), this.unsubscribers.push(() => {
|
|
550
579
|
t.removeEventListener(c, r);
|
|
551
580
|
});
|
|
552
|
-
} else if (s.startsWith("on") && m(n) &&
|
|
581
|
+
} else if (s.startsWith("on") && m(n) && wt.includes(s.substring(2)))
|
|
553
582
|
t[s] = n, this.unsubscribers.push(() => {
|
|
554
583
|
t[s] = void 0;
|
|
555
584
|
});
|
|
556
585
|
else if (s.includes("-"))
|
|
557
|
-
this.attachProp(
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
586
|
+
this.attachProp(
|
|
587
|
+
n,
|
|
588
|
+
(c) => {
|
|
589
|
+
c == null ? t.removeAttribute(s) : t.setAttribute(s, String(c));
|
|
590
|
+
},
|
|
591
|
+
this.getKey(s)
|
|
592
|
+
);
|
|
593
|
+
else if (this.context.getState(A, { fallback: !1 }))
|
|
594
|
+
this.attachProp(
|
|
595
|
+
n,
|
|
596
|
+
(c) => {
|
|
597
|
+
c != null ? t.setAttribute(s, String(e[s])) : t.removeAttribute(s);
|
|
598
|
+
},
|
|
599
|
+
this.getKey(s)
|
|
600
|
+
);
|
|
564
601
|
else
|
|
565
602
|
switch (s) {
|
|
566
603
|
case "contentEditable":
|
|
567
604
|
case "value":
|
|
568
|
-
this.attachProp(
|
|
569
|
-
|
|
570
|
-
|
|
605
|
+
this.attachProp(
|
|
606
|
+
n,
|
|
607
|
+
(r) => {
|
|
608
|
+
t[s] = String(r);
|
|
609
|
+
},
|
|
610
|
+
this.getKey(s)
|
|
611
|
+
);
|
|
571
612
|
break;
|
|
572
613
|
case "for":
|
|
573
|
-
this.attachProp(
|
|
574
|
-
|
|
575
|
-
|
|
614
|
+
this.attachProp(
|
|
615
|
+
n,
|
|
616
|
+
(r) => {
|
|
617
|
+
t.htmlFor = r;
|
|
618
|
+
},
|
|
619
|
+
this.getKey(s)
|
|
620
|
+
);
|
|
576
621
|
break;
|
|
577
622
|
case "innerHTML":
|
|
578
|
-
this.attachProp(
|
|
579
|
-
|
|
580
|
-
|
|
623
|
+
this.attachProp(
|
|
624
|
+
n,
|
|
625
|
+
(r) => {
|
|
626
|
+
t.innerHTML = r;
|
|
627
|
+
},
|
|
628
|
+
this.getKey(s)
|
|
629
|
+
);
|
|
581
630
|
break;
|
|
582
631
|
case "title":
|
|
583
|
-
this.attachProp(
|
|
584
|
-
|
|
585
|
-
|
|
632
|
+
this.attachProp(
|
|
633
|
+
n,
|
|
634
|
+
(r) => {
|
|
635
|
+
r == null ? t.removeAttribute(s) : t.setAttribute(s, String(r));
|
|
636
|
+
},
|
|
637
|
+
this.getKey(s)
|
|
638
|
+
);
|
|
586
639
|
case "checked":
|
|
587
|
-
this.attachProp(
|
|
588
|
-
|
|
589
|
-
|
|
640
|
+
this.attachProp(
|
|
641
|
+
n,
|
|
642
|
+
(r) => {
|
|
643
|
+
t.checked = r, r ? t.setAttribute("checked", "") : t.removeAttribute("checked");
|
|
644
|
+
},
|
|
645
|
+
this.getKey(s)
|
|
646
|
+
);
|
|
590
647
|
break;
|
|
591
648
|
case "dataset":
|
|
592
649
|
let c = {};
|
|
593
|
-
this.attachProp(
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
h
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
650
|
+
this.attachProp(
|
|
651
|
+
n,
|
|
652
|
+
(r) => {
|
|
653
|
+
if (D(r)) {
|
|
654
|
+
const h = {};
|
|
655
|
+
for (const u in r)
|
|
656
|
+
h[ut(u)] = String(r[u]);
|
|
657
|
+
for (const u in c)
|
|
658
|
+
Object.hasOwn(h, u) || (delete t.dataset[u], delete c[u]);
|
|
659
|
+
for (const u in h)
|
|
660
|
+
c[u] !== h[u] && (t.dataset[u] = h[u], c[u] = h[u]);
|
|
661
|
+
} else
|
|
662
|
+
for (const h in c)
|
|
663
|
+
delete t.dataset[h];
|
|
664
|
+
},
|
|
665
|
+
this.getKey(s)
|
|
666
|
+
);
|
|
606
667
|
break;
|
|
607
668
|
case "autocomplete":
|
|
608
669
|
case "autocapitalize":
|
|
609
|
-
this.attachProp(
|
|
610
|
-
|
|
611
|
-
|
|
670
|
+
this.attachProp(
|
|
671
|
+
n,
|
|
672
|
+
(r) => {
|
|
673
|
+
typeof r == "string" ? t[s] = r : r ? t[s] = "on" : t[s] = "off";
|
|
674
|
+
},
|
|
675
|
+
this.getKey(s)
|
|
676
|
+
);
|
|
612
677
|
break;
|
|
613
678
|
default: {
|
|
614
|
-
this.attachProp(
|
|
615
|
-
|
|
616
|
-
|
|
679
|
+
this.attachProp(
|
|
680
|
+
n,
|
|
681
|
+
(r) => {
|
|
682
|
+
t[s] = r;
|
|
683
|
+
},
|
|
684
|
+
this.getKey(s)
|
|
685
|
+
);
|
|
617
686
|
break;
|
|
618
687
|
}
|
|
619
688
|
}
|
|
@@ -623,18 +692,24 @@ class bt extends k {
|
|
|
623
692
|
const n = [];
|
|
624
693
|
if (m(e)) {
|
|
625
694
|
let c;
|
|
626
|
-
const r =
|
|
627
|
-
|
|
628
|
-
|
|
695
|
+
const r = w(
|
|
696
|
+
() => {
|
|
697
|
+
m(c) && c(), t.style.cssText = "", c = this.applyStyles(t, x(e), s);
|
|
698
|
+
},
|
|
699
|
+
{ _type: v }
|
|
700
|
+
);
|
|
629
701
|
s.push(r), n.push(r);
|
|
630
702
|
} else {
|
|
631
|
-
const c =
|
|
703
|
+
const c = st(e);
|
|
632
704
|
for (const r in c) {
|
|
633
705
|
const { value: h, priority: u } = c[r];
|
|
634
706
|
if (m(h)) {
|
|
635
|
-
const l =
|
|
636
|
-
|
|
637
|
-
|
|
707
|
+
const l = w(
|
|
708
|
+
() => {
|
|
709
|
+
x(h) ? t.style.setProperty(r, String(x(h)), u) : t.style.removeProperty(r);
|
|
710
|
+
},
|
|
711
|
+
{ _type: v }
|
|
712
|
+
);
|
|
638
713
|
s.push(l), n.push(l);
|
|
639
714
|
} else h != null && t.style.setProperty(r, String(h));
|
|
640
715
|
}
|
|
@@ -648,18 +723,24 @@ class bt extends k {
|
|
|
648
723
|
const n = [];
|
|
649
724
|
if (m(e)) {
|
|
650
725
|
let c;
|
|
651
|
-
const r =
|
|
652
|
-
|
|
653
|
-
|
|
726
|
+
const r = w(
|
|
727
|
+
() => {
|
|
728
|
+
m(c) && c(), t.removeAttribute("class"), c = this.applyClasses(t, x(e), s);
|
|
729
|
+
},
|
|
730
|
+
{ _type: v }
|
|
731
|
+
);
|
|
654
732
|
s.push(r), n.push(r);
|
|
655
733
|
} else {
|
|
656
|
-
const c =
|
|
734
|
+
const c = et(e);
|
|
657
735
|
for (const r in c) {
|
|
658
736
|
const h = c[r];
|
|
659
737
|
if (m(h)) {
|
|
660
|
-
const u =
|
|
661
|
-
|
|
662
|
-
|
|
738
|
+
const u = w(
|
|
739
|
+
() => {
|
|
740
|
+
x(h) ? t.classList.add(r) : t.classList.remove(r);
|
|
741
|
+
},
|
|
742
|
+
{ _type: v }
|
|
743
|
+
);
|
|
663
744
|
s.push(u), n.push(u);
|
|
664
745
|
} else h && t.classList.add(r);
|
|
665
746
|
}
|
|
@@ -670,49 +751,49 @@ class bt extends k {
|
|
|
670
751
|
};
|
|
671
752
|
}
|
|
672
753
|
}
|
|
673
|
-
function
|
|
674
|
-
let
|
|
675
|
-
if (
|
|
676
|
-
const t =
|
|
754
|
+
function et(o) {
|
|
755
|
+
let i = {};
|
|
756
|
+
if (R(o)) {
|
|
757
|
+
const t = o.split(" ");
|
|
677
758
|
for (const e of t)
|
|
678
|
-
|
|
679
|
-
} else
|
|
680
|
-
Object.assign(
|
|
759
|
+
i[e] = !0;
|
|
760
|
+
} else D(o) ? Object.assign(i, o) : Array.isArray(o) && Array.from(o).filter(Boolean).forEach((t) => {
|
|
761
|
+
Object.assign(i, et(t));
|
|
681
762
|
});
|
|
682
|
-
return delete
|
|
763
|
+
return delete i.undefined, i;
|
|
683
764
|
}
|
|
684
|
-
function
|
|
685
|
-
let
|
|
686
|
-
if (
|
|
687
|
-
const t =
|
|
765
|
+
function st(o) {
|
|
766
|
+
let i = {};
|
|
767
|
+
if (R(o)) {
|
|
768
|
+
const t = o.split(";").filter((e) => e.trim() !== "");
|
|
688
769
|
for (const e of t) {
|
|
689
770
|
const [s, n] = e.split(":"), c = {
|
|
690
771
|
value: n
|
|
691
772
|
};
|
|
692
|
-
n.includes("!important") ? (c.priority = "important", c.value = n.replace("!important", "").trim()) : c.value = n.trim(),
|
|
773
|
+
n.includes("!important") ? (c.priority = "important", c.value = n.replace("!important", "").trim()) : c.value = n.trim(), i[q(s.trim())] = c;
|
|
693
774
|
}
|
|
694
775
|
}
|
|
695
|
-
if (
|
|
696
|
-
for (const t in
|
|
697
|
-
t.startsWith("--") ?
|
|
698
|
-
else Array.isArray(
|
|
699
|
-
Object.assign(
|
|
776
|
+
if (D(o))
|
|
777
|
+
for (const t in o)
|
|
778
|
+
t.startsWith("--") ? i[t] = { value: o[t] } : i[q(t)] = { value: o[t] };
|
|
779
|
+
else Array.isArray(o) && Array.from(o).filter((t) => t != null).forEach((t) => {
|
|
780
|
+
Object.assign(i, st(t));
|
|
700
781
|
});
|
|
701
|
-
return
|
|
782
|
+
return i;
|
|
702
783
|
}
|
|
703
|
-
function
|
|
704
|
-
const
|
|
705
|
-
if (
|
|
706
|
-
let
|
|
707
|
-
if (
|
|
708
|
-
for (const t of
|
|
709
|
-
|
|
710
|
-
return
|
|
784
|
+
function G() {
|
|
785
|
+
const o = this.getRoot();
|
|
786
|
+
if (o == null) return this.tag;
|
|
787
|
+
let i = this.getRoot().tagName.toLowerCase();
|
|
788
|
+
if (o.id && (i += `#${o.id}`), o.classList.length > 0)
|
|
789
|
+
for (const t of o.classList.values())
|
|
790
|
+
i += `.${t}`;
|
|
791
|
+
return i;
|
|
711
792
|
}
|
|
712
|
-
function
|
|
713
|
-
return
|
|
793
|
+
function q(o) {
|
|
794
|
+
return o.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (i, t) => (t ? "-" : "") + i.toLowerCase());
|
|
714
795
|
}
|
|
715
|
-
const
|
|
796
|
+
const wt = [
|
|
716
797
|
// Element
|
|
717
798
|
"animationcancel",
|
|
718
799
|
"animationend",
|
|
@@ -802,7 +883,7 @@ const gt = [
|
|
|
802
883
|
"reset",
|
|
803
884
|
"submit"
|
|
804
885
|
];
|
|
805
|
-
class
|
|
886
|
+
class vt extends M {
|
|
806
887
|
constructor(t, e, s) {
|
|
807
888
|
super();
|
|
808
889
|
a(this, "context");
|
|
@@ -829,7 +910,7 @@ class wt extends k {
|
|
|
829
910
|
move(t, e) {
|
|
830
911
|
}
|
|
831
912
|
}
|
|
832
|
-
class
|
|
913
|
+
class xt extends M {
|
|
833
914
|
constructor(t, e, s, n) {
|
|
834
915
|
super();
|
|
835
916
|
a(this, "root", document.createTextNode(""));
|
|
@@ -848,12 +929,15 @@ class vt extends k {
|
|
|
848
929
|
return this.root.parentElement != null;
|
|
849
930
|
}
|
|
850
931
|
mount(t, e) {
|
|
851
|
-
this.isMounted() || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe =
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
this.
|
|
855
|
-
|
|
856
|
-
|
|
932
|
+
this.isMounted() || (t.insertBefore(this.root, (e == null ? void 0 : e.nextSibling) ?? null), this.unsubscribe = w(
|
|
933
|
+
() => {
|
|
934
|
+
let s = this.items();
|
|
935
|
+
s == null && (s = [], this.context.warn("repeat() received empty value for items", s)), L(() => {
|
|
936
|
+
this._update(Array.from(s));
|
|
937
|
+
});
|
|
938
|
+
},
|
|
939
|
+
{ _type: v }
|
|
940
|
+
));
|
|
857
941
|
}
|
|
858
942
|
unmount(t = !1) {
|
|
859
943
|
var e;
|
|
@@ -884,20 +968,20 @@ class vt extends k {
|
|
|
884
968
|
const n = [];
|
|
885
969
|
for (const l of this.connectedItems.values())
|
|
886
970
|
!e.has(l.key) && l.node.isMounted() && l.node.unmount(!1);
|
|
887
|
-
|
|
971
|
+
lt(() => {
|
|
888
972
|
for (const l of e.values()) {
|
|
889
973
|
const p = this.connectedItems.get(l.key);
|
|
890
974
|
if (p && p.node.isMounted())
|
|
891
|
-
p
|
|
975
|
+
p.item.set(l.value), p.index.set(l.index), n[l.index] = p;
|
|
892
976
|
else {
|
|
893
|
-
const
|
|
977
|
+
const E = F(l.value, { equals: dt }), I = F(l.index);
|
|
894
978
|
n[l.index] = {
|
|
895
979
|
key: l.key,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
node: new
|
|
899
|
-
|
|
900
|
-
|
|
980
|
+
item: E,
|
|
981
|
+
index: I,
|
|
982
|
+
node: new tt(this.context, kt, {
|
|
983
|
+
item: () => E(),
|
|
984
|
+
index: () => I(),
|
|
901
985
|
render: this.render
|
|
902
986
|
})
|
|
903
987
|
};
|
|
@@ -905,8 +989,8 @@ class vt extends k {
|
|
|
905
989
|
}
|
|
906
990
|
});
|
|
907
991
|
for (let l = 0; l < n.length; l++) {
|
|
908
|
-
const p = n[l],
|
|
909
|
-
|
|
992
|
+
const p = n[l], E = ((r = n[l - 1]) == null ? void 0 : r.node.getRoot()) ?? this.root, I = this.connectedItems.get(p.key);
|
|
993
|
+
I && I.node.isMounted() ? p.node.move(this.root.parentElement, E) : p.node.mount(this.root.parentElement, E);
|
|
910
994
|
}
|
|
911
995
|
this.connectedItems.clear();
|
|
912
996
|
for (const l of n)
|
|
@@ -915,12 +999,12 @@ class vt extends k {
|
|
|
915
999
|
(u = this.root.parentNode) == null || u.insertBefore(this.root, c.nextSibling);
|
|
916
1000
|
}
|
|
917
1001
|
}
|
|
918
|
-
const
|
|
919
|
-
function
|
|
920
|
-
return
|
|
1002
|
+
const Nt = "dolla.RepeatItemView";
|
|
1003
|
+
function kt(o, i) {
|
|
1004
|
+
return i.setName(Nt), o.render.call(i, o.item, o.index, i);
|
|
921
1005
|
}
|
|
922
|
-
class
|
|
923
|
-
constructor(
|
|
1006
|
+
class it {
|
|
1007
|
+
constructor(i, t) {
|
|
924
1008
|
/**
|
|
925
1009
|
* In the case of a view, type will be the View function itself. It can also hold an identifier for special nodes like "$cond", "$repeat", etc.
|
|
926
1010
|
* DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
|
|
@@ -931,100 +1015,101 @@ class st {
|
|
|
931
1015
|
* Includes a `children` prop if children were passed.
|
|
932
1016
|
*/
|
|
933
1017
|
a(this, "props");
|
|
934
|
-
this.type =
|
|
1018
|
+
this.type = i, this.props = t;
|
|
935
1019
|
}
|
|
936
1020
|
}
|
|
937
|
-
var
|
|
938
|
-
function
|
|
939
|
-
return new
|
|
1021
|
+
var Mt = /* @__PURE__ */ ((o) => (o.DOM = "$dom", o.Dynamic = "$dynamic", o.Portal = "$portal", o.Repeat = "$repeat", o))(Mt || {});
|
|
1022
|
+
function W(o, i) {
|
|
1023
|
+
return new it(o, i ?? {});
|
|
940
1024
|
}
|
|
941
|
-
function
|
|
942
|
-
return
|
|
943
|
-
source:
|
|
944
|
-
const e = x(
|
|
945
|
-
return e &&
|
|
1025
|
+
function St(o, i, t) {
|
|
1026
|
+
return W("$dynamic", {
|
|
1027
|
+
source: ft(() => {
|
|
1028
|
+
const e = x(o);
|
|
1029
|
+
return e && i ? i : !e && t ? t : null;
|
|
946
1030
|
})
|
|
947
1031
|
});
|
|
948
1032
|
}
|
|
949
|
-
function
|
|
950
|
-
return
|
|
1033
|
+
function Tt(o, i, t) {
|
|
1034
|
+
return St(o, t, i);
|
|
951
1035
|
}
|
|
952
|
-
function
|
|
953
|
-
return
|
|
1036
|
+
function Ut(o, i, t) {
|
|
1037
|
+
return W("$repeat", { items: () => x(o), key: i, render: t });
|
|
954
1038
|
}
|
|
955
|
-
function
|
|
956
|
-
return
|
|
1039
|
+
function Pt(o, i) {
|
|
1040
|
+
return W("$portal", { parent: o, content: i });
|
|
957
1041
|
}
|
|
958
|
-
function ot(
|
|
959
|
-
const t =
|
|
960
|
-
return t.length === 1 ? t[0] : new
|
|
1042
|
+
function ot(o, i = new f("$")) {
|
|
1043
|
+
const t = B(i, o);
|
|
1044
|
+
return t.length === 1 ? t[0] : new C(i, () => t);
|
|
961
1045
|
}
|
|
962
|
-
function
|
|
963
|
-
const t =
|
|
1046
|
+
function B(o, ...i) {
|
|
1047
|
+
const t = i.flat(1 / 0), e = [];
|
|
964
1048
|
for (const s of t)
|
|
965
1049
|
if (!(s == null || s === !1)) {
|
|
966
1050
|
if (s instanceof Node) {
|
|
967
|
-
e.push(new
|
|
1051
|
+
e.push(new P(s));
|
|
968
1052
|
continue;
|
|
969
1053
|
}
|
|
970
|
-
if (s instanceof
|
|
1054
|
+
if (s instanceof it)
|
|
971
1055
|
if (m(s.type)) {
|
|
972
|
-
e.push(new
|
|
1056
|
+
e.push(new tt(o, s.type, s.props));
|
|
973
1057
|
continue;
|
|
974
|
-
} else if (
|
|
1058
|
+
} else if (R(s.type))
|
|
975
1059
|
switch (s.type) {
|
|
976
1060
|
case "$dom": {
|
|
977
1061
|
const n = s.props;
|
|
978
|
-
e.push(new
|
|
1062
|
+
e.push(new P(n.value));
|
|
979
1063
|
continue;
|
|
980
1064
|
}
|
|
981
1065
|
case "$dynamic": {
|
|
982
1066
|
const n = s.props;
|
|
983
|
-
e.push(new
|
|
1067
|
+
e.push(new C(o, n.source));
|
|
984
1068
|
continue;
|
|
985
1069
|
}
|
|
986
1070
|
case "$portal": {
|
|
987
1071
|
const n = s.props;
|
|
988
|
-
e.push(new
|
|
1072
|
+
e.push(new vt(o, n.content, n.parent));
|
|
989
1073
|
continue;
|
|
990
1074
|
}
|
|
991
1075
|
case "$repeat": {
|
|
992
1076
|
const n = s.props;
|
|
993
|
-
e.push(new
|
|
1077
|
+
e.push(new xt(o, n.items, n.key, n.render));
|
|
994
1078
|
continue;
|
|
995
1079
|
}
|
|
996
1080
|
default:
|
|
997
|
-
e.push(new
|
|
1081
|
+
e.push(new yt(o, s.type, s.props));
|
|
998
1082
|
continue;
|
|
999
1083
|
}
|
|
1000
1084
|
else
|
|
1001
1085
|
throw new TypeError(`Expected a string or view function. Got: ${s.type}`);
|
|
1002
|
-
if (s instanceof
|
|
1086
|
+
if (s instanceof M) {
|
|
1003
1087
|
e.push(s);
|
|
1004
1088
|
continue;
|
|
1005
1089
|
}
|
|
1006
1090
|
if (m(s)) {
|
|
1007
|
-
e.push(new
|
|
1091
|
+
e.push(new C(o, s));
|
|
1008
1092
|
continue;
|
|
1009
1093
|
}
|
|
1010
|
-
e.push(new
|
|
1094
|
+
e.push(new P(document.createTextNode(String(s))));
|
|
1011
1095
|
}
|
|
1012
1096
|
return e;
|
|
1013
1097
|
}
|
|
1014
1098
|
export {
|
|
1015
1099
|
f as C,
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1100
|
+
C as D,
|
|
1101
|
+
b as L,
|
|
1102
|
+
it as M,
|
|
1103
|
+
xt as R,
|
|
1104
|
+
tt as V,
|
|
1105
|
+
M as a,
|
|
1106
|
+
Ut as b,
|
|
1107
|
+
_t as c,
|
|
1108
|
+
Mt as d,
|
|
1109
|
+
W as m,
|
|
1110
|
+
Pt as p,
|
|
1026
1111
|
ot as r,
|
|
1027
|
-
|
|
1028
|
-
|
|
1112
|
+
Tt as u,
|
|
1113
|
+
St as w
|
|
1029
1114
|
};
|
|
1030
|
-
//# sourceMappingURL=markup-
|
|
1115
|
+
//# sourceMappingURL=markup-CW_lWDfq.js.map
|