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.
@@ -1913,16 +1913,16 @@ function parseXOpVal(opName, value, px, parserFn) {
1913
1913
  return val;
1914
1914
  }
1915
1915
  function processXExtras(node, attrs, opName, startIdx, px) {
1916
- const consumed = X_OP_CONSUMED[opName];
1917
- const wrappable = X_OP_WRAPPABLE.has(opName);
1916
+ const { consumed, wrappable } = X_OPS[opName];
1918
1917
  const wrappers = [];
1919
1918
  for (let i = startIdx;i < attrs.length; i++) {
1920
1919
  const a = attrs[i];
1921
1920
  const aName = a.name;
1922
1921
  if (consumed.has(aName))
1923
1922
  continue;
1924
- if (wrappable && X_ATTR_WRAPPERS[aName]) {
1925
- wrappers.push([X_ATTR_WRAPPERS[aName], vp.parseBool(a.value, px)]);
1923
+ const wrapper = wrappable ? X_OPS[aName]?.wrapper : null;
1924
+ if (wrapper) {
1925
+ wrappers.push([wrapper, vp.parseBool(a.value, px)]);
1926
1926
  continue;
1927
1927
  }
1928
1928
  const issueInfo = { op: opName, name: aName, value: a.value };
@@ -2014,6 +2014,12 @@ class RenderViewId extends ANode {
2014
2014
  }
2015
2015
  setDataAttr(_key, _val) {}
2016
2016
  }
2017
+ function dynRenderStep(comp, name, key) {
2018
+ const p = resolveDynProducer(comp, name);
2019
+ if (!p)
2020
+ return null;
2021
+ return key === undefined ? new DynStep(p.producerCompId, p.producerSteps) : new DynEachStep(p.producerCompId, p.producerSteps, key);
2022
+ }
2017
2023
 
2018
2024
  class RenderNode extends RenderViewId {
2019
2025
  render(stack, rx) {
@@ -2021,10 +2027,8 @@ class RenderNode extends RenderViewId {
2021
2027
  return rx.renderIt(newStack, this, "", this.viewId);
2022
2028
  }
2023
2029
  toPathStep(ctx) {
2024
- if (this.val instanceof DynVal) {
2025
- const p = resolveDynProducer(ctx.comp, this.val.name);
2026
- return p ? new DynStep(p.producerCompId, p.producerSteps) : null;
2027
- }
2030
+ if (this.val instanceof DynVal)
2031
+ return dynRenderStep(ctx.comp, this.val.name);
2028
2032
  return super.toPathStep(ctx);
2029
2033
  }
2030
2034
  }
@@ -2040,10 +2044,8 @@ class RenderItNode extends RenderViewId {
2040
2044
  return null;
2041
2045
  const nextNode = next.resolveNode();
2042
2046
  if (nextNode instanceof EachNode && next.hasKey) {
2043
- if (nextNode.val instanceof DynVal) {
2044
- const p = resolveDynProducer(ctx.comp, nextNode.val.name);
2045
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, next.key) : null;
2046
- }
2047
+ if (nextNode.val instanceof DynVal)
2048
+ return dynRenderStep(ctx.comp, nextNode.val.name, next.key);
2047
2049
  return new EachRenderItStep(nextNode.val.name, next.key);
2048
2050
  }
2049
2051
  return null;
@@ -2059,12 +2061,8 @@ class RenderEachNode extends RenderViewId {
2059
2061
  return rx.renderEach(stack, this.iterInfo, this, this.viewId);
2060
2062
  }
2061
2063
  toPathStep(ctx) {
2062
- if (this.val instanceof DynVal) {
2063
- if (!ctx.hasKey)
2064
- return null;
2065
- const p = resolveDynProducer(ctx.comp, this.val.name);
2066
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, ctx.key) : null;
2067
- }
2064
+ if (this.val instanceof DynVal)
2065
+ return ctx.hasKey ? dynRenderStep(ctx.comp, this.val.name, ctx.key) : null;
2068
2066
  return super.toPathStep(ctx);
2069
2067
  }
2070
2068
  static parse(px, vp2, s, as, attrs) {
@@ -2194,17 +2192,18 @@ class IterInfo {
2194
2192
  }
2195
2193
  var filterAlwaysTrue = (_v, _k, _seq) => true;
2196
2194
  var nullLoopWith = (seq) => ({ iterData: { seq } });
2197
- var X_OP_CONSUMED = {
2198
- slot: new Set,
2199
- text: new Set,
2200
- render: new Set(["as"]),
2201
- "render-it": new Set(["as"]),
2202
- "render-each": new Set(["as", "when", "loop-with"]),
2203
- show: new Set,
2204
- hide: new Set
2195
+ function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
2196
+ return { consumed: new Set(consumed), wrappable, wrapper };
2197
+ }
2198
+ var X_OPS = {
2199
+ slot: xOp(),
2200
+ text: xOp([], { wrappable: true }),
2201
+ render: xOp(["as"], { wrappable: true }),
2202
+ "render-it": xOp(["as"], { wrappable: true }),
2203
+ "render-each": xOp(["as", "when", "loop-with"], { wrappable: true }),
2204
+ show: xOp([], { wrapper: ShowNode }),
2205
+ hide: xOp([], { wrapper: HideNode })
2205
2206
  };
2206
- var X_OP_WRAPPABLE = new Set(["text", "render", "render-it", "render-each"]);
2207
- var X_ATTR_WRAPPERS = { show: ShowNode, hide: HideNode };
2208
2207
  var WRAPPER_NODES = {
2209
2208
  slot: SlotNode,
2210
2209
  show: ShowNode,
@@ -2292,29 +2291,30 @@ var isBlockDomNode = (n) => {
2292
2291
  const node = n instanceof FragmentNode ? n.childs[0] : n;
2293
2292
  return node instanceof DomNode && HTML_BLOCK_TAGS.has(node.tagName);
2294
2293
  };
2294
+ var isEmptyText = (c) => c instanceof TextNode && c.val === "";
2295
+ function trimEdgeWhite(node) {
2296
+ if (!node.isWhiteSpace?.())
2297
+ return false;
2298
+ node.condenseWhiteSpace();
2299
+ return true;
2300
+ }
2295
2301
  function condenseChildsWhites(childs) {
2296
2302
  if (childs.length === 0)
2297
2303
  return childs;
2298
- let changed = false;
2299
- if (childs[0].isWhiteSpace?.()) {
2300
- childs[0].condenseWhiteSpace();
2301
- changed = true;
2302
- }
2303
2304
  const last = childs.length - 1;
2304
- if (last > 0 && childs[last].isWhiteSpace?.()) {
2305
- childs[last].condenseWhiteSpace();
2306
- changed = true;
2307
- }
2305
+ let emptied = trimEdgeWhite(childs[0]);
2306
+ if (last > 0 && trimEdgeWhite(childs[last]))
2307
+ emptied = true;
2308
2308
  for (let i = 1;i < last; i++) {
2309
2309
  const cur = childs[i];
2310
- if (cur.isWhiteSpace?.() && cur.hasNewLine()) {
2311
- const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
2312
- cur.condenseWhiteSpace(bothBlock ? "" : " ");
2313
- if (bothBlock)
2314
- changed = true;
2315
- }
2310
+ if (!(cur.isWhiteSpace?.() && cur.hasNewLine()))
2311
+ continue;
2312
+ const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
2313
+ cur.condenseWhiteSpace(bothBlock ? "" : " ");
2314
+ if (bothBlock)
2315
+ emptied = true;
2316
2316
  }
2317
- return changed ? childs.filter((c) => !(c instanceof TextNode && c.val === "")) : childs;
2317
+ return emptied ? childs.filter((c) => !isEmptyText(c)) : childs;
2318
2318
  }
2319
2319
 
2320
2320
  class View {
@@ -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 {