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/package.json
CHANGED
|
@@ -56,8 +56,9 @@ The reconstructed path is transformed two ways depending on use:
|
|
|
56
56
|
|
|
57
57
|
The DOM is the only thing that survives between render and click, so the
|
|
58
58
|
renderer leaves breadcrumbs: `data-cid` / `data-nid` / `data-eid` on
|
|
59
|
-
elements, and `§…§` comment "metas" adjacent to component boundaries
|
|
60
|
-
iteration entries
|
|
59
|
+
elements, and `§…§` comment "metas" adjacent to component boundaries,
|
|
60
|
+
iteration entries, and scope boundaries (`@scope` / `@enrich-with`, so
|
|
61
|
+
their custom binds can be replayed). On an event, `Path.fromNodeAndEventName` walks from the
|
|
61
62
|
target up to the root, reads the breadcrumbs, and rebuilds the path. Along
|
|
62
63
|
the way it resolves the handler: normally on the **leaf** component, but
|
|
63
64
|
for bubbling events (and explicit `bubble`) it can resolve on an
|
|
@@ -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 };
|