sinwan 1.1.1 → 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.
Files changed (38) hide show
  1. package/README.md +34 -3
  2. package/dist/cjs/index.development.js +296 -192
  3. package/dist/cjs/index.development.js.map +9 -9
  4. package/dist/cjs/index.production.min.js +2 -2
  5. package/dist/cjs/index.production.min.js.map +9 -9
  6. package/dist/cjs/renderer/index.development.js +239 -87
  7. package/dist/cjs/renderer/index.development.js.map +8 -8
  8. package/dist/cjs/renderer/index.production.min.js +2 -2
  9. package/dist/cjs/renderer/index.production.min.js.map +8 -8
  10. package/dist/cjs/server/index.development.js +132 -67
  11. package/dist/cjs/server/index.development.js.map +6 -6
  12. package/dist/cjs/server/index.production.min.js +2 -2
  13. package/dist/cjs/server/index.production.min.js.map +6 -6
  14. package/dist/component/control-flow.d.ts +6 -1
  15. package/dist/component/control-flow.d.ts.map +1 -1
  16. package/dist/component/instance.d.ts.map +1 -1
  17. package/dist/esm/index.development.js +296 -192
  18. package/dist/esm/index.development.js.map +9 -9
  19. package/dist/esm/index.production.min.js +2 -2
  20. package/dist/esm/index.production.min.js.map +9 -9
  21. package/dist/esm/renderer/index.development.js +239 -87
  22. package/dist/esm/renderer/index.development.js.map +8 -8
  23. package/dist/esm/renderer/index.production.min.js +2 -2
  24. package/dist/esm/renderer/index.production.min.js.map +8 -8
  25. package/dist/esm/server/index.development.js +132 -67
  26. package/dist/esm/server/index.development.js.map +6 -6
  27. package/dist/esm/server/index.production.min.js +2 -2
  28. package/dist/esm/server/index.production.min.js.map +6 -6
  29. package/dist/reactivity/index.d.ts +1 -1
  30. package/dist/reactivity/index.d.ts.map +1 -1
  31. package/dist/renderer/attributes.d.ts.map +1 -1
  32. package/dist/renderer/events.d.ts.map +1 -1
  33. package/dist/renderer/render-control-flow.d.ts.map +1 -1
  34. package/dist/renderer/render-element.d.ts.map +1 -1
  35. package/dist/renderer/types.d.ts +2 -0
  36. package/dist/renderer/types.d.ts.map +1 -1
  37. package/dist/server/renderer.d.ts.map +1 -1
  38. package/package.json +5 -2
@@ -395,7 +395,7 @@ function resolve(value) {
395
395
  }
396
396
  // src/renderer/events.ts
397
397
  function isEventProp(key) {
398
- return key.length > 2 && key[0] === "o" && key[1] === "n" && key[2] >= "A" && key[2] <= "Z";
398
+ return key.length > 2 && key.startsWith("on");
399
399
  }
400
400
  function toEventName(key) {
401
401
  return key.slice(2).toLowerCase();
@@ -472,19 +472,28 @@ function fireMountedHooks(instance) {
472
472
  }
473
473
  }
