tutuca 0.9.68 → 0.9.69

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.
@@ -1802,16 +1802,16 @@ function parseXOpVal(opName, value, px, parserFn) {
1802
1802
  return val;
1803
1803
  }
1804
1804
  function processXExtras(node, attrs, opName, startIdx, px) {
1805
- const consumed = X_OP_CONSUMED[opName];
1806
- const wrappable = X_OP_WRAPPABLE.has(opName);
1805
+ const { consumed, wrappable } = X_OPS[opName];
1807
1806
  const wrappers = [];
1808
1807
  for (let i = startIdx;i < attrs.length; i++) {
1809
1808
  const a = attrs[i];
1810
1809
  const aName = a.name;
1811
1810
  if (consumed.has(aName))
1812
1811
  continue;
1813
- if (wrappable && X_ATTR_WRAPPERS[aName]) {
1814
- wrappers.push([X_ATTR_WRAPPERS[aName], vp.parseBool(a.value, px)]);
1812
+ const wrapper = wrappable ? X_OPS[aName]?.wrapper : null;
1813
+ if (wrapper) {
1814
+ wrappers.push([wrapper, vp.parseBool(a.value, px)]);
1815
1815
  continue;
1816
1816
  }
1817
1817
  const issueInfo = { op: opName, name: aName, value: a.value };
@@ -1903,6 +1903,12 @@ class RenderViewId extends ANode {
1903
1903
  }
1904
1904
  setDataAttr(_key, _val) {}
1905
1905
  }
1906
+ function dynRenderStep(comp, name, key) {
1907
+ const p = resolveDynProducer(comp, name);
1908
+ if (!p)
1909
+ return null;
1910
+ return key === undefined ? new DynStep(p.producerCompId, p.producerSteps) : new DynEachStep(p.producerCompId, p.producerSteps, key);
1911
+ }
1906
1912
 
1907
1913
  class RenderNode extends RenderViewId {
1908
1914
  render(stack, rx) {
@@ -1910,10 +1916,8 @@ class RenderNode extends RenderViewId {
1910
1916
  return rx.renderIt(newStack, this, "", this.viewId);
1911
1917
  }
1912
1918
  toPathStep(ctx) {
1913
- if (this.val instanceof DynVal) {
1914
- const p = resolveDynProducer(ctx.comp, this.val.name);
1915
- return p ? new DynStep(p.producerCompId, p.producerSteps) : null;
1916
- }
1919
+ if (this.val instanceof DynVal)
1920
+ return dynRenderStep(ctx.comp, this.val.name);
1917
1921
  return super.toPathStep(ctx);
1918
1922
  }
1919
1923
  }
@@ -1929,10 +1933,8 @@ class RenderItNode extends RenderViewId {
1929
1933
  return null;
1930
1934
  const nextNode = next.resolveNode();
1931
1935
  if (nextNode instanceof EachNode && next.hasKey) {
1932
- if (nextNode.val instanceof DynVal) {
1933
- const p = resolveDynProducer(ctx.comp, nextNode.val.name);
1934
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, next.key) : null;
1935
- }
1936
+ if (nextNode.val instanceof DynVal)
1937
+ return dynRenderStep(ctx.comp, nextNode.val.name, next.key);
1936
1938
  return new EachRenderItStep(nextNode.val.name, next.key);
1937
1939
  }
1938
1940
  return null;
@@ -1948,12 +1950,8 @@ class RenderEachNode extends RenderViewId {
1948
1950
  return rx.renderEach(stack, this.iterInfo, this, this.viewId);
1949
1951
  }
1950
1952
  toPathStep(ctx) {
1951
- if (this.val instanceof DynVal) {
1952
- if (!ctx.hasKey)
1953
- return null;
1954
- const p = resolveDynProducer(ctx.comp, this.val.name);
1955
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, ctx.key) : null;
1956
- }
1953
+ if (this.val instanceof DynVal)
1954
+ return ctx.hasKey ? dynRenderStep(ctx.comp, this.val.name, ctx.key) : null;
1957
1955
  return super.toPathStep(ctx);
1958
1956
  }
1959
1957
  static parse(px, vp2, s, as, attrs) {
@@ -2083,17 +2081,18 @@ class IterInfo {
2083
2081
  }
2084
2082
  var filterAlwaysTrue = (_v, _k, _seq) => true;
2085
2083
  var nullLoopWith = (seq) => ({ iterData: { seq } });
2086
- var X_OP_CONSUMED = {
2087
- slot: new Set,
2088
- text: new Set,
2089
- render: new Set(["as"]),
2090
- "render-it": new Set(["as"]),
2091
- "render-each": new Set(["as", "when", "loop-with"]),
2092
- show: new Set,
2093
- hide: new Set
2084
+ function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
2085
+ return { consumed: new Set(consumed), wrappable, wrapper };
2086
+ }
2087
+ var X_OPS = {
2088
+ slot: xOp(),
2089
+ text: xOp([], { wrappable: true }),
2090
+ render: xOp(["as"], { wrappable: true }),
2091
+ "render-it": xOp(["as"], { wrappable: true }),
2092
+ "render-each": xOp(["as", "when", "loop-with"], { wrappable: true }),
2093
+ show: xOp([], { wrapper: ShowNode }),
2094
+ hide: xOp([], { wrapper: HideNode })
2094
2095
  };
2095
- var X_OP_WRAPPABLE = new Set(["text", "render", "render-it", "render-each"]);
2096
- var X_ATTR_WRAPPERS = { show: ShowNode, hide: HideNode };
2097
2096
  var WRAPPER_NODES = {
2098
2097
  slot: SlotNode,
2099
2098
  show: ShowNode,
@@ -2181,29 +2180,30 @@ var isBlockDomNode = (n) => {
2181
2180
  const node = n instanceof FragmentNode ? n.childs[0] : n;
2182
2181
  return node instanceof DomNode && HTML_BLOCK_TAGS.has(node.tagName);
2183
2182
  };
2183
+ var isEmptyText = (c) => c instanceof TextNode && c.val === "";
2184
+ function trimEdgeWhite(node) {
2185
+ if (!node.isWhiteSpace?.())
2186
+ return false;
2187
+ node.condenseWhiteSpace();
2188
+ return true;
2189
+ }
2184
2190
  function condenseChildsWhites(childs) {
2185
2191
  if (childs.length === 0)
2186
2192
  return childs;
2187
- let changed = false;
2188
- if (childs[0].isWhiteSpace?.()) {
2189
- childs[0].condenseWhiteSpace();
2190
- changed = true;
2191
- }
2192
2193
  const last = childs.length - 1;
2193
- if (last > 0 && childs[last].isWhiteSpace?.()) {
2194
- childs[last].condenseWhiteSpace();
2195
- changed = true;
2196
- }
2194
+ let emptied = trimEdgeWhite(childs[0]);
2195
+ if (last > 0 && trimEdgeWhite(childs[last]))
2196
+ emptied = true;
2197
2197
  for (let i = 1;i < last; i++) {
2198
2198
  const cur = childs[i];
2199
- if (cur.isWhiteSpace?.() && cur.hasNewLine()) {
2200
- const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
2201
- cur.condenseWhiteSpace(bothBlock ? "" : " ");
2202
- if (bothBlock)
2203
- changed = true;
2204
- }
2199
+ if (!(cur.isWhiteSpace?.() && cur.hasNewLine()))
2200
+ continue;
2201
+ const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
2202
+ cur.condenseWhiteSpace(bothBlock ? "" : " ");
2203
+ if (bothBlock)
2204
+ emptied = true;
2205
2205
  }
2206
- return changed ? childs.filter((c) => !(c instanceof TextNode && c.val === "")) : childs;
2206
+ return emptied ? childs.filter((c) => !isEmptyText(c)) : childs;
2207
2207
  }
2208
2208
 
2209
2209
  class View {
package/dist/tutuca.js CHANGED
@@ -6175,16 +6175,16 @@ function parseXOpVal(opName, value, px, parserFn) {
6175
6175
  return val;
6176
6176
  }
6177
6177
  function processXExtras(node, attrs, opName, startIdx, px) {
6178
- const consumed = X_OP_CONSUMED[opName];
6179
- const wrappable = X_OP_WRAPPABLE.has(opName);
6178
+ const { consumed, wrappable } = X_OPS[opName];
6180
6179
  const wrappers = [];
6181
6180
  for (let i = startIdx;i < attrs.length; i++) {
6182
6181
  const a = attrs[i];
6183
6182
  const aName = a.name;
6184
6183
  if (consumed.has(aName))
6185
6184
  continue;
6186
- if (wrappable && X_ATTR_WRAPPERS[aName]) {
6187
- wrappers.push([X_ATTR_WRAPPERS[aName], vp.parseBool(a.value, px)]);
6185
+ const wrapper = wrappable ? X_OPS[aName]?.wrapper : null;
6186
+ if (wrapper) {
6187
+ wrappers.push([wrapper, vp.parseBool(a.value, px)]);
6188
6188
  continue;
6189
6189
  }
6190
6190
  const issueInfo = { op: opName, name: aName, value: a.value };
@@ -6276,6 +6276,12 @@ class RenderViewId extends ANode {
6276
6276
  }
6277
6277
  setDataAttr(_key, _val) {}
6278
6278
  }
6279
+ function dynRenderStep(comp, name, key) {
6280
+ const p = resolveDynProducer(comp, name);
6281
+ if (!p)
6282
+ return null;
6283
+ return key === undefined ? new DynStep(p.producerCompId, p.producerSteps) : new DynEachStep(p.producerCompId, p.producerSteps, key);
6284
+ }
6279
6285
 
6280
6286
  class RenderNode extends RenderViewId {
6281
6287
  render(stack, rx) {
@@ -6283,10 +6289,8 @@ class RenderNode extends RenderViewId {
6283
6289
  return rx.renderIt(newStack, this, "", this.viewId);
6284
6290
  }
6285
6291
  toPathStep(ctx) {
6286
- if (this.val instanceof DynVal) {
6287
- const p = resolveDynProducer(ctx.comp, this.val.name);
6288
- return p ? new DynStep(p.producerCompId, p.producerSteps) : null;
6289
- }
6292
+ if (this.val instanceof DynVal)
6293
+ return dynRenderStep(ctx.comp, this.val.name);
6290
6294
  return super.toPathStep(ctx);
6291
6295
  }
6292
6296
  }
@@ -6302,10 +6306,8 @@ class RenderItNode extends RenderViewId {
6302
6306
  return null;
6303
6307
  const nextNode = next.resolveNode();
6304
6308
  if (nextNode instanceof EachNode && next.hasKey) {
6305
- if (nextNode.val instanceof DynVal) {
6306
- const p = resolveDynProducer(ctx.comp, nextNode.val.name);
6307
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, next.key) : null;
6308
- }
6309
+ if (nextNode.val instanceof DynVal)
6310
+ return dynRenderStep(ctx.comp, nextNode.val.name, next.key);
6309
6311
  return new EachRenderItStep(nextNode.val.name, next.key);
6310
6312
  }
6311
6313
  return null;
@@ -6321,12 +6323,8 @@ class RenderEachNode extends RenderViewId {
6321
6323
  return rx.renderEach(stack, this.iterInfo, this, this.viewId);
6322
6324
  }
6323
6325
  toPathStep(ctx) {
6324
- if (this.val instanceof DynVal) {
6325
- if (!ctx.hasKey)
6326
- return null;
6327
- const p = resolveDynProducer(ctx.comp, this.val.name);
6328
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, ctx.key) : null;
6329
- }
6326
+ if (this.val instanceof DynVal)
6327
+ return ctx.hasKey ? dynRenderStep(ctx.comp, this.val.name, ctx.key) : null;
6330
6328
  return super.toPathStep(ctx);
6331
6329
  }
6332
6330
  static parse(px, vp2, s, as, attrs) {
@@ -6456,17 +6454,18 @@ class IterInfo {
6456
6454
  }
6457
6455
  var filterAlwaysTrue = (_v, _k, _seq) => true;
6458
6456
  var nullLoopWith = (seq) => ({ iterData: { seq } });
6459
- var X_OP_CONSUMED = {
6460
- slot: new Set,
6461
- text: new Set,
6462
- render: new Set(["as"]),
6463
- "render-it": new Set(["as"]),
6464
- "render-each": new Set(["as", "when", "loop-with"]),
6465
- show: new Set,
6466
- hide: new Set
6457
+ function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
6458
+ return { consumed: new Set(consumed), wrappable, wrapper };
6459
+ }
6460
+ var X_OPS = {
6461
+ slot: xOp(),
6462
+ text: xOp([], { wrappable: true }),
6463
+ render: xOp(["as"], { wrappable: true }),
6464
+ "render-it": xOp(["as"], { wrappable: true }),
6465
+ "render-each": xOp(["as", "when", "loop-with"], { wrappable: true }),
6466
+ show: xOp([], { wrapper: ShowNode }),
6467
+ hide: xOp([], { wrapper: HideNode })
6467
6468
  };
6468
- var X_OP_WRAPPABLE = new Set(["text", "render", "render-it", "render-each"]);
6469
- var X_ATTR_WRAPPERS = { show: ShowNode, hide: HideNode };
6470
6469
  var WRAPPER_NODES = {
6471
6470
  slot: SlotNode,
6472
6471
  show: ShowNode,
@@ -6554,29 +6553,30 @@ var isBlockDomNode = (n) => {
6554
6553
  const node = n instanceof FragmentNode ? n.childs[0] : n;
6555
6554
  return node instanceof DomNode && HTML_BLOCK_TAGS.has(node.tagName);
6556
6555
  };
6556
+ var isEmptyText = (c) => c instanceof TextNode && c.val === "";
6557
+ function trimEdgeWhite(node) {
6558
+ if (!node.isWhiteSpace?.())
6559
+ return false;
6560
+ node.condenseWhiteSpace();
6561
+ return true;
6562
+ }
6557
6563
  function condenseChildsWhites(childs) {
6558
6564
  if (childs.length === 0)
6559
6565
  return childs;
6560
- let changed = false;
6561
- if (childs[0].isWhiteSpace?.()) {
6562
- childs[0].condenseWhiteSpace();
6563
- changed = true;
6564
- }
6565
6566
  const last = childs.length - 1;
6566
- if (last > 0 && childs[last].isWhiteSpace?.()) {
6567
- childs[last].condenseWhiteSpace();
6568
- changed = true;
6569
- }
6567
+ let emptied = trimEdgeWhite(childs[0]);
6568
+ if (last > 0 && trimEdgeWhite(childs[last]))
6569
+ emptied = true;
6570
6570
  for (let i = 1;i < last; i++) {
6571
6571
  const cur = childs[i];
6572
- if (cur.isWhiteSpace?.() && cur.hasNewLine()) {
6573
- const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
6574
- cur.condenseWhiteSpace(bothBlock ? "" : " ");
6575
- if (bothBlock)
6576
- changed = true;
6577
- }
6572
+ if (!(cur.isWhiteSpace?.() && cur.hasNewLine()))
6573
+ continue;
6574
+ const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
6575
+ cur.condenseWhiteSpace(bothBlock ? "" : " ");
6576
+ if (bothBlock)
6577
+ emptied = true;
6578
6578
  }
6579
- return changed ? childs.filter((c) => !(c instanceof TextNode && c.val === "")) : childs;
6579
+ return emptied ? childs.filter((c) => !isEmptyText(c)) : childs;
6580
6580
  }
6581
6581
 
6582
6582
  class View {