tutuca 0.9.65 → 0.9.66

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.
@@ -4344,49 +4344,67 @@ class Path {
4344
4344
  let handlers = null;
4345
4345
  let nodeIds = [];
4346
4346
  let isLeafComponent = true;
4347
+ const crossComponent = (cidNum, vid) => {
4348
+ const comp = comps.getComponentForId(cidNum);
4349
+ let pushStep = true;
4350
+ if (handlers === null && (isLeafComponent || bubbles)) {
4351
+ handlers = findHandlers(comp, eventIds, vid, eventName);
4352
+ if (handlers === null) {
4353
+ if (isLeafComponent && stopOnNoEvent && !bubbles)
4354
+ return false;
4355
+ } else if (!isLeafComponent) {
4356
+ pathSteps.length = 0;
4357
+ pendingDyns.length = 0;
4358
+ pushStep = false;
4359
+ }
4360
+ }
4361
+ isLeafComponent = false;
4362
+ for (const dyn of pendingDyns)
4363
+ dyn.interiorCids.add(cidNum);
4364
+ if (pushStep) {
4365
+ const step = resolvePathStep(comp, nodeIds, vid);
4366
+ if (step) {
4367
+ step._originCid = cidNum;
4368
+ pathSteps.push(step);
4369
+ if (step instanceof DynStep) {
4370
+ step.interiorCids.add(cidNum);
4371
+ pendingDyns.push(step);
4372
+ }
4373
+ }
4374
+ }
4375
+ for (let i = pendingDyns.length - 1;i >= 0; i--)
4376
+ if (pendingDyns[i].producerCompId === cidNum)
4377
+ pendingDyns.splice(i, 1);
4378
+ eventIds = [];
4379
+ nodeIds = [];
4380
+ return true;
4381
+ };
4347
4382
  while (node && node !== rootNode && depth < maxDepth) {
4348
4383
  if (node?.dataset) {
4349
- const { nid, si, sk } = parseMetaComment(node.previousSibling);
4350
4384
  const { eid, cid, vid } = node.dataset;
4351
4385
  if (eid !== undefined)
4352
4386
  eventIds.push(eid);
4353
- if (cid !== undefined) {
4354
- const cidNum = +cid;
4355
- const comp = comps.getComponentForId(cidNum);
4356
- let pushStep = true;
4357
- if (handlers === null && (isLeafComponent || bubbles)) {
4358
- handlers = findHandlers(comp, eventIds, vid, eventName);
4359
- if (handlers === null) {
4360
- if (isLeafComponent && stopOnNoEvent && !bubbles)
4361
- return NO_EVENT_INFO;
4362
- } else if (!isLeafComponent) {
4363
- pathSteps.length = 0;
4364
- pendingDyns.length = 0;
4365
- pushStep = false;
4366
- }
4367
- }
4368
- isLeafComponent = false;
4369
- for (const dyn of pendingDyns)
4370
- dyn.interiorCids.add(cidNum);
4371
- if (pushStep) {
4372
- const step = resolvePathStep(comp, nodeIds, vid);
4373
- if (step) {
4374
- step._originCid = cidNum;
4375
- pathSteps.push(step);
4376
- if (step instanceof DynStep) {
4377
- step.interiorCids.add(cidNum);
4378
- pendingDyns.push(step);
4379
- }
4387
+ const metas = metaChain(node.previousSibling);
4388
+ let sawComp = false;
4389
+ for (let i = 0;i < metas.length; i++) {
4390
+ const m = metas[i];
4391
+ if (m.$ === "Comp") {
4392
+ sawComp = true;
4393
+ if (!crossComponent(m.cid, m.vid))
4394
+ return NO_EVENT_INFO;
4395
+ const outer = metas[i + 1];
4396
+ if (outer?.$ === "Each" && outer.nid === m.nid) {
4397
+ nodeIds.push({ nid: outer.nid, si: outer.si, sk: outer.sk });
4398
+ i += 1;
4399
+ } else {
4400
+ nodeIds.push({ nid: m.nid });
4380
4401
  }
4402
+ } else {
4403
+ nodeIds.push({ nid: m.nid, si: m.si, sk: m.sk });
4381
4404
  }
4382
- for (let i = pendingDyns.length - 1;i >= 0; i--)
4383
- if (pendingDyns[i].producerCompId === cidNum)
4384
- pendingDyns.splice(i, 1);
4385
- eventIds = [];
4386
- nodeIds = [];
4387
4405
  }
4388
- if (nid !== undefined)
4389
- nodeIds.push({ nid, si, sk });
4406
+ if (!sawComp && cid !== undefined && !crossComponent(+cid, vid))
4407
+ return NO_EVENT_INFO;
4390
4408
  }
4391
4409
  depth += 1;
4392
4410
  node = node.parentNode;
@@ -4400,18 +4418,17 @@ class Path {
4400
4418
  return Path.fromNodeAndEventName(target, type, rNode, maxDepth, comps, stopOnNoEvent);
4401
4419
  }
4402
4420
  }
4403
- function parseMetaComment(n) {
4404
- if (n?.nodeType === 8 && n.textContent[0] === "§") {
4405
- const m = parseMetaComment(n.previousSibling);
4406
- if (m !== EMPTY_META)
4407
- return m;
4421
+ function metaChain(n) {
4422
+ const out = [];
4423
+ while (n?.nodeType === 8 && n.textContent[0] === "§") {
4408
4424
  try {
4409
- return JSON.parse(n.textContent.slice(1, -1));
4425
+ out.push(JSON.parse(n.textContent.slice(1, -1)));
4410
4426
  } catch (err) {
4411
4427
  console.warn(err, n);
4412
4428
  }
4429
+ n = n.previousSibling;
4413
4430
  }
4414
- return EMPTY_META;
4431
+ return out;
4415
4432
  }
4416
4433
  function findHandlers(comp, eventIds, vid, eventName) {
4417
4434
  for (const eid of eventIds) {
@@ -4486,7 +4503,7 @@ class PathBuilder {
4486
4503
  return this.add(new SeqStep(name, key));
4487
4504
  }
4488
4505
  }
4489
- var NONE, BindStep, FieldStep, SeqStep, SeqAccessStep, EachBindStep, EachRenderItStep, DynStep, DynEachStep, EMPTY_META, NO_EVENT_INFO, BUBBLING_EVENTS;
4506
+ var NONE, BindStep, FieldStep, SeqStep, SeqAccessStep, EachBindStep, EachRenderItStep, DynStep, DynEachStep, NO_EVENT_INFO, BUBBLING_EVENTS;
4490
4507
  var init_path = __esm(() => {
4491
4508
  NONE = Symbol("NONE");
4492
4509
  BindStep = class BindStep extends Step {
@@ -4634,7 +4651,6 @@ var init_path = __esm(() => {
4634
4651
  return producerSteps.slice(0, -1).concat(new SeqStep(last.field, key));
4635
4652
  }
4636
4653
  };
4637
- EMPTY_META = {};
4638
4654
  NO_EVENT_INFO = [null, null];
4639
4655
  BUBBLING_EVENTS = new Set(["drop"]);
4640
4656
  });
@@ -6177,6 +6193,7 @@ var init_anode = __esm(() => {
6177
6193
  super(nodeId, val);
6178
6194
  this.viewId = viewId;
6179
6195
  }
6196
+ setDataAttr(_key, _val) {}
6180
6197
  };
6181
6198
  RenderNode = class RenderNode extends RenderViewId {
6182
6199
  render(stack, rx) {
@@ -6249,6 +6266,7 @@ var init_anode = __esm(() => {
6249
6266
  render(stack, _rx) {
6250
6267
  return this.val.eval(stack);
6251
6268
  }
6269
+ setDataAttr(_key, _val) {}
6252
6270
  };
6253
6271
  RenderOnceNode = class RenderOnceNode extends BaseNode {
6254
6272
  constructor(node) {
@@ -14192,7 +14210,12 @@ class Renderer {
14192
14210
  if (cachedNode)
14193
14211
  return cachedNode;
14194
14212
  const view = viewName ? comp.getView(viewName) : stack.lookupBestView(comp.views, "main");
14195
- const meta = this._renderMetadata({ $: "Comp", nid: node?.nodeId ?? null });
14213
+ const meta = this._renderMetadata({
14214
+ $: "Comp",
14215
+ nid: node?.nodeId ?? null,
14216
+ cid: comp.id,
14217
+ vid: view.name
14218
+ });
14196
14219
  const dom = new VFragment([meta, this.renderView(view, stack)]);
14197
14220
  this.cache.set(cachePath, cacheKey, dom);
14198
14221
  return dom;