tutuca 0.9.46 → 0.9.47
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/tutuca-cli.js +55 -34
- package/dist/tutuca-dev.js +55 -34
- package/dist/tutuca-dev.min.js +2 -2
- package/dist/tutuca-extra.js +55 -34
- package/dist/tutuca-extra.min.js +2 -2
- package/dist/tutuca.js +55 -34
- package/dist/tutuca.min.js +2 -2
- package/package.json +1 -1
package/dist/tutuca-cli.js
CHANGED
|
@@ -3927,29 +3927,48 @@ function findHandlers(comp, eventIds, vid, eventName) {
|
|
|
3927
3927
|
}
|
|
3928
3928
|
return null;
|
|
3929
3929
|
}
|
|
3930
|
+
|
|
3931
|
+
class StepCtx {
|
|
3932
|
+
constructor(comp, nodeIds, idx, vid) {
|
|
3933
|
+
this.comp = comp;
|
|
3934
|
+
this.nodeIds = nodeIds;
|
|
3935
|
+
this.idx = idx;
|
|
3936
|
+
this.vid = vid;
|
|
3937
|
+
}
|
|
3938
|
+
get meta() {
|
|
3939
|
+
return this.nodeIds[this.idx];
|
|
3940
|
+
}
|
|
3941
|
+
get key() {
|
|
3942
|
+
const m = this.meta;
|
|
3943
|
+
return m.si !== undefined ? +m.si : m.sk;
|
|
3944
|
+
}
|
|
3945
|
+
get hasKey() {
|
|
3946
|
+
const m = this.meta;
|
|
3947
|
+
return m.si !== undefined || m.sk !== undefined;
|
|
3948
|
+
}
|
|
3949
|
+
next() {
|
|
3950
|
+
return this.idx + 1 < this.nodeIds.length ? new StepCtx(this.comp, this.nodeIds, this.idx + 1, this.vid) : null;
|
|
3951
|
+
}
|
|
3952
|
+
resolveNode() {
|
|
3953
|
+
return this.comp.getNodeForId(+this.meta.nid, this.vid);
|
|
3954
|
+
}
|
|
3955
|
+
applyKey(pi) {
|
|
3956
|
+
if (pi === null)
|
|
3957
|
+
return null;
|
|
3958
|
+
const m = this.meta;
|
|
3959
|
+
if (m.si !== undefined)
|
|
3960
|
+
return pi.withIndex(+m.si);
|
|
3961
|
+
if (m.sk !== undefined)
|
|
3962
|
+
return pi.withKey(m.sk);
|
|
3963
|
+
return pi;
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3930
3966
|
function resolvePathStep(comp, nodeIds, vid) {
|
|
3931
3967
|
for (let i = 0;i < nodeIds.length; i++) {
|
|
3932
|
-
const
|
|
3933
|
-
const
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
const next = nodeIds[i + 1];
|
|
3937
|
-
if (!next)
|
|
3938
|
-
continue;
|
|
3939
|
-
const nextNode = comp.getNodeForId(+next.nid, vid);
|
|
3940
|
-
const nKey = next.si !== undefined ? +next.si : next.sk;
|
|
3941
|
-
if (nextNode.toPathItemRenderIt && nKey !== undefined)
|
|
3942
|
-
return nextNode.toPathItemRenderIt(nKey);
|
|
3943
|
-
const pi2 = nextNode.val.toPathItem();
|
|
3944
|
-
if (pi2 !== null)
|
|
3945
|
-
return next.si !== undefined ? pi2.withIndex(nKey) : next.sk ? pi2.withKey(nKey) : pi2;
|
|
3946
|
-
continue;
|
|
3947
|
-
}
|
|
3948
|
-
if (key !== undefined && node.toPathItemEachBind)
|
|
3949
|
-
return node.toPathItemEachBind(key);
|
|
3950
|
-
const pi = node.toPathItem();
|
|
3951
|
-
if (pi !== null)
|
|
3952
|
-
return meta.si !== undefined ? pi.withIndex(+meta.si) : meta.sk ? pi.withKey(meta.sk) : pi;
|
|
3968
|
+
const ctx = new StepCtx(comp, nodeIds, i, vid);
|
|
3969
|
+
const step = ctx.resolveNode().toPathStep(ctx);
|
|
3970
|
+
if (step !== null)
|
|
3971
|
+
return step;
|
|
3953
3972
|
}
|
|
3954
3973
|
return null;
|
|
3955
3974
|
}
|
|
@@ -5094,8 +5113,8 @@ var init_anode = __esm(() => {
|
|
|
5094
5113
|
this.nodeId = nodeId;
|
|
5095
5114
|
this.val = val;
|
|
5096
5115
|
}
|
|
5097
|
-
|
|
5098
|
-
return this.val
|
|
5116
|
+
toPathStep(ctx) {
|
|
5117
|
+
return ctx.applyKey(this.val?.toPathItem?.() ?? null);
|
|
5099
5118
|
}
|
|
5100
5119
|
static parse(html, px) {
|
|
5101
5120
|
const nodes = px.parseHTML(html);
|
|
@@ -5209,7 +5228,15 @@ var init_anode = __esm(() => {
|
|
|
5209
5228
|
const newStack = stack.enter(stack.it, {}, true);
|
|
5210
5229
|
return rx.renderIt(newStack, this.nodeId, "", this.viewId);
|
|
5211
5230
|
}
|
|
5212
|
-
|
|
5231
|
+
toPathStep(ctx) {
|
|
5232
|
+
const next = ctx.next();
|
|
5233
|
+
if (next === null)
|
|
5234
|
+
return null;
|
|
5235
|
+
const nextNode = next.resolveNode();
|
|
5236
|
+
if (nextNode instanceof EachNode && next.hasKey)
|
|
5237
|
+
return new EachRenderItStep(nextNode.val.name, next.key);
|
|
5238
|
+
return null;
|
|
5239
|
+
}
|
|
5213
5240
|
};
|
|
5214
5241
|
RenderEachNode = class RenderEachNode extends RenderViewId {
|
|
5215
5242
|
constructor(nodeId, val, viewId) {
|
|
@@ -5296,7 +5323,7 @@ var init_anode = __esm(() => {
|
|
|
5296
5323
|
const binds = this.val.eval(stack)?.call(stack.it) ?? {};
|
|
5297
5324
|
return this.node.render(stack.enter(stack.it, binds, false), rx);
|
|
5298
5325
|
}
|
|
5299
|
-
|
|
5326
|
+
toPathStep(_ctx) {
|
|
5300
5327
|
return new BindStep({});
|
|
5301
5328
|
}
|
|
5302
5329
|
wrapNode(node) {
|
|
@@ -5313,14 +5340,8 @@ var init_anode = __esm(() => {
|
|
|
5313
5340
|
render(stack, rx) {
|
|
5314
5341
|
return rx.renderEachWhen(stack, this.iterInfo, this.node, this.nodeId);
|
|
5315
5342
|
}
|
|
5316
|
-
|
|
5317
|
-
return new
|
|
5318
|
-
}
|
|
5319
|
-
toPathItemRenderIt(key) {
|
|
5320
|
-
return new EachRenderItStep(this.val.name, key);
|
|
5321
|
-
}
|
|
5322
|
-
toPathItemEachBind(key) {
|
|
5323
|
-
return new EachBindStep(this.val, key);
|
|
5343
|
+
toPathStep(ctx) {
|
|
5344
|
+
return ctx.hasKey ? new EachBindStep(this.val, ctx.key) : null;
|
|
5324
5345
|
}
|
|
5325
5346
|
static register = true;
|
|
5326
5347
|
};
|
|
@@ -13552,8 +13573,8 @@ class Renderer {
|
|
|
13552
13573
|
renderEachWhen(stack, iterInfo, view, nid) {
|
|
13553
13574
|
const { seq, filter, loopWith, enricher } = iterInfo.eval(stack);
|
|
13554
13575
|
const r = [];
|
|
13555
|
-
const iterData = loopWith.call(stack.it, seq);
|
|
13556
13576
|
const it = stack.it;
|
|
13577
|
+
const iterData = loopWith.call(it, seq);
|
|
13557
13578
|
this.getSeqInfo(seq)(seq, (key, value, attrName) => {
|
|
13558
13579
|
if (filter.call(it, key, value, iterData)) {
|
|
13559
13580
|
const cachePath = enricher ? [it, value] : [value];
|
package/dist/tutuca-dev.js
CHANGED
|
@@ -3538,29 +3538,48 @@ function findHandlers(comp, eventIds, vid, eventName) {
|
|
|
3538
3538
|
}
|
|
3539
3539
|
return null;
|
|
3540
3540
|
}
|
|
3541
|
+
|
|
3542
|
+
class StepCtx {
|
|
3543
|
+
constructor(comp, nodeIds, idx, vid) {
|
|
3544
|
+
this.comp = comp;
|
|
3545
|
+
this.nodeIds = nodeIds;
|
|
3546
|
+
this.idx = idx;
|
|
3547
|
+
this.vid = vid;
|
|
3548
|
+
}
|
|
3549
|
+
get meta() {
|
|
3550
|
+
return this.nodeIds[this.idx];
|
|
3551
|
+
}
|
|
3552
|
+
get key() {
|
|
3553
|
+
const m = this.meta;
|
|
3554
|
+
return m.si !== undefined ? +m.si : m.sk;
|
|
3555
|
+
}
|
|
3556
|
+
get hasKey() {
|
|
3557
|
+
const m = this.meta;
|
|
3558
|
+
return m.si !== undefined || m.sk !== undefined;
|
|
3559
|
+
}
|
|
3560
|
+
next() {
|
|
3561
|
+
return this.idx + 1 < this.nodeIds.length ? new StepCtx(this.comp, this.nodeIds, this.idx + 1, this.vid) : null;
|
|
3562
|
+
}
|
|
3563
|
+
resolveNode() {
|
|
3564
|
+
return this.comp.getNodeForId(+this.meta.nid, this.vid);
|
|
3565
|
+
}
|
|
3566
|
+
applyKey(pi) {
|
|
3567
|
+
if (pi === null)
|
|
3568
|
+
return null;
|
|
3569
|
+
const m = this.meta;
|
|
3570
|
+
if (m.si !== undefined)
|
|
3571
|
+
return pi.withIndex(+m.si);
|
|
3572
|
+
if (m.sk !== undefined)
|
|
3573
|
+
return pi.withKey(m.sk);
|
|
3574
|
+
return pi;
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3541
3577
|
function resolvePathStep(comp, nodeIds, vid) {
|
|
3542
3578
|
for (let i = 0;i < nodeIds.length; i++) {
|
|
3543
|
-
const
|
|
3544
|
-
const
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
const next = nodeIds[i + 1];
|
|
3548
|
-
if (!next)
|
|
3549
|
-
continue;
|
|
3550
|
-
const nextNode = comp.getNodeForId(+next.nid, vid);
|
|
3551
|
-
const nKey = next.si !== undefined ? +next.si : next.sk;
|
|
3552
|
-
if (nextNode.toPathItemRenderIt && nKey !== undefined)
|
|
3553
|
-
return nextNode.toPathItemRenderIt(nKey);
|
|
3554
|
-
const pi2 = nextNode.val.toPathItem();
|
|
3555
|
-
if (pi2 !== null)
|
|
3556
|
-
return next.si !== undefined ? pi2.withIndex(nKey) : next.sk ? pi2.withKey(nKey) : pi2;
|
|
3557
|
-
continue;
|
|
3558
|
-
}
|
|
3559
|
-
if (key !== undefined && node.toPathItemEachBind)
|
|
3560
|
-
return node.toPathItemEachBind(key);
|
|
3561
|
-
const pi = node.toPathItem();
|
|
3562
|
-
if (pi !== null)
|
|
3563
|
-
return meta.si !== undefined ? pi.withIndex(+meta.si) : meta.sk ? pi.withKey(meta.sk) : pi;
|
|
3579
|
+
const ctx = new StepCtx(comp, nodeIds, i, vid);
|
|
3580
|
+
const step = ctx.resolveNode().toPathStep(ctx);
|
|
3581
|
+
if (step !== null)
|
|
3582
|
+
return step;
|
|
3564
3583
|
}
|
|
3565
3584
|
return null;
|
|
3566
3585
|
}
|
|
@@ -4360,8 +4379,8 @@ class ANode extends BaseNode {
|
|
|
4360
4379
|
this.nodeId = nodeId;
|
|
4361
4380
|
this.val = val;
|
|
4362
4381
|
}
|
|
4363
|
-
|
|
4364
|
-
return this.val
|
|
4382
|
+
toPathStep(ctx) {
|
|
4383
|
+
return ctx.applyKey(this.val?.toPathItem?.() ?? null);
|
|
4365
4384
|
}
|
|
4366
4385
|
static parse(html, px) {
|
|
4367
4386
|
const nodes = px.parseHTML(html);
|
|
@@ -4579,7 +4598,15 @@ class RenderItNode extends RenderViewId {
|
|
|
4579
4598
|
const newStack = stack.enter(stack.it, {}, true);
|
|
4580
4599
|
return rx.renderIt(newStack, this.nodeId, "", this.viewId);
|
|
4581
4600
|
}
|
|
4582
|
-
|
|
4601
|
+
toPathStep(ctx) {
|
|
4602
|
+
const next = ctx.next();
|
|
4603
|
+
if (next === null)
|
|
4604
|
+
return null;
|
|
4605
|
+
const nextNode = next.resolveNode();
|
|
4606
|
+
if (nextNode instanceof EachNode && next.hasKey)
|
|
4607
|
+
return new EachRenderItStep(nextNode.val.name, next.key);
|
|
4608
|
+
return null;
|
|
4609
|
+
}
|
|
4583
4610
|
}
|
|
4584
4611
|
|
|
4585
4612
|
class RenderEachNode extends RenderViewId {
|
|
@@ -4675,7 +4702,7 @@ class ScopeNode extends WrapperNode {
|
|
|
4675
4702
|
const binds = this.val.eval(stack)?.call(stack.it) ?? {};
|
|
4676
4703
|
return this.node.render(stack.enter(stack.it, binds, false), rx);
|
|
4677
4704
|
}
|
|
4678
|
-
|
|
4705
|
+
toPathStep(_ctx) {
|
|
4679
4706
|
return new BindStep({});
|
|
4680
4707
|
}
|
|
4681
4708
|
wrapNode(node) {
|
|
@@ -4693,14 +4720,8 @@ class EachNode extends WrapperNode {
|
|
|
4693
4720
|
render(stack, rx) {
|
|
4694
4721
|
return rx.renderEachWhen(stack, this.iterInfo, this.node, this.nodeId);
|
|
4695
4722
|
}
|
|
4696
|
-
|
|
4697
|
-
return new
|
|
4698
|
-
}
|
|
4699
|
-
toPathItemRenderIt(key) {
|
|
4700
|
-
return new EachRenderItStep(this.val.name, key);
|
|
4701
|
-
}
|
|
4702
|
-
toPathItemEachBind(key) {
|
|
4703
|
-
return new EachBindStep(this.val, key);
|
|
4723
|
+
toPathStep(ctx) {
|
|
4724
|
+
return ctx.hasKey ? new EachBindStep(this.val, ctx.key) : null;
|
|
4704
4725
|
}
|
|
4705
4726
|
static register = true;
|
|
4706
4727
|
}
|
|
@@ -14450,8 +14471,8 @@ class Renderer {
|
|
|
14450
14471
|
renderEachWhen(stack, iterInfo, view, nid) {
|
|
14451
14472
|
const { seq, filter, loopWith, enricher } = iterInfo.eval(stack);
|
|
14452
14473
|
const r = [];
|
|
14453
|
-
const iterData = loopWith.call(stack.it, seq);
|
|
14454
14474
|
const it = stack.it;
|
|
14475
|
+
const iterData = loopWith.call(it, seq);
|
|
14455
14476
|
this.getSeqInfo(seq)(seq, (key, value, attrName) => {
|
|
14456
14477
|
if (filter.call(it, key, value, iterData)) {
|
|
14457
14478
|
const cachePath = enricher ? [it, value] : [value];
|