tutuca 0.9.10 → 0.9.12
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-dev.js +219 -248
- package/dist/tutuca-dev.min.js +3 -3
- package/dist/tutuca-extra.js +177 -224
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.js +169 -216
- package/dist/tutuca.min.js +3 -3
- package/package.json +1 -1
package/dist/tutuca-dev.js
CHANGED
|
@@ -280,9 +280,6 @@ class ValParser {
|
|
|
280
280
|
this.okStrTpl = false;
|
|
281
281
|
this.okSeqAccess = false;
|
|
282
282
|
}
|
|
283
|
-
parseIfOk(s, px, isOk, parseFn) {
|
|
284
|
-
return isOk ? parseFn(s, px) : null;
|
|
285
|
-
}
|
|
286
283
|
_parseSeqAccess(s, px) {
|
|
287
284
|
if (!this.okSeqAccess) {
|
|
288
285
|
return null;
|
|
@@ -296,13 +293,13 @@ class ValParser {
|
|
|
296
293
|
parse(s, px) {
|
|
297
294
|
switch (getValSubType(s)) {
|
|
298
295
|
case VAL_SUB_TYPE_STRING_TEMPLATE:
|
|
299
|
-
return this.
|
|
296
|
+
return this.okStrTpl ? parseStrTemplate(s, px) : null;
|
|
300
297
|
case VAL_SUB_TYPE_CONST_STRING:
|
|
301
|
-
return this.
|
|
298
|
+
return this.okStrTpl ? parseConst(s, px) : null;
|
|
302
299
|
case VAL_SUB_TYPE_SEQ_ACCESS:
|
|
303
300
|
return this._parseSeqAccess(s, px);
|
|
304
301
|
case VAL_SUB_TYPE_INVALID:
|
|
305
|
-
return this.
|
|
302
|
+
return this.okStrTpl ? parseStrTemplate(s, px) : null;
|
|
306
303
|
}
|
|
307
304
|
const charCode = s.charCodeAt(0);
|
|
308
305
|
switch (charCode) {
|
|
@@ -314,29 +311,29 @@ class ValParser {
|
|
|
314
311
|
return null;
|
|
315
312
|
}
|
|
316
313
|
case 126:
|
|
317
|
-
return this.
|
|
314
|
+
return this.okStrTpl ? parseConst(s.slice(1), px) : null;
|
|
318
315
|
case 39:
|
|
319
|
-
return this.
|
|
316
|
+
return this.okStrTpl ? parseConst(s.slice(1, -1), px) : null;
|
|
320
317
|
case 64:
|
|
321
|
-
return this.
|
|
318
|
+
return this.okBind ? parseBind(s.slice(1), px) : null;
|
|
322
319
|
case 42:
|
|
323
|
-
return this.
|
|
320
|
+
return this.okDyn ? parseDyn(s.slice(1), px) : null;
|
|
324
321
|
case 46:
|
|
325
|
-
return this.
|
|
322
|
+
return this.okField ? parseField(s.slice(1), px) : null;
|
|
326
323
|
case 36:
|
|
327
|
-
return this.
|
|
324
|
+
return this.okComputed ? parseComp(s.slice(1), px) : null;
|
|
328
325
|
case 33:
|
|
329
|
-
return this.
|
|
326
|
+
return this.okRequest ? parseReq(s.slice(1), px) : null;
|
|
330
327
|
}
|
|
331
328
|
const num = VALID_FLOAT_RE.test(s) ? parseFloat(s) : null;
|
|
332
329
|
if (Number.isFinite(num)) {
|
|
333
|
-
return this.
|
|
330
|
+
return this.okConst ? parseConst(num, px) : null;
|
|
334
331
|
} else if (s === "true" || s === "false") {
|
|
335
|
-
return this.
|
|
332
|
+
return this.okConst ? parseConst(s === "true", px) : null;
|
|
336
333
|
} else if (charCode >= 97 && charCode <= 122) {
|
|
337
|
-
return this.
|
|
334
|
+
return this.okName ? parseName(s, px) : null;
|
|
338
335
|
} else if (charCode >= 65 && charCode <= 90) {
|
|
339
|
-
return this.
|
|
336
|
+
return this.okType ? parseType(s, px) : null;
|
|
340
337
|
}
|
|
341
338
|
return null;
|
|
342
339
|
}
|
|
@@ -419,18 +416,18 @@ class BaseVal {
|
|
|
419
416
|
}
|
|
420
417
|
|
|
421
418
|
class ConstVal extends BaseVal {
|
|
422
|
-
constructor(
|
|
419
|
+
constructor(val) {
|
|
423
420
|
super();
|
|
424
|
-
this.
|
|
421
|
+
this.val = val;
|
|
425
422
|
}
|
|
426
423
|
render(_stack, _rx) {
|
|
427
|
-
return this.
|
|
424
|
+
return this.val;
|
|
428
425
|
}
|
|
429
426
|
eval(_stack) {
|
|
430
|
-
return this.
|
|
427
|
+
return this.val;
|
|
431
428
|
}
|
|
432
429
|
toString() {
|
|
433
|
-
const v = this.
|
|
430
|
+
const v = this.val;
|
|
434
431
|
return typeof v === "string" ? `'${v}'` : `${v}`;
|
|
435
432
|
}
|
|
436
433
|
}
|
|
@@ -464,7 +461,7 @@ class StrTplVal extends VarVal {
|
|
|
464
461
|
vals[i] = val;
|
|
465
462
|
allConsts &&= val instanceof ConstVal;
|
|
466
463
|
}
|
|
467
|
-
return allConsts ? new ConstVal(vals.map((v) => v.
|
|
464
|
+
return allConsts ? new ConstVal(vals.map((v) => v.val).join("")) : new StrTplVal(vals);
|
|
468
465
|
}
|
|
469
466
|
}
|
|
470
467
|
|
|
@@ -483,13 +480,13 @@ class NameVal extends VarVal {
|
|
|
483
480
|
|
|
484
481
|
class InputHandlerNameVal extends NameVal {
|
|
485
482
|
eval(stack) {
|
|
486
|
-
return stack.
|
|
483
|
+
return stack.getHandlerFor(this.name, "input") ?? mk404Handler("input", this.name);
|
|
487
484
|
}
|
|
488
485
|
}
|
|
489
486
|
|
|
490
487
|
class AlterHandlerNameVal extends NameVal {
|
|
491
488
|
eval(stack) {
|
|
492
|
-
return stack.
|
|
489
|
+
return stack.getHandlerFor(this.name, "alter") ?? mk404Handler("alter", this.name);
|
|
493
490
|
}
|
|
494
491
|
}
|
|
495
492
|
var mk404Handler = (type, name) => function(...args) {
|
|
@@ -798,7 +795,7 @@ class ConstAttrs extends Attributes {
|
|
|
798
795
|
static fromAttrs(attrs) {
|
|
799
796
|
const attrsObj = {};
|
|
800
797
|
for (const attr of attrs) {
|
|
801
|
-
attrsObj[attr.name] = attr.
|
|
798
|
+
attrsObj[attr.name] = attr.val.eval(null);
|
|
802
799
|
}
|
|
803
800
|
return new ConstAttrs(attrsObj);
|
|
804
801
|
}
|
|
@@ -831,7 +828,7 @@ class DynAttrs extends Attributes {
|
|
|
831
828
|
toMacroVars() {
|
|
832
829
|
const r = {};
|
|
833
830
|
for (const attr of this.items) {
|
|
834
|
-
r[attr.name] = attr.
|
|
831
|
+
r[attr.name] = attr.val.toString();
|
|
835
832
|
}
|
|
836
833
|
return r;
|
|
837
834
|
}
|
|
@@ -844,23 +841,23 @@ class BaseAttr {
|
|
|
844
841
|
}
|
|
845
842
|
|
|
846
843
|
class Attr extends BaseAttr {
|
|
847
|
-
constructor(name,
|
|
844
|
+
constructor(name, val) {
|
|
848
845
|
super(name);
|
|
849
|
-
this.
|
|
846
|
+
this.val = val;
|
|
850
847
|
}
|
|
851
848
|
eval(stack) {
|
|
852
|
-
return this.
|
|
849
|
+
return this.val.eval(stack);
|
|
853
850
|
}
|
|
854
851
|
}
|
|
855
852
|
|
|
856
853
|
class ConstAttr extends Attr {
|
|
857
854
|
}
|
|
858
855
|
class RawHtmlAttr extends Attr {
|
|
859
|
-
constructor(
|
|
860
|
-
super("dangerouslySetInnerHTML",
|
|
856
|
+
constructor(val) {
|
|
857
|
+
super("dangerouslySetInnerHTML", val ?? vp.nullConstVal);
|
|
861
858
|
}
|
|
862
859
|
eval(stack) {
|
|
863
|
-
return { __html: `${this.
|
|
860
|
+
return { __html: `${this.val.eval(stack)}` };
|
|
864
861
|
}
|
|
865
862
|
}
|
|
866
863
|
var NOT_SET_VAL = vp.nullConstVal;
|
|
@@ -940,16 +937,16 @@ class BaseNode {
|
|
|
940
937
|
}
|
|
941
938
|
|
|
942
939
|
class TextNode extends BaseNode {
|
|
943
|
-
constructor(
|
|
940
|
+
constructor(val) {
|
|
944
941
|
super();
|
|
945
|
-
this.
|
|
942
|
+
this.val = val;
|
|
946
943
|
}
|
|
947
944
|
render(_stack, rx) {
|
|
948
|
-
return rx.renderText(this.
|
|
945
|
+
return rx.renderText(this.val);
|
|
949
946
|
}
|
|
950
947
|
isWhiteSpace() {
|
|
951
|
-
for (let i = 0;i < this.
|
|
952
|
-
const c = this.
|
|
948
|
+
for (let i = 0;i < this.val.length; i++) {
|
|
949
|
+
const c = this.val.charCodeAt(i);
|
|
953
950
|
if (!(c === 32 || c === 10 || c === 9 || c === 13)) {
|
|
954
951
|
return false;
|
|
955
952
|
}
|
|
@@ -957,8 +954,8 @@ class TextNode extends BaseNode {
|
|
|
957
954
|
return true;
|
|
958
955
|
}
|
|
959
956
|
hasNewLine() {
|
|
960
|
-
for (let i = 0;i < this.
|
|
961
|
-
const c = this.
|
|
957
|
+
for (let i = 0;i < this.val.length; i++) {
|
|
958
|
+
const c = this.val.charCodeAt(i);
|
|
962
959
|
if (c === 10 || c === 13) {
|
|
963
960
|
return true;
|
|
964
961
|
}
|
|
@@ -966,7 +963,7 @@ class TextNode extends BaseNode {
|
|
|
966
963
|
return false;
|
|
967
964
|
}
|
|
968
965
|
condenseWhiteSpace() {
|
|
969
|
-
this.
|
|
966
|
+
this.val = "";
|
|
970
967
|
}
|
|
971
968
|
isConstant() {
|
|
972
969
|
return true;
|
|
@@ -976,7 +973,7 @@ class TextNode extends BaseNode {
|
|
|
976
973
|
|
|
977
974
|
class CommentNode extends TextNode {
|
|
978
975
|
render(_stack, rx) {
|
|
979
|
-
return rx.renderComment(this.
|
|
976
|
+
return rx.renderComment(this.val);
|
|
980
977
|
}
|
|
981
978
|
}
|
|
982
979
|
function optimizeChilds(childs) {
|
|
@@ -1400,7 +1397,7 @@ class ParseContext {
|
|
|
1400
1397
|
const slots = { _: new FragmentNode(anySlot) };
|
|
1401
1398
|
for (const child of childs) {
|
|
1402
1399
|
if (child instanceof SlotNode) {
|
|
1403
|
-
slots[child.val.
|
|
1400
|
+
slots[child.val.val] = child.node;
|
|
1404
1401
|
} else if (!(child instanceof TextNode) || !child.isWhiteSpace()) {
|
|
1405
1402
|
anySlot.push(child);
|
|
1406
1403
|
}
|
|
@@ -1664,18 +1661,15 @@ class Components {
|
|
|
1664
1661
|
const comp = this.getCompFor(v);
|
|
1665
1662
|
return comp ? comp.on.stackEnter : defaultOnStackEnter;
|
|
1666
1663
|
}
|
|
1667
|
-
|
|
1668
|
-
return this.getCompFor(v)?.
|
|
1669
|
-
}
|
|
1670
|
-
getAlterHandlerFor(v, name) {
|
|
1671
|
-
return this.getCompFor(v)?.alter[name] ?? null;
|
|
1664
|
+
getHandlerFor(v, name, key) {
|
|
1665
|
+
return this.getCompFor(v)?.[key][name] ?? null;
|
|
1672
1666
|
}
|
|
1673
1667
|
getRequestFor(v, name) {
|
|
1674
1668
|
const comp = this.getCompFor(v);
|
|
1675
1669
|
return comp ? comp.scope.lookupRequest(name) : null;
|
|
1676
1670
|
}
|
|
1677
1671
|
lookupComputed(v, name) {
|
|
1678
|
-
const fn = this.
|
|
1672
|
+
const fn = this.getHandlerFor(v, name, "computed");
|
|
1679
1673
|
return fn ? this.computedCache.getKey(v, name, fn) : null;
|
|
1680
1674
|
}
|
|
1681
1675
|
compileStyles() {
|
|
@@ -1954,11 +1948,8 @@ class Stack {
|
|
|
1954
1948
|
const node = this.binds.head.isFrame ? this.binds.head : this.binds.tail.head;
|
|
1955
1949
|
return this.comps.lookupComputed(node.it, name);
|
|
1956
1950
|
}
|
|
1957
|
-
|
|
1958
|
-
return this.comps.
|
|
1959
|
-
}
|
|
1960
|
-
getAlterHandler(name) {
|
|
1961
|
-
return this.comps.getAlterHandlerFor(this.it, name);
|
|
1951
|
+
getHandlerFor(name, key) {
|
|
1952
|
+
return this.comps.getHandlerFor(this.it, name, key);
|
|
1962
1953
|
}
|
|
1963
1954
|
lookupRequest(name) {
|
|
1964
1955
|
return this.comps.getRequestFor(this.it, name);
|
|
@@ -1976,22 +1967,22 @@ class Stack {
|
|
|
1976
1967
|
|
|
1977
1968
|
// src/transactor.js
|
|
1978
1969
|
class State {
|
|
1979
|
-
constructor(
|
|
1980
|
-
this.
|
|
1970
|
+
constructor(val) {
|
|
1971
|
+
this.val = val;
|
|
1981
1972
|
this.changeSubs = [];
|
|
1982
1973
|
}
|
|
1983
1974
|
onChange(cb) {
|
|
1984
1975
|
this.changeSubs.push(cb);
|
|
1985
1976
|
}
|
|
1986
|
-
set(
|
|
1987
|
-
const old = this.
|
|
1988
|
-
this.
|
|
1977
|
+
set(val, info) {
|
|
1978
|
+
const old = this.val;
|
|
1979
|
+
this.val = val;
|
|
1989
1980
|
for (const sub of this.changeSubs) {
|
|
1990
|
-
sub({
|
|
1981
|
+
sub({ val, old, info, timestamp: Date.now() });
|
|
1991
1982
|
}
|
|
1992
1983
|
}
|
|
1993
1984
|
update(fn, info) {
|
|
1994
|
-
return this.set(fn(this.
|
|
1985
|
+
return this.set(fn(this.val), info);
|
|
1995
1986
|
}
|
|
1996
1987
|
}
|
|
1997
1988
|
|
|
@@ -2015,7 +2006,7 @@ class Transactor {
|
|
|
2015
2006
|
return this.pushTransaction(new BubbleEvent(path, this, name, args, parent, newOpts));
|
|
2016
2007
|
}
|
|
2017
2008
|
async pushRequest(path, name, args = [], opts = {}, parent = null) {
|
|
2018
|
-
const curRoot = this.state.
|
|
2009
|
+
const curRoot = this.state.val;
|
|
2019
2010
|
const curLeaf = path.lookup(curRoot);
|
|
2020
2011
|
const handler = this.comps.getRequestFor(curLeaf, name) ?? mkReq404(name);
|
|
2021
2012
|
const resHandlerName = opts?.onResName ?? name;
|
|
@@ -2045,7 +2036,7 @@ class Transactor {
|
|
|
2045
2036
|
}
|
|
2046
2037
|
}
|
|
2047
2038
|
transact(transaction) {
|
|
2048
|
-
const curState = this.state.
|
|
2039
|
+
const curState = this.state.val;
|
|
2049
2040
|
const newState = transaction.run(curState, this.comps);
|
|
2050
2041
|
if (newState !== undefined) {
|
|
2051
2042
|
this.state.set(newState, { transaction });
|
|
@@ -2068,10 +2059,10 @@ function nullHandler() {
|
|
|
2068
2059
|
}
|
|
2069
2060
|
|
|
2070
2061
|
class Transaction {
|
|
2071
|
-
constructor(path, transactor) {
|
|
2062
|
+
constructor(path, transactor, parentTransaction = null) {
|
|
2072
2063
|
this.path = path;
|
|
2073
2064
|
this.transactor = transactor;
|
|
2074
|
-
this.parentTransaction =
|
|
2065
|
+
this.parentTransaction = parentTransaction;
|
|
2075
2066
|
this._task = null;
|
|
2076
2067
|
}
|
|
2077
2068
|
get task() {
|
|
@@ -2229,7 +2220,7 @@ class Task {
|
|
|
2229
2220
|
constructor(info) {
|
|
2230
2221
|
this.info = info;
|
|
2231
2222
|
this.deps = [];
|
|
2232
|
-
this.
|
|
2223
|
+
this.val = this.resolve = this.reject = null;
|
|
2233
2224
|
this.promise = new Promise((res, rej) => {
|
|
2234
2225
|
this.resolve = res;
|
|
2235
2226
|
this.reject = rej;
|
|
@@ -2241,8 +2232,8 @@ class Task {
|
|
|
2241
2232
|
this.deps.push(task);
|
|
2242
2233
|
task.promise.then((_) => this._check());
|
|
2243
2234
|
}
|
|
2244
|
-
complete(
|
|
2245
|
-
this.
|
|
2235
|
+
complete(val) {
|
|
2236
|
+
this.val = val;
|
|
2246
2237
|
this._check();
|
|
2247
2238
|
}
|
|
2248
2239
|
_check() {
|
|
@@ -2345,7 +2336,7 @@ class App {
|
|
|
2345
2336
|
}
|
|
2346
2337
|
} else if (isDragStart) {
|
|
2347
2338
|
e.target.dataset.dragging = 1;
|
|
2348
|
-
const rootValue = this.state.
|
|
2339
|
+
const rootValue = this.state.val;
|
|
2349
2340
|
const value = path.lookup(rootValue);
|
|
2350
2341
|
const type = e.target.dataset.dragtype ?? "?";
|
|
2351
2342
|
const stack = path.buildStack(this.makeStack(rootValue));
|
|
@@ -2371,7 +2362,7 @@ class App {
|
|
|
2371
2362
|
}
|
|
2372
2363
|
}
|
|
2373
2364
|
render() {
|
|
2374
|
-
const root = this.state.
|
|
2365
|
+
const root = this.state.val;
|
|
2375
2366
|
const stack = this.makeStack(root);
|
|
2376
2367
|
return this.renderFn(this.renderer.renderRoot(stack, root), this.rootNode);
|
|
2377
2368
|
}
|
|
@@ -2397,7 +2388,7 @@ class App {
|
|
|
2397
2388
|
this.rootNode.addEventListener(name, this);
|
|
2398
2389
|
}
|
|
2399
2390
|
this.onChange((info) => {
|
|
2400
|
-
if (info.
|
|
2391
|
+
if (info.val !== info.old) {
|
|
2401
2392
|
this.render();
|
|
2402
2393
|
}
|
|
2403
2394
|
});
|
|
@@ -2468,11 +2459,11 @@ function getClosestDropTarget(target, rootNode, count) {
|
|
|
2468
2459
|
}
|
|
2469
2460
|
|
|
2470
2461
|
class DragInfo {
|
|
2471
|
-
constructor(path, stack, e,
|
|
2462
|
+
constructor(path, stack, e, val, type, node) {
|
|
2472
2463
|
this.path = path;
|
|
2473
2464
|
this.stack = stack;
|
|
2474
2465
|
this.e = e;
|
|
2475
|
-
this.
|
|
2466
|
+
this.val = val;
|
|
2476
2467
|
this.type = type;
|
|
2477
2468
|
this.node = node;
|
|
2478
2469
|
}
|
|
@@ -2505,12 +2496,12 @@ class ParseCtxClassSetCollector extends ParseContext {
|
|
|
2505
2496
|
if (attr.name !== "class") {
|
|
2506
2497
|
continue;
|
|
2507
2498
|
}
|
|
2508
|
-
const {
|
|
2499
|
+
const { val, thenVal, elseVal } = attr;
|
|
2509
2500
|
if (thenVal !== undefined) {
|
|
2510
2501
|
this._maybeAddVal(thenVal);
|
|
2511
2502
|
this._maybeAddVal(elseVal);
|
|
2512
2503
|
} else {
|
|
2513
|
-
this._maybeAddVal(
|
|
2504
|
+
this._maybeAddVal(val);
|
|
2514
2505
|
}
|
|
2515
2506
|
}
|
|
2516
2507
|
} else {
|
|
@@ -2521,15 +2512,15 @@ class ParseCtxClassSetCollector extends ParseContext {
|
|
|
2521
2512
|
}
|
|
2522
2513
|
}
|
|
2523
2514
|
_maybeAddVal(value) {
|
|
2524
|
-
if (!this._maybeAddStrTpl(value) && typeof value?.
|
|
2525
|
-
this._addClasses(value.
|
|
2515
|
+
if (!this._maybeAddStrTpl(value) && typeof value?.val === "string") {
|
|
2516
|
+
this._addClasses(value.val);
|
|
2526
2517
|
}
|
|
2527
2518
|
}
|
|
2528
2519
|
_maybeAddStrTpl(value) {
|
|
2529
2520
|
if (value?.vals !== undefined) {
|
|
2530
2521
|
for (const val of value.vals) {
|
|
2531
|
-
if (val instanceof ConstVal && val.
|
|
2532
|
-
this._addClasses(val.
|
|
2522
|
+
if (val instanceof ConstVal && val.val !== "") {
|
|
2523
|
+
this._addClasses(val.val);
|
|
2533
2524
|
}
|
|
2534
2525
|
}
|
|
2535
2526
|
return true;
|
|
@@ -2639,13 +2630,13 @@ function hasIterator(maybeIterable) {
|
|
|
2639
2630
|
}
|
|
2640
2631
|
return !!getIteratorFn(maybeIterable);
|
|
2641
2632
|
}
|
|
2642
|
-
var isIterator = (maybeIterator) =>
|
|
2633
|
+
var isIterator = (maybeIterator) => typeof maybeIterator?.next === "function";
|
|
2643
2634
|
function getIterator(iterable) {
|
|
2644
2635
|
const iteratorFn = getIteratorFn(iterable);
|
|
2645
2636
|
return iteratorFn?.call(iterable);
|
|
2646
2637
|
}
|
|
2647
2638
|
function getIteratorFn(iterable) {
|
|
2648
|
-
const iteratorFn = iterable
|
|
2639
|
+
const iteratorFn = iterable?.[Symbol.iterator];
|
|
2649
2640
|
if (typeof iteratorFn === "function") {
|
|
2650
2641
|
return iteratorFn;
|
|
2651
2642
|
}
|
|
@@ -2740,12 +2731,10 @@ function flipFactory(collection) {
|
|
|
2740
2731
|
flipSequence.__iterate = function(fn, reverse) {
|
|
2741
2732
|
return collection.__iterate((v, k) => fn(k, v, this), reverse);
|
|
2742
2733
|
};
|
|
2743
|
-
flipSequence.__iteratorUncached =
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
});
|
|
2748
|
-
};
|
|
2734
|
+
flipSequence.__iteratorUncached = (reverse) => mapEntries(collection.__iterator(reverse), (k, v, entry) => {
|
|
2735
|
+
entry[0] = v;
|
|
2736
|
+
entry[1] = k;
|
|
2737
|
+
});
|
|
2749
2738
|
return flipSequence;
|
|
2750
2739
|
}
|
|
2751
2740
|
function mapFactory(collection, mapper, context) {
|
|
@@ -2759,12 +2748,10 @@ function mapFactory(collection, mapper, context) {
|
|
|
2759
2748
|
mappedSequence.__iterate = function(fn, reverse) {
|
|
2760
2749
|
return collection.__iterate((v, k) => fn(mapper.call(context, v, k, collection), k, this), reverse);
|
|
2761
2750
|
};
|
|
2762
|
-
mappedSequence.__iteratorUncached =
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
});
|
|
2767
|
-
};
|
|
2751
|
+
mappedSequence.__iteratorUncached = (reverse) => mapEntries(collection.__iterator(reverse), (k, v, entry) => {
|
|
2752
|
+
entry[0] = k;
|
|
2753
|
+
entry[1] = mapper.call(context, v, k, collection);
|
|
2754
|
+
});
|
|
2768
2755
|
return mappedSequence;
|
|
2769
2756
|
}
|
|
2770
2757
|
function reverseFactory(collection, useKeys) {
|
|
@@ -2917,7 +2904,7 @@ function maxFactory(collection, comparator, mapper) {
|
|
|
2917
2904
|
}
|
|
2918
2905
|
if (mapper) {
|
|
2919
2906
|
const entry = collection.toSeq().map((v, k) => [v, mapper(v, k, collection)]).reduce((a, b) => maxCompare(comparator, a[1], b[1]) ? b : a);
|
|
2920
|
-
return entry
|
|
2907
|
+
return entry?.[0];
|
|
2921
2908
|
}
|
|
2922
2909
|
return collection.reduce((a, b) => maxCompare(comparator, a, b) ? b : a);
|
|
2923
2910
|
}
|
|
@@ -3522,7 +3509,7 @@ class CollectionImpl {
|
|
|
3522
3509
|
}
|
|
3523
3510
|
findKey(predicate, context) {
|
|
3524
3511
|
const entry = this.findEntry(predicate, context);
|
|
3525
|
-
return entry
|
|
3512
|
+
return entry?.[0];
|
|
3526
3513
|
}
|
|
3527
3514
|
findLast(predicate, context, notSetValue) {
|
|
3528
3515
|
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
|
|
@@ -5390,7 +5377,7 @@ class ListImpl extends IndexedCollectionImpl {
|
|
|
5390
5377
|
if (index >= 0 && index < this.size) {
|
|
5391
5378
|
index += this._origin;
|
|
5392
5379
|
const node = listNodeFor(this, index);
|
|
5393
|
-
return node
|
|
5380
|
+
return node?.array[index & MASK];
|
|
5394
5381
|
}
|
|
5395
5382
|
return notSetValue;
|
|
5396
5383
|
}
|
|
@@ -5621,7 +5608,7 @@ function iterateList(list, reverse) {
|
|
|
5621
5608
|
function pushFrame(node, level, offset) {
|
|
5622
5609
|
if (level === 0) {
|
|
5623
5610
|
const array = offset === tailPos ? tail?.array : node?.array;
|
|
5624
|
-
|
|
5611
|
+
const from = offset > left ? 0 : left - offset;
|
|
5625
5612
|
let to = right - offset;
|
|
5626
5613
|
if (to > SIZE) {
|
|
5627
5614
|
to = SIZE;
|
|
@@ -5636,7 +5623,7 @@ function iterateList(list, reverse) {
|
|
|
5636
5623
|
}
|
|
5637
5624
|
} else {
|
|
5638
5625
|
const array = node?.array;
|
|
5639
|
-
|
|
5626
|
+
const from = offset > left ? 0 : left - offset >> level;
|
|
5640
5627
|
let to = (right - offset >> level) + 1;
|
|
5641
5628
|
if (to > SIZE) {
|
|
5642
5629
|
to = SIZE;
|
|
@@ -5738,7 +5725,7 @@ function updateVNode(node, ownerID, level, index, value, didAlter) {
|
|
|
5738
5725
|
}
|
|
5739
5726
|
let newNode;
|
|
5740
5727
|
if (level > 0) {
|
|
5741
|
-
const lowerNode = node
|
|
5728
|
+
const lowerNode = node?.array[idx];
|
|
5742
5729
|
const newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
|
|
5743
5730
|
if (newLowerNode === lowerNode) {
|
|
5744
5731
|
return node;
|
|
@@ -5831,14 +5818,14 @@ function setListBounds(list, begin, end) {
|
|
|
5831
5818
|
node.array[oldTailOffset >>> SHIFT & MASK] = oldTail;
|
|
5832
5819
|
}
|
|
5833
5820
|
if (newCapacity < oldCapacity) {
|
|
5834
|
-
newTail = newTail
|
|
5821
|
+
newTail = newTail?.removeAfter(owner, 0, newCapacity);
|
|
5835
5822
|
}
|
|
5836
5823
|
if (newOrigin >= newTailOffset) {
|
|
5837
5824
|
newOrigin -= newTailOffset;
|
|
5838
5825
|
newCapacity -= newTailOffset;
|
|
5839
5826
|
newLevel = SHIFT;
|
|
5840
5827
|
newRoot = null;
|
|
5841
|
-
newTail = newTail
|
|
5828
|
+
newTail = newTail?.removeBefore(owner, 0, newOrigin);
|
|
5842
5829
|
} else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
|
|
5843
5830
|
offsetShift = 0;
|
|
5844
5831
|
while (newRoot) {
|
|
@@ -6846,7 +6833,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
|
|
|
6846
6833
|
if (keyPath && key !== "") {
|
|
6847
6834
|
keyPath.push(key);
|
|
6848
6835
|
}
|
|
6849
|
-
const converted = converter.call(parentValue, key, Seq(value).map((v, k) => fromJSWith(stack, converter, v, k, keyPath, value)), keyPath
|
|
6836
|
+
const converted = converter.call(parentValue, key, Seq(value).map((v, k) => fromJSWith(stack, converter, v, k, keyPath, value)), keyPath?.slice());
|
|
6850
6837
|
stack.pop();
|
|
6851
6838
|
if (keyPath) {
|
|
6852
6839
|
keyPath.pop();
|
|
@@ -7331,7 +7318,7 @@ class Renderer {
|
|
|
7331
7318
|
this.comps = comps;
|
|
7332
7319
|
this.h = h;
|
|
7333
7320
|
this.fragment = fragment;
|
|
7334
|
-
this.
|
|
7321
|
+
this.renderComment = comment;
|
|
7335
7322
|
this.renderFn = renderFn;
|
|
7336
7323
|
this.getSeqInfo = getSeqInfo ?? basicGetSeqInfo;
|
|
7337
7324
|
this.cache = cache ?? new WeakMapDomCache;
|
|
@@ -7357,13 +7344,13 @@ class Renderer {
|
|
|
7357
7344
|
return dom.innerHTML;
|
|
7358
7345
|
}
|
|
7359
7346
|
renderRoot(stack, val, viewName = null) {
|
|
7360
|
-
const
|
|
7361
|
-
const nid =
|
|
7362
|
-
return
|
|
7347
|
+
const comp = this.comps.getCompFor(val);
|
|
7348
|
+
const nid = comp.getView(viewName).anode.nodeId ?? null;
|
|
7349
|
+
return comp ? this._rValComp(stack, val, comp, nid, "ROOT", viewName) : null;
|
|
7363
7350
|
}
|
|
7364
7351
|
renderIt(stack, nodeId, key, viewName) {
|
|
7365
|
-
const
|
|
7366
|
-
return
|
|
7352
|
+
const comp = this.comps.getCompFor(stack.it);
|
|
7353
|
+
return comp ? this._rValComp(stack, stack.it, comp, nodeId, key, viewName) : null;
|
|
7367
7354
|
}
|
|
7368
7355
|
_rValComp(stack, val, comp, nid, key, viewName) {
|
|
7369
7356
|
const cacheKey = `${viewName ?? stack.viewsId ?? ""}${nid}-${key}`;
|
|
@@ -7373,10 +7360,13 @@ class Renderer {
|
|
|
7373
7360
|
}
|
|
7374
7361
|
const view = viewName ? comp.getView(viewName) : stack.lookupBestView(comp.views, "main");
|
|
7375
7362
|
const meta = this.renderMetadata("Comp", { nid });
|
|
7376
|
-
const dom = this.renderFragment([meta,
|
|
7363
|
+
const dom = this.renderFragment([meta, this.renderView(view, stack)]);
|
|
7377
7364
|
this.cache.set(val, cacheKey, dom);
|
|
7378
7365
|
return dom;
|
|
7379
7366
|
}
|
|
7367
|
+
pushEachEntry(r, nid, attrName, key, dom) {
|
|
7368
|
+
r.push(this.renderMetadata("Each", { nid, [attrName]: key }), dom);
|
|
7369
|
+
}
|
|
7380
7370
|
renderEach(stack, iterInfo, nodeId, viewName) {
|
|
7381
7371
|
const { seq, filter, loopWith } = iterInfo.eval(stack);
|
|
7382
7372
|
const [attrName, gen] = this.getSeqInfo(seq);
|
|
@@ -7386,16 +7376,14 @@ class Renderer {
|
|
|
7386
7376
|
if (filter.call(stack.it, key, value, iterData)) {
|
|
7387
7377
|
const newStack = stack.enter(value, { key }, true);
|
|
7388
7378
|
const dom = this.renderIt(newStack, nodeId, key, viewName);
|
|
7389
|
-
|
|
7390
|
-
r.push(dom);
|
|
7379
|
+
this.pushEachEntry(r, nodeId, attrName, key, dom);
|
|
7391
7380
|
}
|
|
7392
7381
|
}
|
|
7393
7382
|
return r;
|
|
7394
7383
|
}
|
|
7395
|
-
renderEachWhen(stack, iterInfo,
|
|
7384
|
+
renderEachWhen(stack, iterInfo, view, nid) {
|
|
7396
7385
|
const { seq, filter, loopWith, enricher } = iterInfo.eval(stack);
|
|
7397
7386
|
const [attrName, gen] = this.getSeqInfo(seq);
|
|
7398
|
-
const hasEnricher = !!enricher;
|
|
7399
7387
|
const r = [];
|
|
7400
7388
|
const iterData = loopWith.call(stack.it, seq);
|
|
7401
7389
|
for (const [key, value] of gen(seq)) {
|
|
@@ -7403,30 +7391,31 @@ class Renderer {
|
|
|
7403
7391
|
const bindings = { key, value };
|
|
7404
7392
|
const cacheKey = `${nid}-${key}`;
|
|
7405
7393
|
let cachedNode;
|
|
7406
|
-
if (
|
|
7394
|
+
if (enricher) {
|
|
7407
7395
|
enricher.call(stack.it, bindings, key, value, iterData);
|
|
7408
7396
|
cachedNode = this.cache.get2(stack.it, value, cacheKey);
|
|
7409
7397
|
} else {
|
|
7410
7398
|
cachedNode = this.cache.get(value, cacheKey);
|
|
7411
7399
|
}
|
|
7412
7400
|
if (cachedNode) {
|
|
7413
|
-
|
|
7414
|
-
r.push(cachedNode);
|
|
7401
|
+
this.pushEachEntry(r, nid, attrName, key, cachedNode);
|
|
7415
7402
|
continue;
|
|
7416
7403
|
}
|
|
7417
7404
|
const newStack = stack.enter(value, bindings, false);
|
|
7418
|
-
const dom =
|
|
7419
|
-
|
|
7420
|
-
if (
|
|
7405
|
+
const dom = this.renderView(view, newStack);
|
|
7406
|
+
this.pushEachEntry(r, nid, attrName, key, dom);
|
|
7407
|
+
if (enricher) {
|
|
7421
7408
|
this.cache.set2(stack.it, value, cacheKey, dom);
|
|
7422
7409
|
} else {
|
|
7423
7410
|
this.cache.set(value, cacheKey, dom);
|
|
7424
7411
|
}
|
|
7425
|
-
r.push(dom);
|
|
7426
7412
|
}
|
|
7427
7413
|
}
|
|
7428
7414
|
return r;
|
|
7429
7415
|
}
|
|
7416
|
+
renderView(view, stack) {
|
|
7417
|
+
return view.render(stack, this);
|
|
7418
|
+
}
|
|
7430
7419
|
renderText(text) {
|
|
7431
7420
|
return text;
|
|
7432
7421
|
}
|
|
@@ -7434,10 +7423,7 @@ class Renderer {
|
|
|
7434
7423
|
info.$ = type;
|
|
7435
7424
|
return this.renderComment(`§${JSON.stringify(info)}§`);
|
|
7436
7425
|
}
|
|
7437
|
-
|
|
7438
|
-
return this.comment(text);
|
|
7439
|
-
}
|
|
7440
|
-
renderEmpty(_text) {
|
|
7426
|
+
renderEmpty() {
|
|
7441
7427
|
return null;
|
|
7442
7428
|
}
|
|
7443
7429
|
renderTag(tagName, attrs, childs) {
|
|
@@ -7564,6 +7550,7 @@ seqInfoByClass.set(KList, ["data-sk", klistEntries]);
|
|
|
7564
7550
|
// src/vdom.js
|
|
7565
7551
|
var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
|
|
7566
7552
|
var isObject = (v) => v !== null && typeof v === "object";
|
|
7553
|
+
var prototypesDiffer = (a, b) => Object.getPrototypeOf(a) !== Object.getPrototypeOf(b);
|
|
7567
7554
|
function applyProperties(node, props, previous) {
|
|
7568
7555
|
for (const propName in props) {
|
|
7569
7556
|
const propValue = props[propName];
|
|
@@ -7585,41 +7572,48 @@ function applyProperties(node, props, previous) {
|
|
|
7585
7572
|
function removeProperty(node, propName, previous) {
|
|
7586
7573
|
const previousValue = previous[propName];
|
|
7587
7574
|
if (propName === "dangerouslySetInnerHTML") {
|
|
7588
|
-
node.
|
|
7575
|
+
node.replaceChildren();
|
|
7576
|
+
} else if (propName === "className") {
|
|
7577
|
+
node.removeAttribute("class");
|
|
7578
|
+
} else if (propName === "htmlFor") {
|
|
7579
|
+
node.removeAttribute("for");
|
|
7589
7580
|
} else if (typeof previousValue === "string" || isHtmlAttribute(propName)) {
|
|
7590
|
-
|
|
7591
|
-
node.removeAttribute(attrName);
|
|
7581
|
+
node.removeAttribute(propName);
|
|
7592
7582
|
} else {
|
|
7593
7583
|
node[propName] = null;
|
|
7594
7584
|
}
|
|
7595
7585
|
}
|
|
7596
7586
|
function patchObject(node, previous, propName, propValue) {
|
|
7597
7587
|
const previousValue = previous?.[propName];
|
|
7598
|
-
if (isObject(previousValue) &&
|
|
7588
|
+
if (isObject(previousValue) && prototypesDiffer(previousValue, propValue)) {
|
|
7599
7589
|
node[propName] = propValue;
|
|
7600
7590
|
return;
|
|
7601
7591
|
}
|
|
7602
|
-
|
|
7603
|
-
if (!isObject(current)) {
|
|
7592
|
+
if (!isObject(node[propName])) {
|
|
7604
7593
|
node[propName] = {};
|
|
7605
|
-
current = node[propName];
|
|
7606
7594
|
}
|
|
7607
|
-
const target =
|
|
7595
|
+
const target = node[propName];
|
|
7608
7596
|
for (const k in propValue) {
|
|
7609
7597
|
target[k] = propValue[k];
|
|
7610
7598
|
}
|
|
7611
7599
|
}
|
|
7612
7600
|
|
|
7613
7601
|
class VBase {
|
|
7614
|
-
isEqualTo(other) {
|
|
7615
|
-
return this === other;
|
|
7616
|
-
}
|
|
7617
|
-
toDom(_opts) {
|
|
7618
|
-
return null;
|
|
7619
|
-
}
|
|
7620
7602
|
}
|
|
7621
7603
|
var getKey = (child) => child instanceof VNode2 ? child.key : undefined;
|
|
7622
7604
|
var isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
7605
|
+
function childsEqual(a, b) {
|
|
7606
|
+
for (let i = 0;i < a.length; i++) {
|
|
7607
|
+
if (!a[i].isEqualTo(b[i]))
|
|
7608
|
+
return false;
|
|
7609
|
+
}
|
|
7610
|
+
return true;
|
|
7611
|
+
}
|
|
7612
|
+
function appendChildNodes(parent, childs, opts) {
|
|
7613
|
+
for (const child of childs) {
|
|
7614
|
+
parent.appendChild(child.toDom(opts));
|
|
7615
|
+
}
|
|
7616
|
+
}
|
|
7623
7617
|
function addChild(normalizedChildren, child) {
|
|
7624
7618
|
if (child == null)
|
|
7625
7619
|
return;
|
|
@@ -7683,21 +7677,11 @@ class VFragment extends VBase {
|
|
|
7683
7677
|
if (!(other instanceof VFragment) || this.childs.length !== other.childs.length) {
|
|
7684
7678
|
return false;
|
|
7685
7679
|
}
|
|
7686
|
-
|
|
7687
|
-
if (!this.childs[i].isEqualTo(other.childs[i])) {
|
|
7688
|
-
return false;
|
|
7689
|
-
}
|
|
7690
|
-
}
|
|
7691
|
-
return true;
|
|
7680
|
+
return childsEqual(this.childs, other.childs);
|
|
7692
7681
|
}
|
|
7693
7682
|
toDom(opts) {
|
|
7694
7683
|
const fragment = opts.document.createDocumentFragment();
|
|
7695
|
-
|
|
7696
|
-
const childNode = child.toDom(opts);
|
|
7697
|
-
if (childNode) {
|
|
7698
|
-
fragment.appendChild(childNode);
|
|
7699
|
-
}
|
|
7700
|
-
}
|
|
7684
|
+
appendChildNodes(fragment, this.childs, opts);
|
|
7701
7685
|
return fragment;
|
|
7702
7686
|
}
|
|
7703
7687
|
}
|
|
@@ -7728,23 +7712,13 @@ class VNode2 extends VBase {
|
|
|
7728
7712
|
return false;
|
|
7729
7713
|
}
|
|
7730
7714
|
}
|
|
7731
|
-
|
|
7732
|
-
if (!this.childs[i].isEqualTo(other.childs[i])) {
|
|
7733
|
-
return false;
|
|
7734
|
-
}
|
|
7735
|
-
}
|
|
7736
|
-
return true;
|
|
7715
|
+
return childsEqual(this.childs, other.childs);
|
|
7737
7716
|
}
|
|
7738
7717
|
toDom(opts) {
|
|
7739
7718
|
const doc = opts.document;
|
|
7740
7719
|
const node = this.namespace === null ? doc.createElement(this.tag) : doc.createElementNS(this.namespace, this.tag);
|
|
7741
7720
|
applyProperties(node, this.attrs, {});
|
|
7742
|
-
|
|
7743
|
-
const childNode = child.toDom(opts);
|
|
7744
|
-
if (childNode) {
|
|
7745
|
-
node.appendChild(childNode);
|
|
7746
|
-
}
|
|
7747
|
-
}
|
|
7721
|
+
appendChildNodes(node, this.childs, opts);
|
|
7748
7722
|
return node;
|
|
7749
7723
|
}
|
|
7750
7724
|
}
|
|
@@ -7758,8 +7732,10 @@ function diffProps(a, b) {
|
|
|
7758
7732
|
}
|
|
7759
7733
|
const aValue = a[aKey];
|
|
7760
7734
|
const bValue = b[aKey];
|
|
7761
|
-
if (aValue === bValue)
|
|
7762
|
-
|
|
7735
|
+
if (aValue === bValue)
|
|
7736
|
+
continue;
|
|
7737
|
+
if (isObject(aValue) && isObject(bValue)) {
|
|
7738
|
+
if (prototypesDiffer(bValue, aValue)) {
|
|
7763
7739
|
diff ??= {};
|
|
7764
7740
|
diff[aKey] = bValue;
|
|
7765
7741
|
} else {
|
|
@@ -7782,55 +7758,44 @@ function diffProps(a, b) {
|
|
|
7782
7758
|
}
|
|
7783
7759
|
return diff;
|
|
7784
7760
|
}
|
|
7785
|
-
function replaceNode(domNode, vnode, options) {
|
|
7786
|
-
const parentNode = domNode.parentNode;
|
|
7787
|
-
const newNode = vnode.toDom(options);
|
|
7788
|
-
if (parentNode && newNode && newNode !== domNode) {
|
|
7789
|
-
parentNode.replaceChild(newNode, domNode);
|
|
7790
|
-
}
|
|
7791
|
-
return newNode || domNode;
|
|
7792
|
-
}
|
|
7793
|
-
var bothInstanceOf = (a, b, C) => a instanceof C && b instanceof C;
|
|
7794
7761
|
function morphNode(domNode, source, target, opts) {
|
|
7795
7762
|
if (source === target || source.isEqualTo(target))
|
|
7796
7763
|
return domNode;
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
7803
|
-
if (propsDiff) {
|
|
7804
|
-
applyProperties(domNode, propsDiff, source.attrs);
|
|
7764
|
+
const type = source.nodeType;
|
|
7765
|
+
if (type === target.nodeType) {
|
|
7766
|
+
if (type === 3 || type === 8) {
|
|
7767
|
+
domNode.data = target.text;
|
|
7768
|
+
return domNode;
|
|
7805
7769
|
}
|
|
7806
|
-
if (
|
|
7807
|
-
|
|
7770
|
+
if (type === 1 && source.tag === target.tag && source.namespace === target.namespace && source.key === target.key) {
|
|
7771
|
+
const propsDiff = diffProps(source.attrs, target.attrs);
|
|
7772
|
+
if (propsDiff)
|
|
7773
|
+
applyProperties(domNode, propsDiff, source.attrs);
|
|
7774
|
+
if (!target.attrs.dangerouslySetInnerHTML) {
|
|
7775
|
+
morphChildren(domNode, source.childs, target.childs, opts);
|
|
7776
|
+
}
|
|
7777
|
+
return domNode;
|
|
7778
|
+
}
|
|
7779
|
+
if (type === 11) {
|
|
7780
|
+
morphChildren(domNode, source.childs, target.childs, opts);
|
|
7781
|
+
return domNode;
|
|
7808
7782
|
}
|
|
7809
|
-
return domNode;
|
|
7810
|
-
}
|
|
7811
|
-
if (bothInstanceOf(source, target, VFragment)) {
|
|
7812
|
-
morphChildren(domNode, source.childs, target.childs, null, opts);
|
|
7813
|
-
return domNode;
|
|
7814
7783
|
}
|
|
7815
|
-
|
|
7784
|
+
const newNode = target.toDom(opts);
|
|
7785
|
+
domNode.parentNode?.replaceChild(newNode, domNode);
|
|
7786
|
+
return newNode;
|
|
7816
7787
|
}
|
|
7817
|
-
function morphChildren(parentDom, oldChilds, newChilds,
|
|
7788
|
+
function morphChildren(parentDom, oldChilds, newChilds, opts) {
|
|
7818
7789
|
if (oldChilds.length === 0) {
|
|
7819
|
-
|
|
7820
|
-
const node = child.toDom(opts);
|
|
7821
|
-
if (node)
|
|
7822
|
-
parentDom.appendChild(node);
|
|
7823
|
-
}
|
|
7790
|
+
appendChildNodes(parentDom, newChilds, opts);
|
|
7824
7791
|
return;
|
|
7825
7792
|
}
|
|
7826
7793
|
if (newChilds.length === 0) {
|
|
7827
|
-
|
|
7828
|
-
parentDom.removeChild(parentDom.firstChild);
|
|
7829
|
-
}
|
|
7794
|
+
parentDom.replaceChildren();
|
|
7830
7795
|
return;
|
|
7831
7796
|
}
|
|
7832
7797
|
const domNodes = Array.from(parentDom.childNodes);
|
|
7833
|
-
const oldKeyMap =
|
|
7798
|
+
const oldKeyMap = Object.create(null);
|
|
7834
7799
|
for (let i = 0;i < oldChilds.length; i++) {
|
|
7835
7800
|
const key = getKey(oldChilds[i]);
|
|
7836
7801
|
if (key != null)
|
|
@@ -7857,17 +7822,13 @@ function morphChildren(parentDom, oldChilds, newChilds, _parentTag, opts) {
|
|
|
7857
7822
|
}
|
|
7858
7823
|
if (oldIdx >= 0) {
|
|
7859
7824
|
used[oldIdx] = 1;
|
|
7860
|
-
const
|
|
7861
|
-
const newDom = morphNode(dom, oldChilds[oldIdx], newChild, opts);
|
|
7825
|
+
const newDom = morphNode(domNodes[oldIdx], oldChilds[oldIdx], newChild, opts);
|
|
7862
7826
|
const ref = parentDom.childNodes[j] ?? null;
|
|
7863
7827
|
if (newDom !== ref)
|
|
7864
7828
|
parentDom.insertBefore(newDom, ref);
|
|
7865
7829
|
} else {
|
|
7866
|
-
const
|
|
7867
|
-
|
|
7868
|
-
const ref = parentDom.childNodes[j] ?? null;
|
|
7869
|
-
parentDom.insertBefore(dom, ref);
|
|
7870
|
-
}
|
|
7830
|
+
const ref = parentDom.childNodes[j] ?? null;
|
|
7831
|
+
parentDom.insertBefore(newChild.toDom(opts), ref);
|
|
7871
7832
|
}
|
|
7872
7833
|
}
|
|
7873
7834
|
for (let i = oldChilds.length - 1;i >= 0; i--) {
|
|
@@ -7880,24 +7841,16 @@ var renderCache = new WeakMap;
|
|
|
7880
7841
|
function render(vnode, container, options) {
|
|
7881
7842
|
const cached = renderCache.get(container);
|
|
7882
7843
|
const isFragment = vnode instanceof VFragment;
|
|
7883
|
-
if (cached) {
|
|
7884
|
-
const
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
const domToCache = isFragment ? container : newDom;
|
|
7889
|
-
renderCache.set(container, { vnode, dom: domToCache });
|
|
7890
|
-
return newDom;
|
|
7891
|
-
}
|
|
7892
|
-
renderCache.delete(container);
|
|
7844
|
+
if (cached && cached.vnode instanceof VFragment === isFragment) {
|
|
7845
|
+
const oldDom = isFragment ? container : cached.dom;
|
|
7846
|
+
const newDom = morphNode(oldDom, cached.vnode, vnode, options);
|
|
7847
|
+
renderCache.set(container, { vnode, dom: isFragment ? container : newDom });
|
|
7848
|
+
return newDom;
|
|
7893
7849
|
}
|
|
7850
|
+
renderCache.delete(container);
|
|
7894
7851
|
const domNode = vnode.toDom(options);
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
container.appendChild(domNode);
|
|
7898
|
-
const domToCache = isFragment ? container : domNode;
|
|
7899
|
-
renderCache.set(container, { vnode, dom: domToCache });
|
|
7900
|
-
}
|
|
7852
|
+
container.replaceChildren(domNode);
|
|
7853
|
+
renderCache.set(container, { vnode, dom: isFragment ? container : domNode });
|
|
7901
7854
|
return domNode;
|
|
7902
7855
|
}
|
|
7903
7856
|
function h(tagName, properties, children) {
|
|
@@ -7956,8 +7909,8 @@ async function compileClassesToStyle(app, compileClasses, styleId = "margaui-css
|
|
|
7956
7909
|
injectCss(styleId, css2);
|
|
7957
7910
|
return t2 - t1;
|
|
7958
7911
|
}
|
|
7959
|
-
async function compileClassesToStyleText(app, compileClasses, extraCSSClasses) {
|
|
7960
|
-
app.ParseContext =
|
|
7912
|
+
async function compileClassesToStyleText(app, compileClasses, extraCSSClasses, Ctx = ParseCtxClassSetCollector) {
|
|
7913
|
+
app.ParseContext = Ctx;
|
|
7961
7914
|
app.compile();
|
|
7962
7915
|
const classes = new Set(extraCSSClasses ?? []);
|
|
7963
7916
|
for (const Comp of app.comps.byId.values()) {
|
|
@@ -8024,30 +7977,28 @@ function checkEventModifiers(lx, view) {
|
|
|
8024
7977
|
}
|
|
8025
7978
|
}
|
|
8026
7979
|
}
|
|
7980
|
+
var KNOWN_HANDLER_NAMES = new Set([
|
|
7981
|
+
"value",
|
|
7982
|
+
"valueAsInt",
|
|
7983
|
+
"valueAsFloat",
|
|
7984
|
+
"target",
|
|
7985
|
+
"event",
|
|
7986
|
+
"isAlt",
|
|
7987
|
+
"isShift",
|
|
7988
|
+
"isCtrl",
|
|
7989
|
+
"isCmd",
|
|
7990
|
+
"key",
|
|
7991
|
+
"keyCode",
|
|
7992
|
+
"isUpKey",
|
|
7993
|
+
"isDownKey",
|
|
7994
|
+
"isSend",
|
|
7995
|
+
"isCancel",
|
|
7996
|
+
"isTabKey",
|
|
7997
|
+
"ctx",
|
|
7998
|
+
"dragInfo"
|
|
7999
|
+
]);
|
|
8027
8000
|
function isKnownHandlerName(name) {
|
|
8028
|
-
|
|
8029
|
-
case "value":
|
|
8030
|
-
case "valueAsInt":
|
|
8031
|
-
case "valueAsFloat":
|
|
8032
|
-
case "target":
|
|
8033
|
-
case "event":
|
|
8034
|
-
case "isAlt":
|
|
8035
|
-
case "isShift":
|
|
8036
|
-
case "isCtrl":
|
|
8037
|
-
case "isCmd":
|
|
8038
|
-
case "key":
|
|
8039
|
-
case "keyCode":
|
|
8040
|
-
case "isUpKey":
|
|
8041
|
-
case "isDownKey":
|
|
8042
|
-
case "isSend":
|
|
8043
|
-
case "isCancel":
|
|
8044
|
-
case "isTabKey":
|
|
8045
|
-
case "ctx":
|
|
8046
|
-
case "dragInfo":
|
|
8047
|
-
return true;
|
|
8048
|
-
default:
|
|
8049
|
-
return false;
|
|
8050
|
-
}
|
|
8001
|
+
return KNOWN_HANDLER_NAMES.has(name);
|
|
8051
8002
|
}
|
|
8052
8003
|
function checkKnownHandlerNames(lx, view, Comp) {
|
|
8053
8004
|
const { computed, scope, Class } = Comp;
|
|
@@ -8145,7 +8096,7 @@ function checkConsistentAttrs(lx, Comp) {
|
|
|
8145
8096
|
if (attrs instanceof DynAttrs) {
|
|
8146
8097
|
for (const attr2 of attrs.items) {
|
|
8147
8098
|
if (attr2 instanceof Attr) {
|
|
8148
|
-
checkConsistentAttrVal(lx, attr2.
|
|
8099
|
+
checkConsistentAttrVal(lx, attr2.val, fields, proto, computed, scope);
|
|
8149
8100
|
}
|
|
8150
8101
|
}
|
|
8151
8102
|
}
|
|
@@ -8193,6 +8144,25 @@ class LintParseContext extends ParseContext {
|
|
|
8193
8144
|
this.attrs.push({ attrs, wrapperAttrs, textChild });
|
|
8194
8145
|
}
|
|
8195
8146
|
}
|
|
8147
|
+
// dev.js
|
|
8148
|
+
class LintClassCollectorCtx extends ParseCtxClassSetCollector {
|
|
8149
|
+
constructor(...args) {
|
|
8150
|
+
super(...args);
|
|
8151
|
+
this.attrs = [];
|
|
8152
|
+
}
|
|
8153
|
+
enterMacro(macroName, macroVars, macroSlots) {
|
|
8154
|
+
const { DOMParser: DP, Text, Comment, nodes, events, macroNodes } = this;
|
|
8155
|
+
const frame = { macroName, macroVars, macroSlots };
|
|
8156
|
+
const v = new LintClassCollectorCtx(DP, Text, Comment, nodes, events, macroNodes, frame, this);
|
|
8157
|
+
v.classes = this.classes;
|
|
8158
|
+
v.attrs = this.attrs;
|
|
8159
|
+
return v;
|
|
8160
|
+
}
|
|
8161
|
+
onAttributes(attrs, wrapperAttrs, textChild) {
|
|
8162
|
+
super.onAttributes(attrs, wrapperAttrs, textChild);
|
|
8163
|
+
this.attrs.push({ attrs, wrapperAttrs, textChild });
|
|
8164
|
+
}
|
|
8165
|
+
}
|
|
8196
8166
|
export {
|
|
8197
8167
|
version,
|
|
8198
8168
|
updateIn$1 as updateIn,
|
|
@@ -8262,6 +8232,7 @@ export {
|
|
|
8262
8232
|
List,
|
|
8263
8233
|
LintParseContext,
|
|
8264
8234
|
LintContext,
|
|
8235
|
+
LintClassCollectorCtx,
|
|
8265
8236
|
LEVEL_WARN,
|
|
8266
8237
|
LEVEL_HINT,
|
|
8267
8238
|
LEVEL_ERROR,
|