ks-fwork 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ks-fwork.js +572 -791
- package/package.json +3 -6
- package/src/index.js +1 -1
package/dist/ks-fwork.js
CHANGED
|
@@ -1,794 +1,575 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
|
|
3
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
4
|
+
get: ((e) => i[e]).bind(null, d),
|
|
5
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
6
|
+
});
|
|
7
|
+
return e;
|
|
8
|
+
}, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
9
|
+
value: n,
|
|
10
|
+
enumerable: !0
|
|
11
|
+
}) : a, n));
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/events.js
|
|
14
|
+
function l(e = {}, t, n = null) {
|
|
15
|
+
let r = {};
|
|
16
|
+
return Object.entries(e).forEach(([e, i]) => {
|
|
17
|
+
r[e] = u(e, i, t, n);
|
|
18
|
+
}), r;
|
|
19
|
+
}
|
|
20
|
+
function u(e, t, n, r = null) {
|
|
21
|
+
function i() {
|
|
22
|
+
r ? t.apply(r, arguments) : t(...arguments);
|
|
23
|
+
}
|
|
24
|
+
return n.addEventListener(e, i), i;
|
|
25
|
+
}
|
|
26
|
+
function d(e = {}, t) {
|
|
27
|
+
Object.entries(e).forEach(([e, n]) => {
|
|
28
|
+
t.removeEventListener(e, n);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/utils/arrays.js
|
|
33
|
+
function f(e) {
|
|
34
|
+
return e.filter((e) => e != null);
|
|
35
|
+
}
|
|
36
|
+
function p(e, t) {
|
|
37
|
+
return {
|
|
38
|
+
added: t.filter((t) => !e.includes(t)),
|
|
39
|
+
removed: e.filter((e) => !t.includes(e))
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
var m = {
|
|
43
|
+
ADD: "add",
|
|
44
|
+
REMOVE: "remove",
|
|
45
|
+
MOVE: "move",
|
|
46
|
+
NOOP: "noop"
|
|
47
|
+
}, h = class {
|
|
48
|
+
#e = [];
|
|
49
|
+
#t = [];
|
|
50
|
+
#n;
|
|
51
|
+
constructor(e, t) {
|
|
52
|
+
this.#e = [...e], this.#t = e.map((e, t) => t), this.#n = t;
|
|
53
|
+
}
|
|
54
|
+
get length() {
|
|
55
|
+
return this.#e.length;
|
|
56
|
+
}
|
|
57
|
+
originalIndexAt(e) {
|
|
58
|
+
return this.#t[e];
|
|
59
|
+
}
|
|
60
|
+
isAddition(e, t) {
|
|
61
|
+
return this.findIndexFrom(e, t) === -1;
|
|
62
|
+
}
|
|
63
|
+
addItem(e, t) {
|
|
64
|
+
let n = {
|
|
65
|
+
op: m.ADD,
|
|
66
|
+
index: t,
|
|
67
|
+
item: e
|
|
68
|
+
};
|
|
69
|
+
return this.#e.splice(t, 0, e), this.#t.splice(t, 0, -1), n;
|
|
70
|
+
}
|
|
71
|
+
isRemoval(e, t) {
|
|
72
|
+
if (e >= this.length) return !1;
|
|
73
|
+
let n = this.#e[e];
|
|
74
|
+
return t.findIndex((e) => this.#n(n, e)) === -1;
|
|
75
|
+
}
|
|
76
|
+
removeItem(e) {
|
|
77
|
+
let t = {
|
|
78
|
+
op: m.REMOVE,
|
|
79
|
+
index: e,
|
|
80
|
+
item: this.#e[e]
|
|
81
|
+
};
|
|
82
|
+
return this.#e.splice(e, 1), this.#t.splice(e, 1), t;
|
|
83
|
+
}
|
|
84
|
+
moveItem(e, t) {
|
|
85
|
+
let n = this.findIndexFrom(e, t), r = {
|
|
86
|
+
op: m.MOVE,
|
|
87
|
+
originalIndex: this.originalIndexAt(n),
|
|
88
|
+
from: n,
|
|
89
|
+
index: t,
|
|
90
|
+
item: this.#e[n]
|
|
91
|
+
}, [i] = this.#e.splice(n, 1);
|
|
92
|
+
this.#e.splice(t, 0, i);
|
|
93
|
+
let [a] = this.#t.splice(n, 1);
|
|
94
|
+
return this.#t.splice(t, 0, a), r;
|
|
95
|
+
}
|
|
96
|
+
isNoop(e, t) {
|
|
97
|
+
if (e >= this.length) return !1;
|
|
98
|
+
let n = this.#e[e], r = t[e];
|
|
99
|
+
return this.#n(n, r);
|
|
100
|
+
}
|
|
101
|
+
noopItem(e) {
|
|
102
|
+
return {
|
|
103
|
+
op: m.NOOP,
|
|
104
|
+
originalIndex: this.originalIndexAt(e),
|
|
105
|
+
index: e,
|
|
106
|
+
item: this.#e[e]
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
removeItemsAfter(e) {
|
|
110
|
+
let t = [];
|
|
111
|
+
for (; this.length > e;) t.push(this.removeItem(e));
|
|
112
|
+
return t;
|
|
113
|
+
}
|
|
114
|
+
findIndexFrom(e, t) {
|
|
115
|
+
for (let n = t; n < this.length; n++) if (this.#n(e, this.#e[n])) return n;
|
|
116
|
+
return -1;
|
|
117
|
+
}
|
|
39
118
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
isRemoval(index, newArray) {
|
|
69
|
-
if (index >= this.length) { return false; }
|
|
70
|
-
const item = this.#oldArray[index];
|
|
71
|
-
const indexInNewArray = newArray.findIndex((newArrayItem) => this.#equalsFn(item, newArrayItem));
|
|
72
|
-
return indexInNewArray === -1;
|
|
73
|
-
}
|
|
74
|
-
removeItem(index) {
|
|
75
|
-
const operation = {
|
|
76
|
-
op: ARRAY_DIFF_OP.REMOVE,
|
|
77
|
-
index,
|
|
78
|
-
item: this.#oldArray[index],
|
|
79
|
-
};
|
|
80
|
-
this.#oldArray.splice(index, 1);
|
|
81
|
-
this.#originalIndices.splice(index, 1);
|
|
82
|
-
return operation;
|
|
83
|
-
}
|
|
84
|
-
moveItem(item, toIndex) {
|
|
85
|
-
const fromIndex = this.findIndexFrom(item, toIndex);
|
|
86
|
-
const operation = {
|
|
87
|
-
op: ARRAY_DIFF_OP.MOVE,
|
|
88
|
-
originalIndex: this.originalIndexAt(fromIndex),
|
|
89
|
-
from: fromIndex,
|
|
90
|
-
index: toIndex,
|
|
91
|
-
item: this.#oldArray[fromIndex],
|
|
92
|
-
};
|
|
93
|
-
const [itemToMove] = this.#oldArray.splice(fromIndex, 1);
|
|
94
|
-
this.#oldArray.splice(toIndex, 0, itemToMove);
|
|
95
|
-
const [originalIndex] = this.#originalIndices.splice(fromIndex, 1);
|
|
96
|
-
this.#originalIndices.splice(toIndex, 0, originalIndex);
|
|
97
|
-
return operation;
|
|
98
|
-
}
|
|
99
|
-
isNoop(index, newArray) {
|
|
100
|
-
if (index >= this.length) {return false; }
|
|
101
|
-
const item = this.#oldArray[index];
|
|
102
|
-
const newArrayItem = newArray[index];
|
|
103
|
-
return this.#equalsFn(item, newArrayItem);
|
|
104
|
-
}
|
|
105
|
-
noopItem(index) {
|
|
106
|
-
return {
|
|
107
|
-
op: ARRAY_DIFF_OP.NOOP,
|
|
108
|
-
originalIndex: this.originalIndexAt(index),
|
|
109
|
-
index,
|
|
110
|
-
item: this.#oldArray[index],
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
removeItemsAfter(index) {
|
|
114
|
-
const operations = [];
|
|
115
|
-
while (this.length > index) {
|
|
116
|
-
operations.push(this.removeItem(index));
|
|
117
|
-
}
|
|
118
|
-
return operations;
|
|
119
|
-
}
|
|
120
|
-
findIndexFrom(item, startIndex) {
|
|
121
|
-
for (let i = startIndex; i < this.length; i++) {
|
|
122
|
-
if (this.#equalsFn(item, this.#oldArray[i])) {
|
|
123
|
-
return i;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return -1;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function arraysDiffSequence(oldArray, newArray, equalsFn = (a, b) => a === b) {
|
|
130
|
-
const sequence = [];
|
|
131
|
-
const array = new ArrayWithOriginalIndices(oldArray, equalsFn);
|
|
132
|
-
for (let index = 0; index < newArray.length; index++) {
|
|
133
|
-
if (array.isRemoval(index, newArray)) {
|
|
134
|
-
sequence.push(array.removeItem(index));
|
|
135
|
-
index--;
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
if (array.isNoop(index, newArray)) {
|
|
139
|
-
sequence.push(array.noopItem(index));
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
const item = newArray[index];
|
|
143
|
-
if (array.isAddition(item, index)) {
|
|
144
|
-
sequence.push(array.addItem(item, index));
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
sequence.push(array.moveItem(item, index));
|
|
148
|
-
}
|
|
149
|
-
sequence.push(...array.removeItemsAfter(newArray.length));
|
|
150
|
-
return sequence;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const DOM_TYPES = {
|
|
154
|
-
TEXT: 'text',
|
|
155
|
-
ELEMENT: 'element',
|
|
156
|
-
FRAGMENT: 'fragment',
|
|
157
|
-
COMPONENT: 'component'
|
|
119
|
+
function ee(e, t, n = (e, t) => e === t) {
|
|
120
|
+
let r = [], i = new h(e, n);
|
|
121
|
+
for (let e = 0; e < t.length; e++) {
|
|
122
|
+
if (i.isRemoval(e, t)) {
|
|
123
|
+
r.push(i.removeItem(e)), e--;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (i.isNoop(e, t)) {
|
|
127
|
+
r.push(i.noopItem(e));
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
let n = t[e];
|
|
131
|
+
if (i.isAddition(n, e)) {
|
|
132
|
+
r.push(i.addItem(n, e));
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
r.push(i.moveItem(n, e));
|
|
136
|
+
}
|
|
137
|
+
return r.push(...i.removeItemsAfter(t.length)), r;
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/h.js
|
|
141
|
+
var g = {
|
|
142
|
+
TEXT: "text",
|
|
143
|
+
ELEMENT: "element",
|
|
144
|
+
FRAGMENT: "fragment",
|
|
145
|
+
COMPONENT: "component"
|
|
158
146
|
};
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
const el = oldVNode.el;
|
|
491
|
-
const { value: oldText } = oldVNode;
|
|
492
|
-
const { value: newText } = newVNode;
|
|
493
|
-
if (oldText !== newText) {
|
|
494
|
-
el.nodeValue = newText;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
function patchElement(oldVNode, newVNode, hostComponent) {
|
|
498
|
-
const el = oldVNode.el;
|
|
499
|
-
const {
|
|
500
|
-
class: oldClass,
|
|
501
|
-
style: oldStyle,
|
|
502
|
-
on: oldEvents,
|
|
503
|
-
...oldAttrs
|
|
504
|
-
} = oldVNode.props;
|
|
505
|
-
const {
|
|
506
|
-
class: newClass,
|
|
507
|
-
style: newStyle,
|
|
508
|
-
on: newEvents,
|
|
509
|
-
...newAttrs
|
|
510
|
-
} = newVNode.props;
|
|
511
|
-
const { listeners: oldListeners } = oldVNode;
|
|
512
|
-
patchAttrs(el, oldAttrs, newAttrs);
|
|
513
|
-
patchClasses(el, oldClass, newClass);
|
|
514
|
-
patchStyles(el, oldStyle, newStyle);
|
|
515
|
-
newVNode.listeners = patchEvents(el, oldListeners, oldEvents, newEvents, hostComponent);
|
|
516
|
-
}
|
|
517
|
-
function patchComponent(oldVNode, newVNode) {
|
|
518
|
-
const { component } = oldVNode;
|
|
519
|
-
const { props } = extractPropsAndEvents(newVNode);
|
|
520
|
-
component.updateProps(props);
|
|
521
|
-
newVNode.component = component;
|
|
522
|
-
newVNode.el = component.firstElement;
|
|
523
|
-
}
|
|
524
|
-
function patchAttrs(el, oldAttrs, newAttrs) {
|
|
525
|
-
const { added, removed, updated } = objectsDiff(oldAttrs, newAttrs);
|
|
526
|
-
for (const attr of removed) {
|
|
527
|
-
removeAttribute(el, attr);
|
|
528
|
-
}
|
|
529
|
-
for (const attr of added.concat(updated)) {
|
|
530
|
-
setAttribute(el, attr, newAttrs[attr]);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
function patchClasses(el, oldClass, newClass) {
|
|
534
|
-
const oldClasses = toClassList(oldClass);
|
|
535
|
-
const newClasses = toClassList(newClass);
|
|
536
|
-
const { added, removed } = arraysDiff(oldClasses, newClasses);
|
|
537
|
-
if (removed.length > 0) {
|
|
538
|
-
el.classList.remove(...removed);
|
|
539
|
-
}
|
|
540
|
-
if (added.length > 0) {
|
|
541
|
-
el.classList.add(...added);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
function toClassList(classes = '') {
|
|
545
|
-
return Array.isArray(classes)
|
|
546
|
-
? classes.filter(isNotBlankOrEmptyString)
|
|
547
|
-
: classes.split(/(\s+)/).filter(isNotBlankOrEmptyString);
|
|
548
|
-
}
|
|
549
|
-
function patchStyles(el, oldStyle = {}, newStyle = {}) {
|
|
550
|
-
const { added, removed, updated} = objectsDiff(oldStyle, newStyle);
|
|
551
|
-
for (const style of removed) {
|
|
552
|
-
removeStyle(el, style);
|
|
553
|
-
}
|
|
554
|
-
for (const style of added.concat(updated)) {
|
|
555
|
-
setStyle(el, style, newStyle[style]);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
function patchEvents(el, oldListeners = {}, oldEvents = {}, newEvents = {}, hostComponent) {
|
|
559
|
-
const { removed, added, updated} = objectsDiff(oldEvents, newEvents);
|
|
560
|
-
for (const eventName of removed.concat(updated)) {
|
|
561
|
-
el.removeEventListener(eventName, oldListeners[eventName]);
|
|
562
|
-
}
|
|
563
|
-
const addedListeners = {};
|
|
564
|
-
for (const eventName of added.concat(updated)) {
|
|
565
|
-
addedListeners[eventName] = addEventListener(eventName, newEvents[eventName], el, hostComponent);
|
|
566
|
-
}
|
|
567
|
-
return addedListeners;
|
|
568
|
-
}
|
|
569
|
-
function patchChildren(oldVNode, newVNode, hostComponent) {
|
|
570
|
-
const oldChildren = extractChildren(oldVNode);
|
|
571
|
-
const newChildren = extractChildren(newVNode);
|
|
572
|
-
const parentEl = oldVNode.el;
|
|
573
|
-
const diffSeq = arraysDiffSequence(oldChildren, newChildren, areNodesEqual);
|
|
574
|
-
for (const operation of diffSeq) {
|
|
575
|
-
const { originalIndex, from, index, item } = operation;
|
|
576
|
-
const offset = hostComponent?.offset ?? 0;
|
|
577
|
-
switch (operation.op) {
|
|
578
|
-
case ARRAY_DIFF_OP.ADD: {
|
|
579
|
-
mountDOM(item, parentEl, index, hostComponent);
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
case ARRAY_DIFF_OP.REMOVE: {
|
|
583
|
-
destroyDOM(item);
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
case ARRAY_DIFF_OP.MOVE: {
|
|
587
|
-
const el = oldChildren[from].el;
|
|
588
|
-
const elAtTargetIndex = parentEl.childNodes[index + offset];
|
|
589
|
-
parentEl.insertBefore(el, elAtTargetIndex);
|
|
590
|
-
patchDOM(oldChildren[from], newChildren[index], parentEl, hostComponent);
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
case ARRAY_DIFF_OP.NOOP: {
|
|
594
|
-
patchDOM(oldChildren[originalIndex], newChildren[index], parentEl, hostComponent);
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function getDefaultExportFromCjs (x) {
|
|
602
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
var fastDeepEqual;
|
|
606
|
-
var hasRequiredFastDeepEqual;
|
|
607
|
-
function requireFastDeepEqual () {
|
|
608
|
-
if (hasRequiredFastDeepEqual) return fastDeepEqual;
|
|
609
|
-
hasRequiredFastDeepEqual = 1;
|
|
610
|
-
fastDeepEqual = function equal(a, b) {
|
|
611
|
-
if (a === b) return true;
|
|
612
|
-
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
|
613
|
-
if (a.constructor !== b.constructor) return false;
|
|
614
|
-
var length, i, keys;
|
|
615
|
-
if (Array.isArray(a)) {
|
|
616
|
-
length = a.length;
|
|
617
|
-
if (length != b.length) return false;
|
|
618
|
-
for (i = length; i-- !== 0;)
|
|
619
|
-
if (!equal(a[i], b[i])) return false;
|
|
620
|
-
return true;
|
|
621
|
-
}
|
|
622
|
-
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
623
|
-
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
624
|
-
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
625
|
-
keys = Object.keys(a);
|
|
626
|
-
length = keys.length;
|
|
627
|
-
if (length !== Object.keys(b).length) return false;
|
|
628
|
-
for (i = length; i-- !== 0;)
|
|
629
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
630
|
-
for (i = length; i-- !== 0;) {
|
|
631
|
-
var key = keys[i];
|
|
632
|
-
if (!equal(a[key], b[key])) return false;
|
|
633
|
-
}
|
|
634
|
-
return true;
|
|
635
|
-
}
|
|
636
|
-
return a!==a && b!==b;
|
|
147
|
+
function _(e, t = {}, n = []) {
|
|
148
|
+
return {
|
|
149
|
+
tag: e,
|
|
150
|
+
props: t,
|
|
151
|
+
type: typeof e == "string" ? g.ELEMENT : g.COMPONENT,
|
|
152
|
+
children: b(f(n))
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function v(e) {
|
|
156
|
+
return {
|
|
157
|
+
type: g.TEXT,
|
|
158
|
+
value: e
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function y(e) {
|
|
162
|
+
return {
|
|
163
|
+
children: b(f(e)),
|
|
164
|
+
type: g.FRAGMENT
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function b(e) {
|
|
168
|
+
return e.map((e) => typeof e == "string" ? v(e) : e);
|
|
169
|
+
}
|
|
170
|
+
function x(e) {
|
|
171
|
+
if (e.children == null) return [];
|
|
172
|
+
let t = [];
|
|
173
|
+
for (let n of e.children) n.type === g.FRAGMENT ? t.push(...x(n)) : t.push(n);
|
|
174
|
+
return t;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/scheduler.js
|
|
178
|
+
var S = !1, C = [];
|
|
179
|
+
function w(e) {
|
|
180
|
+
C.push(e), T();
|
|
181
|
+
}
|
|
182
|
+
function T() {
|
|
183
|
+
S || (S = !0, queueMicrotask(E));
|
|
184
|
+
}
|
|
185
|
+
function E() {
|
|
186
|
+
for (; C.length > 0;) {
|
|
187
|
+
let e = C.shift();
|
|
188
|
+
try {
|
|
189
|
+
Promise.resolve(e()).catch((e) => {
|
|
190
|
+
console.error(`[scheduler]: ${e}`);
|
|
191
|
+
});
|
|
192
|
+
} catch (e) {
|
|
193
|
+
console.error(`[scheduler]: ${e}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
S = !1;
|
|
197
|
+
}
|
|
198
|
+
function te() {
|
|
199
|
+
return T(), D();
|
|
200
|
+
}
|
|
201
|
+
function D() {
|
|
202
|
+
return new Promise((e) => setTimeout(e));
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/destroy-dom.js
|
|
206
|
+
function O(e) {
|
|
207
|
+
let { type: t } = e;
|
|
208
|
+
switch (t) {
|
|
209
|
+
case g.TEXT:
|
|
210
|
+
k(e);
|
|
211
|
+
break;
|
|
212
|
+
case g.ELEMENT:
|
|
213
|
+
A(e);
|
|
214
|
+
break;
|
|
215
|
+
case g.FRAGMENT:
|
|
216
|
+
j(e);
|
|
217
|
+
break;
|
|
218
|
+
case g.COMPONENT:
|
|
219
|
+
e.component.unmount(), w(() => e.component.onUnmounted());
|
|
220
|
+
break;
|
|
221
|
+
default: throw Error(`Can't destroy virtual node of type: ${e.type}`);
|
|
222
|
+
}
|
|
223
|
+
delete e.el;
|
|
224
|
+
}
|
|
225
|
+
function k(e) {
|
|
226
|
+
let { el: t } = e;
|
|
227
|
+
t.remove();
|
|
228
|
+
}
|
|
229
|
+
function A(e) {
|
|
230
|
+
let { el: t, children: n, listeners: r } = e;
|
|
231
|
+
n.forEach(O), r && (d(r, t), delete e.listeners), t.remove();
|
|
232
|
+
}
|
|
233
|
+
function j(e) {
|
|
234
|
+
let { children: t } = e;
|
|
235
|
+
t.forEach(O);
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/attributes.js
|
|
239
|
+
function M(e, t) {
|
|
240
|
+
let { class: n, style: r, ...i } = t;
|
|
241
|
+
n && ne(e, n), r && Object.entries(r).forEach(([t, n]) => {
|
|
242
|
+
N(e, t, n);
|
|
243
|
+
});
|
|
244
|
+
for (let [t, n] of Object.entries(i)) F(e, t, n);
|
|
245
|
+
}
|
|
246
|
+
function ne(e, t) {
|
|
247
|
+
e.className = "", typeof t == "string" && (e.className = t), Array.isArray(t) && e.classList.add(...t);
|
|
248
|
+
}
|
|
249
|
+
function N(e, t, n) {
|
|
250
|
+
e.style[t] = n;
|
|
251
|
+
}
|
|
252
|
+
function P(e, t) {
|
|
253
|
+
e.style[t] = null;
|
|
254
|
+
}
|
|
255
|
+
function F(e, t, n) {
|
|
256
|
+
n == null ? I(e, t) : t.startsWith("data-") ? e.setAttribute(t, n) : e[t] = n;
|
|
257
|
+
}
|
|
258
|
+
function I(e, t) {
|
|
259
|
+
e[t] = null, e.removeAttribute(t);
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/utils/props.js
|
|
263
|
+
function L(e) {
|
|
264
|
+
let { on: t = {}, ...n } = e.props;
|
|
265
|
+
return delete n.key, {
|
|
266
|
+
props: n,
|
|
267
|
+
events: t
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/mount-dom.js
|
|
272
|
+
function R(e, t, n, r = null) {
|
|
273
|
+
switch (e.type) {
|
|
274
|
+
case g.TEXT:
|
|
275
|
+
z(e, t, n);
|
|
276
|
+
break;
|
|
277
|
+
case g.ELEMENT:
|
|
278
|
+
B(e, t, n, r);
|
|
279
|
+
break;
|
|
280
|
+
case g.FRAGMENT:
|
|
281
|
+
V(e, t, n, r);
|
|
282
|
+
break;
|
|
283
|
+
case g.COMPONENT:
|
|
284
|
+
H(e, t, n, r), w(() => e.component.onMounted());
|
|
285
|
+
break;
|
|
286
|
+
default: throw Error(`Can't mount virtual node of type: ${e.type}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function z(e, t, n) {
|
|
290
|
+
let { value: r } = e, i = document.createTextNode(r);
|
|
291
|
+
e.el = i, W(i, t, n);
|
|
292
|
+
}
|
|
293
|
+
function B(e, t, n, r) {
|
|
294
|
+
let { tag: i, children: a } = e, o = document.createElement(i);
|
|
295
|
+
U(o, e, r), e.el = o, a.forEach((e) => R(e, o, null, r)), W(o, t, n);
|
|
296
|
+
}
|
|
297
|
+
function V(e, t, n, r) {
|
|
298
|
+
let { children: i } = e;
|
|
299
|
+
e.el = t, i.forEach((e, i) => {
|
|
300
|
+
R(e, t, n ? n + i : null, r);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function H(e, t, n, r) {
|
|
304
|
+
let i = e.tag, { props: a, events: o } = L(e), s = new i(a, o, r);
|
|
305
|
+
s.mount(t, n), e.component = s, e.el = s.firstElement;
|
|
306
|
+
}
|
|
307
|
+
function U(e, t, n) {
|
|
308
|
+
let { props: r, events: i } = L(t);
|
|
309
|
+
t.listeners = l(i, e, n), M(e, r);
|
|
310
|
+
}
|
|
311
|
+
function W(e, t, n) {
|
|
312
|
+
if (n == null) {
|
|
313
|
+
t.append(e);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (n < 0) throw Error(`Index must be a positive number, got ${n}`);
|
|
317
|
+
let r = t.childNodes;
|
|
318
|
+
n >= r.length ? t.append(e) : t.insertBefore(e, r[n]);
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/app.js
|
|
322
|
+
function G(e, t = {}) {
|
|
323
|
+
let n = null, r = null, i = !1;
|
|
324
|
+
function a() {
|
|
325
|
+
n = null, r = null, i = !1;
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
mount(a) {
|
|
329
|
+
if (i) throw Error("The application is already mounted");
|
|
330
|
+
n = a, r = _(e, t), R(r, n), i = !0;
|
|
331
|
+
},
|
|
332
|
+
unmount() {
|
|
333
|
+
if (!i) throw Error("The application is not mounted");
|
|
334
|
+
O(r), a();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region src/nodes-equal.js
|
|
340
|
+
function K(e, t) {
|
|
341
|
+
if (e.type !== t.type) return !1;
|
|
342
|
+
if (e.type === g.ELEMENT) {
|
|
343
|
+
let { tag: n, props: { key: r } } = e, { tag: i, props: { key: a } } = t;
|
|
344
|
+
return n === i && r === a;
|
|
345
|
+
}
|
|
346
|
+
if (e.type === g.COMPONENT) {
|
|
347
|
+
let { tag: n, props: { key: r } } = e, { tag: i, props: { key: a } } = t;
|
|
348
|
+
return n === i && r === a;
|
|
349
|
+
}
|
|
350
|
+
return !0;
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/utils/objects.js
|
|
354
|
+
function q(e, t) {
|
|
355
|
+
let n = Object.keys(e), r = Object.keys(t);
|
|
356
|
+
return {
|
|
357
|
+
added: r.filter((t) => !(t in e)),
|
|
358
|
+
removed: n.filter((e) => !(e in t)),
|
|
359
|
+
updated: r.filter((n) => n in e && e[n] !== t[n])
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function J(e, t) {
|
|
363
|
+
return Object.prototype.hasOwnProperty.call(e, t);
|
|
364
|
+
}
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/utils/strings.js
|
|
367
|
+
function Y(e) {
|
|
368
|
+
return e !== "";
|
|
369
|
+
}
|
|
370
|
+
function X(e) {
|
|
371
|
+
return Y(e.trim());
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/patch-dom.js
|
|
375
|
+
function Z(e, t, n, r = null) {
|
|
376
|
+
if (!K(e, t)) {
|
|
377
|
+
let i = re(n, e.el);
|
|
378
|
+
return O(e), R(t, n, i, r), t;
|
|
379
|
+
}
|
|
380
|
+
switch (t.el = e.el, t.type) {
|
|
381
|
+
case g.TEXT: return ie(e, t), t;
|
|
382
|
+
case g.ELEMENT:
|
|
383
|
+
ae(e, t, r);
|
|
384
|
+
break;
|
|
385
|
+
case g.COMPONENT:
|
|
386
|
+
oe(e, t);
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
return de(e, t, r), t;
|
|
390
|
+
}
|
|
391
|
+
function re(e, t) {
|
|
392
|
+
let n = Array.from(e.childNodes).indexOf(t);
|
|
393
|
+
return n < 0 ? null : n;
|
|
394
|
+
}
|
|
395
|
+
function ie(e, t) {
|
|
396
|
+
let n = e.el, { value: r } = e, { value: i } = t;
|
|
397
|
+
r !== i && (n.nodeValue = i);
|
|
398
|
+
}
|
|
399
|
+
function ae(e, t, n) {
|
|
400
|
+
let r = e.el, { class: i, style: a, on: o, ...s } = e.props, { class: c, style: l, on: u, ...d } = t.props, { listeners: f } = e;
|
|
401
|
+
se(r, s, d), ce(r, i, c), le(r, a, l), t.listeners = ue(r, f, o, u, n);
|
|
402
|
+
}
|
|
403
|
+
function oe(e, t) {
|
|
404
|
+
let { component: n } = e, { props: r } = L(t);
|
|
405
|
+
n.updateProps(r), t.component = n, t.el = n.firstElement;
|
|
406
|
+
}
|
|
407
|
+
function se(e, t, n) {
|
|
408
|
+
let { added: r, removed: i, updated: a } = q(t, n);
|
|
409
|
+
for (let t of i) I(e, t);
|
|
410
|
+
for (let t of r.concat(a)) F(e, t, n[t]);
|
|
411
|
+
}
|
|
412
|
+
function ce(e, t, n) {
|
|
413
|
+
let { added: r, removed: i } = p(Q(t), Q(n));
|
|
414
|
+
i.length > 0 && e.classList.remove(...i), r.length > 0 && e.classList.add(...r);
|
|
415
|
+
}
|
|
416
|
+
function Q(e = "") {
|
|
417
|
+
return Array.isArray(e) ? e.filter(X) : e.split(/(\s+)/).filter(X);
|
|
418
|
+
}
|
|
419
|
+
function le(e, t = {}, n = {}) {
|
|
420
|
+
let { added: r, removed: i, updated: a } = q(t, n);
|
|
421
|
+
for (let t of i) P(e, t);
|
|
422
|
+
for (let t of r.concat(a)) N(e, t, n[t]);
|
|
423
|
+
}
|
|
424
|
+
function ue(e, t = {}, n = {}, r = {}, i) {
|
|
425
|
+
let { removed: a, added: o, updated: s } = q(n, r);
|
|
426
|
+
for (let n of a.concat(s)) e.removeEventListener(n, t[n]);
|
|
427
|
+
let c = {};
|
|
428
|
+
for (let t of o.concat(s)) c[t] = u(t, r[t], e, i);
|
|
429
|
+
return c;
|
|
430
|
+
}
|
|
431
|
+
function de(e, t, n) {
|
|
432
|
+
let r = x(e), i = x(t), a = e.el, o = ee(r, i, K);
|
|
433
|
+
for (let e of o) {
|
|
434
|
+
let { originalIndex: t, from: o, index: s, item: c } = e, l = n?.offset ?? 0;
|
|
435
|
+
switch (e.op) {
|
|
436
|
+
case m.ADD:
|
|
437
|
+
R(c, a, s, n);
|
|
438
|
+
break;
|
|
439
|
+
case m.REMOVE:
|
|
440
|
+
O(c);
|
|
441
|
+
break;
|
|
442
|
+
case m.MOVE: {
|
|
443
|
+
let e = r[o].el, t = a.childNodes[s + l];
|
|
444
|
+
a.insertBefore(e, t), Z(r[o], i[s], a, n);
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
case m.NOOP:
|
|
448
|
+
Z(r[t], i[s], a, n);
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/dispatcher.js
|
|
455
|
+
var fe = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
|
|
456
|
+
t.exports = function e(t, n) {
|
|
457
|
+
if (t === n) return !0;
|
|
458
|
+
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
459
|
+
if (t.constructor !== n.constructor) return !1;
|
|
460
|
+
var r, i, a;
|
|
461
|
+
if (Array.isArray(t)) {
|
|
462
|
+
if (r = t.length, r != n.length) return !1;
|
|
463
|
+
for (i = r; i-- !== 0;) if (!e(t[i], n[i])) return !1;
|
|
464
|
+
return !0;
|
|
465
|
+
}
|
|
466
|
+
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
467
|
+
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
468
|
+
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
469
|
+
if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
|
|
470
|
+
for (i = r; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(n, a[i])) return !1;
|
|
471
|
+
for (i = r; i-- !== 0;) {
|
|
472
|
+
var o = a[i];
|
|
473
|
+
if (!e(t[o], n[o])) return !1;
|
|
474
|
+
}
|
|
475
|
+
return !0;
|
|
476
|
+
}
|
|
477
|
+
return t !== t && n !== n;
|
|
637
478
|
};
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
render() {
|
|
736
|
-
return render.call(this);
|
|
737
|
-
}
|
|
738
|
-
emit(eventName, payload) {
|
|
739
|
-
this.#dispatcher.dispatch(eventName, payload);
|
|
740
|
-
}
|
|
741
|
-
mount(hostEl, index = null) {
|
|
742
|
-
if (this.#isMounted) {
|
|
743
|
-
throw new Error('Component is already mounted');
|
|
744
|
-
}
|
|
745
|
-
this.#vNode = this.render();
|
|
746
|
-
mountDOM(this.#vNode, hostEl, index, this);
|
|
747
|
-
this.#wireEventHandlers();
|
|
748
|
-
this.#hostEl = hostEl;
|
|
749
|
-
this.#isMounted = true;
|
|
750
|
-
}
|
|
751
|
-
unmount() {
|
|
752
|
-
if (!this.#isMounted) {
|
|
753
|
-
throw new Error('Component is not mounted');
|
|
754
|
-
}
|
|
755
|
-
destroyDOM(this.#vNode);
|
|
756
|
-
this.#subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
757
|
-
this.#vNode = null;
|
|
758
|
-
this.#hostEl = null;
|
|
759
|
-
this.#isMounted = false;
|
|
760
|
-
this.#subscriptions = [];
|
|
761
|
-
}
|
|
762
|
-
#patch() {
|
|
763
|
-
if (!this.#isMounted) {
|
|
764
|
-
throw new Error('Component is not mounted');
|
|
765
|
-
}
|
|
766
|
-
const vNode = this.render();
|
|
767
|
-
this.#vNode = patchDOM(this.#vNode, vNode, this.#hostEl, this);
|
|
768
|
-
}
|
|
769
|
-
#wireEventHandlers() {
|
|
770
|
-
this.#subscriptions = Object.entries(this.#eventHandlers).map(
|
|
771
|
-
([eventName, handler]) =>
|
|
772
|
-
this.#wireEventHandler(eventName, handler)
|
|
773
|
-
);
|
|
774
|
-
}
|
|
775
|
-
#wireEventHandler(eventName, handler) {
|
|
776
|
-
return this.#dispatcher.subscribe(eventName, (payload) => {
|
|
777
|
-
if (this.#parentComponent) {
|
|
778
|
-
handler.call(this.#parentComponent, payload);
|
|
779
|
-
} else {
|
|
780
|
-
handler(payload);
|
|
781
|
-
}
|
|
782
|
-
})
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
for (const methodName in methods) {
|
|
786
|
-
if (hasOwnProperty(Component, methodName)) {
|
|
787
|
-
throw new Error(`Method "${methodName}()" already exists in the component.`);
|
|
788
|
-
}
|
|
789
|
-
Component.prototype[methodName] = methods[methodName];
|
|
790
|
-
}
|
|
791
|
-
return Component;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
export { createApp, defineComponent, h, hFragment, hString, nextTick };
|
|
479
|
+
})))(), 1), pe = class {
|
|
480
|
+
#e = /* @__PURE__ */ new Map();
|
|
481
|
+
#t = [];
|
|
482
|
+
subscribe(e, t) {
|
|
483
|
+
this.#e.has(e) || this.#e.set(e, []);
|
|
484
|
+
let n = this.#e.get(e);
|
|
485
|
+
return n.includes(t) ? () => {} : (n.push(t), () => {
|
|
486
|
+
let e = n.indexOf(t);
|
|
487
|
+
n.splice(e, 1);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
afterEveryCommand(e) {
|
|
491
|
+
return this.#t.push(e), () => {
|
|
492
|
+
let t = this.#t.indexOf(e);
|
|
493
|
+
this.#t.splice(t, 1);
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
dispatch(e, t) {
|
|
497
|
+
this.#e.has(e) ? this.#e.get(e).forEach((e) => e(t)) : console.warn(`No handlers for command: ${e}`), this.#t.forEach((e) => e());
|
|
498
|
+
}
|
|
499
|
+
}, $ = () => {};
|
|
500
|
+
function me({ render: e, state: t, onMounted: n = $, onUnmounted: r = $, ...i }) {
|
|
501
|
+
class a {
|
|
502
|
+
#e = !1;
|
|
503
|
+
#t = null;
|
|
504
|
+
#n = null;
|
|
505
|
+
#r = null;
|
|
506
|
+
#i = null;
|
|
507
|
+
#a = new pe();
|
|
508
|
+
#o = [];
|
|
509
|
+
constructor(e = {}, n = {}, r = null) {
|
|
510
|
+
this.props = e, this.state = t ? t(e) : {}, this.#r = n, this.#i = r;
|
|
511
|
+
}
|
|
512
|
+
onMounted() {
|
|
513
|
+
return Promise.resolve(n.call(this));
|
|
514
|
+
}
|
|
515
|
+
onUnmounted() {
|
|
516
|
+
return Promise.resolve(r.call(this));
|
|
517
|
+
}
|
|
518
|
+
get elements() {
|
|
519
|
+
return this.#t == null ? [] : this.#t.type === g.FRAGMENT ? x(this.#t).flatMap((e) => e.type === g.COMPONENT ? e.component.elements : [e.el]) : [this.#t.el];
|
|
520
|
+
}
|
|
521
|
+
get firstElement() {
|
|
522
|
+
return this.elements[0];
|
|
523
|
+
}
|
|
524
|
+
get offset() {
|
|
525
|
+
return this.#t.type === g.FRAGMENT ? Array.from(this.#n.children).indexOf(this.firstElement) : 0;
|
|
526
|
+
}
|
|
527
|
+
updateProps(e) {
|
|
528
|
+
let t = {
|
|
529
|
+
...this.props,
|
|
530
|
+
...e
|
|
531
|
+
};
|
|
532
|
+
(0, fe.default)(this.props, t) || (this.props = t, this.#s());
|
|
533
|
+
}
|
|
534
|
+
updateState(e) {
|
|
535
|
+
this.state = {
|
|
536
|
+
...this.state,
|
|
537
|
+
...e
|
|
538
|
+
}, this.#s();
|
|
539
|
+
}
|
|
540
|
+
render() {
|
|
541
|
+
return e.call(this);
|
|
542
|
+
}
|
|
543
|
+
emit(e, t) {
|
|
544
|
+
this.#a.dispatch(e, t);
|
|
545
|
+
}
|
|
546
|
+
mount(e, t = null) {
|
|
547
|
+
if (this.#e) throw Error("Component is already mounted");
|
|
548
|
+
this.#t = this.render(), R(this.#t, e, t, this), this.#c(), this.#n = e, this.#e = !0;
|
|
549
|
+
}
|
|
550
|
+
unmount() {
|
|
551
|
+
if (!this.#e) throw Error("Component is not mounted");
|
|
552
|
+
O(this.#t), this.#o.forEach((e) => e()), this.#t = null, this.#n = null, this.#e = !1, this.#o = [];
|
|
553
|
+
}
|
|
554
|
+
#s() {
|
|
555
|
+
if (!this.#e) throw Error("Component is not mounted");
|
|
556
|
+
let e = this.render();
|
|
557
|
+
this.#t = Z(this.#t, e, this.#n, this);
|
|
558
|
+
}
|
|
559
|
+
#c() {
|
|
560
|
+
this.#o = Object.entries(this.#r).map(([e, t]) => this.#l(e, t));
|
|
561
|
+
}
|
|
562
|
+
#l(e, t) {
|
|
563
|
+
return this.#a.subscribe(e, (e) => {
|
|
564
|
+
this.#i ? t.call(this.#i, e) : t(e);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
for (let e in i) {
|
|
569
|
+
if (J(a, e)) throw Error(`Method "${e}()" already exists in the component.`);
|
|
570
|
+
a.prototype[e] = i[e];
|
|
571
|
+
}
|
|
572
|
+
return a;
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
575
|
+
export { G as createApp, me as defineComponent, _ as h, y as hFragment, v as hString, te as nextTick };
|