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
@@ -462,7 +462,7 @@ function resolve(value) {
462
462
  }
463
463
  // src/renderer/events.ts
464
464
  function isEventProp(key) {
465
- return key.length > 2 && key[0] === "o" && key[1] === "n" && key[2] >= "A" && key[2] <= "Z";
465
+ return key.length > 2 && key.startsWith("on");
466
466
  }
467
467
  function toEventName(key) {
468
468
  return key.slice(2).toLowerCase();
@@ -539,19 +539,28 @@ function fireMountedHooks(instance) {
539
539
  }
540
540
  }
541
541
  function fireUnmountedHooks(instance) {
542
- for (const child of instance.children) {
542
+ const children = [...instance.children];
543
+ for (const child of children) {
543
544
  fireUnmountedHooks(child);
544
545
  }
545
- if (instance.isMounted && !instance.isUnmounted) {
546
+ if (!instance.isUnmounted) {
546
547
  instance.isUnmounted = true;
547
- instance.isMounted = false;
548
- for (const hook of instance._unmountedHooks) {
549
- hook();
548
+ if (instance.isMounted) {
549
+ instance.isMounted = false;
550
+ for (const hook of instance._unmountedHooks) {
551
+ hook();
552
+ }
550
553
  }
551
554
  for (const dispose of instance.effects) {
552
555
  dispose();
553
556
  }
554
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
+ }
555
564
  }
556
565
  }
557
566
  function fireUpdatedHooks(instance) {
@@ -601,7 +610,9 @@ function applyAttributes(el, props) {
601
610
  for (const [key, value] of Object.entries(props)) {
602
611
  if (SKIP_PROPS.has(key) || isEventProp(key))
603
612
  continue;
604
- if (isReactive(value)) {
613
+ const attrName = resolveAttributeName(key);
614
+ const isComplex = attrName === "class" || attrName === "style";
615
+ if (isReactive(value) || isComplex && containsReactive(value)) {
605
616
  const state = { previousStyleProps: new Set };
606
617
  let initialized = false;
607
618
  const dispose = effect(() => {
@@ -663,19 +674,17 @@ function setSingleAttribute(el, key, value, state) {
663
674
  function resolveAttributeName(key) {
664
675
  return PROP_ALIASES[key] ?? key;
665
676
  }
666
- function applyStyle(el, styles, state) {
677
+ function applyStyle(el, value, state) {
678
+ const styleObj = normalizeStyle(value);
667
679
  const nextProps = new Set;
668
- for (const [prop, val] of Object.entries(styles)) {
680
+ for (const [prop, val] of Object.entries(styleObj)) {
669
681
  nextProps.add(prop);
670
682
  if (val == null) {
671
683
  removeStyleProperty(el, prop);
672
684
  continue;
673
685
  }
674
- if (prop.includes("-")) {
675
- el.style.setProperty(prop, String(val));
676
- } else {
677
- el.style[prop] = val;
678
- }
686
+ const kebabProp = prop.startsWith("--") ? prop : camelToKebab(prop);
687
+ el.style.setProperty(kebabProp, String(val));
679
688
  }
680
689
  if (!state) {
681
690
  return;
@@ -687,23 +696,75 @@ function applyStyle(el, styles, state) {
687
696
  }
688
697
  state.previousStyleProps = nextProps;
689
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
+ }
690
735
  function removeStyleProperty(el, prop) {
691
- if (prop.includes("-")) {
692
- el.style.removeProperty(prop);
693
- } else {
694
- el.style[prop] = "";
695
- }
736
+ const kebabProp = prop.startsWith("--") ? prop : camelToKebab(prop);
737
+ el.style.removeProperty(kebabProp);
696
738
  }
697
739
  function applyClass(el, value) {
698
- let classStr;
699
- if (Array.isArray(value)) {
700
- classStr = value.filter(Boolean).join(" ");
701
- } else if (typeof value === "object" && value !== null) {
702
- classStr = Object.entries(value).filter(([, v]) => Boolean(v)).map(([k]) => k).join(" ");
703
- } else {
704
- classStr = String(value);
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(" ");
750
+ }
751
+ if (typeof resolved === "object") {
752
+ return Object.entries(resolved).filter(([, v]) => Boolean(resolve(v))).map(([k]) => k).join(" ");
753
+ }
754
+ return String(resolved);
755
+ }
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);
705
763
  }
706
- domOps.setAttribute(el, "class", classStr);
764
+ return false;
765
+ }
766
+ function camelToKebab(str) {
767
+ return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
707
768
  }
708
769
 
709
770
  // src/component/control-flow.ts
@@ -799,6 +860,9 @@ function Portal(props) {
799
860
  children: []
800
861
  };
801
862
  }
863
+ function isElementLike(value) {
864
+ return value != null && typeof value === "object" && "tag" in value;
865
+ }
802
866
  function isShowElement(element) {
803
867
  return element.tag === SHOW_TYPE;
804
868
  }
@@ -823,6 +887,107 @@ function isDynamicElement(element) {
823
887
  function isPortalElement(element) {
824
888
  return element.tag === PORTAL_TYPE;
825
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
+ }
826
991
  function normalizeChildren2(children) {
827
992
  if (children == null || typeof children === "boolean") {
828
993
  return [];
@@ -962,8 +1127,10 @@ function renderShowBlock(element, block, parent, namespace, owner) {
962
1127
  return effect(() => {
963
1128
  clearChildren(block);
964
1129
  const when = readReactive2(element.props.when);
965
- const content = withOptionalInstance(owner, () => when ? resolveShowChildren(element, when) : element.props.fallback);
966
- block.children = renderBlockContent(content, parent, block.endAnchor, namespace, owner);
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
+ });
967
1134
  if (initialized) {
968
1135
  fireMountedAndQueueUpdated(owner);
969
1136
  }
@@ -1150,18 +1317,31 @@ function renderPortal(element, parent, anchor, namespace) {
1150
1317
  insertNode(parent, placeholder, anchor);
1151
1318
  const owner = getCurrentInstance();
1152
1319
  let disposeEffect = () => {};
1320
+ const targetAnchor = domOps.createComment("Sinwan-pa");
1321
+ let lastTarget = null;
1153
1322
  const portal = {
1154
1323
  type: "portal",
1155
1324
  anchor: placeholder,
1156
1325
  children: [],
1157
- dispose: () => disposeEffect()
1326
+ dispose: () => disposeEffect(),
1327
+ targetAnchor
1158
1328
  };
1159
1329
  let initialized = false;
1160
1330
  disposeEffect = effect(() => {
1161
- clearPortalChildren(portal);
1162
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);
1163
1343
  if (target) {
1164
- portal.children = renderBlockContent(element.props.children ?? element.children, target, null, namespace, owner);
1344
+ portal.children = renderBlockContent(element.props.children ?? element.children, target, targetAnchor, namespace, owner);
1165
1345
  }
1166
1346
  if (initialized) {
1167
1347
  fireMountedAndQueueUpdated(owner);
@@ -1170,48 +1350,12 @@ function renderPortal(element, parent, anchor, namespace) {
1170
1350
  });
1171
1351
  return portal;
1172
1352
  }
1173
- function resolveShowChildren(element, value) {
1174
- const children = element.props.children ?? element.children;
1175
- if (typeof children === "function") {
1176
- return children(value);
1177
- }
1178
- return children;
1179
- }
1180
- function resolveSwitchContent(element) {
1181
- const props = element.props;
1182
- const children = normalizeContent(props.children ?? element.children);
1183
- for (const child of children) {
1184
- const match = getMatchElement(child);
1185
- if (!match) {
1186
- continue;
1187
- }
1188
- const when = readReactive2(match.props.when);
1189
- if (when) {
1190
- return resolveMatchChildren(match, when);
1191
- }
1192
- }
1193
- return props.fallback;
1194
- }
1195
- function resolveMatchChildren(element, value) {
1196
- const children = element.props.children ?? element.children;
1197
- if (typeof children === "function") {
1198
- return children(value);
1199
- }
1200
- return children;
1201
- }
1202
- function resolveKeyChildren(element, value) {
1203
- const children = element.props.children ?? element.children;
1204
- if (typeof children === "function") {
1205
- return children(value);
1206
- }
1207
- return children;
1208
- }
1209
1353
  function createDynamicElement(element, tag) {
1210
1354
  if (typeof tag !== "string" && typeof tag !== "function") {
1211
1355
  return null;
1212
1356
  }
1213
1357
  const { component, ...props } = element.props;
1214
- const children = normalizeContent(props.children ?? element.children);
1358
+ const children = normalizeContent2(props.children ?? element.children);
1215
1359
  return {
1216
1360
  tag,
1217
1361
  props,
@@ -1219,11 +1363,14 @@ function createDynamicElement(element, tag) {
1219
1363
  };
1220
1364
  }
1221
1365
  function renderBlockContent(content, parent, anchor, namespace, owner) {
1222
- if (content == null || typeof content === "boolean") {
1366
+ if (content == null || typeof content === "boolean")
1223
1367
  return [];
1224
- }
1225
- const nodes = Array.isArray(content) ? content : [content];
1226
- return nodes.map((node) => withOptionalInstance(owner, () => renderNodeToDOM(node, parent, anchor, namespace)));
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
+ });
1227
1374
  }
1228
1375
  function clearChildren(block) {
1229
1376
  for (const child of block.children) {
@@ -1241,6 +1388,23 @@ function moveBeforeEnd(parent, mounted, endAnchor) {
1241
1388
  for (const node of getMountedDomNodes(mounted)) {
1242
1389
  domOps.insertBefore(parent, node, endAnchor);
1243
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
+ }
1244
1408
  }
1245
1409
  function fireMountedAndQueueUpdated(owner) {
1246
1410
  if (owner) {
@@ -1254,24 +1418,12 @@ function withOptionalInstance(owner, fn) {
1254
1418
  function readReactive2(value) {
1255
1419
  return resolve(value);
1256
1420
  }
1257
- function normalizeContent(content) {
1421
+ function normalizeContent2(content) {
1258
1422
  if (content == null || typeof content === "boolean") {
1259
1423
  return [];
1260
1424
  }
1261
1425
  return Array.isArray(content) ? content : [content];
1262
1426
  }
1263
- function isElementLike(value) {
1264
- return value != null && typeof value === "object" && "tag" in value;
1265
- }
1266
- function getMatchElement(value) {
1267
- if (!isElementLike(value)) {
1268
- return null;
1269
- }
1270
- if (isMatchElement(value)) {
1271
- return value;
1272
- }
1273
- return value.tag === Match ? Match(value.props) : null;
1274
- }
1275
1427
  function resolvePortalTarget(value) {
1276
1428
  const target = readReactive2(value);
1277
1429
  if (target == null) {
@@ -1745,24 +1897,24 @@ async function renderElement(element) {
1745
1897
  }
1746
1898
  if (isShowElement(element)) {
1747
1899
  const when = readReactive3(props.when);
1748
- return renderToString(when ? resolveShowChildren2(element, when) : props.fallback);
1900
+ return renderToString(when ? resolveShowChildren(element, when) : props.fallback);
1749
1901
  }
1750
1902
  if (isForElement(element)) {
1751
1903
  return renderForElement(element);
1752
1904
  }
1753
1905
  if (isSwitchElement(element)) {
1754
- return renderToString(resolveSwitchContent2(element));
1906
+ return renderToString(resolveSwitchContent(element));
1755
1907
  }
1756
1908
  if (isMatchElement(element)) {
1757
1909
  const when = readReactive3(props.when);
1758
- return renderToString(when ? resolveMatchChildren2(element, when) : null);
1910
+ return renderToString(when ? resolveMatchChildren(element, when) : null);
1759
1911
  }
1760
1912
  if (isIndexElement(element)) {
1761
1913
  return renderIndexElement(element);
1762
1914
  }
1763
1915
  if (isKeyElement(element)) {
1764
1916
  const key = readReactive3(props.when);
1765
- return renderToString(resolveKeyChildren2(element, key));
1917
+ return renderToString(resolveKeyChildren(element, key));
1766
1918
  }
1767
1919
  if (isDynamicElement(element)) {
1768
1920
  const tag2 = readReactive3(props.component);
@@ -1852,75 +2004,27 @@ async function renderIndexElement(element) {
1852
2004
  const rendered = await Promise.all(each.map((item, index) => renderToString(props.children(() => item, index))));
1853
2005
  return rendered.join("");
1854
2006
  }
1855
- function resolveSwitchContent2(element) {
1856
- const props = element.props;
1857
- const children = normalizeContent2(props.children ?? element.children);
1858
- for (const child of children) {
1859
- const match = getMatchElement2(child);
1860
- if (!match) {
1861
- continue;
1862
- }
1863
- const when = readReactive3(match.props.when);
1864
- if (when) {
1865
- return resolveMatchChildren2(match, when);
1866
- }
1867
- }
1868
- return props.fallback;
1869
- }
1870
- function resolveMatchChildren2(element, value) {
1871
- const children = element.props.children ?? element.children;
1872
- if (typeof children === "function") {
1873
- return children(value);
1874
- }
1875
- return children;
1876
- }
1877
- function resolveKeyChildren2(element, value) {
1878
- const children = element.props.children ?? element.children;
1879
- if (typeof children === "function") {
1880
- return children(value);
1881
- }
1882
- return children;
1883
- }
1884
2007
  function createDynamicElement2(element, tag) {
1885
2008
  if (typeof tag !== "string" && typeof tag !== "function") {
1886
2009
  return null;
1887
2010
  }
1888
2011
  const { component, ...props } = element.props;
1889
- const children = normalizeContent2(props.children ?? element.children);
2012
+ const children = normalizeContent3(props.children ?? element.children);
1890
2013
  return {
1891
2014
  tag,
1892
2015
  props,
1893
2016
  children
1894
2017
  };
1895
2018
  }
1896
- function resolveShowChildren2(element, value) {
1897
- const children = element.props.children ?? element.children;
1898
- if (typeof children === "function") {
1899
- return children(value);
1900
- }
1901
- return children;
1902
- }
1903
2019
  function readReactive3(value) {
1904
2020
  return isSignal(value) || isComputed(value) ? value.value : value;
1905
2021
  }
1906
- function normalizeContent2(content) {
2022
+ function normalizeContent3(content) {
1907
2023
  if (content == null || typeof content === "boolean") {
1908
2024
  return [];
1909
2025
  }
1910
2026
  return Array.isArray(content) ? content : [content];
1911
2027
  }
1912
- function isElementLike2(value) {
1913
- return value != null && typeof value === "object" && "tag" in value;
1914
- }
1915
- function getMatchElement2(value) {
1916
- if (!isElementLike2(value)) {
1917
- return null;
1918
- }
1919
- if (isMatchElement(value)) {
1920
- return value;
1921
- }
1922
- return value.tag === Match ? Match(value.props) : null;
1923
- }
1924
2028
  // src/hydration/markers.ts
1925
2029
  var COMP_ID_ATTR = "data-sinwan-id";
1926
2030
  var COMP_ID_PREFIX = "c";
@@ -2055,7 +2159,7 @@ async function streamElement(element, controller, encoder) {
2055
2159
  }
2056
2160
  if (isShowElement(element)) {
2057
2161
  const when = readReactive4(props.when);
2058
- await streamNode(when ? resolveShowChildren3(element, when) : props.fallback, controller, encoder);
2162
+ await streamNode(when ? resolveShowChildren2(element, when) : props.fallback, controller, encoder);
2059
2163
  return;
2060
2164
  }
2061
2165
  if (isForElement(element)) {
@@ -2063,12 +2167,12 @@ async function streamElement(element, controller, encoder) {
2063
2167
  return;
2064
2168
  }
2065
2169
  if (isSwitchElement(element)) {
2066
- await streamNode(resolveSwitchContent3(element), controller, encoder);
2170
+ await streamNode(resolveSwitchContent2(element), controller, encoder);
2067
2171
  return;
2068
2172
  }
2069
2173
  if (isMatchElement(element)) {
2070
2174
  const when = readReactive4(props.when);
2071
- await streamNode(when ? resolveMatchChildren3(element, when) : null, controller, encoder);
2175
+ await streamNode(when ? resolveMatchChildren2(element, when) : null, controller, encoder);
2072
2176
  return;
2073
2177
  }
2074
2178
  if (isIndexElement(element)) {
@@ -2077,7 +2181,7 @@ async function streamElement(element, controller, encoder) {
2077
2181
  }
2078
2182
  if (isKeyElement(element)) {
2079
2183
  const key = readReactive4(props.when);
2080
- await streamNode(resolveKeyChildren3(element, key), controller, encoder);
2184
+ await streamNode(resolveKeyChildren2(element, key), controller, encoder);
2081
2185
  return;
2082
2186
  }
2083
2187
  if (isDynamicElement(element)) {
@@ -2183,7 +2287,7 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
2183
2287
  }
2184
2288
  if (isShowElement(element)) {
2185
2289
  const when = readReactive4(props.when);
2186
- await streamHydratableNodeToController(when ? resolveShowChildren3(element, when) : props.fallback, controller, encoder, ctx, isComponentRoot);
2290
+ await streamHydratableNodeToController(when ? resolveShowChildren2(element, when) : props.fallback, controller, encoder, ctx, isComponentRoot);
2187
2291
  return;
2188
2292
  }
2189
2293
  if (isForElement(element)) {
@@ -2191,12 +2295,12 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
2191
2295
  return;
2192
2296
  }
2193
2297
  if (isSwitchElement(element)) {
2194
- await streamHydratableNodeToController(resolveSwitchContent3(element), controller, encoder, ctx, isComponentRoot);
2298
+ await streamHydratableNodeToController(resolveSwitchContent2(element), controller, encoder, ctx, isComponentRoot);
2195
2299
  return;
2196
2300
  }
2197
2301
  if (isMatchElement(element)) {
2198
2302
  const when = readReactive4(props.when);
2199
- await streamHydratableNodeToController(when ? resolveMatchChildren3(element, when) : null, controller, encoder, ctx, isComponentRoot);
2303
+ await streamHydratableNodeToController(when ? resolveMatchChildren2(element, when) : null, controller, encoder, ctx, isComponentRoot);
2200
2304
  return;
2201
2305
  }
2202
2306
  if (isIndexElement(element)) {
@@ -2205,7 +2309,7 @@ async function streamHydratableElement(element, controller, encoder, ctx, isComp
2205
2309
  }
2206
2310
  if (isKeyElement(element)) {
2207
2311
  const key = readReactive4(props.when);
2208
- await streamHydratableNodeToController(resolveKeyChildren3(element, key), controller, encoder, ctx, isComponentRoot);
2312
+ await streamHydratableNodeToController(resolveKeyChildren2(element, key), controller, encoder, ctx, isComponentRoot);
2209
2313
  return;
2210
2314
  }
2211
2315
  if (isDynamicElement(element)) {
@@ -2362,36 +2466,36 @@ async function streamIndexElement(element, controller, encoder) {
2362
2466
  await streamNode(props.children(() => each[index], index), controller, encoder);
2363
2467
  }
2364
2468
  }
2365
- function resolveShowChildren3(element, value) {
2469
+ function resolveShowChildren2(element, value) {
2366
2470
  const children = element.props.children ?? element.children;
2367
2471
  if (typeof children === "function") {
2368
2472
  return children(value);
2369
2473
  }
2370
2474
  return children;
2371
2475
  }
2372
- function resolveSwitchContent3(element) {
2476
+ function resolveSwitchContent2(element) {
2373
2477
  const props = element.props;
2374
- const children = normalizeContent3(props.children ?? element.children);
2478
+ const children = normalizeContent4(props.children ?? element.children);
2375
2479
  for (const child of children) {
2376
- const match = getMatchElement3(child);
2480
+ const match = getMatchElement(child);
2377
2481
  if (!match) {
2378
2482
  continue;
2379
2483
  }
2380
2484
  const when = readReactive4(match.props.when);
2381
2485
  if (when) {
2382
- return resolveMatchChildren3(match, when);
2486
+ return resolveMatchChildren2(match, when);
2383
2487
  }
2384
2488
  }
2385
2489
  return props.fallback;
2386
2490
  }
2387
- function resolveMatchChildren3(element, value) {
2491
+ function resolveMatchChildren2(element, value) {
2388
2492
  const children = element.props.children ?? element.children;
2389
2493
  if (typeof children === "function") {
2390
2494
  return children(value);
2391
2495
  }
2392
2496
  return children;
2393
2497
  }
2394
- function resolveKeyChildren3(element, value) {
2498
+ function resolveKeyChildren2(element, value) {
2395
2499
  const children = element.props.children ?? element.children;
2396
2500
  if (typeof children === "function") {
2397
2501
  return children(value);
@@ -2403,7 +2507,7 @@ function createDynamicElement3(element, tag) {
2403
2507
  return null;
2404
2508
  }
2405
2509
  const { component, ...props } = element.props;
2406
- const children = normalizeContent3(props.children ?? element.children);
2510
+ const children = normalizeContent4(props.children ?? element.children);
2407
2511
  return {
2408
2512
  tag,
2409
2513
  props,
@@ -2413,17 +2517,17 @@ function createDynamicElement3(element, tag) {
2413
2517
  function readReactive4(value) {
2414
2518
  return isSignal(value) || isComputed(value) ? value.value : value;
2415
2519
  }
2416
- function normalizeContent3(content) {
2520
+ function normalizeContent4(content) {
2417
2521
  if (content == null || typeof content === "boolean") {
2418
2522
  return [];
2419
2523
  }
2420
2524
  return Array.isArray(content) ? content : [content];
2421
2525
  }
2422
- function isElementLike3(value) {
2526
+ function isElementLike2(value) {
2423
2527
  return value != null && typeof value === "object" && "tag" in value;
2424
2528
  }
2425
- function getMatchElement3(value) {
2426
- if (!isElementLike3(value)) {
2529
+ function getMatchElement(value) {
2530
+ if (!isElementLike2(value)) {
2427
2531
  return null;
2428
2532
  }
2429
2533
  if (isMatchElement(value)) {
@@ -2508,25 +2612,25 @@ function renderElementH(element, ctx, isComponentRoot) {
2508
2612
  }
2509
2613
  if (isShowElement(element)) {
2510
2614
  const when = readReactive5(props.when);
2511
- const content = when ? resolveShowChildren4(element, when) : props.fallback;
2615
+ const content = when ? resolveShowChildren3(element, when) : props.fallback;
2512
2616
  return renderNodeMaybeRoot(content, ctx, isComponentRoot);
2513
2617
  }
2514
2618
  if (isForElement(element)) {
2515
2619
  return renderForElementH(element, ctx);
2516
2620
  }
2517
2621
  if (isSwitchElement(element)) {
2518
- return renderNodeMaybeRoot(resolveSwitchContent4(element), ctx, isComponentRoot);
2622
+ return renderNodeMaybeRoot(resolveSwitchContent3(element), ctx, isComponentRoot);
2519
2623
  }
2520
2624
  if (isMatchElement(element)) {
2521
2625
  const when = readReactive5(props.when);
2522
- return renderNodeMaybeRoot(when ? resolveMatchChildren4(element, when) : null, ctx, isComponentRoot);
2626
+ return renderNodeMaybeRoot(when ? resolveMatchChildren3(element, when) : null, ctx, isComponentRoot);
2523
2627
  }
2524
2628
  if (isIndexElement(element)) {
2525
2629
  return renderIndexElementH(element, ctx);
2526
2630
  }
2527
2631
  if (isKeyElement(element)) {
2528
2632
  const key = readReactive5(props.when);
2529
- return renderNodeMaybeRoot(resolveKeyChildren4(element, key), ctx, isComponentRoot);
2633
+ return renderNodeMaybeRoot(resolveKeyChildren3(element, key), ctx, isComponentRoot);
2530
2634
  }
2531
2635
  if (isDynamicElement(element)) {
2532
2636
  const dynamicTag = readReactive5(props.component);
@@ -2625,36 +2729,36 @@ function renderIndexElementH(element, ctx) {
2625
2729
  }
2626
2730
  return each.map((item, index) => renderNodeH(props.children(() => item, index), ctx)).join("");
2627
2731
  }
2628
- function resolveShowChildren4(element, value) {
2732
+ function resolveShowChildren3(element, value) {
2629
2733
  const children = element.props.children ?? element.children;
2630
2734
  if (typeof children === "function") {
2631
2735
  return children(value);
2632
2736
  }
2633
2737
  return children;
2634
2738
  }
2635
- function resolveSwitchContent4(element) {
2739
+ function resolveSwitchContent3(element) {
2636
2740
  const props = element.props;
2637
- const children = normalizeContent4(props.children ?? element.children);
2741
+ const children = normalizeContent5(props.children ?? element.children);
2638
2742
  for (const child of children) {
2639
- const match = getMatchElement4(child);
2743
+ const match = getMatchElement2(child);
2640
2744
  if (!match) {
2641
2745
  continue;
2642
2746
  }
2643
2747
  const when = readReactive5(match.props.when);
2644
2748
  if (when) {
2645
- return resolveMatchChildren4(match, when);
2749
+ return resolveMatchChildren3(match, when);
2646
2750
  }
2647
2751
  }
2648
2752
  return props.fallback;
2649
2753
  }
2650
- function resolveMatchChildren4(element, value) {
2754
+ function resolveMatchChildren3(element, value) {
2651
2755
  const children = element.props.children ?? element.children;
2652
2756
  if (typeof children === "function") {
2653
2757
  return children(value);
2654
2758
  }
2655
2759
  return children;
2656
2760
  }
2657
- function resolveKeyChildren4(element, value) {
2761
+ function resolveKeyChildren3(element, value) {
2658
2762
  const children = element.props.children ?? element.children;
2659
2763
  if (typeof children === "function") {
2660
2764
  return children(value);
@@ -2666,7 +2770,7 @@ function createDynamicElement4(element, tag) {
2666
2770
  return null;
2667
2771
  }
2668
2772
  const { component, ...props } = element.props;
2669
- const children = normalizeContent4(props.children ?? element.children);
2773
+ const children = normalizeContent5(props.children ?? element.children);
2670
2774
  return {
2671
2775
  tag,
2672
2776
  props,
@@ -2676,17 +2780,17 @@ function createDynamicElement4(element, tag) {
2676
2780
  function readReactive5(value) {
2677
2781
  return isSignal(value) || isComputed(value) ? value.value : value;
2678
2782
  }
2679
- function normalizeContent4(content) {
2783
+ function normalizeContent5(content) {
2680
2784
  if (content == null || typeof content === "boolean") {
2681
2785
  return [];
2682
2786
  }
2683
2787
  return Array.isArray(content) ? content : [content];
2684
2788
  }
2685
- function isElementLike4(value) {
2789
+ function isElementLike3(value) {
2686
2790
  return value != null && typeof value === "object" && "tag" in value;
2687
2791
  }
2688
- function getMatchElement4(value) {
2689
- if (!isElementLike4(value)) {
2792
+ function getMatchElement2(value) {
2793
+ if (!isElementLike3(value)) {
2690
2794
  return null;
2691
2795
  }
2692
2796
  if (isMatchElement(value)) {
@@ -2977,7 +3081,7 @@ function hydrateAttributes(el, props) {
2977
3081
  function hydrateControlFlow(element, cursor) {
2978
3082
  if (isShowElement(element)) {
2979
3083
  const when = readReactive6(element.props.when);
2980
- const content = when ? resolveShowChildren5(element, when) : element.props.fallback;
3084
+ const content = when ? resolveShowChildren4(element, when) : element.props.fallback;
2981
3085
  return hydrateContent(content, cursor);
2982
3086
  }
2983
3087
  if (isForElement(element)) {
@@ -2987,7 +3091,7 @@ function hydrateControlFlow(element, cursor) {
2987
3091
  return hydrateArray(children, cursor);
2988
3092
  }
2989
3093
  if (isSwitchElement(element)) {
2990
- return hydrateContent(resolveSwitchContent5(element), cursor);
3094
+ return hydrateContent(resolveSwitchContent4(element), cursor);
2991
3095
  }
2992
3096
  if (isIndexElement(element)) {
2993
3097
  const props = element.props;
@@ -2997,7 +3101,7 @@ function hydrateControlFlow(element, cursor) {
2997
3101
  }
2998
3102
  if (isKeyElement(element)) {
2999
3103
  const key = readReactive6(element.props.when);
3000
- return hydrateContent(resolveKeyChildren5(element, key), cursor);
3104
+ return hydrateContent(resolveKeyChildren4(element, key), cursor);
3001
3105
  }
3002
3106
  if (isDynamicElement(element)) {
3003
3107
  const tag = readReactive6(element.props.component);
@@ -3012,36 +3116,36 @@ function hydrateContent(content, cursor) {
3012
3116
  }
3013
3117
  return Array.isArray(content) ? hydrateArray(content, cursor) : hydrateNode(content, cursor);
3014
3118
  }
3015
- function resolveShowChildren5(element, value) {
3119
+ function resolveShowChildren4(element, value) {
3016
3120
  const children = element.props.children ?? element.children;
3017
3121
  if (typeof children === "function") {
3018
3122
  return children(value);
3019
3123
  }
3020
3124
  return children;
3021
3125
  }
3022
- function resolveSwitchContent5(element) {
3126
+ function resolveSwitchContent4(element) {
3023
3127
  const props = element.props;
3024
- const children = normalizeContent5(props.children ?? element.children);
3128
+ const children = normalizeContent6(props.children ?? element.children);
3025
3129
  for (const child of children) {
3026
- const match = getMatchElement5(child);
3130
+ const match = getMatchElement3(child);
3027
3131
  if (!match) {
3028
3132
  continue;
3029
3133
  }
3030
3134
  const when = readReactive6(match.props.when);
3031
3135
  if (when) {
3032
- return resolveMatchChildren5(match, when);
3136
+ return resolveMatchChildren4(match, when);
3033
3137
  }
3034
3138
  }
3035
3139
  return props.fallback;
3036
3140
  }
3037
- function resolveMatchChildren5(element, value) {
3141
+ function resolveMatchChildren4(element, value) {
3038
3142
  const children = element.props.children ?? element.children;
3039
3143
  if (typeof children === "function") {
3040
3144
  return children(value);
3041
3145
  }
3042
3146
  return children;
3043
3147
  }
3044
- function resolveKeyChildren5(element, value) {
3148
+ function resolveKeyChildren4(element, value) {
3045
3149
  const children = element.props.children ?? element.children;
3046
3150
  if (typeof children === "function") {
3047
3151
  return children(value);
@@ -3053,7 +3157,7 @@ function createDynamicElement5(element, tag) {
3053
3157
  return null;
3054
3158
  }
3055
3159
  const { component, ...props } = element.props;
3056
- const children = normalizeContent5(props.children ?? element.children);
3160
+ const children = normalizeContent6(props.children ?? element.children);
3057
3161
  return {
3058
3162
  tag,
3059
3163
  props,
@@ -3063,17 +3167,17 @@ function createDynamicElement5(element, tag) {
3063
3167
  function readReactive6(value) {
3064
3168
  return isSignal(value) || isComputed(value) ? value.value : value;
3065
3169
  }
3066
- function normalizeContent5(content) {
3170
+ function normalizeContent6(content) {
3067
3171
  if (content == null || typeof content === "boolean") {
3068
3172
  return [];
3069
3173
  }
3070
3174
  return Array.isArray(content) ? content : [content];
3071
3175
  }
3072
- function isElementLike5(value) {
3176
+ function isElementLike4(value) {
3073
3177
  return value != null && typeof value === "object" && "tag" in value;
3074
3178
  }
3075
- function getMatchElement5(value) {
3076
- if (!isElementLike5(value)) {
3179
+ function getMatchElement3(value) {
3180
+ if (!isElementLike4(value)) {
3077
3181
  return null;
3078
3182
  }
3079
3183
  if (isMatchElement(value)) {
@@ -3184,5 +3288,5 @@ function hydrate(component, container, props) {
3184
3288
  };
3185
3289
  }
3186
3290
 
3187
- //# debugId=446E2FDDC310248664756E2164756E21
3291
+ //# debugId=2A80AE62418E0A4664756E2164756E21
3188
3292
  //# sourceMappingURL=index.development.js.map