lilact 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lilact.development.js +124 -50
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +20 -20
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +22 -22
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/accessories.ErrorBoundary.html +8 -8
- package/docs/classes/accessories.Suspense.html +7 -7
- package/docs/classes/components.Component.html +11 -11
- package/docs/classes/components.HTMLComponent.html +11 -11
- package/docs/classes/components.RootComponent.html +11 -11
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/hooks.startTransition.html +6 -0
- package/docs/functions/hooks.useActionState.html +1 -1
- package/docs/functions/hooks.useDebugValue.html +5 -0
- package/docs/functions/hooks.useDeferredValue.html +1 -1
- package/docs/functions/hooks.useEffect.html +4 -4
- package/docs/functions/hooks.useImperativeHandle.html +1 -1
- package/docs/functions/hooks.useInsertionEffect.html +5 -0
- package/docs/functions/hooks.useLayoutEffect.html +2 -2
- package/docs/functions/hooks.useMemo.html +3 -3
- package/docs/functions/hooks.useReducer.html +1 -1
- package/docs/functions/misc.Fragment.html +2 -2
- package/docs/functions/misc.deepEqual.html +1 -1
- package/docs/functions/misc.findDOMNode.html +1 -1
- package/docs/functions/misc.forwardRef.html +1 -1
- package/docs/functions/misc.getComponentByPointer.html +1 -1
- package/docs/functions/misc.isAsync.html +1 -1
- package/docs/functions/misc.isClass.html +1 -1
- package/docs/functions/misc.isEmpty.html +1 -1
- package/docs/functions/misc.isError.html +1 -1
- package/docs/functions/misc.isThenable.html +1 -1
- package/docs/functions/{misc.isValidElement.html → misc.isValidComponent.html} +1 -1
- package/docs/functions/misc.shallowEqual.html +1 -1
- package/docs/functions/misc.toBool.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +9 -6
- package/docs/hierarchy.html +1 -1
- package/docs/modules/hooks.html +1 -1
- package/docs/modules/misc.html +1 -1
- package/docs/static/demos/actionstate.jsx +2 -2
- package/docs/static/demos/priorities.jsx +68 -0
- package/docs/static/index.html +2 -1
- package/docs/static/lilact.development.js +124 -50
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +20 -20
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +22 -22
- package/docs/variables/misc.Children.html +2 -2
- package/docs/variables/misc.isValidElement.html +7 -0
- package/examples/demos/actionstate.jsx +2 -2
- package/examples/demos/priorities.jsx +68 -0
- package/examples/index.html +2 -1
- package/examples/lilact.development.js +124 -50
- package/examples/lilact.development.js.map +3 -3
- package/examples/lilact.development.min.js +20 -20
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +22 -22
- package/package.json +1 -1
- package/src/accessories.jsx +232 -233
- package/src/components.jsx +87 -20
- package/src/hooks.jsx +80 -11
- package/src/lilact.jsx +1 -1
- package/src/misc.jsx +9 -5
package/src/accessories.jsx
CHANGED
|
@@ -51,44 +51,44 @@ const {css,cx} = emotion;
|
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
53
|
export function Spinner({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
size = 48,
|
|
55
|
+
className,
|
|
56
|
+
style,
|
|
57
|
+
color = "currentColor",
|
|
58
|
+
strokeWidth = 3,
|
|
59
|
+
"aria-label": ariaLabel = "Loading",
|
|
60
60
|
}) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
61
|
+
const s = Math.max(1, size)+"px";
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
className={className}
|
|
66
|
+
style={{
|
|
67
|
+
width: "100%",
|
|
68
|
+
height: "100%",
|
|
69
|
+
display: "grid",
|
|
70
|
+
placeItems: "center",
|
|
71
|
+
...style,
|
|
72
|
+
}}
|
|
73
|
+
aria-label={ariaLabel}
|
|
74
|
+
role="status"
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
style={{
|
|
78
|
+
width: s,
|
|
79
|
+
height: s,
|
|
80
|
+
borderRadius: "50%",
|
|
81
|
+
border: `${strokeWidth}px solid rgba(0,0,0,0.15)`,
|
|
82
|
+
borderTopColor: color,
|
|
83
|
+
animation: "ddSpinnerSpin 0.9s linear infinite",
|
|
84
|
+
boxSizing: "border-box",
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
<style>{`
|
|
88
|
+
@keyframes ddSpinnerSpin { to { transform: rotate(360deg); } }
|
|
89
|
+
`}</style>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
@@ -444,203 +444,202 @@ export function DragHandle({
|
|
|
444
444
|
*/
|
|
445
445
|
|
|
446
446
|
export const SplitPane = forwardRef(function SplitPane(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
447
|
+
{
|
|
448
|
+
mode = "horizontal",
|
|
449
|
+
position,
|
|
450
|
+
defaultPosition = 0.5,
|
|
451
|
+
min = 0.1,
|
|
452
|
+
max = 0.9,
|
|
453
|
+
splitterSize = 8,
|
|
454
|
+
onSizeChange,
|
|
455
|
+
style,
|
|
456
|
+
className,
|
|
457
|
+
firstPaneStyle,
|
|
458
|
+
secondPaneStyle,
|
|
459
|
+
splitterStyle,
|
|
460
|
+
children,
|
|
461
|
+
},
|
|
462
|
+
ref
|
|
463
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
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
);
|
|
464
|
+
const initialMode = mode === "vertical" ? "vertical" : "horizontal";
|
|
465
|
+
const [internalMode, setInternalMode] = useState(initialMode);
|
|
466
|
+
|
|
467
|
+
const [internalPos, setInternalPos] = useState(clamp(defaultPosition, min, max));
|
|
468
|
+
const posResolved = position == null ? internalPos : clamp(position, min, max);
|
|
469
|
+
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
if (position == null) return;
|
|
472
|
+
setInternalPos(clamp(position, min, max));
|
|
473
|
+
}, [position, min, max]);
|
|
474
|
+
|
|
475
|
+
useEffect(() => {
|
|
476
|
+
setInternalMode(mode === "vertical" ? "vertical" : "horizontal");
|
|
477
|
+
}, [mode]);
|
|
478
|
+
|
|
479
|
+
const setPosition = (next) => {
|
|
480
|
+
const clamped = clamp(next, min, max);
|
|
481
|
+
if (position == null) setInternalPos(clamped);
|
|
482
|
+
onSizeChange?.(clamped);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
useImperativeHandle(ref, () => ({
|
|
486
|
+
setPosition,
|
|
487
|
+
setMode: (nextMode) => setInternalMode(nextMode === "vertical" ? "vertical" : "horizontal"),
|
|
488
|
+
getPosition: () => posResolved,
|
|
489
|
+
getMode: () => internalMode,
|
|
490
|
+
}));
|
|
491
|
+
|
|
492
|
+
const containerRef = useRef(null);
|
|
493
|
+
const sizeRef = useRef({ w: 0, h: 0 });
|
|
494
|
+
|
|
495
|
+
useLayoutEffect(() => {
|
|
496
|
+
const el = containerRef.current;
|
|
497
|
+
if (!el) return;
|
|
498
|
+
|
|
499
|
+
const ro = new ResizeObserver(() => {
|
|
500
|
+
const rect = el.getBoundingClientRect();
|
|
501
|
+
sizeRef.current = { w: rect.width, h: rect.height };
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
ro.observe(el);
|
|
505
|
+
const rect = el.getBoundingClientRect();
|
|
506
|
+
sizeRef.current = { w: rect.width, h: rect.height };
|
|
507
|
+
|
|
508
|
+
return () => ro.disconnect();
|
|
509
|
+
}, []);
|
|
510
|
+
|
|
511
|
+
const startPosRef = useRef(posResolved);
|
|
512
|
+
const [dragging, setDragging] = useState(false);
|
|
513
|
+
|
|
514
|
+
const handleStart = () => {
|
|
515
|
+
setDragging(true);
|
|
516
|
+
startPosRef.current = posResolved;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
const handleDelta = (x, y, _data) => {
|
|
520
|
+
const { w, h } = sizeRef.current;
|
|
521
|
+
if (internalMode === "horizontal") {
|
|
522
|
+
setPosition(startPosRef.current + x / (w || 1));
|
|
523
|
+
} else {
|
|
524
|
+
setPosition(startPosRef.current + y / (h || 1));
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
const handleEnd = () => setDragging(false);
|
|
529
|
+
|
|
530
|
+
const arr = Children.toArray(children);
|
|
531
|
+
const firstChild = arr[0];
|
|
532
|
+
const secondChild = arr[1];
|
|
533
|
+
|
|
534
|
+
const p = posResolved;
|
|
535
|
+
|
|
536
|
+
const pane1StyleAbs =
|
|
537
|
+
internalMode === "horizontal"
|
|
538
|
+
? {
|
|
539
|
+
position: "absolute",
|
|
540
|
+
top: 0,
|
|
541
|
+
bottom: 0,
|
|
542
|
+
left: 0,
|
|
543
|
+
width: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
544
|
+
overflow: "auto",
|
|
545
|
+
...(firstPaneStyle || {}),
|
|
546
|
+
}
|
|
547
|
+
: {
|
|
548
|
+
position: "absolute",
|
|
549
|
+
left: 0,
|
|
550
|
+
right: 0,
|
|
551
|
+
top: 0,
|
|
552
|
+
height: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
553
|
+
overflow: "auto",
|
|
554
|
+
...(firstPaneStyle || {}),
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
const pane2StyleAbs =
|
|
558
|
+
internalMode === "horizontal"
|
|
559
|
+
? {
|
|
560
|
+
position: "absolute",
|
|
561
|
+
top: 0,
|
|
562
|
+
bottom: 0,
|
|
563
|
+
left: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
|
|
564
|
+
right: 0,
|
|
565
|
+
overflow: "auto",
|
|
566
|
+
...(secondPaneStyle || {}),
|
|
567
|
+
}
|
|
568
|
+
: {
|
|
569
|
+
position: "absolute",
|
|
570
|
+
left: 0,
|
|
571
|
+
right: 0,
|
|
572
|
+
top: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
|
|
573
|
+
bottom: 0,
|
|
574
|
+
overflow: "auto",
|
|
575
|
+
...(secondPaneStyle || {}),
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
// Basic visible default for splitter (so it doesn't "disappear" on mode switch).
|
|
579
|
+
// Also give zIndex + background and keep pointer events enabled.
|
|
580
|
+
const splitterBase = {
|
|
581
|
+
background: "rgba(0,0,0,0.08)",
|
|
582
|
+
boxShadow: "inset 0 0 2px rgba(0,0,0,0.25)",
|
|
583
|
+
zIndex: 10,
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
const splitterAbsStyle =
|
|
587
|
+
internalMode === "horizontal"
|
|
588
|
+
? {
|
|
589
|
+
position: "absolute",
|
|
590
|
+
top: 0,
|
|
591
|
+
bottom: 0,
|
|
592
|
+
left: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
593
|
+
width: splitterSize,
|
|
594
|
+
height: "100%",
|
|
595
|
+
|
|
596
|
+
cursor: dragging ? "col-resize" : "col-resize",
|
|
597
|
+
touchAction: "none",
|
|
598
|
+
pointerEvents: "auto",
|
|
599
|
+
|
|
600
|
+
...splitterBase,
|
|
601
|
+
...(splitterStyle || {}),
|
|
602
|
+
}
|
|
603
|
+
: {
|
|
604
|
+
position: "absolute",
|
|
605
|
+
left: 0,
|
|
606
|
+
right: 0,
|
|
607
|
+
top: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
608
|
+
height: splitterSize,
|
|
609
|
+
width: "100%",
|
|
610
|
+
|
|
611
|
+
cursor: dragging ? "row-resize" : "row-resize",
|
|
612
|
+
touchAction: "none",
|
|
613
|
+
pointerEvents: "auto",
|
|
614
|
+
|
|
615
|
+
...splitterBase,
|
|
616
|
+
...(splitterStyle || {}),
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
return (
|
|
620
|
+
<div
|
|
621
|
+
ref={containerRef}
|
|
622
|
+
className={className}
|
|
623
|
+
style={{
|
|
624
|
+
position: "relative",
|
|
625
|
+
width: "100%",
|
|
626
|
+
height: "100%",
|
|
627
|
+
overflow: "hidden",
|
|
628
|
+
...(style || {}),
|
|
629
|
+
}}
|
|
630
|
+
>
|
|
631
|
+
<div style={pane1StyleAbs}>{firstChild}</div>
|
|
632
|
+
<div style={pane2StyleAbs}>{secondChild}</div>
|
|
633
|
+
|
|
634
|
+
<DragHandle
|
|
635
|
+
onStart={handleStart}
|
|
636
|
+
onDelta={handleDelta}
|
|
637
|
+
onEnd={handleEnd}
|
|
638
|
+
style={splitterAbsStyle}
|
|
639
|
+
className="splitter"
|
|
640
|
+
/>
|
|
641
|
+
</div>
|
|
642
|
+
);
|
|
644
643
|
});
|
|
645
644
|
|
|
646
645
|
|
package/src/components.jsx
CHANGED
|
@@ -94,7 +94,12 @@ class ComponentCache
|
|
|
94
94
|
{
|
|
95
95
|
this.current_map.forEach( (arr)=>{
|
|
96
96
|
arr.slice(arr[IDX]).forEach((ex)=>{
|
|
97
|
-
if(ex.cleanup)
|
|
97
|
+
if(ex.cleanup) {
|
|
98
|
+
ex.cleanup();
|
|
99
|
+
}
|
|
100
|
+
else if(ex.element) {
|
|
101
|
+
ex.element.parentElement.removeChild(ex.element);
|
|
102
|
+
}
|
|
98
103
|
});
|
|
99
104
|
});
|
|
100
105
|
|
|
@@ -428,19 +433,31 @@ if(DEBUG) {
|
|
|
428
433
|
this.event_detachers[al] =
|
|
429
434
|
Lilact.addWrappedEventListener(this.element, alc.substring(2), patch[a], {capture: true});
|
|
430
435
|
}
|
|
431
|
-
else if(
|
|
432
|
-
if(typeof(patch
|
|
433
|
-
this.element.style = patch
|
|
436
|
+
else if(a==='style') {
|
|
437
|
+
if(typeof(patch.style)==='string') {
|
|
438
|
+
this.element.style = patch.style;
|
|
434
439
|
}
|
|
435
440
|
else {
|
|
436
|
-
|
|
441
|
+
if(this.props?.style) {
|
|
442
|
+
if(typeof(this.props.style)==='string') {
|
|
443
|
+
this.element.style = "";
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
for(let p in this.props.style) {
|
|
447
|
+
if( !patch.style.hasOwnProperty(p) ) {
|
|
448
|
+
this.element.style[p] = "";
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
for(const x in patch.style) {
|
|
437
454
|
if( length_css_attributes_set.has(x) ) {
|
|
438
|
-
if(isFinite(patch[
|
|
439
|
-
patch[
|
|
455
|
+
if(isFinite(patch.style[x])) {
|
|
456
|
+
patch.style[x]+='px';
|
|
440
457
|
}
|
|
441
458
|
}
|
|
442
459
|
}
|
|
443
|
-
Object.assign(this.element.style, patch
|
|
460
|
+
Object.assign(this.element.style, patch.style);
|
|
444
461
|
}
|
|
445
462
|
}
|
|
446
463
|
else if(boolean_html_attributes_set.has(a)) { // not lower cased(al), as it is set as a js property
|
|
@@ -704,23 +721,58 @@ function prepareCore(parent, core)
|
|
|
704
721
|
|
|
705
722
|
function doUpdates()
|
|
706
723
|
{
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
let _update_cbs = Lilact.update_cbs;
|
|
710
|
-
let _update_set = Lilact.update_set;
|
|
724
|
+
/*
|
|
725
|
+
Priority:
|
|
711
726
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
727
|
+
- Render + enqueue DOM work (runs in the same task where you schedule the update).
|
|
728
|
+
- Apply DOM updates (do this synchronously before you schedule any effects that must happen before paint).
|
|
729
|
+
- Insertion effects (run immediately after DOM is in place, still before paint).
|
|
730
|
+
- Layout effects (run immediately after insertion effects, still before paint).
|
|
731
|
+
- Passive effects (useEffect)
|
|
715
732
|
|
|
716
|
-
|
|
733
|
+
schedule them for after paint using requestAnimationFrame, typically:
|
|
734
|
+
run the “after paint” work in the next frame or in a callback scheduled such that it runs after the browser has performed the paint.
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
Current task: render → DOM updates → insertion effects → layout effects
|
|
738
|
+
Next paint timing boundary: requestAnimationFrame callback → passive effects (useEffect)
|
|
739
|
+
*/
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
clearTimeout(Lilact.effect_timeout);
|
|
743
|
+
|
|
744
|
+
const _update_set = Lilact.update_set;
|
|
745
|
+
const _update_cbs = Lilact.update_cbs;
|
|
746
|
+
Lilact.update_set = new Set;
|
|
747
|
+
Lilact.update_cbs = new Set;
|
|
748
|
+
|
|
749
|
+
for(const u of _update_set) u.apply();
|
|
750
|
+
for(const cb of _update_cbs) cb();
|
|
751
|
+
processEffects();
|
|
717
752
|
|
|
718
|
-
for(const u of _update_set) u.apply();
|
|
719
|
-
for(const cb of _update_cbs) cb();
|
|
720
|
-
});
|
|
721
753
|
}
|
|
722
754
|
|
|
723
755
|
|
|
756
|
+
/** @ignore */
|
|
757
|
+
export function processEffects()
|
|
758
|
+
{
|
|
759
|
+
const _insertion_effects = Lilact.insertion_effects;
|
|
760
|
+
const _layout_effects = Lilact.layout_effects;
|
|
761
|
+
const _passive_effects = Lilact.passive_effects;
|
|
762
|
+
|
|
763
|
+
Lilact.insertion_effects = new Set;
|
|
764
|
+
Lilact.layout_effects = new Set;
|
|
765
|
+
Lilact.passive_effects = new Set;
|
|
766
|
+
|
|
767
|
+
for(const ie of _insertion_effects) ie();
|
|
768
|
+
for(const le of _layout_effects) le();
|
|
769
|
+
|
|
770
|
+
requestAnimationFrame(()=>{
|
|
771
|
+
for(const pe of _passive_effects) pe();
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
}
|
|
775
|
+
|
|
724
776
|
function decode(html)
|
|
725
777
|
{
|
|
726
778
|
decode.parser ??= new DOMParser;
|
|
@@ -1037,7 +1089,7 @@ export class RootComponent extends HTMLComponent
|
|
|
1037
1089
|
|
|
1038
1090
|
export function createComponent(entity, props={}, ...children)
|
|
1039
1091
|
{
|
|
1040
|
-
if(
|
|
1092
|
+
if(typeof(entity)!=='string' && typeof(entity)!=='function') {
|
|
1041
1093
|
throw new Error("Invalid entity for createComponent.");
|
|
1042
1094
|
}
|
|
1043
1095
|
|
|
@@ -1129,6 +1181,7 @@ export function render(component, element)
|
|
|
1129
1181
|
return createRoot(element).render(component);
|
|
1130
1182
|
}
|
|
1131
1183
|
|
|
1184
|
+
|
|
1132
1185
|
/** @ignore */
|
|
1133
1186
|
export const createElement = createComponent;
|
|
1134
1187
|
|
|
@@ -1143,6 +1196,18 @@ export let update_cbs = new Set;
|
|
|
1143
1196
|
export let roots = new Set;
|
|
1144
1197
|
/** @ignore */
|
|
1145
1198
|
export let layout_effects = new Set;
|
|
1199
|
+
/** @ignore */
|
|
1200
|
+
export let insertion_effects = new Set;
|
|
1201
|
+
/** @ignore */
|
|
1202
|
+
export let passive_effects = new Set;
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
/** @ignore */
|
|
1206
|
+
export let update_timeout = undefined;
|
|
1207
|
+
/** @ignore */
|
|
1208
|
+
export let effect_timeout = undefined;
|
|
1209
|
+
/** @ignore */
|
|
1210
|
+
export let update_interval_margin = 0;
|
|
1146
1211
|
|
|
1147
1212
|
/** @ignore */
|
|
1148
1213
|
export const special_attributes = new Set([
|
|
@@ -1189,3 +1254,5 @@ export const length_css_attributes_set = new Set([
|
|
|
1189
1254
|
export const boolean_html_attributes_set = new
|
|
1190
1255
|
Set(["disabled", "readOnly", "required", "checked", "multiple",
|
|
1191
1256
|
"hidden","open","loop","muted","controls","playsInline","allowFullScreen"]);
|
|
1257
|
+
|
|
1258
|
+
|