@esportsplus/template 0.16.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/.editorconfig +9 -0
- package/.gitattributes +2 -0
- package/.github/dependabot.yml +25 -0
- package/.github/workflows/bump.yml +9 -0
- package/.github/workflows/dependabot.yml +12 -0
- package/.github/workflows/publish.yml +16 -0
- package/README.md +385 -0
- package/build/attributes.d.ts +5 -0
- package/build/attributes.js +212 -0
- package/build/compiler/codegen.d.ts +21 -0
- package/build/compiler/codegen.js +303 -0
- package/build/compiler/constants.d.ts +16 -0
- package/build/compiler/constants.js +19 -0
- package/build/compiler/index.d.ts +14 -0
- package/build/compiler/index.js +61 -0
- package/build/compiler/parser.d.ts +19 -0
- package/build/compiler/parser.js +164 -0
- package/build/compiler/plugins/tsc.d.ts +3 -0
- package/build/compiler/plugins/tsc.js +4 -0
- package/build/compiler/plugins/vite.d.ts +13 -0
- package/build/compiler/plugins/vite.js +8 -0
- package/build/compiler/ts-analyzer.d.ts +4 -0
- package/build/compiler/ts-analyzer.js +63 -0
- package/build/compiler/ts-parser.d.ts +24 -0
- package/build/compiler/ts-parser.js +67 -0
- package/build/constants.d.ts +12 -0
- package/build/constants.js +25 -0
- package/build/event/index.d.ts +10 -0
- package/build/event/index.js +90 -0
- package/build/event/onconnect.d.ts +3 -0
- package/build/event/onconnect.js +15 -0
- package/build/event/onresize.d.ts +3 -0
- package/build/event/onresize.js +26 -0
- package/build/event/ontick.d.ts +6 -0
- package/build/event/ontick.js +41 -0
- package/build/html.d.ts +9 -0
- package/build/html.js +7 -0
- package/build/index.d.ts +8 -0
- package/build/index.js +12 -0
- package/build/render.d.ts +3 -0
- package/build/render.js +8 -0
- package/build/slot/array.d.ts +25 -0
- package/build/slot/array.js +189 -0
- package/build/slot/cleanup.d.ts +4 -0
- package/build/slot/cleanup.js +23 -0
- package/build/slot/effect.d.ts +12 -0
- package/build/slot/effect.js +85 -0
- package/build/slot/index.d.ts +7 -0
- package/build/slot/index.js +14 -0
- package/build/slot/render.d.ts +2 -0
- package/build/slot/render.js +44 -0
- package/build/svg.d.ts +5 -0
- package/build/svg.js +14 -0
- package/build/types.d.ts +23 -0
- package/build/types.js +1 -0
- package/build/utilities.d.ts +7 -0
- package/build/utilities.js +31 -0
- package/package.json +43 -0
- package/src/attributes.ts +313 -0
- package/src/compiler/codegen.ts +492 -0
- package/src/compiler/constants.ts +25 -0
- package/src/compiler/index.ts +87 -0
- package/src/compiler/parser.ts +242 -0
- package/src/compiler/plugins/tsc.ts +6 -0
- package/src/compiler/plugins/vite.ts +10 -0
- package/src/compiler/ts-analyzer.ts +89 -0
- package/src/compiler/ts-parser.ts +112 -0
- package/src/constants.ts +44 -0
- package/src/event/index.ts +130 -0
- package/src/event/onconnect.ts +22 -0
- package/src/event/onresize.ts +37 -0
- package/src/event/ontick.ts +59 -0
- package/src/html.ts +18 -0
- package/src/index.ts +19 -0
- package/src/llm.txt +403 -0
- package/src/render.ts +13 -0
- package/src/slot/array.ts +257 -0
- package/src/slot/cleanup.ts +37 -0
- package/src/slot/effect.ts +114 -0
- package/src/slot/index.ts +17 -0
- package/src/slot/render.ts +61 -0
- package/src/svg.ts +27 -0
- package/src/types.ts +40 -0
- package/src/utilities.ts +53 -0
- package/storage/compiler-architecture-2026-01-13.md +420 -0
- package/test/dist/test.js +1912 -0
- package/test/dist/test.js.map +1 -0
- package/test/index.ts +648 -0
- package/test/vite.config.ts +23 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,1912 @@
|
|
|
1
|
+
new TextDecoder();
|
|
2
|
+
new TextEncoder();
|
|
3
|
+
BigInt.prototype.toJSON = function() {
|
|
4
|
+
return this.toString();
|
|
5
|
+
};
|
|
6
|
+
new TextEncoder();
|
|
7
|
+
const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
8
|
+
const VALID_CHARACTERS = {};
|
|
9
|
+
for (let i = 0, n = ENCODING.length; i < n; i++) {
|
|
10
|
+
let char = ENCODING[i];
|
|
11
|
+
VALID_CHARACTERS[char] = true;
|
|
12
|
+
VALID_CHARACTERS[char.toLowerCase()] = true;
|
|
13
|
+
}
|
|
14
|
+
crypto.randomUUID.bind(crypto);
|
|
15
|
+
const { defineProperty } = Object;
|
|
16
|
+
const { isArray } = Array;
|
|
17
|
+
const isObject = (value) => {
|
|
18
|
+
return typeof value === "object" && value !== null && value.constructor === Object;
|
|
19
|
+
};
|
|
20
|
+
const isPromise = (val) => {
|
|
21
|
+
return val instanceof Promise;
|
|
22
|
+
};
|
|
23
|
+
const COMPUTED = /* @__PURE__ */ Symbol("reactivity.computed");
|
|
24
|
+
const PACKAGE_NAME = "@esportsplus/reactivity";
|
|
25
|
+
const REACTIVE_ARRAY = /* @__PURE__ */ Symbol("reactivity.reactive.array");
|
|
26
|
+
const REACTIVE_OBJECT = /* @__PURE__ */ Symbol("reactivity.reactive.object");
|
|
27
|
+
const SIGNAL = /* @__PURE__ */ Symbol("reactivity.signal");
|
|
28
|
+
const STABILIZER_IDLE = 0;
|
|
29
|
+
const STABILIZER_RESCHEDULE = 1;
|
|
30
|
+
const STABILIZER_RUNNING = 2;
|
|
31
|
+
const STABILIZER_SCHEDULED = 3;
|
|
32
|
+
const STATE_NONE$1 = 0;
|
|
33
|
+
const STATE_CHECK = 1 << 0;
|
|
34
|
+
const STATE_DIRTY = 1 << 1;
|
|
35
|
+
const STATE_RECOMPUTING = 1 << 2;
|
|
36
|
+
const STATE_IN_HEAP = 1 << 3;
|
|
37
|
+
const STATE_NOTIFY_MASK = STATE_CHECK | STATE_DIRTY;
|
|
38
|
+
let depth = 0, heap = new Array(64), heap_i = 0, heap_n = 0, linkPool = [], linkPoolMax = 1e3, microtask = queueMicrotask, notified = false, observer = null, scope = null, stabilizer = STABILIZER_IDLE, version = 0;
|
|
39
|
+
function cleanup(computed2) {
|
|
40
|
+
if (!computed2.cleanup) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let value = computed2.cleanup;
|
|
44
|
+
if (typeof value === "function") {
|
|
45
|
+
value();
|
|
46
|
+
} else {
|
|
47
|
+
for (let i = 0, n = value.length; i < n; i++) {
|
|
48
|
+
value[i]();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
computed2.cleanup = null;
|
|
52
|
+
}
|
|
53
|
+
function deleteFromHeap(computed2) {
|
|
54
|
+
let state = computed2.state;
|
|
55
|
+
if (!(state & STATE_IN_HEAP)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
computed2.state = state & ~STATE_IN_HEAP;
|
|
59
|
+
let height = computed2.height;
|
|
60
|
+
if (computed2.prevHeap === computed2) {
|
|
61
|
+
heap[height] = void 0;
|
|
62
|
+
} else {
|
|
63
|
+
let next = computed2.nextHeap, dhh = heap[height], end = next ?? dhh;
|
|
64
|
+
if (computed2 === dhh) {
|
|
65
|
+
heap[height] = next;
|
|
66
|
+
} else {
|
|
67
|
+
computed2.prevHeap.nextHeap = next;
|
|
68
|
+
}
|
|
69
|
+
end.prevHeap = computed2.prevHeap;
|
|
70
|
+
}
|
|
71
|
+
computed2.nextHeap = void 0;
|
|
72
|
+
computed2.prevHeap = computed2;
|
|
73
|
+
}
|
|
74
|
+
function insertIntoHeap(computed2) {
|
|
75
|
+
let state = computed2.state;
|
|
76
|
+
if (state & STATE_IN_HEAP) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
computed2.state = state | STATE_IN_HEAP;
|
|
80
|
+
let height = computed2.height, heapAtHeight = heap[height];
|
|
81
|
+
if (heapAtHeight === void 0) {
|
|
82
|
+
heap[height] = computed2;
|
|
83
|
+
} else {
|
|
84
|
+
let tail = heapAtHeight.prevHeap;
|
|
85
|
+
tail.nextHeap = computed2;
|
|
86
|
+
computed2.prevHeap = tail;
|
|
87
|
+
heapAtHeight.prevHeap = computed2;
|
|
88
|
+
}
|
|
89
|
+
if (height > heap_n) {
|
|
90
|
+
heap_n = height;
|
|
91
|
+
if (height >= heap.length) {
|
|
92
|
+
heap.length = Math.max(height + 1, Math.ceil(heap.length * 2));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function link(dep, sub) {
|
|
97
|
+
let prevDep = sub.depsTail;
|
|
98
|
+
if (prevDep && prevDep.dep === dep) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let nextDep = null;
|
|
102
|
+
if (sub.state & STATE_RECOMPUTING) {
|
|
103
|
+
nextDep = prevDep ? prevDep.nextDep : sub.deps;
|
|
104
|
+
if (nextDep && nextDep.dep === dep) {
|
|
105
|
+
nextDep.version = version;
|
|
106
|
+
sub.depsTail = nextDep;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
let prevSub = dep.subsTail;
|
|
111
|
+
if (prevSub && prevSub.version === version && prevSub.sub === sub) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
let pooled = linkPool.pop(), newLink = sub.depsTail = dep.subsTail = pooled ? (pooled.dep = dep, pooled.sub = sub, pooled.nextDep = nextDep, pooled.prevSub = prevSub, pooled.nextSub = null, pooled.version = version, pooled) : {
|
|
115
|
+
dep,
|
|
116
|
+
sub,
|
|
117
|
+
nextDep,
|
|
118
|
+
prevSub,
|
|
119
|
+
nextSub: null,
|
|
120
|
+
version
|
|
121
|
+
};
|
|
122
|
+
if (prevDep) {
|
|
123
|
+
prevDep.nextDep = newLink;
|
|
124
|
+
} else {
|
|
125
|
+
sub.deps = newLink;
|
|
126
|
+
}
|
|
127
|
+
if (prevSub) {
|
|
128
|
+
prevSub.nextSub = newLink;
|
|
129
|
+
} else {
|
|
130
|
+
dep.subs = newLink;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function notify(computed2, newState = STATE_DIRTY) {
|
|
134
|
+
let state = computed2.state;
|
|
135
|
+
if ((state & STATE_NOTIFY_MASK) >= newState) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
computed2.state = state | newState;
|
|
139
|
+
for (let link2 = computed2.subs; link2; link2 = link2.nextSub) {
|
|
140
|
+
notify(link2.sub, STATE_CHECK);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function recompute(computed2, del) {
|
|
144
|
+
if (del) {
|
|
145
|
+
deleteFromHeap(computed2);
|
|
146
|
+
} else {
|
|
147
|
+
computed2.nextHeap = void 0;
|
|
148
|
+
computed2.prevHeap = computed2;
|
|
149
|
+
}
|
|
150
|
+
if (computed2.cleanup) {
|
|
151
|
+
cleanup(computed2);
|
|
152
|
+
}
|
|
153
|
+
let o = observer, ok = true, value;
|
|
154
|
+
observer = computed2;
|
|
155
|
+
computed2.depsTail = null;
|
|
156
|
+
computed2.state = STATE_RECOMPUTING;
|
|
157
|
+
depth++;
|
|
158
|
+
version++;
|
|
159
|
+
try {
|
|
160
|
+
value = computed2.fn(onCleanup);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
ok = false;
|
|
163
|
+
}
|
|
164
|
+
depth--;
|
|
165
|
+
observer = o;
|
|
166
|
+
computed2.state = STATE_NONE$1;
|
|
167
|
+
let depsTail = computed2.depsTail, remove2 = depsTail ? depsTail.nextDep : computed2.deps;
|
|
168
|
+
if (remove2) {
|
|
169
|
+
do {
|
|
170
|
+
remove2 = unlink(remove2);
|
|
171
|
+
} while (remove2);
|
|
172
|
+
if (depsTail) {
|
|
173
|
+
depsTail.nextDep = null;
|
|
174
|
+
} else {
|
|
175
|
+
computed2.deps = null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (ok && value !== computed2.value) {
|
|
179
|
+
computed2.value = value;
|
|
180
|
+
for (let c = computed2.subs; c; c = c.nextSub) {
|
|
181
|
+
let s = c.sub, state = s.state;
|
|
182
|
+
if (state & STATE_CHECK) {
|
|
183
|
+
s.state = state | STATE_DIRTY;
|
|
184
|
+
}
|
|
185
|
+
insertIntoHeap(s);
|
|
186
|
+
}
|
|
187
|
+
schedule$1();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function schedule$1() {
|
|
191
|
+
if (stabilizer === STABILIZER_SCHEDULED) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (stabilizer === STABILIZER_IDLE && !depth) {
|
|
195
|
+
stabilizer = STABILIZER_SCHEDULED;
|
|
196
|
+
microtask(stabilize);
|
|
197
|
+
} else if (stabilizer === STABILIZER_RUNNING) {
|
|
198
|
+
stabilizer = STABILIZER_RESCHEDULE;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function stabilize() {
|
|
202
|
+
let o = observer;
|
|
203
|
+
observer = null;
|
|
204
|
+
stabilizer = STABILIZER_RUNNING;
|
|
205
|
+
for (heap_i = 0; heap_i <= heap_n; heap_i++) {
|
|
206
|
+
let computed2 = heap[heap_i];
|
|
207
|
+
heap[heap_i] = void 0;
|
|
208
|
+
while (computed2 !== void 0) {
|
|
209
|
+
let next = computed2.nextHeap;
|
|
210
|
+
recompute(computed2, false);
|
|
211
|
+
computed2 = next;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
while (heap_n > 0 && heap[heap_n] === void 0) {
|
|
215
|
+
heap_n--;
|
|
216
|
+
}
|
|
217
|
+
observer = o;
|
|
218
|
+
if (stabilizer === STABILIZER_RESCHEDULE) {
|
|
219
|
+
microtask(stabilize);
|
|
220
|
+
} else {
|
|
221
|
+
stabilizer = STABILIZER_IDLE;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function unlink(link2) {
|
|
225
|
+
let dep = link2.dep, nextDep = link2.nextDep, nextSub = link2.nextSub, prevSub = link2.prevSub;
|
|
226
|
+
if (nextSub) {
|
|
227
|
+
nextSub.prevSub = prevSub;
|
|
228
|
+
} else {
|
|
229
|
+
dep.subsTail = prevSub;
|
|
230
|
+
}
|
|
231
|
+
if (prevSub) {
|
|
232
|
+
prevSub.nextSub = nextSub;
|
|
233
|
+
} else if ((dep.subs = nextSub) === null && dep.type === COMPUTED) {
|
|
234
|
+
dispose$1(dep);
|
|
235
|
+
}
|
|
236
|
+
if (linkPool.length < linkPoolMax) {
|
|
237
|
+
link2.dep = link2.sub = null;
|
|
238
|
+
link2.nextDep = link2.nextSub = link2.prevSub = null;
|
|
239
|
+
linkPool.push(link2);
|
|
240
|
+
}
|
|
241
|
+
return nextDep;
|
|
242
|
+
}
|
|
243
|
+
function update(computed2) {
|
|
244
|
+
if (computed2.state & STATE_CHECK) {
|
|
245
|
+
for (let link2 = computed2.deps; link2; link2 = link2.nextDep) {
|
|
246
|
+
let dep = link2.dep;
|
|
247
|
+
if (dep.type === COMPUTED) {
|
|
248
|
+
update(dep);
|
|
249
|
+
if (computed2.state & STATE_DIRTY) {
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (computed2.state & STATE_DIRTY) {
|
|
256
|
+
recompute(computed2, true);
|
|
257
|
+
}
|
|
258
|
+
computed2.state = STATE_NONE$1;
|
|
259
|
+
}
|
|
260
|
+
const computed = (fn) => {
|
|
261
|
+
let self = {
|
|
262
|
+
cleanup: null,
|
|
263
|
+
deps: null,
|
|
264
|
+
depsTail: null,
|
|
265
|
+
fn,
|
|
266
|
+
height: 0,
|
|
267
|
+
nextHeap: void 0,
|
|
268
|
+
prevHeap: null,
|
|
269
|
+
state: STATE_NONE$1,
|
|
270
|
+
subs: null,
|
|
271
|
+
subsTail: null,
|
|
272
|
+
type: COMPUTED,
|
|
273
|
+
value: void 0
|
|
274
|
+
};
|
|
275
|
+
self.prevHeap = self;
|
|
276
|
+
if (observer) {
|
|
277
|
+
if (observer.depsTail === null) {
|
|
278
|
+
self.height = observer.height;
|
|
279
|
+
recompute(self, false);
|
|
280
|
+
} else {
|
|
281
|
+
self.height = observer.height + 1;
|
|
282
|
+
insertIntoHeap(self);
|
|
283
|
+
schedule$1();
|
|
284
|
+
}
|
|
285
|
+
link(self, observer);
|
|
286
|
+
onCleanup(() => dispose$1(self));
|
|
287
|
+
} else {
|
|
288
|
+
recompute(self, false);
|
|
289
|
+
root.disposables++;
|
|
290
|
+
if (scope) {
|
|
291
|
+
onCleanup(() => dispose$1(self));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return self;
|
|
295
|
+
};
|
|
296
|
+
const dispose$1 = (computed2) => {
|
|
297
|
+
deleteFromHeap(computed2);
|
|
298
|
+
let dep = computed2.deps;
|
|
299
|
+
while (dep) {
|
|
300
|
+
dep = unlink(dep);
|
|
301
|
+
}
|
|
302
|
+
computed2.deps = null;
|
|
303
|
+
if (computed2.cleanup) {
|
|
304
|
+
cleanup(computed2);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
const effect = (fn) => {
|
|
308
|
+
let c = computed(fn);
|
|
309
|
+
return () => {
|
|
310
|
+
dispose$1(c);
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
const onCleanup = (fn) => {
|
|
314
|
+
let parent = observer || scope;
|
|
315
|
+
if (!parent) {
|
|
316
|
+
return fn;
|
|
317
|
+
}
|
|
318
|
+
let cleanup2 = parent.cleanup;
|
|
319
|
+
if (!cleanup2) {
|
|
320
|
+
parent.cleanup = fn;
|
|
321
|
+
} else if (typeof cleanup2 === "function") {
|
|
322
|
+
parent.cleanup = [cleanup2, fn];
|
|
323
|
+
} else {
|
|
324
|
+
cleanup2.push(fn);
|
|
325
|
+
}
|
|
326
|
+
return fn;
|
|
327
|
+
};
|
|
328
|
+
const read$1 = (node) => {
|
|
329
|
+
if (observer) {
|
|
330
|
+
link(node, observer);
|
|
331
|
+
if (node.type === COMPUTED) {
|
|
332
|
+
let height = node.height;
|
|
333
|
+
if (height >= observer.height) {
|
|
334
|
+
observer.height = height + 1;
|
|
335
|
+
}
|
|
336
|
+
if (height >= heap_i || node.state & STATE_NOTIFY_MASK) {
|
|
337
|
+
if (!notified) {
|
|
338
|
+
notified = true;
|
|
339
|
+
for (let i = 0; i <= heap_n; i++) {
|
|
340
|
+
for (let computed2 = heap[i]; computed2 !== void 0; computed2 = computed2.nextHeap) {
|
|
341
|
+
notify(computed2);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
update(node);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return node.value;
|
|
350
|
+
};
|
|
351
|
+
const root = (fn) => {
|
|
352
|
+
let c, d = root.disposables, o = observer, s = scope, self = null, tracking = fn.length, value;
|
|
353
|
+
observer = null;
|
|
354
|
+
root.disposables = 0;
|
|
355
|
+
if (tracking) {
|
|
356
|
+
scope = self = { cleanup: null };
|
|
357
|
+
value = fn(c = () => dispose$1(self));
|
|
358
|
+
} else {
|
|
359
|
+
scope = null;
|
|
360
|
+
value = fn();
|
|
361
|
+
}
|
|
362
|
+
observer = o;
|
|
363
|
+
root.disposables = d;
|
|
364
|
+
scope = s;
|
|
365
|
+
if (c) {
|
|
366
|
+
onCleanup(c);
|
|
367
|
+
}
|
|
368
|
+
return value;
|
|
369
|
+
};
|
|
370
|
+
root.disposables = 0;
|
|
371
|
+
const signal = (value) => {
|
|
372
|
+
return {
|
|
373
|
+
subs: null,
|
|
374
|
+
subsTail: null,
|
|
375
|
+
type: SIGNAL,
|
|
376
|
+
value
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
const write = (signal2, value) => {
|
|
380
|
+
if (signal2.value === value) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
notified = false;
|
|
384
|
+
signal2.value = value;
|
|
385
|
+
if (signal2.subs === null) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
for (let link2 = signal2.subs; link2; link2 = link2.nextSub) {
|
|
389
|
+
insertIntoHeap(link2.sub);
|
|
390
|
+
}
|
|
391
|
+
schedule$1();
|
|
392
|
+
};
|
|
393
|
+
class ReactiveObject {
|
|
394
|
+
disposers = null;
|
|
395
|
+
constructor(data) {
|
|
396
|
+
if (data == null) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
for (let key in data) {
|
|
400
|
+
let value = data[key], type = typeof value;
|
|
401
|
+
if (type === "function") {
|
|
402
|
+
let node2 = this[COMPUTED](value);
|
|
403
|
+
defineProperty(this, key, {
|
|
404
|
+
enumerable: true,
|
|
405
|
+
get: () => read$1(node2)
|
|
406
|
+
});
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (value == null || type !== "object") ;
|
|
410
|
+
else if (isArray(value)) {
|
|
411
|
+
defineProperty(this, key, {
|
|
412
|
+
enumerable: true,
|
|
413
|
+
value: this[REACTIVE_ARRAY](value)
|
|
414
|
+
});
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
let node = signal(value);
|
|
418
|
+
defineProperty(this, key, {
|
|
419
|
+
enumerable: true,
|
|
420
|
+
get() {
|
|
421
|
+
return read$1(node);
|
|
422
|
+
},
|
|
423
|
+
set(v) {
|
|
424
|
+
write(node, v);
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
[REACTIVE_ARRAY](value) {
|
|
430
|
+
let node = new ReactiveArray(...value);
|
|
431
|
+
(this.disposers ??= []).push(() => node.dispose());
|
|
432
|
+
return node;
|
|
433
|
+
}
|
|
434
|
+
[COMPUTED](value) {
|
|
435
|
+
return root(() => {
|
|
436
|
+
let node = computed(value);
|
|
437
|
+
if (isPromise(node.value)) {
|
|
438
|
+
let factory2 = node, version2 = 0;
|
|
439
|
+
node = signal(void 0);
|
|
440
|
+
(this.disposers ??= []).push(effect(() => {
|
|
441
|
+
let id = ++version2;
|
|
442
|
+
read$1(factory2).then((v) => {
|
|
443
|
+
if (id !== version2) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
write(node, v);
|
|
447
|
+
});
|
|
448
|
+
}));
|
|
449
|
+
} else {
|
|
450
|
+
(this.disposers ??= []).push(() => dispose$1(node));
|
|
451
|
+
}
|
|
452
|
+
return node;
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
[SIGNAL](value) {
|
|
456
|
+
return signal(value);
|
|
457
|
+
}
|
|
458
|
+
dispose() {
|
|
459
|
+
let disposers = this.disposers, disposer;
|
|
460
|
+
if (!disposers) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
while (disposer = disposers.pop()) {
|
|
464
|
+
disposer();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
Object.defineProperty(ReactiveObject.prototype, REACTIVE_OBJECT, { value: true });
|
|
469
|
+
const isReactiveObject = (value) => {
|
|
470
|
+
return typeof value === "object" && value !== null && value[REACTIVE_OBJECT] === true;
|
|
471
|
+
};
|
|
472
|
+
function dispose(value) {
|
|
473
|
+
if (isReactiveObject(value)) {
|
|
474
|
+
value.dispose();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
class ReactiveArray extends Array {
|
|
478
|
+
_length;
|
|
479
|
+
listeners = {};
|
|
480
|
+
constructor(...items) {
|
|
481
|
+
super(...items);
|
|
482
|
+
this._length = signal(items.length);
|
|
483
|
+
}
|
|
484
|
+
$length() {
|
|
485
|
+
return read$1(this._length);
|
|
486
|
+
}
|
|
487
|
+
$set(i, value) {
|
|
488
|
+
let prev = this[i];
|
|
489
|
+
if (prev === value) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
this[i] = value;
|
|
493
|
+
if (i >= super.length) {
|
|
494
|
+
write(this._length, i + 1);
|
|
495
|
+
}
|
|
496
|
+
this.dispatch("set", { index: i, item: value });
|
|
497
|
+
}
|
|
498
|
+
clear() {
|
|
499
|
+
this.dispose();
|
|
500
|
+
write(this._length, 0);
|
|
501
|
+
this.dispatch("clear");
|
|
502
|
+
}
|
|
503
|
+
concat(...items) {
|
|
504
|
+
let added = [];
|
|
505
|
+
for (let i = 0, n = items.length; i < n; i++) {
|
|
506
|
+
let item = items[i];
|
|
507
|
+
if (isArray(item)) {
|
|
508
|
+
for (let j = 0, o = item.length; j < o; j++) {
|
|
509
|
+
added.push(item[j]);
|
|
510
|
+
super.push(item[j]);
|
|
511
|
+
}
|
|
512
|
+
} else {
|
|
513
|
+
added.push(item);
|
|
514
|
+
super.push(item);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (added.length) {
|
|
518
|
+
write(this._length, super.length);
|
|
519
|
+
this.dispatch("concat", { items: added });
|
|
520
|
+
}
|
|
521
|
+
return this;
|
|
522
|
+
}
|
|
523
|
+
dispatch(event, value) {
|
|
524
|
+
let listeners = this.listeners[event];
|
|
525
|
+
if (!listeners) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
for (let i = 0, n = listeners.length; i < n; i++) {
|
|
529
|
+
let listener = listeners[i];
|
|
530
|
+
if (listener === null) {
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
try {
|
|
534
|
+
listener(value);
|
|
535
|
+
if (listener.once !== void 0) {
|
|
536
|
+
listeners[i] = null;
|
|
537
|
+
}
|
|
538
|
+
} catch {
|
|
539
|
+
listeners[i] = null;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
while (listeners.length && listeners[listeners.length - 1] === null) {
|
|
543
|
+
listeners.pop();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
dispose() {
|
|
547
|
+
while (this.length) {
|
|
548
|
+
dispose(super.pop());
|
|
549
|
+
}
|
|
550
|
+
write(this._length, 0);
|
|
551
|
+
}
|
|
552
|
+
on(event, listener) {
|
|
553
|
+
let listeners = this.listeners[event];
|
|
554
|
+
if (listeners === void 0) {
|
|
555
|
+
this.listeners[event] = [listener];
|
|
556
|
+
} else {
|
|
557
|
+
let hole = listeners.length;
|
|
558
|
+
for (let i = 0, n = hole; i < n; i++) {
|
|
559
|
+
let l = listeners[i];
|
|
560
|
+
if (l === listener) {
|
|
561
|
+
return;
|
|
562
|
+
} else if (l === null && hole === n) {
|
|
563
|
+
hole = i;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
listeners[hole] = listener;
|
|
567
|
+
while (listeners.length && listeners[listeners.length - 1] === null) {
|
|
568
|
+
listeners.pop();
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
once(event, listener) {
|
|
573
|
+
listener.once = true;
|
|
574
|
+
this.on(event, listener);
|
|
575
|
+
}
|
|
576
|
+
pop() {
|
|
577
|
+
let item = super.pop();
|
|
578
|
+
if (item !== void 0) {
|
|
579
|
+
dispose(item);
|
|
580
|
+
write(this._length, super.length);
|
|
581
|
+
this.dispatch("pop", { item });
|
|
582
|
+
}
|
|
583
|
+
return item;
|
|
584
|
+
}
|
|
585
|
+
push(...items) {
|
|
586
|
+
if (!items.length) {
|
|
587
|
+
return super.length;
|
|
588
|
+
}
|
|
589
|
+
let length = super.push(...items);
|
|
590
|
+
write(this._length, length);
|
|
591
|
+
this.dispatch("push", { items });
|
|
592
|
+
return length;
|
|
593
|
+
}
|
|
594
|
+
reverse() {
|
|
595
|
+
super.reverse();
|
|
596
|
+
this.dispatch("reverse");
|
|
597
|
+
return this;
|
|
598
|
+
}
|
|
599
|
+
shift() {
|
|
600
|
+
let item = super.shift();
|
|
601
|
+
if (item !== void 0) {
|
|
602
|
+
dispose(item);
|
|
603
|
+
write(this._length, super.length);
|
|
604
|
+
this.dispatch("shift", { item });
|
|
605
|
+
}
|
|
606
|
+
return item;
|
|
607
|
+
}
|
|
608
|
+
sort(fn) {
|
|
609
|
+
let before = new Array(this.length);
|
|
610
|
+
for (let i = 0, n = before.length; i < n; i++) {
|
|
611
|
+
before[i] = this[i];
|
|
612
|
+
}
|
|
613
|
+
super.sort(fn);
|
|
614
|
+
let buckets = /* @__PURE__ */ new Map(), cursors = /* @__PURE__ */ new Map(), order = new Array(this.length);
|
|
615
|
+
for (let i = 0, n = before.length; i < n; i++) {
|
|
616
|
+
let value = before[i], list2 = buckets.get(value);
|
|
617
|
+
if (!list2) {
|
|
618
|
+
buckets.set(value, [i]);
|
|
619
|
+
} else {
|
|
620
|
+
list2.push(i);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
for (let i = 0, n = this.length; i < n; i++) {
|
|
624
|
+
let value = this[i], list2 = buckets.get(value);
|
|
625
|
+
if (!list2) {
|
|
626
|
+
order[i] = i;
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
let cursor = cursors.get(value) || 0;
|
|
630
|
+
order[i] = list2[cursor];
|
|
631
|
+
cursors.set(value, cursor + 1);
|
|
632
|
+
}
|
|
633
|
+
this.dispatch("sort", { order });
|
|
634
|
+
return this;
|
|
635
|
+
}
|
|
636
|
+
splice(start, deleteCount = this.length, ...items) {
|
|
637
|
+
let removed = super.splice(start, deleteCount, ...items);
|
|
638
|
+
if (items.length > 0 || removed.length > 0) {
|
|
639
|
+
write(this._length, super.length);
|
|
640
|
+
for (let i = 0, n = removed.length; i < n; i++) {
|
|
641
|
+
dispose(removed[i]);
|
|
642
|
+
}
|
|
643
|
+
this.dispatch("splice", { deleteCount, items, start });
|
|
644
|
+
}
|
|
645
|
+
return removed;
|
|
646
|
+
}
|
|
647
|
+
unshift(...items) {
|
|
648
|
+
let length = super.unshift(...items);
|
|
649
|
+
write(this._length, length);
|
|
650
|
+
this.dispatch("unshift", { items });
|
|
651
|
+
return length;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
Object.defineProperty(ReactiveArray.prototype, REACTIVE_ARRAY, { value: true });
|
|
655
|
+
function reactive$1(input) {
|
|
656
|
+
let dispose2 = false, value = root(() => {
|
|
657
|
+
let response;
|
|
658
|
+
if (isObject(input)) {
|
|
659
|
+
response = new ReactiveObject(input);
|
|
660
|
+
} else if (isArray(input)) {
|
|
661
|
+
response = new ReactiveArray(...input);
|
|
662
|
+
}
|
|
663
|
+
if (response) {
|
|
664
|
+
if (root.disposables) {
|
|
665
|
+
dispose2 = true;
|
|
666
|
+
}
|
|
667
|
+
return response;
|
|
668
|
+
}
|
|
669
|
+
throw new Error(`${PACKAGE_NAME}: 'reactive' received invalid input - ${JSON.stringify(input)}`);
|
|
670
|
+
});
|
|
671
|
+
if (dispose2) {
|
|
672
|
+
onCleanup(() => value.dispose());
|
|
673
|
+
}
|
|
674
|
+
return value;
|
|
675
|
+
}
|
|
676
|
+
const ARRAY_SLOT = /* @__PURE__ */ Symbol("template.array.slot");
|
|
677
|
+
const ATTRIBUTE_DELIMITERS = {
|
|
678
|
+
class: " ",
|
|
679
|
+
style: ";"
|
|
680
|
+
};
|
|
681
|
+
const CLEANUP = /* @__PURE__ */ Symbol("template.cleanup");
|
|
682
|
+
const SLOT_HTML = "<!--$-->";
|
|
683
|
+
const STATE_HYDRATING = 0;
|
|
684
|
+
const STATE_NONE = 1;
|
|
685
|
+
const STATE_WAITING = 2;
|
|
686
|
+
const STORE = /* @__PURE__ */ Symbol("template.store");
|
|
687
|
+
let tmpl = document.createElement("template"), txt = document.createTextNode("");
|
|
688
|
+
const clone = typeof navigator !== "undefined" && navigator.userAgent.includes("Firefox") ? document.importNode.bind(document) : (node, deep = true) => node.cloneNode(deep);
|
|
689
|
+
const fragment = (html2) => {
|
|
690
|
+
let element = tmpl.cloneNode();
|
|
691
|
+
element.innerHTML = html2;
|
|
692
|
+
return element.content;
|
|
693
|
+
};
|
|
694
|
+
const marker = fragment(SLOT_HTML).firstChild;
|
|
695
|
+
const raf = globalThis?.requestAnimationFrame;
|
|
696
|
+
const template = (html2) => {
|
|
697
|
+
let cached;
|
|
698
|
+
return () => {
|
|
699
|
+
if (!cached) {
|
|
700
|
+
let element = tmpl.cloneNode();
|
|
701
|
+
element.innerHTML = html2;
|
|
702
|
+
cached = element.content;
|
|
703
|
+
}
|
|
704
|
+
return clone(cached, true);
|
|
705
|
+
};
|
|
706
|
+
};
|
|
707
|
+
const text = (value) => {
|
|
708
|
+
let element = txt.cloneNode();
|
|
709
|
+
if (value !== "") {
|
|
710
|
+
element.nodeValue = value;
|
|
711
|
+
}
|
|
712
|
+
return element;
|
|
713
|
+
};
|
|
714
|
+
const ondisconnect$1 = (element, fn) => {
|
|
715
|
+
(element[CLEANUP] ??= []).push(fn);
|
|
716
|
+
};
|
|
717
|
+
const remove = (...groups) => {
|
|
718
|
+
for (let i = 0, n = groups.length; i < n; i++) {
|
|
719
|
+
let fns, fn, group = groups[i], head = group.head, next, tail = group.tail || head;
|
|
720
|
+
while (tail) {
|
|
721
|
+
if (fns = tail[CLEANUP]) {
|
|
722
|
+
while (fn = fns.pop()) {
|
|
723
|
+
fn();
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
next = tail.previousSibling;
|
|
727
|
+
tail.remove();
|
|
728
|
+
if (head === tail) {
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
tail = next;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
const EMPTY_FRAGMENT$1 = fragment("");
|
|
736
|
+
function render(anchor, value) {
|
|
737
|
+
if (value == null || value === false || value === "") {
|
|
738
|
+
return EMPTY_FRAGMENT$1;
|
|
739
|
+
}
|
|
740
|
+
if (typeof value !== "object") {
|
|
741
|
+
return text(value);
|
|
742
|
+
}
|
|
743
|
+
if (value[ARRAY_SLOT] === true) {
|
|
744
|
+
return value.fragment;
|
|
745
|
+
}
|
|
746
|
+
if (value.nodeType !== void 0) {
|
|
747
|
+
return value;
|
|
748
|
+
}
|
|
749
|
+
let n = value.length;
|
|
750
|
+
if (typeof n === "number") {
|
|
751
|
+
if (n === 0) {
|
|
752
|
+
return EMPTY_FRAGMENT$1;
|
|
753
|
+
} else if (n === 1) {
|
|
754
|
+
return render(anchor, value[0]);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (isArray(value)) {
|
|
758
|
+
let fragment2 = clone(EMPTY_FRAGMENT$1);
|
|
759
|
+
for (let i = 0; i < n; i++) {
|
|
760
|
+
fragment2.append(render(anchor, value[i]));
|
|
761
|
+
anchor = fragment2.lastChild;
|
|
762
|
+
}
|
|
763
|
+
return fragment2;
|
|
764
|
+
}
|
|
765
|
+
if (value instanceof NodeList) {
|
|
766
|
+
let fragment2 = clone(EMPTY_FRAGMENT$1);
|
|
767
|
+
for (let i = 0; i < n; i++) {
|
|
768
|
+
fragment2.append(value[i]);
|
|
769
|
+
}
|
|
770
|
+
return fragment2;
|
|
771
|
+
}
|
|
772
|
+
return text(value);
|
|
773
|
+
}
|
|
774
|
+
function read(value) {
|
|
775
|
+
if (typeof value === "function") {
|
|
776
|
+
return read(value());
|
|
777
|
+
}
|
|
778
|
+
if (value == null || value === false) {
|
|
779
|
+
return "";
|
|
780
|
+
}
|
|
781
|
+
return value;
|
|
782
|
+
}
|
|
783
|
+
class EffectSlot {
|
|
784
|
+
anchor;
|
|
785
|
+
disposer;
|
|
786
|
+
group = null;
|
|
787
|
+
scheduled = false;
|
|
788
|
+
textnode = null;
|
|
789
|
+
constructor(anchor, fn) {
|
|
790
|
+
let dispose2 = fn.length ? () => this.dispose() : void 0, value;
|
|
791
|
+
this.anchor = anchor;
|
|
792
|
+
this.disposer = effect(() => {
|
|
793
|
+
value = read(fn(dispose2));
|
|
794
|
+
if (!this.disposer) {
|
|
795
|
+
this.update(value);
|
|
796
|
+
} else if (!this.scheduled) {
|
|
797
|
+
this.scheduled = true;
|
|
798
|
+
raf(() => {
|
|
799
|
+
this.scheduled = false;
|
|
800
|
+
this.update(value);
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
dispose() {
|
|
806
|
+
let { anchor, group, textnode } = this;
|
|
807
|
+
if (textnode) {
|
|
808
|
+
group = { head: anchor, tail: textnode };
|
|
809
|
+
} else if (group) {
|
|
810
|
+
group.head = anchor;
|
|
811
|
+
}
|
|
812
|
+
this.disposer();
|
|
813
|
+
if (group) {
|
|
814
|
+
remove(group);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
update(value) {
|
|
818
|
+
let { anchor, group, textnode } = this;
|
|
819
|
+
if (group) {
|
|
820
|
+
remove(group);
|
|
821
|
+
this.group = null;
|
|
822
|
+
}
|
|
823
|
+
if (typeof value !== "object") {
|
|
824
|
+
if (typeof value !== "string") {
|
|
825
|
+
value = String(value);
|
|
826
|
+
}
|
|
827
|
+
if (textnode) {
|
|
828
|
+
textnode.nodeValue = value;
|
|
829
|
+
if (!textnode.isConnected) {
|
|
830
|
+
anchor.after(textnode);
|
|
831
|
+
}
|
|
832
|
+
} else {
|
|
833
|
+
anchor.after(this.textnode = text(value));
|
|
834
|
+
}
|
|
835
|
+
} else {
|
|
836
|
+
let fragment2 = render(anchor, value), head = fragment2.firstChild;
|
|
837
|
+
if (textnode?.isConnected) {
|
|
838
|
+
remove({ head: textnode, tail: textnode });
|
|
839
|
+
}
|
|
840
|
+
if (head) {
|
|
841
|
+
this.group = {
|
|
842
|
+
head,
|
|
843
|
+
tail: fragment2.lastChild
|
|
844
|
+
};
|
|
845
|
+
anchor.after(fragment2);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
const EMPTY_FRAGMENT = fragment("");
|
|
851
|
+
class ArraySlot {
|
|
852
|
+
array;
|
|
853
|
+
marker;
|
|
854
|
+
nodes = [];
|
|
855
|
+
queue = [];
|
|
856
|
+
scheduled = false;
|
|
857
|
+
signal;
|
|
858
|
+
template;
|
|
859
|
+
fragment;
|
|
860
|
+
constructor(array, template2) {
|
|
861
|
+
this.array = array;
|
|
862
|
+
let fragment2 = this.fragment = clone(EMPTY_FRAGMENT);
|
|
863
|
+
this.marker = marker.cloneNode();
|
|
864
|
+
this.signal = signal(array.length);
|
|
865
|
+
this.template = function(data) {
|
|
866
|
+
let dispose2, frag = root((d) => {
|
|
867
|
+
dispose2 = d;
|
|
868
|
+
return template2(data);
|
|
869
|
+
}), group = {
|
|
870
|
+
head: frag.firstChild,
|
|
871
|
+
tail: frag.lastChild
|
|
872
|
+
};
|
|
873
|
+
fragment2.append(frag);
|
|
874
|
+
ondisconnect$1(group.head, dispose2);
|
|
875
|
+
return group;
|
|
876
|
+
};
|
|
877
|
+
fragment2.append(this.marker);
|
|
878
|
+
if (array.length) {
|
|
879
|
+
root(() => {
|
|
880
|
+
this.nodes = array.map(this.template);
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
array.on("clear", () => {
|
|
884
|
+
this.queue.length = 0;
|
|
885
|
+
this.schedule({ op: "clear" });
|
|
886
|
+
});
|
|
887
|
+
array.on("concat", ({ items }) => {
|
|
888
|
+
this.schedule({ items, op: "concat" });
|
|
889
|
+
});
|
|
890
|
+
array.on("pop", () => {
|
|
891
|
+
this.schedule({ op: "pop" });
|
|
892
|
+
});
|
|
893
|
+
array.on("push", ({ items }) => {
|
|
894
|
+
this.schedule({ items, op: "push" });
|
|
895
|
+
});
|
|
896
|
+
array.on("reverse", () => {
|
|
897
|
+
this.schedule({ op: "reverse" });
|
|
898
|
+
});
|
|
899
|
+
array.on("shift", () => {
|
|
900
|
+
this.schedule({ op: "shift" });
|
|
901
|
+
});
|
|
902
|
+
array.on("sort", ({ order }) => {
|
|
903
|
+
this.schedule({ op: "sort", order });
|
|
904
|
+
});
|
|
905
|
+
array.on("splice", ({ deleteCount, items, start }) => {
|
|
906
|
+
this.schedule({ deleteCount, items, op: "splice", start });
|
|
907
|
+
});
|
|
908
|
+
array.on("unshift", ({ items }) => {
|
|
909
|
+
this.schedule({ items, op: "unshift" });
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
anchor(index = this.nodes.length - 1) {
|
|
913
|
+
let node = this.nodes[index];
|
|
914
|
+
if (node) {
|
|
915
|
+
return node.tail || node.head;
|
|
916
|
+
}
|
|
917
|
+
return this.marker;
|
|
918
|
+
}
|
|
919
|
+
clear() {
|
|
920
|
+
remove(...this.nodes.splice(0));
|
|
921
|
+
}
|
|
922
|
+
pop() {
|
|
923
|
+
let group = this.nodes.pop();
|
|
924
|
+
if (group) {
|
|
925
|
+
remove(group);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
push(items) {
|
|
929
|
+
let anchor = this.anchor();
|
|
930
|
+
this.nodes.push(...items.map(this.template));
|
|
931
|
+
anchor.after(this.fragment);
|
|
932
|
+
}
|
|
933
|
+
schedule(op) {
|
|
934
|
+
this.queue.push(op);
|
|
935
|
+
if (this.scheduled) {
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
this.scheduled = true;
|
|
939
|
+
raf(() => {
|
|
940
|
+
let queue2 = this.queue;
|
|
941
|
+
this.queue = [];
|
|
942
|
+
this.scheduled = false;
|
|
943
|
+
root(() => {
|
|
944
|
+
for (let i = 0, n = queue2.length; i < n; i++) {
|
|
945
|
+
let op2 = queue2[i];
|
|
946
|
+
switch (op2.op) {
|
|
947
|
+
case "clear":
|
|
948
|
+
this.clear();
|
|
949
|
+
break;
|
|
950
|
+
case "concat":
|
|
951
|
+
this.push(op2.items);
|
|
952
|
+
break;
|
|
953
|
+
case "pop":
|
|
954
|
+
this.pop();
|
|
955
|
+
break;
|
|
956
|
+
case "push":
|
|
957
|
+
this.push(op2.items);
|
|
958
|
+
break;
|
|
959
|
+
case "reverse":
|
|
960
|
+
this.nodes.reverse();
|
|
961
|
+
this.sync();
|
|
962
|
+
break;
|
|
963
|
+
case "shift":
|
|
964
|
+
this.shift();
|
|
965
|
+
break;
|
|
966
|
+
case "sort":
|
|
967
|
+
this.sort(op2.order);
|
|
968
|
+
break;
|
|
969
|
+
case "splice":
|
|
970
|
+
this.splice(op2.start, op2.deleteCount, op2.items);
|
|
971
|
+
break;
|
|
972
|
+
case "unshift":
|
|
973
|
+
this.unshift(op2.items);
|
|
974
|
+
break;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
write(this.signal, this.nodes.length);
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
shift() {
|
|
982
|
+
let group = this.nodes.shift();
|
|
983
|
+
if (group) {
|
|
984
|
+
remove(group);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
sort(order) {
|
|
988
|
+
let nodes = this.nodes, n = nodes.length;
|
|
989
|
+
if (n !== order.length) {
|
|
990
|
+
remove(...nodes.splice(0));
|
|
991
|
+
this.nodes = this.array.map(this.template);
|
|
992
|
+
this.marker.after(this.fragment);
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
let sorted = new Array(n);
|
|
996
|
+
for (let i = 0; i < n; i++) {
|
|
997
|
+
sorted[i] = nodes[order[i]];
|
|
998
|
+
}
|
|
999
|
+
this.nodes = sorted;
|
|
1000
|
+
this.sync();
|
|
1001
|
+
}
|
|
1002
|
+
splice(start, stop = this.nodes.length, items) {
|
|
1003
|
+
if (!items.length) {
|
|
1004
|
+
remove(...this.nodes.splice(start, stop));
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
remove(...this.nodes.splice(start, stop, ...items.map(this.template)));
|
|
1008
|
+
this.anchor(start - 1).after(this.fragment);
|
|
1009
|
+
}
|
|
1010
|
+
sync() {
|
|
1011
|
+
let nodes = this.nodes, n = nodes.length;
|
|
1012
|
+
if (!n) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
for (let i = 0; i < n; i++) {
|
|
1016
|
+
let group = nodes[i], next, node = group.head;
|
|
1017
|
+
while (node) {
|
|
1018
|
+
next = node === group.tail ? null : node.nextSibling;
|
|
1019
|
+
this.fragment.append(node);
|
|
1020
|
+
node = next;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
this.marker.after(this.fragment);
|
|
1024
|
+
}
|
|
1025
|
+
unshift(items) {
|
|
1026
|
+
this.nodes.unshift(...items.map(this.template));
|
|
1027
|
+
this.marker.after(this.fragment);
|
|
1028
|
+
}
|
|
1029
|
+
get length() {
|
|
1030
|
+
return read$1(this.signal);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
Object.defineProperty(ArraySlot.prototype, ARRAY_SLOT, { value: true });
|
|
1034
|
+
const slot = (anchor, renderable) => {
|
|
1035
|
+
if (typeof renderable === "function") {
|
|
1036
|
+
new EffectSlot(anchor, renderable);
|
|
1037
|
+
} else {
|
|
1038
|
+
anchor.after(render(anchor, renderable));
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
Object.assign(/* @__PURE__ */ new Set(), { running: false });
|
|
1042
|
+
let controllers = /* @__PURE__ */ new Map(), host = window.document, keys = {}, passive = /* @__PURE__ */ new Set([
|
|
1043
|
+
"animationend",
|
|
1044
|
+
"animationiteration",
|
|
1045
|
+
"animationstart",
|
|
1046
|
+
"mousedown",
|
|
1047
|
+
"mouseenter",
|
|
1048
|
+
"mouseleave",
|
|
1049
|
+
"mousemove",
|
|
1050
|
+
"mouseout",
|
|
1051
|
+
"mouseover",
|
|
1052
|
+
"mouseup",
|
|
1053
|
+
"mousewheel",
|
|
1054
|
+
"pointerenter",
|
|
1055
|
+
"pointerleave",
|
|
1056
|
+
"pointermove",
|
|
1057
|
+
"pointerout",
|
|
1058
|
+
"pointerover",
|
|
1059
|
+
"scroll",
|
|
1060
|
+
"touchcancel",
|
|
1061
|
+
"touchend",
|
|
1062
|
+
"touchleave",
|
|
1063
|
+
"touchmove",
|
|
1064
|
+
"touchstart",
|
|
1065
|
+
"transitionend",
|
|
1066
|
+
"wheel"
|
|
1067
|
+
]);
|
|
1068
|
+
["mousemove", "mousewheel", "scroll", "touchend", "touchmove", "touchstart", "wheel"].map((event) => {
|
|
1069
|
+
controllers.set(event, null);
|
|
1070
|
+
});
|
|
1071
|
+
function register(element, event) {
|
|
1072
|
+
let controller = controllers.get(event), signal2;
|
|
1073
|
+
if (controller === null) {
|
|
1074
|
+
let { abort, signal: signal3 } = new AbortController();
|
|
1075
|
+
controllers.set(event, controller = {
|
|
1076
|
+
abort,
|
|
1077
|
+
signal: signal3,
|
|
1078
|
+
listeners: 0
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
if (controller) {
|
|
1082
|
+
controller.listeners++;
|
|
1083
|
+
ondisconnect(element, () => {
|
|
1084
|
+
if (--controller.listeners) {
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
controller.abort();
|
|
1088
|
+
controllers.set(event, null);
|
|
1089
|
+
});
|
|
1090
|
+
signal2 = controller.signal;
|
|
1091
|
+
}
|
|
1092
|
+
let key = keys[event] = /* @__PURE__ */ Symbol();
|
|
1093
|
+
host.addEventListener(event, (e) => {
|
|
1094
|
+
let fn, node = e.target;
|
|
1095
|
+
while (node) {
|
|
1096
|
+
fn = node[key];
|
|
1097
|
+
if (typeof fn === "function") {
|
|
1098
|
+
defineProperty(e, "currentTarget", {
|
|
1099
|
+
configurable: true,
|
|
1100
|
+
get() {
|
|
1101
|
+
return node || window.document;
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
return fn.call(node, e);
|
|
1105
|
+
}
|
|
1106
|
+
node = node.parentElement;
|
|
1107
|
+
}
|
|
1108
|
+
}, {
|
|
1109
|
+
passive: passive.has(event),
|
|
1110
|
+
signal: signal2
|
|
1111
|
+
});
|
|
1112
|
+
return key;
|
|
1113
|
+
}
|
|
1114
|
+
const delegate = (element, event, listener) => {
|
|
1115
|
+
element[keys[event] || register(element, event)] = listener;
|
|
1116
|
+
};
|
|
1117
|
+
const ondisconnect = (element, listener) => {
|
|
1118
|
+
ondisconnect$1(element, () => listener(element));
|
|
1119
|
+
};
|
|
1120
|
+
let Node$1 = class Node2 {
|
|
1121
|
+
data;
|
|
1122
|
+
next = null;
|
|
1123
|
+
constructor(size) {
|
|
1124
|
+
this.data = new Array(size);
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
class Queue {
|
|
1128
|
+
head = null;
|
|
1129
|
+
headIndex = 0;
|
|
1130
|
+
pool = null;
|
|
1131
|
+
preallocate;
|
|
1132
|
+
size = 0;
|
|
1133
|
+
tail = null;
|
|
1134
|
+
tailIndex = 0;
|
|
1135
|
+
constructor(preallocate) {
|
|
1136
|
+
this.preallocate = preallocate;
|
|
1137
|
+
}
|
|
1138
|
+
allocate() {
|
|
1139
|
+
let node = this.pool;
|
|
1140
|
+
if (node) {
|
|
1141
|
+
this.pool = node.next;
|
|
1142
|
+
node.next = null;
|
|
1143
|
+
return node;
|
|
1144
|
+
}
|
|
1145
|
+
return new Node$1(this.preallocate);
|
|
1146
|
+
}
|
|
1147
|
+
release(node) {
|
|
1148
|
+
node.next = this.pool;
|
|
1149
|
+
this.pool = node;
|
|
1150
|
+
}
|
|
1151
|
+
get length() {
|
|
1152
|
+
return this.size;
|
|
1153
|
+
}
|
|
1154
|
+
add(value) {
|
|
1155
|
+
let preallocate = this.preallocate, size = this.size, tail = this.tail, tailIndex = this.tailIndex;
|
|
1156
|
+
if (tail === null) {
|
|
1157
|
+
tail = this.head = this.tail = this.allocate();
|
|
1158
|
+
tailIndex = 0;
|
|
1159
|
+
} else if (size === 0) {
|
|
1160
|
+
tailIndex = 0;
|
|
1161
|
+
this.headIndex = 0;
|
|
1162
|
+
} else if (tailIndex === preallocate) {
|
|
1163
|
+
tail = tail.next = this.allocate();
|
|
1164
|
+
tailIndex = 0;
|
|
1165
|
+
this.tail = tail;
|
|
1166
|
+
}
|
|
1167
|
+
tail.data[tailIndex] = value;
|
|
1168
|
+
this.tailIndex = tailIndex + 1;
|
|
1169
|
+
this.size = size + 1;
|
|
1170
|
+
}
|
|
1171
|
+
clear() {
|
|
1172
|
+
let head = this.head;
|
|
1173
|
+
while (head !== null) {
|
|
1174
|
+
let next = head.next;
|
|
1175
|
+
this.release(head);
|
|
1176
|
+
head = next;
|
|
1177
|
+
}
|
|
1178
|
+
this.head = null;
|
|
1179
|
+
this.headIndex = 0;
|
|
1180
|
+
this.size = 0;
|
|
1181
|
+
this.tail = null;
|
|
1182
|
+
this.tailIndex = 0;
|
|
1183
|
+
}
|
|
1184
|
+
next() {
|
|
1185
|
+
let size = this.size;
|
|
1186
|
+
if (size === 0) {
|
|
1187
|
+
return void 0;
|
|
1188
|
+
}
|
|
1189
|
+
let head = this.head, headIndex = this.headIndex, preallocate = this.preallocate, value = head.data[headIndex];
|
|
1190
|
+
head.data[headIndex] = void 0;
|
|
1191
|
+
headIndex++;
|
|
1192
|
+
size--;
|
|
1193
|
+
if (headIndex === preallocate) {
|
|
1194
|
+
let next = head.next;
|
|
1195
|
+
this.release(head);
|
|
1196
|
+
this.head = next;
|
|
1197
|
+
headIndex = 0;
|
|
1198
|
+
if (next === null) {
|
|
1199
|
+
this.tail = null;
|
|
1200
|
+
this.tailIndex = 0;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
this.headIndex = headIndex;
|
|
1204
|
+
this.size = size;
|
|
1205
|
+
return value;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
const READY = 0;
|
|
1209
|
+
const RUNNING = 1;
|
|
1210
|
+
const SCHEDULED = 2;
|
|
1211
|
+
class Scheduler {
|
|
1212
|
+
lastRunAt = 0;
|
|
1213
|
+
queue;
|
|
1214
|
+
scheduler;
|
|
1215
|
+
state = READY;
|
|
1216
|
+
task;
|
|
1217
|
+
throttled = null;
|
|
1218
|
+
constructor(queue2, scheduler) {
|
|
1219
|
+
this.queue = queue2;
|
|
1220
|
+
this.scheduler = scheduler;
|
|
1221
|
+
this.task = () => this.run();
|
|
1222
|
+
}
|
|
1223
|
+
run() {
|
|
1224
|
+
if (this.state === RUNNING) {
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
this.state = RUNNING;
|
|
1228
|
+
let elapsed = Date.now() - this.lastRunAt, throttle = this.throttled;
|
|
1229
|
+
if (!throttle || throttle.interval <= elapsed) {
|
|
1230
|
+
let q = this.queue, n = throttle?.limit ?? q.length;
|
|
1231
|
+
for (let i = 0; i < n; i++) {
|
|
1232
|
+
let task2 = q.next();
|
|
1233
|
+
if (!task2) {
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1236
|
+
task2();
|
|
1237
|
+
}
|
|
1238
|
+
this.lastRunAt = Date.now();
|
|
1239
|
+
}
|
|
1240
|
+
this.state = READY;
|
|
1241
|
+
this.schedule();
|
|
1242
|
+
}
|
|
1243
|
+
get length() {
|
|
1244
|
+
return this.queue.length;
|
|
1245
|
+
}
|
|
1246
|
+
add(task2) {
|
|
1247
|
+
this.queue.add(task2);
|
|
1248
|
+
this.schedule();
|
|
1249
|
+
return this;
|
|
1250
|
+
}
|
|
1251
|
+
schedule() {
|
|
1252
|
+
if (this.state !== READY || !this.queue.length) {
|
|
1253
|
+
return this;
|
|
1254
|
+
}
|
|
1255
|
+
this.state = SCHEDULED;
|
|
1256
|
+
this.scheduler(this.task);
|
|
1257
|
+
return this;
|
|
1258
|
+
}
|
|
1259
|
+
throttle(limit, ms) {
|
|
1260
|
+
this.throttled = {
|
|
1261
|
+
interval: ms / limit,
|
|
1262
|
+
limit
|
|
1263
|
+
};
|
|
1264
|
+
return this;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
const api = (preallocate = 128) => {
|
|
1268
|
+
return new Queue(preallocate);
|
|
1269
|
+
};
|
|
1270
|
+
api.immediate = () => {
|
|
1271
|
+
let { port1, port2 } = new MessageChannel();
|
|
1272
|
+
return new Scheduler(api(), (task2) => {
|
|
1273
|
+
if (port1.onmessage !== task2) {
|
|
1274
|
+
port1.onmessage = task2;
|
|
1275
|
+
}
|
|
1276
|
+
port2.postMessage(null);
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
api.micro = () => {
|
|
1280
|
+
let queueMicrotask2 = globalThis?.queueMicrotask;
|
|
1281
|
+
if (queueMicrotask2) {
|
|
1282
|
+
return new Scheduler(api(), (task2) => queueMicrotask2(task2));
|
|
1283
|
+
}
|
|
1284
|
+
let resolved = Promise.resolve();
|
|
1285
|
+
return new Scheduler(api(), (task2) => resolved.then(task2));
|
|
1286
|
+
};
|
|
1287
|
+
api.raf = () => {
|
|
1288
|
+
let requestAnimationFrame = globalThis?.requestAnimationFrame;
|
|
1289
|
+
if (requestAnimationFrame) {
|
|
1290
|
+
return new Scheduler(api(), (task2) => requestAnimationFrame(task2));
|
|
1291
|
+
}
|
|
1292
|
+
return new Scheduler(api(), (task2) => setTimeout(task2, 16));
|
|
1293
|
+
};
|
|
1294
|
+
let queue = api(64), scheduled = false;
|
|
1295
|
+
function apply(element, name, value) {
|
|
1296
|
+
if (value == null || value === false || value === "") {
|
|
1297
|
+
element.removeAttribute(name);
|
|
1298
|
+
} else if (name === "class") {
|
|
1299
|
+
element.className = value;
|
|
1300
|
+
} else if (name === "style" || name[0] === "d" && name.startsWith("data-") || element["ownerSVGElement"]) {
|
|
1301
|
+
element.setAttribute(name, value);
|
|
1302
|
+
} else {
|
|
1303
|
+
element[name] = value;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
function context(element) {
|
|
1307
|
+
return element[STORE] ??= { element };
|
|
1308
|
+
}
|
|
1309
|
+
function list(ctx, element, id, name, state, value) {
|
|
1310
|
+
if (value == null || value === false || value === "") {
|
|
1311
|
+
value = "";
|
|
1312
|
+
}
|
|
1313
|
+
let changed = false, delimiter = ATTRIBUTE_DELIMITERS[name], store = (ctx ??= context(element)).store ??= {}, dynamic = store[name];
|
|
1314
|
+
if (!dynamic) {
|
|
1315
|
+
store[name + ".static"] = (element.getAttribute(name) || "").trim();
|
|
1316
|
+
store[name] = dynamic = /* @__PURE__ */ new Set();
|
|
1317
|
+
}
|
|
1318
|
+
if (id === null) {
|
|
1319
|
+
if (value && typeof value === "string") {
|
|
1320
|
+
changed = true;
|
|
1321
|
+
store[name + ".static"] += (store[name + ".static"] ? delimiter : "") + value;
|
|
1322
|
+
}
|
|
1323
|
+
} else if (store[id + ".raw"] !== value) {
|
|
1324
|
+
let hot = {};
|
|
1325
|
+
if (value && typeof value === "string") {
|
|
1326
|
+
let part, parts = value.split(delimiter);
|
|
1327
|
+
while (part = parts.pop()) {
|
|
1328
|
+
part = part.trim();
|
|
1329
|
+
if (part === "") {
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (!dynamic.has(part)) {
|
|
1333
|
+
changed = true;
|
|
1334
|
+
dynamic.add(part);
|
|
1335
|
+
}
|
|
1336
|
+
hot[part] = true;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
let cold = store[id];
|
|
1340
|
+
if (cold !== void 0) {
|
|
1341
|
+
for (let part in cold) {
|
|
1342
|
+
if (hot[part] === true) {
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
changed = true;
|
|
1346
|
+
dynamic.delete(part);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
store[id + ".raw"] = value;
|
|
1350
|
+
store[id] = hot;
|
|
1351
|
+
}
|
|
1352
|
+
if (!changed) {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
value = store[name + ".static"];
|
|
1356
|
+
for (let key of dynamic) {
|
|
1357
|
+
value += (value ? delimiter : "") + key;
|
|
1358
|
+
}
|
|
1359
|
+
if (state === STATE_HYDRATING) {
|
|
1360
|
+
apply(element, name, value);
|
|
1361
|
+
} else {
|
|
1362
|
+
schedule(ctx, element, name, state, value);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
function property(ctx, element, id, name, state, value) {
|
|
1366
|
+
if (value == null || value === false || value === "") {
|
|
1367
|
+
value = "";
|
|
1368
|
+
}
|
|
1369
|
+
if (id !== null) {
|
|
1370
|
+
ctx ??= context(element);
|
|
1371
|
+
if (ctx[name] === value) {
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
ctx[name] = value;
|
|
1375
|
+
}
|
|
1376
|
+
if (state === STATE_HYDRATING) {
|
|
1377
|
+
apply(element, name, value);
|
|
1378
|
+
} else {
|
|
1379
|
+
schedule(ctx, element, name, state, value);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
function reactive(element, name, state, value) {
|
|
1383
|
+
let ctx = context(element), fn = name === "class" || name === "style" ? list : property;
|
|
1384
|
+
ctx.effect ??= 0;
|
|
1385
|
+
let id = ctx.effect++;
|
|
1386
|
+
effect(() => {
|
|
1387
|
+
let v = value(element);
|
|
1388
|
+
if (v == null || typeof v !== "object") {
|
|
1389
|
+
fn(ctx, element, id, name, state, v);
|
|
1390
|
+
} else if (isArray(v)) {
|
|
1391
|
+
let last = v.length - 1;
|
|
1392
|
+
for (let i = 0, n = v.length; i < n; i++) {
|
|
1393
|
+
fn(ctx, element, id, name, state === STATE_HYDRATING ? state : i !== last ? STATE_WAITING : state, v[i]);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
state = STATE_NONE;
|
|
1398
|
+
}
|
|
1399
|
+
function schedule(ctx, element, name, state, value) {
|
|
1400
|
+
ctx ??= context(element);
|
|
1401
|
+
(ctx.updates ??= {})[name] = value;
|
|
1402
|
+
if (state === STATE_NONE && !ctx.updating) {
|
|
1403
|
+
ctx.updating = true;
|
|
1404
|
+
queue.add(ctx);
|
|
1405
|
+
}
|
|
1406
|
+
if (scheduled) {
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
scheduled = true;
|
|
1410
|
+
raf(task);
|
|
1411
|
+
}
|
|
1412
|
+
function task() {
|
|
1413
|
+
let context2, n = queue.length;
|
|
1414
|
+
while ((context2 = queue.next()) && n--) {
|
|
1415
|
+
let { element, updates } = context2;
|
|
1416
|
+
for (let name in updates) {
|
|
1417
|
+
apply(element, name, updates[name]);
|
|
1418
|
+
}
|
|
1419
|
+
context2.updates = {};
|
|
1420
|
+
context2.updating = false;
|
|
1421
|
+
}
|
|
1422
|
+
if (queue.length) {
|
|
1423
|
+
raf(task);
|
|
1424
|
+
} else {
|
|
1425
|
+
scheduled = false;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
const setList = (element, name, value, attributes = {}) => {
|
|
1429
|
+
let ctx = context(element), store = ctx.store ??= {};
|
|
1430
|
+
store[name] ??= /* @__PURE__ */ new Set();
|
|
1431
|
+
store[name + ".static"] ??= "";
|
|
1432
|
+
store[name + ".static"] += `${attributes[name] && store[name + ".static"] ? ATTRIBUTE_DELIMITERS[name] : ""}${attributes[name]}`;
|
|
1433
|
+
if (typeof value === "function") {
|
|
1434
|
+
reactive(element, name, STATE_HYDRATING, value);
|
|
1435
|
+
} else if (typeof value !== "object") {
|
|
1436
|
+
list(ctx, element, null, name, STATE_HYDRATING, value);
|
|
1437
|
+
} else if (isArray(value)) {
|
|
1438
|
+
for (let i = 0, n = value.length; i < n; i++) {
|
|
1439
|
+
let v = value[i];
|
|
1440
|
+
if (v == null || v === false || v === "") {
|
|
1441
|
+
continue;
|
|
1442
|
+
}
|
|
1443
|
+
list(ctx, element, null, name, STATE_HYDRATING, v);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
};
|
|
1447
|
+
const setProperty = (element, name, value) => {
|
|
1448
|
+
if (typeof value === "function") {
|
|
1449
|
+
reactive(element, name, STATE_HYDRATING, value);
|
|
1450
|
+
} else {
|
|
1451
|
+
property(null, element, null, name, STATE_HYDRATING, value);
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
const html = (_literals, ..._values) => {
|
|
1455
|
+
throw new Error("html`` templates must be compiled. Ensure vite-plugin is configured.");
|
|
1456
|
+
};
|
|
1457
|
+
html.reactive = (_arr, _template) => {
|
|
1458
|
+
throw new Error("html.reactive() must be compiled. Ensure vite-plugin is configured.");
|
|
1459
|
+
};
|
|
1460
|
+
let factory = template("<svg><use /></svg>");
|
|
1461
|
+
const svg = html.bind(null);
|
|
1462
|
+
svg.sprite = (href) => {
|
|
1463
|
+
if (href[0] !== "#") {
|
|
1464
|
+
href = "#" + href;
|
|
1465
|
+
}
|
|
1466
|
+
let root2 = factory();
|
|
1467
|
+
setProperty(root2.firstChild.firstChild, "href", href);
|
|
1468
|
+
return root2;
|
|
1469
|
+
};
|
|
1470
|
+
if (typeof Node !== "undefined") {
|
|
1471
|
+
Node.prototype[CLEANUP] = null;
|
|
1472
|
+
Node.prototype[STORE] = null;
|
|
1473
|
+
}
|
|
1474
|
+
const template_77447a9a695040d8bcd63a98c06d66fc3 = template(`<div class="counter"><span class="count"><!--$--></span><span class="enabled"><!--$--></span><span class="message"><!--$--></span><span class="price"><!--$--></span></div>`);
|
|
1475
|
+
const template_77447a9a695040d8bcd63a98c06d66fc9 = template(`<li><!--$--></li>`);
|
|
1476
|
+
const template_77447a9a695040d8bcd63a98c06d66fcc = template(`<div class="computed"><h1><!--$--></h1><p>Items: <!--$--></p><p>Total: <!--$--></p><ul><!--$--></ul></div>`);
|
|
1477
|
+
const template_77447a9a695040d8bcd63a98c06d66fci = template(`<span class="num"><!--$--></span>`);
|
|
1478
|
+
const template_77447a9a695040d8bcd63a98c06d66fcl = template(`<span class="str"><!--$--></span>`);
|
|
1479
|
+
const template_77447a9a695040d8bcd63a98c06d66fco = template(`<span class="mix"><!--$--></span>`);
|
|
1480
|
+
const template_77447a9a695040d8bcd63a98c06d66fcr = template(`<div class="arrays"><section><h2>Numbers</h2><!--$--></section><section><h2>Strings</h2><!--$--></section><section><h2>Mixed</h2><!--$--></section></div>`);
|
|
1481
|
+
const template_77447a9a695040d8bcd63a98c06d66fcw = template(`<div class="objects"><section class="user"><h2><!--$--></h2><p>Age: <!--$--></p><p>Email: <!--$--></p></section><section class="product"><p>Price: $<!--$--></p><p>Discount: <!--$-->%</p><p>Final: $<!--$--></p></section><section class="config"><p>Theme: <!--$--></p><p>Debug: <!--$--></p></section></div>`);
|
|
1482
|
+
const template_77447a9a695040d8bcd63a98c06d66fc16 = template(`<div class="item "><span><!--$--></span><input type="checkbox" checked= /></div>`);
|
|
1483
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1c = template(`<button> Count <!--$-->: <!--$--></button>`);
|
|
1484
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1h = template(`<div class="complex"><header><span>Total: <!--$--></span><span>Selected: <!--$--></span></header><main><!--$--></main><footer><!--$--></footer></div>`);
|
|
1485
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1m = template(`<details>Expanded content</details>`);
|
|
1486
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1n = template(`<summary>Click to expand</summary>`);
|
|
1487
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1o = template(`<div class="loading">Loading...</div>`);
|
|
1488
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1p = template(`<div class="error">Error occurred</div>`);
|
|
1489
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1q = template(`<div class="success">Success!</div>`);
|
|
1490
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1s = template(`<span>Welcome, <!--$--></span>`);
|
|
1491
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1u = template(`<span>Please log in</span>`);
|
|
1492
|
+
const template_77447a9a695040d8bcd63a98c06d66fc1w = template(`<div class="conditional"><!--$--><!--$--><!--$--></div>`);
|
|
1493
|
+
const template_77447a9a695040d8bcd63a98c06d66fc21 = template(`<li><!--$--><button>Remove</button></li>`);
|
|
1494
|
+
const template_77447a9a695040d8bcd63a98c06d66fc25 = template(`<div class="events"><button> Clicked <!--$--> times </button><input type="text" value= /><button> Add Item </button><ul><!--$--></ul></div>`);
|
|
1495
|
+
const template_77447a9a695040d8bcd63a98c06d66fc2c = template(`<div class="attributes"><button class= disabled= data-value= style=> Dynamic Button </button><a href= target="_blank">Dynamic Link</a><input type="text" class= placeholder= /></div>`);
|
|
1496
|
+
const template_77447a9a695040d8bcd63a98c06d66fc2j = template(`<span><!--$--></span>`);
|
|
1497
|
+
const template_77447a9a695040d8bcd63a98c06d66fc2m = template(`<div class="mixed"><section><h3>Primitive: <!--$--></h3><h3>Computed: <!--$--></h3></section><section><h3>Object Name: <!--$--></h3><h3>Object Count: <!--$--></h3><h3>Object Double: <!--$--></h3></section><section><h3>Array Length: <!--$--></h3><!--$--></section><section><button> Increment All </button></section></div>`);
|
|
1498
|
+
const template_77447a9a695040d8bcd63a98c06d66fc2w = template(`<div class="todo "><input type="checkbox" checked= /><span><!--$--></span></div>`);
|
|
1499
|
+
const template_77447a9a695040d8bcd63a98c06d66fc32 = template(`<div class="todo-app"><header><h1>Todos (<!--$--> completed)</h1><nav><button class=>All</button><button class=>Active</button><button class=>Completed</button></nav></header><main><!--$--></main></div>`);
|
|
1500
|
+
const template_77447a9a695040d8bcd63a98c06d66fc3c = template(`<div class="leaf"><span><!--$-->: <!--$--></span><button>+</button></div>`);
|
|
1501
|
+
const template_77447a9a695040d8bcd63a98c06d66fc3h = template(`<div class="branch"><h2><!--$--></h2><!--$--></div>`);
|
|
1502
|
+
const template_77447a9a695040d8bcd63a98c06d66fc3l = template(`<div class="tree"><h1><!--$--></h1><!--$--></div>`);
|
|
1503
|
+
const template_77447a9a695040d8bcd63a98c06d66fc3p = template(`<div class="static-dynamic"><p>Static text here</p><p><!--$--> text here</p><span>Static number: 100</span><span>Dynamic number: <!--$--></span><div class="static-class">Static class</div><div>Dynamic class</div><a href="https://static.com">Static link</a><a href=>Dynamic link</a><input type="text" value="static" /><input type="text" value= /></div>`);
|
|
1504
|
+
function testPrimitiveSignals() {
|
|
1505
|
+
let count = reactive$1(0), enabled = reactive$1(true), message = reactive$1("Hello"), price = reactive$1(19.99);
|
|
1506
|
+
let view = (() => {
|
|
1507
|
+
let root_77447a9a695040d8bcd63a98c06d66fc2 = template_77447a9a695040d8bcd63a98c06d66fc3(), element_77447a9a695040d8bcd63a98c06d66fc4 = root_77447a9a695040d8bcd63a98c06d66fc2.firstChild.firstElementChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fc5 = root_77447a9a695040d8bcd63a98c06d66fc2.firstChild.firstElementChild.nextElementSibling.firstChild, element_77447a9a695040d8bcd63a98c06d66fc6 = root_77447a9a695040d8bcd63a98c06d66fc2.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstChild, element_77447a9a695040d8bcd63a98c06d66fc7 = root_77447a9a695040d8bcd63a98c06d66fc2.firstChild.firstElementChild.nextElementSibling.nextElementSibling.nextElementSibling.firstChild;
|
|
1508
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc4, count);
|
|
1509
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc5, enabled);
|
|
1510
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc6, message);
|
|
1511
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc7, price);
|
|
1512
|
+
return root_77447a9a695040d8bcd63a98c06d66fc2;
|
|
1513
|
+
})();
|
|
1514
|
+
count++;
|
|
1515
|
+
count--;
|
|
1516
|
+
count += 5;
|
|
1517
|
+
count -= 2;
|
|
1518
|
+
count *= 2;
|
|
1519
|
+
enabled = !enabled;
|
|
1520
|
+
message = message + " World";
|
|
1521
|
+
return { count, enabled, message, price, view };
|
|
1522
|
+
}
|
|
1523
|
+
function testComputedValues() {
|
|
1524
|
+
let firstName = reactive$1("John"), lastName = reactive$1("Doe"), items = reactive$1([1, 2, 3, 4, 5]);
|
|
1525
|
+
let fullName = reactive$1(() => `${firstName} ${lastName}`), itemCount = reactive$1(() => items.length), doubled = reactive$1(() => items.map((x) => x * 2)), total = reactive$1(() => items.reduce((a, b) => a + b, 0));
|
|
1526
|
+
let view = (() => {
|
|
1527
|
+
let root_77447a9a695040d8bcd63a98c06d66fcb = template_77447a9a695040d8bcd63a98c06d66fcc(), element_77447a9a695040d8bcd63a98c06d66fcd = root_77447a9a695040d8bcd63a98c06d66fcb.firstChild.firstElementChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fce = root_77447a9a695040d8bcd63a98c06d66fcb.firstChild.firstElementChild.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fcf = root_77447a9a695040d8bcd63a98c06d66fcb.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fcg = root_77447a9a695040d8bcd63a98c06d66fcb.firstChild.firstElementChild.nextElementSibling.nextElementSibling.nextElementSibling.firstChild;
|
|
1528
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcd, fullName);
|
|
1529
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fce, itemCount);
|
|
1530
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcf, total);
|
|
1531
|
+
new EffectSlot(element_77447a9a695040d8bcd63a98c06d66fcg, () => doubled.map((n) => {
|
|
1532
|
+
let root_77447a9a695040d8bcd63a98c06d66fc8 = template_77447a9a695040d8bcd63a98c06d66fc9(), element_77447a9a695040d8bcd63a98c06d66fca = root_77447a9a695040d8bcd63a98c06d66fc8.firstChild.firstChild;
|
|
1533
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fca, n);
|
|
1534
|
+
return root_77447a9a695040d8bcd63a98c06d66fc8;
|
|
1535
|
+
}));
|
|
1536
|
+
return root_77447a9a695040d8bcd63a98c06d66fcb;
|
|
1537
|
+
})();
|
|
1538
|
+
firstName = "Jane";
|
|
1539
|
+
items.push(6);
|
|
1540
|
+
return { doubled, firstName, fullName, itemCount, items, lastName, total, view };
|
|
1541
|
+
}
|
|
1542
|
+
function testReactiveArrays() {
|
|
1543
|
+
let numbers = reactive$1([1, 2, 3]), strings = reactive$1(["a", "b", "c"]), mixed = reactive$1([1, "two", 3, "four"]);
|
|
1544
|
+
let view = (() => {
|
|
1545
|
+
let root_77447a9a695040d8bcd63a98c06d66fcq = template_77447a9a695040d8bcd63a98c06d66fcr(), element_77447a9a695040d8bcd63a98c06d66fcs = root_77447a9a695040d8bcd63a98c06d66fcq.firstChild.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fct = root_77447a9a695040d8bcd63a98c06d66fcq.firstChild.firstElementChild.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fcu = root_77447a9a695040d8bcd63a98c06d66fcq.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstChild.nextSibling;
|
|
1546
|
+
element_77447a9a695040d8bcd63a98c06d66fcs.parentNode.insertBefore(new ArraySlot(numbers, (n) => {
|
|
1547
|
+
let root_77447a9a695040d8bcd63a98c06d66fch = template_77447a9a695040d8bcd63a98c06d66fci(), element_77447a9a695040d8bcd63a98c06d66fcj = root_77447a9a695040d8bcd63a98c06d66fch.firstChild.firstChild;
|
|
1548
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcj, n);
|
|
1549
|
+
return root_77447a9a695040d8bcd63a98c06d66fch;
|
|
1550
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fcs);
|
|
1551
|
+
element_77447a9a695040d8bcd63a98c06d66fct.parentNode.insertBefore(new ArraySlot(strings, (s) => {
|
|
1552
|
+
let root_77447a9a695040d8bcd63a98c06d66fck = template_77447a9a695040d8bcd63a98c06d66fcl(), element_77447a9a695040d8bcd63a98c06d66fcm = root_77447a9a695040d8bcd63a98c06d66fck.firstChild.firstChild;
|
|
1553
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcm, s);
|
|
1554
|
+
return root_77447a9a695040d8bcd63a98c06d66fck;
|
|
1555
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fct);
|
|
1556
|
+
element_77447a9a695040d8bcd63a98c06d66fcu.parentNode.insertBefore(new ArraySlot(mixed, (m) => {
|
|
1557
|
+
let root_77447a9a695040d8bcd63a98c06d66fcn = template_77447a9a695040d8bcd63a98c06d66fco(), element_77447a9a695040d8bcd63a98c06d66fcp = root_77447a9a695040d8bcd63a98c06d66fcn.firstChild.firstChild;
|
|
1558
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcp, m);
|
|
1559
|
+
return root_77447a9a695040d8bcd63a98c06d66fcn;
|
|
1560
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fcu);
|
|
1561
|
+
return root_77447a9a695040d8bcd63a98c06d66fcq;
|
|
1562
|
+
})();
|
|
1563
|
+
numbers.push(4);
|
|
1564
|
+
numbers.unshift(0);
|
|
1565
|
+
numbers[2] = 99;
|
|
1566
|
+
strings.pop();
|
|
1567
|
+
strings.shift();
|
|
1568
|
+
strings.splice(0, 0, "inserted");
|
|
1569
|
+
let numLen = numbers.length, strLen = strings.length;
|
|
1570
|
+
return { mixed, numLen, numbers, strLen, strings, view };
|
|
1571
|
+
}
|
|
1572
|
+
function testReactiveObjects() {
|
|
1573
|
+
let user = reactive$1({
|
|
1574
|
+
age: 25,
|
|
1575
|
+
email: "john@example.com",
|
|
1576
|
+
name: "John"
|
|
1577
|
+
});
|
|
1578
|
+
let product = reactive$1({
|
|
1579
|
+
discount: 0.1,
|
|
1580
|
+
finalPrice: () => product.price * (1 - product.discount),
|
|
1581
|
+
price: 100
|
|
1582
|
+
});
|
|
1583
|
+
let config = reactive$1({
|
|
1584
|
+
debug: false,
|
|
1585
|
+
features: {
|
|
1586
|
+
darkMode: true,
|
|
1587
|
+
notifications: false
|
|
1588
|
+
},
|
|
1589
|
+
theme: "light"
|
|
1590
|
+
});
|
|
1591
|
+
let view = (() => {
|
|
1592
|
+
let root_77447a9a695040d8bcd63a98c06d66fcv = template_77447a9a695040d8bcd63a98c06d66fcw(), element_77447a9a695040d8bcd63a98c06d66fcx = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.firstElementChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fcy = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.firstElementChild.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fcz = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.firstElementChild.nextElementSibling.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc10 = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.nextElementSibling.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc11 = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.nextElementSibling.firstElementChild.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc12 = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.nextElementSibling.firstElementChild.nextElementSibling.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc13 = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc14 = root_77447a9a695040d8bcd63a98c06d66fcv.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstElementChild.nextElementSibling.firstChild.nextSibling;
|
|
1593
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcx, user.name);
|
|
1594
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcy, user.age);
|
|
1595
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fcz, user.email);
|
|
1596
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc10, product.price);
|
|
1597
|
+
new EffectSlot(element_77447a9a695040d8bcd63a98c06d66fc11, () => product.discount * 100);
|
|
1598
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc12, product.finalPrice);
|
|
1599
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc13, config.theme);
|
|
1600
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc14, config.debug);
|
|
1601
|
+
return root_77447a9a695040d8bcd63a98c06d66fcv;
|
|
1602
|
+
})();
|
|
1603
|
+
user.name = "Jane";
|
|
1604
|
+
user.age++;
|
|
1605
|
+
product.price = 150;
|
|
1606
|
+
product.discount = 0.2;
|
|
1607
|
+
config.theme = "dark";
|
|
1608
|
+
config.debug = true;
|
|
1609
|
+
return { config, product, user, view };
|
|
1610
|
+
}
|
|
1611
|
+
function testComplexNested() {
|
|
1612
|
+
let state = reactive$1({
|
|
1613
|
+
counts: reactive$1([0, 0, 0]),
|
|
1614
|
+
currentIndex: 0,
|
|
1615
|
+
increment: () => {
|
|
1616
|
+
state.counts[state.currentIndex]++;
|
|
1617
|
+
},
|
|
1618
|
+
items: reactive$1([
|
|
1619
|
+
{ id: 1, name: "Item 1", selected: false },
|
|
1620
|
+
{ id: 2, name: "Item 2", selected: true },
|
|
1621
|
+
{ id: 3, name: "Item 3", selected: false }
|
|
1622
|
+
]),
|
|
1623
|
+
selectedCount: () => state.items.filter((i) => i.selected).length,
|
|
1624
|
+
total: () => state.counts.reduce((a, b) => a + b, 0)
|
|
1625
|
+
});
|
|
1626
|
+
let view = (() => {
|
|
1627
|
+
let root_77447a9a695040d8bcd63a98c06d66fc1g = template_77447a9a695040d8bcd63a98c06d66fc1h(), element_77447a9a695040d8bcd63a98c06d66fc1i = root_77447a9a695040d8bcd63a98c06d66fc1g.firstChild.firstElementChild.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc1j = root_77447a9a695040d8bcd63a98c06d66fc1g.firstChild.firstElementChild.firstElementChild.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc1k = root_77447a9a695040d8bcd63a98c06d66fc1g.firstChild.firstElementChild.nextElementSibling.firstChild, element_77447a9a695040d8bcd63a98c06d66fc1l = root_77447a9a695040d8bcd63a98c06d66fc1g.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstChild;
|
|
1628
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc1i, state.total);
|
|
1629
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc1j, state.selectedCount);
|
|
1630
|
+
element_77447a9a695040d8bcd63a98c06d66fc1k.parentNode.insertBefore(new ArraySlot(state.items, (item) => {
|
|
1631
|
+
let root_77447a9a695040d8bcd63a98c06d66fc15 = template_77447a9a695040d8bcd63a98c06d66fc16(), element_77447a9a695040d8bcd63a98c06d66fc17 = root_77447a9a695040d8bcd63a98c06d66fc15.firstChild, element_77447a9a695040d8bcd63a98c06d66fc18 = element_77447a9a695040d8bcd63a98c06d66fc17.firstElementChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fc19 = element_77447a9a695040d8bcd63a98c06d66fc17.firstElementChild.nextElementSibling, attributes_77447a9a695040d8bcd63a98c06d66fc1a = { "class": "item" };
|
|
1632
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc17, "class", () => item.selected ? "selected" : "", attributes_77447a9a695040d8bcd63a98c06d66fc1a);
|
|
1633
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc18, item.name);
|
|
1634
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc19, "checked", () => item.selected);
|
|
1635
|
+
return root_77447a9a695040d8bcd63a98c06d66fc15;
|
|
1636
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fc1k);
|
|
1637
|
+
element_77447a9a695040d8bcd63a98c06d66fc1l.parentNode.insertBefore(new ArraySlot(state.counts, (count, i) => {
|
|
1638
|
+
let root_77447a9a695040d8bcd63a98c06d66fc1b = template_77447a9a695040d8bcd63a98c06d66fc1c(), element_77447a9a695040d8bcd63a98c06d66fc1d = root_77447a9a695040d8bcd63a98c06d66fc1b.firstChild, element_77447a9a695040d8bcd63a98c06d66fc1e = element_77447a9a695040d8bcd63a98c06d66fc1d.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc1f = element_77447a9a695040d8bcd63a98c06d66fc1e.nextSibling.nextSibling;
|
|
1639
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc1d, "click", () => {
|
|
1640
|
+
state.currentIndex = i;
|
|
1641
|
+
state.increment();
|
|
1642
|
+
});
|
|
1643
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc1e, i);
|
|
1644
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc1f, count);
|
|
1645
|
+
return root_77447a9a695040d8bcd63a98c06d66fc1b;
|
|
1646
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fc1l);
|
|
1647
|
+
return root_77447a9a695040d8bcd63a98c06d66fc1g;
|
|
1648
|
+
})();
|
|
1649
|
+
state.items[0].selected = true;
|
|
1650
|
+
state.counts[0] = 5;
|
|
1651
|
+
state.currentIndex = 1;
|
|
1652
|
+
return { state, view };
|
|
1653
|
+
}
|
|
1654
|
+
function testConditionalRendering() {
|
|
1655
|
+
let showDetails = reactive$1(false), status = reactive$1("loading"), user = reactive$1(null);
|
|
1656
|
+
let view = (() => {
|
|
1657
|
+
let root_77447a9a695040d8bcd63a98c06d66fc1v = template_77447a9a695040d8bcd63a98c06d66fc1w(), element_77447a9a695040d8bcd63a98c06d66fc1x = root_77447a9a695040d8bcd63a98c06d66fc1v.firstChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fc1y = element_77447a9a695040d8bcd63a98c06d66fc1x.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc1z = element_77447a9a695040d8bcd63a98c06d66fc1y.nextSibling;
|
|
1658
|
+
new EffectSlot(element_77447a9a695040d8bcd63a98c06d66fc1x, () => showDetails ? template_77447a9a695040d8bcd63a98c06d66fc1m() : template_77447a9a695040d8bcd63a98c06d66fc1n());
|
|
1659
|
+
new EffectSlot(element_77447a9a695040d8bcd63a98c06d66fc1y, () => {
|
|
1660
|
+
if (status === "loading") {
|
|
1661
|
+
return template_77447a9a695040d8bcd63a98c06d66fc1o();
|
|
1662
|
+
}
|
|
1663
|
+
if (status === "error") {
|
|
1664
|
+
return template_77447a9a695040d8bcd63a98c06d66fc1p();
|
|
1665
|
+
}
|
|
1666
|
+
return template_77447a9a695040d8bcd63a98c06d66fc1q();
|
|
1667
|
+
});
|
|
1668
|
+
new EffectSlot(element_77447a9a695040d8bcd63a98c06d66fc1z, () => user ? (() => {
|
|
1669
|
+
let root_77447a9a695040d8bcd63a98c06d66fc1r = template_77447a9a695040d8bcd63a98c06d66fc1s(), element_77447a9a695040d8bcd63a98c06d66fc1t = root_77447a9a695040d8bcd63a98c06d66fc1r.firstChild.firstChild.nextSibling;
|
|
1670
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc1t, user.name);
|
|
1671
|
+
return root_77447a9a695040d8bcd63a98c06d66fc1r;
|
|
1672
|
+
})() : template_77447a9a695040d8bcd63a98c06d66fc1u());
|
|
1673
|
+
return root_77447a9a695040d8bcd63a98c06d66fc1v;
|
|
1674
|
+
})();
|
|
1675
|
+
showDetails = true;
|
|
1676
|
+
status = "success";
|
|
1677
|
+
user = { name: "Alice" };
|
|
1678
|
+
return { showDetails, status, user, view };
|
|
1679
|
+
}
|
|
1680
|
+
function testEventHandlers() {
|
|
1681
|
+
let clicks = reactive$1(0), inputValue = reactive$1(""), items = reactive$1([]);
|
|
1682
|
+
let view = (() => {
|
|
1683
|
+
let root_77447a9a695040d8bcd63a98c06d66fc24 = template_77447a9a695040d8bcd63a98c06d66fc25(), element_77447a9a695040d8bcd63a98c06d66fc26 = root_77447a9a695040d8bcd63a98c06d66fc24.firstChild.firstElementChild, element_77447a9a695040d8bcd63a98c06d66fc27 = element_77447a9a695040d8bcd63a98c06d66fc26.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc28 = element_77447a9a695040d8bcd63a98c06d66fc26.nextElementSibling, element_77447a9a695040d8bcd63a98c06d66fc29 = element_77447a9a695040d8bcd63a98c06d66fc28.nextElementSibling, element_77447a9a695040d8bcd63a98c06d66fc2a = element_77447a9a695040d8bcd63a98c06d66fc29.nextElementSibling.firstChild;
|
|
1684
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc26, "click", () => clicks++);
|
|
1685
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc27, clicks);
|
|
1686
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc28, "value", inputValue);
|
|
1687
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc28, "input", (e) => {
|
|
1688
|
+
inputValue = e.target.value;
|
|
1689
|
+
});
|
|
1690
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc29, "click", () => {
|
|
1691
|
+
if (inputValue) {
|
|
1692
|
+
items.push(inputValue);
|
|
1693
|
+
inputValue = "";
|
|
1694
|
+
}
|
|
1695
|
+
});
|
|
1696
|
+
element_77447a9a695040d8bcd63a98c06d66fc2a.parentNode.insertBefore(new ArraySlot(items, (item, index) => {
|
|
1697
|
+
let root_77447a9a695040d8bcd63a98c06d66fc20 = template_77447a9a695040d8bcd63a98c06d66fc21(), element_77447a9a695040d8bcd63a98c06d66fc22 = root_77447a9a695040d8bcd63a98c06d66fc20.firstChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fc23 = root_77447a9a695040d8bcd63a98c06d66fc20.firstChild.firstElementChild;
|
|
1698
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc22, item);
|
|
1699
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc23, "click", () => items.splice(index, 1));
|
|
1700
|
+
return root_77447a9a695040d8bcd63a98c06d66fc20;
|
|
1701
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fc2a);
|
|
1702
|
+
return root_77447a9a695040d8bcd63a98c06d66fc24;
|
|
1703
|
+
})();
|
|
1704
|
+
clicks++;
|
|
1705
|
+
clicks++;
|
|
1706
|
+
inputValue = "Test item";
|
|
1707
|
+
items.push("First");
|
|
1708
|
+
items.push("Second");
|
|
1709
|
+
return { clicks, inputValue, items, view };
|
|
1710
|
+
}
|
|
1711
|
+
function testAttributeBindings() {
|
|
1712
|
+
let isDisabled = reactive$1(false), classes = reactive$1("primary"), styles = reactive$1("color: red"), href = reactive$1("https://example.com"), dataValue = reactive$1(42);
|
|
1713
|
+
let view = (() => {
|
|
1714
|
+
let root_77447a9a695040d8bcd63a98c06d66fc2b = template_77447a9a695040d8bcd63a98c06d66fc2c(), element_77447a9a695040d8bcd63a98c06d66fc2d = root_77447a9a695040d8bcd63a98c06d66fc2b.firstChild.firstElementChild, element_77447a9a695040d8bcd63a98c06d66fc2e = element_77447a9a695040d8bcd63a98c06d66fc2d.nextElementSibling, element_77447a9a695040d8bcd63a98c06d66fc2f = element_77447a9a695040d8bcd63a98c06d66fc2e.nextElementSibling, attributes_77447a9a695040d8bcd63a98c06d66fc2g = {}, attributes_77447a9a695040d8bcd63a98c06d66fc2h = {};
|
|
1715
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc2d, "class", classes, attributes_77447a9a695040d8bcd63a98c06d66fc2g);
|
|
1716
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc2d, "disabled", isDisabled);
|
|
1717
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc2d, "data-value", dataValue);
|
|
1718
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc2d, "style", styles, attributes_77447a9a695040d8bcd63a98c06d66fc2g);
|
|
1719
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc2e, "href", href);
|
|
1720
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc2f, "class", () => isDisabled ? "disabled-input" : "active-input", attributes_77447a9a695040d8bcd63a98c06d66fc2h);
|
|
1721
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc2f, "placeholder", () => `Value: ${dataValue}`);
|
|
1722
|
+
return root_77447a9a695040d8bcd63a98c06d66fc2b;
|
|
1723
|
+
})();
|
|
1724
|
+
isDisabled = true;
|
|
1725
|
+
classes = "secondary active";
|
|
1726
|
+
styles = "color: blue; font-weight: bold";
|
|
1727
|
+
href = "https://updated.com";
|
|
1728
|
+
dataValue = 100;
|
|
1729
|
+
return { classes, dataValue, href, isDisabled, styles, view };
|
|
1730
|
+
}
|
|
1731
|
+
function testMixedReactiveTypes() {
|
|
1732
|
+
let primitive = reactive$1(0), computed2 = reactive$1(() => primitive * 2), array = reactive$1([1, 2, 3]), object = reactive$1({
|
|
1733
|
+
count: 0,
|
|
1734
|
+
double: () => object.count * 2,
|
|
1735
|
+
name: "Test"
|
|
1736
|
+
});
|
|
1737
|
+
let view = (() => {
|
|
1738
|
+
let root_77447a9a695040d8bcd63a98c06d66fc2l = template_77447a9a695040d8bcd63a98c06d66fc2m(), element_77447a9a695040d8bcd63a98c06d66fc2n = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc2o = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.firstElementChild.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc2p = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.nextElementSibling.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc2q = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.nextElementSibling.firstElementChild.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc2r = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.nextElementSibling.firstElementChild.nextElementSibling.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc2s = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc2t = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.nextElementSibling.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc2u = root_77447a9a695040d8bcd63a98c06d66fc2l.firstChild.firstElementChild.nextElementSibling.nextElementSibling.nextElementSibling.firstElementChild;
|
|
1739
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc2n, primitive);
|
|
1740
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc2o, computed2);
|
|
1741
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc2p, object.name);
|
|
1742
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc2q, object.count);
|
|
1743
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc2r, object.double);
|
|
1744
|
+
new EffectSlot(element_77447a9a695040d8bcd63a98c06d66fc2s, () => array.length);
|
|
1745
|
+
element_77447a9a695040d8bcd63a98c06d66fc2t.parentNode.insertBefore(new ArraySlot(array, (n) => {
|
|
1746
|
+
let root_77447a9a695040d8bcd63a98c06d66fc2i = template_77447a9a695040d8bcd63a98c06d66fc2j(), element_77447a9a695040d8bcd63a98c06d66fc2k = root_77447a9a695040d8bcd63a98c06d66fc2i.firstChild.firstChild;
|
|
1747
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc2k, n);
|
|
1748
|
+
return root_77447a9a695040d8bcd63a98c06d66fc2i;
|
|
1749
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fc2t);
|
|
1750
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc2u, "click", () => {
|
|
1751
|
+
primitive++;
|
|
1752
|
+
object.count++;
|
|
1753
|
+
array.push(array.length + 1);
|
|
1754
|
+
});
|
|
1755
|
+
return root_77447a9a695040d8bcd63a98c06d66fc2l;
|
|
1756
|
+
})();
|
|
1757
|
+
primitive = 5;
|
|
1758
|
+
object.name = "Updated";
|
|
1759
|
+
object.count = 10;
|
|
1760
|
+
array.push(4, 5, 6);
|
|
1761
|
+
return { array, computed: computed2, object, primitive, view };
|
|
1762
|
+
}
|
|
1763
|
+
function testTypedReactive() {
|
|
1764
|
+
let state = reactive$1({
|
|
1765
|
+
addTodo: (text2) => {
|
|
1766
|
+
state.todos.push({
|
|
1767
|
+
completed: false,
|
|
1768
|
+
id: state.nextId++,
|
|
1769
|
+
text: text2
|
|
1770
|
+
});
|
|
1771
|
+
},
|
|
1772
|
+
completedCount: () => state.todos.filter((t) => t.completed).length,
|
|
1773
|
+
filter: "all",
|
|
1774
|
+
filteredTodos: () => {
|
|
1775
|
+
if (state.filter === "active") {
|
|
1776
|
+
return state.todos.filter((t) => !t.completed);
|
|
1777
|
+
}
|
|
1778
|
+
if (state.filter === "completed") {
|
|
1779
|
+
return state.todos.filter((t) => t.completed);
|
|
1780
|
+
}
|
|
1781
|
+
return state.todos;
|
|
1782
|
+
},
|
|
1783
|
+
nextId: 1,
|
|
1784
|
+
todos: [],
|
|
1785
|
+
toggleTodo: (id) => {
|
|
1786
|
+
let todo = state.todos.find((t) => t.id === id);
|
|
1787
|
+
if (todo) {
|
|
1788
|
+
todo.completed = !todo.completed;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
let view = (() => {
|
|
1793
|
+
let root_77447a9a695040d8bcd63a98c06d66fc31 = template_77447a9a695040d8bcd63a98c06d66fc32(), element_77447a9a695040d8bcd63a98c06d66fc33 = root_77447a9a695040d8bcd63a98c06d66fc31.firstChild.firstElementChild.firstElementChild.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc34 = root_77447a9a695040d8bcd63a98c06d66fc31.firstChild.firstElementChild.firstElementChild.nextElementSibling.firstElementChild, element_77447a9a695040d8bcd63a98c06d66fc35 = element_77447a9a695040d8bcd63a98c06d66fc34.nextElementSibling, element_77447a9a695040d8bcd63a98c06d66fc36 = element_77447a9a695040d8bcd63a98c06d66fc35.nextElementSibling, element_77447a9a695040d8bcd63a98c06d66fc37 = root_77447a9a695040d8bcd63a98c06d66fc31.firstChild.firstElementChild.nextElementSibling.firstChild, attributes_77447a9a695040d8bcd63a98c06d66fc38 = {}, attributes_77447a9a695040d8bcd63a98c06d66fc39 = {}, attributes_77447a9a695040d8bcd63a98c06d66fc3a = {};
|
|
1794
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc33, state.completedCount);
|
|
1795
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc34, "class", () => state.filter === "all" ? "active" : "", attributes_77447a9a695040d8bcd63a98c06d66fc38);
|
|
1796
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc34, "click", () => {
|
|
1797
|
+
state.filter = "all";
|
|
1798
|
+
});
|
|
1799
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc35, "class", () => state.filter === "active" ? "active" : "", attributes_77447a9a695040d8bcd63a98c06d66fc39);
|
|
1800
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc35, "click", () => {
|
|
1801
|
+
state.filter = "active";
|
|
1802
|
+
});
|
|
1803
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc36, "class", () => state.filter === "completed" ? "active" : "", attributes_77447a9a695040d8bcd63a98c06d66fc3a);
|
|
1804
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc36, "click", () => {
|
|
1805
|
+
state.filter = "completed";
|
|
1806
|
+
});
|
|
1807
|
+
new EffectSlot(element_77447a9a695040d8bcd63a98c06d66fc37, () => state.filteredTodos().map((todo) => {
|
|
1808
|
+
let root_77447a9a695040d8bcd63a98c06d66fc2v = template_77447a9a695040d8bcd63a98c06d66fc2w(), element_77447a9a695040d8bcd63a98c06d66fc2x = root_77447a9a695040d8bcd63a98c06d66fc2v.firstChild, element_77447a9a695040d8bcd63a98c06d66fc2y = element_77447a9a695040d8bcd63a98c06d66fc2x.firstElementChild, element_77447a9a695040d8bcd63a98c06d66fc2z = element_77447a9a695040d8bcd63a98c06d66fc2y.nextElementSibling.firstChild, attributes_77447a9a695040d8bcd63a98c06d66fc30 = { "class": "todo" };
|
|
1809
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc2x, "class", todo.completed ? "completed" : "", attributes_77447a9a695040d8bcd63a98c06d66fc30);
|
|
1810
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc2y, "checked", todo.completed);
|
|
1811
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc2y, "change", () => state.toggleTodo(todo.id));
|
|
1812
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc2z, todo.text);
|
|
1813
|
+
return root_77447a9a695040d8bcd63a98c06d66fc2v;
|
|
1814
|
+
}));
|
|
1815
|
+
return root_77447a9a695040d8bcd63a98c06d66fc31;
|
|
1816
|
+
})();
|
|
1817
|
+
state.addTodo("Learn TypeScript");
|
|
1818
|
+
state.addTodo("Build app");
|
|
1819
|
+
state.addTodo("Write tests");
|
|
1820
|
+
state.toggleTodo(1);
|
|
1821
|
+
return { state, view };
|
|
1822
|
+
}
|
|
1823
|
+
function testDeeplyNested() {
|
|
1824
|
+
let level1 = reactive$1({
|
|
1825
|
+
items: reactive$1([
|
|
1826
|
+
{
|
|
1827
|
+
children: reactive$1([
|
|
1828
|
+
{ name: "Leaf 1", value: reactive$1(1) },
|
|
1829
|
+
{ name: "Leaf 2", value: reactive$1(2) }
|
|
1830
|
+
]),
|
|
1831
|
+
name: "Child 1"
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
children: reactive$1([
|
|
1835
|
+
{ name: "Leaf 3", value: reactive$1(3) }
|
|
1836
|
+
]),
|
|
1837
|
+
name: "Child 2"
|
|
1838
|
+
}
|
|
1839
|
+
]),
|
|
1840
|
+
name: "Root"
|
|
1841
|
+
});
|
|
1842
|
+
let view = (() => {
|
|
1843
|
+
let root_77447a9a695040d8bcd63a98c06d66fc3k = template_77447a9a695040d8bcd63a98c06d66fc3l(), element_77447a9a695040d8bcd63a98c06d66fc3m = root_77447a9a695040d8bcd63a98c06d66fc3k.firstChild.firstElementChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fc3n = root_77447a9a695040d8bcd63a98c06d66fc3k.firstChild.firstChild.nextSibling;
|
|
1844
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc3m, level1.name);
|
|
1845
|
+
element_77447a9a695040d8bcd63a98c06d66fc3n.parentNode.insertBefore(new ArraySlot(level1.items, (item) => {
|
|
1846
|
+
let root_77447a9a695040d8bcd63a98c06d66fc3g = template_77447a9a695040d8bcd63a98c06d66fc3h(), element_77447a9a695040d8bcd63a98c06d66fc3i = root_77447a9a695040d8bcd63a98c06d66fc3g.firstChild.firstElementChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fc3j = root_77447a9a695040d8bcd63a98c06d66fc3g.firstChild.firstChild.nextSibling;
|
|
1847
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc3i, item.name);
|
|
1848
|
+
element_77447a9a695040d8bcd63a98c06d66fc3j.parentNode.insertBefore(new ArraySlot(item.children, (child) => {
|
|
1849
|
+
let root_77447a9a695040d8bcd63a98c06d66fc3b = template_77447a9a695040d8bcd63a98c06d66fc3c(), element_77447a9a695040d8bcd63a98c06d66fc3d = root_77447a9a695040d8bcd63a98c06d66fc3b.firstChild.firstElementChild.firstChild, element_77447a9a695040d8bcd63a98c06d66fc3e = element_77447a9a695040d8bcd63a98c06d66fc3d.nextSibling.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc3f = root_77447a9a695040d8bcd63a98c06d66fc3b.firstChild.firstElementChild.nextElementSibling;
|
|
1850
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc3d, child.name);
|
|
1851
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc3e, child.value);
|
|
1852
|
+
delegate(element_77447a9a695040d8bcd63a98c06d66fc3f, "click", () => child.value++);
|
|
1853
|
+
return root_77447a9a695040d8bcd63a98c06d66fc3b;
|
|
1854
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fc3j);
|
|
1855
|
+
return root_77447a9a695040d8bcd63a98c06d66fc3g;
|
|
1856
|
+
}).fragment, element_77447a9a695040d8bcd63a98c06d66fc3n);
|
|
1857
|
+
return root_77447a9a695040d8bcd63a98c06d66fc3k;
|
|
1858
|
+
})();
|
|
1859
|
+
level1.items[0].children[0].value++;
|
|
1860
|
+
level1.items.push({
|
|
1861
|
+
children: reactive$1([{ name: "Leaf 4", value: reactive$1(4) }]),
|
|
1862
|
+
name: "Child 3"
|
|
1863
|
+
});
|
|
1864
|
+
return { level1, view };
|
|
1865
|
+
}
|
|
1866
|
+
function testStaticVsDynamic() {
|
|
1867
|
+
let dynamicText = reactive$1("Dynamic"), dynamicNum = reactive$1(42), dynamicBool = reactive$1(true);
|
|
1868
|
+
let view = (() => {
|
|
1869
|
+
let root_77447a9a695040d8bcd63a98c06d66fc3o = template_77447a9a695040d8bcd63a98c06d66fc3p(), element_77447a9a695040d8bcd63a98c06d66fc3q = root_77447a9a695040d8bcd63a98c06d66fc3o.firstChild.firstElementChild.nextElementSibling.firstChild, element_77447a9a695040d8bcd63a98c06d66fc3r = root_77447a9a695040d8bcd63a98c06d66fc3o.firstChild.firstElementChild.nextElementSibling.nextElementSibling.nextElementSibling.firstChild.nextSibling, element_77447a9a695040d8bcd63a98c06d66fc3s = root_77447a9a695040d8bcd63a98c06d66fc3o.firstChild.firstElementChild.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling, element_77447a9a695040d8bcd63a98c06d66fc3t = element_77447a9a695040d8bcd63a98c06d66fc3s.nextElementSibling.nextElementSibling, element_77447a9a695040d8bcd63a98c06d66fc3u = element_77447a9a695040d8bcd63a98c06d66fc3t.nextElementSibling.nextElementSibling, attributes_77447a9a695040d8bcd63a98c06d66fc3v = { "class": "" };
|
|
1870
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc3q, dynamicText);
|
|
1871
|
+
slot(element_77447a9a695040d8bcd63a98c06d66fc3r, dynamicNum);
|
|
1872
|
+
setList(element_77447a9a695040d8bcd63a98c06d66fc3s, "class", () => dynamicBool ? "dynamic-true" : "dynamic-false", attributes_77447a9a695040d8bcd63a98c06d66fc3v);
|
|
1873
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc3t, "href", () => dynamicBool ? "https://true.com" : "https://false.com");
|
|
1874
|
+
setProperty(element_77447a9a695040d8bcd63a98c06d66fc3u, "value", dynamicText);
|
|
1875
|
+
return root_77447a9a695040d8bcd63a98c06d66fc3o;
|
|
1876
|
+
})();
|
|
1877
|
+
dynamicText = "Updated";
|
|
1878
|
+
dynamicNum = 100;
|
|
1879
|
+
dynamicBool = false;
|
|
1880
|
+
return { dynamicBool, dynamicNum, dynamicText, view };
|
|
1881
|
+
}
|
|
1882
|
+
const tests = {
|
|
1883
|
+
testAttributeBindings,
|
|
1884
|
+
testComplexNested,
|
|
1885
|
+
testComputedValues,
|
|
1886
|
+
testConditionalRendering,
|
|
1887
|
+
testDeeplyNested,
|
|
1888
|
+
testEventHandlers,
|
|
1889
|
+
testMixedReactiveTypes,
|
|
1890
|
+
testPrimitiveSignals,
|
|
1891
|
+
testReactiveArrays,
|
|
1892
|
+
testReactiveObjects,
|
|
1893
|
+
testStaticVsDynamic,
|
|
1894
|
+
testTypedReactive
|
|
1895
|
+
};
|
|
1896
|
+
const results = Object.entries(tests).map(([name, fn]) => {
|
|
1897
|
+
try {
|
|
1898
|
+
let result = fn();
|
|
1899
|
+
console.log(`✓ ${name} passed`);
|
|
1900
|
+
return { name, result, status: "passed" };
|
|
1901
|
+
} catch (error) {
|
|
1902
|
+
console.error(`✗ ${name} failed:`, error);
|
|
1903
|
+
return { error, name, status: "failed" };
|
|
1904
|
+
}
|
|
1905
|
+
});
|
|
1906
|
+
console.log(`
|
|
1907
|
+
Tests completed: ${results.filter((r) => r.status === "passed").length}/${results.length} passed`);
|
|
1908
|
+
export {
|
|
1909
|
+
results,
|
|
1910
|
+
tests
|
|
1911
|
+
};
|
|
1912
|
+
//# sourceMappingURL=test.js.map
|