474
474
  function fireUnmountedHooks(instance) {
475
- for (const child of instance.children) {
475
+ const children = [...instance.children];
476
+ for (const child of children) {
476
477
  fireUnmountedHooks(child);
477
478
  }
478
- if (instance.isMounted && !instance.isUnmounted) {
479
+ if (!instance.isUnmounted) {
479
480
  instance.isUnmounted = true;
480
- instance.isMounted = false;
481
- for (const hook of instance._unmountedHooks) {
482
- hook();
481
+ if (instance.isMounted) {
482
+ instance.isMounted = false;
483
+ for (const hook of instance._unmountedHooks) {
484
+ hook();
485
+ }
483
486
  }
484
487
  for (const dispose of instance.effects) {
485
488
  dispose();
486
489
  }
487
490
  instance.effects.length = 0;
491
+ if (instance.parent) {
492
+ const idx = instance.parent.children.indexOf(instance);
493
+ if (idx !== -1) {
494
+ instance.parent.children.splice(idx, 1);
495
+ }
496
+ }
488
497
  }
489
498
  }
490
499
  function fireUpdatedHooks(instance) {
@@ -534,7 +543,9 @@ function applyAttributes(el, props) {
534
543
  for (const [key, value] of Object.entries(props)) {
535
544
  if (SKIP_PROPS.has(key) || isEventProp(key))
536
545
  continue;
537
- if (isReactive(value)) {
546
+ const attrName = resolveAttributeName(key);
547
+ const isComplex = attrName === "class" || attrName === "style";
548
+ if (isReactive(value) || isComplex && containsReactive(value)) {
538
549
  const state = { previousStyleProps: new Set };
539
550
  let initialized = false;
540
551
  const dispose = effect(() => {
@@ -596,19 +607,17 @@ function setSingleAttribute(el, key, value, state) {
596
607
  function resolveAttributeName(key) {
597
608
  return PROP_ALIASES[key] ?? key;
598
609
  }
599
- function applyStyle(el, styles, state) {
610
+ function applyStyle(el, value, state) {
611
+ const styleObj = normalizeStyle(value);
600
612
  const nextProps = new Set;
601
- for (const [prop, val] of Object.entries(styles)) {
613
+ for (const [prop, val] of Object.entries(styleObj)) {
602
614
  nextProps.add(prop);
603
615
  if (val == null) {
604
616
  removeStyleProperty(el, prop);
605
617
  continue;
606
618
  }
607
- if (prop.includes("-")) {
608
- el.style.setProperty(prop, String(val));
609
- } else {
610
- el.style[prop] = val;
611
- }
619
+ const kebabProp = prop.startsWith("--") ? prop : camelToKebab(prop);
620
+ el.style.setProperty(kebabProp, String(val));
612
621
  }
613
622
  if (!state) {
614
623
  return;
@@ -620,23 +629,75 @@ function applyStyle(el, styles, state) {
620
629
  }
621
630
  state.previousStyleProps = nextProps;
622
631
  }
632
+ function normalizeStyle(value) {
633
+ const resolved = resolve(value);
634
+ if (!resolved)
635
+ return {};
636
+ if (typeof resolved === "string") {
637
+ return parseStyleString(resolved);
638
+ }
639
+ if (Array.isArray(resolved)) {
640
+ return resolved.reduce((acc, item) => {
641
+ const normalized = normalizeStyle(item);
642
+ return Object.assign(acc, normalized);
643
+ }, {});
644
+ }
645
+ if (typeof resolved === "object") {
646
+ const result = {};
647
+ for (const [k, v] of Object.entries(resolved)) {
648
+ result[k] = resolve(v);
649
+ }
650
+ return result;
651
+ }
652
+ return {};
653
+ }
654
+ function parseStyleString(style) {
655
+ const result = {};
656
+ style.split(";").forEach((rule) => {
657
+ const i = rule.indexOf(":");
658
+ if (i > 0) {
659
+ const prop = rule.slice(0, i).trim();
660
+ const val = rule.slice(i + 1).trim();
661
+ if (prop && val) {
662
+ result[prop] = val;
663
+ }
664
+ }
665
+ });
666
+ return result;
667
+ }
623
668
  function removeStyleProperty(el, prop) {
624
- if (prop.includes("-")) {
625
- el.style.removeProperty(prop);
626
- } else {
627
- el.style[prop] = "";
628
- }
669
+ const kebabProp = prop.startsWith("--") ? prop : camelToKebab(prop);
670
+ el.style.removeProperty(kebabProp);
629
671
  }
630
672
  function applyClass(el, value) {
631
- let classStr;
632
- if (Array.isArray(value)) {
633
- classStr = value.filter(Boolean).join(" ");
634
- } else if (typeof value === "object" && value !== null) {
635
- classStr = Object.entries(value).filter(([, v]) => Boolean(v)).map(([k]) => k).join(" ");
636
- } else {
637
- classStr = String(value);
673
+ domOps.setAttribute(el, "class", normalizeClass(value));
674
+ }
675
+ function normalizeClass(value) {
676
+ const resolved = resolve(value);
677
+ if (!resolved)
678
+ return "";
679
+ if (typeof resolved === "string")
680
+ return resolved;
681
+ if (Array.isArray(resolved)) {
682
+ return resolved.map(normalizeClass).filter(Boolean).join(" ");
683
+ }
684
+ if (typeof resolved === "object") {
685
+ return Object.entries(resolved).filter(([, v]) => Boolean(resolve(v))).map(([k]) => k).join(" ");
686
+ }
687
+ return String(resolved);
688
+ }
689
+ function containsReactive(value) {
690
+ if (isReactive(value))
691
+ return true;
692
+ if (Array.isArray(value))
693
+ return value.some(containsReactive);
694
+ if (typeof value === "object" && value !== null) {
695
+ return Object.values(value).some(containsReactive);
638
696
  }
639
- domOps.setAttribute(el, "class", classStr);
697
+ return false;
698
+ }
699
+ function camelToKebab(str) {
700
+ return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
640
701
  }
641
702
 
642
703
  // src/component/control-flow.ts
@@ -732,6 +793,9 @@ function Portal(props) {
732
793
  children: []
733
794
  };
734
795
  }
796
+ function isElementLike(value) {
797
+ return value != null && typeof value === "object" && "tag" in value;
798
+ }
735
799
  function isShowElement(element) {
736
800
  return element.tag === SHOW_TYPE;
737
801
  }
@@ -756,6 +820,107 @@ function isDynamicElement(element) {
756
820
  function isPortalElement(element) {
757
821
  return element.tag === PORTAL_TYPE;
758
822
  }
823
+ function resolveSwitchContent(element) {
824
+ const props = element.props;
825
+ const children = normalizeContent(props.children ?? element.children);
826
+ const match = findTruthyMatch(children);
827
+ return match !== undefined ? match : props.fallback;
828
+ }
829
+ function findTruthyMatch(nodes) {
830
+ for (const node of nodes) {
831
+ if (node == null || typeof node === "boolean")
832
+ continue;
833
+ if (Array.isArray(node)) {
834
+ const match = findTruthyMatch(node);
835
+ if (match !== undefined)
836
+ return match;
837
+ continue;
838
+ }
839
+ if (isElementLike(node)) {
840
+ let element = node;
841
+ if (typeof element.tag === "function") {
842
+ const tag = element.tag;
843
+ if (tag === Match || tag === Show || tag === For || tag === Index || tag === Key || tag === Switch) {
844
+ element = tag(element.props);
845
+ }
846
+ }
847
+ if (isMatchElement(element)) {
848
+ const when = readReactive(element.props.when);
849
+ if (when) {
850
+ return resolveMatchChildren(element, when);
851
+ }
852
+ } else if (isShowElement(element)) {
853
+ const when = readReactive(element.props.when);
854
+ if (when) {
855
+ const content = resolveShowChildren(element, when);
856
+ const match = findTruthyMatch(normalizeContent(content));
857
+ if (match !== undefined)
858
+ return match;
859
+ } else if (element.props.fallback) {
860
+ const match = findTruthyMatch(normalizeContent(element.props.fallback));
861
+ if (match !== undefined)
862
+ return match;
863
+ }
864
+ } else if (isForElement(element)) {
865
+ const props = element.props;
866
+ const items = readReactive(props.each);
867
+ if (Array.isArray(items)) {
868
+ for (let i = 0;i < items.length; i++) {
869
+ const child = props.children(items[i], () => i);
870
+ const match = findTruthyMatch(normalizeContent(child));
871
+ if (match !== undefined)
872
+ return match;
873
+ }
874
+ }
875
+ } else if (isIndexElement(element)) {
876
+ const props = element.props;
877
+ const items = readReactive(props.each);
878
+ if (Array.isArray(items)) {
879
+ for (let i = 0;i < items.length; i++) {
880
+ const child = props.children(() => items[i], i);
881
+ const match = findTruthyMatch(normalizeContent(child));
882
+ if (match !== undefined)
883
+ return match;
884
+ }
885
+ }
886
+ } else if (isKeyElement(element)) {
887
+ const key = readReactive(element.props.when);
888
+ const child = resolveKeyChildren(element, key);
889
+ const match = findTruthyMatch(normalizeContent(child));
890
+ if (match !== undefined)
891
+ return match;
892
+ }
893
+ }
894
+ }
895
+ return;
896
+ }
897
+ function resolveMatchChildren(element, value) {
898
+ const children = element.props.children ?? element.children;
899
+ if (typeof children === "function") {
900
+ return children(value);
901
+ }
902
+ return children;
903
+ }
904
+ function resolveShowChildren(element, value) {
905
+ const children = element.props.children ?? element.children;
906
+ if (typeof children === "function") {
907
+ return children(value);
908
+ }
909
+ return children;
910
+ }
911
+ function resolveKeyChildren(element, value) {
912
+ const children = element.props.children ?? element.children;
913
+ if (typeof children === "function") {
914
+ return children(value);
915
+ }
916
+ return children;
917
+ }
918
+ function normalizeContent(content) {
919
+ if (content == null || typeof content === "boolean") {
920
+ return [];
921
+ }
922
+ return Array.isArray(content) ? content : [content];
923
+ }
759
924
  function normalizeChildren2(children) {
760
925
  if (children == null || typeof children === "boolean") {
761
926
  return [];
@@ -895,8 +1060,10 @@ function renderShowBlock(element, block, parent, namespace, owner) {
895
1060
  return effect(() => {
896
1061
  clearChildren(block);
897
1062
  const when = readReactive2(element.props.when);
898
- const content = withOptionalInstance(owner, () => when ? resolveShowChildren(element, when) : element.props.fallback);
899
- block.children = renderBlockContent(content, parent, block.endAnchor, namespace, owner);
1063
+ block.children = withOptionalInstance(owner, () => {
1064
+ const content = when ? resolveShowChildren(element, when) : element.props.fallback;
1065
+ return renderBlockContent(content, parent, block.endAnchor, namespace, owner);
1066
+ });
900
1067
  if (initialized) {
901
1068
  fireMountedAndQueueUpdated(owner);
902
1069
  }
@@ -1083,18 +1250,31 @@ function renderPortal(element, parent, anchor, namespace) {
1083
1250
  insertNode(parent, placeholder, anchor);
1084
1251
  const owner = getCurrentInstance();
1085
1252
  let disposeEffect = () => {};
1253
+ const targetAnchor = domOps.createComment("Sinwan-pa");
1254
+ let lastTarget = null;
1086
1255
  const portal = {
1087
1256
  type: "portal",
1088
1257
  anchor: placeholder,
1089
1258
  children: [],
1090
- dispose: () => disposeEffect()
1259
+ dispose: () => disposeEffect(),
1260
+ targetAnchor
1091
1261
  };
1092
1262
  let initialized = false;
1093
1263
  disposeEffect = effect(() => {
1094
- clearPortalChildren(portal);
1095
1264
  const target = resolvePortalTarget(element.props.mount);
1265
+ if (target !== lastTarget) {
1266
+ if (lastTarget) {
1267
+ domOps.remove(targetAnchor);
1268
+ }
1269
+ if (target) {
1270
+ domOps.appendChild(target, targetAnchor);
1271
+ }
1272
+ lastTarget = target;
1273
+ portal.target = target;
1274
+ }
1275
+ clearPortalChildren(portal);
1096
1276
  if (target) {
1097
- portal.children = renderBlockContent(element.props.children ?? element.children, target, null, namespace, owner);
1277
+ portal.children = renderBlockContent(element.props.children ?? element.children, target, targetAnchor, namespace, owner);
1098
1278
  }
1099
1279
  if (initialized) {
1100
1280
  fireMountedAndQueueUpdated(owner);
@@ -1103,48 +1283,12 @@ function renderPortal(element, parent, anchor, namespace) {
1103
1283
  });
1104
1284
  return portal;
1105
1285
  }
1106
- function resolveShowChildren(element, value) {
1107
- const children = element.props.children ?? element.children;
1108
- if (typeof children === "function") {
1109
- return children(value);
1110
- }
1111
- return children;
1112
- }
1113
- function resolveSwitchContent(element) {
1114
- const props = element.props;
1115
- const children = normalizeContent(props.children ?? element.children);
1116
- for (const child of children) {
1117
- const match = getMatchElement(child);
1118
- if (!match) {
1119
- continue;
1120
- }
1121
- const when = readReactive2(match.props.when);
1122
- if (when) {
1123
- return resolveMatchChildren(match, when);
1124
- }
1125
- }
1126
- return props.fallback;
1127
- }
1128
- function resolveMatchChildren(element, value) {
1129
- const children = element.props.children ?? element.children;
1130
- if (typeof children === "function") {
1131
- return children(value);
1132
- }
1133
- return children;
1134
- }
1135
- function resolveKeyChildren(element, value) {
1136
- const children = element.props.children ?? element.children;
1137
- if (typeof children === "function") {
1138
- return children(value);
1139
- }
1140
- return children;
1141
- }
1142
1286
  function createDynamicElement(element, tag) {
1143
1287
  if (typeof tag !== "string" && typeof tag !== "function") {
1144
1288
  return null;
1145
1289
  }
1146
1290
  const { component, ...props } = element.props;
1147
- const children = normalizeContent(props.children ?? element.children);
1291
+ const children = normalizeContent2(props.children ?? element.children);
1148
1292
  return {
1149
1293
  tag,
1150
1294
  props,
@@ -1152,11 +1296,14 @@ function createDynamicElement(element, tag) {
1152
1296
  };
1153
1297
  }
1154
1298
  function renderBlockContent(content, parent, anchor, namespace, owner) {
1155
- if (content == null || typeof content === "boolean") {
1299
+ if (content == null || typeof content === "boolean")
1156
1300
  return [];
1157
- }
1158
- const nodes = Array.isArray(content) ? content : [content];
1159
- return nodes.map((node) => withOptionalInstance(owner, () => renderNodeToDOM(node, parent, anchor, namespace)));
1301
+ return withOptionalInstance(owner, () => {
1302
+ if (Array.isArray(content)) {
1303
+ return content.map((child) => renderNodeToDOM(child, parent, anchor, namespace));
1304
+ }
1305
+ return [renderNodeToDOM(content, parent, anchor, namespace)];
1306
+ });
1160
1307
  }
1161
1308
  function clearChildren(block) {
1162
1309
  for (const child of block.children) {
@@ -1174,6 +1321,23 @@ function moveBeforeEnd(parent, mounted, endAnchor) {
1174
1321
  for (const node of getMountedDomNodes(mounted)) {
1175
1322
  domOps.insertBefore(parent, node, endAnchor);
1176
1323
  }
1324
+ syncPortalOrder(mounted);
1325
+ }
1326
+ function syncPortalOrder(mounted) {
1327
+ if (mounted.type === "portal") {
1328
+ if (mounted.target && mounted.targetAnchor) {
1329
+ for (const child of mounted.children) {
1330
+ for (const node of getMountedDomNodes(child)) {
1331
+ domOps.appendChild(mounted.target, node);
1332
+ }
1333
+ }
1334
+ domOps.appendChild(mounted.target, mounted.targetAnchor);
1335
+ }
1336
+ } else if ("children" in mounted && Array.isArray(mounted.children)) {
1337
+ for (const child of mounted.children) {
1338
+ syncPortalOrder(child);
1339
+ }
1340
+ }
1177
1341
  }
1178
1342
  function fireMountedAndQueueUpdated(owner) {
1179
1343
  if (owner) {
@@ -1187,24 +1351,12 @@ function withOptionalInstance(owner, fn) {
1187
1351
  function readReactive2(value) {
1188
1352
  return resolve(value);
1189
1353
  }
1190
- function normalizeContent(content) {
1354
+ function normalizeContent2(content) {
1191
1355
  if (content == null || typeof content === "boolean") {
1192
1356
  return [];
1193
1357
  }
1194
1358
  return Array.isArray(content) ? content : [content];
1195
1359
  }
1196
- function isElementLike(value) {
1197
- return value != null && typeof value === "object" && "tag" in value;
1198
- }
1199
- function getMatchElement(value) {
1200
- if (!isElementLike(value)) {
1201
- return null;
1202
- }
1203
- if (isMatchElement(value)) {
1204
- return value;
1205
- }
1206
- return value.tag === Match ? Match(value.props) : null;
1207
- }
1208
1360
  function resolvePortalTarget(value) {
1209
1361
  const target = readReactive2(value);
1210
1362
  if (target == null) {
@@ -1661,24 +1813,24 @@ async function renderElement(element) {
1661
1813
  }
1662
1814
  if (isShowElement(element)) {
1663
1815
  const when = readReactive3(props.when);
1664
- return renderToString(when ? resolveShowChildren2(element, when) : props.fallback);
1816
+ return renderToString(when ? resolveShowChildren(element, when) : props.fallback);
1665
1817
  }
1666
1818
  if (isForElement(element)) {
1667
1819
  return renderForElement(element);
1668
1820
  }
1669
1821
  if (isSwitchElement(element)) {
1670
- return renderToString(resolveSwitchContent2(element));
1822
+ return renderToString(resolveSwitchContent(element));
1671
1823
  }
1672
1824
  if (isMatchElement(element)) {
1673
1825
  const when = readReactive3(props.when);
1674
- return renderToString(when ? resolveMatchChildren2(element, when) : null);
1826
+ return renderToString(when ? resolveMatchChildren(element, when) : null);
1675
1827
  }
1676
1828
  if (isIndexElement(element)) {
1677
1829
  return renderIndexElement(element);
1678
1830
  }
1679
1831
  if (isKeyElement(element)) {
1680
1832
  const key = readReactive3(props.when);
1681
- return renderToString(resolveKeyChildren2(element, key));
1833
+ return renderToString(resolveKeyChildren(element, key));
1682
1834
  }
1683
1835
  if (isDynamicElement(element)) {
1684
1836
  const tag2 = readReactive3(props.component);
@@ -1768,75 +1920,27 @@ async function renderIndexElement(element) {
1768
1920
  const rendered = await Promise.all(each.map((item, index) => renderToString(props.children(() => item, index))));
1769
1921
  return rendered.join("");
1770
1922
  }
1771
- function resolveSwitchContent2(element) {
1772
- const props = element.props;
1773
- const children = normalizeContent2(props.children ?? element.children);
1774
- for (const child of children) {
1775
- const match = getMatchElement2(child);
1776
- if (!match) {
1777
- continue;
1778
- }
1779
- const when = readReactive3(match.props.when);
1780
- if (when) {
1781
- return resolveMatchChildren2(match, when);
1782
- }
1783
- }
1784
- return props.fallback;
1785
- }
1786
- function resolveMatchChildren2(element, value) {
1787
- const children = element.props.children ?? element.children;
1788
- if (typeof children === "function") {
1789
- return children(value);
1790
- }
1791
- return children;
1792
- }
1793
- function resolveKeyChildren2(element, value) {
1794
- const children = element.props.children ?? element.children;
1795
- if (typeof children === "function") {
1796
- return children(value);
1797
- }
1798
- return children;
1799
- }
1800
1923
  function createDynamicElement2(element, tag) {
1801
1924
  if (typeof tag !== "string" && typeof tag !== "function") {
1802
1925
  return null;
1803
1926
  }
1804
1927
  const { component, ...props } = element.props;
1805
- const children = normalizeContent2(props.children ?? element.children);
1928
+ const children = normalizeContent3(props.children ?? element.children);
1806
1929
  return {
1807
1930
  tag,
1808
1931
  props,
1809
1932
  children
1810
1933
  };
1811
1934
  }
1812
- function resolveShowChildren2(element, value) {
1813
- const children = element.props.children ?? element.children;
1814
- if (typeof children === "function") {
1815
- return children(value);
1816
- }
1817
- return children;
1818
- }
1819
1935
  function readReactive3(value) {
1820
1936
  return isSignal(value) || isComputed(value) ? value.value : value;
1821
1937
  }
1822
- function normalizeContent2(content) {
1938
+ function normalizeContent3(content) {
1823
1939
  if (content == null || typeof content === "boolean") {
1824
1940
  return [];
1825
1941
  }
1826
1942
  return Array.isArray(content) ? content : [content];
1827
1943
  }
1828
- function isElementLike2(value) {
1829
- return value != null && typeof value === "object" && "tag" in value;
1830
- }
1831
- function getMatchElement2(value) {
1832
- if (!isElementLike2(value)) {
1833
- return null;
1834
- }
1835
- if (isMatchElement(value)) {
1836
- return value;
1837
- }
1838
- return value.tag === Match ? Match(value.props) : null;
1839
- }
1840
1944
  // src/hydration/markers.ts
1841
1945
  var COMP_ID_ATTR = "data-sinwan-id";
1842
1946
  var COMP_ID_PREFIX = "c";
@@ -1971,7 +2075,7 @@ async function streamElement(element, controller, encoder) {
1971
2075
  }
1972
2076
  if (isShowElement(element)) {
1973
2077
  const when = readReactive4(props.when);
1974
- await streamNode(when ? resolveShowChildren3(element, when) : props.fallback, controller, encoder);
2078
+ await streamNode(when ? resolveShowChildren2(element, when) : props.fallback, controller, encoder);
1975
2079
  return;
1976
2080
  }
1977
2081
  if (isForElement(element)) {
@@ -1979,12 +2083,12 @@ async function streamElement(element, controller, encoder) {
1979
2083
  return;
1980
2084
  }
1981
2085
  if (isSwitchElement(element)) {
1982
- await streamNode(resolveSwitchContent3(element), controller, encoder);
2086
+ await streamNode(resolveSwitchContent2(element), controller, encoder);
1983
2087
  return;
1984
2088
  }
1985
2089
  if (isMatchElement(element)) {
1986
2090
  const when = readReactive4(props.when);
1987
- await streamNode(when ? resolveMatchChildren3(element, when) : null, controller, encoder);
2091
+ await streamNode(when ? resolveMatchChildren2(element, when) : null, controller, encoder);
1988
2092
  return;
1989
2093
  }
1990
2094
  if (isIndexElement(element)) {
@@ -1993,7 +2097,7 @@ async function streamElement(element, controller, encoder) {
1993
2097
  }
1994
2098
  if (isKeyElement(element)) {
1995
2099
  const key = readReactive4(props.when);
1996
- await streamNode(resolveKeyChildren3(element, key), controller, encoder);
2100
+ await streamNode(resolveKeyChildren2(element, key), controller, encoder);
1997
2101
  return;
1998
2102
  }
1999
2103
  if (isDynamicElement(element)) {
@@ -2099,7 +2203,7 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
2099
2203
  }
2100
2204
  if (isShowElement(element)) {
2101
2205
  const when = readReactive4(props.when);
2102
- await streamHydratableNodeToController(when ? resolveShowChildren3(element, when) : props.fallback, controller, encoder, ctx, isComponentRoot);
2206
+ await streamHydratableNodeToController(when ? resolveShowChildren2(element, when) : props.fallback, controller, encoder, ctx, isComponentRoot);
2103
2207
  return;
2104
2208
  }
2105
2209
  if (isForElement(element)) {
@@ -2107,12 +2211,12 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
2107
2211
  return;
2108
2212
  }
2109
2213
  if (isSwitchElement(element)) {
2110
- await streamHydratableNodeToController(resolveSwitchContent3(element), controller, encoder, ctx, isComponentRoot);
2214
+ await streamHydratableNodeToController(resolveSwitchContent2(element), controller, encoder, ctx, isComponentRoot);
2111
2215
  return;
2112
2216
  }
2113
2217
  if (isMatchElement(element)) {
2114
2218
  const when = readReactive4(props.when);
2115
- await streamHydratableNodeToController(when ? resolveMatchChildren3(element, when) : null, controller, encoder, ctx, isComponentRoot);
2219
+ await streamHydratableNodeToController(when ? resolveMatchChildren2(element, when) : null, controller, encoder, ctx, isComponentRoot);
2116
2220
  return;
2117
2221
  }
2118
2222
  if (isIndexElement(element)) {
@@ -2121,7 +2225,7 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
2121
2225
  }
2122
2226
  if (isKeyElement(element)) {
2123
2227
  const key = readReactive4(props.when);
2124
- await streamHydratableNodeToController(resolveKeyChildren3(element, key), controller, encoder, ctx, isComponentRoot);
2228
+ await streamHydratableNodeToController(resolveKeyChildren2(element, key), controller, encoder, ctx, isComponentRoot);
2125
2229
  return;
2126
2230
  }
2127
2231
  if (isDynamicElement(element)) {
@@ -2278,36 +2382,36 @@ async function streamIndexElement(element, controller, encoder) {
2278
2382
  await streamNode(props.children(() => each[index], index), controller, encoder);
2279
2383
  }
2280
2384
  }
2281
- function resolveShowChildren3(element, value) {
2385
+ function resolveShowChildren2(element, value) {
2282
2386
  const children = element.props.children ?? element.children;
2283
2387
  if (typeof children === "function") {
2284
2388
  return children(value);
2285
2389
  }
2286
2390
  return children;
2287
2391
  }
2288
- function resolveSwitchContent3(element) {
2392
+ function resolveSwitchContent2(element) {
2289
2393
  const props = element.props;
2290
- const children = normalizeContent3(props.children ?? element.children);
2394
+ const children = normalizeContent4(props.children ?? element.children);
2291
2395
  for (const child of children) {
2292
- const match = getMatchElement3(child);
2396
+ const match = getMatchElement(child);
2293
2397
  if (!match) {
2294
2398
  continue;
2295
2399
  }
2296
2400
  const when = readReactive4(match.props.when);
2297
2401
  if (when) {
2298
- return resolveMatchChildren3(match, when);
2402
+ return resolveMatchChildren2(match, when);
2299
2403
  }
2300
2404
  }
2301
2405
  return props.fallback;
2302
2406
  }
2303
- function resolveMatchChildren3(element, value) {
2407
+ function resolveMatchChildren2(element, value) {
2304
2408
  const children = element.props.children ?? element.children;
2305
2409
  if (typeof children === "function") {
2306
2410
  return children(value);
2307
2411
  }
2308
2412
  return children;
2309
2413
  }
2310
- function resolveKeyChildren3(element, value) {
2414
+ function resolveKeyChildren2(element, value) {
2311
2415
  const children = element.props.children ?? element.children;
2312
2416
  if (typeof children === "function") {
2313
2417
  return children(value);
@@ -2319,7 +2423,7 @@ function createDynamicElement3(element, tag) {
2319
2423
  return null;
2320
2424
  }
2321
2425
  const { component, ...props } = element.props;
2322
- const children = normalizeContent3(props.children ?? element.children);
2426
+ const children = normalizeContent4(props.children ?? element.children);
2323
2427
  return {
2324
2428
  tag,
2325
2429
  props,
@@ -2329,17 +2433,17 @@ function createDynamicElement3(element, tag) {
2329
2433
  function readReactive4(value) {
2330
2434
  return isSignal(value) || isComputed(value) ? value.value : value;
2331
2435
  }
2332
- function normalizeContent3(content) {
2436
+ function normalizeContent4(content) {
2333
2437
  if (content == null || typeof content === "boolean") {
2334
2438
  return [];
2335
2439
  }
2336
2440
  return Array.isArray(content) ? content : [content];
2337
2441
  }
2338
- function isElementLike3(value) {
2442
+ function isElementLike2(value) {
2339
2443
  return value != null && typeof value === "object" && "tag" in value;
2340
2444
  }
2341
- function getMatchElement3(value) {
2342
- if (!isElementLike3(value)) {
2445
+ function getMatchElement(value) {
2446
+ if (!isElementLike2(value)) {
2343
2447
  return null;
2344
2448
  }
2345
2449
  if (isMatchElement(value)) {
@@ -2424,25 +2528,25 @@ function renderElementH(element, ctx, isComponentRoot) {
2424
2528
  }
2425
2529
  if (isShowElement(element)) {
2426
2530
  const when = readReactive5(props.when);
2427
- const content = when ? resolveShowChildren4(element, when) : props.fallback;
2531
+ const content = when ? resolveShowChildren3(element, when) : props.fallback;
2428
2532
  return renderNodeMaybeRoot(content, ctx, isComponentRoot);
2429
2533
  }
2430
2534
  if (isForElement(element)) {
2431
2535
  return renderForElementH(element, ctx);
2432
2536
  }
2433
2537
  if (isSwitchElement(element)) {
2434
- return renderNodeMaybeRoot(resolveSwitchContent4(element), ctx, isComponentRoot);
2538
+ return renderNodeMaybeRoot(resolveSwitchContent3(element), ctx, isComponentRoot);
2435
2539
  }
2436
2540
  if (isMatchElement(element)) {
2437
2541
  const when = readReactive5(props.when);
2438
- return renderNodeMaybeRoot(when ? resolveMatchChildren4(element, when) : null, ctx, isComponentRoot);
2542
+ return renderNodeMaybeRoot(when ? resolveMatchChildren3(element, when) : null, ctx, isComponentRoot);
2439
2543
  }
2440
2544
  if (isIndexElement(element)) {
2441
2545
  return renderIndexElementH(element, ctx);
2442
2546
  }
2443
2547
  if (isKeyElement(element)) {
2444
2548
  const key = readReactive5(props.when);
2445
- return renderNodeMaybeRoot(resolveKeyChildren4(element, key), ctx, isComponentRoot);
2549
+ return renderNodeMaybeRoot(resolveKeyChildren3(element, key), ctx, isComponentRoot);
2446
2550
  }
2447
2551
  if (isDynamicElement(element)) {
2448
2552
  const dynamicTag = readReactive5(props.component);
@@ -2541,36 +2645,36 @@ function renderIndexElementH(element, ctx) {
2541
2645
  }
2542
2646
  return each.map((item, index) => renderNodeH(props.children(() => item, index), ctx)).join("");
2543
2647
  }
2544
- function resolveShowChildren4(element, value) {
2648
+ function resolveShowChildren3(element, value) {
2545
2649
  const children = element.props.children ?? element.children;
2546
2650
  if (typeof children === "function") {
2547
2651
  return children(value);
2548
2652
  }
2549
2653
  return children;
2550
2654
  }
2551
- function resolveSwitchContent4(element) {
2655
+ function resolveSwitchContent3(element) {
2552
2656
  const props = element.props;
2553
- const children = normalizeContent4(props.children ?? element.children);
2657
+ const children = normalizeContent5(props.children ?? element.children);
2554
2658
  for (const child of children) {
2555
- const match = getMatchElement4(child);
2659
+ const match = getMatchElement2(child);
2556
2660
  if (!match) {
2557
2661
  continue;
2558
2662
  }
2559
2663
  const when = readReactive5(match.props.when);
2560
2664
  if (when) {
2561
- return resolveMatchChildren4(match, when);
2665
+ return resolveMatchChildren3(match, when);
2562
2666
  }
2563
2667
  }
2564
2668
  return props.fallback;
2565
2669
  }
2566
- function resolveMatchChildren4(element, value) {
2670
+ function resolveMatchChildren3(element, value) {
2567
2671
  const children = element.props.children ?? element.children;
2568
2672
  if (typeof children === "function") {
2569
2673
  return children(value);
2570
2674
  }
2571
2675
  return children;
2572
2676
  }
2573
- function resolveKeyChildren4(element, value) {
2677
+ function resolveKeyChildren3(element, value) {
2574
2678
  const children = element.props.children ?? element.children;
2575
2679
  if (typeof children === "function") {
2576
2680
  return children(value);
@@ -2582,7 +2686,7 @@ function createDynamicElement4(element, tag) {
2582
2686
  return null;
2583
2687
  }
2584
2688
  const { component, ...props } = element.props;
2585
- const children = normalizeContent4(props.children ?? element.children);
2689
+ const children = normalizeContent5(props.children ?? element.children);
2586
2690
  return {
2587
2691
  tag,
2588
2692
  props,
@@ -2592,17 +2696,17 @@ function createDynamicElement4(element, tag) {
2592
2696
  function readReactive5(value) {
2593
2697
  return isSignal(value) || isComputed(value) ? value.value : value;
2594
2698
  }
2595
- function normalizeContent4(content) {
2699
+ function normalizeContent5(content) {
2596
2700
  if (content == null || typeof content === "boolean") {
2597
2701
  return [];
2598
2702
  }
2599
2703
  return Array.isArray(content) ? content : [content];
2600
2704
  }
2601
- function isElementLike4(value) {
2705
+ function isElementLike3(value) {
2602
2706
  return value != null && typeof value === "object" && "tag" in value;
2603
2707
  }
2604
- function getMatchElement4(value) {
2605
- if (!isElementLike4(value)) {
2708
+ function getMatchElement2(value) {
2709
+ if (!isElementLike3(value)) {
2606
2710
  return null;
2607
2711
  }
2608
2712
  if (isMatchElement(value)) {
@@ -2834,7 +2938,7 @@ function hydrateAttributes(el, props) {
2834
2938
  function hydrateControlFlow(element, cursor) {
2835
2939
  if (isShowElement(element)) {
2836
2940
  const when = readReactive6(element.props.when);
2837
- const content = when ? resolveShowChildren5(element, when) : element.props.fallback;
2941
+ const content = when ? resolveShowChildren4(element, when) : element.props.fallback;
2838
2942
  return hydrateContent(content, cursor);
2839
2943
  }
2840
2944
  if (isForElement(element)) {
@@ -2844,7 +2948,7 @@ function hydrateControlFlow(element, cursor) {
2844
2948
  return hydrateArray(children, cursor);
2845
2949
  }
2846
2950
  if (isSwitchElement(element)) {
2847
- return hydrateContent(resolveSwitchContent5(element), cursor);
2951
+ return hydrateContent(resolveSwitchContent4(element), cursor);
2848
2952
  }
2849
2953
  if (isIndexElement(element)) {
2850
2954
  const props = element.props;
@@ -2854,7 +2958,7 @@ function hydrateControlFlow(element, cursor) {
2854
2958
  }
2855
2959
  if (isKeyElement(element)) {
2856
2960
  const key = readReactive6(element.props.when);
2857
- return hydrateContent(resolveKeyChildren5(element, key), cursor);
2961
+ return hydrateContent(resolveKeyChildren4(element, key), cursor);
2858
2962
  }
2859
2963
  if (isDynamicElement(element)) {
2860
2964
  const tag = readReactive6(element.props.component);
@@ -2869,36 +2973,36 @@ function hydrateContent(content, cursor) {
2869
2973
  }
2870
2974
  return Array.isArray(content) ? hydrateArray(content, cursor) : hydrateNode(content, cursor);
2871
2975
  }
2872
- function resolveShowChildren5(element, value) {
2976
+ function resolveShowChildren4(element, value) {
2873
2977
  const children = element.props.children ?? element.children;
2874
2978
  if (typeof children === "function") {
2875
2979
  return children(value);
2876
2980
  }
2877
2981
  return children;
2878
2982
  }
2879
- function resolveSwitchContent5(element) {
2983
+ function resolveSwitchContent4(element) {
2880
2984
  const props = element.props;
2881
- const children = normalizeContent5(props.children ?? element.children);
2985
+ const children = normalizeContent6(props.children ?? element.children);
2882
2986
  for (const child of children) {
2883
- const match = getMatchElement5(child);
2987
+ const match = getMatchElement3(child);
2884
2988
  if (!match) {
2885
2989
  continue;
2886
2990
  }
2887
2991
  const when = readReactive6(match.props.when);
2888
2992
  if (when) {
2889
- return resolveMatchChildren5(match, when);
2993
+ return resolveMatchChildren4(match, when);
2890
2994
  }
2891
2995
  }
2892
2996
  return props.fallback;
2893
2997
  }
2894
- function resolveMatchChildren5(element, value) {
2998
+ function resolveMatchChildren4(element, value) {
2895
2999
  const children = element.props.children ?? element.children;
2896
3000
  if (typeof children === "function") {
2897
3001
  return children(value);
2898
3002
  }
2899
3003
  return children;
2900
3004
  }
2901
- function resolveKeyChildren5(element, value) {
3005
+ function resolveKeyChildren4(element, value) {
2902
3006
  const children = element.props.children ?? element.children;
2903
3007
  if (typeof children === "function") {
2904
3008
  return children(value);
@@ -2910,7 +3014,7 @@ function createDynamicElement5(element, tag) {
2910
3014
  return null;
2911
3015
  }
2912
3016
  const { component, ...props } = element.props;
2913
- const children = normalizeContent5(props.children ?? element.children);
3017
+ const children = normalizeContent6(props.children ?? element.children);
2914
3018
  return {
2915
3019
  tag,
2916
3020
  props,
@@ -2920,17 +3024,17 @@ function createDynamicElement5(element, tag) {
2920
3024
  function readReactive6(value) {
2921
3025
  return isSignal(value) || isComputed(value) ? value.value : value;
2922
3026
  }
2923
- function normalizeContent5(content) {
3027
+ function normalizeContent6(content) {
2924
3028
  if (content == null || typeof content === "boolean") {
2925
3029
  return [];
2926
3030
  }
2927
3031
  return Array.isArray(content) ? content : [content];
2928
3032
  }
2929
- function isElementLike5(value) {
3033
+ function isElementLike4(value) {
2930
3034
  return value != null && typeof value === "object" && "tag" in value;
2931
3035
  }
2932
- function getMatchElement5(value) {
2933
- if (!isElementLike5(value)) {
3036
+ function getMatchElement3(value) {
3037
+ if (!isElementLike4(value)) {
2934
3038
  return null;
2935
3039
  }
2936
3040
  if (isMatchElement(value)) {
@@ -3097,5 +3201,5 @@ export {
3097
3201
  Dynamic
3098
3202
  };
3099
3203
 
3100
- //# debugId=D6124451AF9E145564756E2164756E21
3204
+ //# debugId=325D4F9F85E0A68464756E2164756E21
3101
3205
  //# sourceMappingURL=index.development.js.map