sinwan 1.1.0 → 1.1.2
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/README.md +34 -3
- package/dist/cjs/index.development.js +357 -221
- package/dist/cjs/index.development.js.map +12 -11
- package/dist/cjs/index.production.min.js +2 -2
- package/dist/cjs/index.production.min.js.map +12 -11
- package/dist/cjs/renderer/index.development.js +300 -116
- package/dist/cjs/renderer/index.development.js.map +11 -10
- package/dist/cjs/renderer/index.production.min.js +2 -2
- package/dist/cjs/renderer/index.production.min.js.map +11 -10
- package/dist/cjs/server/index.development.js +146 -68
- package/dist/cjs/server/index.development.js.map +8 -7
- package/dist/cjs/server/index.production.min.js +2 -2
- package/dist/cjs/server/index.production.min.js.map +8 -7
- package/dist/component/control-flow.d.ts +6 -1
- package/dist/component/control-flow.d.ts.map +1 -1
- package/dist/component/instance.d.ts.map +1 -1
- package/dist/esm/index.development.js +357 -221
- package/dist/esm/index.development.js.map +12 -11
- package/dist/esm/index.production.min.js +2 -2
- package/dist/esm/index.production.min.js.map +12 -11
- package/dist/esm/renderer/index.development.js +300 -116
- package/dist/esm/renderer/index.development.js.map +11 -10
- package/dist/esm/renderer/index.production.min.js +2 -2
- package/dist/esm/renderer/index.production.min.js.map +11 -10
- package/dist/esm/server/index.development.js +146 -68
- package/dist/esm/server/index.development.js.map +8 -7
- package/dist/esm/server/index.production.min.js +2 -2
- package/dist/esm/server/index.production.min.js.map +8 -7
- package/dist/reactivity/index.d.ts +2 -1
- package/dist/reactivity/index.d.ts.map +1 -1
- package/dist/reactivity/normalization.d.ts +19 -0
- package/dist/reactivity/normalization.d.ts.map +1 -0
- package/dist/renderer/attributes.d.ts.map +1 -1
- package/dist/renderer/events.d.ts.map +1 -1
- package/dist/renderer/render-children.d.ts.map +1 -1
- package/dist/renderer/render-control-flow.d.ts.map +1 -1
- package/dist/renderer/render-element.d.ts.map +1 -1
- package/dist/renderer/types.d.ts +2 -0
- package/dist/renderer/types.d.ts.map +1 -1
- package/dist/server/renderer.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -3
|
@@ -383,7 +383,6 @@ function signal(initial) {
|
|
|
383
383
|
function isSignal(value) {
|
|
384
384
|
return value != null && typeof value === "object" && SIGNAL_BRAND in value;
|
|
385
385
|
}
|
|
386
|
-
|
|
387
386
|
// src/reactivity/computed.ts
|
|
388
387
|
var COMPUTED_BRAND = Symbol("Sinwan:computed");
|
|
389
388
|
|
|
@@ -435,10 +434,35 @@ function computed(getter) {
|
|
|
435
434
|
function isComputed(value) {
|
|
436
435
|
return value != null && typeof value === "object" && COMPUTED_BRAND in value;
|
|
437
436
|
}
|
|
438
|
-
|
|
437
|
+
// src/reactivity/batch.ts
|
|
438
|
+
var batchDepth = 0;
|
|
439
|
+
function batch(fn) {
|
|
440
|
+
batchDepth++;
|
|
441
|
+
try {
|
|
442
|
+
fn();
|
|
443
|
+
} finally {
|
|
444
|
+
batchDepth--;
|
|
445
|
+
if (batchDepth === 0) {
|
|
446
|
+
flushSync();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
// src/reactivity/normalization.ts
|
|
451
|
+
function isReactive(value) {
|
|
452
|
+
return isSignal(value) || isComputed(value) || typeof value === "function";
|
|
453
|
+
}
|
|
454
|
+
function resolve(value) {
|
|
455
|
+
if (isSignal(value) || isComputed(value)) {
|
|
456
|
+
return value.value;
|
|
457
|
+
}
|
|
458
|
+
if (typeof value === "function") {
|
|
459
|
+
return value();
|
|
460
|
+
}
|
|
461
|
+
return value;
|
|
462
|
+
}
|
|
439
463
|
// src/renderer/events.ts
|
|
440
464
|
function isEventProp(key) {
|
|
441
|
-
return key.length > 2 && key
|
|
465
|
+
return key.length > 2 && key.startsWith("on");
|
|
442
466
|
}
|
|
443
467
|
function toEventName(key) {
|
|
444
468
|
return key.slice(2).toLowerCase();
|
|
@@ -515,19 +539,28 @@ function fireMountedHooks(instance) {
|
|
|
515
539
|
}
|
|
516
540
|
}
|
|
517
541
|
function fireUnmountedHooks(instance) {
|
|
518
|
-
|
|
542
|
+
const children = [...instance.children];
|
|
543
|
+
for (const child of children) {
|
|
519
544
|
fireUnmountedHooks(child);
|
|
520
545
|
}
|
|
521
|
-
if (
|
|
546
|
+
if (!instance.isUnmounted) {
|
|
522
547
|
instance.isUnmounted = true;
|
|
523
|
-
instance.isMounted
|
|
524
|
-
|
|
525
|
-
hook
|
|
548
|
+
if (instance.isMounted) {
|
|
549
|
+
instance.isMounted = false;
|
|
550
|
+
for (const hook of instance._unmountedHooks) {
|
|
551
|
+
hook();
|
|
552
|
+
}
|
|
526
553
|
}
|
|
527
554
|
for (const dispose of instance.effects) {
|
|
528
555
|
dispose();
|
|
529
556
|
}
|
|
530
557
|
instance.effects.length = 0;
|
|
558
|
+
if (instance.parent) {
|
|
559
|
+
const idx = instance.parent.children.indexOf(instance);
|
|
560
|
+
if (idx !== -1) {
|
|
561
|
+
instance.parent.children.splice(idx, 1);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
531
564
|
}
|
|
532
565
|
}
|
|
533
566
|
function fireUpdatedHooks(instance) {
|
|
@@ -577,11 +610,13 @@ function applyAttributes(el, props) {
|
|
|
577
610
|
for (const [key, value] of Object.entries(props)) {
|
|
578
611
|
if (SKIP_PROPS.has(key) || isEventProp(key))
|
|
579
612
|
continue;
|
|
580
|
-
|
|
613
|
+
const attrName = resolveAttributeName(key);
|
|
614
|
+
const isComplex = attrName === "class" || attrName === "style";
|
|
615
|
+
if (isReactive(value) || isComplex && containsReactive(value)) {
|
|
581
616
|
const state = { previousStyleProps: new Set };
|
|
582
617
|
let initialized = false;
|
|
583
618
|
const dispose = effect(() => {
|
|
584
|
-
setSingleAttribute(el, key, value
|
|
619
|
+
setSingleAttribute(el, key, resolve(value), state);
|
|
585
620
|
if (initialized) {
|
|
586
621
|
queueUpdatedHooks(owner);
|
|
587
622
|
}
|
|
@@ -639,19 +674,17 @@ function setSingleAttribute(el, key, value, state) {
|
|
|
639
674
|
function resolveAttributeName(key) {
|
|
640
675
|
return PROP_ALIASES[key] ?? key;
|
|
641
676
|
}
|
|
642
|
-
function applyStyle(el,
|
|
677
|
+
function applyStyle(el, value, state) {
|
|
678
|
+
const styleObj = normalizeStyle(value);
|
|
643
679
|
const nextProps = new Set;
|
|
644
|
-
for (const [prop, val] of Object.entries(
|
|
680
|
+
for (const [prop, val] of Object.entries(styleObj)) {
|
|
645
681
|
nextProps.add(prop);
|
|
646
682
|
if (val == null) {
|
|
647
683
|
removeStyleProperty(el, prop);
|
|
648
684
|
continue;
|
|
649
685
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
} else {
|
|
653
|
-
el.style[prop] = val;
|
|
654
|
-
}
|
|
686
|
+
const kebabProp = prop.startsWith("--") ? prop : camelToKebab(prop);
|
|
687
|
+
el.style.setProperty(kebabProp, String(val));
|
|
655
688
|
}
|
|
656
689
|
if (!state) {
|
|
657
690
|
return;
|
|
@@ -663,37 +696,77 @@ function applyStyle(el, styles, state) {
|
|
|
663
696
|
}
|
|
664
697
|
state.previousStyleProps = nextProps;
|
|
665
698
|
}
|
|
699
|
+
function normalizeStyle(value) {
|
|
700
|
+
const resolved = resolve(value);
|
|
701
|
+
if (!resolved)
|
|
702
|
+
return {};
|
|
703
|
+
if (typeof resolved === "string") {
|
|
704
|
+
return parseStyleString(resolved);
|
|
705
|
+
}
|
|
706
|
+
if (Array.isArray(resolved)) {
|
|
707
|
+
return resolved.reduce((acc, item) => {
|
|
708
|
+
const normalized = normalizeStyle(item);
|
|
709
|
+
return Object.assign(acc, normalized);
|
|
710
|
+
}, {});
|
|
711
|
+
}
|
|
712
|
+
if (typeof resolved === "object") {
|
|
713
|
+
const result = {};
|
|
714
|
+
for (const [k, v] of Object.entries(resolved)) {
|
|
715
|
+
result[k] = resolve(v);
|
|
716
|
+
}
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
return {};
|
|
720
|
+
}
|
|
721
|
+
function parseStyleString(style) {
|
|
722
|
+
const result = {};
|
|
723
|
+
style.split(";").forEach((rule) => {
|
|
724
|
+
const i = rule.indexOf(":");
|
|
725
|
+
if (i > 0) {
|
|
726
|
+
const prop = rule.slice(0, i).trim();
|
|
727
|
+
const val = rule.slice(i + 1).trim();
|
|
728
|
+
if (prop && val) {
|
|
729
|
+
result[prop] = val;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
return result;
|
|
734
|
+
}
|
|
666
735
|
function removeStyleProperty(el, prop) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
} else {
|
|
670
|
-
el.style[prop] = "";
|
|
671
|
-
}
|
|
736
|
+
const kebabProp = prop.startsWith("--") ? prop : camelToKebab(prop);
|
|
737
|
+
el.style.removeProperty(kebabProp);
|
|
672
738
|
}
|
|
673
739
|
function applyClass(el, value) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
740
|
+
domOps.setAttribute(el, "class", normalizeClass(value));
|
|
741
|
+
}
|
|
742
|
+
function normalizeClass(value) {
|
|
743
|
+
const resolved = resolve(value);
|
|
744
|
+
if (!resolved)
|
|
745
|
+
return "";
|
|
746
|
+
if (typeof resolved === "string")
|
|
747
|
+
return resolved;
|
|
748
|
+
if (Array.isArray(resolved)) {
|
|
749
|
+
return resolved.map(normalizeClass).filter(Boolean).join(" ");
|
|
681
750
|
}
|
|
682
|
-
|
|
751
|
+
if (typeof resolved === "object") {
|
|
752
|
+
return Object.entries(resolved).filter(([, v]) => Boolean(resolve(v))).map(([k]) => k).join(" ");
|
|
753
|
+
}
|
|
754
|
+
return String(resolved);
|
|
683
755
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
batchDepth--;
|
|
692
|
-
if (batchDepth === 0) {
|
|
693
|
-
flushSync();
|
|
694
|
-
}
|
|
756
|
+
function containsReactive(value) {
|
|
757
|
+
if (isReactive(value))
|
|
758
|
+
return true;
|
|
759
|
+
if (Array.isArray(value))
|
|
760
|
+
return value.some(containsReactive);
|
|
761
|
+
if (typeof value === "object" && value !== null) {
|
|
762
|
+
return Object.values(value).some(containsReactive);
|
|
695
763
|
}
|
|
764
|
+
return false;
|
|
696
765
|
}
|
|
766
|
+
function camelToKebab(str) {
|
|
767
|
+
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
768
|
+
}
|
|
769
|
+
|
|
697
770
|
// src/component/control-flow.ts
|
|
698
771
|
var SHOW_TYPE = Symbol.for("Sinwan.Show");
|
|
699
772
|
var FOR_TYPE = Symbol.for("Sinwan.For");
|
|
@@ -787,6 +860,9 @@ function Portal(props) {
|
|
|
787
860
|
children: []
|
|
788
861
|
};
|
|
789
862
|
}
|
|
863
|
+
function isElementLike(value) {
|
|
864
|
+
return value != null && typeof value === "object" && "tag" in value;
|
|
865
|
+
}
|
|
790
866
|
function isShowElement(element) {
|
|
791
867
|
return element.tag === SHOW_TYPE;
|
|
792
868
|
}
|
|
@@ -811,6 +887,107 @@ function isDynamicElement(element) {
|
|
|
811
887
|
function isPortalElement(element) {
|
|
812
888
|
return element.tag === PORTAL_TYPE;
|
|
813
889
|
}
|
|
890
|
+
function resolveSwitchContent(element) {
|
|
891
|
+
const props = element.props;
|
|
892
|
+
const children = normalizeContent(props.children ?? element.children);
|
|
893
|
+
const match = findTruthyMatch(children);
|
|
894
|
+
return match !== undefined ? match : props.fallback;
|
|
895
|
+
}
|
|
896
|
+
function findTruthyMatch(nodes) {
|
|
897
|
+
for (const node of nodes) {
|
|
898
|
+
if (node == null || typeof node === "boolean")
|
|
899
|
+
continue;
|
|
900
|
+
if (Array.isArray(node)) {
|
|
901
|
+
const match = findTruthyMatch(node);
|
|
902
|
+
if (match !== undefined)
|
|
903
|
+
return match;
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
if (isElementLike(node)) {
|
|
907
|
+
let element = node;
|
|
908
|
+
if (typeof element.tag === "function") {
|
|
909
|
+
const tag = element.tag;
|
|
910
|
+
if (tag === Match || tag === Show || tag === For || tag === Index || tag === Key || tag === Switch) {
|
|
911
|
+
element = tag(element.props);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if (isMatchElement(element)) {
|
|
915
|
+
const when = readReactive(element.props.when);
|
|
916
|
+
if (when) {
|
|
917
|
+
return resolveMatchChildren(element, when);
|
|
918
|
+
}
|
|
919
|
+
} else if (isShowElement(element)) {
|
|
920
|
+
const when = readReactive(element.props.when);
|
|
921
|
+
if (when) {
|
|
922
|
+
const content = resolveShowChildren(element, when);
|
|
923
|
+
const match = findTruthyMatch(normalizeContent(content));
|
|
924
|
+
if (match !== undefined)
|
|
925
|
+
return match;
|
|
926
|
+
} else if (element.props.fallback) {
|
|
927
|
+
const match = findTruthyMatch(normalizeContent(element.props.fallback));
|
|
928
|
+
if (match !== undefined)
|
|
929
|
+
return match;
|
|
930
|
+
}
|
|
931
|
+
} else if (isForElement(element)) {
|
|
932
|
+
const props = element.props;
|
|
933
|
+
const items = readReactive(props.each);
|
|
934
|
+
if (Array.isArray(items)) {
|
|
935
|
+
for (let i = 0;i < items.length; i++) {
|
|
936
|
+
const child = props.children(items[i], () => i);
|
|
937
|
+
const match = findTruthyMatch(normalizeContent(child));
|
|
938
|
+
if (match !== undefined)
|
|
939
|
+
return match;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
} else if (isIndexElement(element)) {
|
|
943
|
+
const props = element.props;
|
|
944
|
+
const items = readReactive(props.each);
|
|
945
|
+
if (Array.isArray(items)) {
|
|
946
|
+
for (let i = 0;i < items.length; i++) {
|
|
947
|
+
const child = props.children(() => items[i], i);
|
|
948
|
+
const match = findTruthyMatch(normalizeContent(child));
|
|
949
|
+
if (match !== undefined)
|
|
950
|
+
return match;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
} else if (isKeyElement(element)) {
|
|
954
|
+
const key = readReactive(element.props.when);
|
|
955
|
+
const child = resolveKeyChildren(element, key);
|
|
956
|
+
const match = findTruthyMatch(normalizeContent(child));
|
|
957
|
+
if (match !== undefined)
|
|
958
|
+
return match;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
function resolveMatchChildren(element, value) {
|
|
965
|
+
const children = element.props.children ?? element.children;
|
|
966
|
+
if (typeof children === "function") {
|
|
967
|
+
return children(value);
|
|
968
|
+
}
|
|
969
|
+
return children;
|
|
970
|
+
}
|
|
971
|
+
function resolveShowChildren(element, value) {
|
|
972
|
+
const children = element.props.children ?? element.children;
|
|
973
|
+
if (typeof children === "function") {
|
|
974
|
+
return children(value);
|
|
975
|
+
}
|
|
976
|
+
return children;
|
|
977
|
+
}
|
|
978
|
+
function resolveKeyChildren(element, value) {
|
|
979
|
+
const children = element.props.children ?? element.children;
|
|
980
|
+
if (typeof children === "function") {
|
|
981
|
+
return children(value);
|
|
982
|
+
}
|
|
983
|
+
return children;
|
|
984
|
+
}
|
|
985
|
+
function normalizeContent(content) {
|
|
986
|
+
if (content == null || typeof content === "boolean") {
|
|
987
|
+
return [];
|
|
988
|
+
}
|
|
989
|
+
return Array.isArray(content) ? content : [content];
|
|
990
|
+
}
|
|
814
991
|
function normalizeChildren2(children) {
|
|
815
992
|
if (children == null || typeof children === "boolean") {
|
|
816
993
|
return [];
|
|
@@ -818,7 +995,7 @@ function normalizeChildren2(children) {
|
|
|
818
995
|
return Array.isArray(children) ? children : [children];
|
|
819
996
|
}
|
|
820
997
|
function readReactive(value) {
|
|
821
|
-
return
|
|
998
|
+
return resolve(value);
|
|
822
999
|
}
|
|
823
1000
|
function appendHiddenDisplay(style) {
|
|
824
1001
|
const trimmed = style.trim();
|
|
@@ -950,8 +1127,10 @@ function renderShowBlock(element, block, parent, namespace, owner) {
|
|
|
950
1127
|
return effect(() => {
|
|
951
1128
|
clearChildren(block);
|
|
952
1129
|
const when = readReactive2(element.props.when);
|
|
953
|
-
|
|
954
|
-
|
|
1130
|
+
block.children = withOptionalInstance(owner, () => {
|
|
1131
|
+
const content = when ? resolveShowChildren(element, when) : element.props.fallback;
|
|
1132
|
+
return renderBlockContent(content, parent, block.endAnchor, namespace, owner);
|
|
1133
|
+
});
|
|
955
1134
|
if (initialized) {
|
|
956
1135
|
fireMountedAndQueueUpdated(owner);
|
|
957
1136
|
}
|
|
@@ -1138,18 +1317,31 @@ function renderPortal(element, parent, anchor, namespace) {
|
|
|
1138
1317
|
insertNode(parent, placeholder, anchor);
|
|
1139
1318
|
const owner = getCurrentInstance();
|
|
1140
1319
|
let disposeEffect = () => {};
|
|
1320
|
+
const targetAnchor = domOps.createComment("Sinwan-pa");
|
|
1321
|
+
let lastTarget = null;
|
|
1141
1322
|
const portal = {
|
|
1142
1323
|
type: "portal",
|
|
1143
1324
|
anchor: placeholder,
|
|
1144
1325
|
children: [],
|
|
1145
|
-
dispose: () => disposeEffect()
|
|
1326
|
+
dispose: () => disposeEffect(),
|
|
1327
|
+
targetAnchor
|
|
1146
1328
|
};
|
|
1147
1329
|
let initialized = false;
|
|
1148
1330
|
disposeEffect = effect(() => {
|
|
1149
|
-
clearPortalChildren(portal);
|
|
1150
1331
|
const target = resolvePortalTarget(element.props.mount);
|
|
1332
|
+
if (target !== lastTarget) {
|
|
1333
|
+
if (lastTarget) {
|
|
1334
|
+
domOps.remove(targetAnchor);
|
|
1335
|
+
}
|
|
1336
|
+
if (target) {
|
|
1337
|
+
domOps.appendChild(target, targetAnchor);
|
|
1338
|
+
}
|
|
1339
|
+
lastTarget = target;
|
|
1340
|
+
portal.target = target;
|
|
1341
|
+
}
|
|
1342
|
+
clearPortalChildren(portal);
|
|
1151
1343
|
if (target) {
|
|
1152
|
-
portal.children = renderBlockContent(element.props.children ?? element.children, target,
|
|
1344
|
+
portal.children = renderBlockContent(element.props.children ?? element.children, target, targetAnchor, namespace, owner);
|
|
1153
1345
|
}
|
|
1154
1346
|
if (initialized) {
|
|
1155
1347
|
fireMountedAndQueueUpdated(owner);
|
|
@@ -1158,48 +1350,12 @@ function renderPortal(element, parent, anchor, namespace) {
|
|
|
1158
1350
|
});
|
|
1159
1351
|
return portal;
|
|
1160
1352
|
}
|
|
1161
|
-
function resolveShowChildren(element, value) {
|
|
1162
|
-
const children = element.props.children ?? element.children;
|
|
1163
|
-
if (typeof children === "function") {
|
|
1164
|
-
return children(value);
|
|
1165
|
-
}
|
|
1166
|
-
return children;
|
|
1167
|
-
}
|
|
1168
|
-
function resolveSwitchContent(element) {
|
|
1169
|
-
const props = element.props;
|
|
1170
|
-
const children = normalizeContent(props.children ?? element.children);
|
|
1171
|
-
for (const child of children) {
|
|
1172
|
-
const match = getMatchElement(child);
|
|
1173
|
-
if (!match) {
|
|
1174
|
-
continue;
|
|
1175
|
-
}
|
|
1176
|
-
const when = readReactive2(match.props.when);
|
|
1177
|
-
if (when) {
|
|
1178
|
-
return resolveMatchChildren(match, when);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
return props.fallback;
|
|
1182
|
-
}
|
|
1183
|
-
function resolveMatchChildren(element, value) {
|
|
1184
|
-
const children = element.props.children ?? element.children;
|
|
1185
|
-
if (typeof children === "function") {
|
|
1186
|
-
return children(value);
|
|
1187
|
-
}
|
|
1188
|
-
return children;
|
|
1189
|
-
}
|
|
1190
|
-
function resolveKeyChildren(element, value) {
|
|
1191
|
-
const children = element.props.children ?? element.children;
|
|
1192
|
-
if (typeof children === "function") {
|
|
1193
|
-
return children(value);
|
|
1194
|
-
}
|
|
1195
|
-
return children;
|
|
1196
|
-
}
|
|
1197
1353
|
function createDynamicElement(element, tag) {
|
|
1198
1354
|
if (typeof tag !== "string" && typeof tag !== "function") {
|
|
1199
1355
|
return null;
|
|
1200
1356
|
}
|
|
1201
1357
|
const { component, ...props } = element.props;
|
|
1202
|
-
const children =
|
|
1358
|
+
const children = normalizeContent2(props.children ?? element.children);
|
|
1203
1359
|
return {
|
|
1204
1360
|
tag,
|
|
1205
1361
|
props,
|
|
@@ -1207,11 +1363,14 @@ function createDynamicElement(element, tag) {
|
|
|
1207
1363
|
};
|
|
1208
1364
|
}
|
|
1209
1365
|
function renderBlockContent(content, parent, anchor, namespace, owner) {
|
|
1210
|
-
if (content == null || typeof content === "boolean")
|
|
1366
|
+
if (content == null || typeof content === "boolean")
|
|
1211
1367
|
return [];
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1368
|
+
return withOptionalInstance(owner, () => {
|
|
1369
|
+
if (Array.isArray(content)) {
|
|
1370
|
+
return content.map((child) => renderNodeToDOM(child, parent, anchor, namespace));
|
|
1371
|
+
}
|
|
1372
|
+
return [renderNodeToDOM(content, parent, anchor, namespace)];
|
|
1373
|
+
});
|
|
1215
1374
|
}
|
|
1216
1375
|
function clearChildren(block) {
|
|
1217
1376
|
for (const child of block.children) {
|
|
@@ -1229,6 +1388,23 @@ function moveBeforeEnd(parent, mounted, endAnchor) {
|
|
|
1229
1388
|
for (const node of getMountedDomNodes(mounted)) {
|
|
1230
1389
|
domOps.insertBefore(parent, node, endAnchor);
|
|
1231
1390
|
}
|
|
1391
|
+
syncPortalOrder(mounted);
|
|
1392
|
+
}
|
|
1393
|
+
function syncPortalOrder(mounted) {
|
|
1394
|
+
if (mounted.type === "portal") {
|
|
1395
|
+
if (mounted.target && mounted.targetAnchor) {
|
|
1396
|
+
for (const child of mounted.children) {
|
|
1397
|
+
for (const node of getMountedDomNodes(child)) {
|
|
1398
|
+
domOps.appendChild(mounted.target, node);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
domOps.appendChild(mounted.target, mounted.targetAnchor);
|
|
1402
|
+
}
|
|
1403
|
+
} else if ("children" in mounted && Array.isArray(mounted.children)) {
|
|
1404
|
+
for (const child of mounted.children) {
|
|
1405
|
+
syncPortalOrder(child);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1232
1408
|
}
|
|
1233
1409
|
function fireMountedAndQueueUpdated(owner) {
|
|
1234
1410
|
if (owner) {
|
|
@@ -1240,26 +1416,14 @@ function withOptionalInstance(owner, fn) {
|
|
|
1240
1416
|
return owner ? withInstance(owner, fn) : fn();
|
|
1241
1417
|
}
|
|
1242
1418
|
function readReactive2(value) {
|
|
1243
|
-
return
|
|
1419
|
+
return resolve(value);
|
|
1244
1420
|
}
|
|
1245
|
-
function
|
|
1421
|
+
function normalizeContent2(content) {
|
|
1246
1422
|
if (content == null || typeof content === "boolean") {
|
|
1247
1423
|
return [];
|
|
1248
1424
|
}
|
|
1249
1425
|
return Array.isArray(content) ? content : [content];
|
|
1250
1426
|
}
|
|
1251
|
-
function isElementLike(value) {
|
|
1252
|
-
return value != null && typeof value === "object" && "tag" in value;
|
|
1253
|
-
}
|
|
1254
|
-
function getMatchElement(value) {
|
|
1255
|
-
if (!isElementLike(value)) {
|
|
1256
|
-
return null;
|
|
1257
|
-
}
|
|
1258
|
-
if (isMatchElement(value)) {
|
|
1259
|
-
return value;
|
|
1260
|
-
}
|
|
1261
|
-
return value.tag === Match ? Match(value.props) : null;
|
|
1262
|
-
}
|
|
1263
1427
|
function resolvePortalTarget(value) {
|
|
1264
1428
|
const target = readReactive2(value);
|
|
1265
1429
|
if (target == null) {
|
|
@@ -1461,19 +1625,8 @@ function renderNodeToDOM(node, parent, anchor = null, namespace = null) {
|
|
|
1461
1625
|
insertNode2(parent, text2, anchor);
|
|
1462
1626
|
return { type: "text", node: text2 };
|
|
1463
1627
|
}
|
|
1464
|
-
if (
|
|
1465
|
-
|
|
1466
|
-
insertNode2(parent, text2, anchor);
|
|
1467
|
-
const owner = getCurrentInstance();
|
|
1468
|
-
let initialized = false;
|
|
1469
|
-
const dispose = effect(() => {
|
|
1470
|
-
domOps.setTextContent(text2, String(node.value));
|
|
1471
|
-
if (initialized) {
|
|
1472
|
-
queueUpdatedHooks(owner);
|
|
1473
|
-
}
|
|
1474
|
-
initialized = true;
|
|
1475
|
-
});
|
|
1476
|
-
return { type: "reactive-text", node: text2, dispose };
|
|
1628
|
+
if (isReactive(node)) {
|
|
1629
|
+
return renderReactiveNodeToDOM(node, parent, anchor, namespace);
|
|
1477
1630
|
}
|
|
1478
1631
|
if (Array.isArray(node)) {
|
|
1479
1632
|
return renderArrayToDOM(node, parent, anchor, namespace);
|
|
@@ -1510,6 +1663,37 @@ function renderChildrenToDOM(children, parent, namespace = null) {
|
|
|
1510
1663
|
}
|
|
1511
1664
|
return mounted;
|
|
1512
1665
|
}
|
|
1666
|
+
function renderReactiveNodeToDOM(reactive, parent, anchor, namespace) {
|
|
1667
|
+
const startAnchor = domOps.createComment("Sinwan-r");
|
|
1668
|
+
const endAnchor = domOps.createComment("/Sinwan-r");
|
|
1669
|
+
insertNode2(parent, startAnchor, anchor);
|
|
1670
|
+
insertNode2(parent, endAnchor, anchor);
|
|
1671
|
+
const owner = getCurrentInstance();
|
|
1672
|
+
let mountedContent = null;
|
|
1673
|
+
let initialized = false;
|
|
1674
|
+
const block = {
|
|
1675
|
+
type: "reactive-block",
|
|
1676
|
+
startAnchor,
|
|
1677
|
+
endAnchor,
|
|
1678
|
+
children: [],
|
|
1679
|
+
dispose: () => {}
|
|
1680
|
+
};
|
|
1681
|
+
block.dispose = effect(() => {
|
|
1682
|
+
if (mountedContent) {
|
|
1683
|
+
removeMountedNode(mountedContent);
|
|
1684
|
+
}
|
|
1685
|
+
const value = resolve(reactive);
|
|
1686
|
+
mountedContent = renderNodeToDOM(value, parent, endAnchor, namespace);
|
|
1687
|
+
block.children = [mountedContent];
|
|
1688
|
+
if (initialized) {
|
|
1689
|
+
if (owner)
|
|
1690
|
+
fireMountedHooks(owner);
|
|
1691
|
+
queueUpdatedHooks(owner);
|
|
1692
|
+
}
|
|
1693
|
+
initialized = true;
|
|
1694
|
+
});
|
|
1695
|
+
return block;
|
|
1696
|
+
}
|
|
1513
1697
|
function insertNode2(parent, child, anchor) {
|
|
1514
1698
|
if (anchor) {
|
|
1515
1699
|
domOps.insertBefore(parent, child, anchor);
|
|
@@ -1713,24 +1897,24 @@ async function renderElement(element) {
|
|
|
1713
1897
|
}
|
|
1714
1898
|
if (isShowElement(element)) {
|
|
1715
1899
|
const when = readReactive3(props.when);
|
|
1716
|
-
return renderToString(when ?
|
|
1900
|
+
return renderToString(when ? resolveShowChildren(element, when) : props.fallback);
|
|
1717
1901
|
}
|
|
1718
1902
|
if (isForElement(element)) {
|
|
1719
1903
|
return renderForElement(element);
|
|
1720
1904
|
}
|
|
1721
1905
|
if (isSwitchElement(element)) {
|
|
1722
|
-
return renderToString(
|
|
1906
|
+
return renderToString(resolveSwitchContent(element));
|
|
1723
1907
|
}
|
|
1724
1908
|
if (isMatchElement(element)) {
|
|
1725
1909
|
const when = readReactive3(props.when);
|
|
1726
|
-
return renderToString(when ?
|
|
1910
|
+
return renderToString(when ? resolveMatchChildren(element, when) : null);
|
|
1727
1911
|
}
|
|
1728
1912
|
if (isIndexElement(element)) {
|
|
1729
1913
|
return renderIndexElement(element);
|
|
1730
1914
|
}
|
|
1731
1915
|
if (isKeyElement(element)) {
|
|
1732
1916
|
const key = readReactive3(props.when);
|
|
1733
|
-
return renderToString(
|
|
1917
|
+
return renderToString(resolveKeyChildren(element, key));
|
|
1734
1918
|
}
|
|
1735
1919
|
if (isDynamicElement(element)) {
|
|
1736
1920
|
const tag2 = readReactive3(props.component);
|
|
@@ -1820,75 +2004,27 @@ async function renderIndexElement(element) {
|
|
|
1820
2004
|
const rendered = await Promise.all(each.map((item, index) => renderToString(props.children(() => item, index))));
|
|
1821
2005
|
return rendered.join("");
|
|
1822
2006
|
}
|
|
1823
|
-
function resolveSwitchContent2(element) {
|
|
1824
|
-
const props = element.props;
|
|
1825
|
-
const children = normalizeContent2(props.children ?? element.children);
|
|
1826
|
-
for (const child of children) {
|
|
1827
|
-
const match = getMatchElement2(child);
|
|
1828
|
-
if (!match) {
|
|
1829
|
-
continue;
|
|
1830
|
-
}
|
|
1831
|
-
const when = readReactive3(match.props.when);
|
|
1832
|
-
if (when) {
|
|
1833
|
-
return resolveMatchChildren2(match, when);
|
|
1834
|
-
}
|
|
1835
|
-
}
|
|
1836
|
-
return props.fallback;
|
|
1837
|
-
}
|
|
1838
|
-
function resolveMatchChildren2(element, value) {
|
|
1839
|
-
const children = element.props.children ?? element.children;
|
|
1840
|
-
if (typeof children === "function") {
|
|
1841
|
-
return children(value);
|
|
1842
|
-
}
|
|
1843
|
-
return children;
|
|
1844
|
-
}
|
|
1845
|
-
function resolveKeyChildren2(element, value) {
|
|
1846
|
-
const children = element.props.children ?? element.children;
|
|
1847
|
-
if (typeof children === "function") {
|
|
1848
|
-
return children(value);
|
|
1849
|
-
}
|
|
1850
|
-
return children;
|
|
1851
|
-
}
|
|
1852
2007
|
function createDynamicElement2(element, tag) {
|
|
1853
2008
|
if (typeof tag !== "string" && typeof tag !== "function") {
|
|
1854
2009
|
return null;
|
|
1855
2010
|
}
|
|
1856
2011
|
const { component, ...props } = element.props;
|
|
1857
|
-
const children =
|
|
2012
|
+
const children = normalizeContent3(props.children ?? element.children);
|
|
1858
2013
|
return {
|
|
1859
2014
|
tag,
|
|
1860
2015
|
props,
|
|
1861
2016
|
children
|
|
1862
2017
|
};
|
|
1863
2018
|
}
|
|
1864
|
-
function resolveShowChildren2(element, value) {
|
|
1865
|
-
const children = element.props.children ?? element.children;
|
|
1866
|
-
if (typeof children === "function") {
|
|
1867
|
-
return children(value);
|
|
1868
|
-
}
|
|
1869
|
-
return children;
|
|
1870
|
-
}
|
|
1871
2019
|
function readReactive3(value) {
|
|
1872
2020
|
return isSignal(value) || isComputed(value) ? value.value : value;
|
|
1873
2021
|
}
|
|
1874
|
-
function
|
|
2022
|
+
function normalizeContent3(content) {
|
|
1875
2023
|
if (content == null || typeof content === "boolean") {
|
|
1876
2024
|
return [];
|
|
1877
2025
|
}
|
|
1878
2026
|
return Array.isArray(content) ? content : [content];
|
|
1879
2027
|
}
|
|
1880
|
-
function isElementLike2(value) {
|
|
1881
|
-
return value != null && typeof value === "object" && "tag" in value;
|
|
1882
|
-
}
|
|
1883
|
-
function getMatchElement2(value) {
|
|
1884
|
-
if (!isElementLike2(value)) {
|
|
1885
|
-
return null;
|
|
1886
|
-
}
|
|
1887
|
-
if (isMatchElement(value)) {
|
|
1888
|
-
return value;
|
|
1889
|
-
}
|
|
1890
|
-
return value.tag === Match ? Match(value.props) : null;
|
|
1891
|
-
}
|
|
1892
2028
|
// src/hydration/markers.ts
|
|
1893
2029
|
var COMP_ID_ATTR = "data-sinwan-id";
|
|
1894
2030
|
var COMP_ID_PREFIX = "c";
|
|
@@ -2023,7 +2159,7 @@ async function streamElement(element, controller, encoder) {
|
|
|
2023
2159
|
}
|
|
2024
2160
|
if (isShowElement(element)) {
|
|
2025
2161
|
const when = readReactive4(props.when);
|
|
2026
|
-
await streamNode(when ?
|
|
2162
|
+
await streamNode(when ? resolveShowChildren2(element, when) : props.fallback, controller, encoder);
|
|
2027
2163
|
return;
|
|
2028
2164
|
}
|
|
2029
2165
|
if (isForElement(element)) {
|
|
@@ -2031,12 +2167,12 @@ async function streamElement(element, controller, encoder) {
|
|
|
2031
2167
|
return;
|
|
2032
2168
|
}
|
|
2033
2169
|
if (isSwitchElement(element)) {
|
|
2034
|
-
await streamNode(
|
|
2170
|
+
await streamNode(resolveSwitchContent2(element), controller, encoder);
|
|
2035
2171
|
return;
|
|
2036
2172
|
}
|
|
2037
2173
|
if (isMatchElement(element)) {
|
|
2038
2174
|
const when = readReactive4(props.when);
|
|
2039
|
-
await streamNode(when ?
|
|
2175
|
+
await streamNode(when ? resolveMatchChildren2(element, when) : null, controller, encoder);
|
|
2040
2176
|
return;
|
|
2041
2177
|
}
|
|
2042
2178
|
if (isIndexElement(element)) {
|
|
@@ -2045,7 +2181,7 @@ async function streamElement(element, controller, encoder) {
|
|
|
2045
2181
|
}
|
|
2046
2182
|
if (isKeyElement(element)) {
|
|
2047
2183
|
const key = readReactive4(props.when);
|
|
2048
|
-
await streamNode(
|
|
2184
|
+
await streamNode(resolveKeyChildren2(element, key), controller, encoder);
|
|
2049
2185
|
return;
|
|
2050
2186
|
}
|
|
2051
2187
|
if (isDynamicElement(element)) {
|
|
@@ -2151,7 +2287,7 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
|
|
|
2151
2287
|
}
|
|
2152
2288
|
if (isShowElement(element)) {
|
|
2153
2289
|
const when = readReactive4(props.when);
|
|
2154
|
-
await streamHydratableNodeToController(when ?
|
|
2290
|
+
await streamHydratableNodeToController(when ? resolveShowChildren2(element, when) : props.fallback, controller, encoder, ctx, isComponentRoot);
|
|
2155
2291
|
return;
|
|
2156
2292
|
}
|
|
2157
2293
|
if (isForElement(element)) {
|
|
@@ -2159,12 +2295,12 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
|
|
|
2159
2295
|
return;
|
|
2160
2296
|
}
|
|
2161
2297
|
if (isSwitchElement(element)) {
|
|
2162
|
-
await streamHydratableNodeToController(
|
|
2298
|
+
await streamHydratableNodeToController(resolveSwitchContent2(element), controller, encoder, ctx, isComponentRoot);
|
|
2163
2299
|
return;
|
|
2164
2300
|
}
|
|
2165
2301
|
if (isMatchElement(element)) {
|
|
2166
2302
|
const when = readReactive4(props.when);
|
|
2167
|
-
await streamHydratableNodeToController(when ?
|
|
2303
|
+
await streamHydratableNodeToController(when ? resolveMatchChildren2(element, when) : null, controller, encoder, ctx, isComponentRoot);
|
|
2168
2304
|
return;
|
|
2169
2305
|
}
|
|
2170
2306
|
if (isIndexElement(element)) {
|
|
@@ -2173,7 +2309,7 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
|
|
|
2173
2309
|
}
|
|
2174
2310
|
if (isKeyElement(element)) {
|
|
2175
2311
|
const key = readReactive4(props.when);
|
|
2176
|
-
await streamHydratableNodeToController(
|
|
2312
|
+
await streamHydratableNodeToController(resolveKeyChildren2(element, key), controller, encoder, ctx, isComponentRoot);
|
|
2177
2313
|
return;
|
|
2178
2314
|
}
|
|
2179
2315
|
if (isDynamicElement(element)) {
|
|
@@ -2330,36 +2466,36 @@ async function streamIndexElement(element, controller, encoder) {
|
|
|
2330
2466
|
await streamNode(props.children(() => each[index], index), controller, encoder);
|
|
2331
2467
|
}
|
|
2332
2468
|
}
|
|
2333
|
-
function
|
|
2469
|
+
function resolveShowChildren2(element, value) {
|
|
2334
2470
|
const children = element.props.children ?? element.children;
|
|
2335
2471
|
if (typeof children === "function") {
|
|
2336
2472
|
return children(value);
|
|
2337
2473
|
}
|
|
2338
2474
|
return children;
|
|
2339
2475
|
}
|
|
2340
|
-
function
|
|
2476
|
+
function resolveSwitchContent2(element) {
|
|
2341
2477
|
const props = element.props;
|
|
2342
|
-
const children =
|
|
2478
|
+
const children = normalizeContent4(props.children ?? element.children);
|
|
2343
2479
|
for (const child of children) {
|
|
2344
|
-
const match =
|
|
2480
|
+
const match = getMatchElement(child);
|
|
2345
2481
|
if (!match) {
|
|
2346
2482
|
continue;
|
|
2347
2483
|
}
|
|
2348
2484
|
const when = readReactive4(match.props.when);
|
|
2349
2485
|
if (when) {
|
|
2350
|
-
return
|
|
2486
|
+
return resolveMatchChildren2(match, when);
|
|
2351
2487
|
}
|
|
2352
2488
|
}
|
|
2353
2489
|
return props.fallback;
|
|
2354
2490
|
}
|
|
2355
|
-
function
|
|
2491
|
+
function resolveMatchChildren2(element, value) {
|
|
2356
2492
|
const children = element.props.children ?? element.children;
|
|
2357
2493
|
if (typeof children === "function") {
|
|
2358
2494
|
return children(value);
|
|
2359
2495
|
}
|
|
2360
2496
|
return children;
|
|
2361
2497
|
}
|
|
2362
|
-
function
|
|
2498
|
+
function resolveKeyChildren2(element, value) {
|
|
2363
2499
|
const children = element.props.children ?? element.children;
|
|
2364
2500
|
if (typeof children === "function") {
|
|
2365
2501
|
return children(value);
|
|
@@ -2371,7 +2507,7 @@ function createDynamicElement3(element, tag) {
|
|
|
2371
2507
|
return null;
|
|
2372
2508
|
}
|
|
2373
2509
|
const { component, ...props } = element.props;
|
|
2374
|
-
const children =
|
|
2510
|
+
const children = normalizeContent4(props.children ?? element.children);
|
|
2375
2511
|
return {
|
|
2376
2512
|
tag,
|
|
2377
2513
|
props,
|
|
@@ -2381,17 +2517,17 @@ function createDynamicElement3(element, tag) {
|
|
|
2381
2517
|
function readReactive4(value) {
|
|
2382
2518
|
return isSignal(value) || isComputed(value) ? value.value : value;
|
|
2383
2519
|
}
|
|
2384
|
-
function
|
|
2520
|
+
function normalizeContent4(content) {
|
|
2385
2521
|
if (content == null || typeof content === "boolean") {
|
|
2386
2522
|
return [];
|
|
2387
2523
|
}
|
|
2388
2524
|
return Array.isArray(content) ? content : [content];
|
|
2389
2525
|
}
|
|
2390
|
-
function
|
|
2526
|
+
function isElementLike2(value) {
|
|
2391
2527
|
return value != null && typeof value === "object" && "tag" in value;
|
|
2392
2528
|
}
|
|
2393
|
-
function
|
|
2394
|
-
if (!
|
|
2529
|
+
function getMatchElement(value) {
|
|
2530
|
+
if (!isElementLike2(value)) {
|
|
2395
2531
|
return null;
|
|
2396
2532
|
}
|
|
2397
2533
|
if (isMatchElement(value)) {
|
|
@@ -2476,25 +2612,25 @@ function renderElementH(element, ctx, isComponentRoot) {
|
|
|
2476
2612
|
}
|
|
2477
2613
|
if (isShowElement(element)) {
|
|
2478
2614
|
const when = readReactive5(props.when);
|
|
2479
|
-
const content = when ?
|
|
2615
|
+
const content = when ? resolveShowChildren3(element, when) : props.fallback;
|
|
2480
2616
|
return renderNodeMaybeRoot(content, ctx, isComponentRoot);
|
|
2481
2617
|
}
|
|
2482
2618
|
if (isForElement(element)) {
|
|
2483
2619
|
return renderForElementH(element, ctx);
|
|
2484
2620
|
}
|
|
2485
2621
|
if (isSwitchElement(element)) {
|
|
2486
|
-
return renderNodeMaybeRoot(
|
|
2622
|
+
return renderNodeMaybeRoot(resolveSwitchContent3(element), ctx, isComponentRoot);
|
|
2487
2623
|
}
|
|
2488
2624
|
if (isMatchElement(element)) {
|
|
2489
2625
|
const when = readReactive5(props.when);
|
|
2490
|
-
return renderNodeMaybeRoot(when ?
|
|
2626
|
+
return renderNodeMaybeRoot(when ? resolveMatchChildren3(element, when) : null, ctx, isComponentRoot);
|
|
2491
2627
|
}
|
|
2492
2628
|
if (isIndexElement(element)) {
|
|
2493
2629
|
return renderIndexElementH(element, ctx);
|
|
2494
2630
|
}
|
|
2495
2631
|
if (isKeyElement(element)) {
|
|
2496
2632
|
const key = readReactive5(props.when);
|
|
2497
|
-
return renderNodeMaybeRoot(
|
|
2633
|
+
return renderNodeMaybeRoot(resolveKeyChildren3(element, key), ctx, isComponentRoot);
|
|
2498
2634
|
}
|
|
2499
2635
|
if (isDynamicElement(element)) {
|
|
2500
2636
|
const dynamicTag = readReactive5(props.component);
|
|
@@ -2593,36 +2729,36 @@ function renderIndexElementH(element, ctx) {
|
|
|
2593
2729
|
}
|
|
2594
2730
|
return each.map((item, index) => renderNodeH(props.children(() => item, index), ctx)).join("");
|
|
2595
2731
|
}
|
|
2596
|
-
function
|
|
2732
|
+
function resolveShowChildren3(element, value) {
|
|
2597
2733
|
const children = element.props.children ?? element.children;
|
|
2598
2734
|
if (typeof children === "function") {
|
|
2599
2735
|
return children(value);
|
|
2600
2736
|
}
|
|
2601
2737
|
return children;
|
|
2602
2738
|
}
|
|
2603
|
-
function
|
|
2739
|
+
function resolveSwitchContent3(element) {
|
|
2604
2740
|
const props = element.props;
|
|
2605
|
-
const children =
|
|
2741
|
+
const children = normalizeContent5(props.children ?? element.children);
|
|
2606
2742
|
for (const child of children) {
|
|
2607
|
-
const match =
|
|
2743
|
+
const match = getMatchElement2(child);
|
|
2608
2744
|
if (!match) {
|
|
2609
2745
|
continue;
|
|
2610
2746
|
}
|
|
2611
2747
|
const when = readReactive5(match.props.when);
|
|
2612
2748
|
if (when) {
|
|
2613
|
-
return
|
|
2749
|
+
return resolveMatchChildren3(match, when);
|
|
2614
2750
|
}
|
|
2615
2751
|
}
|
|
2616
2752
|
return props.fallback;
|
|
2617
2753
|
}
|
|
2618
|
-
function
|
|
2754
|
+
function resolveMatchChildren3(element, value) {
|
|
2619
2755
|
const children = element.props.children ?? element.children;
|
|
2620
2756
|
if (typeof children === "function") {
|
|
2621
2757
|
return children(value);
|
|
2622
2758
|
}
|
|
2623
2759
|
return children;
|
|
2624
2760
|
}
|
|
2625
|
-
function
|
|
2761
|
+
function resolveKeyChildren3(element, value) {
|
|
2626
2762
|
const children = element.props.children ?? element.children;
|
|
2627
2763
|
if (typeof children === "function") {
|
|
2628
2764
|
return children(value);
|
|
@@ -2634,7 +2770,7 @@ function createDynamicElement4(element, tag) {
|
|
|
2634
2770
|
return null;
|
|
2635
2771
|
}
|
|
2636
2772
|
const { component, ...props } = element.props;
|
|
2637
|
-
const children =
|
|
2773
|
+
const children = normalizeContent5(props.children ?? element.children);
|
|
2638
2774
|
return {
|
|
2639
2775
|
tag,
|
|
2640
2776
|
props,
|
|
@@ -2644,17 +2780,17 @@ function createDynamicElement4(element, tag) {
|
|
|
2644
2780
|
function readReactive5(value) {
|
|
2645
2781
|
return isSignal(value) || isComputed(value) ? value.value : value;
|
|
2646
2782
|
}
|
|
2647
|
-
function
|
|
2783
|
+
function normalizeContent5(content) {
|
|
2648
2784
|
if (content == null || typeof content === "boolean") {
|
|
2649
2785
|
return [];
|
|
2650
2786
|
}
|
|
2651
2787
|
return Array.isArray(content) ? content : [content];
|
|
2652
2788
|
}
|
|
2653
|
-
function
|
|
2789
|
+
function isElementLike3(value) {
|
|
2654
2790
|
return value != null && typeof value === "object" && "tag" in value;
|
|
2655
2791
|
}
|
|
2656
|
-
function
|
|
2657
|
-
if (!
|
|
2792
|
+
function getMatchElement2(value) {
|
|
2793
|
+
if (!isElementLike3(value)) {
|
|
2658
2794
|
return null;
|
|
2659
2795
|
}
|
|
2660
2796
|
if (isMatchElement(value)) {
|
|
@@ -2945,7 +3081,7 @@ function hydrateAttributes(el, props) {
|
|
|
2945
3081
|
function hydrateControlFlow(element, cursor) {
|
|
2946
3082
|
if (isShowElement(element)) {
|
|
2947
3083
|
const when = readReactive6(element.props.when);
|
|
2948
|
-
const content = when ?
|
|
3084
|
+
const content = when ? resolveShowChildren4(element, when) : element.props.fallback;
|
|
2949
3085
|
return hydrateContent(content, cursor);
|
|
2950
3086
|
}
|
|
2951
3087
|
if (isForElement(element)) {
|
|
@@ -2955,7 +3091,7 @@ function hydrateControlFlow(element, cursor) {
|
|
|
2955
3091
|
return hydrateArray(children, cursor);
|
|
2956
3092
|
}
|
|
2957
3093
|
if (isSwitchElement(element)) {
|
|
2958
|
-
return hydrateContent(
|
|
3094
|
+
return hydrateContent(resolveSwitchContent4(element), cursor);
|
|
2959
3095
|
}
|
|
2960
3096
|
if (isIndexElement(element)) {
|
|
2961
3097
|
const props = element.props;
|
|
@@ -2965,7 +3101,7 @@ function hydrateControlFlow(element, cursor) {
|
|
|
2965
3101
|
}
|
|
2966
3102
|
if (isKeyElement(element)) {
|
|
2967
3103
|
const key = readReactive6(element.props.when);
|
|
2968
|
-
return hydrateContent(
|
|
3104
|
+
return hydrateContent(resolveKeyChildren4(element, key), cursor);
|
|
2969
3105
|
}
|
|
2970
3106
|
if (isDynamicElement(element)) {
|
|
2971
3107
|
const tag = readReactive6(element.props.component);
|
|
@@ -2980,36 +3116,36 @@ function hydrateContent(content, cursor) {
|
|
|
2980
3116
|
}
|
|
2981
3117
|
return Array.isArray(content) ? hydrateArray(content, cursor) : hydrateNode(content, cursor);
|
|
2982
3118
|
}
|
|
2983
|
-
function
|
|
3119
|
+
function resolveShowChildren4(element, value) {
|
|
2984
3120
|
const children = element.props.children ?? element.children;
|
|
2985
3121
|
if (typeof children === "function") {
|
|
2986
3122
|
return children(value);
|
|
2987
3123
|
}
|
|
2988
3124
|
return children;
|
|
2989
3125
|
}
|
|
2990
|
-
function
|
|
3126
|
+
function resolveSwitchContent4(element) {
|
|
2991
3127
|
const props = element.props;
|
|
2992
|
-
const children =
|
|
3128
|
+
const children = normalizeContent6(props.children ?? element.children);
|
|
2993
3129
|
for (const child of children) {
|
|
2994
|
-
const match =
|
|
3130
|
+
const match = getMatchElement3(child);
|
|
2995
3131
|
if (!match) {
|
|
2996
3132
|
continue;
|
|
2997
3133
|
}
|
|
2998
3134
|
const when = readReactive6(match.props.when);
|
|
2999
3135
|
if (when) {
|
|
3000
|
-
return
|
|
3136
|
+
return resolveMatchChildren4(match, when);
|
|
3001
3137
|
}
|
|
3002
3138
|
}
|
|
3003
3139
|
return props.fallback;
|
|
3004
3140
|
}
|
|
3005
|
-
function
|
|
3141
|
+
function resolveMatchChildren4(element, value) {
|
|
3006
3142
|
const children = element.props.children ?? element.children;
|
|
3007
3143
|
if (typeof children === "function") {
|
|
3008
3144
|
return children(value);
|
|
3009
3145
|
}
|
|
3010
3146
|
return children;
|
|
3011
3147
|
}
|
|
3012
|
-
function
|
|
3148
|
+
function resolveKeyChildren4(element, value) {
|
|
3013
3149
|
const children = element.props.children ?? element.children;
|
|
3014
3150
|
if (typeof children === "function") {
|
|
3015
3151
|
return children(value);
|
|
@@ -3021,7 +3157,7 @@ function createDynamicElement5(element, tag) {
|
|
|
3021
3157
|
return null;
|
|
3022
3158
|
}
|
|
3023
3159
|
const { component, ...props } = element.props;
|
|
3024
|
-
const children =
|
|
3160
|
+
const children = normalizeContent6(props.children ?? element.children);
|
|
3025
3161
|
return {
|
|
3026
3162
|
tag,
|
|
3027
3163
|
props,
|
|
@@ -3031,17 +3167,17 @@ function createDynamicElement5(element, tag) {
|
|
|
3031
3167
|
function readReactive6(value) {
|
|
3032
3168
|
return isSignal(value) || isComputed(value) ? value.value : value;
|
|
3033
3169
|
}
|
|
3034
|
-
function
|
|
3170
|
+
function normalizeContent6(content) {
|
|
3035
3171
|
if (content == null || typeof content === "boolean") {
|
|
3036
3172
|
return [];
|
|
3037
3173
|
}
|
|
3038
3174
|
return Array.isArray(content) ? content : [content];
|
|
3039
3175
|
}
|
|
3040
|
-
function
|
|
3176
|
+
function isElementLike4(value) {
|
|
3041
3177
|
return value != null && typeof value === "object" && "tag" in value;
|
|
3042
3178
|
}
|
|
3043
|
-
function
|
|
3044
|
-
if (!
|
|
3179
|
+
function getMatchElement3(value) {
|
|
3180
|
+
if (!isElementLike4(value)) {
|
|
3045
3181
|
return null;
|
|
3046
3182
|
}
|
|
3047
3183
|
if (isMatchElement(value)) {
|
|
@@ -3152,5 +3288,5 @@ function hydrate(component, container, props) {
|
|
|
3152
3288
|
};
|
|
3153
3289
|
}
|
|
3154
3290
|
|
|
3155
|
-
//# debugId=
|
|
3291
|
+
//# debugId=2A80AE62418E0A4664756E2164756E21
|
|
3156
3292
|
//# sourceMappingURL=index.development.js.map
|