@sigx/terminal 0.1.25 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -958,10 +958,60 @@ function isComponent(type) {
958
958
  }
959
959
  const Fragment = Symbol.for("sigx.Fragment");
960
960
  const Text = Symbol.for("sigx.Text");
961
+ const Comment = Symbol.for("sigx.Comment");
961
962
  function normalizeChildren(children) {
962
963
  if (children == null || children === false || children === true) return [];
963
964
  if (isComputed(children)) return normalizeChildren(children.value);
964
- if (Array.isArray(children)) return children.flatMap((c) => normalizeChildren(c));
965
+ if (Array.isArray(children)) return children.map((c) => {
966
+ if (c == null || c === false || c === true) return {
967
+ type: Comment,
968
+ props: {},
969
+ key: null,
970
+ children: [],
971
+ dom: null
972
+ };
973
+ if (isComputed(c)) return normalizeChildren(c.value)[0] ?? {
974
+ type: Comment,
975
+ props: {},
976
+ key: null,
977
+ children: [],
978
+ dom: null
979
+ };
980
+ if (typeof c === "string" || typeof c === "number") return {
981
+ type: Text,
982
+ props: {},
983
+ key: null,
984
+ children: [],
985
+ dom: null,
986
+ text: c
987
+ };
988
+ if (Array.isArray(c)) {
989
+ const nested = normalizeChildren(c);
990
+ if (nested.length === 0) return {
991
+ type: Comment,
992
+ props: {},
993
+ key: null,
994
+ children: [],
995
+ dom: null
996
+ };
997
+ if (nested.length === 1) return nested[0];
998
+ return {
999
+ type: Fragment,
1000
+ props: {},
1001
+ key: null,
1002
+ children: nested,
1003
+ dom: null
1004
+ };
1005
+ }
1006
+ if (c.type) return c;
1007
+ return {
1008
+ type: Comment,
1009
+ props: {},
1010
+ key: null,
1011
+ children: [],
1012
+ dom: null
1013
+ };
1014
+ });
965
1015
  if (typeof children === "string" || typeof children === "number") return [{
966
1016
  type: Text,
967
1017
  props: {},
@@ -1575,6 +1625,12 @@ function createRenderer(options) {
1575
1625
  hostInsert(node, container, before);
1576
1626
  return;
1577
1627
  }
1628
+ if (vnode.type === Comment) {
1629
+ const node = hostCreateComment("");
1630
+ vnode.dom = node;
1631
+ hostInsert(node, container, before);
1632
+ return;
1633
+ }
1578
1634
  if (vnode.type === Fragment) {
1579
1635
  const anchor = hostCreateComment("");
1580
1636
  vnode.dom = anchor;
@@ -1627,6 +1683,10 @@ function createRenderer(options) {
1627
1683
  if (vnode.dom) hostRemove(vnode.dom);
1628
1684
  return;
1629
1685
  }
1686
+ if (vnode.type === Comment) {
1687
+ if (vnode.dom) hostRemove(vnode.dom);
1688
+ return;
1689
+ }
1630
1690
  if (vnode.props?.ref) untrack(() => {
1631
1691
  if (typeof vnode.props.ref === "function") vnode.props.ref(null);
1632
1692
  else if (vnode.props.ref && typeof vnode.props.ref === "object") vnode.props.ref.current = null;
@@ -1706,6 +1766,10 @@ function createRenderer(options) {
1706
1766
  if (oldVNode.text !== newVNode.text) hostSetText(newVNode.dom, String(newVNode.text));
1707
1767
  return;
1708
1768
  }
1769
+ if (newVNode.type === Comment) {
1770
+ newVNode.dom = oldVNode.dom;
1771
+ return;
1772
+ }
1709
1773
  if (newVNode.type === Fragment) {
1710
1774
  patchChildren(oldVNode, newVNode, container, false);
1711
1775
  return;
@@ -2513,6 +2577,6 @@ const terminalMount = (component, options, appContext) => {
2513
2577
  };
2514
2578
  };
2515
2579
  setDefaultMount(terminalMount);
2516
- export { Button, CLIENT_DIRECTIVES, CLIENT_DIRECTIVE_PREFIX, Checkbox, ComputedSymbol, ErrorBoundary, Fragment, Input, InstanceLifetimes, ProgressBar, Select, SigxError, SigxErrorCode, SubscriptionHandler, Suspense, Text, Utils, asyncSetupClientError, batch, component, compound, computed, createModel, createModelFromBinding, createTopic, defineApp, defineDirective, defineFactory, defineInjectable, defineProvide, detectAccess, effect, effectScope, exitTerminal, focus, focusNext, focusPrev, focusState, getComponentMeta, getCurrentInstance, guid, isComponent, isComputed, isDirective, isLazyComponent, isModel, isReactive, jsx, jsxDEV, jsxs, lazy, mountTargetNotFoundError, mountTerminal, noMountFunctionError, onCreated, onKey, onMounted, onUnmounted, onUpdated, provideInvalidInjectableError, provideOutsideSetupError, registerFocusable, render, renderNodeToLines, renderTargetNotFoundError, renderTerminal, signal, terminalMount, toRaw, toSubscriber, unregisterFocusable, untrack, useAppContext, useAsync, watch };
2580
+ export { Button, CLIENT_DIRECTIVES, CLIENT_DIRECTIVE_PREFIX, Checkbox, Comment, ComputedSymbol, ErrorBoundary, Fragment, Input, InstanceLifetimes, ProgressBar, Select, SigxError, SigxErrorCode, SubscriptionHandler, Suspense, Text, Utils, asyncSetupClientError, batch, component, compound, computed, createModel, createModelFromBinding, createTopic, defineApp, defineDirective, defineFactory, defineInjectable, defineProvide, detectAccess, effect, effectScope, exitTerminal, focus, focusNext, focusPrev, focusState, getComponentMeta, getCurrentInstance, guid, isComponent, isComputed, isDirective, isLazyComponent, isModel, isReactive, jsx, jsxDEV, jsxs, lazy, mountTargetNotFoundError, mountTerminal, noMountFunctionError, onCreated, onKey, onMounted, onUnmounted, onUpdated, provideInvalidInjectableError, provideOutsideSetupError, registerFocusable, render, renderNodeToLines, renderTargetNotFoundError, renderTerminal, signal, terminalMount, toRaw, toSubscriber, unregisterFocusable, untrack, useAppContext, useAsync, watch };
2517
2581
 
2518
2582
  //# sourceMappingURL=index.js.map