ks-fwork 4.0.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 CHANGED
@@ -1,787 +1,575 @@
1
- function addEventListeners(listeners = {}, el, hostComponent = null) {
2
- const addedListeners = {};
3
- Object.entries(listeners).forEach(([eventName, handler]) => {
4
- addedListeners[eventName] = addEventListener(eventName, handler, el, hostComponent);
5
- });
6
- return addedListeners;
7
- }
8
- function addEventListener(eventName, handler, el, hostComponent = null) {
9
- function boundHandler() {
10
- hostComponent ? handler.apply(hostComponent, arguments) : handler(...arguments);
11
- }
12
- el.addEventListener(eventName, boundHandler);
13
- return boundHandler;
14
- }
15
- function removeEventListeners(listeners = {}, el) {
16
- Object.entries(listeners).forEach(([eventName, handler]) => {
17
- el.removeEventListener(eventName, handler);
18
- });
19
- }
20
-
21
- function withoutNulls(arr) {
22
- return arr.filter((item) => item != null);
23
- }
24
- function arraysDiff(oldArray, newArray) {
25
- return {
26
- added: newArray.filter(
27
- (newItem) => !oldArray.includes(newItem)
28
- ),
29
- removed: oldArray.filter(
30
- (oldItem) => !newArray.includes(oldItem)
31
- ),
32
- }
33
- }
34
- const ARRAY_DIFF_OP = {
35
- ADD: 'add',
36
- REMOVE: 'remove',
37
- MOVE: 'move',
38
- NOOP: 'noop'
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
- class ArrayWithOriginalIndices {
41
- #oldArray = [];
42
- #originalIndices = [];
43
- #equalsFn;
44
- constructor(array, equalsFn) {
45
- this.#oldArray = [...array];
46
- this.#originalIndices = array.map((value, index) => index);
47
- this.#equalsFn = equalsFn;
48
- }
49
- get length() {
50
- return this.#oldArray.length;
51
- }
52
- originalIndexAt(index) {
53
- return this.#originalIndices[index];
54
- }
55
- isAddition(item, startIndex) {
56
- return this.findIndexFrom(item, startIndex) === -1;
57
- }
58
- addItem(item, index) {
59
- const operation = {
60
- op: ARRAY_DIFF_OP.ADD,
61
- index,
62
- item
63
- };
64
- this.#oldArray.splice(index, 0, item);
65
- this.#originalIndices.splice(index, 0, -1);
66
- return operation;
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 h(tag, props = {}, children = []) {
160
- const type = typeof tag === 'string' ? DOM_TYPES.ELEMENT : DOM_TYPES.COMPONENT;
161
- return {
162
- tag,
163
- props,
164
- type,
165
- children: mapTextNodes(withoutNulls(children)),
166
- }
167
- }
168
- function hString(str) {
169
- return {
170
- type: DOM_TYPES.TEXT,
171
- value: str
172
- };
173
- }
174
- function hFragment(vNodes) {
175
- return {
176
- children: mapTextNodes(withoutNulls(vNodes)),
177
- type: DOM_TYPES.FRAGMENT,
178
- }
179
- }
180
- function mapTextNodes(children) {
181
- return children.map((child) =>
182
- typeof child === 'string' ? hString(child) : child
183
- )
184
- }
185
- function extractChildren(vNode) {
186
- if (vNode.children == null) return [];
187
- const children = [];
188
- for (const child of vNode.children) {
189
- if (child.type === DOM_TYPES.FRAGMENT) {
190
- children.push(...extractChildren(child));
191
- } else {
192
- children.push(child);
193
- }
194
- }
195
- return children;
196
- }
197
-
198
- let isScheduled = false;
199
- const jobs = [];
200
- function enqueueJob(job) {
201
- jobs.push(job);
202
- scheduleUpdate();
203
- }
204
- function scheduleUpdate() {
205
- if (isScheduled) return;
206
- isScheduled = true;
207
- queueMicrotask(processJobs);
208
- }
209
- function processJobs() {
210
- while (jobs.length > 0) {
211
- const job = jobs.shift();
212
- try {
213
- Promise.resolve(job()).catch((error) => {
214
- console.error(`[scheduler]: ${error}`);
215
- });
216
- } catch (error) {
217
- console.error(`[scheduler]: ${error}`);
218
- }
219
- }
220
- isScheduled = false;
221
- }
222
-
223
- function destroyDOM(vNode) {
224
- const { type } = vNode;
225
- switch (type) {
226
- case DOM_TYPES.TEXT: {
227
- removeTextNode(vNode);
228
- break;
229
- }
230
- case DOM_TYPES.ELEMENT: {
231
- removeElementNode(vNode);
232
- break;
233
- }
234
- case DOM_TYPES.FRAGMENT: {
235
- removeFragmentNode(vNode);
236
- break;
237
- }
238
- case DOM_TYPES.COMPONENT: {
239
- vNode.component.unmount();
240
- enqueueJob(() => vNode.component.onUnmounted());
241
- break;
242
- }
243
- default: {
244
- throw new Error(`Can't destroy virtual node of type: ${vNode.type}`);
245
- }
246
- }
247
- delete vNode.el;
248
- }
249
- function removeTextNode(vNode) {
250
- const { el } = vNode;
251
- el.remove();
252
- }
253
- function removeElementNode(vNode) {
254
- const { el, children, listeners } = vNode;
255
- children.forEach(destroyDOM);
256
- if (listeners) {
257
- removeEventListeners(listeners, el);
258
- delete vNode.listeners;
259
- }
260
- el.remove();
261
- }
262
- function removeFragmentNode(vNode) {
263
- const { children } = vNode;
264
- children.forEach(destroyDOM);
265
- }
266
-
267
- function setAttributes(el, attrs) {
268
- const { class: className, style, ...otherAttrs } = attrs;
269
- if (className) {
270
- setClass(el, className);
271
- }
272
- if (style) {
273
- Object.entries(style).forEach(([prop, value]) => {
274
- setStyle(el, prop, value);
275
- });
276
- }
277
- for (const [name, value] of Object.entries(otherAttrs)) {
278
- setAttribute(el, name, value);
279
- }
280
- }
281
- function setClass(el, className) {
282
- el.className = '';
283
- if (typeof className === 'string') {
284
- el.className = className;
285
- }
286
- if (Array.isArray(className)) {
287
- el.classList.add(...className);
288
- }
289
- }
290
- function setStyle(el, name, value) {
291
- el.style[name] = value;
292
- }
293
- function removeStyle(el, name) {
294
- el.style[name] = null;
295
- }
296
- function setAttribute(el, name, value) {
297
- if (value == null) {
298
- removeAttribute(el, name);
299
- } else if (name.startsWith('data-')) {
300
- el.setAttribute(name, value);
301
- } else {
302
- el[name] = value;
303
- }
304
- }
305
- function removeAttribute(el, name) {
306
- el[name] = null;
307
- el.removeAttribute(name);
308
- }
309
-
310
- function extractPropsAndEvents(vNode) {
311
- const { on: events = {}, ...props } = vNode.props;
312
- delete props.key;
313
- return { props, events }
314
- }
315
-
316
- function mountDOM(vNode, parentEl, index, hostComponent = null) {
317
- switch (vNode.type) {
318
- case DOM_TYPES.TEXT: {
319
- createTextNode(vNode, parentEl, index);
320
- break;
321
- }
322
- case DOM_TYPES.ELEMENT: {
323
- createElementNode(vNode, parentEl, index, hostComponent);
324
- break;
325
- }
326
- case DOM_TYPES.FRAGMENT: {
327
- createFragmentNode(vNode, parentEl, index, hostComponent);
328
- break;
329
- }
330
- case DOM_TYPES.COMPONENT: {
331
- createComponentNode(vNode, parentEl, index, hostComponent);
332
- enqueueJob(() => vNode.component.onMounted());
333
- break;
334
- }
335
- default: {
336
- throw new Error(`Can't mount virtual node of type: ${vNode.type}`);
337
- }
338
- }
339
- }
340
- function createTextNode(vNode, parentEl, index) {
341
- const { value } = vNode;
342
- const textNode = document.createTextNode(value);
343
- vNode.el = textNode;
344
- insert(textNode, parentEl, index);
345
- }
346
- function createElementNode(vNode, parentEl, index, hostComponent) {
347
- const { tag, children } = vNode;
348
- const el = document.createElement(tag);
349
- addProps(el, vNode, hostComponent);
350
- vNode.el = el;
351
- children.forEach((child) => mountDOM(child, el, null, hostComponent));
352
- insert(el, parentEl, index);
353
- }
354
- function createFragmentNode(vNode, parentEl, index, hostComponent) {
355
- const { children } = vNode;
356
- vNode.el = parentEl;
357
- children.forEach((child, i) => {
358
- mountDOM(child, parentEl, index ? index + i : null, hostComponent);
359
- });
360
- }
361
- function createComponentNode(vNode, parentEl, index, hostComponent) {
362
- const Component = vNode.tag;
363
- const { props, events } = extractPropsAndEvents(vNode);
364
- const component = new Component(props, events, hostComponent);
365
- component.mount(parentEl, index);
366
- vNode.component = component;
367
- vNode.el = component.firstElement;
368
- }
369
- function addProps(el, vNode, hostComponent) {
370
- const { props: attrs, events} = extractPropsAndEvents(vNode);
371
- vNode.listeners = addEventListeners(events, el, hostComponent);
372
- setAttributes(el, attrs);
373
- }
374
- function insert(el, parentEl, index) {
375
- if (index == null) {
376
- parentEl.append(el);
377
- return;
378
- }
379
- if (index < 0) {
380
- throw new Error(`Index must be a positive number, got ${index}`);
381
- }
382
- const children = parentEl.childNodes;
383
- if (index >= children.length) {
384
- parentEl.append(el);
385
- } else {
386
- parentEl.insertBefore(el, children[index]);
387
- }
388
- }
389
-
390
- function createApp(RootComponent, props = {}) {
391
- let parentEl = null;
392
- let rootNode = null;
393
- let isMounted = false;
394
- function reset() {
395
- parentEl = null;
396
- rootNode = null;
397
- isMounted = false;
398
- }
399
- return {
400
- mount(_parentEl) {
401
- if (isMounted) throw new Error('The application is already mounted');
402
- parentEl = _parentEl;
403
- rootNode = h(RootComponent, props);
404
- mountDOM(rootNode, parentEl);
405
- isMounted = true;
406
- },
407
- unmount() {
408
- if (!isMounted) throw new Error('The application is not mounted');
409
- destroyDOM(rootNode);
410
- reset();
411
- },
412
- }
413
- }
414
-
415
- function areNodesEqual(nodeOne, nodeTwo) {
416
- if (nodeOne.type !== nodeTwo.type) return false;
417
- if (nodeOne.type === DOM_TYPES.ELEMENT) {
418
- const { tag: tagOne, props: { key: keyOne } } = nodeOne;
419
- const { tag: tagTwo, props: { key: keyTwo } } = nodeTwo;
420
- return tagOne === tagTwo && keyOne === keyTwo;
421
- }
422
- if (nodeOne.type === DOM_TYPES.COMPONENT) {
423
- const { tag: componentOne, props: { key: keyOne } } = nodeOne;
424
- const { tag: componentTwo, props: { key: keyTwo } } = nodeTwo;
425
- return componentOne === componentTwo && keyOne === keyTwo;
426
- }
427
- return true;
428
- }
429
-
430
- function objectsDiff(oldObj, newObj) {
431
- const oldKeys = Object.keys(oldObj);
432
- const newKeys = Object.keys(newObj);
433
- return {
434
- added: newKeys.filter((newKey) => !(newKey in oldObj)),
435
- removed: oldKeys.filter((oldKey) => !(oldKey in newObj)),
436
- updated: newKeys.filter(
437
- (key) => key in oldObj && oldObj[key] !== newObj[key]
438
- ),
439
- }
440
- }
441
- function hasOwnProperty(obj, prop) {
442
- return Object.prototype.hasOwnProperty.call(obj, prop);
443
- }
444
-
445
- function isNotEmptyString(str) {
446
- return str !== '';
447
- }
448
- function isNotBlankOrEmptyString(str) {
449
- return isNotEmptyString(str.trim());
450
- }
451
-
452
- function patchDOM(oldVNode, newVNode, parentEl, hostComponent = null) {
453
- if (!areNodesEqual(oldVNode, newVNode)) {
454
- const index = findIndexInParent(parentEl, oldVNode.el);
455
- destroyDOM(oldVNode);
456
- mountDOM(newVNode, parentEl, index, hostComponent);
457
- return newVNode;
458
- }
459
- newVNode.el = oldVNode.el;
460
- switch (newVNode.type) {
461
- case DOM_TYPES.TEXT: {
462
- patchText(oldVNode, newVNode);
463
- return newVNode;
464
- }
465
- case DOM_TYPES.ELEMENT: {
466
- patchElement(oldVNode, newVNode, hostComponent);
467
- break;
468
- }
469
- case DOM_TYPES.COMPONENT: {
470
- patchComponent(oldVNode, newVNode);
471
- break;
472
- }
473
- }
474
- patchChildren(oldVNode, newVNode, hostComponent);
475
- return newVNode;
476
- }
477
- function findIndexInParent(parentEl, el) {
478
- const index = Array.from(parentEl.childNodes).indexOf(el);
479
- if (index < 0) return null;
480
- return index;
481
- }
482
- function patchText(oldVNode, newVNode) {
483
- const el = oldVNode.el;
484
- const { value: oldText } = oldVNode;
485
- const { value: newText } = newVNode;
486
- if (oldText !== newText) {
487
- el.nodeValue = newText;
488
- }
489
- }
490
- function patchElement(oldVNode, newVNode, hostComponent) {
491
- const el = oldVNode.el;
492
- const {
493
- class: oldClass,
494
- style: oldStyle,
495
- on: oldEvents,
496
- ...oldAttrs
497
- } = oldVNode.props;
498
- const {
499
- class: newClass,
500
- style: newStyle,
501
- on: newEvents,
502
- ...newAttrs
503
- } = newVNode.props;
504
- const { listeners: oldListeners } = oldVNode;
505
- patchAttrs(el, oldAttrs, newAttrs);
506
- patchClasses(el, oldClass, newClass);
507
- patchStyles(el, oldStyle, newStyle);
508
- newVNode.listeners = patchEvents(el, oldListeners, oldEvents, newEvents, hostComponent);
509
- }
510
- function patchComponent(oldVNode, newVNode) {
511
- const { component } = oldVNode;
512
- const { props } = extractPropsAndEvents(newVNode);
513
- component.updateProps(props);
514
- newVNode.component = component;
515
- newVNode.el = component.firstElement;
516
- }
517
- function patchAttrs(el, oldAttrs, newAttrs) {
518
- const { added, removed, updated } = objectsDiff(oldAttrs, newAttrs);
519
- for (const attr of removed) {
520
- removeAttribute(el, attr);
521
- }
522
- for (const attr of added.concat(updated)) {
523
- setAttribute(el, attr, newAttrs[attr]);
524
- }
525
- }
526
- function patchClasses(el, oldClass, newClass) {
527
- const oldClasses = toClassList(oldClass);
528
- const newClasses = toClassList(newClass);
529
- const { added, removed } = arraysDiff(oldClasses, newClasses);
530
- if (removed.length > 0) {
531
- el.classList.remove(...removed);
532
- }
533
- if (added.length > 0) {
534
- el.classList.add(...added);
535
- }
536
- }
537
- function toClassList(classes = '') {
538
- return Array.isArray(classes)
539
- ? classes.filter(isNotBlankOrEmptyString)
540
- : classes.split(/(\s+)/).filter(isNotBlankOrEmptyString);
541
- }
542
- function patchStyles(el, oldStyle = {}, newStyle = {}) {
543
- const { added, removed, updated} = objectsDiff(oldStyle, newStyle);
544
- for (const style of removed) {
545
- removeStyle(el, style);
546
- }
547
- for (const style of added.concat(updated)) {
548
- setStyle(el, style, newStyle[style]);
549
- }
550
- }
551
- function patchEvents(el, oldListeners = {}, oldEvents = {}, newEvents = {}, hostComponent) {
552
- const { removed, added, updated} = objectsDiff(oldEvents, newEvents);
553
- for (const eventName of removed.concat(updated)) {
554
- el.removeEventListener(eventName, oldListeners[eventName]);
555
- }
556
- const addedListeners = {};
557
- for (const eventName of added.concat(updated)) {
558
- addedListeners[eventName] = addEventListener(eventName, newEvents[eventName], el, hostComponent);
559
- }
560
- return addedListeners;
561
- }
562
- function patchChildren(oldVNode, newVNode, hostComponent) {
563
- const oldChildren = extractChildren(oldVNode);
564
- const newChildren = extractChildren(newVNode);
565
- const parentEl = oldVNode.el;
566
- const diffSeq = arraysDiffSequence(oldChildren, newChildren, areNodesEqual);
567
- for (const operation of diffSeq) {
568
- const { originalIndex, from, index, item } = operation;
569
- const offset = hostComponent?.offset ?? 0;
570
- switch (operation.op) {
571
- case ARRAY_DIFF_OP.ADD: {
572
- mountDOM(item, parentEl, index, hostComponent);
573
- break;
574
- }
575
- case ARRAY_DIFF_OP.REMOVE: {
576
- destroyDOM(item);
577
- break;
578
- }
579
- case ARRAY_DIFF_OP.MOVE: {
580
- const el = oldChildren[from].el;
581
- const elAtTargetIndex = parentEl.childNodes[index + offset];
582
- parentEl.insertBefore(el, elAtTargetIndex);
583
- patchDOM(oldChildren[from], newChildren[index], parentEl, hostComponent);
584
- break;
585
- }
586
- case ARRAY_DIFF_OP.NOOP: {
587
- patchDOM(oldChildren[originalIndex], newChildren[index], parentEl, hostComponent);
588
- break;
589
- }
590
- }
591
- }
592
- }
593
-
594
- function getDefaultExportFromCjs (x) {
595
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
596
- }
597
-
598
- var fastDeepEqual;
599
- var hasRequiredFastDeepEqual;
600
- function requireFastDeepEqual () {
601
- if (hasRequiredFastDeepEqual) return fastDeepEqual;
602
- hasRequiredFastDeepEqual = 1;
603
- fastDeepEqual = function equal(a, b) {
604
- if (a === b) return true;
605
- if (a && b && typeof a == 'object' && typeof b == 'object') {
606
- if (a.constructor !== b.constructor) return false;
607
- var length, i, keys;
608
- if (Array.isArray(a)) {
609
- length = a.length;
610
- if (length != b.length) return false;
611
- for (i = length; i-- !== 0;)
612
- if (!equal(a[i], b[i])) return false;
613
- return true;
614
- }
615
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
616
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
617
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
618
- keys = Object.keys(a);
619
- length = keys.length;
620
- if (length !== Object.keys(b).length) return false;
621
- for (i = length; i-- !== 0;)
622
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
623
- for (i = length; i-- !== 0;) {
624
- var key = keys[i];
625
- if (!equal(a[key], b[key])) return false;
626
- }
627
- return true;
628
- }
629
- 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;
630
478
  };
631
- return fastDeepEqual;
632
- }
633
-
634
- var fastDeepEqualExports = requireFastDeepEqual();
635
- var equal = /*@__PURE__*/getDefaultExportFromCjs(fastDeepEqualExports);
636
-
637
- class Dispatcher {
638
- #handlersByCommand = new Map();
639
- #afterHandlers = [];
640
- subscribe(commandName, handler) {
641
- if (!this.#handlersByCommand.has(commandName)) {
642
- this.#handlersByCommand.set(commandName, []);
643
- }
644
- const handlers = this.#handlersByCommand.get(commandName);
645
- if (handlers.includes(handler)) {
646
- return () => {}
647
- }
648
- handlers.push(handler);
649
- return () => {
650
- const index = handlers.indexOf(handler);
651
- handlers.splice(index, 1);
652
- }
653
- }
654
- afterEveryCommand(handler) {
655
- this.#afterHandlers.push(handler);
656
- return () => {
657
- const index = this.#afterHandlers.indexOf(handler);
658
- this.#afterHandlers.splice(index, 1);
659
- }
660
- }
661
- dispatch(commandName, payload) {
662
- if (this.#handlersByCommand.has(commandName)) {
663
- this.#handlersByCommand.get(commandName).forEach((handler) => handler(payload));
664
- } else {
665
- console.warn(`No handlers for command: ${commandName}`);
666
- }
667
- this.#afterHandlers.forEach((handler) => handler());
668
- }
669
- }
670
-
671
- const emptyFn = () => {};
672
- function defineComponent({ render, state, onMounted = emptyFn, onUnmounted = emptyFn, ...methods }) {
673
- class Component {
674
- #isMounted = false;
675
- #vNode = null;
676
- #hostEl = null;
677
- #eventHandlers = null;
678
- #parentComponent = null;
679
- #dispatcher = new Dispatcher();
680
- #subscriptions = [];
681
- constructor(props = {}, eventHandlers = {}, parentComponent = null) {
682
- this.props = props;
683
- this.state = state ? state(props) : {};
684
- this.#eventHandlers = eventHandlers;
685
- this.#parentComponent = parentComponent;
686
- }
687
- onMounted() {
688
- return Promise.resolve(onMounted.call(this));
689
- }
690
- onUnmounted() {
691
- return Promise.resolve(onUnmounted.call(this));
692
- }
693
- get elements() {
694
- if (this.#vNode == null) {
695
- return [];
696
- }
697
- if (this.#vNode.type === DOM_TYPES.FRAGMENT) {
698
- return extractChildren(this.#vNode).flatMap((child) => {
699
- if (child.type === DOM_TYPES.COMPONENT) {
700
- return child.component.elements;
701
- }
702
- return [child.el];
703
- });
704
- }
705
- return [this.#vNode.el];
706
- }
707
- get firstElement() {
708
- return this.elements[0];
709
- }
710
- get offset() {
711
- if(this.#vNode.type === DOM_TYPES.FRAGMENT) {
712
- return Array.from(this.#hostEl.children).indexOf(this.firstElement);
713
- }
714
- return 0;
715
- }
716
- updateProps(props) {
717
- const newProps = { ...this.props, ...props };
718
- if (equal(this.props, newProps)) {
719
- return;
720
- }
721
- this.props = newProps;
722
- this.#patch();
723
- }
724
- updateState(state) {
725
- this.state = { ...this.state, ...state };
726
- this.#patch();
727
- }
728
- render() {
729
- return render.call(this);
730
- }
731
- emit(eventName, payload) {
732
- this.#dispatcher.dispatch(eventName, payload);
733
- }
734
- mount(hostEl, index = null) {
735
- if (this.#isMounted) {
736
- throw new Error('Component is already mounted');
737
- }
738
- this.#vNode = this.render();
739
- mountDOM(this.#vNode, hostEl, index, this);
740
- this.#wireEventHandlers();
741
- this.#hostEl = hostEl;
742
- this.#isMounted = true;
743
- }
744
- unmount() {
745
- if (!this.#isMounted) {
746
- throw new Error('Component is not mounted');
747
- }
748
- destroyDOM(this.#vNode);
749
- this.#subscriptions.forEach((unsubscribe) => unsubscribe());
750
- this.#vNode = null;
751
- this.#hostEl = null;
752
- this.#isMounted = false;
753
- this.#subscriptions = [];
754
- }
755
- #patch() {
756
- if (!this.#isMounted) {
757
- throw new Error('Component is not mounted');
758
- }
759
- const vNode = this.render();
760
- this.#vNode = patchDOM(this.#vNode, vNode, this.#hostEl, this);
761
- }
762
- #wireEventHandlers() {
763
- this.#subscriptions = Object.entries(this.#eventHandlers).map(
764
- ([eventName, handler]) =>
765
- this.#wireEventHandler(eventName, handler)
766
- );
767
- }
768
- #wireEventHandler(eventName, handler) {
769
- return this.#dispatcher.subscribe(eventName, (payload) => {
770
- if (this.#parentComponent) {
771
- handler.call(this.#parentComponent, payload);
772
- } else {
773
- handler(payload);
774
- }
775
- })
776
- }
777
- }
778
- for (const methodName in methods) {
779
- if (hasOwnProperty(Component, methodName)) {
780
- throw new Error(`Method "${methodName}()" already exists in the component.`);
781
- }
782
- Component.prototype[methodName] = methods[methodName];
783
- }
784
- return Component;
785
- }
786
-
787
- export { createApp, defineComponent, h, hFragment, hString };
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 };