tutuca 0.13.0 → 0.13.2
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 +136 -214
- package/dist/tutuca-dev.ext.js +123 -199
- package/dist/tutuca-dev.js +123 -199
- package/dist/tutuca-dev.min.js +4 -4
- package/dist/tutuca-extra.ext.js +120 -196
- package/dist/tutuca-extra.js +120 -196
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.ext.js +120 -196
- package/dist/tutuca.js +120 -196
- package/dist/tutuca.min.js +3 -3
- package/package.json +1 -1
- package/skill/tutuca/core.md +4 -2
- package/skill/tutuca/testing.md +1 -1
- package/skill/tutuca-source/tutuca.ext.js +120 -196
package/dist/tutuca-dev.ext.js
CHANGED
|
@@ -222,11 +222,6 @@ var writeKey = (value, key, next) => {
|
|
|
222
222
|
value.add(next);
|
|
223
223
|
} else value[key] = next;
|
|
224
224
|
};
|
|
225
|
-
var readSeqKey = (value, key, dval = null) => {
|
|
226
|
-
const direct = readKey(value, key, NONE);
|
|
227
|
-
if (direct !== NONE) return direct;
|
|
228
|
-
return typeof value?.get === "function" ? value.get(key, dval) : dval;
|
|
229
|
-
};
|
|
230
225
|
var writeSeqKey = (value, key, next) => {
|
|
231
226
|
if (value instanceof Map || value instanceof Set || Array.isArray(value) || Object.hasOwn(value, key))
|
|
232
227
|
writeKey(value, key, next);
|
|
@@ -239,7 +234,7 @@ var Step = class {
|
|
|
239
234
|
}
|
|
240
235
|
setDraftValue(_root, _v) {
|
|
241
236
|
}
|
|
242
|
-
enterFrame(stack,
|
|
237
|
+
enterFrame(stack, next) {
|
|
243
238
|
return stack.enter(next, {}, true);
|
|
244
239
|
}
|
|
245
240
|
toAbstractPathStep() {
|
|
@@ -265,7 +260,7 @@ var BindStep = class _BindStep extends Step {
|
|
|
265
260
|
lookup(v, _dval) {
|
|
266
261
|
return v;
|
|
267
262
|
}
|
|
268
|
-
enterFrame(stack,
|
|
263
|
+
enterFrame(stack, next) {
|
|
269
264
|
return stack.enter(next, { ...this.binds }, false);
|
|
270
265
|
}
|
|
271
266
|
withIndex(i) {
|
|
@@ -283,7 +278,7 @@ var ScopeBindStep = class _ScopeBindStep extends BindStep {
|
|
|
283
278
|
super(binds);
|
|
284
279
|
this.val = val;
|
|
285
280
|
}
|
|
286
|
-
enterFrame(stack,
|
|
281
|
+
enterFrame(stack, next) {
|
|
287
282
|
const dyn = this.val.evalAsHandler(stack)?.call(stack.it) ?? {};
|
|
288
283
|
return stack.enter(next, { ...this.binds, ...dyn }, false);
|
|
289
284
|
}
|
|
@@ -322,13 +317,13 @@ var SeqStep = class extends Step {
|
|
|
322
317
|
this.key = key;
|
|
323
318
|
}
|
|
324
319
|
lookup(v, dval = null) {
|
|
325
|
-
return
|
|
320
|
+
return seqGet(readKey(v, this.field, null), this.key, dval);
|
|
326
321
|
}
|
|
327
322
|
setDraftValue(root, v) {
|
|
328
323
|
const seq = readKey(root, this.field, null);
|
|
329
324
|
if (seq != null) writeSeqKey(seq, this.key, v);
|
|
330
325
|
}
|
|
331
|
-
enterFrame(stack,
|
|
326
|
+
enterFrame(stack, next) {
|
|
332
327
|
return stack.enter(next, { key: this.key }, true);
|
|
333
328
|
}
|
|
334
329
|
toKey() {
|
|
@@ -344,7 +339,7 @@ var SeqAccessStep = class extends Step {
|
|
|
344
339
|
lookup(v, dval = null) {
|
|
345
340
|
const seq = readKey(v, this.seqField, NONE);
|
|
346
341
|
const key = readKey(v, this.keyField, NONE);
|
|
347
|
-
return key !== NONE && seq !== NONE ?
|
|
342
|
+
return key !== NONE && seq !== NONE ? seqGet(seq, key, dval) : dval;
|
|
348
343
|
}
|
|
349
344
|
setDraftValue(root, v) {
|
|
350
345
|
const seq = readKey(root, this.seqField, NONE);
|
|
@@ -375,7 +370,7 @@ var EachBindStep = class extends Step {
|
|
|
375
370
|
}
|
|
376
371
|
// Replay the renderer's per-item binds (key, value + any @enrich-with binds)
|
|
377
372
|
// so a rebuilt stack matches the one @each rendered with.
|
|
378
|
-
enterFrame(stack,
|
|
373
|
+
enterFrame(stack, next) {
|
|
379
374
|
return stack.enter(next, this.iterInfo.enrichBinds(stack, this.key), false);
|
|
380
375
|
}
|
|
381
376
|
toAbstractPathStep() {
|
|
@@ -383,7 +378,7 @@ var EachBindStep = class extends Step {
|
|
|
383
378
|
}
|
|
384
379
|
};
|
|
385
380
|
var EachRenderItStep = class extends SeqStep {
|
|
386
|
-
enterFrame(stack,
|
|
381
|
+
enterFrame(stack, next) {
|
|
387
382
|
return stack.enter(next, { key: this.key, value: next }, false).enter(next, {}, true);
|
|
388
383
|
}
|
|
389
384
|
toAbstractPathStep() {
|
|
@@ -408,7 +403,7 @@ var DynStep = class extends Step {
|
|
|
408
403
|
warnRawDynStep("lookup", this);
|
|
409
404
|
return dval;
|
|
410
405
|
}
|
|
411
|
-
enterFrame(stack,
|
|
406
|
+
enterFrame(stack, _next) {
|
|
412
407
|
warnRawDynStep("enterFrame", this);
|
|
413
408
|
return stack;
|
|
414
409
|
}
|
|
@@ -546,7 +541,7 @@ var Path = class _Path {
|
|
|
546
541
|
console.warn("bad PathItem", { root: stack.it, step, path: this });
|
|
547
542
|
return null;
|
|
548
543
|
}
|
|
549
|
-
stack = step.enterFrame(stack,
|
|
544
|
+
stack = step.enterFrame(stack, next);
|
|
550
545
|
prev = next;
|
|
551
546
|
}
|
|
552
547
|
return stack;
|
|
@@ -616,10 +611,6 @@ var Path = class _Path {
|
|
|
616
611
|
console.warn("event reconstruction: dynamic-var producer not found", pendingDyns);
|
|
617
612
|
return [new _Path(pathSteps.reverse()), handlers];
|
|
618
613
|
}
|
|
619
|
-
static fromEvent(e, rNode, maxDepth, comps, stopOnNoEvent = true) {
|
|
620
|
-
const { type, target } = e;
|
|
621
|
-
return _Path.fromNodeAndEventName(target, type, rNode, maxDepth, comps, stopOnNoEvent);
|
|
622
|
-
}
|
|
623
614
|
};
|
|
624
615
|
function metaChain(n) {
|
|
625
616
|
const out = [];
|
|
@@ -1179,7 +1170,7 @@ var Attributes = class {
|
|
|
1179
1170
|
this.items = items;
|
|
1180
1171
|
}
|
|
1181
1172
|
static parse(attributes, px, parseAll = false) {
|
|
1182
|
-
return
|
|
1173
|
+
return new AttrParser(px).parse(attributes, parseAll);
|
|
1183
1174
|
}
|
|
1184
1175
|
isConstant() {
|
|
1185
1176
|
return false;
|
|
@@ -1425,9 +1416,6 @@ var IfAttr = class extends BaseAttr {
|
|
|
1425
1416
|
return this.condVal.eval(stack) ? this.thenVal.eval(stack) : this.elseVal.eval(stack);
|
|
1426
1417
|
}
|
|
1427
1418
|
};
|
|
1428
|
-
function getAttrParser(px) {
|
|
1429
|
-
return new AttrParser(px);
|
|
1430
|
-
}
|
|
1431
1419
|
var EventHandler = class _EventHandler {
|
|
1432
1420
|
constructor(handlerVal, args = []) {
|
|
1433
1421
|
this.handlerVal = handlerVal;
|
|
@@ -1443,12 +1431,6 @@ var EventHandler = class _EventHandler {
|
|
|
1443
1431
|
return r === null ? null : new _EventHandler(r.handlerVal, r.args);
|
|
1444
1432
|
}
|
|
1445
1433
|
};
|
|
1446
|
-
var IntentHandler = class {
|
|
1447
|
-
constructor(name, fn) {
|
|
1448
|
-
this.name = name;
|
|
1449
|
-
this.fn = fn;
|
|
1450
|
-
}
|
|
1451
|
-
};
|
|
1452
1434
|
|
|
1453
1435
|
// src/iteration.js
|
|
1454
1436
|
var SEQ_INFO = /* @__PURE__ */ Symbol.for("tutuca.seqInfo");
|
|
@@ -1499,6 +1481,15 @@ var callEnricher = (enricher, it, binds, key, value, iterData) => {
|
|
|
1499
1481
|
binds.key = key;
|
|
1500
1482
|
binds.value = value;
|
|
1501
1483
|
};
|
|
1484
|
+
function bindsForKey({ seq, it, loopWith, enricher, ctx }, key) {
|
|
1485
|
+
const value = seqGet(seq, key, null);
|
|
1486
|
+
const binds = { key, value };
|
|
1487
|
+
if (enricher) {
|
|
1488
|
+
const { iterData } = unpackLoopResult(loopWith.call(it, seq, ctx), seq);
|
|
1489
|
+
callEnricher(enricher, it, binds, key, value, iterData);
|
|
1490
|
+
}
|
|
1491
|
+
return binds;
|
|
1492
|
+
}
|
|
1502
1493
|
var visitKeys = (seq, keys, visit) => {
|
|
1503
1494
|
const attrName = isIndexedSeq(seq) ? "si" : "sk";
|
|
1504
1495
|
for (const key of keys) visit(key, seqGet(seq, key), attrName);
|
|
@@ -2343,20 +2334,11 @@ var IterInfo = class {
|
|
|
2343
2334
|
const enricher = this.enrichWithVal?.evalAsHandler(stack) ?? null;
|
|
2344
2335
|
return { seq, filter, loopWith, enricher };
|
|
2345
2336
|
}
|
|
2346
|
-
// Rebuild the per-item binds for `key
|
|
2347
|
-
// { key, value }, then run @enrich-with (with @loop-with's iterData) if any.
|
|
2337
|
+
// Rebuild the per-item binds for `key` (see iteration.js bindsForKey).
|
|
2348
2338
|
enrichBinds(stack, key) {
|
|
2349
2339
|
const { seq, filter, loopWith, enricher } = this.eval(stack);
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2352
|
-
if (enricher) {
|
|
2353
|
-
const { iterData } = unpackLoopResult(
|
|
2354
|
-
loopWith.call(stack.it, seq, makeLoopCtx(stack, filter)),
|
|
2355
|
-
seq
|
|
2356
|
-
);
|
|
2357
|
-
callEnricher(enricher, stack.it, binds, key, value, iterData);
|
|
2358
|
-
}
|
|
2359
|
-
return binds;
|
|
2340
|
+
const ctx = makeLoopCtx(stack, filter);
|
|
2341
|
+
return bindsForKey({ seq, it: stack.it, loopWith, enricher, ctx }, key);
|
|
2360
2342
|
}
|
|
2361
2343
|
};
|
|
2362
2344
|
function xOp(consumed = [], { wrappable = false, wrapper = null, ignoresChildren = false } = {}) {
|
|
@@ -2552,10 +2534,11 @@ var NodeEvent = class {
|
|
|
2552
2534
|
}
|
|
2553
2535
|
};
|
|
2554
2536
|
var fwdIfCtxPred = (pred) => (w) => (that, f, args, ctx) => pred(ctx) ? w(that, f, args, ctx) : that;
|
|
2555
|
-
var
|
|
2556
|
-
var
|
|
2557
|
-
var
|
|
2558
|
-
var
|
|
2537
|
+
var fwdIfEventPred = (pred) => fwdIfCtxPred(({ e }) => pred(e));
|
|
2538
|
+
var fwdIfKey = (keyName) => fwdIfEventPred(keyIs(keyName));
|
|
2539
|
+
var fwdCtrl = fwdIfEventPred(macCtrl);
|
|
2540
|
+
var fwdMeta = fwdIfEventPred((e) => e.metaKey);
|
|
2541
|
+
var fwdAlt = fwdIfEventPred((e) => e.altKey);
|
|
2559
2542
|
var MOD_WRAPPERS_FOR_ANY_EVENT = {
|
|
2560
2543
|
ctrl: fwdCtrl,
|
|
2561
2544
|
cmd: fwdCtrl,
|
|
@@ -2740,13 +2723,15 @@ var ComponentStack = class _ComponentStack {
|
|
|
2740
2723
|
getCompFor(v) {
|
|
2741
2724
|
return this.comps.getCompFor(v);
|
|
2742
2725
|
}
|
|
2743
|
-
// Handlers that answer an intent's `lex` leg. A name maps to a LIST
|
|
2744
|
-
// walks: a handler that returns PASS declines and hands
|
|
2745
|
-
//
|
|
2726
|
+
// Handlers that answer an intent's `lex` leg. A name maps to a LIST of plain
|
|
2727
|
+
// functions, because the leg walks: a handler that returns PASS declines and hands
|
|
2728
|
+
// the intent to the next one. Each runs with no `this` and takes a dispatcher
|
|
2729
|
+
// context as its final argument; resolving answers, throwing fails. A bare function
|
|
2730
|
+
// is accepted as a one-element list.
|
|
2746
2731
|
registerIntentHandlers(handlers) {
|
|
2747
2732
|
for (const name in handlers) {
|
|
2748
|
-
const fns =
|
|
2749
|
-
this.intentsByName[name] =
|
|
2733
|
+
const fns = handlers[name];
|
|
2734
|
+
this.intentsByName[name] = Array.isArray(fns) ? fns : [fns];
|
|
2750
2735
|
}
|
|
2751
2736
|
}
|
|
2752
2737
|
// Innermost scope first, then outward. Concatenated rather than first-match, so a
|
|
@@ -2776,14 +2761,12 @@ var ComponentStack = class _ComponentStack {
|
|
|
2776
2761
|
}
|
|
2777
2762
|
};
|
|
2778
2763
|
var ProvideInfo = class {
|
|
2779
|
-
constructor(
|
|
2780
|
-
this.name = name;
|
|
2764
|
+
constructor(val) {
|
|
2781
2765
|
this.val = val;
|
|
2782
2766
|
}
|
|
2783
2767
|
};
|
|
2784
2768
|
var LookupInfo = class {
|
|
2785
|
-
constructor(
|
|
2786
|
-
this.name = name;
|
|
2769
|
+
constructor(val) {
|
|
2787
2770
|
this.val = val;
|
|
2788
2771
|
}
|
|
2789
2772
|
};
|
|
@@ -2831,13 +2814,13 @@ var Component = class {
|
|
|
2831
2814
|
continue;
|
|
2832
2815
|
}
|
|
2833
2816
|
const val = parseProvide(this._rawProvide[key], ctx);
|
|
2834
|
-
if (val) this.provide[key] = new ProvideInfo(
|
|
2817
|
+
if (val) this.provide[key] = new ProvideInfo(val);
|
|
2835
2818
|
}
|
|
2836
2819
|
for (const entry of this._rawLookup) {
|
|
2837
2820
|
const name = isString(entry) ? entry : isString(entry?.name) ? entry.name : null;
|
|
2838
2821
|
if (name === null) continue;
|
|
2839
2822
|
const defStr = isString(entry?.default) ? entry.default : null;
|
|
2840
|
-
this.lookup[name] = new LookupInfo(
|
|
2823
|
+
this.lookup[name] = new LookupInfo(defStr === null ? null : parseField(defStr, ctx));
|
|
2841
2824
|
}
|
|
2842
2825
|
for (const key in this.lookup)
|
|
2843
2826
|
if (this.provide[key] !== void 0)
|
|
@@ -5660,10 +5643,10 @@ var ATTR_VAL_CHECKERS = {
|
|
|
5660
5643
|
}
|
|
5661
5644
|
};
|
|
5662
5645
|
function checkConsistentAttrVal(lx, val, env, skipNameVal = false, errCtx = null, isRoot = true) {
|
|
5663
|
-
const
|
|
5664
|
-
if (
|
|
5646
|
+
const check2 = ATTR_VAL_CHECKERS[val?.constructor.name];
|
|
5647
|
+
if (check2 === void 0) return;
|
|
5665
5648
|
const recurse = (sub) => checkConsistentAttrVal(lx, sub, env, skipNameVal, errCtx, false);
|
|
5666
|
-
|
|
5649
|
+
check2({ lx, val, env, errCtx, skipNameVal, recurse, isRoot });
|
|
5667
5650
|
}
|
|
5668
5651
|
var NODE_KIND_TO_CTX = {
|
|
5669
5652
|
RenderTextNode: { originAttr: "<x text>" },
|
|
@@ -6109,34 +6092,16 @@ function dispatchPhase(dispatcher, targetPath, phase, self) {
|
|
|
6109
6092
|
// src/oo.js
|
|
6110
6093
|
var BAD_VALUE2 = /* @__PURE__ */ Symbol("BadValue");
|
|
6111
6094
|
var nullCoercer = (v) => v;
|
|
6112
|
-
function defaultToData(v) {
|
|
6113
|
-
if (v instanceof Map) return [...v.entries()];
|
|
6114
|
-
if (v instanceof Set) return [...v.values()];
|
|
6115
|
-
return v;
|
|
6116
|
-
}
|
|
6117
6095
|
var Field = class {
|
|
6118
6096
|
constructor(type, name, typeCheck, coercer, defaultValue = null) {
|
|
6119
6097
|
this.type = type;
|
|
6120
6098
|
this.name = name;
|
|
6121
6099
|
this.typeCheck = typeCheck;
|
|
6122
6100
|
this.coercer = coercer;
|
|
6123
|
-
this.checks = [];
|
|
6124
6101
|
this.defaultValue = defaultValue;
|
|
6125
6102
|
}
|
|
6126
|
-
toDataDef() {
|
|
6127
|
-
return { type: this.type, defaultValue: defaultToData(this.defaultValue) };
|
|
6128
|
-
}
|
|
6129
|
-
getFirstFailingCheck(v) {
|
|
6130
|
-
if (!this.typeCheck.isValid(v)) return this.typeCheck;
|
|
6131
|
-
for (const check3 of this.checks) if (!check3.isValid(v)) return check3;
|
|
6132
|
-
return null;
|
|
6133
|
-
}
|
|
6134
6103
|
isValid(v) {
|
|
6135
|
-
return this.
|
|
6136
|
-
}
|
|
6137
|
-
addCheck(check3) {
|
|
6138
|
-
this.checks.push(check3);
|
|
6139
|
-
return this;
|
|
6104
|
+
return this.typeCheck(v);
|
|
6140
6105
|
}
|
|
6141
6106
|
coerceOr(v, defaultValue = null) {
|
|
6142
6107
|
if (this.isValid(v)) return v;
|
|
@@ -6147,39 +6112,15 @@ var Field = class {
|
|
|
6147
6112
|
return this.coerceOr(v, this.defaultValue);
|
|
6148
6113
|
}
|
|
6149
6114
|
};
|
|
6150
|
-
var
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
var
|
|
6159
|
-
};
|
|
6160
|
-
var CHECK_TYPE_ANY = new CheckTypeAny();
|
|
6161
|
-
var FnCheck = class extends Check {
|
|
6162
|
-
constructor(isValidFn, getMessageFn) {
|
|
6163
|
-
super();
|
|
6164
|
-
this._isValid = isValidFn;
|
|
6165
|
-
this._getMessage = getMessageFn;
|
|
6166
|
-
}
|
|
6167
|
-
isValid(v) {
|
|
6168
|
-
return this._isValid(v);
|
|
6169
|
-
}
|
|
6170
|
-
getMessage(v) {
|
|
6171
|
-
return this._getMessage(v);
|
|
6172
|
-
}
|
|
6173
|
-
};
|
|
6174
|
-
var check = (fn, message) => new FnCheck(fn, () => message);
|
|
6175
|
-
var CHECK_TYPE_INT = check(Number.isInteger, "Integer expected");
|
|
6176
|
-
var CHECK_TYPE_FLOAT = check(Number.isFinite, "Float expected");
|
|
6177
|
-
var CHECK_TYPE_BOOL = check((v) => typeof v === "boolean", "Boolean expected");
|
|
6178
|
-
var CHECK_TYPE_STRING = check((v) => typeof v === "string", "String expected");
|
|
6179
|
-
var CHECK_TYPE_LIST = check(Array.isArray, "Array expected");
|
|
6180
|
-
var CHECK_TYPE_OBJECT = check(isPlainObject, "Plain object expected");
|
|
6181
|
-
var CHECK_TYPE_MAP = check((v) => v instanceof Map, "Map expected");
|
|
6182
|
-
var CHECK_TYPE_SET = check((v) => v instanceof Set, "Set expected");
|
|
6115
|
+
var CHECK_TYPE_ANY = (_v) => true;
|
|
6116
|
+
var CHECK_TYPE_INT = Number.isInteger;
|
|
6117
|
+
var CHECK_TYPE_FLOAT = Number.isFinite;
|
|
6118
|
+
var CHECK_TYPE_BOOL = (v) => typeof v === "boolean";
|
|
6119
|
+
var CHECK_TYPE_STRING = (v) => typeof v === "string";
|
|
6120
|
+
var CHECK_TYPE_LIST = Array.isArray;
|
|
6121
|
+
var CHECK_TYPE_OBJECT = isPlainObject;
|
|
6122
|
+
var CHECK_TYPE_MAP = (v) => v instanceof Map;
|
|
6123
|
+
var CHECK_TYPE_SET = (v) => v instanceof Set;
|
|
6183
6124
|
var FieldBool = class extends Field {
|
|
6184
6125
|
constructor(name, defaultValue = false) {
|
|
6185
6126
|
super("bool", name, CHECK_TYPE_BOOL, (v) => !!v, defaultValue);
|
|
@@ -6189,9 +6130,6 @@ var FieldAny = class extends Field {
|
|
|
6189
6130
|
constructor(name, defaultValue = null) {
|
|
6190
6131
|
super("any", name, CHECK_TYPE_ANY, nullCoercer, defaultValue);
|
|
6191
6132
|
}
|
|
6192
|
-
toDataDef() {
|
|
6193
|
-
return { type: getTypeName(this.defaultValue) ?? "any", defaultValue: this.defaultValue };
|
|
6194
|
-
}
|
|
6195
6133
|
};
|
|
6196
6134
|
var FieldString = class extends Field {
|
|
6197
6135
|
constructor(name, defaultValue = "") {
|
|
@@ -6214,26 +6152,13 @@ var FieldFloat = class extends Field {
|
|
|
6214
6152
|
super("float", name, CHECK_TYPE_FLOAT, (_) => null, defaultValue);
|
|
6215
6153
|
}
|
|
6216
6154
|
};
|
|
6217
|
-
var
|
|
6218
|
-
var
|
|
6219
|
-
constructor(typeName) {
|
|
6220
|
-
this.typeName = typeName;
|
|
6221
|
-
}
|
|
6222
|
-
isValid(v) {
|
|
6223
|
-
return getTypeName(v) === this.typeName;
|
|
6224
|
-
}
|
|
6225
|
-
getMessage(v) {
|
|
6226
|
-
return `Expected "${this.typeName}", got "${getTypeName(v)}"`;
|
|
6227
|
-
}
|
|
6228
|
-
};
|
|
6155
|
+
var metaOf = (v) => v?.constructor?.[COMPONENT] ?? v?.constructor?.getMetaClass?.();
|
|
6156
|
+
var getTypeName = (v) => metaOf(v)?.name ?? null;
|
|
6229
6157
|
var FieldComp = class extends Field {
|
|
6230
6158
|
constructor(type, name, args) {
|
|
6231
|
-
super(type, name,
|
|
6159
|
+
super(type, name, (v) => getTypeName(v) === type, nullCoercer, null);
|
|
6232
6160
|
this.args = args;
|
|
6233
6161
|
}
|
|
6234
|
-
toDataDef() {
|
|
6235
|
-
return { component: this.type, args: this.args };
|
|
6236
|
-
}
|
|
6237
6162
|
};
|
|
6238
6163
|
var FieldList = class extends Field {
|
|
6239
6164
|
constructor(name, defaultValue = []) {
|
|
@@ -6395,7 +6320,7 @@ function classFromData(name, { fields = {}, methods, statics }) {
|
|
|
6395
6320
|
return b.build();
|
|
6396
6321
|
}
|
|
6397
6322
|
function validateDraftFields(current, draft) {
|
|
6398
|
-
const meta = current
|
|
6323
|
+
const meta = metaOf(current);
|
|
6399
6324
|
if (!meta) return;
|
|
6400
6325
|
for (const [name, field] of Object.entries(meta.fields)) {
|
|
6401
6326
|
const value = draft[name];
|
|
@@ -6454,7 +6379,7 @@ var component = (opts) => Component.fromSpec(opts);
|
|
|
6454
6379
|
// src/stack.js
|
|
6455
6380
|
var STOP = /* @__PURE__ */ Symbol("STOP");
|
|
6456
6381
|
var NEXT = /* @__PURE__ */ Symbol("NEXT");
|
|
6457
|
-
var
|
|
6382
|
+
var DEFAULT_ROUTE = ["dyn", "lex"];
|
|
6458
6383
|
function routeLookup(route, lex, dyn) {
|
|
6459
6384
|
for (let i = 0; i < route.length; i++) {
|
|
6460
6385
|
const leg = route[i];
|
|
@@ -6576,20 +6501,6 @@ var Stack = class _Stack {
|
|
|
6576
6501
|
lookupBind(name) {
|
|
6577
6502
|
return lookup(this.binds, name);
|
|
6578
6503
|
}
|
|
6579
|
-
// The `lex` leg: what a name means in the registration scope of the component being
|
|
6580
|
-
// rendered. The scope chain holds components, so this leg only ever answers for a
|
|
6581
|
-
// type name — for a value name it is a miss, which is why one default route serves
|
|
6582
|
-
// both. Guarded: a non-component `it` has no scope to ask.
|
|
6583
|
-
_lookupLex(name) {
|
|
6584
|
-
return this.comps.getCompFor(this.it)?.scope.lookupComponent(name) ?? null;
|
|
6585
|
-
}
|
|
6586
|
-
lookupRouted(name, route = DEFAULT_LOOKUP_ROUTE) {
|
|
6587
|
-
return routeLookup(
|
|
6588
|
-
route,
|
|
6589
|
-
() => this._lookupLex(name),
|
|
6590
|
-
() => this.lookupDynamic(name)
|
|
6591
|
-
);
|
|
6592
|
-
}
|
|
6593
6504
|
lookupFieldRaw(name) {
|
|
6594
6505
|
return this.it[name] ?? null;
|
|
6595
6506
|
}
|
|
@@ -6690,28 +6601,46 @@ var Transactor = class {
|
|
|
6690
6601
|
if (i !== -1) this._refusalObservers.splice(i, 1);
|
|
6691
6602
|
};
|
|
6692
6603
|
}
|
|
6693
|
-
// Build and dispatch
|
|
6694
|
-
//
|
|
6695
|
-
//
|
|
6696
|
-
//
|
|
6604
|
+
// Build and dispatch one observer record. Pins field-resolved keys (e.g. a
|
|
6605
|
+
// `.a[.selId]` render target reconstructed from a DOM event) against the root the
|
|
6606
|
+
// handler read, so pathKeys carries concrete keys instead of dropping the dynamic
|
|
6607
|
+
// step. No-op when nobody is observing.
|
|
6608
|
+
_emitRecord(root, { kind, name, args, path, targetPath, handler, handlerName, matched, before, after, parent }) {
|
|
6609
|
+
if (this._observers.length === 0) return;
|
|
6610
|
+
const pinned = path.pinKeys(root);
|
|
6611
|
+
this._emit({
|
|
6612
|
+
kind,
|
|
6613
|
+
name,
|
|
6614
|
+
args: args ?? null,
|
|
6615
|
+
path: pinned,
|
|
6616
|
+
pathKeys: pinned.toKeys(),
|
|
6617
|
+
targetPath,
|
|
6618
|
+
handler: handler ?? null,
|
|
6619
|
+
handlerName: handlerName ?? (handler?.name || null),
|
|
6620
|
+
matched: matched ?? null,
|
|
6621
|
+
before,
|
|
6622
|
+
after,
|
|
6623
|
+
parent,
|
|
6624
|
+
timestamp: Date.now()
|
|
6625
|
+
});
|
|
6626
|
+
}
|
|
6627
|
+
// The observer record for a settled transaction. The resolved handler
|
|
6628
|
+
// (`_resolvedHandler`/`_matched`) and per-leaf before/after (`_before`/`_after`)
|
|
6629
|
+
// were captured while the handler ran (see callHandler / Transaction.run).
|
|
6697
6630
|
_emitTransaction(transaction, root) {
|
|
6698
6631
|
if (this._observers.length === 0) return;
|
|
6699
6632
|
if (transaction._resolvedHandler === void 0) return;
|
|
6700
|
-
|
|
6701
|
-
this._emit({
|
|
6633
|
+
this._emitRecord(root, {
|
|
6702
6634
|
kind: transaction.observeKind,
|
|
6703
6635
|
name: transaction.observeName,
|
|
6704
|
-
args: transaction.args
|
|
6705
|
-
path,
|
|
6706
|
-
pathKeys: path.toKeys(),
|
|
6636
|
+
args: transaction.args,
|
|
6637
|
+
path: transaction.getTransactionPath(),
|
|
6707
6638
|
targetPath: transaction.targetPath ?? transaction.path,
|
|
6708
|
-
handler: transaction._resolvedHandler
|
|
6709
|
-
|
|
6710
|
-
matched: transaction._matched ?? null,
|
|
6639
|
+
handler: transaction._resolvedHandler,
|
|
6640
|
+
matched: transaction._matched,
|
|
6711
6641
|
before: transaction._before,
|
|
6712
6642
|
after: transaction._after,
|
|
6713
|
-
parent: transaction.parentTransaction
|
|
6714
|
-
timestamp: Date.now()
|
|
6643
|
+
parent: transaction.parentTransaction
|
|
6715
6644
|
});
|
|
6716
6645
|
}
|
|
6717
6646
|
// Make `child` a tracked unit of `parent`'s subtree: the parent's completion stays open
|
|
@@ -6809,7 +6738,7 @@ var Transaction = class {
|
|
|
6809
6738
|
// rather than throwing, so a stray call from the wrong place is a message and not a
|
|
6810
6739
|
// crash. `walk` is undefined here, which is how ctx.reply/ctx.fail tell the two apart.
|
|
6811
6740
|
stop() {
|
|
6812
|
-
|
|
6741
|
+
warnNotIntent("stop");
|
|
6813
6742
|
}
|
|
6814
6743
|
forward(_opts) {
|
|
6815
6744
|
console.warn('ctx.forward() needs a "receive" or "intent" handler - ignored');
|
|
@@ -6894,11 +6823,8 @@ var InputEvent = class extends Transaction {
|
|
|
6894
6823
|
}
|
|
6895
6824
|
this.transactor.pushIntent(this.dispatchPath, name, args, rest, this);
|
|
6896
6825
|
}
|
|
6897
|
-
buildStack(root, comps) {
|
|
6898
|
-
return this.path.toTransactionPath().buildStack(Stack.root(comps, root, this));
|
|
6899
|
-
}
|
|
6900
6826
|
getHandlerAndArgs(root, _instance, comps) {
|
|
6901
|
-
const stack = this.buildStack(root,
|
|
6827
|
+
const stack = this.path.toTransactionPath().buildStack(Stack.root(comps, root, this));
|
|
6902
6828
|
const [handler, args] = this.handler.getHandlerAndArgs(stack, this);
|
|
6903
6829
|
this._handlerArgs = [...args];
|
|
6904
6830
|
const path = this.dispatchPath;
|
|
@@ -7000,7 +6926,6 @@ var IntentEvent = class extends NameArgsTransaction {
|
|
|
7000
6926
|
};
|
|
7001
6927
|
var PASS = /* @__PURE__ */ Symbol.for("tutuca.intent.pass");
|
|
7002
6928
|
var REFUSAL_RING_CAP = 200;
|
|
7003
|
-
var DEFAULT_ROUTE = ["dyn", "lex"];
|
|
7004
6929
|
var INTENT_DEPTH = 64;
|
|
7005
6930
|
var IntentWalk = class {
|
|
7006
6931
|
constructor(transactor, path, name, args, opts, parent, release) {
|
|
@@ -7049,24 +6974,19 @@ var IntentWalk = class {
|
|
|
7049
6974
|
const txnPath = this.origin.toTransactionPath();
|
|
7050
6975
|
const leaf = txnPath.lookup(root);
|
|
7051
6976
|
const chain = this.transactor.comps.getIntentChainFor(leaf, this.name);
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
this.
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
after: void 0,
|
|
7066
|
-
parent: this.parent,
|
|
7067
|
-
timestamp: Date.now()
|
|
7068
|
-
});
|
|
7069
|
-
}
|
|
6977
|
+
this.transactor._emitRecord(root, {
|
|
6978
|
+
kind: "intent",
|
|
6979
|
+
name: this.name,
|
|
6980
|
+
args: this.args,
|
|
6981
|
+
path: txnPath,
|
|
6982
|
+
targetPath: this.origin,
|
|
6983
|
+
handler: chain[0],
|
|
6984
|
+
handlerName: chain[0]?.name || this.name,
|
|
6985
|
+
matched: chain.length > 0 ? "exact" : "none",
|
|
6986
|
+
before: leaf,
|
|
6987
|
+
after: void 0,
|
|
6988
|
+
parent: this.parent
|
|
6989
|
+
});
|
|
7070
6990
|
if (chain.length === 0) return this.advance();
|
|
7071
6991
|
const p = this._runLex(chain, 0);
|
|
7072
6992
|
this.transactor._inflight.add(p);
|
|
@@ -7077,7 +6997,7 @@ var IntentWalk = class {
|
|
|
7077
6997
|
if (i >= chain.length) return this.advance();
|
|
7078
6998
|
const ctx = new Dispatcher(this.origin, this.transactor, this.parent);
|
|
7079
6999
|
try {
|
|
7080
|
-
const res = await chain[i].
|
|
7000
|
+
const res = await chain[i].apply(null, [...this.args, ctx]);
|
|
7081
7001
|
if (res === PASS) return this._runLex(chain, i + 1);
|
|
7082
7002
|
this.answer("Ok", res);
|
|
7083
7003
|
} catch (error) {
|
|
@@ -7230,9 +7150,8 @@ var Dispatcher = class {
|
|
|
7230
7150
|
// the same spelling as `ctx.intent` — `["dyn"]` the render ancestry, `["lex"]` the
|
|
7231
7151
|
// registration scope, default both.
|
|
7232
7152
|
lookup(name, opts) {
|
|
7233
|
-
const route = opts?.route ?? DEFAULT_LOOKUP_ROUTE;
|
|
7234
7153
|
return routeLookup(
|
|
7235
|
-
route,
|
|
7154
|
+
opts?.route ?? DEFAULT_ROUTE,
|
|
7236
7155
|
() => this._lookupLex(name),
|
|
7237
7156
|
() => this._stack()?.lookupDynamic(name) ?? null
|
|
7238
7157
|
);
|
|
@@ -7251,12 +7170,10 @@ var Dispatcher = class {
|
|
|
7251
7170
|
// can only ever answer with one; the `dyn` leg reads a binding an ancestor
|
|
7252
7171
|
// published, so it is the leg that has to be checked.
|
|
7253
7172
|
lookupType(name, opts) {
|
|
7254
|
-
const
|
|
7173
|
+
const route = opts?.route ?? DEFAULT_ROUTE;
|
|
7174
|
+
const v = this.lookup(name, { route });
|
|
7255
7175
|
if (v == null) {
|
|
7256
|
-
this.transactor.refuse("TYPE_NOT_FOUND", {
|
|
7257
|
-
name,
|
|
7258
|
-
route: opts?.route ?? DEFAULT_LOOKUP_ROUTE
|
|
7259
|
-
});
|
|
7176
|
+
this.transactor.refuse("TYPE_NOT_FOUND", { name, route });
|
|
7260
7177
|
return null;
|
|
7261
7178
|
}
|
|
7262
7179
|
if (v?.[COMPONENT] == null) {
|
|
@@ -8058,7 +7975,14 @@ var App = class {
|
|
|
8058
7975
|
const { type } = e;
|
|
8059
7976
|
const isDrag = type === "dragover" || type === "dragstart" || type === "dragend" || type === "drop";
|
|
8060
7977
|
const { rootNode: root, maxEventNodeDepth: maxDepth, comps, transactor } = this;
|
|
8061
|
-
const [path, handlers] = Path.
|
|
7978
|
+
const [path, handlers] = Path.fromNodeAndEventName(
|
|
7979
|
+
e.target,
|
|
7980
|
+
type,
|
|
7981
|
+
root,
|
|
7982
|
+
maxDepth,
|
|
7983
|
+
comps,
|
|
7984
|
+
!isDrag
|
|
7985
|
+
);
|
|
8062
7986
|
if (isDrag) this._handleDragEvent(e, type, path);
|
|
8063
7987
|
if (path !== null && handlers !== null)
|
|
8064
7988
|
for (const handler of handlers) transactor.transactInputNow(path, e, handler, this.dragInfo);
|
|
@@ -8120,7 +8044,7 @@ var App = class {
|
|
|
8120
8044
|
const value = txnPath.lookup(rootValue);
|
|
8121
8045
|
const dragType = e.target.dataset.dragtype ?? "?";
|
|
8122
8046
|
const stack = path.toTransactionPath().buildStack(this.makeStack(rootValue));
|
|
8123
|
-
this.dragInfo = new DragInfo(
|
|
8047
|
+
this.dragInfo = new DragInfo(stack, value, dragType, e.target);
|
|
8124
8048
|
} else if (type === "drop") {
|
|
8125
8049
|
e.preventDefault();
|
|
8126
8050
|
this._cleanDragOverAttrs();
|
|
@@ -8257,10 +8181,8 @@ function getClosestDropTarget(target, rootNode, count) {
|
|
|
8257
8181
|
return null;
|
|
8258
8182
|
}
|
|
8259
8183
|
var DragInfo = class {
|
|
8260
|
-
constructor(
|
|
8261
|
-
this.path = path;
|
|
8184
|
+
constructor(stack, val, type, node) {
|
|
8262
8185
|
this.stack = stack;
|
|
8263
|
-
this.e = e;
|
|
8264
8186
|
this.val = val;
|
|
8265
8187
|
this.type = type;
|
|
8266
8188
|
this.node = node;
|
|
@@ -8352,6 +8274,8 @@ var Renderer = class {
|
|
|
8352
8274
|
setNullCache() {
|
|
8353
8275
|
this.cache = new NullDomCache();
|
|
8354
8276
|
}
|
|
8277
|
+
// Library utilities for consumers embedding tutuca: render a value to a detached
|
|
8278
|
+
// DOM node / an HTML string. Not called by the framework itself.
|
|
8355
8279
|
renderToDOM(stack, val) {
|
|
8356
8280
|
const rootNode = document.createElement("div");
|
|
8357
8281
|
const rOpts = { document };
|
|
@@ -8569,7 +8493,7 @@ function shadowCheckComponent(Comp) {
|
|
|
8569
8493
|
});
|
|
8570
8494
|
return checkComponent(shadowComp).reports;
|
|
8571
8495
|
}
|
|
8572
|
-
function
|
|
8496
|
+
function check(app) {
|
|
8573
8497
|
const counts = { error: 0, warn: 0, hint: 0 };
|
|
8574
8498
|
for (const Comp of app.comps.byId.values()) {
|
|
8575
8499
|
const reports = shadowCheckComponent(Comp);
|
|
@@ -8694,7 +8618,7 @@ export {
|
|
|
8694
8618
|
UNKNOWN_X_OP,
|
|
8695
8619
|
UNSUPPORTED_EXPR_SYNTAX,
|
|
8696
8620
|
X_OP_IGNORES_CHILDREN,
|
|
8697
|
-
|
|
8621
|
+
check,
|
|
8698
8622
|
checkComponent,
|
|
8699
8623
|
collectIterBindings,
|
|
8700
8624
|
compileClassesToStyle,
|