tutuca 0.9.95 → 0.9.97
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 +40 -10
- package/dist/tutuca-dev.ext.js +41 -9
- package/dist/tutuca-dev.js +41 -9
- package/dist/tutuca-dev.min.js +1 -1
- package/dist/tutuca-extra.ext.js +41 -9
- package/dist/tutuca-extra.js +41 -9
- package/dist/tutuca-extra.min.js +1 -1
- package/dist/tutuca.ext.js +41 -9
- package/dist/tutuca.js +41 -9
- package/dist/tutuca.min.js +1 -1
- package/package.json +1 -1
- package/skill/tutuca/semantics.md +3 -2
- package/skill/tutuca-source/tutuca.ext.js +41 -9
package/dist/tutuca.ext.js
CHANGED
|
@@ -47,6 +47,23 @@ class BindStep extends Step {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
class ScopeBindStep extends BindStep {
|
|
51
|
+
constructor(val, binds = {}) {
|
|
52
|
+
super(binds);
|
|
53
|
+
this.val = val;
|
|
54
|
+
}
|
|
55
|
+
enterFrame(stack, _prev, next) {
|
|
56
|
+
const dyn = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
|
|
57
|
+
return stack.enter(next, { ...this.binds, ...dyn }, false);
|
|
58
|
+
}
|
|
59
|
+
withIndex(i) {
|
|
60
|
+
return new ScopeBindStep(this.val, { ...this.binds, key: i });
|
|
61
|
+
}
|
|
62
|
+
withKey(key) {
|
|
63
|
+
return new ScopeBindStep(this.val, { ...this.binds, key });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
50
67
|
class FieldStep extends Step {
|
|
51
68
|
constructor(field) {
|
|
52
69
|
super();
|
|
@@ -108,9 +125,9 @@ class SeqAccessStep extends Step {
|
|
|
108
125
|
}
|
|
109
126
|
|
|
110
127
|
class EachBindStep extends Step {
|
|
111
|
-
constructor(
|
|
128
|
+
constructor(iterInfo, key) {
|
|
112
129
|
super();
|
|
113
|
-
this.
|
|
130
|
+
this.iterInfo = iterInfo;
|
|
114
131
|
this.key = key;
|
|
115
132
|
}
|
|
116
133
|
lookup(v, _dval) {
|
|
@@ -120,8 +137,7 @@ class EachBindStep extends Step {
|
|
|
120
137
|
return v;
|
|
121
138
|
}
|
|
122
139
|
enterFrame(stack, _prev, next) {
|
|
123
|
-
|
|
124
|
-
return stack.enter(next, { key: this.key, value: item }, false);
|
|
140
|
+
return stack.enter(next, this.iterInfo.enrichBinds(stack, this.key), false);
|
|
125
141
|
}
|
|
126
142
|
toAbstractPathStep() {
|
|
127
143
|
return null;
|
|
@@ -1208,6 +1224,8 @@ class RequestHandler {
|
|
|
1208
1224
|
import { isIndexed, isKeyed } from "immutable";
|
|
1209
1225
|
|
|
1210
1226
|
// src/cache.js
|
|
1227
|
+
var isWeakKey = (k) => k !== null && (typeof k === "object" || typeof k === "function");
|
|
1228
|
+
|
|
1211
1229
|
class NullDomCache {
|
|
1212
1230
|
get(_keys, _cacheKey) {}
|
|
1213
1231
|
set(_keys, _cacheKey, _v) {}
|
|
@@ -1251,7 +1269,7 @@ class WeakMapDomCache {
|
|
|
1251
1269
|
const key = keys[i];
|
|
1252
1270
|
let next = cur.get(key);
|
|
1253
1271
|
if (!next) {
|
|
1254
|
-
if (
|
|
1272
|
+
if (!isWeakKey(key)) {
|
|
1255
1273
|
this.badKey += 1;
|
|
1256
1274
|
return;
|
|
1257
1275
|
}
|
|
@@ -1264,7 +1282,7 @@ class WeakMapDomCache {
|
|
|
1264
1282
|
const leaf = cur.get(lastKey);
|
|
1265
1283
|
if (leaf)
|
|
1266
1284
|
leaf[cacheKey] = v;
|
|
1267
|
-
else if (
|
|
1285
|
+
else if (isWeakKey(lastKey))
|
|
1268
1286
|
cur.set(lastKey, { [cacheKey]: v });
|
|
1269
1287
|
else
|
|
1270
1288
|
this.badKey += 1;
|
|
@@ -1776,6 +1794,9 @@ class Renderer {
|
|
|
1776
1794
|
_renderMetadata(info) {
|
|
1777
1795
|
return new VComment(`§${JSON.stringify(info)}§`);
|
|
1778
1796
|
}
|
|
1797
|
+
renderScopeMeta(nid, dom) {
|
|
1798
|
+
return new VFragment([this._renderMetadata({ $: "Scope", nid }), dom]);
|
|
1799
|
+
}
|
|
1779
1800
|
}
|
|
1780
1801
|
var getSeqInfo = (seq) => isIndexed(seq) ? imIndexedIter : isKeyed(seq) ? imKeyedIter : seq?.[SEQ_INFO] ?? unkIter;
|
|
1781
1802
|
var normalizeRange = (start, end, size) => {
|
|
@@ -2296,10 +2317,11 @@ class SlotNode extends WrapperNode {
|
|
|
2296
2317
|
class ScopeNode extends WrapperNode {
|
|
2297
2318
|
render(stack, rx) {
|
|
2298
2319
|
const binds = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
|
|
2299
|
-
|
|
2320
|
+
const dom = this.node.render(stack.enter(stack.it, binds, false), rx);
|
|
2321
|
+
return rx.renderScopeMeta(this.nodeId, dom);
|
|
2300
2322
|
}
|
|
2301
2323
|
toPathStep(_ctx) {
|
|
2302
|
-
return new
|
|
2324
|
+
return new ScopeBindStep(this.val);
|
|
2303
2325
|
}
|
|
2304
2326
|
wrapNode(node) {
|
|
2305
2327
|
this.node = node;
|
|
@@ -2317,7 +2339,7 @@ class EachNode extends WrapperNode {
|
|
|
2317
2339
|
return rx.renderEachWhen(stack, this.iterInfo, this.node, this.nodeId);
|
|
2318
2340
|
}
|
|
2319
2341
|
toPathStep(ctx) {
|
|
2320
|
-
return ctx.hasKey ? new EachBindStep(this.
|
|
2342
|
+
return ctx.hasKey ? new EachBindStep(this.iterInfo, ctx.key) : null;
|
|
2321
2343
|
}
|
|
2322
2344
|
static register = true;
|
|
2323
2345
|
}
|
|
@@ -2336,6 +2358,16 @@ class IterInfo {
|
|
|
2336
2358
|
const enricher = this.enrichWithVal?.evalAsHandler(stack) ?? null;
|
|
2337
2359
|
return { seq, filter, loopWith, enricher };
|
|
2338
2360
|
}
|
|
2361
|
+
enrichBinds(stack, key) {
|
|
2362
|
+
const { seq, loopWith, enricher } = this.eval(stack);
|
|
2363
|
+
const value = seq?.get ? seq.get(key, null) : null;
|
|
2364
|
+
const binds = { key, value };
|
|
2365
|
+
if (enricher) {
|
|
2366
|
+
const { iterData } = unpackLoopResult(loopWith.call(stack.it, seq), seq);
|
|
2367
|
+
enricher.call(stack.it, binds, key, value, iterData);
|
|
2368
|
+
}
|
|
2369
|
+
return binds;
|
|
2370
|
+
}
|
|
2339
2371
|
}
|
|
2340
2372
|
function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
|
|
2341
2373
|
return { consumed: new Set(consumed), wrappable, wrapper };
|
package/dist/tutuca.js
CHANGED
|
@@ -4420,6 +4420,23 @@ class BindStep extends Step {
|
|
|
4420
4420
|
}
|
|
4421
4421
|
}
|
|
4422
4422
|
|
|
4423
|
+
class ScopeBindStep extends BindStep {
|
|
4424
|
+
constructor(val, binds = {}) {
|
|
4425
|
+
super(binds);
|
|
4426
|
+
this.val = val;
|
|
4427
|
+
}
|
|
4428
|
+
enterFrame(stack, _prev, next) {
|
|
4429
|
+
const dyn = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
|
|
4430
|
+
return stack.enter(next, { ...this.binds, ...dyn }, false);
|
|
4431
|
+
}
|
|
4432
|
+
withIndex(i) {
|
|
4433
|
+
return new ScopeBindStep(this.val, { ...this.binds, key: i });
|
|
4434
|
+
}
|
|
4435
|
+
withKey(key) {
|
|
4436
|
+
return new ScopeBindStep(this.val, { ...this.binds, key });
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
|
|
4423
4440
|
class FieldStep extends Step {
|
|
4424
4441
|
constructor(field) {
|
|
4425
4442
|
super();
|
|
@@ -4481,9 +4498,9 @@ class SeqAccessStep extends Step {
|
|
|
4481
4498
|
}
|
|
4482
4499
|
|
|
4483
4500
|
class EachBindStep extends Step {
|
|
4484
|
-
constructor(
|
|
4501
|
+
constructor(iterInfo, key) {
|
|
4485
4502
|
super();
|
|
4486
|
-
this.
|
|
4503
|
+
this.iterInfo = iterInfo;
|
|
4487
4504
|
this.key = key;
|
|
4488
4505
|
}
|
|
4489
4506
|
lookup(v, _dval) {
|
|
@@ -4493,8 +4510,7 @@ class EachBindStep extends Step {
|
|
|
4493
4510
|
return v;
|
|
4494
4511
|
}
|
|
4495
4512
|
enterFrame(stack, _prev, next) {
|
|
4496
|
-
|
|
4497
|
-
return stack.enter(next, { key: this.key, value: item }, false);
|
|
4513
|
+
return stack.enter(next, this.iterInfo.enrichBinds(stack, this.key), false);
|
|
4498
4514
|
}
|
|
4499
4515
|
toAbstractPathStep() {
|
|
4500
4516
|
return null;
|
|
@@ -5578,6 +5594,8 @@ class RequestHandler {
|
|
|
5578
5594
|
}
|
|
5579
5595
|
|
|
5580
5596
|
// src/cache.js
|
|
5597
|
+
var isWeakKey = (k) => k !== null && (typeof k === "object" || typeof k === "function");
|
|
5598
|
+
|
|
5581
5599
|
class NullDomCache {
|
|
5582
5600
|
get(_keys, _cacheKey) {}
|
|
5583
5601
|
set(_keys, _cacheKey, _v) {}
|
|
@@ -5621,7 +5639,7 @@ class WeakMapDomCache {
|
|
|
5621
5639
|
const key = keys[i];
|
|
5622
5640
|
let next = cur.get(key);
|
|
5623
5641
|
if (!next) {
|
|
5624
|
-
if (
|
|
5642
|
+
if (!isWeakKey(key)) {
|
|
5625
5643
|
this.badKey += 1;
|
|
5626
5644
|
return;
|
|
5627
5645
|
}
|
|
@@ -5634,7 +5652,7 @@ class WeakMapDomCache {
|
|
|
5634
5652
|
const leaf = cur.get(lastKey);
|
|
5635
5653
|
if (leaf)
|
|
5636
5654
|
leaf[cacheKey] = v;
|
|
5637
|
-
else if (
|
|
5655
|
+
else if (isWeakKey(lastKey))
|
|
5638
5656
|
cur.set(lastKey, { [cacheKey]: v });
|
|
5639
5657
|
else
|
|
5640
5658
|
this.badKey += 1;
|
|
@@ -6146,6 +6164,9 @@ class Renderer {
|
|
|
6146
6164
|
_renderMetadata(info) {
|
|
6147
6165
|
return new VComment(`§${JSON.stringify(info)}§`);
|
|
6148
6166
|
}
|
|
6167
|
+
renderScopeMeta(nid, dom) {
|
|
6168
|
+
return new VFragment([this._renderMetadata({ $: "Scope", nid }), dom]);
|
|
6169
|
+
}
|
|
6149
6170
|
}
|
|
6150
6171
|
var getSeqInfo = (seq) => isIndexed(seq) ? imIndexedIter : isKeyed(seq) ? imKeyedIter : seq?.[SEQ_INFO] ?? unkIter;
|
|
6151
6172
|
var normalizeRange = (start, end, size) => {
|
|
@@ -6666,10 +6687,11 @@ class SlotNode extends WrapperNode {
|
|
|
6666
6687
|
class ScopeNode extends WrapperNode {
|
|
6667
6688
|
render(stack, rx) {
|
|
6668
6689
|
const binds = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
|
|
6669
|
-
|
|
6690
|
+
const dom = this.node.render(stack.enter(stack.it, binds, false), rx);
|
|
6691
|
+
return rx.renderScopeMeta(this.nodeId, dom);
|
|
6670
6692
|
}
|
|
6671
6693
|
toPathStep(_ctx) {
|
|
6672
|
-
return new
|
|
6694
|
+
return new ScopeBindStep(this.val);
|
|
6673
6695
|
}
|
|
6674
6696
|
wrapNode(node) {
|
|
6675
6697
|
this.node = node;
|
|
@@ -6687,7 +6709,7 @@ class EachNode extends WrapperNode {
|
|
|
6687
6709
|
return rx.renderEachWhen(stack, this.iterInfo, this.node, this.nodeId);
|
|
6688
6710
|
}
|
|
6689
6711
|
toPathStep(ctx) {
|
|
6690
|
-
return ctx.hasKey ? new EachBindStep(this.
|
|
6712
|
+
return ctx.hasKey ? new EachBindStep(this.iterInfo, ctx.key) : null;
|
|
6691
6713
|
}
|
|
6692
6714
|
static register = true;
|
|
6693
6715
|
}
|
|
@@ -6706,6 +6728,16 @@ class IterInfo {
|
|
|
6706
6728
|
const enricher = this.enrichWithVal?.evalAsHandler(stack) ?? null;
|
|
6707
6729
|
return { seq, filter, loopWith, enricher };
|
|
6708
6730
|
}
|
|
6731
|
+
enrichBinds(stack, key) {
|
|
6732
|
+
const { seq, loopWith, enricher } = this.eval(stack);
|
|
6733
|
+
const value = seq?.get ? seq.get(key, null) : null;
|
|
6734
|
+
const binds = { key, value };
|
|
6735
|
+
if (enricher) {
|
|
6736
|
+
const { iterData } = unpackLoopResult(loopWith.call(stack.it, seq), seq);
|
|
6737
|
+
enricher.call(stack.it, binds, key, value, iterData);
|
|
6738
|
+
}
|
|
6739
|
+
return binds;
|
|
6740
|
+
}
|
|
6709
6741
|
}
|
|
6710
6742
|
function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
|
|
6711
6743
|
return { consumed: new Set(consumed), wrappable, wrapper };
|