@manyducks.co/dolla 2.0.0-alpha.52 → 2.0.0-alpha.54
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/index.d.ts +2 -0
- package/dist/core/logger.d.ts +8 -3
- package/dist/core/mixin.d.ts +62 -0
- package/dist/core/nodes/html.d.ts +3 -2
- package/dist/core/nodes/view.d.ts +2 -2
- package/dist/core/ref.d.ts +22 -0
- package/dist/core/views/default-crash-view.d.ts +5 -1
- package/dist/{fragment-DSGTP-XE.js → fragment-CmWsN-4Y.js} +2 -2
- package/dist/{fragment-DSGTP-XE.js.map → fragment-CmWsN-4Y.js.map} +1 -1
- package/dist/i18n.js +1 -1
- package/dist/index.js +72 -51
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/{logger-CSRDjb4e.js → logger-CBfhf3fA.js} +153 -151
- package/dist/{logger-CSRDjb4e.js.map → logger-CBfhf3fA.js.map} +1 -1
- package/dist/{router-BYOH-To5.js → router-BoJac1lD.js} +3 -3
- package/dist/{router-BYOH-To5.js.map → router-BoJac1lD.js.map} +1 -1
- package/dist/router.js +1 -1
- package/dist/types.d.ts +21 -0
- package/dist/{view-CY19Cf0X.js → view-BKpHFpWG.js} +504 -392
- package/dist/view-BKpHFpWG.js.map +1 -0
- package/docs/i18n.md +17 -12
- package/docs/mixins.md +32 -0
- package/index.d.ts +1 -1
- package/notes/effection-idea.md +34 -0
- package/notes/mixins.md +22 -0
- package/package.json +1 -1
- package/dist/view-CY19Cf0X.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var ee = Object.defineProperty;
|
|
2
|
-
var te = (
|
|
3
|
-
var r = (
|
|
4
|
-
import { t as
|
|
5
|
-
import { e as
|
|
2
|
+
var te = (i, e, t) => e in i ? ee(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var r = (i, e, t) => te(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { t as R, g as f, c as h, i as C, b as $, h as se, j as z } from "./typeChecking-EAVNeFyB.js";
|
|
5
|
+
import { e as a, p as w, g as y, j as A, $ as x, f as P, b as ne, k as ie, d as oe } from "./logger-CBfhf3fA.js";
|
|
6
6
|
const W = /* @__PURE__ */ new Map(), S = {
|
|
7
7
|
stores: W
|
|
8
8
|
}, p = Symbol.for("DollaMarkupElement");
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
class
|
|
9
|
+
var F;
|
|
10
|
+
F = p;
|
|
11
|
+
class O {
|
|
12
12
|
constructor(e) {
|
|
13
|
-
r(this,
|
|
13
|
+
r(this, F, !0);
|
|
14
14
|
r(this, "domNode");
|
|
15
15
|
this.domNode = e;
|
|
16
16
|
}
|
|
@@ -24,11 +24,11 @@ class I {
|
|
|
24
24
|
this.domNode.parentNode && !e && this.domNode.parentNode.removeChild(this.domNode);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
var
|
|
28
|
-
|
|
27
|
+
var T;
|
|
28
|
+
T = p;
|
|
29
29
|
class re {
|
|
30
30
|
constructor(e) {
|
|
31
|
-
r(this,
|
|
31
|
+
r(this, T, !0);
|
|
32
32
|
r(this, "domNode", document.createTextNode(""));
|
|
33
33
|
r(this, "children", []);
|
|
34
34
|
r(this, "elementContext");
|
|
@@ -40,19 +40,19 @@ class re {
|
|
|
40
40
|
return this.domNode.parentNode != null;
|
|
41
41
|
}
|
|
42
42
|
mount(e, t) {
|
|
43
|
-
this.isMounted || (e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe =
|
|
43
|
+
this.isMounted || (e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe = a(() => {
|
|
44
44
|
try {
|
|
45
45
|
const s = this.source();
|
|
46
|
-
if (!
|
|
46
|
+
if (!Y(s))
|
|
47
47
|
throw console.error(s), new TypeError(
|
|
48
|
-
`Dynamic received invalid value to render. Got type: ${
|
|
48
|
+
`Dynamic received invalid value to render. Got type: ${R(s)}, value: ${s}`
|
|
49
49
|
);
|
|
50
|
-
|
|
50
|
+
w(() => {
|
|
51
51
|
this.update(f(s) ? s : [s]);
|
|
52
52
|
});
|
|
53
53
|
} catch (s) {
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const n = this.elementContext.view.logger;
|
|
55
|
+
n.error(s), n.crash(s);
|
|
56
56
|
}
|
|
57
57
|
}));
|
|
58
58
|
}
|
|
@@ -66,23 +66,23 @@ class re {
|
|
|
66
66
|
this.children = [];
|
|
67
67
|
}
|
|
68
68
|
update(e) {
|
|
69
|
-
var o,
|
|
69
|
+
var o, c, u;
|
|
70
70
|
if (this.cleanup(!1), e == null || e.length === 0 || !this.isMounted)
|
|
71
71
|
return;
|
|
72
|
-
const t = e.flatMap((
|
|
73
|
-
for (const
|
|
72
|
+
const t = e.flatMap((d) => Q(d) ? d : N(this.elementContext, M(d)));
|
|
73
|
+
for (const d of t) {
|
|
74
74
|
const l = ((o = this.children.at(-1)) == null ? void 0 : o.domNode) || this.domNode;
|
|
75
|
-
|
|
75
|
+
d.mount(this.domNode.parentNode, l), this.children.push(d);
|
|
76
76
|
}
|
|
77
|
-
const s = this.domNode.parentNode,
|
|
78
|
-
"moveBefore" in s ? s.moveBefore(this.domNode,
|
|
77
|
+
const s = this.domNode.parentNode, n = ((u = (c = this.children.at(-1)) == null ? void 0 : c.domNode) == null ? void 0 : u.nextSibling) ?? null;
|
|
78
|
+
"moveBefore" in s ? s.moveBefore(this.domNode, n) : s.insertBefore(this.domNode, n);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
var
|
|
82
|
-
|
|
81
|
+
var j;
|
|
82
|
+
j = p;
|
|
83
83
|
class Z {
|
|
84
84
|
constructor(e) {
|
|
85
|
-
r(this,
|
|
85
|
+
r(this, j, !0);
|
|
86
86
|
r(this, "domNode", document.createTextNode(""));
|
|
87
87
|
r(this, "isMounted", !1);
|
|
88
88
|
r(this, "source");
|
|
@@ -91,9 +91,9 @@ class Z {
|
|
|
91
91
|
this.source = e;
|
|
92
92
|
}
|
|
93
93
|
mount(e, t) {
|
|
94
|
-
this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), h(this.source) ? this.unsubscribe =
|
|
95
|
-
const s =
|
|
96
|
-
|
|
94
|
+
this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), h(this.source) ? this.unsubscribe = a(() => {
|
|
95
|
+
const s = y(this.source);
|
|
96
|
+
w(() => {
|
|
97
97
|
this.update(s);
|
|
98
98
|
});
|
|
99
99
|
}) : this.update(this.elements));
|
|
@@ -109,43 +109,278 @@ class Z {
|
|
|
109
109
|
update(e) {
|
|
110
110
|
var t, s;
|
|
111
111
|
if (this.cleanup(!1), e.length > 0) {
|
|
112
|
-
for (let
|
|
113
|
-
const o = e[
|
|
114
|
-
o.mount(this.domNode.parentElement,
|
|
112
|
+
for (let n = 0; n < e.length; n++) {
|
|
113
|
+
const o = e[n], c = n > 0 ? this.elements[n - 1] : void 0;
|
|
114
|
+
o.mount(this.domNode.parentElement, c == null ? void 0 : c.domNode), this.elements.push(o);
|
|
115
115
|
}
|
|
116
116
|
(s = this.domNode.parentNode) == null || s.insertBefore(this.domNode, ((t = this.elements.at(-1)) == null ? void 0 : t.domNode) ?? null);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
let ce = class {
|
|
121
|
+
constructor(e) {
|
|
122
|
+
r(this, "store");
|
|
123
|
+
this.store = e;
|
|
124
|
+
const t = Object.getOwnPropertyDescriptors(this.store.logger);
|
|
125
|
+
for (const s in t)
|
|
126
|
+
s !== "setName" && Object.defineProperty(this, s, t[s]);
|
|
127
|
+
}
|
|
128
|
+
get isMounted() {
|
|
129
|
+
return this.store.isMounted;
|
|
130
|
+
}
|
|
131
|
+
get name() {
|
|
132
|
+
return w(this.store.name) || this.store.id;
|
|
133
|
+
}
|
|
134
|
+
set name(e) {
|
|
135
|
+
this.store.name(e);
|
|
136
|
+
}
|
|
137
|
+
get(e) {
|
|
138
|
+
if (h(e)) {
|
|
139
|
+
let t = this.store.elementContext, s;
|
|
140
|
+
for (; s = t.stores.get(e), s == null && t.parent != null; )
|
|
141
|
+
t = t.parent;
|
|
142
|
+
if (s == null)
|
|
143
|
+
throw new g(`Store '${e.name}' is not provided on this context.`);
|
|
144
|
+
return s.value;
|
|
145
|
+
} else
|
|
146
|
+
throw new g("Invalid store.");
|
|
147
|
+
}
|
|
148
|
+
onMount(e) {
|
|
149
|
+
this.store.lifecycleListeners.mount.push(e);
|
|
150
|
+
}
|
|
151
|
+
onUnmount(e) {
|
|
152
|
+
this.store.lifecycleListeners.unmount.push(e);
|
|
153
|
+
}
|
|
154
|
+
effect(e) {
|
|
155
|
+
const t = this.store, s = () => {
|
|
156
|
+
try {
|
|
157
|
+
return e();
|
|
158
|
+
} catch (n) {
|
|
159
|
+
n instanceof Error ? this.crash(n) : typeof n == "string" ? this.crash(new Error(n)) : (this.error(n), this.crash(new Error("Unknown error thrown in effect callback")));
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
if (t.isMounted) {
|
|
163
|
+
const n = a(s);
|
|
164
|
+
return t.lifecycleListeners.unmount.push(n), n;
|
|
165
|
+
} else {
|
|
166
|
+
let n, o = !1;
|
|
167
|
+
return t.lifecycleListeners.mount.push(() => {
|
|
168
|
+
o || (n = a(s), t.lifecycleListeners.unmount.push(n));
|
|
169
|
+
}), () => {
|
|
170
|
+
n != null && (o = !0, n());
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
class H {
|
|
176
|
+
constructor(e, t) {
|
|
177
|
+
r(this, "fn");
|
|
178
|
+
r(this, "_options");
|
|
179
|
+
/**
|
|
180
|
+
* Value is guaranteed to be set after `attach` is called.
|
|
181
|
+
*/
|
|
182
|
+
r(this, "value");
|
|
183
|
+
r(this, "isMounted", !1);
|
|
184
|
+
r(this, "elementContext");
|
|
185
|
+
r(this, "lifecycleListeners", { mount: [], unmount: [] });
|
|
186
|
+
r(this, "logger");
|
|
187
|
+
r(this, "id", A());
|
|
188
|
+
r(this, "name", x(""));
|
|
189
|
+
this.fn = e, this.name(e.name), this._options = t;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Attaches this Store to the elementContext.
|
|
193
|
+
* Returns false if there was already an instance attached, and true otherwise.
|
|
194
|
+
*/
|
|
195
|
+
attach(e) {
|
|
196
|
+
if (e.stores.has(this.fn))
|
|
197
|
+
return !1;
|
|
198
|
+
this.elementContext = e, this.logger = P(this.name, { tag: this.id, tagName: "uid" });
|
|
199
|
+
const t = new ce(this);
|
|
200
|
+
try {
|
|
201
|
+
this.value = this.fn.call(t, this._options, t);
|
|
202
|
+
} catch (s) {
|
|
203
|
+
throw this.logger.crash(s), s;
|
|
204
|
+
}
|
|
205
|
+
return e.stores.set(this.fn, this), !0;
|
|
206
|
+
}
|
|
207
|
+
handleMount() {
|
|
208
|
+
this.isMounted = !0;
|
|
209
|
+
for (const e of this.lifecycleListeners.mount)
|
|
210
|
+
e();
|
|
211
|
+
this.lifecycleListeners.mount.length = 0;
|
|
212
|
+
}
|
|
213
|
+
handleUnmount() {
|
|
214
|
+
this.isMounted = !1;
|
|
215
|
+
for (const e of this.lifecycleListeners.unmount)
|
|
216
|
+
e();
|
|
217
|
+
this.lifecycleListeners.unmount.length = 0;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
class g extends Error {
|
|
221
|
+
}
|
|
222
|
+
const Ee = Object.freeze({
|
|
223
|
+
provide(i, e) {
|
|
224
|
+
const t = new H(i, e);
|
|
225
|
+
if (t.attach(S))
|
|
226
|
+
return t.value;
|
|
227
|
+
{
|
|
228
|
+
let n = i.name ? `'${i.name}'` : "this store";
|
|
229
|
+
return console.warn(`An instance of ${n} is already attached.`), this.get(i);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
get(i) {
|
|
233
|
+
if (h(i)) {
|
|
234
|
+
const e = S.stores.get(i);
|
|
235
|
+
if (e == null) {
|
|
236
|
+
let t = i.name ? `'${i.name}'` : "this store";
|
|
237
|
+
throw new g(`No instance of ${t} is provided.`);
|
|
238
|
+
} else
|
|
239
|
+
return e.value;
|
|
240
|
+
} else
|
|
241
|
+
throw new g("Invalid store.");
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
function ue(i) {
|
|
245
|
+
let e = i.domNode.tagName.toLowerCase();
|
|
246
|
+
if (i.domNode.id && (e += `#${i.domNode.id}`), i.domNode.classList.length > 0)
|
|
247
|
+
for (const t of i.domNode.classList.values())
|
|
248
|
+
e += `.${t}`;
|
|
249
|
+
return e;
|
|
250
|
+
}
|
|
251
|
+
let le = class {
|
|
252
|
+
constructor(e, t) {
|
|
253
|
+
r(this, "html");
|
|
254
|
+
r(this, "controller");
|
|
255
|
+
r(this, "uid", A());
|
|
256
|
+
this.html = e, this.controller = t;
|
|
257
|
+
const s = P(() => ue(e), { tag: "mixin" }), n = Object.getOwnPropertyDescriptors(s);
|
|
258
|
+
for (const o in n)
|
|
259
|
+
Object.defineProperty(this, o, n[o]);
|
|
260
|
+
}
|
|
261
|
+
get isMounted() {
|
|
262
|
+
return this.html.isMounted;
|
|
263
|
+
}
|
|
264
|
+
get(e) {
|
|
265
|
+
if (h(e)) {
|
|
266
|
+
let t = this.html.elementContext, s;
|
|
267
|
+
for (; s = t.stores.get(e), s == null && t.parent != null; )
|
|
268
|
+
t = t.parent;
|
|
269
|
+
if (s == null)
|
|
270
|
+
throw new g(`Store '${e.name}' is not provided on this context.`);
|
|
271
|
+
return s.value;
|
|
272
|
+
} else
|
|
273
|
+
throw new g("Invalid store.");
|
|
274
|
+
}
|
|
275
|
+
beforeMount(e) {
|
|
276
|
+
this.controller.lifecycleListeners.beforeMount.push(e);
|
|
277
|
+
}
|
|
278
|
+
onMount(e) {
|
|
279
|
+
this.controller.lifecycleListeners.mount.push(e);
|
|
280
|
+
}
|
|
281
|
+
beforeUnmount(e) {
|
|
282
|
+
this.controller.lifecycleListeners.beforeUnmount.push(e);
|
|
283
|
+
}
|
|
284
|
+
onUnmount(e) {
|
|
285
|
+
this.controller.lifecycleListeners.unmount.push(e);
|
|
286
|
+
}
|
|
287
|
+
effect(e) {
|
|
288
|
+
const t = () => {
|
|
289
|
+
try {
|
|
290
|
+
return e();
|
|
291
|
+
} catch (s) {
|
|
292
|
+
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"));
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
if (this.html.isMounted) {
|
|
296
|
+
const s = a(t);
|
|
297
|
+
return this.controller.lifecycleListeners.unmount.push(s), s;
|
|
298
|
+
} else {
|
|
299
|
+
let s, n = !1;
|
|
300
|
+
return this.controller.lifecycleListeners.mount.push(() => {
|
|
301
|
+
n || (s = a(t), this.controller.lifecycleListeners.unmount.push(s));
|
|
302
|
+
}), () => {
|
|
303
|
+
s != null && (n = !0, s());
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
class he {
|
|
309
|
+
constructor(e, t) {
|
|
310
|
+
r(this, "context");
|
|
311
|
+
r(this, "lifecycleListeners", {
|
|
312
|
+
beforeMount: [],
|
|
313
|
+
mount: [],
|
|
314
|
+
beforeUnmount: [],
|
|
315
|
+
unmount: []
|
|
316
|
+
});
|
|
317
|
+
this.context = new le(e, this);
|
|
318
|
+
for (const s of t)
|
|
319
|
+
s(e.domNode, this.context);
|
|
320
|
+
}
|
|
321
|
+
beforeMount() {
|
|
322
|
+
try {
|
|
323
|
+
for (const e of this.lifecycleListeners.beforeMount)
|
|
324
|
+
e();
|
|
325
|
+
} catch (e) {
|
|
326
|
+
this.context.crash(e);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
onMount() {
|
|
330
|
+
try {
|
|
331
|
+
for (const e of this.lifecycleListeners.mount)
|
|
332
|
+
e();
|
|
333
|
+
} catch (e) {
|
|
334
|
+
this.context.crash(e);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
beforeUnmount() {
|
|
338
|
+
try {
|
|
339
|
+
for (const e of this.lifecycleListeners.beforeUnmount)
|
|
340
|
+
e();
|
|
341
|
+
} catch (e) {
|
|
342
|
+
this.context.crash(e);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
onUnmount() {
|
|
346
|
+
try {
|
|
347
|
+
for (const e of this.lifecycleListeners.unmount)
|
|
348
|
+
e();
|
|
349
|
+
} catch (e) {
|
|
350
|
+
this.context.crash(e);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
const ae = (i) => /^on[A-Z]/.test(i);
|
|
355
|
+
var B;
|
|
356
|
+
B = p;
|
|
357
|
+
class de {
|
|
358
|
+
constructor({ tag: e, props: t, children: s, elementContext: n }) {
|
|
359
|
+
r(this, B, !0);
|
|
126
360
|
r(this, "domNode");
|
|
361
|
+
r(this, "elementContext");
|
|
127
362
|
r(this, "props");
|
|
128
363
|
r(this, "childMarkup", []);
|
|
129
364
|
r(this, "children", []);
|
|
130
365
|
r(this, "unsubscribers", []);
|
|
131
|
-
r(this, "
|
|
366
|
+
r(this, "mixin");
|
|
132
367
|
r(this, "logger");
|
|
133
368
|
// Track the ref so we can nullify it on unmount.
|
|
134
369
|
r(this, "ref");
|
|
135
370
|
// Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
|
|
136
371
|
r(this, "canClickAway", !1);
|
|
137
|
-
if (e.toLowerCase() === "svg" && (
|
|
138
|
-
...
|
|
372
|
+
if (e.toLowerCase() === "svg" && (n = {
|
|
373
|
+
...n,
|
|
139
374
|
isSVG: !0
|
|
140
|
-
}), this.logger =
|
|
375
|
+
}), this.logger = n.view.logger, n.isSVG ? this.domNode = document.createElementNS("http://www.w3.org/2000/svg", e) : this.domNode = document.createElement(e), ne() === "development" && w(n.view.name) && (this.domNode.dataset.view = w(n.view.name)), t.ref)
|
|
141
376
|
if (h(t.ref))
|
|
142
377
|
this.ref = t.ref, this.ref(this.domNode);
|
|
143
378
|
else
|
|
144
379
|
throw new Error("Expected ref to be a function. Got: " + t.ref);
|
|
145
|
-
this.props = {
|
|
146
|
-
...ie(["ref", "class", "className"], t),
|
|
380
|
+
t.mixin && (this.mixin = new he(this, f(t.mixin) ? t.mixin : [t.mixin])), this.props = {
|
|
381
|
+
...ie(["ref", "class", "className", "mixin"], t),
|
|
147
382
|
class: t.className ?? t.class
|
|
148
|
-
}, s && (this.childMarkup = M(s)), this.elementContext =
|
|
383
|
+
}, s && (this.childMarkup = M(s)), this.elementContext = n;
|
|
149
384
|
}
|
|
150
385
|
get isMounted() {
|
|
151
386
|
return this.domNode.parentNode != null;
|
|
@@ -153,33 +388,34 @@ class ce {
|
|
|
153
388
|
mount(e, t) {
|
|
154
389
|
if (e == null)
|
|
155
390
|
throw new Error(`HTML element requires a parent element as the first argument to connect. Got: ${e}`);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
391
|
+
const s = this.isMounted;
|
|
392
|
+
if (!s) {
|
|
393
|
+
this.mixin && this.mixin.beforeMount(), this.childMarkup.length > 0 && (this.children = N(this.elementContext, this.childMarkup));
|
|
394
|
+
for (let n = 0; n < this.children.length; n++) {
|
|
395
|
+
const o = this.children[n], c = n > 0 ? this.children[n - 1].domNode : void 0;
|
|
396
|
+
o.mount(this.domNode, c);
|
|
161
397
|
}
|
|
162
398
|
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);
|
|
163
399
|
}
|
|
164
|
-
e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null),
|
|
165
|
-
this.canClickAway = !0;
|
|
166
|
-
}
|
|
400
|
+
e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), queueMicrotask(() => {
|
|
401
|
+
this.canClickAway = !0, this.mixin && !s && this.mixin.onMount();
|
|
402
|
+
});
|
|
167
403
|
}
|
|
168
404
|
unmount(e = !1) {
|
|
169
405
|
var t;
|
|
170
406
|
if (this.isMounted) {
|
|
171
|
-
e || (t = this.domNode.parentNode) == null || t.removeChild(this.domNode);
|
|
407
|
+
this.mixin && this.mixin.beforeUnmount(), e || (t = this.domNode.parentNode) == null || t.removeChild(this.domNode);
|
|
172
408
|
for (const s of this.children)
|
|
173
409
|
s.unmount(!0);
|
|
174
|
-
this.
|
|
410
|
+
this.canClickAway = !1;
|
|
175
411
|
for (const s of this.unsubscribers)
|
|
176
412
|
s();
|
|
177
|
-
this.unsubscribers.length = 0;
|
|
413
|
+
this.unsubscribers.length = 0, this.ref && this.ref(void 0), this.mixin && this.mixin.onUnmount();
|
|
178
414
|
}
|
|
179
415
|
}
|
|
180
416
|
attachProp(e, t) {
|
|
181
417
|
h(e) ? this.unsubscribers.push(
|
|
182
|
-
|
|
418
|
+
a(() => {
|
|
183
419
|
try {
|
|
184
420
|
t(e());
|
|
185
421
|
} catch (s) {
|
|
@@ -190,82 +426,82 @@ class ce {
|
|
|
190
426
|
}
|
|
191
427
|
applyProps(e, t) {
|
|
192
428
|
for (const s in t) {
|
|
193
|
-
const
|
|
429
|
+
const n = t[s];
|
|
194
430
|
if (s === "on:clickoutside" || s === "onClickOutside" || s === "onclickoutside") {
|
|
195
|
-
const o = (
|
|
196
|
-
this.canClickAway && !e.contains(
|
|
197
|
-
},
|
|
198
|
-
window.addEventListener("click", o,
|
|
199
|
-
window.removeEventListener("click", o,
|
|
431
|
+
const o = (u) => {
|
|
432
|
+
this.canClickAway && !e.contains(u.target) && n(u);
|
|
433
|
+
}, c = { capture: !0 };
|
|
434
|
+
window.addEventListener("click", o, c), this.unsubscribers.push(() => {
|
|
435
|
+
window.removeEventListener("click", o, c);
|
|
200
436
|
});
|
|
201
|
-
} else if (h(
|
|
202
|
-
const o = s.slice(2).toLowerCase(),
|
|
203
|
-
e.addEventListener(o,
|
|
204
|
-
e.removeEventListener(o,
|
|
437
|
+
} else if (h(n) && ae(s)) {
|
|
438
|
+
const o = s.slice(2).toLowerCase(), c = n;
|
|
439
|
+
e.addEventListener(o, c), this.unsubscribers.push(() => {
|
|
440
|
+
e.removeEventListener(o, c);
|
|
205
441
|
});
|
|
206
|
-
} else if (h(
|
|
442
|
+
} else if (h(n) && me.includes(s)) {
|
|
207
443
|
const o = s.substring(2);
|
|
208
|
-
e.addEventListener(o,
|
|
209
|
-
e.removeEventListener(o,
|
|
444
|
+
e.addEventListener(o, n), this.unsubscribers.push(() => {
|
|
445
|
+
e.removeEventListener(o, n);
|
|
210
446
|
});
|
|
211
447
|
} else if (s.includes("-"))
|
|
212
|
-
this.attachProp(
|
|
448
|
+
this.attachProp(n, (o) => {
|
|
213
449
|
o == null ? e.removeAttribute(s) : e.setAttribute(s, String(o));
|
|
214
450
|
});
|
|
215
|
-
else if (!
|
|
451
|
+
else if (!fe.includes(s))
|
|
216
452
|
if (this.elementContext.isSVG)
|
|
217
|
-
this.attachProp(
|
|
453
|
+
this.attachProp(n, (o) => {
|
|
218
454
|
o != null ? e.setAttribute(s, String(t[s])) : e.removeAttribute(s);
|
|
219
455
|
});
|
|
220
456
|
else
|
|
221
457
|
switch (s) {
|
|
222
458
|
case "contentEditable":
|
|
223
459
|
case "value":
|
|
224
|
-
this.attachProp(
|
|
460
|
+
this.attachProp(n, (o) => {
|
|
225
461
|
e[s] = String(o);
|
|
226
462
|
});
|
|
227
463
|
break;
|
|
228
464
|
case "for":
|
|
229
|
-
this.attachProp(
|
|
465
|
+
this.attachProp(n, (o) => {
|
|
230
466
|
e.htmlFor = o;
|
|
231
467
|
});
|
|
232
468
|
break;
|
|
233
469
|
case "title":
|
|
234
|
-
this.attachProp(
|
|
470
|
+
this.attachProp(n, (o) => {
|
|
235
471
|
o == null ? e.removeAttribute(s) : e.setAttribute(s, String(o));
|
|
236
472
|
});
|
|
237
473
|
case "checked":
|
|
238
|
-
this.attachProp(
|
|
474
|
+
this.attachProp(n, (o) => {
|
|
239
475
|
e.checked = o, o ? e.setAttribute("checked", "") : e.removeAttribute("checked");
|
|
240
476
|
});
|
|
241
477
|
break;
|
|
242
478
|
case "autocomplete":
|
|
243
479
|
case "autocapitalize":
|
|
244
|
-
this.attachProp(
|
|
480
|
+
this.attachProp(n, (o) => {
|
|
245
481
|
typeof o == "string" ? e[s] = o : o ? e[s] = "on" : e[s] = "off";
|
|
246
482
|
});
|
|
247
483
|
break;
|
|
248
484
|
default: {
|
|
249
485
|
if (s.startsWith("prop:")) {
|
|
250
486
|
const o = s.substring(5);
|
|
251
|
-
this.attachProp(
|
|
252
|
-
e[o] =
|
|
487
|
+
this.attachProp(n, (c) => {
|
|
488
|
+
e[o] = c;
|
|
253
489
|
});
|
|
254
490
|
} else if (s.startsWith("on:")) {
|
|
255
491
|
const o = s.substring(3);
|
|
256
|
-
let
|
|
257
|
-
h(
|
|
258
|
-
e.removeEventListener(o,
|
|
259
|
-
})) : this.attachProp(
|
|
260
|
-
!
|
|
492
|
+
let c;
|
|
493
|
+
h(n) ? (e.addEventListener(o, n), this.unsubscribers.push(() => {
|
|
494
|
+
e.removeEventListener(o, n);
|
|
495
|
+
})) : this.attachProp(n, (u) => {
|
|
496
|
+
!u && c ? e.removeEventListener(o, c) : u != null && (c && c !== u && e.removeEventListener(o, c), e.addEventListener(o, u)), c = u;
|
|
261
497
|
});
|
|
262
498
|
} else if (s.startsWith("attr:")) {
|
|
263
499
|
const o = s.substring(5).toLowerCase();
|
|
264
|
-
this.attachProp(
|
|
265
|
-
|
|
500
|
+
this.attachProp(n, (c) => {
|
|
501
|
+
c != null ? e.setAttribute(o, String(c)) : e.removeAttribute(o);
|
|
266
502
|
});
|
|
267
503
|
} else
|
|
268
|
-
this.attachProp(
|
|
504
|
+
this.attachProp(n, (o) => {
|
|
269
505
|
e[s] = o;
|
|
270
506
|
});
|
|
271
507
|
break;
|
|
@@ -274,95 +510,95 @@ class ce {
|
|
|
274
510
|
}
|
|
275
511
|
}
|
|
276
512
|
applyStyles(e, t, s) {
|
|
277
|
-
const
|
|
513
|
+
const n = [];
|
|
278
514
|
if (h(t)) {
|
|
279
515
|
let o;
|
|
280
|
-
const
|
|
281
|
-
h(o) && o(), e.style.cssText = "", o = this.applyStyles(e,
|
|
516
|
+
const c = a(() => {
|
|
517
|
+
h(o) && o(), e.style.cssText = "", o = this.applyStyles(e, y(t), s);
|
|
282
518
|
});
|
|
283
|
-
s.push(
|
|
519
|
+
s.push(c), n.push(c);
|
|
284
520
|
} else {
|
|
285
|
-
const o =
|
|
286
|
-
for (const
|
|
287
|
-
const { value:
|
|
288
|
-
if (h(
|
|
289
|
-
const l =
|
|
290
|
-
|
|
521
|
+
const o = J(t);
|
|
522
|
+
for (const c in o) {
|
|
523
|
+
const { value: u, priority: d } = o[c];
|
|
524
|
+
if (h(u)) {
|
|
525
|
+
const l = a(() => {
|
|
526
|
+
y(u) ? e.style.setProperty(c, String(y(u)), d) : e.style.removeProperty(c);
|
|
291
527
|
});
|
|
292
|
-
s.push(l),
|
|
293
|
-
} else
|
|
528
|
+
s.push(l), n.push(l);
|
|
529
|
+
} else u != null && e.style.setProperty(c, String(u));
|
|
294
530
|
}
|
|
295
531
|
}
|
|
296
532
|
return function() {
|
|
297
|
-
for (const
|
|
298
|
-
|
|
533
|
+
for (const c of n)
|
|
534
|
+
c(), s.splice(s.indexOf(c), 1);
|
|
299
535
|
};
|
|
300
536
|
}
|
|
301
537
|
applyClasses(e, t, s) {
|
|
302
|
-
const
|
|
538
|
+
const n = [];
|
|
303
539
|
if (h(t)) {
|
|
304
540
|
let o;
|
|
305
|
-
const
|
|
306
|
-
h(o) && o(), e.removeAttribute("class"), o = this.applyClasses(e,
|
|
541
|
+
const c = a(() => {
|
|
542
|
+
h(o) && o(), e.removeAttribute("class"), o = this.applyClasses(e, y(t), s);
|
|
307
543
|
});
|
|
308
|
-
s.push(
|
|
544
|
+
s.push(c), n.push(c);
|
|
309
545
|
} else {
|
|
310
|
-
const o =
|
|
311
|
-
for (const
|
|
312
|
-
const
|
|
313
|
-
if (h(
|
|
314
|
-
const
|
|
315
|
-
|
|
546
|
+
const o = K(t);
|
|
547
|
+
for (const c in o) {
|
|
548
|
+
const u = o[c];
|
|
549
|
+
if (h(u)) {
|
|
550
|
+
const d = a(() => {
|
|
551
|
+
y(u) ? e.classList.add(c) : e.classList.remove(c);
|
|
316
552
|
});
|
|
317
|
-
s.push(
|
|
318
|
-
} else
|
|
553
|
+
s.push(d), n.push(d);
|
|
554
|
+
} else u && e.classList.add(c);
|
|
319
555
|
}
|
|
320
556
|
}
|
|
321
557
|
return function() {
|
|
322
|
-
for (const
|
|
323
|
-
|
|
558
|
+
for (const c of n)
|
|
559
|
+
c(), s.splice(s.indexOf(c), 1);
|
|
324
560
|
};
|
|
325
561
|
}
|
|
326
562
|
}
|
|
327
|
-
function
|
|
563
|
+
function K(i) {
|
|
328
564
|
let e = {};
|
|
329
|
-
if (C(
|
|
330
|
-
const t =
|
|
565
|
+
if (C(i)) {
|
|
566
|
+
const t = i.split(" ");
|
|
331
567
|
for (const s of t)
|
|
332
568
|
e[s] = !0;
|
|
333
|
-
} else $(
|
|
334
|
-
Object.assign(e,
|
|
569
|
+
} else $(i) ? Object.assign(e, i) : Array.isArray(i) && Array.from(i).filter(Boolean).forEach((t) => {
|
|
570
|
+
Object.assign(e, K(t));
|
|
335
571
|
});
|
|
336
572
|
return delete e.undefined, e;
|
|
337
573
|
}
|
|
338
|
-
function
|
|
574
|
+
function J(i) {
|
|
339
575
|
let e = {};
|
|
340
|
-
if (C(
|
|
341
|
-
const t =
|
|
576
|
+
if (C(i)) {
|
|
577
|
+
const t = i.split(";").filter((s) => s.trim() !== "");
|
|
342
578
|
for (const s of t) {
|
|
343
|
-
const [
|
|
579
|
+
const [n, o] = s.split(":"), c = {
|
|
344
580
|
value: o
|
|
345
581
|
};
|
|
346
|
-
o.includes("!important") ? (
|
|
582
|
+
o.includes("!important") ? (c.priority = "important", c.value = o.replace("!important", "").trim()) : c.value = o.trim(), e[_(n.trim())] = c;
|
|
347
583
|
}
|
|
348
584
|
}
|
|
349
|
-
if ($(
|
|
350
|
-
for (const t in
|
|
351
|
-
t.startsWith("--") ? e[t] = { value:
|
|
352
|
-
else Array.isArray(
|
|
353
|
-
Object.assign(e,
|
|
585
|
+
if ($(i))
|
|
586
|
+
for (const t in i)
|
|
587
|
+
t.startsWith("--") ? e[t] = { value: i[t] } : e[_(t)] = { value: i[t] };
|
|
588
|
+
else Array.isArray(i) && Array.from(i).filter((t) => t != null).forEach((t) => {
|
|
589
|
+
Object.assign(e, J(t));
|
|
354
590
|
});
|
|
355
591
|
return e;
|
|
356
592
|
}
|
|
357
|
-
function
|
|
358
|
-
return
|
|
593
|
+
function _(i) {
|
|
594
|
+
return i.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (e, t) => (t ? "-" : "") + e.toLowerCase());
|
|
359
595
|
}
|
|
360
|
-
const
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
class
|
|
596
|
+
const fe = ["ref", "children", "class", "style", "data", "mixin"], me = ["onsubmit", "onclick", "ontransitionend"];
|
|
597
|
+
var V;
|
|
598
|
+
V = p;
|
|
599
|
+
class pe {
|
|
364
600
|
constructor(e) {
|
|
365
|
-
r(this,
|
|
601
|
+
r(this, V, !0);
|
|
366
602
|
r(this, "domNode", document.createTextNode(""));
|
|
367
603
|
r(this, "isMounted", !1);
|
|
368
604
|
r(this, "view");
|
|
@@ -371,9 +607,9 @@ class ae {
|
|
|
371
607
|
this.view = e;
|
|
372
608
|
}
|
|
373
609
|
mount(e, t) {
|
|
374
|
-
this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe =
|
|
610
|
+
this.isMounted || (this.isMounted = !0, e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe = a(() => {
|
|
375
611
|
const s = this.view();
|
|
376
|
-
|
|
612
|
+
w(() => {
|
|
377
613
|
this.update(s);
|
|
378
614
|
});
|
|
379
615
|
}));
|
|
@@ -388,11 +624,11 @@ class ae {
|
|
|
388
624
|
this.cleanup(!1), e && (e.mount(this.domNode.parentElement, this.domNode), this.mountedView = e);
|
|
389
625
|
}
|
|
390
626
|
}
|
|
391
|
-
var
|
|
392
|
-
|
|
393
|
-
class
|
|
627
|
+
var q;
|
|
628
|
+
q = p;
|
|
629
|
+
class be {
|
|
394
630
|
constructor(e) {
|
|
395
|
-
r(this,
|
|
631
|
+
r(this, q, !0);
|
|
396
632
|
r(this, "config");
|
|
397
633
|
r(this, "element");
|
|
398
634
|
this.config = e;
|
|
@@ -401,19 +637,19 @@ class de {
|
|
|
401
637
|
return this.element ? this.element.isMounted : !1;
|
|
402
638
|
}
|
|
403
639
|
mount(e, t) {
|
|
404
|
-
const { content: s, parent:
|
|
405
|
-
|
|
640
|
+
const { content: s, parent: n } = this.config;
|
|
641
|
+
Q(s) ? this.element = s : this.element = k(N(this.config.elementContext, M(s))), this.element.mount(n);
|
|
406
642
|
}
|
|
407
643
|
unmount(e = !1) {
|
|
408
644
|
var t;
|
|
409
645
|
(t = this.element) != null && t.isMounted && this.element.unmount(!1);
|
|
410
646
|
}
|
|
411
647
|
}
|
|
412
|
-
var
|
|
413
|
-
|
|
414
|
-
class
|
|
415
|
-
constructor({ elementContext: e, items: t, renderFn: s, keyFn:
|
|
416
|
-
r(this,
|
|
648
|
+
var D;
|
|
649
|
+
D = p;
|
|
650
|
+
class ye {
|
|
651
|
+
constructor({ elementContext: e, items: t, renderFn: s, keyFn: n }) {
|
|
652
|
+
r(this, D, !0);
|
|
417
653
|
r(this, "domNode", document.createTextNode(""));
|
|
418
654
|
r(this, "items");
|
|
419
655
|
r(this, "unsubscribe", null);
|
|
@@ -421,15 +657,15 @@ class fe {
|
|
|
421
657
|
r(this, "elementContext");
|
|
422
658
|
r(this, "renderFn");
|
|
423
659
|
r(this, "keyFn");
|
|
424
|
-
this.elementContext = e, this.items = t, this.renderFn = s, this.keyFn =
|
|
660
|
+
this.elementContext = e, this.items = t, this.renderFn = s, this.keyFn = n;
|
|
425
661
|
}
|
|
426
662
|
get isMounted() {
|
|
427
663
|
return this.domNode.parentNode != null;
|
|
428
664
|
}
|
|
429
665
|
mount(e, t) {
|
|
430
|
-
this.isMounted || (e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe =
|
|
666
|
+
this.isMounted || (e.insertBefore(this.domNode, (t == null ? void 0 : t.nextSibling) ?? null), this.unsubscribe = a(() => {
|
|
431
667
|
let s = this.items();
|
|
432
|
-
s == null && (s = [], console.log("repeat received empty value", s, this)),
|
|
668
|
+
s == null && (s = [], console.log("repeat received empty value", s, this)), w(() => {
|
|
433
669
|
this._update(Array.from(s));
|
|
434
670
|
});
|
|
435
671
|
}));
|
|
@@ -444,7 +680,7 @@ class fe {
|
|
|
444
680
|
this.connectedItems = [];
|
|
445
681
|
}
|
|
446
682
|
_update(e) {
|
|
447
|
-
var
|
|
683
|
+
var c, u, d;
|
|
448
684
|
if (e.length === 0 || !this.isMounted)
|
|
449
685
|
return this._cleanup(!1);
|
|
450
686
|
const t = [];
|
|
@@ -455,49 +691,49 @@ class fe {
|
|
|
455
691
|
value: l,
|
|
456
692
|
index: s++
|
|
457
693
|
});
|
|
458
|
-
const
|
|
694
|
+
const n = [];
|
|
459
695
|
for (const l of this.connectedItems)
|
|
460
696
|
t.find((b) => b.key === l.key) || l.element.unmount(!1);
|
|
461
697
|
for (const l of t) {
|
|
462
698
|
const v = this.connectedItems.find((b) => b.key === l.key);
|
|
463
699
|
if (v)
|
|
464
|
-
v.item(l.value), v.index(l.index),
|
|
700
|
+
v.item(l.value), v.index(l.index), n[l.index] = v;
|
|
465
701
|
else {
|
|
466
|
-
const b =
|
|
467
|
-
|
|
702
|
+
const b = x(l.value, { equals: oe }), I = x(l.index);
|
|
703
|
+
n[l.index] = {
|
|
468
704
|
key: l.key,
|
|
469
705
|
item: b,
|
|
470
|
-
index:
|
|
471
|
-
element: new
|
|
706
|
+
index: I,
|
|
707
|
+
element: new L(this.elementContext, we, {
|
|
472
708
|
item: () => b(),
|
|
473
|
-
index: () =>
|
|
709
|
+
index: () => I(),
|
|
474
710
|
renderFn: this.renderFn
|
|
475
711
|
})
|
|
476
712
|
};
|
|
477
713
|
}
|
|
478
714
|
}
|
|
479
|
-
for (let l = 0; l <
|
|
480
|
-
const v =
|
|
715
|
+
for (let l = 0; l < n.length; l++) {
|
|
716
|
+
const v = n[l], b = ((c = n[l - 1]) == null ? void 0 : c.element.domNode) ?? this.domNode;
|
|
481
717
|
v.element.mount(this.domNode.parentNode, b);
|
|
482
718
|
}
|
|
483
|
-
this.connectedItems =
|
|
484
|
-
const o = ((
|
|
485
|
-
(
|
|
719
|
+
this.connectedItems = n;
|
|
720
|
+
const o = ((u = n.at(-1)) == null ? void 0 : u.element.domNode) ?? this.domNode;
|
|
721
|
+
(d = this.domNode.parentNode) == null || d.insertBefore(this.domNode, o.nextSibling);
|
|
486
722
|
}
|
|
487
723
|
}
|
|
488
|
-
function
|
|
489
|
-
return e.name = "@RepeatItem",
|
|
724
|
+
function we(i, e) {
|
|
725
|
+
return e.name = "@RepeatItem", i.renderFn.call(e, i.item, i.index, e);
|
|
490
726
|
}
|
|
491
|
-
function E(
|
|
492
|
-
return
|
|
727
|
+
function E(i) {
|
|
728
|
+
return i instanceof X;
|
|
493
729
|
}
|
|
494
|
-
function
|
|
495
|
-
return (
|
|
730
|
+
function Q(i) {
|
|
731
|
+
return (i == null ? void 0 : i[p]) === !0;
|
|
496
732
|
}
|
|
497
|
-
function M(
|
|
498
|
-
f(
|
|
733
|
+
function M(i) {
|
|
734
|
+
f(i) || (i = [i]);
|
|
499
735
|
const e = [];
|
|
500
|
-
for (const t of
|
|
736
|
+
for (const t of i)
|
|
501
737
|
if (!(t == null || t === !1)) {
|
|
502
738
|
if (t instanceof Node) {
|
|
503
739
|
e.push(m("$node", { value: t }));
|
|
@@ -519,13 +755,13 @@ function M(n) {
|
|
|
519
755
|
}
|
|
520
756
|
return e;
|
|
521
757
|
}
|
|
522
|
-
function
|
|
523
|
-
return
|
|
758
|
+
function Se(i) {
|
|
759
|
+
return k(N(S, i));
|
|
524
760
|
}
|
|
525
|
-
function m(
|
|
526
|
-
return new
|
|
761
|
+
function m(i, e, ...t) {
|
|
762
|
+
return new X(i, e, ...t);
|
|
527
763
|
}
|
|
528
|
-
class
|
|
764
|
+
class X {
|
|
529
765
|
constructor(e, t, ...s) {
|
|
530
766
|
r(this, "type");
|
|
531
767
|
r(this, "props");
|
|
@@ -533,212 +769,88 @@ class Q {
|
|
|
533
769
|
this.type = e, this.props = t, this.children = s;
|
|
534
770
|
}
|
|
535
771
|
}
|
|
536
|
-
function
|
|
772
|
+
function ge(i, e, t) {
|
|
537
773
|
return m("$dynamic", {
|
|
538
|
-
source:
|
|
539
|
-
const s =
|
|
774
|
+
source: x(() => {
|
|
775
|
+
const s = y(i);
|
|
540
776
|
return s && e ? e : !s && t ? t : null;
|
|
541
777
|
})
|
|
542
778
|
});
|
|
543
779
|
}
|
|
544
|
-
function
|
|
545
|
-
return
|
|
780
|
+
function $e(i, e, t) {
|
|
781
|
+
return ge(i, t, e);
|
|
546
782
|
}
|
|
547
|
-
function
|
|
548
|
-
return m("$repeat", { items: () =>
|
|
783
|
+
function Ae(i, e, t) {
|
|
784
|
+
return m("$repeat", { items: () => y(i), keyFn: e, renderFn: t });
|
|
549
785
|
}
|
|
550
|
-
function
|
|
551
|
-
return m("$portal", { parent:
|
|
786
|
+
function Pe(i, e) {
|
|
787
|
+
return m("$portal", { parent: i, content: e });
|
|
552
788
|
}
|
|
553
|
-
function
|
|
789
|
+
function N(i, e) {
|
|
554
790
|
return (f(e) ? e : [e]).map((s) => {
|
|
555
791
|
if (h(s.type))
|
|
556
|
-
return new
|
|
792
|
+
return new L(i, s.type, s.props, s.children);
|
|
557
793
|
if (C(s.type))
|
|
558
794
|
switch (s.type) {
|
|
559
795
|
case "$node": {
|
|
560
|
-
const
|
|
561
|
-
return new
|
|
796
|
+
const n = s.props;
|
|
797
|
+
return new O(n.value);
|
|
562
798
|
}
|
|
563
799
|
case "$text": {
|
|
564
|
-
const
|
|
565
|
-
return new
|
|
800
|
+
const n = s.props;
|
|
801
|
+
return new O(document.createTextNode(String(n.value)));
|
|
566
802
|
}
|
|
567
803
|
case "$repeat": {
|
|
568
|
-
const
|
|
569
|
-
return new
|
|
570
|
-
items:
|
|
571
|
-
keyFn:
|
|
572
|
-
renderFn:
|
|
573
|
-
elementContext:
|
|
804
|
+
const n = s.props;
|
|
805
|
+
return new ye({
|
|
806
|
+
items: n.items,
|
|
807
|
+
keyFn: n.keyFn,
|
|
808
|
+
renderFn: n.renderFn,
|
|
809
|
+
elementContext: i
|
|
574
810
|
});
|
|
575
811
|
}
|
|
576
812
|
case "$dynamic": {
|
|
577
|
-
const
|
|
813
|
+
const n = s.props;
|
|
578
814
|
return new re({
|
|
579
|
-
source:
|
|
580
|
-
elementContext:
|
|
815
|
+
source: n.source,
|
|
816
|
+
elementContext: i
|
|
581
817
|
});
|
|
582
818
|
}
|
|
583
819
|
case "$fragment": {
|
|
584
|
-
const
|
|
585
|
-
return new Z(
|
|
820
|
+
const n = s.props;
|
|
821
|
+
return new Z(n.children);
|
|
586
822
|
}
|
|
587
823
|
case "$outlet": {
|
|
588
|
-
const
|
|
589
|
-
return new
|
|
824
|
+
const n = s.props;
|
|
825
|
+
return new pe(n.view);
|
|
590
826
|
}
|
|
591
827
|
case "$portal": {
|
|
592
|
-
const
|
|
593
|
-
return new
|
|
594
|
-
content:
|
|
595
|
-
parent:
|
|
596
|
-
elementContext:
|
|
828
|
+
const n = s.props;
|
|
829
|
+
return new be({
|
|
830
|
+
content: n.content,
|
|
831
|
+
parent: n.parent,
|
|
832
|
+
elementContext: i
|
|
597
833
|
});
|
|
598
834
|
}
|
|
599
835
|
default:
|
|
600
|
-
return new
|
|
836
|
+
return new de({
|
|
601
837
|
tag: s.type,
|
|
602
838
|
props: s.props ?? {},
|
|
603
839
|
children: s.children,
|
|
604
|
-
elementContext:
|
|
840
|
+
elementContext: i
|
|
605
841
|
});
|
|
606
842
|
}
|
|
607
843
|
else
|
|
608
844
|
throw new TypeError(`Expected a string or view function. Got: ${s.type}`);
|
|
609
845
|
});
|
|
610
846
|
}
|
|
611
|
-
function
|
|
612
|
-
return
|
|
613
|
-
}
|
|
614
|
-
function X(n) {
|
|
615
|
-
return n == null || n === !1 || h(n) || C(n) || se(n) || E(n) || D(X, n);
|
|
616
|
-
}
|
|
617
|
-
let be = class {
|
|
618
|
-
constructor(e) {
|
|
619
|
-
r(this, "store");
|
|
620
|
-
this.store = e;
|
|
621
|
-
const t = Object.getOwnPropertyDescriptors(this.store.logger);
|
|
622
|
-
for (const s in t)
|
|
623
|
-
s !== "setName" && Object.defineProperty(this, s, t[s]);
|
|
624
|
-
}
|
|
625
|
-
get isMounted() {
|
|
626
|
-
return this.store.isMounted;
|
|
627
|
-
}
|
|
628
|
-
get name() {
|
|
629
|
-
return y(this.store.name) || this.store.id;
|
|
630
|
-
}
|
|
631
|
-
set name(e) {
|
|
632
|
-
this.store.name(e);
|
|
633
|
-
}
|
|
634
|
-
get(e) {
|
|
635
|
-
if (h(e)) {
|
|
636
|
-
let t = this.store.elementContext, s;
|
|
637
|
-
for (; s = t.stores.get(e), s == null && t.parent != null; )
|
|
638
|
-
t = t.parent;
|
|
639
|
-
if (s == null)
|
|
640
|
-
throw new x(`Store '${e.name}' is not provided on this context.`);
|
|
641
|
-
return s.value;
|
|
642
|
-
} else
|
|
643
|
-
throw new x("Invalid store.");
|
|
644
|
-
}
|
|
645
|
-
onMount(e) {
|
|
646
|
-
this.store.lifecycleListeners.mount.push(e);
|
|
647
|
-
}
|
|
648
|
-
onUnmount(e) {
|
|
649
|
-
this.store.lifecycleListeners.unmount.push(e);
|
|
650
|
-
}
|
|
651
|
-
effect(e) {
|
|
652
|
-
const t = this.store, s = () => {
|
|
653
|
-
try {
|
|
654
|
-
return e();
|
|
655
|
-
} catch (i) {
|
|
656
|
-
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")));
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
if (t.isMounted) {
|
|
660
|
-
const i = d(s);
|
|
661
|
-
return t.lifecycleListeners.unmount.push(i), i;
|
|
662
|
-
} else {
|
|
663
|
-
let i, o = !1;
|
|
664
|
-
return t.lifecycleListeners.mount.push(() => {
|
|
665
|
-
o || (i = d(s), t.lifecycleListeners.unmount.push(i));
|
|
666
|
-
}), () => {
|
|
667
|
-
i != null && (o = !0, i());
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
class Y {
|
|
673
|
-
constructor(e, t) {
|
|
674
|
-
r(this, "fn");
|
|
675
|
-
r(this, "_options");
|
|
676
|
-
/**
|
|
677
|
-
* Value is guaranteed to be set after `attach` is called.
|
|
678
|
-
*/
|
|
679
|
-
r(this, "value");
|
|
680
|
-
r(this, "isMounted", !1);
|
|
681
|
-
r(this, "elementContext");
|
|
682
|
-
r(this, "lifecycleListeners", { mount: [], unmount: [] });
|
|
683
|
-
r(this, "logger");
|
|
684
|
-
r(this, "id", R());
|
|
685
|
-
r(this, "name", N(""));
|
|
686
|
-
this.fn = e, this.name(e.name), this._options = t;
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* Attaches this Store to the elementContext.
|
|
690
|
-
* Returns false if there was already an instance attached, and true otherwise.
|
|
691
|
-
*/
|
|
692
|
-
attach(e) {
|
|
693
|
-
if (e.stores.has(this.fn))
|
|
694
|
-
return !1;
|
|
695
|
-
this.elementContext = e, this.logger = z(this.name, { uid: this.id });
|
|
696
|
-
const t = new be(this);
|
|
697
|
-
try {
|
|
698
|
-
this.value = this.fn.call(t, this._options, t);
|
|
699
|
-
} catch (s) {
|
|
700
|
-
throw this.logger.crash(s), s;
|
|
701
|
-
}
|
|
702
|
-
return e.stores.set(this.fn, this), !0;
|
|
703
|
-
}
|
|
704
|
-
handleMount() {
|
|
705
|
-
this.isMounted = !0;
|
|
706
|
-
for (const e of this.lifecycleListeners.mount)
|
|
707
|
-
e();
|
|
708
|
-
this.lifecycleListeners.mount.length = 0;
|
|
709
|
-
}
|
|
710
|
-
handleUnmount() {
|
|
711
|
-
this.isMounted = !1;
|
|
712
|
-
for (const e of this.lifecycleListeners.unmount)
|
|
713
|
-
e();
|
|
714
|
-
this.lifecycleListeners.unmount.length = 0;
|
|
715
|
-
}
|
|
847
|
+
function k(i) {
|
|
848
|
+
return i.length === 1 ? i[0] : new Z(i);
|
|
716
849
|
}
|
|
717
|
-
|
|
850
|
+
function Y(i) {
|
|
851
|
+
return i == null || i === !1 || h(i) || C(i) || se(i) || E(i) || z(Y, i);
|
|
718
852
|
}
|
|
719
|
-
|
|
720
|
-
provide(n, e) {
|
|
721
|
-
const t = new Y(n, e);
|
|
722
|
-
if (t.attach(S))
|
|
723
|
-
return t.value;
|
|
724
|
-
{
|
|
725
|
-
let i = n.name ? `'${n.name}'` : "this store";
|
|
726
|
-
return console.warn(`An instance of ${i} is already attached.`), this.get(n);
|
|
727
|
-
}
|
|
728
|
-
},
|
|
729
|
-
get(n) {
|
|
730
|
-
if (h(n)) {
|
|
731
|
-
const e = S.stores.get(n);
|
|
732
|
-
if (e == null) {
|
|
733
|
-
let t = n.name ? `'${n.name}'` : "this store";
|
|
734
|
-
throw new x(`No instance of ${t} is provided.`);
|
|
735
|
-
} else
|
|
736
|
-
return e.value;
|
|
737
|
-
} else
|
|
738
|
-
throw new x("Invalid store.");
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
class we {
|
|
853
|
+
class ve {
|
|
742
854
|
constructor(e) {
|
|
743
855
|
r(this, "view");
|
|
744
856
|
this.view = e;
|
|
@@ -753,13 +865,13 @@ class we {
|
|
|
753
865
|
return this.view.isMounted;
|
|
754
866
|
}
|
|
755
867
|
get name() {
|
|
756
|
-
return
|
|
868
|
+
return w(this.view.name) || this.uid;
|
|
757
869
|
}
|
|
758
870
|
set name(e) {
|
|
759
871
|
this.view.name(e);
|
|
760
872
|
}
|
|
761
873
|
provide(e, t) {
|
|
762
|
-
const s = new
|
|
874
|
+
const s = new H(e, t);
|
|
763
875
|
if (s.attach(this.view.elementContext))
|
|
764
876
|
return this.view.lifecycleListeners.mount.push(() => {
|
|
765
877
|
s.handleMount();
|
|
@@ -777,10 +889,10 @@ class we {
|
|
|
777
889
|
for (; s = t.stores.get(e), s == null && t.parent != null; )
|
|
778
890
|
t = t.parent;
|
|
779
891
|
if (s == null)
|
|
780
|
-
throw new
|
|
892
|
+
throw new g(`Store '${e.name}' is not provided on this context.`);
|
|
781
893
|
return s.value;
|
|
782
894
|
} else
|
|
783
|
-
throw new
|
|
895
|
+
throw new g("Invalid store.");
|
|
784
896
|
}
|
|
785
897
|
beforeMount(e) {
|
|
786
898
|
this.view.lifecycleListeners.beforeMount.push(e);
|
|
@@ -803,14 +915,14 @@ class we {
|
|
|
803
915
|
}
|
|
804
916
|
};
|
|
805
917
|
if (this.view.isMounted) {
|
|
806
|
-
const s =
|
|
918
|
+
const s = a(t);
|
|
807
919
|
return this.view.lifecycleListeners.unmount.push(s), s;
|
|
808
920
|
} else {
|
|
809
|
-
let s,
|
|
921
|
+
let s, n = !1;
|
|
810
922
|
return this.view.lifecycleListeners.mount.push(() => {
|
|
811
|
-
|
|
923
|
+
n || (s = a(t), this.view.lifecycleListeners.unmount.push(s));
|
|
812
924
|
}), () => {
|
|
813
|
-
s != null && (
|
|
925
|
+
s != null && (n = !0, s());
|
|
814
926
|
};
|
|
815
927
|
}
|
|
816
928
|
}
|
|
@@ -818,18 +930,18 @@ class we {
|
|
|
818
930
|
return m("$outlet", { view: this.view.elementContext.route });
|
|
819
931
|
}
|
|
820
932
|
}
|
|
821
|
-
var
|
|
822
|
-
|
|
823
|
-
const
|
|
824
|
-
constructor(e, t, s,
|
|
825
|
-
r(this,
|
|
826
|
-
r(this, "uniqueId",
|
|
933
|
+
var G;
|
|
934
|
+
G = p;
|
|
935
|
+
const U = class U {
|
|
936
|
+
constructor(e, t, s, n) {
|
|
937
|
+
r(this, G, !0);
|
|
938
|
+
r(this, "uniqueId", A());
|
|
827
939
|
r(this, "elementContext");
|
|
828
940
|
r(this, "logger");
|
|
829
941
|
r(this, "props");
|
|
830
942
|
r(this, "fn");
|
|
831
943
|
r(this, "element");
|
|
832
|
-
r(this, "name",
|
|
944
|
+
r(this, "name", x(""));
|
|
833
945
|
r(this, "context");
|
|
834
946
|
r(this, "lifecycleListeners", { beforeMount: [], mount: [], beforeUnmount: [], unmount: [] });
|
|
835
947
|
r(this, "isMounted", !1);
|
|
@@ -838,11 +950,11 @@ const A = class A {
|
|
|
838
950
|
parent: e,
|
|
839
951
|
view: this,
|
|
840
952
|
stores: /* @__PURE__ */ new Map(),
|
|
841
|
-
route:
|
|
842
|
-
}, this.logger =
|
|
953
|
+
route: x()
|
|
954
|
+
}, this.logger = P(this.name, { tag: this.uniqueId, tagName: "uid" }), this.props = {
|
|
843
955
|
...s,
|
|
844
|
-
children:
|
|
845
|
-
}, this.fn = t, this.context = new
|
|
956
|
+
children: n
|
|
957
|
+
}, this.fn = t, this.context = new ve(this);
|
|
846
958
|
}
|
|
847
959
|
/*===============================*\
|
|
848
960
|
|| "Public" API ||
|
|
@@ -855,12 +967,12 @@ const A = class A {
|
|
|
855
967
|
const s = this.isMounted;
|
|
856
968
|
if (!s) {
|
|
857
969
|
this._initialize();
|
|
858
|
-
for (const
|
|
859
|
-
|
|
970
|
+
for (const n of this.lifecycleListeners.beforeMount)
|
|
971
|
+
n();
|
|
860
972
|
}
|
|
861
973
|
this.element && this.element.mount(e, t), s || (this.isMounted = !0, requestAnimationFrame(() => {
|
|
862
|
-
for (const
|
|
863
|
-
|
|
974
|
+
for (const n of this.lifecycleListeners.mount)
|
|
975
|
+
n();
|
|
864
976
|
}));
|
|
865
977
|
}
|
|
866
978
|
unmount(e = !1) {
|
|
@@ -872,7 +984,7 @@ const A = class A {
|
|
|
872
984
|
this.lifecycleListeners.beforeMount.length = 0, this.lifecycleListeners.mount.length = 0, this.lifecycleListeners.beforeUnmount.length = 0, this.lifecycleListeners.unmount.length = 0;
|
|
873
985
|
}
|
|
874
986
|
setRouteView(e) {
|
|
875
|
-
const t = new
|
|
987
|
+
const t = new U(this.elementContext, e, {});
|
|
876
988
|
return this.elementContext.route(t), t;
|
|
877
989
|
}
|
|
878
990
|
/*===============================*\
|
|
@@ -887,46 +999,46 @@ const A = class A {
|
|
|
887
999
|
throw s instanceof Error && this.logger.crash(s), s;
|
|
888
1000
|
}
|
|
889
1001
|
if (t !== null) if (t instanceof Node)
|
|
890
|
-
this.element =
|
|
1002
|
+
this.element = k(N(this.elementContext, m("$node", { value: t })));
|
|
891
1003
|
else if (h(t))
|
|
892
|
-
this.element =
|
|
893
|
-
|
|
1004
|
+
this.element = k(
|
|
1005
|
+
N(this.elementContext, m("$dynamic", { source: t }))
|
|
894
1006
|
);
|
|
895
|
-
else if (E(t) ||
|
|
896
|
-
this.element =
|
|
1007
|
+
else if (E(t) || z(E, t))
|
|
1008
|
+
this.element = k(N(this.elementContext, t));
|
|
897
1009
|
else {
|
|
898
1010
|
const s = new TypeError(
|
|
899
|
-
`Expected '${this.fn.name}' function to return a DOM node, Markup element, Signal or null. Got: ${
|
|
1011
|
+
`Expected '${this.fn.name}' function to return a DOM node, Markup element, Signal or null. Got: ${R(t)}`
|
|
900
1012
|
);
|
|
901
1013
|
this.logger.crash(s);
|
|
902
1014
|
}
|
|
903
1015
|
}
|
|
904
1016
|
};
|
|
905
|
-
let
|
|
906
|
-
const
|
|
1017
|
+
let L = U;
|
|
1018
|
+
const Ne = {
|
|
907
1019
|
stores: W
|
|
908
1020
|
};
|
|
909
|
-
function
|
|
910
|
-
if (h(
|
|
911
|
-
const e =
|
|
912
|
-
return new
|
|
913
|
-
} else if ($(
|
|
914
|
-
const e =
|
|
915
|
-
return new
|
|
1021
|
+
function Ue(...i) {
|
|
1022
|
+
if (h(i[0])) {
|
|
1023
|
+
const e = i[0], t = f(i[1]) ? {} : i[1], s = f(i[2]) ? i[2] : f(i[1]) ? i[1] : [];
|
|
1024
|
+
return new L(Ne, e, t, M(s));
|
|
1025
|
+
} else if ($(i[0]) && h(i[1])) {
|
|
1026
|
+
const e = i[0], t = i[1], s = f(i[2]) ? {} : i[2], n = f(i[3]) ? i[3] : f(i[2]) ? i[2] : [];
|
|
1027
|
+
return new L(e, t, s, n ? M(n) : []);
|
|
916
1028
|
} else
|
|
917
1029
|
throw new TypeError(
|
|
918
1030
|
"Unexpected arguments; expected view, props and children, or context, view, props and children."
|
|
919
1031
|
);
|
|
920
1032
|
}
|
|
921
1033
|
export {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1034
|
+
Ee as S,
|
|
1035
|
+
Ae as a,
|
|
1036
|
+
Se as b,
|
|
1037
|
+
Ue as c,
|
|
926
1038
|
m,
|
|
927
|
-
|
|
1039
|
+
Pe as p,
|
|
928
1040
|
S as r,
|
|
929
|
-
|
|
930
|
-
|
|
1041
|
+
$e as u,
|
|
1042
|
+
ge as w
|
|
931
1043
|
};
|
|
932
|
-
//# sourceMappingURL=view-
|
|
1044
|
+
//# sourceMappingURL=view-BKpHFpWG.js.map
|