@unsetsoft/ryunixjs 1.1.6-canary.4 → 1.1.6-canary.7
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/Ryunix.js +144 -107
- package/dist/Ryunix.min.js +1 -1
- package/package.json +1 -1
package/dist/Ryunix.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Ryunix = {}));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Ryunix = {}, global.lodash));
|
|
5
|
+
})(this, (function (exports, lodash) { 'use strict';
|
|
6
6
|
|
|
7
7
|
let vars = {
|
|
8
8
|
containerRoot: {},
|
|
@@ -37,37 +37,31 @@
|
|
|
37
37
|
string: 'string',
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
const OLD_STRINGS = Object.freeze({
|
|
41
|
+
style: 'style',
|
|
42
|
+
className: 'className',
|
|
43
|
+
});
|
|
44
|
+
|
|
40
45
|
const EFFECT_TAGS = Object.freeze({
|
|
41
46
|
PLACEMENT: Symbol('ryunix.reconciler.status.placement').toString(),
|
|
42
47
|
UPDATE: Symbol('ryunix.reconciler.status.update').toString(),
|
|
43
48
|
DELETION: Symbol('ryunix.reconciler.status.deletion').toString(),
|
|
44
49
|
});
|
|
45
50
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
49
|
-
if (arr1[i] !== arr2[i]) return false
|
|
50
|
-
}
|
|
51
|
-
return true
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const resolveProps = (props) => {
|
|
55
|
-
const resolvedProps = {};
|
|
56
|
-
for (const key in props) {
|
|
57
|
-
resolvedProps[key] =
|
|
58
|
-
typeof props[key] === STRINGS.function ? props[key]() : props[key];
|
|
59
|
-
}
|
|
60
|
-
return resolvedProps
|
|
51
|
+
const generateHash = (prefix) => {
|
|
52
|
+
return `${prefix}-${Math.random().toString(36).substring(2, 9)}`
|
|
61
53
|
};
|
|
62
54
|
|
|
63
55
|
const Fragment = (props) => {
|
|
64
56
|
return props.children
|
|
65
57
|
};
|
|
66
58
|
|
|
67
|
-
const childArray = (children, out
|
|
68
|
-
|
|
69
|
-
if (Array.isArray(children)) {
|
|
70
|
-
children.
|
|
59
|
+
const childArray = (children, out) => {
|
|
60
|
+
out = out || [];
|
|
61
|
+
if (children == undefined || typeof children == STRINGS.boolean) ; else if (Array.isArray(children)) {
|
|
62
|
+
children.some((child) => {
|
|
63
|
+
childArray(child, out);
|
|
64
|
+
});
|
|
71
65
|
} else {
|
|
72
66
|
out.push(children);
|
|
73
67
|
}
|
|
@@ -92,18 +86,18 @@
|
|
|
92
86
|
*/
|
|
93
87
|
|
|
94
88
|
const createElement = (type, props, ...children) => {
|
|
95
|
-
|
|
96
|
-
resolvedProps.children = childArray(children, []);
|
|
89
|
+
children = childArray(children, []);
|
|
97
90
|
const key =
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
props && props.key
|
|
92
|
+
? generateHash(props.key)
|
|
93
|
+
: generateHash(RYUNIX_TYPES.Ryunix_ELEMENT.toString());
|
|
100
94
|
|
|
101
95
|
return {
|
|
102
96
|
type,
|
|
103
97
|
props: {
|
|
104
|
-
...
|
|
98
|
+
...props,
|
|
105
99
|
key,
|
|
106
|
-
children:
|
|
100
|
+
children: children.map((child) =>
|
|
107
101
|
typeof child === STRINGS.object ? child : createTextElement(child),
|
|
108
102
|
),
|
|
109
103
|
},
|
|
@@ -219,53 +213,77 @@
|
|
|
219
213
|
*/
|
|
220
214
|
|
|
221
215
|
const useEffect = (callback, deps) => {
|
|
222
|
-
const oldHook =
|
|
216
|
+
const oldHook =
|
|
217
|
+
vars.wipFiber.alternate &&
|
|
218
|
+
vars.wipFiber.alternate.hooks &&
|
|
219
|
+
vars.wipFiber.alternate.hooks[vars.hookIndex];
|
|
220
|
+
|
|
223
221
|
const hook = {
|
|
224
222
|
type: RYUNIX_TYPES.RYUNIX_EFFECT,
|
|
225
223
|
deps,
|
|
226
|
-
cleanup: oldHook?.cleanup,
|
|
227
224
|
};
|
|
228
225
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
226
|
+
if (!oldHook) {
|
|
227
|
+
// invoke callback if this is the first time
|
|
228
|
+
callback();
|
|
229
|
+
} else {
|
|
230
|
+
if (!lodash.isEqual(oldHook.deps, hook.deps)) {
|
|
231
|
+
callback();
|
|
232
|
+
}
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
if (
|
|
236
|
-
|
|
235
|
+
if (vars.wipFiber.hooks) {
|
|
236
|
+
vars.wipFiber.hooks.push(hook);
|
|
237
|
+
vars.hookIndex++;
|
|
237
238
|
}
|
|
238
|
-
|
|
239
|
-
vars.wipFiber.hooks.push(hook);
|
|
240
|
-
vars.hookIndex++;
|
|
241
239
|
};
|
|
242
240
|
|
|
243
241
|
const useRef = (initial) => {
|
|
244
|
-
const oldHook =
|
|
242
|
+
const oldHook =
|
|
243
|
+
vars.wipFiber.alternate &&
|
|
244
|
+
vars.wipFiber.alternate.hooks &&
|
|
245
|
+
vars.wipFiber.alternate.hooks[vars.hookIndex];
|
|
246
|
+
|
|
245
247
|
const hook = {
|
|
246
248
|
type: RYUNIX_TYPES.RYUNIX_REF,
|
|
247
249
|
value: oldHook ? oldHook.value : { current: initial },
|
|
248
250
|
};
|
|
249
251
|
|
|
250
|
-
vars.wipFiber.hooks
|
|
251
|
-
|
|
252
|
+
if (vars.wipFiber.hooks) {
|
|
253
|
+
vars.wipFiber.hooks.push(hook);
|
|
254
|
+
vars.hookIndex++;
|
|
255
|
+
}
|
|
256
|
+
|
|
252
257
|
return hook.value
|
|
253
258
|
};
|
|
254
259
|
|
|
255
|
-
const useMemo = (
|
|
256
|
-
const oldHook =
|
|
260
|
+
const useMemo = (comp, deps) => {
|
|
261
|
+
const oldHook =
|
|
262
|
+
vars.wipFiber.alternate &&
|
|
263
|
+
vars.wipFiber.alternate.hooks &&
|
|
264
|
+
vars.wipFiber.alternate.hooks[vars.hookIndex];
|
|
265
|
+
|
|
257
266
|
const hook = {
|
|
258
267
|
type: RYUNIX_TYPES.RYUNIX_MEMO,
|
|
259
|
-
value:
|
|
268
|
+
value: null,
|
|
260
269
|
deps,
|
|
261
270
|
};
|
|
262
271
|
|
|
263
|
-
if (
|
|
264
|
-
hook.
|
|
272
|
+
if (oldHook) {
|
|
273
|
+
if (lodash.isEqual(oldHook.deps, hook.deps)) {
|
|
274
|
+
hook.value = oldHook.value;
|
|
275
|
+
} else {
|
|
276
|
+
hook.value = comp();
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
hook.value = comp();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (vars.wipFiber.hooks) {
|
|
283
|
+
vars.wipFiber.hooks.push(hook);
|
|
284
|
+
vars.hookIndex++;
|
|
265
285
|
}
|
|
266
286
|
|
|
267
|
-
vars.wipFiber.hooks.push(hook);
|
|
268
|
-
vars.hookIndex++;
|
|
269
287
|
return hook.value
|
|
270
288
|
};
|
|
271
289
|
|
|
@@ -462,12 +480,13 @@
|
|
|
462
480
|
* "cancelEffects" is likely intended
|
|
463
481
|
*/
|
|
464
482
|
const cancelEffects = (fiber) => {
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
483
|
+
if (fiber.hooks) {
|
|
484
|
+
fiber.hooks
|
|
485
|
+
.filter((hook) => hook.tag === RYUNIX_TYPES.RYUNIX_EFFECT && hook.cancel)
|
|
486
|
+
.forEach((effectHook) => {
|
|
487
|
+
effectHook.cancel();
|
|
488
|
+
});
|
|
489
|
+
}
|
|
471
490
|
};
|
|
472
491
|
|
|
473
492
|
/**
|
|
@@ -478,12 +497,13 @@
|
|
|
478
497
|
* contains information about a component and its children, as
|
|
479
498
|
*/
|
|
480
499
|
const runEffects = (fiber) => {
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
500
|
+
if (fiber.hooks) {
|
|
501
|
+
fiber.hooks
|
|
502
|
+
.filter((hook) => hook.tag === RYUNIX_TYPES.RYUNIX_EFFECT && hook.effect)
|
|
503
|
+
.forEach((effectHook) => {
|
|
504
|
+
effectHook.cancel = effectHook.effect();
|
|
505
|
+
});
|
|
506
|
+
}
|
|
487
507
|
};
|
|
488
508
|
|
|
489
509
|
/**
|
|
@@ -498,14 +518,15 @@
|
|
|
498
518
|
*/
|
|
499
519
|
const createDom = (fiber) => {
|
|
500
520
|
const dom =
|
|
501
|
-
fiber.type
|
|
502
|
-
? document.createTextNode(
|
|
521
|
+
fiber.type == RYUNIX_TYPES.TEXT_ELEMENT
|
|
522
|
+
? document.createTextNode('')
|
|
503
523
|
: document.createElement(fiber.type);
|
|
504
524
|
|
|
505
525
|
updateDom(dom, {}, fiber.props);
|
|
506
526
|
|
|
507
527
|
return dom
|
|
508
528
|
};
|
|
529
|
+
|
|
509
530
|
/**
|
|
510
531
|
* The function updates the DOM by removing old event listeners and properties, and adding new ones
|
|
511
532
|
* based on the previous and next props.
|
|
@@ -522,14 +543,6 @@
|
|
|
522
543
|
dom.removeEventListener(eventType, prevProps[name]);
|
|
523
544
|
});
|
|
524
545
|
|
|
525
|
-
Object.keys(nextProps)
|
|
526
|
-
.filter(isEvent)
|
|
527
|
-
.filter(isNew(prevProps, nextProps))
|
|
528
|
-
.forEach((name) => {
|
|
529
|
-
const eventType = name.toLowerCase().substring(2);
|
|
530
|
-
dom.addEventListener(eventType, nextProps[name]);
|
|
531
|
-
});
|
|
532
|
-
|
|
533
546
|
Object.keys(prevProps)
|
|
534
547
|
.filter(isProperty)
|
|
535
548
|
.filter(isGone(nextProps))
|
|
@@ -542,24 +555,47 @@
|
|
|
542
555
|
.filter(isNew(prevProps, nextProps))
|
|
543
556
|
.forEach((name) => {
|
|
544
557
|
if (name === STRINGS.style) {
|
|
545
|
-
DomStyle(dom, nextProps[
|
|
558
|
+
DomStyle(dom, nextProps['ryunix-style']);
|
|
559
|
+
} else if (name === OLD_STRINGS.style) {
|
|
560
|
+
DomStyle(dom, nextProps.style);
|
|
546
561
|
} else if (name === STRINGS.className) {
|
|
547
|
-
if (nextProps[
|
|
548
|
-
|
|
562
|
+
if (nextProps['ryunix-class'] === '') {
|
|
563
|
+
throw new Error('data-class cannot be empty.')
|
|
549
564
|
}
|
|
565
|
+
|
|
566
|
+
prevProps['ryunix-class'] &&
|
|
567
|
+
dom.classList.remove(...prevProps['ryunix-class'].split(/\s+/));
|
|
568
|
+
dom.classList.add(...nextProps['ryunix-class'].split(/\s+/));
|
|
569
|
+
} else if (name === OLD_STRINGS.className) {
|
|
570
|
+
if (nextProps.className === '') {
|
|
571
|
+
throw new Error('className cannot be empty.')
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
prevProps.className &&
|
|
575
|
+
dom.classList.remove(...prevProps.className.split(/\s+/));
|
|
576
|
+
dom.classList.add(...nextProps.className.split(/\s+/));
|
|
550
577
|
} else {
|
|
551
578
|
dom[name] = nextProps[name];
|
|
552
579
|
}
|
|
553
580
|
});
|
|
581
|
+
|
|
582
|
+
Object.keys(nextProps)
|
|
583
|
+
.filter(isEvent)
|
|
584
|
+
.filter(isNew(prevProps, nextProps))
|
|
585
|
+
.forEach((name) => {
|
|
586
|
+
const eventType = name.toLowerCase().substring(2);
|
|
587
|
+
dom.addEventListener(eventType, nextProps[name]);
|
|
588
|
+
});
|
|
554
589
|
};
|
|
555
590
|
|
|
556
591
|
const DomStyle = (dom, style) => {
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
|
|
592
|
+
dom.style = Object.keys(style).reduce((acc, styleName) => {
|
|
593
|
+
const key = styleName.replace(reg, function (v) {
|
|
594
|
+
return '-' + v.toLowerCase()
|
|
595
|
+
});
|
|
596
|
+
acc += `${key}: ${style[styleName]};`;
|
|
597
|
+
return acc
|
|
598
|
+
}, '');
|
|
563
599
|
};
|
|
564
600
|
|
|
565
601
|
var Dom = /*#__PURE__*/Object.freeze({
|
|
@@ -578,7 +614,7 @@
|
|
|
578
614
|
commitWork(vars.wipRoot.child);
|
|
579
615
|
vars.currentRoot = vars.wipRoot;
|
|
580
616
|
}
|
|
581
|
-
vars.wipRoot =
|
|
617
|
+
vars.wipRoot = undefined;
|
|
582
618
|
};
|
|
583
619
|
|
|
584
620
|
/**
|
|
@@ -592,15 +628,15 @@
|
|
|
592
628
|
if (!fiber) return
|
|
593
629
|
|
|
594
630
|
let domParentFiber = fiber.parent;
|
|
595
|
-
while (
|
|
631
|
+
while (!domParentFiber.dom) {
|
|
596
632
|
domParentFiber = domParentFiber.parent;
|
|
597
633
|
}
|
|
598
|
-
const domParent = domParentFiber
|
|
634
|
+
const domParent = domParentFiber.dom;
|
|
599
635
|
|
|
600
|
-
if (fiber.effectTag === EFFECT_TAGS.PLACEMENT && fiber.dom) {
|
|
636
|
+
if (fiber.effectTag === EFFECT_TAGS.PLACEMENT && fiber.dom != null) {
|
|
601
637
|
domParent.appendChild(fiber.dom);
|
|
602
638
|
runEffects(fiber);
|
|
603
|
-
} else if (fiber.effectTag === EFFECT_TAGS.UPDATE && fiber.dom) {
|
|
639
|
+
} else if (fiber.effectTag === EFFECT_TAGS.UPDATE && fiber.dom != null) {
|
|
604
640
|
cancelEffects(fiber);
|
|
605
641
|
updateDom(fiber.dom, fiber.alternate.props, fiber.props);
|
|
606
642
|
runEffects(fiber);
|
|
@@ -610,6 +646,7 @@
|
|
|
610
646
|
return
|
|
611
647
|
}
|
|
612
648
|
|
|
649
|
+
// Recorre los "fibers" hijos y hermanos
|
|
613
650
|
commitWork(fiber.child);
|
|
614
651
|
commitWork(fiber.sibling);
|
|
615
652
|
};
|
|
@@ -624,12 +661,9 @@
|
|
|
624
661
|
const commitDeletion = (fiber, domParent) => {
|
|
625
662
|
if (fiber.dom) {
|
|
626
663
|
domParent.removeChild(fiber.dom);
|
|
627
|
-
} else
|
|
664
|
+
} else {
|
|
628
665
|
commitDeletion(fiber.child, domParent);
|
|
629
666
|
}
|
|
630
|
-
if (fiber.sibling) {
|
|
631
|
-
commitDeletion(fiber.sibling, domParent);
|
|
632
|
-
}
|
|
633
667
|
};
|
|
634
668
|
|
|
635
669
|
var Commits = /*#__PURE__*/Object.freeze({
|
|
@@ -648,16 +682,15 @@
|
|
|
648
682
|
* @param elements - an array of elements representing the new children to be rendered in the current
|
|
649
683
|
* fiber's subtree
|
|
650
684
|
*/
|
|
651
|
-
|
|
652
685
|
const reconcileChildren = (wipFiber, elements) => {
|
|
653
686
|
let index = 0;
|
|
687
|
+
let oldFiber = wipFiber.alternate && wipFiber.alternate.child;
|
|
654
688
|
let prevSibling = null;
|
|
655
|
-
const oldFibersMap = new Map();
|
|
656
689
|
|
|
657
|
-
|
|
690
|
+
const oldFibersMap = new Map();
|
|
658
691
|
while (oldFiber) {
|
|
659
|
-
const
|
|
660
|
-
oldFibersMap.set(
|
|
692
|
+
const oldKey = oldFiber.props.key || oldFiber.type;
|
|
693
|
+
oldFibersMap.set(oldKey, oldFiber);
|
|
661
694
|
oldFiber = oldFiber.sibling;
|
|
662
695
|
}
|
|
663
696
|
|
|
@@ -669,12 +702,13 @@
|
|
|
669
702
|
let newFiber;
|
|
670
703
|
const sameType = oldFiber && element && element.type === oldFiber.type;
|
|
671
704
|
|
|
672
|
-
if (sameType
|
|
673
|
-
newFiber = oldFiber;
|
|
674
|
-
} else if (sameType) {
|
|
705
|
+
if (sameType) {
|
|
675
706
|
newFiber = {
|
|
676
|
-
|
|
707
|
+
type: oldFiber.type,
|
|
677
708
|
props: element.props,
|
|
709
|
+
dom: oldFiber.dom,
|
|
710
|
+
parent: wipFiber,
|
|
711
|
+
alternate: oldFiber,
|
|
678
712
|
effectTag: EFFECT_TAGS.UPDATE,
|
|
679
713
|
};
|
|
680
714
|
oldFibersMap.delete(key);
|
|
@@ -682,8 +716,10 @@
|
|
|
682
716
|
newFiber = {
|
|
683
717
|
type: element.type,
|
|
684
718
|
props: element.props,
|
|
685
|
-
|
|
719
|
+
dom: undefined,
|
|
686
720
|
parent: wipFiber,
|
|
721
|
+
alternate: undefined,
|
|
722
|
+
effectTag: EFFECT_TAGS.PLACEMENT,
|
|
687
723
|
};
|
|
688
724
|
}
|
|
689
725
|
|
|
@@ -721,7 +757,9 @@
|
|
|
721
757
|
vars.wipFiber.hooks = [];
|
|
722
758
|
|
|
723
759
|
const children = fiber.type(fiber.props);
|
|
724
|
-
|
|
760
|
+
let childArr = Array.isArray(children) ? children : [children];
|
|
761
|
+
|
|
762
|
+
reconcileChildren(fiber, childArr);
|
|
725
763
|
};
|
|
726
764
|
|
|
727
765
|
/**
|
|
@@ -762,9 +800,7 @@
|
|
|
762
800
|
commitRoot();
|
|
763
801
|
}
|
|
764
802
|
|
|
765
|
-
|
|
766
|
-
requestIdleCallback(workLoop);
|
|
767
|
-
}
|
|
803
|
+
requestIdleCallback(workLoop);
|
|
768
804
|
};
|
|
769
805
|
|
|
770
806
|
requestIdleCallback(workLoop);
|
|
@@ -788,9 +824,9 @@
|
|
|
788
824
|
} else {
|
|
789
825
|
updateHostComponent(fiber);
|
|
790
826
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
827
|
+
if (fiber.child) {
|
|
828
|
+
return fiber.child
|
|
829
|
+
}
|
|
794
830
|
let nextFiber = fiber;
|
|
795
831
|
while (nextFiber) {
|
|
796
832
|
if (nextFiber.sibling) {
|
|
@@ -798,6 +834,7 @@
|
|
|
798
834
|
}
|
|
799
835
|
nextFiber = nextFiber.parent;
|
|
800
836
|
}
|
|
837
|
+
return undefined
|
|
801
838
|
};
|
|
802
839
|
|
|
803
840
|
var Workers = /*#__PURE__*/Object.freeze({
|
package/dist/Ryunix.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={})}(this,(function(e){"use strict";let
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={},e.lodash)}(this,(function(e,t){"use strict";let o={containerRoot:{},nextUnitOfWork:{},currentRoot:{},wipRoot:{},deletions:[],wipFiber:{},hookIndex:0};const n=/[A-Z]/g,r=Object.freeze({TEXT_ELEMENT:Symbol("text.element"),Ryunix_ELEMENT:Symbol("ryunix.element"),RYUNIX_EFFECT:Symbol("ryunix.effect"),RYUNIX_MEMO:Symbol("ryunix.memo"),RYUNIX_URL_QUERY:Symbol("ryunix.urlQuery"),RYUNIX_REF:Symbol("ryunix.ref"),RYUNIX_STORE:Symbol("ryunix.store"),RYUNIX_REDUCE:Symbol("ryunix.reduce")}),i=Object.freeze({object:"object",function:"function",style:"ryunix-style",className:"ryunix-class",children:"children",boolean:"boolean",string:"string"}),s=Object.freeze({style:"style",className:"className"}),a=Object.freeze({PLACEMENT:Symbol("ryunix.reconciler.status.placement").toString(),UPDATE:Symbol("ryunix.reconciler.status.update").toString(),DELETION:Symbol("ryunix.reconciler.status.deletion").toString()}),l=e=>`${e}-${Math.random().toString(36).substring(2,9)}`,c=(e,t)=>(t=t||[],null==e||typeof e==i.boolean||(Array.isArray(e)?e.some((e=>{c(e,t)})):t.push(e)),t),p=(e,t,...o)=>{o=c(o,[]);const n=t&&t.key?l(t.key):l(r.Ryunix_ELEMENT.toString());return{type:e,props:{...t,key:n,children:o.map((e=>typeof e===i.object?e:u(e)))}}},u=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),d=(e,t)=>{o.wipRoot={dom:t,props:{children:[e]},alternate:o.currentRoot},o.deletions=[],o.nextUnitOfWork=o.wipRoot},f=e=>{const t=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],n={state:t?t.state:e,queue:t?[...t.queue]:[]};n.queue.forEach((e=>{n.state=typeof e===i.function?e(n.state):e})),n.queue=[];return o.wipFiber&&o.wipFiber.hooks&&(o.wipFiber.hooks.push(n),o.hookIndex++),[n.state,e=>{n.queue.push(e),o.wipRoot={dom:o.currentRoot.dom,props:{...o.currentRoot.props},alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[]}]},m=(e,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:r.RYUNIX_EFFECT,deps:n};i&&t.isEqual(i.deps,s.deps)||e(),o.wipFiber.hooks&&(o.wipFiber.hooks.push(s),o.hookIndex++)},h=(e,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:r.RYUNIX_MEMO,value:null,deps:n};return i&&t.isEqual(i.deps,s.deps)?s.value=i.value:s.value=e(),o.wipFiber.hooks&&(o.wipFiber.hooks.push(s),o.hookIndex++),s.value},y=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t},b=e=>e.startsWith("on"),E=e=>e!==i.children&&!b(e),w=(e,t)=>o=>e[o]!==t[o],k=e=>t=>!(t in e),R=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},x=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},F=e=>{const t=e.type==r.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return _(t,{},e.props),t},_=(e,t,o)=>{Object.keys(t).filter(b).filter((e=>k(o)(e)||w(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(E).filter(k(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(E).filter(w(t,o)).forEach((n=>{if(n===i.style)N(e,o["ryunix-style"]);else if(n===s.style)N(e,o.style);else if(n===i.className){if(""===o["ryunix-class"])throw new Error("data-class cannot be empty.");t["ryunix-class"]&&e.classList.remove(...t["ryunix-class"].split(/\s+/)),e.classList.add(...o["ryunix-class"].split(/\s+/))}else if(n===s.className){if(""===o.className)throw new Error("className cannot be empty.");t.className&&e.classList.remove(...t.className.split(/\s+/)),e.classList.add(...o.className.split(/\s+/))}else e[n]=o[n]})),Object.keys(o).filter(b).filter(w(t,o)).forEach((t=>{const n=t.toLowerCase().substring(2);e.addEventListener(n,o[t])}))},N=(e,t)=>{e.style=Object.keys(t).reduce(((e,o)=>e+=`${o.replace(n,(function(e){return"-"+e.toLowerCase()}))}: ${t[o]};`),"")};var g=Object.freeze({__proto__:null,DomStyle:N,createDom:F,updateDom:_});const T=()=>{o.deletions.forEach(v),o.wipRoot&&o.wipRoot.child&&(v(o.wipRoot.child),o.currentRoot=o.wipRoot),o.wipRoot=void 0},v=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const o=t.dom;if(e.effectTag===a.PLACEMENT&&null!=e.dom)o.appendChild(e.dom),x(e);else if(e.effectTag===a.UPDATE&&null!=e.dom)R(e),_(e.dom,e.alternate.props,e.props),x(e);else if(e.effectTag===a.DELETION)return O(e,o),void R(e);v(e.child),v(e.sibling)},O=(e,t)=>{e.dom?t.removeChild(e.dom):O(e.child,t)};var I=Object.freeze({__proto__:null,commitDeletion:O,commitRoot:T,commitWork:v});const L=(e,t)=>{let n=0,r=e.alternate&&e.alternate.child,i=null;const s=new Map;for(;r;){const e=r.props.key||r.type;s.set(e,r),r=r.sibling}for(;n<t.length;){const o=t[n],r=o.props.key||o.type,l=s.get(r);let c;l&&o&&o.type===l.type?(c={type:l.type,props:o.props,dom:l.dom,parent:e,alternate:l,effectTag:a.UPDATE},s.delete(r)):o&&(c={type:o.type,props:o.props,dom:void 0,parent:e,alternate:void 0,effectTag:a.PLACEMENT}),0===n?e.child=c:i&&(i.sibling=c),i=c,n++}s.forEach((e=>{e.effectTag=a.DELETION,o.deletions.push(e)}))};var U=Object.freeze({__proto__:null,reconcileChildren:L});const C=e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=e.type(e.props);let n=Array.isArray(t)?t:[t];L(e,n)},S=e=>{e.dom||(e.dom=F(e)),L(e,e.props.children)};var j=Object.freeze({__proto__:null,updateFunctionComponent:C,updateHostComponent:S});const M=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=X(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&T(),requestIdleCallback(M)};requestIdleCallback(M);const X=e=>{if(e.type instanceof Function?C(e):S(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}};var D={createElement:p,render:d,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t),d(e,o.containerRoot)},Fragment:e=>e.children,Dom:g,Workers:Object.freeze({__proto__:null,performUnitOfWork:X,workLoop:M}),Reconciler:U,Components:j,Commits:I};window.Ryunix=D,e.default=D,e.useCallback=(e,t)=>h((()=>e),t),e.useEffect=m,e.useMemo=h,e.useQuery=y,e.useRef=e=>{const t=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],n={type:r.RYUNIX_REF,value:t?t.value:{current:e}};return o.wipFiber.hooks&&(o.wipFiber.hooks.push(n),o.hookIndex++),n.value},e.useRouter=e=>{const[t,o]=f(window.location.pathname),n=(e,t)=>{const o=t.split("?")[0],r=e.find((e=>e.NotFound)),i=r?{route:{component:r.NotFound},params:{}}:{route:{component:null},params:{}};for(const r of e){if(r.subRoutes){const e=n(r.subRoutes,t);if(e)return e}if("*"===r.path)return i;if(!r.path||"string"!=typeof r.path){console.warn("Invalid route detected:",r),console.info("if you are using { NotFound: NotFound } please add { path: '*', NotFound: NotFound }");continue}const e=[],s=new RegExp(`^${r.path.replace(/:\w+/g,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),a=o.match(s);if(a){return{route:r,params:e.reduce(((e,t,o)=>(e[t]=a[o+1],e)),{})}}}return i},r=e=>{window.history.pushState({},"",e),s(e)},s=e=>{const t=e.split("?")[0];o(t)};m((()=>{const e=()=>s(window.location.pathname);return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const a=n(e,t)||{};return{Children:()=>{const e=y(),{route:t}=a;return t&&t.component&&typeof t.component===i.function?t.component({params:a.params||{},query:e}):(console.error("Component not found for current path or the component is not a valid function:",a),null)},NavLink:({to:e,...t})=>p("a",{href:e,onClick:t=>{t.preventDefault(),r(e)},...t},t.children),navigate:r}},e.useStore=f,Object.defineProperty(e,"__esModule",{value:!0})}));
|