@manyducks.co/dolla 2.0.0-alpha.8 → 2.0.0
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 +222 -512
- package/dist/core/app.d.ts +24 -0
- package/dist/core/context.d.ts +147 -0
- package/dist/core/env.d.ts +3 -0
- package/dist/core/hooks.d.ts +70 -0
- package/dist/core/hooks.test.d.ts +1 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/logger.d.ts +42 -0
- package/dist/core/logger.test.d.ts +0 -0
- package/dist/core/markup.d.ts +82 -0
- package/dist/core/markup.test.d.ts +0 -0
- package/dist/core/nodes/_markup.d.ts +36 -0
- package/dist/core/nodes/dom.d.ts +13 -0
- package/dist/core/nodes/dynamic.d.ts +22 -0
- package/dist/core/nodes/element.d.ts +27 -0
- package/dist/core/nodes/portal.d.ts +18 -0
- package/dist/core/nodes/repeat.d.ts +27 -0
- package/dist/core/nodes/view.d.ts +25 -0
- package/dist/core/ref.d.ts +19 -0
- package/dist/core/ref.test.d.ts +1 -0
- package/dist/core/signals.d.ts +100 -0
- package/dist/core/signals.test.d.ts +1 -0
- package/dist/{views → core/views}/default-crash-view.d.ts +11 -4
- package/dist/core/views/for.d.ts +21 -0
- package/dist/core/views/fragment.d.ts +7 -0
- package/dist/core/views/portal.d.ts +16 -0
- package/dist/core/views/show.d.ts +25 -0
- package/dist/fragment-BahD_BJA.js +7 -0
- package/dist/fragment-BahD_BJA.js.map +1 -0
- package/dist/{modules/http.d.ts → http/index.d.ts} +3 -5
- package/dist/http.js +150 -0
- package/dist/http.js.map +1 -0
- package/dist/i18n/index.d.ts +134 -0
- package/dist/i18n.js +309 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index-DRJlxs-Q.js +535 -0
- package/dist/index-DRJlxs-Q.js.map +1 -0
- package/dist/index.js +160 -1386
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +3 -2
- package/dist/jsx-dev-runtime.js +5 -12
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +4 -3
- package/dist/jsx-runtime.js +9 -15
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/logger-Aqi9m1CF.js +565 -0
- package/dist/logger-Aqi9m1CF.js.map +1 -0
- package/dist/markup-8jNhoqDe.js +1089 -0
- package/dist/markup-8jNhoqDe.js.map +1 -0
- package/dist/router/hooks.d.ts +2 -0
- package/dist/router/index.d.ts +3 -0
- package/dist/router/router.d.ts +166 -0
- package/dist/{routing.d.ts → router/router.utils.d.ts} +17 -3
- package/dist/router/router.utils.test.d.ts +1 -0
- package/dist/router.js +6 -0
- package/dist/router.js.map +1 -0
- package/dist/typeChecking-5kmX0ulW.js +65 -0
- package/dist/typeChecking-5kmX0ulW.js.map +1 -0
- package/dist/typeChecking.d.ts +2 -98
- package/dist/typeChecking.test.d.ts +1 -0
- package/dist/types.d.ts +97 -25
- package/dist/utils.d.ts +25 -3
- package/docs/buildless.md +132 -0
- package/docs/components.md +238 -0
- package/docs/hooks.md +356 -0
- package/docs/http.md +178 -0
- package/docs/i18n.md +220 -0
- package/docs/index.md +10 -0
- package/docs/markup.md +136 -0
- package/docs/mixins.md +176 -0
- package/docs/ref.md +77 -0
- package/docs/router.md +281 -0
- package/docs/setup.md +137 -0
- package/docs/signals.md +262 -0
- package/docs/stores.md +113 -0
- package/docs/views.md +356 -0
- package/index.d.ts +2 -2
- package/notes/atomic.md +452 -0
- package/notes/elimination.md +33 -0
- package/notes/observable.md +180 -0
- package/notes/scratch.md +350 -18
- package/notes/splitting.md +5 -0
- package/package.json +29 -15
- package/vite.config.js +5 -11
- package/build.js +0 -34
- package/dist/index.d.ts +0 -21
- package/dist/markup.d.ts +0 -108
- package/dist/modules/dolla.d.ts +0 -111
- package/dist/modules/language.d.ts +0 -41
- package/dist/modules/render.d.ts +0 -17
- package/dist/modules/router.d.ts +0 -152
- package/dist/nodes/cond.d.ts +0 -26
- package/dist/nodes/html.d.ts +0 -31
- package/dist/nodes/observer.d.ts +0 -29
- package/dist/nodes/outlet.d.ts +0 -22
- package/dist/nodes/portal.d.ts +0 -19
- package/dist/nodes/repeat.d.ts +0 -34
- package/dist/nodes/text.d.ts +0 -19
- package/dist/passthrough-9kwwjgWk.js +0 -1279
- package/dist/passthrough-9kwwjgWk.js.map +0 -1
- package/dist/state.d.ts +0 -101
- package/dist/view.d.ts +0 -65
- package/dist/views/passthrough.d.ts +0 -5
- package/notes/context-vars.md +0 -21
- package/notes/readme-scratch.md +0 -222
- package/notes/route-middleware.md +0 -42
- package/tests/state.test.js +0 -135
- /package/dist/{routing.test.d.ts → core/context.test.d.ts} +0 -0
|
@@ -0,0 +1,1089 @@
|
|
|
1
|
+
import { b as u, t as q, a as L, i as O, h as F } from "./typeChecking-5kmX0ulW.js";
|
|
2
|
+
import { u as v, i as G, g as w, n as _, p as N, e as m, t as D, q as T, v as z, f as H, x as Y, y as Z, s as J, m as Q, l as X, b as tt, w as U, d as et } from "./logger-Aqi9m1CF.js";
|
|
3
|
+
var d = /* @__PURE__ */ ((n) => (n.WILL_MOUNT = "willMount", n.DID_MOUNT = "didMount", n.WILL_UNMOUNT = "willUnmount", n.DID_UNMOUNT = "didUnmount", n.DISPOSE = "dispose", n))(d || {});
|
|
4
|
+
const k = Symbol("name"), l = Symbol("lifecycle"), b = Symbol("parent"), y = Symbol("stores"), f = Symbol("state");
|
|
5
|
+
class st {
|
|
6
|
+
context;
|
|
7
|
+
state = 0;
|
|
8
|
+
listeners = /* @__PURE__ */ new Map();
|
|
9
|
+
bound;
|
|
10
|
+
constructor(t) {
|
|
11
|
+
this.context = t;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Listen for a certain event to be emitted. Listeners are called when the event results in a state change.
|
|
15
|
+
*/
|
|
16
|
+
on(t, s) {
|
|
17
|
+
const e = this.listeners.get(t);
|
|
18
|
+
e ? e.add(s) : this.listeners.set(t, /* @__PURE__ */ new Set([s]));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Stop a particular listener from being called when an event is emitted.
|
|
22
|
+
*/
|
|
23
|
+
off(t, s) {
|
|
24
|
+
const e = this.listeners.get(t);
|
|
25
|
+
e && (e.delete(s), e.size === 0 && this.listeners.delete(t));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Advance the lifecycle state machine.
|
|
29
|
+
*/
|
|
30
|
+
emit(t) {
|
|
31
|
+
switch (t) {
|
|
32
|
+
case "willMount": {
|
|
33
|
+
this.state < 1 ? (this.state = 1, this.notify(t)) : this.context.crash(new Error(`Tried to WILL_MOUNT context at state ${this.state}`));
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "didMount": {
|
|
37
|
+
this.state >= 1 && this.state < 2 ? (this.state = 2, this.notify(t)) : this.context.crash(new Error(`Tried to WILL_UNMOUNT context at state ${this.state}`));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case "willUnmount": {
|
|
41
|
+
this.state >= 2 && this.state < 3 ? (this.notify(t), this.state = 3) : this.context.crash(new Error(`Tried to WILL_UNMOUNT context at state ${this.state}`));
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case "didUnmount": {
|
|
45
|
+
this.state >= 3 && this.state < 4 ? (this.state = 4 % 4, this.notify(t)) : this.context.crash(new Error(`Tried to DID_UNMOUNT context at state ${this.state}`));
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "dispose": {
|
|
49
|
+
this.state === 0 ? (this.notify(t), this.listeners.clear(), this.bound = void 0, this.context[f] = void 0, this.context[y] = void 0, this.state = 5) : this.context.crash(new Error(`Tried to DISPOSE context at state ${this.state}`));
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Bind `context` to this lifecycle; when any event is emitted here it will be emitted for `context` as well.
|
|
56
|
+
*/
|
|
57
|
+
bind(t) {
|
|
58
|
+
this.bound ? this.bound.add(t) : this.bound = /* @__PURE__ */ new Set([t]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Call all the event's listeners and re-emit to bound contexts.
|
|
62
|
+
*/
|
|
63
|
+
notify(t) {
|
|
64
|
+
const s = this.listeners.get(t);
|
|
65
|
+
if (s)
|
|
66
|
+
for (const e of s)
|
|
67
|
+
e();
|
|
68
|
+
if (this.bound)
|
|
69
|
+
for (const e of this.bound)
|
|
70
|
+
e[l].emit(t);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
class h {
|
|
74
|
+
#t;
|
|
75
|
+
[k];
|
|
76
|
+
[l] = new st(this);
|
|
77
|
+
[b];
|
|
78
|
+
[y];
|
|
79
|
+
[f];
|
|
80
|
+
get isMounted() {
|
|
81
|
+
const { state: t } = this[l];
|
|
82
|
+
return t >= 2 && t < 4;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns a new Context with this one as its parent.
|
|
86
|
+
*/
|
|
87
|
+
static createChildOf(t, s, e) {
|
|
88
|
+
const o = new h(s, e);
|
|
89
|
+
return o[b] = t, e?.bindLifecycleToParent && t[l].bind(o), o;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Emit a lifecycle event to `context`.
|
|
93
|
+
*/
|
|
94
|
+
static emit(t, s) {
|
|
95
|
+
t[l].emit(s);
|
|
96
|
+
}
|
|
97
|
+
constructor(t, s) {
|
|
98
|
+
this.#t = t, this[k] = v(t);
|
|
99
|
+
const e = G(() => w(this.#t), s?.logger), o = Object.getOwnPropertyDescriptors(e);
|
|
100
|
+
for (const r in o)
|
|
101
|
+
Object.defineProperty(this, r, o[r]);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the current name of this context.
|
|
105
|
+
*/
|
|
106
|
+
getName() {
|
|
107
|
+
return v(this.#t);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Sets a new name for this context.
|
|
111
|
+
*/
|
|
112
|
+
setName(t) {
|
|
113
|
+
this.#t = t, this[k] = v(t);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates an instance of a store and attaches it to this context.
|
|
117
|
+
*/
|
|
118
|
+
provideStore(t, s) {
|
|
119
|
+
if (this[y]?.get(t)) {
|
|
120
|
+
let o = t.name ? `'${t.name}'` : "this store";
|
|
121
|
+
throw this.crash(new Error(`An instance of ${o} was already added on this context.`));
|
|
122
|
+
}
|
|
123
|
+
const e = h.createChildOf(this, t.name, {
|
|
124
|
+
bindLifecycleToParent: !0,
|
|
125
|
+
logger: { tag: _(), tagName: "uid" }
|
|
126
|
+
});
|
|
127
|
+
try {
|
|
128
|
+
this[y] || (this[y] = /* @__PURE__ */ new Map());
|
|
129
|
+
const o = N(e), r = t(s);
|
|
130
|
+
N(o), this[y].set(t, r);
|
|
131
|
+
} catch (o) {
|
|
132
|
+
throw this.crash(o);
|
|
133
|
+
}
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Retrieves the nearest instance of `store`. If this context doesn't have it, the parent context is checked. This process continues until either:
|
|
138
|
+
* 1. An instance of the store is found and returned.
|
|
139
|
+
* 2. No instance is found and an error is thrown.
|
|
140
|
+
*/
|
|
141
|
+
useStore(t) {
|
|
142
|
+
if (!u(t))
|
|
143
|
+
throw new Error("Invalid store.");
|
|
144
|
+
let s = this, e;
|
|
145
|
+
for (; e = s[y]?.get(t), e == null && s[b] != null; )
|
|
146
|
+
s = s[b];
|
|
147
|
+
if (e == null)
|
|
148
|
+
throw this.crash(new Error(`Store '${t.name}' is not provided by this context.`));
|
|
149
|
+
return e;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Registers a `listener` to be called at a specific transition point during this context's lifecycle.
|
|
153
|
+
*
|
|
154
|
+
* Prefer `useMount` and `useUnmount` hooks for general usage.
|
|
155
|
+
*/
|
|
156
|
+
onLifecycleTransition(t, s) {
|
|
157
|
+
return this[l].on(t, s), () => this[l].off(t, s);
|
|
158
|
+
}
|
|
159
|
+
effect(t) {
|
|
160
|
+
const s = () => {
|
|
161
|
+
try {
|
|
162
|
+
return t();
|
|
163
|
+
} catch (e) {
|
|
164
|
+
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"));
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
if (this[l].state >= 1) {
|
|
168
|
+
const e = m(s);
|
|
169
|
+
return this[l].on("didUnmount", e), e;
|
|
170
|
+
} else {
|
|
171
|
+
let e, o = !1;
|
|
172
|
+
return this[l].on("willMount", () => {
|
|
173
|
+
o || (e = m(s), this[l].on("didUnmount", e));
|
|
174
|
+
}), () => {
|
|
175
|
+
e != null && (o = !0, e());
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
getState(t, s) {
|
|
180
|
+
const e = s?.immediate ?? !1;
|
|
181
|
+
let o = this, r;
|
|
182
|
+
for (; r = o[f]?.get(t), r === void 0 && !e && o[b] != null; )
|
|
183
|
+
o = o[b];
|
|
184
|
+
if (r === void 0) {
|
|
185
|
+
if (s != null && Object.hasOwn(s, "fallback"))
|
|
186
|
+
return s.fallback;
|
|
187
|
+
throw new Error(`Expected a value for '${String(t)}' but got undefined.`);
|
|
188
|
+
}
|
|
189
|
+
return r;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns a Map containing all state values available to this context.
|
|
193
|
+
*
|
|
194
|
+
* Pass `options.immediate` to only include state stored on this context.
|
|
195
|
+
* By default all state stored on parent contexts is also included.
|
|
196
|
+
*/
|
|
197
|
+
getStateMap(t) {
|
|
198
|
+
let s = this;
|
|
199
|
+
const e = t?.immediate ?? !1, o = [];
|
|
200
|
+
for (; s[f] && o.push(...s[f].entries()), !e && s[b] != null; )
|
|
201
|
+
s = s[b];
|
|
202
|
+
return new Map(o.reverse());
|
|
203
|
+
}
|
|
204
|
+
setState(...t) {
|
|
205
|
+
if (this[f] || (this[f] = /* @__PURE__ */ new Map()), t.length === 2)
|
|
206
|
+
this[f].set(t[0], t[1]);
|
|
207
|
+
else if (q(t[0]) === "array")
|
|
208
|
+
for (const [s, e] of t[0])
|
|
209
|
+
e === void 0 ? this[f].delete(s) : this[f].set(s, e);
|
|
210
|
+
else
|
|
211
|
+
throw new Error("Invalid arguments.");
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function bt(n, t) {
|
|
216
|
+
return new h(n, t);
|
|
217
|
+
}
|
|
218
|
+
class x {
|
|
219
|
+
/**
|
|
220
|
+
* Returns a single DOM node to represent this MarkupNode's position in the DOM.
|
|
221
|
+
* Usually the parent element, but it can be an empty Text node used as a marker.
|
|
222
|
+
*
|
|
223
|
+
* It only needs to be defined while the node is mounted, so it can be created in the `mount` function.
|
|
224
|
+
*/
|
|
225
|
+
getRoot() {
|
|
226
|
+
throw new Error("getRoot method is not implemented");
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Returns true while this node is mounted.
|
|
230
|
+
*/
|
|
231
|
+
isMounted() {
|
|
232
|
+
throw new Error("isMounted method is not implemented");
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Mount this node to a `parent` element.
|
|
236
|
+
* If passed, this node will be mounted as the next sibling of `after`.
|
|
237
|
+
*/
|
|
238
|
+
mount(t, s) {
|
|
239
|
+
throw new Error("mount method is not implemented");
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Unmount this MarkupNode from its parent element.
|
|
243
|
+
*
|
|
244
|
+
* The `skipDOM` option can be passed as an optimization when unmounting a parent node.
|
|
245
|
+
* A value of `true` indicates that no DOM operations need to happen because the parent is already being unmounted.
|
|
246
|
+
*
|
|
247
|
+
* @param skipDOM - No DOM updates will be performed when true. Lifecycle methods will be called regardless.
|
|
248
|
+
*/
|
|
249
|
+
unmount(t) {
|
|
250
|
+
throw new Error("unmount method is not implemented");
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Moves a node without unmounting and remounting (if the browser supports Element.moveBefore).
|
|
254
|
+
*/
|
|
255
|
+
move(t, s) {
|
|
256
|
+
throw new Error("move method is not implemented");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
class M extends x {
|
|
260
|
+
root;
|
|
261
|
+
constructor(t) {
|
|
262
|
+
super(), this.root = t;
|
|
263
|
+
}
|
|
264
|
+
getRoot() {
|
|
265
|
+
return this.root;
|
|
266
|
+
}
|
|
267
|
+
isMounted() {
|
|
268
|
+
return this.root.parentNode != null;
|
|
269
|
+
}
|
|
270
|
+
mount(t, s) {
|
|
271
|
+
t.insertBefore(this.root, s?.nextSibling ?? null);
|
|
272
|
+
}
|
|
273
|
+
unmount(t = !1) {
|
|
274
|
+
!t && this.root.parentNode && this.root.parentNode.removeChild(this.root);
|
|
275
|
+
}
|
|
276
|
+
move(t, s) {
|
|
277
|
+
if ("moveBefore" in t && this.root instanceof Element)
|
|
278
|
+
try {
|
|
279
|
+
t.moveBefore(this.root, s?.nextSibling ?? null);
|
|
280
|
+
} catch {
|
|
281
|
+
this.mount(t, s);
|
|
282
|
+
}
|
|
283
|
+
else
|
|
284
|
+
this.mount(t, s);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
class E extends x {
|
|
288
|
+
root = document.createTextNode("");
|
|
289
|
+
children = [];
|
|
290
|
+
context;
|
|
291
|
+
$slot;
|
|
292
|
+
unsubscribe;
|
|
293
|
+
constructor(t, s) {
|
|
294
|
+
super(), this.context = t, this.$slot = s;
|
|
295
|
+
}
|
|
296
|
+
getRoot() {
|
|
297
|
+
return this.root;
|
|
298
|
+
}
|
|
299
|
+
isMounted() {
|
|
300
|
+
return this.root.parentElement != null;
|
|
301
|
+
}
|
|
302
|
+
mount(t, s) {
|
|
303
|
+
this.isMounted() || (t.insertBefore(this.root, s?.nextSibling ?? null), this.unsubscribe = m(() => {
|
|
304
|
+
try {
|
|
305
|
+
const e = this.$slot();
|
|
306
|
+
v(() => {
|
|
307
|
+
this.update(D(e));
|
|
308
|
+
});
|
|
309
|
+
} catch (e) {
|
|
310
|
+
this.context.crash(e);
|
|
311
|
+
}
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
unmount(t = !1) {
|
|
315
|
+
this.unsubscribe?.(), this.isMounted() && (T(this.root.parentElement, this.root, this.children[0]?.getRoot() ?? null), this.root.parentNode?.removeChild(this.root), this.cleanup(t));
|
|
316
|
+
}
|
|
317
|
+
move(t, s) {
|
|
318
|
+
if ("moveBefore" in t)
|
|
319
|
+
try {
|
|
320
|
+
t.moveBefore(this.root, s?.nextSibling ?? null);
|
|
321
|
+
for (let e = 0; e < this.children.length; e++)
|
|
322
|
+
this.children[e].move(t, this.children[e - 1]?.getRoot() ?? this.root);
|
|
323
|
+
t.moveBefore(this.root, this.children.at(-1)?.getRoot()?.nextSibling ?? null);
|
|
324
|
+
} catch {
|
|
325
|
+
this.mount(t, s);
|
|
326
|
+
}
|
|
327
|
+
else
|
|
328
|
+
this.mount(t, s);
|
|
329
|
+
}
|
|
330
|
+
cleanup(t) {
|
|
331
|
+
for (const s of this.children)
|
|
332
|
+
s.isMounted() && s.unmount(t);
|
|
333
|
+
this.children.length = 0;
|
|
334
|
+
}
|
|
335
|
+
update(t) {
|
|
336
|
+
if (this.cleanup(!1), t.length === 0 || !this.isMounted()) return;
|
|
337
|
+
const s = C(this.context, t);
|
|
338
|
+
for (const r of s) {
|
|
339
|
+
const i = this.children.at(-1)?.getRoot() || this.root;
|
|
340
|
+
r.mount(this.root.parentElement, i), this.children.push(r);
|
|
341
|
+
}
|
|
342
|
+
const e = this.root.parentElement, o = this.children.at(-1)?.getRoot()?.nextSibling ?? null;
|
|
343
|
+
T(e, this.root, o);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const I = Symbol("Ref.EMPTY");
|
|
347
|
+
function ot(...n) {
|
|
348
|
+
return it.bind({ current: n.length ? n[0] : I });
|
|
349
|
+
}
|
|
350
|
+
function it(...n) {
|
|
351
|
+
if (n.length)
|
|
352
|
+
this.current = n[0];
|
|
353
|
+
else if (this.current === I)
|
|
354
|
+
throw new Error("Ref getter was called, but ref has no value! Be sure to set your refs before accessing them.");
|
|
355
|
+
return this.current;
|
|
356
|
+
}
|
|
357
|
+
const $ = Symbol("ViewNode");
|
|
358
|
+
class B extends x {
|
|
359
|
+
id = _();
|
|
360
|
+
props;
|
|
361
|
+
context;
|
|
362
|
+
view;
|
|
363
|
+
node;
|
|
364
|
+
/**
|
|
365
|
+
* @param context - Parent contenxt to link to.
|
|
366
|
+
* @param view - View function to mount.
|
|
367
|
+
* @param props - Props to pass to view function.
|
|
368
|
+
*/
|
|
369
|
+
constructor(t, s, e) {
|
|
370
|
+
super(), this.context = h.createChildOf(t, s.name ?? "anonymous view", {
|
|
371
|
+
logger: {
|
|
372
|
+
tag: this.id,
|
|
373
|
+
tagName: "uid"
|
|
374
|
+
}
|
|
375
|
+
}), this.context.setState($, this), this.props = e, this.view = s;
|
|
376
|
+
}
|
|
377
|
+
getRoot() {
|
|
378
|
+
return this.node?.getRoot();
|
|
379
|
+
}
|
|
380
|
+
isMounted() {
|
|
381
|
+
return this.context.isMounted;
|
|
382
|
+
}
|
|
383
|
+
mount(t, s) {
|
|
384
|
+
const e = this.isMounted();
|
|
385
|
+
if (!e) {
|
|
386
|
+
const { context: o, props: r, view: i } = this;
|
|
387
|
+
try {
|
|
388
|
+
const c = N(o), a = i(r);
|
|
389
|
+
N(c), a != null && a !== !1 && (this.node = V(a, o));
|
|
390
|
+
} catch (c) {
|
|
391
|
+
throw c instanceof Error && o.crash(c), c;
|
|
392
|
+
}
|
|
393
|
+
h.emit(this.context, d.WILL_MOUNT);
|
|
394
|
+
}
|
|
395
|
+
this.node && this.node.mount(t, s), e || h.emit(this.context, d.DID_MOUNT);
|
|
396
|
+
}
|
|
397
|
+
unmount(t = !1) {
|
|
398
|
+
h.emit(this.context, d.WILL_UNMOUNT), this.node && this.node.unmount(t), h.emit(this.context, d.DID_UNMOUNT), h.emit(this.context, d.DISPOSE);
|
|
399
|
+
}
|
|
400
|
+
move(t, s) {
|
|
401
|
+
this.node?.move(t, s);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const nt = (n) => /^on[A-Z]/.test(n), S = Symbol("HTML.isSVG"), rt = ["class", "className", "ref", "mixin", "children"];
|
|
405
|
+
class ct extends x {
|
|
406
|
+
root;
|
|
407
|
+
id = z();
|
|
408
|
+
tag;
|
|
409
|
+
props;
|
|
410
|
+
context;
|
|
411
|
+
childNodes = [];
|
|
412
|
+
unsubscribers = [];
|
|
413
|
+
// Track the ref so we can nullify it on unmount.
|
|
414
|
+
ref;
|
|
415
|
+
// Prevents 'onClickOutside' handlers from firing in the same cycle in which the element is connected.
|
|
416
|
+
canClickAway = !1;
|
|
417
|
+
constructor(t, s, e) {
|
|
418
|
+
if (super(), this.tag = s, this.props = e, this.context = h.createChildOf(t, P.bind(this)), s.toLowerCase() === "svg" && this.context.setState(S, !0), this.context.getState(S, { fallback: !1 }) ? this.root = document.createElementNS("http://www.w3.org/2000/svg", s) : this.root = document.createElement(s), H() === "development") {
|
|
419
|
+
const o = this.context.getState($, { fallback: null });
|
|
420
|
+
o && (this.root.dataset.view = o.context.getName());
|
|
421
|
+
}
|
|
422
|
+
if (e.ref)
|
|
423
|
+
if (u(e.ref))
|
|
424
|
+
this.ref = e.ref, this.ref(this.root);
|
|
425
|
+
else
|
|
426
|
+
throw new Error("Expected ref to be a function. Got: " + e.ref);
|
|
427
|
+
}
|
|
428
|
+
getRoot() {
|
|
429
|
+
return this.root;
|
|
430
|
+
}
|
|
431
|
+
isMounted() {
|
|
432
|
+
return this.context.isMounted;
|
|
433
|
+
}
|
|
434
|
+
mount(t, s) {
|
|
435
|
+
const e = this.isMounted();
|
|
436
|
+
if (!e) {
|
|
437
|
+
const { props: o } = this;
|
|
438
|
+
if (o.mixin)
|
|
439
|
+
for (const i of D(o.mixin)) {
|
|
440
|
+
const c = h.createChildOf(this.context, P.bind(this), {
|
|
441
|
+
bindLifecycleToParent: !0,
|
|
442
|
+
logger: { tagName: i.name === "mixin" ? void 0 : "mixin", tag: i.name }
|
|
443
|
+
}), a = N(c);
|
|
444
|
+
i(this.root, c), N(a);
|
|
445
|
+
}
|
|
446
|
+
h.emit(this.context, d.WILL_MOUNT);
|
|
447
|
+
const r = o.className ?? o.class;
|
|
448
|
+
this.applyProps(this.root, o), o.style && this.applyStyles(this.root, o.style, this.unsubscribers), r && this.applyClasses(this.root, r, this.unsubscribers), o.children && (this.childNodes = C(this.context, o.children));
|
|
449
|
+
}
|
|
450
|
+
if (!e)
|
|
451
|
+
for (let o = 0; o < this.childNodes.length; o++) {
|
|
452
|
+
const r = this.childNodes[o], i = o > 0 ? this.childNodes[o - 1].getRoot() : void 0;
|
|
453
|
+
r.mount(this.root, i);
|
|
454
|
+
}
|
|
455
|
+
this.root.parentNode === t && "moveBefore" in t ? t.moveBefore(this.root, s?.nextSibling ?? null) : t.insertBefore(this.root, s?.nextSibling ?? null), this.canClickAway = !0, e || h.emit(this.context, d.DID_MOUNT);
|
|
456
|
+
}
|
|
457
|
+
unmount(t = !1) {
|
|
458
|
+
h.emit(this.context, d.WILL_UNMOUNT), t || this.root.parentNode?.removeChild(this.root);
|
|
459
|
+
for (const s of this.childNodes)
|
|
460
|
+
s.unmount(!0);
|
|
461
|
+
this.canClickAway = !1;
|
|
462
|
+
for (const s of this.unsubscribers)
|
|
463
|
+
s();
|
|
464
|
+
this.unsubscribers.length = 0, h.emit(this.context, d.DID_UNMOUNT), h.emit(this.context, d.DISPOSE), queueMicrotask(() => {
|
|
465
|
+
this.ref && this.ref(I);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
move(t, s) {
|
|
469
|
+
if ("moveBefore" in t)
|
|
470
|
+
try {
|
|
471
|
+
t.moveBefore(this.root, s?.nextSibling ?? null);
|
|
472
|
+
} catch {
|
|
473
|
+
this.mount(t, s);
|
|
474
|
+
}
|
|
475
|
+
else
|
|
476
|
+
this.mount(t, s);
|
|
477
|
+
}
|
|
478
|
+
attachProp(t, s, e) {
|
|
479
|
+
u(t) ? this.unsubscribers.push(
|
|
480
|
+
m(() => {
|
|
481
|
+
try {
|
|
482
|
+
s(t());
|
|
483
|
+
} catch (o) {
|
|
484
|
+
this.context.error(o), this.context.crash(o);
|
|
485
|
+
}
|
|
486
|
+
})
|
|
487
|
+
) : s(t);
|
|
488
|
+
}
|
|
489
|
+
getKey(t) {
|
|
490
|
+
return this.id + ":" + t;
|
|
491
|
+
}
|
|
492
|
+
applyProps(t, s) {
|
|
493
|
+
for (const e in Y(rt, s)) {
|
|
494
|
+
const o = s[e];
|
|
495
|
+
if (e === "on:clickoutside" || e === "onClickOutside" || e === "onclickoutside") {
|
|
496
|
+
const r = (c) => {
|
|
497
|
+
this.canClickAway && !t.contains(c.target) && o(c);
|
|
498
|
+
}, i = { capture: !0 };
|
|
499
|
+
window.addEventListener("click", r, i), this.unsubscribers.push(() => {
|
|
500
|
+
window.removeEventListener("click", r, i);
|
|
501
|
+
});
|
|
502
|
+
} else if (e.startsWith("prop:")) {
|
|
503
|
+
const r = e.substring(5);
|
|
504
|
+
this.attachProp(
|
|
505
|
+
o,
|
|
506
|
+
(i) => {
|
|
507
|
+
t[r] = i;
|
|
508
|
+
},
|
|
509
|
+
this.getKey(r)
|
|
510
|
+
);
|
|
511
|
+
} else if (e.startsWith("on:")) {
|
|
512
|
+
const r = e.substring(3);
|
|
513
|
+
let i;
|
|
514
|
+
u(o) ? (t.addEventListener(r, o), this.unsubscribers.push(() => {
|
|
515
|
+
t.removeEventListener(r, o);
|
|
516
|
+
})) : this.attachProp(
|
|
517
|
+
o,
|
|
518
|
+
(c) => {
|
|
519
|
+
!c && i ? t.removeEventListener(r, i) : c != null && (i && i !== c && t.removeEventListener(r, i), t.addEventListener(r, c)), i = c;
|
|
520
|
+
},
|
|
521
|
+
this.getKey(r)
|
|
522
|
+
);
|
|
523
|
+
} else if (e.startsWith("attr:")) {
|
|
524
|
+
const r = e.substring(5).toLowerCase();
|
|
525
|
+
this.attachProp(
|
|
526
|
+
o,
|
|
527
|
+
(i) => {
|
|
528
|
+
i != null ? t.setAttribute(r, String(i)) : t.removeAttribute(r);
|
|
529
|
+
},
|
|
530
|
+
this.getKey(r)
|
|
531
|
+
);
|
|
532
|
+
} else if (u(o) && nt(e)) {
|
|
533
|
+
const r = e.slice(2).toLowerCase(), i = o;
|
|
534
|
+
t.addEventListener(r, i), this.unsubscribers.push(() => {
|
|
535
|
+
t.removeEventListener(r, i);
|
|
536
|
+
});
|
|
537
|
+
} else if (e.startsWith("on") && u(o) && at.includes(e.substring(2)))
|
|
538
|
+
t[e] = o, this.unsubscribers.push(() => {
|
|
539
|
+
t[e] = void 0;
|
|
540
|
+
});
|
|
541
|
+
else if (e.includes("-"))
|
|
542
|
+
this.attachProp(
|
|
543
|
+
o,
|
|
544
|
+
(r) => {
|
|
545
|
+
r == null ? t.removeAttribute(e) : t.setAttribute(e, String(r));
|
|
546
|
+
},
|
|
547
|
+
this.getKey(e)
|
|
548
|
+
);
|
|
549
|
+
else if (this.context.getState(S, { fallback: !1 }))
|
|
550
|
+
this.attachProp(
|
|
551
|
+
o,
|
|
552
|
+
(r) => {
|
|
553
|
+
r != null ? t.setAttribute(e, String(s[e])) : t.removeAttribute(e);
|
|
554
|
+
},
|
|
555
|
+
this.getKey(e)
|
|
556
|
+
);
|
|
557
|
+
else
|
|
558
|
+
switch (e) {
|
|
559
|
+
case "contentEditable":
|
|
560
|
+
case "value":
|
|
561
|
+
this.attachProp(
|
|
562
|
+
o,
|
|
563
|
+
(i) => {
|
|
564
|
+
t[e] = String(i);
|
|
565
|
+
},
|
|
566
|
+
this.getKey(e)
|
|
567
|
+
);
|
|
568
|
+
break;
|
|
569
|
+
case "for":
|
|
570
|
+
this.attachProp(
|
|
571
|
+
o,
|
|
572
|
+
(i) => {
|
|
573
|
+
t.htmlFor = i;
|
|
574
|
+
},
|
|
575
|
+
this.getKey(e)
|
|
576
|
+
);
|
|
577
|
+
break;
|
|
578
|
+
case "innerHTML":
|
|
579
|
+
this.attachProp(
|
|
580
|
+
o,
|
|
581
|
+
(i) => {
|
|
582
|
+
t.innerHTML = i;
|
|
583
|
+
},
|
|
584
|
+
this.getKey(e)
|
|
585
|
+
);
|
|
586
|
+
break;
|
|
587
|
+
case "title":
|
|
588
|
+
this.attachProp(
|
|
589
|
+
o,
|
|
590
|
+
(i) => {
|
|
591
|
+
i == null ? t.removeAttribute(e) : t.setAttribute(e, String(i));
|
|
592
|
+
},
|
|
593
|
+
this.getKey(e)
|
|
594
|
+
);
|
|
595
|
+
case "checked":
|
|
596
|
+
this.attachProp(
|
|
597
|
+
o,
|
|
598
|
+
(i) => {
|
|
599
|
+
t.checked = i, i ? t.setAttribute("checked", "") : t.removeAttribute("checked");
|
|
600
|
+
},
|
|
601
|
+
this.getKey(e)
|
|
602
|
+
);
|
|
603
|
+
break;
|
|
604
|
+
case "dataset":
|
|
605
|
+
let r = {};
|
|
606
|
+
this.attachProp(
|
|
607
|
+
o,
|
|
608
|
+
(i) => {
|
|
609
|
+
if (L(i)) {
|
|
610
|
+
const c = {};
|
|
611
|
+
for (const a in i)
|
|
612
|
+
c[Z(a)] = String(i[a]);
|
|
613
|
+
for (const a in r)
|
|
614
|
+
Object.hasOwn(c, a) || (delete t.dataset[a], delete r[a]);
|
|
615
|
+
for (const a in c)
|
|
616
|
+
r[a] !== c[a] && (t.dataset[a] = c[a], r[a] = c[a]);
|
|
617
|
+
} else
|
|
618
|
+
for (const c in r)
|
|
619
|
+
delete t.dataset[c];
|
|
620
|
+
},
|
|
621
|
+
this.getKey(e)
|
|
622
|
+
);
|
|
623
|
+
break;
|
|
624
|
+
case "autocomplete":
|
|
625
|
+
case "autocapitalize":
|
|
626
|
+
this.attachProp(
|
|
627
|
+
o,
|
|
628
|
+
(i) => {
|
|
629
|
+
typeof i == "string" ? t[e] = i : i ? t[e] = "on" : t[e] = "off";
|
|
630
|
+
},
|
|
631
|
+
this.getKey(e)
|
|
632
|
+
);
|
|
633
|
+
break;
|
|
634
|
+
default: {
|
|
635
|
+
this.attachProp(
|
|
636
|
+
o,
|
|
637
|
+
(i) => {
|
|
638
|
+
t[e] = i;
|
|
639
|
+
},
|
|
640
|
+
this.getKey(e)
|
|
641
|
+
);
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
applyStyles(t, s, e) {
|
|
648
|
+
const o = [];
|
|
649
|
+
if (u(s)) {
|
|
650
|
+
let r;
|
|
651
|
+
const i = m(() => {
|
|
652
|
+
u(r) && r(), t.style.cssText = "", r = this.applyStyles(t, w(s), e);
|
|
653
|
+
});
|
|
654
|
+
e.push(i), o.push(i);
|
|
655
|
+
} else {
|
|
656
|
+
const r = W(s);
|
|
657
|
+
for (const i in r) {
|
|
658
|
+
const { value: c, priority: a } = r[i];
|
|
659
|
+
if (u(c)) {
|
|
660
|
+
const g = m(() => {
|
|
661
|
+
w(c) ? t.style.setProperty(i, String(A(w(c))), a) : t.style.removeProperty(i);
|
|
662
|
+
});
|
|
663
|
+
e.push(g), o.push(g);
|
|
664
|
+
} else c != null && t.style.setProperty(i, String(A(c)));
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return function() {
|
|
668
|
+
for (const i of o)
|
|
669
|
+
i(), e.splice(e.indexOf(i), 1);
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
applyClasses(t, s, e) {
|
|
673
|
+
const o = [];
|
|
674
|
+
if (u(s)) {
|
|
675
|
+
let r;
|
|
676
|
+
const i = m(() => {
|
|
677
|
+
u(r) && r(), t.removeAttribute("class"), r = this.applyClasses(t, w(s), e);
|
|
678
|
+
});
|
|
679
|
+
e.push(i), o.push(i);
|
|
680
|
+
} else {
|
|
681
|
+
const r = K(s);
|
|
682
|
+
for (const i in r) {
|
|
683
|
+
const c = r[i];
|
|
684
|
+
if (u(c)) {
|
|
685
|
+
const a = m(() => {
|
|
686
|
+
w(c) ? t.classList.add(i) : t.classList.remove(i);
|
|
687
|
+
});
|
|
688
|
+
e.push(a), o.push(a);
|
|
689
|
+
} else c && t.classList.add(i);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
return function() {
|
|
693
|
+
for (const i of o)
|
|
694
|
+
i(), e.splice(e.indexOf(i), 1);
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function K(n) {
|
|
699
|
+
let t = {};
|
|
700
|
+
if (O(n)) {
|
|
701
|
+
const s = n.split(" ");
|
|
702
|
+
for (const e of s)
|
|
703
|
+
t[e] = !0;
|
|
704
|
+
} else L(n) ? Object.assign(t, n) : Array.isArray(n) && Array.from(n).filter(Boolean).forEach((s) => {
|
|
705
|
+
Object.assign(t, K(s));
|
|
706
|
+
});
|
|
707
|
+
return delete t.undefined, t;
|
|
708
|
+
}
|
|
709
|
+
function W(n) {
|
|
710
|
+
let t = {};
|
|
711
|
+
if (O(n)) {
|
|
712
|
+
const s = n.split(";").filter((e) => e.trim() !== "");
|
|
713
|
+
for (const e of s) {
|
|
714
|
+
const [o, r] = e.split(":"), i = {
|
|
715
|
+
value: r
|
|
716
|
+
};
|
|
717
|
+
r.includes("!important") ? (i.priority = "important", i.value = r.replace("!important", "").trim()) : i.value = r.trim(), t[R(o.trim())] = i;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
if (L(n))
|
|
721
|
+
for (const s in n)
|
|
722
|
+
s.startsWith("--") ? t[s] = { value: n[s] } : t[R(s)] = { value: n[s] };
|
|
723
|
+
else Array.isArray(n) && Array.from(n).filter((s) => s != null).forEach((s) => {
|
|
724
|
+
Object.assign(t, W(s));
|
|
725
|
+
});
|
|
726
|
+
return t;
|
|
727
|
+
}
|
|
728
|
+
function P() {
|
|
729
|
+
const n = this.getRoot();
|
|
730
|
+
if (n == null) return this.tag;
|
|
731
|
+
let t = this.getRoot().tagName.toLowerCase();
|
|
732
|
+
if (n.id && (t += `#${n.id}`), n.classList.length > 0)
|
|
733
|
+
for (const s of n.classList.values())
|
|
734
|
+
t += `.${s}`;
|
|
735
|
+
return t;
|
|
736
|
+
}
|
|
737
|
+
function R(n) {
|
|
738
|
+
return n.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, s) => (s ? "-" : "") + t.toLowerCase());
|
|
739
|
+
}
|
|
740
|
+
function A(n) {
|
|
741
|
+
return F(n) ? `${n}px` : n;
|
|
742
|
+
}
|
|
743
|
+
const at = [
|
|
744
|
+
// Element
|
|
745
|
+
"animationcancel",
|
|
746
|
+
"animationend",
|
|
747
|
+
"animationiteration",
|
|
748
|
+
"animationstart",
|
|
749
|
+
"auxclick",
|
|
750
|
+
"beforeinput",
|
|
751
|
+
"beforematch",
|
|
752
|
+
"beforexrselect",
|
|
753
|
+
"blur",
|
|
754
|
+
"click",
|
|
755
|
+
"compositionend",
|
|
756
|
+
"compositionstart",
|
|
757
|
+
"compositionupdate",
|
|
758
|
+
"contentvisibilityautostatechange",
|
|
759
|
+
"contextmenu",
|
|
760
|
+
"copy",
|
|
761
|
+
"cut",
|
|
762
|
+
"dblclick",
|
|
763
|
+
"focus",
|
|
764
|
+
"focusin",
|
|
765
|
+
"focusout",
|
|
766
|
+
"fullscreenchange",
|
|
767
|
+
"fullscreenerror",
|
|
768
|
+
"gotpointercapture",
|
|
769
|
+
"input",
|
|
770
|
+
"keydown",
|
|
771
|
+
"keyup",
|
|
772
|
+
"lostpointercapture",
|
|
773
|
+
"mousedown",
|
|
774
|
+
"mouseenter",
|
|
775
|
+
"mouseleave",
|
|
776
|
+
"mousemove",
|
|
777
|
+
"mouseout",
|
|
778
|
+
"mouseover",
|
|
779
|
+
"mouseup",
|
|
780
|
+
"paste",
|
|
781
|
+
"pointercancel",
|
|
782
|
+
"pointerdown",
|
|
783
|
+
"pointerenter",
|
|
784
|
+
"pointerleave",
|
|
785
|
+
"pointermove",
|
|
786
|
+
"pointerout",
|
|
787
|
+
"pointerover",
|
|
788
|
+
"pointerrawupdate",
|
|
789
|
+
"pointerup",
|
|
790
|
+
"scroll",
|
|
791
|
+
"scrollend",
|
|
792
|
+
"scrollsnapchange",
|
|
793
|
+
"scrollsnapchanging",
|
|
794
|
+
"securitypolicyviolation",
|
|
795
|
+
"touchcancel",
|
|
796
|
+
"touchend",
|
|
797
|
+
"touchmove",
|
|
798
|
+
"touchstart",
|
|
799
|
+
"transitioncancel",
|
|
800
|
+
"transitionend",
|
|
801
|
+
"transitionrun",
|
|
802
|
+
"transitionstart",
|
|
803
|
+
"webkitmouseforcechanged",
|
|
804
|
+
"webkitmouseforcedown",
|
|
805
|
+
"webkitmouseforceup",
|
|
806
|
+
"webkimouseforcewillbegin",
|
|
807
|
+
"wheel",
|
|
808
|
+
// HTMLElement
|
|
809
|
+
"beforetoggle",
|
|
810
|
+
"change",
|
|
811
|
+
"command",
|
|
812
|
+
"drag",
|
|
813
|
+
"dragend",
|
|
814
|
+
"dragenter",
|
|
815
|
+
"dragleave",
|
|
816
|
+
"dragover",
|
|
817
|
+
"dragstart",
|
|
818
|
+
"drop",
|
|
819
|
+
"error",
|
|
820
|
+
"load",
|
|
821
|
+
"toggle",
|
|
822
|
+
// HTMLInputElement
|
|
823
|
+
"cancel",
|
|
824
|
+
"invalid",
|
|
825
|
+
"search",
|
|
826
|
+
"select",
|
|
827
|
+
"selectionchange",
|
|
828
|
+
// HTMLFormElement
|
|
829
|
+
"formdata",
|
|
830
|
+
"reset",
|
|
831
|
+
"submit"
|
|
832
|
+
];
|
|
833
|
+
class ht extends x {
|
|
834
|
+
context;
|
|
835
|
+
value;
|
|
836
|
+
parent;
|
|
837
|
+
node;
|
|
838
|
+
constructor(t, s, e) {
|
|
839
|
+
super(), this.context = t, this.value = s, this.parent = e;
|
|
840
|
+
}
|
|
841
|
+
getRoot() {
|
|
842
|
+
return this.node?.getRoot();
|
|
843
|
+
}
|
|
844
|
+
isMounted() {
|
|
845
|
+
return this.node ? this.node.isMounted() : !1;
|
|
846
|
+
}
|
|
847
|
+
mount(t, s) {
|
|
848
|
+
const e = V(this.value, this.context);
|
|
849
|
+
this.node = e, e.mount(this.parent);
|
|
850
|
+
}
|
|
851
|
+
unmount(t = !1) {
|
|
852
|
+
this.node?.isMounted() && this.node.unmount(!1);
|
|
853
|
+
}
|
|
854
|
+
move(t, s) {
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function p(n) {
|
|
858
|
+
const t = X();
|
|
859
|
+
if (!t)
|
|
860
|
+
throw new Error("No context found; hooks can only be called in the body of a View, Store or Mixin.");
|
|
861
|
+
return n != null && t.setName(n), t;
|
|
862
|
+
}
|
|
863
|
+
function yt(n) {
|
|
864
|
+
return p().useStore(n);
|
|
865
|
+
}
|
|
866
|
+
function wt(n, t) {
|
|
867
|
+
return p().provideStore(n, t).useStore(n);
|
|
868
|
+
}
|
|
869
|
+
function xt(n) {
|
|
870
|
+
const t = p();
|
|
871
|
+
t.onLifecycleTransition("didMount", () => {
|
|
872
|
+
const s = n();
|
|
873
|
+
s && t.onLifecycleTransition("didUnmount", s);
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
function vt(n) {
|
|
877
|
+
p().onLifecycleTransition("didUnmount", n);
|
|
878
|
+
}
|
|
879
|
+
function ut(n, t) {
|
|
880
|
+
return p(), J(n, t);
|
|
881
|
+
}
|
|
882
|
+
function Nt(n, t, s) {
|
|
883
|
+
return p(), Q(n, { ...s, deps: t });
|
|
884
|
+
}
|
|
885
|
+
function kt(n, t) {
|
|
886
|
+
const [s, e] = ut(t);
|
|
887
|
+
return [s, (r) => {
|
|
888
|
+
e((i) => n(i, r));
|
|
889
|
+
}];
|
|
890
|
+
}
|
|
891
|
+
function Mt(n, t) {
|
|
892
|
+
const s = p();
|
|
893
|
+
t ? s.effect(() => {
|
|
894
|
+
for (const e of t) w(e);
|
|
895
|
+
return v(n);
|
|
896
|
+
}) : s.effect(n);
|
|
897
|
+
}
|
|
898
|
+
function St(...n) {
|
|
899
|
+
p();
|
|
900
|
+
const t = ot(...n);
|
|
901
|
+
return Object.defineProperty(t, "current", { get: t, set: t }), t;
|
|
902
|
+
}
|
|
903
|
+
class lt extends x {
|
|
904
|
+
root = document.createTextNode("");
|
|
905
|
+
context;
|
|
906
|
+
items;
|
|
907
|
+
key;
|
|
908
|
+
render;
|
|
909
|
+
unsubscribe = null;
|
|
910
|
+
connectedItems = /* @__PURE__ */ new Map();
|
|
911
|
+
constructor(t, s, e, o) {
|
|
912
|
+
super(), this.context = t, this.items = s, this.key = e, this.render = o;
|
|
913
|
+
}
|
|
914
|
+
getRoot() {
|
|
915
|
+
return this.root;
|
|
916
|
+
}
|
|
917
|
+
isMounted() {
|
|
918
|
+
return this.root.parentElement != null;
|
|
919
|
+
}
|
|
920
|
+
mount(t, s) {
|
|
921
|
+
this.isMounted() || (t.insertBefore(this.root, s?.nextSibling ?? null), this.unsubscribe = m(() => {
|
|
922
|
+
let e = this.items();
|
|
923
|
+
e == null && (e = [], this.context.warn("repeat() received empty value for items", e)), v(() => {
|
|
924
|
+
this._update(Array.from(e));
|
|
925
|
+
});
|
|
926
|
+
}));
|
|
927
|
+
}
|
|
928
|
+
unmount(t = !1) {
|
|
929
|
+
this.unsubscribe && (this.unsubscribe(), this.unsubscribe = null), !t && this.isMounted() && this.root.parentNode?.removeChild(this.root), this._cleanup(!0);
|
|
930
|
+
}
|
|
931
|
+
move(t, s) {
|
|
932
|
+
return this.mount(t, s);
|
|
933
|
+
}
|
|
934
|
+
_cleanup(t) {
|
|
935
|
+
for (const s of this.connectedItems.values())
|
|
936
|
+
s.node.unmount(t);
|
|
937
|
+
this.connectedItems.clear();
|
|
938
|
+
}
|
|
939
|
+
_update(t) {
|
|
940
|
+
if (t.length === 0 || !this.isMounted())
|
|
941
|
+
return this._cleanup(!1);
|
|
942
|
+
const s = /* @__PURE__ */ new Map();
|
|
943
|
+
let e = 0;
|
|
944
|
+
for (const i of t) {
|
|
945
|
+
const c = this.key(i, e);
|
|
946
|
+
s.set(c, {
|
|
947
|
+
key: c,
|
|
948
|
+
value: i,
|
|
949
|
+
index: e++
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
const o = [];
|
|
953
|
+
for (const i of this.connectedItems.values())
|
|
954
|
+
!s.has(i.key) && i.node.isMounted() && i.node.unmount(!1);
|
|
955
|
+
tt(() => {
|
|
956
|
+
for (const i of s.values()) {
|
|
957
|
+
const c = this.connectedItems.get(i.key);
|
|
958
|
+
if (c && c.node.isMounted())
|
|
959
|
+
c.item.set(i.value), c.index.set(i.index), o[i.index] = c;
|
|
960
|
+
else {
|
|
961
|
+
const a = U(i.value, { equals: et }), g = U(i.index);
|
|
962
|
+
o[i.index] = {
|
|
963
|
+
key: i.key,
|
|
964
|
+
item: a,
|
|
965
|
+
index: g,
|
|
966
|
+
node: new B(this.context, ft, {
|
|
967
|
+
item: () => a(),
|
|
968
|
+
index: () => g(),
|
|
969
|
+
render: this.render
|
|
970
|
+
})
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
for (let i = 0; i < o.length; i++) {
|
|
976
|
+
const c = o[i], a = o[i - 1]?.node.getRoot() ?? this.root, g = this.connectedItems.get(c.key);
|
|
977
|
+
g && g.node.isMounted() ? c.node.move(this.root.parentElement, a) : c.node.mount(this.root.parentElement, a);
|
|
978
|
+
}
|
|
979
|
+
this.connectedItems.clear();
|
|
980
|
+
for (const i of o)
|
|
981
|
+
this.connectedItems.set(i.key, i);
|
|
982
|
+
const r = o.at(-1)?.node.getRoot() ?? this.root;
|
|
983
|
+
this.root.parentNode?.insertBefore(this.root, r.nextSibling);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
const dt = "dolla.RepeatItemView";
|
|
987
|
+
function ft(n) {
|
|
988
|
+
return p(dt), n.render(n.item, n.index);
|
|
989
|
+
}
|
|
990
|
+
class j {
|
|
991
|
+
/**
|
|
992
|
+
* 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.
|
|
993
|
+
* DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
|
|
994
|
+
*/
|
|
995
|
+
type;
|
|
996
|
+
/**
|
|
997
|
+
* Data that will be passed to a new MarkupNode instance when it is constructed.
|
|
998
|
+
* Includes a `children` prop if children were passed.
|
|
999
|
+
*/
|
|
1000
|
+
props;
|
|
1001
|
+
constructor(t, s) {
|
|
1002
|
+
this.type = t, this.props = s;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
var mt = /* @__PURE__ */ ((n) => (n.DOM = "$dom", n.Dynamic = "$dynamic", n.Portal = "$portal", n.Repeat = "$repeat", n))(mt || {});
|
|
1006
|
+
function Et(n, t) {
|
|
1007
|
+
return new j(n, t ?? {});
|
|
1008
|
+
}
|
|
1009
|
+
function V(n, t = new h("$")) {
|
|
1010
|
+
const s = C(t, n);
|
|
1011
|
+
return s.length === 1 ? s[0] : new E(t, () => s);
|
|
1012
|
+
}
|
|
1013
|
+
function C(n, ...t) {
|
|
1014
|
+
const s = t.flat(1 / 0), e = [];
|
|
1015
|
+
for (const o of s)
|
|
1016
|
+
if (!(o == null || o === !1)) {
|
|
1017
|
+
if (o instanceof Node) {
|
|
1018
|
+
e.push(new M(o));
|
|
1019
|
+
continue;
|
|
1020
|
+
}
|
|
1021
|
+
if (o instanceof j)
|
|
1022
|
+
if (u(o.type)) {
|
|
1023
|
+
e.push(new B(n, o.type, o.props));
|
|
1024
|
+
continue;
|
|
1025
|
+
} else if (O(o.type))
|
|
1026
|
+
switch (o.type) {
|
|
1027
|
+
case "$dom": {
|
|
1028
|
+
const r = o.props;
|
|
1029
|
+
e.push(new M(r.value));
|
|
1030
|
+
continue;
|
|
1031
|
+
}
|
|
1032
|
+
case "$dynamic": {
|
|
1033
|
+
const r = o.props;
|
|
1034
|
+
e.push(new E(n, r.source));
|
|
1035
|
+
continue;
|
|
1036
|
+
}
|
|
1037
|
+
case "$portal": {
|
|
1038
|
+
const r = o.props;
|
|
1039
|
+
e.push(new ht(n, r.content, r.parent));
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
case "$repeat": {
|
|
1043
|
+
const r = o.props;
|
|
1044
|
+
e.push(new lt(n, r.items, r.key, r.render));
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
default:
|
|
1048
|
+
e.push(new ct(n, o.type, o.props));
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
else
|
|
1052
|
+
throw new TypeError(`Expected a string or view function. Got: ${o.type}`);
|
|
1053
|
+
if (o instanceof x) {
|
|
1054
|
+
e.push(o);
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
if (u(o)) {
|
|
1058
|
+
e.push(new E(n, o));
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
e.push(new M(document.createTextNode(String(o))));
|
|
1062
|
+
}
|
|
1063
|
+
return e;
|
|
1064
|
+
}
|
|
1065
|
+
export {
|
|
1066
|
+
h as C,
|
|
1067
|
+
E as D,
|
|
1068
|
+
d as L,
|
|
1069
|
+
j as M,
|
|
1070
|
+
lt as R,
|
|
1071
|
+
B as V,
|
|
1072
|
+
mt as a,
|
|
1073
|
+
bt as b,
|
|
1074
|
+
Et as c,
|
|
1075
|
+
x as d,
|
|
1076
|
+
ot as e,
|
|
1077
|
+
yt as f,
|
|
1078
|
+
wt as g,
|
|
1079
|
+
xt as h,
|
|
1080
|
+
vt as i,
|
|
1081
|
+
ut as j,
|
|
1082
|
+
Nt as k,
|
|
1083
|
+
kt as l,
|
|
1084
|
+
Mt as m,
|
|
1085
|
+
St as n,
|
|
1086
|
+
V as r,
|
|
1087
|
+
p as u
|
|
1088
|
+
};
|
|
1089
|
+
//# sourceMappingURL=markup-8jNhoqDe.js.map
|