mol_view_tree2_lib 1.0.196 → 1.0.198
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/node.d.ts +281 -3
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +371 -19
- package/node.js.map +1 -1
- package/node.mjs +371 -19
- package/node.test.js +681 -36
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +285 -3
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +364 -16
- package/web.js.map +1 -1
- package/web.mjs +364 -16
- package/web.test.js +310 -17
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -35,6 +35,11 @@ var $;
|
|
|
35
35
|
var $;
|
|
36
36
|
(function ($) {
|
|
37
37
|
const instances = new WeakSet();
|
|
38
|
+
/**
|
|
39
|
+
* Proxy that delegates all to lazy returned target.
|
|
40
|
+
*
|
|
41
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
42
|
+
*/
|
|
38
43
|
function $mol_delegate(proto, target) {
|
|
39
44
|
const proxy = new Proxy(proto, {
|
|
40
45
|
get: (_, field) => {
|
|
@@ -138,7 +143,7 @@ var $;
|
|
|
138
143
|
var $;
|
|
139
144
|
(function ($) {
|
|
140
145
|
function $mol_fail_hidden(error) {
|
|
141
|
-
throw error;
|
|
146
|
+
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
142
147
|
}
|
|
143
148
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
144
149
|
})($ || ($ = {}));
|
|
@@ -230,6 +235,9 @@ var $;
|
|
|
230
235
|
[Symbol.dispose]() {
|
|
231
236
|
this.destructor();
|
|
232
237
|
}
|
|
238
|
+
//[ Symbol.toPrimitive ]( hint: string ) {
|
|
239
|
+
// return hint === 'number' ? this.valueOf() : this.toString()
|
|
240
|
+
//}
|
|
233
241
|
toString() {
|
|
234
242
|
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
235
243
|
}
|
|
@@ -241,6 +249,7 @@ var $;
|
|
|
241
249
|
"use strict";
|
|
242
250
|
var $;
|
|
243
251
|
(function ($) {
|
|
252
|
+
/** Position in any resource. */
|
|
244
253
|
class $mol_span extends $mol_object2 {
|
|
245
254
|
uri;
|
|
246
255
|
source;
|
|
@@ -256,13 +265,17 @@ var $;
|
|
|
256
265
|
this.length = length;
|
|
257
266
|
this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
|
|
258
267
|
}
|
|
268
|
+
/** Span for begin of unknown resource */
|
|
259
269
|
static unknown = $mol_span.begin('?');
|
|
270
|
+
/** Makes new span for begin of resource. */
|
|
260
271
|
static begin(uri, source = '') {
|
|
261
272
|
return new $mol_span(uri, source, 1, 1, 0);
|
|
262
273
|
}
|
|
274
|
+
/** Makes new span for end of resource. */
|
|
263
275
|
static end(uri, source) {
|
|
264
276
|
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
265
277
|
}
|
|
278
|
+
/** Makes new span for entire resource. */
|
|
266
279
|
static entire(uri, source) {
|
|
267
280
|
return new $mol_span(uri, source, 1, 1, source.length);
|
|
268
281
|
}
|
|
@@ -277,15 +290,19 @@ var $;
|
|
|
277
290
|
length: this.length
|
|
278
291
|
};
|
|
279
292
|
}
|
|
293
|
+
/** Makes new error for this span. */
|
|
280
294
|
error(message, Class = Error) {
|
|
281
295
|
return new Class(`${message} (${this})`);
|
|
282
296
|
}
|
|
297
|
+
/** Makes new span for same uri. */
|
|
283
298
|
span(row, col, length) {
|
|
284
299
|
return new $mol_span(this.uri, this.source, row, col, length);
|
|
285
300
|
}
|
|
301
|
+
/** Makes new span after end of this. */
|
|
286
302
|
after(length = 0) {
|
|
287
303
|
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
288
304
|
}
|
|
305
|
+
/** Makes new span between begin and end. */
|
|
289
306
|
slice(begin, end = -1) {
|
|
290
307
|
let len = this.length;
|
|
291
308
|
if (begin < 0)
|
|
@@ -308,6 +325,7 @@ var $;
|
|
|
308
325
|
"use strict";
|
|
309
326
|
var $;
|
|
310
327
|
(function ($) {
|
|
328
|
+
/** Syntax error with cordinates and source line snippet. */
|
|
311
329
|
class $mol_error_syntax extends SyntaxError {
|
|
312
330
|
reason;
|
|
313
331
|
line;
|
|
@@ -326,6 +344,7 @@ var $;
|
|
|
326
344
|
"use strict";
|
|
327
345
|
var $;
|
|
328
346
|
(function ($) {
|
|
347
|
+
/** Parses tree format from string. */
|
|
329
348
|
function $mol_tree2_from_string(str, uri = '?') {
|
|
330
349
|
const span = $mol_span.entire(uri, str);
|
|
331
350
|
var root = $mol_tree2.list([], span);
|
|
@@ -335,6 +354,7 @@ var $;
|
|
|
335
354
|
var indent = 0;
|
|
336
355
|
var line_start = pos;
|
|
337
356
|
row++;
|
|
357
|
+
// read indent
|
|
338
358
|
while (str.length > pos && str[pos] == '\t') {
|
|
339
359
|
indent++;
|
|
340
360
|
pos++;
|
|
@@ -343,8 +363,10 @@ var $;
|
|
|
343
363
|
min_indent = indent;
|
|
344
364
|
}
|
|
345
365
|
indent -= min_indent;
|
|
366
|
+
// invalid tab size
|
|
346
367
|
if (indent < 0 || indent >= stack.length) {
|
|
347
368
|
const sp = span.span(row, 1, pos - line_start);
|
|
369
|
+
// skip error line
|
|
348
370
|
while (str.length > pos && str[pos] != '\n') {
|
|
349
371
|
pos++;
|
|
350
372
|
}
|
|
@@ -359,7 +381,9 @@ var $;
|
|
|
359
381
|
}
|
|
360
382
|
stack.length = indent + 1;
|
|
361
383
|
var parent = stack[indent];
|
|
384
|
+
// parse types
|
|
362
385
|
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
386
|
+
// type can not contain space and tab
|
|
363
387
|
var error_start = pos;
|
|
364
388
|
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
365
389
|
pos++;
|
|
@@ -371,6 +395,7 @@ var $;
|
|
|
371
395
|
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
372
396
|
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
373
397
|
}
|
|
398
|
+
// read type
|
|
374
399
|
var type_start = pos;
|
|
375
400
|
while (str.length > pos &&
|
|
376
401
|
str[pos] != '\\' &&
|
|
@@ -385,10 +410,12 @@ var $;
|
|
|
385
410
|
parent_kids.push(next);
|
|
386
411
|
parent = next;
|
|
387
412
|
}
|
|
413
|
+
// read one space if exists
|
|
388
414
|
if (str.length > pos && str[pos] == ' ') {
|
|
389
415
|
pos++;
|
|
390
416
|
}
|
|
391
417
|
}
|
|
418
|
+
// read data
|
|
392
419
|
if (str.length > pos && str[pos] == '\\') {
|
|
393
420
|
var data_start = pos;
|
|
394
421
|
while (str.length > pos && str[pos] != '\n') {
|
|
@@ -399,6 +426,7 @@ var $;
|
|
|
399
426
|
parent_kids.push(next);
|
|
400
427
|
parent = next;
|
|
401
428
|
}
|
|
429
|
+
// now must be end of text
|
|
402
430
|
if (str.length === pos && stack.length > 0) {
|
|
403
431
|
const sp = span.span(row, pos - line_start + 1, 1);
|
|
404
432
|
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
@@ -415,6 +443,7 @@ var $;
|
|
|
415
443
|
"use strict";
|
|
416
444
|
var $;
|
|
417
445
|
(function ($) {
|
|
446
|
+
/** Serializes tree to string in tree format. */
|
|
418
447
|
function $mol_tree2_to_string(tree) {
|
|
419
448
|
let output = [];
|
|
420
449
|
function dump(tree, prefix = '') {
|
|
@@ -458,12 +487,25 @@ var $;
|
|
|
458
487
|
"use strict";
|
|
459
488
|
var $;
|
|
460
489
|
(function ($) {
|
|
490
|
+
/**
|
|
491
|
+
* Abstract Syntax Tree with human readable serialization.
|
|
492
|
+
* Avoid direct instantiation. Use static factories instead.
|
|
493
|
+
* @see https://github.com/nin-jin/tree.d
|
|
494
|
+
*/
|
|
461
495
|
class $mol_tree2 extends Object {
|
|
462
496
|
type;
|
|
463
497
|
value;
|
|
464
498
|
kids;
|
|
465
499
|
span;
|
|
466
|
-
constructor(
|
|
500
|
+
constructor(
|
|
501
|
+
/** Type of structural node, `value` should be empty */
|
|
502
|
+
type,
|
|
503
|
+
/** Content of data node, `type` should be empty */
|
|
504
|
+
value,
|
|
505
|
+
/** Child nodes */
|
|
506
|
+
kids,
|
|
507
|
+
/** Position in most far source resource */
|
|
508
|
+
span) {
|
|
467
509
|
super();
|
|
468
510
|
this.type = type;
|
|
469
511
|
this.value = value;
|
|
@@ -471,12 +513,15 @@ var $;
|
|
|
471
513
|
this.span = span;
|
|
472
514
|
this[Symbol.toStringTag] = type || '\\' + value;
|
|
473
515
|
}
|
|
516
|
+
/** Makes collection node. */
|
|
474
517
|
static list(kids, span = $mol_span.unknown) {
|
|
475
518
|
return new $mol_tree2('', '', kids, span);
|
|
476
519
|
}
|
|
520
|
+
/** Makes new derived collection node. */
|
|
477
521
|
list(kids) {
|
|
478
522
|
return $mol_tree2.list(kids, this.span);
|
|
479
523
|
}
|
|
524
|
+
/** Makes data node for any string. */
|
|
480
525
|
static data(value, kids = [], span = $mol_span.unknown) {
|
|
481
526
|
const chunks = value.split('\n');
|
|
482
527
|
if (chunks.length > 1) {
|
|
@@ -490,21 +535,26 @@ var $;
|
|
|
490
535
|
}
|
|
491
536
|
return new $mol_tree2('', value, kids, span);
|
|
492
537
|
}
|
|
538
|
+
/** Makes new derived data node. */
|
|
493
539
|
data(value, kids = []) {
|
|
494
540
|
return $mol_tree2.data(value, kids, this.span);
|
|
495
541
|
}
|
|
542
|
+
/** Makes struct node. */
|
|
496
543
|
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
497
544
|
if (/[ \n\t\\]/.test(type)) {
|
|
498
545
|
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
499
546
|
}
|
|
500
547
|
return new $mol_tree2(type, '', kids, span);
|
|
501
548
|
}
|
|
549
|
+
/** Makes new derived structural node. */
|
|
502
550
|
struct(type, kids = []) {
|
|
503
551
|
return $mol_tree2.struct(type, kids, this.span);
|
|
504
552
|
}
|
|
553
|
+
/** Makes new derived node with different kids id defined. */
|
|
505
554
|
clone(kids, span = this.span) {
|
|
506
555
|
return new $mol_tree2(this.type, this.value, kids, span);
|
|
507
556
|
}
|
|
557
|
+
/** Returns multiline text content. */
|
|
508
558
|
text() {
|
|
509
559
|
var values = [];
|
|
510
560
|
for (var kid of this.kids) {
|
|
@@ -514,15 +564,20 @@ var $;
|
|
|
514
564
|
}
|
|
515
565
|
return this.value + values.join('\n');
|
|
516
566
|
}
|
|
567
|
+
/** Parses tree format. */
|
|
568
|
+
/** @deprecated Use $mol_tree2_from_string */
|
|
517
569
|
static fromString(str, uri = 'unknown') {
|
|
518
570
|
return $$.$mol_tree2_from_string(str, uri);
|
|
519
571
|
}
|
|
572
|
+
/** Serializes to tree format. */
|
|
520
573
|
toString() {
|
|
521
574
|
return $$.$mol_tree2_to_string(this);
|
|
522
575
|
}
|
|
576
|
+
/** Makes new tree with node overrided by path. */
|
|
523
577
|
insert(value, ...path) {
|
|
524
578
|
return this.update($mol_maybe(value), ...path)[0];
|
|
525
579
|
}
|
|
580
|
+
/** Makes new tree with node overrided by path. */
|
|
526
581
|
update(value, ...path) {
|
|
527
582
|
if (path.length === 0)
|
|
528
583
|
return value;
|
|
@@ -555,6 +610,7 @@ var $;
|
|
|
555
610
|
return [this.clone(kids)];
|
|
556
611
|
}
|
|
557
612
|
}
|
|
613
|
+
/** Query nodes by path. */
|
|
558
614
|
select(...path) {
|
|
559
615
|
let next = [this];
|
|
560
616
|
for (const type of path) {
|
|
@@ -581,6 +637,7 @@ var $;
|
|
|
581
637
|
}
|
|
582
638
|
return this.list(next);
|
|
583
639
|
}
|
|
640
|
+
/** Filter kids by path or value. */
|
|
584
641
|
filter(path, value) {
|
|
585
642
|
const sub = this.kids.filter(item => {
|
|
586
643
|
var found = item.select(...path);
|
|
@@ -608,9 +665,11 @@ var $;
|
|
|
608
665
|
$mol_fail_hidden(error);
|
|
609
666
|
}
|
|
610
667
|
}
|
|
668
|
+
/** Transform tree through context with transformers */
|
|
611
669
|
hack(belt, context = {}) {
|
|
612
670
|
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
613
671
|
}
|
|
672
|
+
/** Makes Error with node coordinates. */
|
|
614
673
|
error(message, Class = Error) {
|
|
615
674
|
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
616
675
|
}
|
|
@@ -1007,14 +1066,18 @@ var $;
|
|
|
1007
1066
|
];
|
|
1008
1067
|
},
|
|
1009
1068
|
'': (input, belt) => {
|
|
1069
|
+
// string
|
|
1010
1070
|
if (!input.type)
|
|
1011
1071
|
return [
|
|
1012
1072
|
input.data(JSON.stringify(input.text())),
|
|
1013
1073
|
];
|
|
1074
|
+
// variable
|
|
1014
1075
|
if (/^[\w$#][\w0-9$]*$/i.test(input.type))
|
|
1015
1076
|
return [
|
|
1016
1077
|
input.data(input.type),
|
|
1078
|
+
// ... input.hack( context ),
|
|
1017
1079
|
];
|
|
1080
|
+
// number
|
|
1018
1081
|
if ($mol_tree2_js_is_number(input.type))
|
|
1019
1082
|
return [
|
|
1020
1083
|
input.data(input.type)
|
|
@@ -1339,6 +1402,7 @@ var $;
|
|
|
1339
1402
|
"use strict";
|
|
1340
1403
|
var $;
|
|
1341
1404
|
(function ($) {
|
|
1405
|
+
/** Makes JSON from json.tree. */
|
|
1342
1406
|
function $mol_tree2_to_json(tree) {
|
|
1343
1407
|
if (!tree.type) {
|
|
1344
1408
|
if (tree.kids.every(kid => !kid.type))
|
|
@@ -1604,8 +1668,10 @@ var $;
|
|
|
1604
1668
|
var $;
|
|
1605
1669
|
(function ($) {
|
|
1606
1670
|
let x = /x/[Symbol.matchAll];
|
|
1671
|
+
/** Type safe reguar expression builder */
|
|
1607
1672
|
class $mol_regexp extends RegExp {
|
|
1608
1673
|
groups;
|
|
1674
|
+
/** Prefer to use $mol_regexp.from */
|
|
1609
1675
|
constructor(source, flags = 'gsu', groups = []) {
|
|
1610
1676
|
super(source, flags);
|
|
1611
1677
|
this.groups = groups;
|
|
@@ -1625,12 +1691,14 @@ var $;
|
|
|
1625
1691
|
this.lastIndex = index;
|
|
1626
1692
|
}
|
|
1627
1693
|
}
|
|
1694
|
+
/** Parses input and returns found capture groups or null */
|
|
1628
1695
|
[Symbol.match](str) {
|
|
1629
1696
|
const res = [...this[Symbol.matchAll](str)].filter(r => r.groups).map(r => r[0]);
|
|
1630
1697
|
if (!res.length)
|
|
1631
1698
|
return null;
|
|
1632
1699
|
return res;
|
|
1633
1700
|
}
|
|
1701
|
+
/** Splits string by regexp edges */
|
|
1634
1702
|
[Symbol.split](str) {
|
|
1635
1703
|
const res = [];
|
|
1636
1704
|
let token_last = null;
|
|
@@ -1685,12 +1753,14 @@ var $;
|
|
|
1685
1753
|
get native() {
|
|
1686
1754
|
return new RegExp(this.source, this.flags);
|
|
1687
1755
|
}
|
|
1756
|
+
/** Makes regexp that greedy repeats this pattern with delimiter */
|
|
1688
1757
|
static separated(chunk, sep) {
|
|
1689
1758
|
return $mol_regexp.from([
|
|
1690
1759
|
$mol_regexp.repeat_greedy([[chunk], sep], 0),
|
|
1691
1760
|
chunk,
|
|
1692
1761
|
]);
|
|
1693
1762
|
}
|
|
1763
|
+
/** Makes regexp that non-greedy repeats this pattern from min to max count */
|
|
1694
1764
|
static repeat(source, min = 0, max = Number.POSITIVE_INFINITY) {
|
|
1695
1765
|
const regexp = $mol_regexp.from(source);
|
|
1696
1766
|
const upper = Number.isFinite(max) ? max : '';
|
|
@@ -1706,6 +1776,7 @@ var $;
|
|
|
1706
1776
|
};
|
|
1707
1777
|
return regexp2;
|
|
1708
1778
|
}
|
|
1779
|
+
/** Makes regexp that greedy repeats this pattern from min to max count */
|
|
1709
1780
|
static repeat_greedy(source, min = 0, max = Number.POSITIVE_INFINITY) {
|
|
1710
1781
|
const regexp = $mol_regexp.from(source);
|
|
1711
1782
|
const upper = Number.isFinite(max) ? max : '';
|
|
@@ -1721,6 +1792,7 @@ var $;
|
|
|
1721
1792
|
};
|
|
1722
1793
|
return regexp2;
|
|
1723
1794
|
}
|
|
1795
|
+
/** Makes regexp that match any of options */
|
|
1724
1796
|
static vary(sources, flags = 'gsu') {
|
|
1725
1797
|
const groups = [];
|
|
1726
1798
|
const chunks = sources.map(source => {
|
|
@@ -1730,17 +1802,21 @@ var $;
|
|
|
1730
1802
|
});
|
|
1731
1803
|
return new $mol_regexp(`(?:${chunks.join('|')})`, flags, groups);
|
|
1732
1804
|
}
|
|
1805
|
+
/** Makes regexp that allow absent of this pattern */
|
|
1733
1806
|
static optional(source) {
|
|
1734
1807
|
return $mol_regexp.repeat_greedy(source, 0, 1);
|
|
1735
1808
|
}
|
|
1809
|
+
/** Makes regexp that look ahead for pattern */
|
|
1736
1810
|
static force_after(source) {
|
|
1737
1811
|
const regexp = $mol_regexp.from(source);
|
|
1738
1812
|
return new $mol_regexp(`(?=${regexp.source})`, regexp.flags, regexp.groups);
|
|
1739
1813
|
}
|
|
1814
|
+
/** Makes regexp that look ahead for pattern */
|
|
1740
1815
|
static forbid_after(source) {
|
|
1741
1816
|
const regexp = $mol_regexp.from(source);
|
|
1742
1817
|
return new $mol_regexp(`(?!${regexp.source})`, regexp.flags, regexp.groups);
|
|
1743
1818
|
}
|
|
1819
|
+
/** Converts some js values to regexp */
|
|
1744
1820
|
static from(source, { ignoreCase, multiline } = {
|
|
1745
1821
|
ignoreCase: false,
|
|
1746
1822
|
multiline: false,
|
|
@@ -1841,9 +1917,11 @@ var $;
|
|
|
1841
1917
|
return regexp;
|
|
1842
1918
|
}
|
|
1843
1919
|
}
|
|
1920
|
+
/** Makes regexp which includes only unicode category */
|
|
1844
1921
|
static unicode_only(...category) {
|
|
1845
1922
|
return new $mol_regexp(`\\p{${category.join('=')}}`);
|
|
1846
1923
|
}
|
|
1924
|
+
/** Makes regexp which excludes unicode category */
|
|
1847
1925
|
static unicode_except(...category) {
|
|
1848
1926
|
return new $mol_regexp(`\\P{${category.join('=')}}`);
|
|
1849
1927
|
}
|
|
@@ -1967,13 +2045,23 @@ var $;
|
|
|
1967
2045
|
var $;
|
|
1968
2046
|
(function ($) {
|
|
1969
2047
|
const err = $mol_view_tree2_error_str;
|
|
2048
|
+
const is_writable = (input) => input.type.includes('?');
|
|
1970
2049
|
function $mol_view_tree2_class_props(klass) {
|
|
1971
2050
|
let props = this.$mol_view_tree2_class_super(klass);
|
|
2051
|
+
// ! syntax to * and ?val syntax to ?
|
|
1972
2052
|
props = props.clone(props.hack({
|
|
1973
2053
|
'': (node, belt) => {
|
|
1974
|
-
const
|
|
2054
|
+
const next = node.type.indexOf('?');
|
|
2055
|
+
const id = node.type.indexOf('!');
|
|
2056
|
+
let normal = node.type;
|
|
2057
|
+
const ch = node.type[id + 1];
|
|
2058
|
+
if (id !== -1 && ch?.toUpperCase() !== ch?.toLowerCase())
|
|
2059
|
+
normal = `${normal.substring(0, id)}*${next === -1 ? '' : '?'}`;
|
|
2060
|
+
else if (next !== -1)
|
|
2061
|
+
normal = normal.substring(0, next + 1);
|
|
1975
2062
|
if (node.type === normal)
|
|
1976
2063
|
return [node.clone(node.hack(belt))];
|
|
2064
|
+
console.warn(`Syntax ${node.type} is deprecated. Use ${normal} instead`);
|
|
1977
2065
|
return [node.struct(normal, node.hack(belt))];
|
|
1978
2066
|
}
|
|
1979
2067
|
}));
|
|
@@ -2010,12 +2098,26 @@ var $;
|
|
|
2010
2098
|
this.$mol_fail(err `Need a child ${operator.span}`);
|
|
2011
2099
|
if (!context.factory)
|
|
2012
2100
|
this.$mol_fail(err `Need a parent ${left.span}`);
|
|
2101
|
+
if (is_writable(left) !== is_writable(right))
|
|
2102
|
+
this.$mol_fail(err `Left and right operands are not compatible at ${operator.span}`);
|
|
2013
2103
|
add_inner(right.clone([
|
|
2014
2104
|
right.struct('=', [
|
|
2015
2105
|
context.factory.struct(context.factory.type.replace(/\*.*/, '*'), [left.clone([])]),
|
|
2016
2106
|
]),
|
|
2017
2107
|
]));
|
|
2018
2108
|
}
|
|
2109
|
+
else if (operator?.type === "<=>") {
|
|
2110
|
+
const right = operator.kids[0];
|
|
2111
|
+
if (!right)
|
|
2112
|
+
this.$mol_fail(err `Need a child ${operator.span}`);
|
|
2113
|
+
if (!is_writable(left))
|
|
2114
|
+
this.$mol_fail(err `Expected writable at ${left.span}`);
|
|
2115
|
+
if (!is_writable(right))
|
|
2116
|
+
this.$mol_fail(err `Expected writable at ${right.span}`);
|
|
2117
|
+
}
|
|
2118
|
+
else if (operator?.type === "<=" && is_writable(left)) {
|
|
2119
|
+
this.$mol_fail(err `Expected readonly at ${left.span}`);
|
|
2120
|
+
}
|
|
2019
2121
|
if (right)
|
|
2020
2122
|
context = { factory: right.clone([]) };
|
|
2021
2123
|
else if (operator && !context.factory && $mol_view_tree2_class_match(operator)) {
|
|
@@ -2155,6 +2257,7 @@ var $;
|
|
|
2155
2257
|
const left_parts = this.$mol_view_tree2_prop_parts(left);
|
|
2156
2258
|
const right_parts = this.$mol_view_tree2_prop_parts(right);
|
|
2157
2259
|
let conflict;
|
|
2260
|
+
// if (left_parts.next && right_parts.next) conflict = 'next'
|
|
2158
2261
|
if (left_parts.key && right_parts.key)
|
|
2159
2262
|
conflict = 'key';
|
|
2160
2263
|
if (conflict) {
|
|
@@ -2279,7 +2382,7 @@ var $;
|
|
|
2279
2382
|
}, context);
|
|
2280
2383
|
return prop.struct('indent', [
|
|
2281
2384
|
prop.struct('line', [
|
|
2282
|
-
channel_signature.call(this, prop, ...val),
|
|
2385
|
+
channel_signature.call(this, prop, ...val), // Parameter, not Return
|
|
2283
2386
|
prop.data(': '),
|
|
2284
2387
|
...val,
|
|
2285
2388
|
])
|
|
@@ -2320,6 +2423,7 @@ var $;
|
|
|
2320
2423
|
"use strict";
|
|
2321
2424
|
var $;
|
|
2322
2425
|
(function ($) {
|
|
2426
|
+
/** Generates unique identifier. */
|
|
2323
2427
|
function $mol_guid(length = 8, exists = () => false) {
|
|
2324
2428
|
for (;;) {
|
|
2325
2429
|
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
@@ -2335,11 +2439,16 @@ var $;
|
|
|
2335
2439
|
"use strict";
|
|
2336
2440
|
var $;
|
|
2337
2441
|
(function ($) {
|
|
2442
|
+
/** Special status statuses. */
|
|
2338
2443
|
let $mol_wire_cursor;
|
|
2339
2444
|
(function ($mol_wire_cursor) {
|
|
2445
|
+
/** Update required. */
|
|
2340
2446
|
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
2447
|
+
/** Some of (transitive) pub update required. */
|
|
2341
2448
|
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
2449
|
+
/** Actual state but may be dropped. */
|
|
2342
2450
|
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
2451
|
+
/** State will never be changed. */
|
|
2343
2452
|
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
2344
2453
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
2345
2454
|
})($ || ($ = {}));
|
|
@@ -2348,6 +2457,9 @@ var $;
|
|
|
2348
2457
|
"use strict";
|
|
2349
2458
|
var $;
|
|
2350
2459
|
(function ($) {
|
|
2460
|
+
/**
|
|
2461
|
+
* Collects subscribers in compact array. 28B
|
|
2462
|
+
*/
|
|
2351
2463
|
class $mol_wire_pub extends Object {
|
|
2352
2464
|
constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
|
|
2353
2465
|
super();
|
|
@@ -2355,10 +2467,17 @@ var $;
|
|
|
2355
2467
|
}
|
|
2356
2468
|
[Symbol.toStringTag];
|
|
2357
2469
|
data = [];
|
|
2470
|
+
// Derived objects should be Arrays.
|
|
2358
2471
|
static get [Symbol.species]() {
|
|
2359
2472
|
return Array;
|
|
2360
2473
|
}
|
|
2361
|
-
|
|
2474
|
+
/**
|
|
2475
|
+
* Index of first subscriber.
|
|
2476
|
+
*/
|
|
2477
|
+
sub_from = 0; // 4B
|
|
2478
|
+
/**
|
|
2479
|
+
* All current subscribers.
|
|
2480
|
+
*/
|
|
2362
2481
|
get sub_list() {
|
|
2363
2482
|
const res = [];
|
|
2364
2483
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
@@ -2366,14 +2485,23 @@ var $;
|
|
|
2366
2485
|
}
|
|
2367
2486
|
return res;
|
|
2368
2487
|
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Has any subscribers or not.
|
|
2490
|
+
*/
|
|
2369
2491
|
get sub_empty() {
|
|
2370
2492
|
return this.sub_from === this.data.length;
|
|
2371
2493
|
}
|
|
2494
|
+
/**
|
|
2495
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
2496
|
+
*/
|
|
2372
2497
|
sub_on(sub, pub_pos) {
|
|
2373
2498
|
const pos = this.data.length;
|
|
2374
2499
|
this.data.push(sub, pub_pos);
|
|
2375
2500
|
return pos;
|
|
2376
2501
|
}
|
|
2502
|
+
/**
|
|
2503
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
2504
|
+
*/
|
|
2377
2505
|
sub_off(sub_pos) {
|
|
2378
2506
|
if (!(sub_pos < this.data.length)) {
|
|
2379
2507
|
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
@@ -2386,21 +2514,39 @@ var $;
|
|
|
2386
2514
|
if (end === this.sub_from)
|
|
2387
2515
|
this.reap();
|
|
2388
2516
|
}
|
|
2517
|
+
/**
|
|
2518
|
+
* Called when last sub was unsubscribed.
|
|
2519
|
+
**/
|
|
2389
2520
|
reap() { }
|
|
2521
|
+
/**
|
|
2522
|
+
* Autowire this publisher with current subscriber.
|
|
2523
|
+
**/
|
|
2390
2524
|
promote() {
|
|
2391
2525
|
$mol_wire_auto()?.track_next(this);
|
|
2392
2526
|
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Enforce actualization. Should not throw errors.
|
|
2529
|
+
*/
|
|
2393
2530
|
fresh() { }
|
|
2531
|
+
/**
|
|
2532
|
+
* Allow to put data to caches in the subtree.
|
|
2533
|
+
*/
|
|
2394
2534
|
complete() { }
|
|
2395
2535
|
get incompleted() {
|
|
2396
2536
|
return false;
|
|
2397
2537
|
}
|
|
2538
|
+
/**
|
|
2539
|
+
* Notify subscribers about self changes.
|
|
2540
|
+
*/
|
|
2398
2541
|
emit(quant = $mol_wire_cursor.stale) {
|
|
2399
2542
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
2400
2543
|
;
|
|
2401
2544
|
this.data[i].absorb(quant, this.data[i + 1]);
|
|
2402
2545
|
}
|
|
2403
2546
|
}
|
|
2547
|
+
/**
|
|
2548
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
2549
|
+
*/
|
|
2404
2550
|
peer_move(from_pos, to_pos) {
|
|
2405
2551
|
const peer = this.data[from_pos];
|
|
2406
2552
|
const self_pos = this.data[from_pos + 1];
|
|
@@ -2408,6 +2554,9 @@ var $;
|
|
|
2408
2554
|
this.data[to_pos + 1] = self_pos;
|
|
2409
2555
|
peer.peer_repos(self_pos, to_pos);
|
|
2410
2556
|
}
|
|
2557
|
+
/**
|
|
2558
|
+
* Updates self position in the peer.
|
|
2559
|
+
*/
|
|
2411
2560
|
peer_repos(peer_pos, self_pos) {
|
|
2412
2561
|
this.data[peer_pos + 1] = self_pos;
|
|
2413
2562
|
}
|
|
@@ -2423,10 +2572,16 @@ var $;
|
|
|
2423
2572
|
var $;
|
|
2424
2573
|
(function ($) {
|
|
2425
2574
|
$.$mol_wire_auto_sub = null;
|
|
2575
|
+
/**
|
|
2576
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
2577
|
+
*/
|
|
2426
2578
|
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
2427
2579
|
return $.$mol_wire_auto_sub = next;
|
|
2428
2580
|
}
|
|
2429
2581
|
$.$mol_wire_auto = $mol_wire_auto;
|
|
2582
|
+
/**
|
|
2583
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
2584
|
+
*/
|
|
2430
2585
|
$.$mol_wire_affected = [];
|
|
2431
2586
|
})($ || ($ = {}));
|
|
2432
2587
|
|
|
@@ -2434,6 +2589,7 @@ var $;
|
|
|
2434
2589
|
"use strict";
|
|
2435
2590
|
var $;
|
|
2436
2591
|
(function ($) {
|
|
2592
|
+
// https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
|
|
2437
2593
|
$['devtoolsFormatters'] ||= [];
|
|
2438
2594
|
function $mol_dev_format_register(config) {
|
|
2439
2595
|
$['devtoolsFormatters'].push(config);
|
|
@@ -2485,6 +2641,7 @@ var $;
|
|
|
2485
2641
|
return false;
|
|
2486
2642
|
if (!val)
|
|
2487
2643
|
return false;
|
|
2644
|
+
// if( Error.isError( val ) ) true
|
|
2488
2645
|
if (val[$.$mol_dev_format_body])
|
|
2489
2646
|
return true;
|
|
2490
2647
|
return false;
|
|
@@ -2502,12 +2659,16 @@ var $;
|
|
|
2502
2659
|
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
2503
2660
|
}
|
|
2504
2661
|
}
|
|
2662
|
+
// if( Error.isError( val ) ) {
|
|
2663
|
+
// return $mol_dev_format_native( val )
|
|
2664
|
+
// }
|
|
2505
2665
|
return null;
|
|
2506
2666
|
},
|
|
2507
2667
|
});
|
|
2508
2668
|
function $mol_dev_format_native(obj) {
|
|
2509
2669
|
if (typeof obj === 'undefined')
|
|
2510
2670
|
return $.$mol_dev_format_shade('undefined');
|
|
2671
|
+
// if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
|
|
2511
2672
|
return [
|
|
2512
2673
|
'object',
|
|
2513
2674
|
{
|
|
@@ -2565,6 +2726,9 @@ var $;
|
|
|
2565
2726
|
'margin-left': '13px'
|
|
2566
2727
|
});
|
|
2567
2728
|
class Stack extends Array {
|
|
2729
|
+
// [ Symbol.toPrimitive ]() {
|
|
2730
|
+
// return this.toString()
|
|
2731
|
+
// }
|
|
2568
2732
|
toString() {
|
|
2569
2733
|
return this.join('\n');
|
|
2570
2734
|
}
|
|
@@ -2587,6 +2751,7 @@ var $;
|
|
|
2587
2751
|
this.method = call.getMethodName() ?? '';
|
|
2588
2752
|
if (this.method === this.function)
|
|
2589
2753
|
this.method = '';
|
|
2754
|
+
// const func = c.getFunction()
|
|
2590
2755
|
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
2591
2756
|
this.eval = call.getEvalOrigin() ?? '';
|
|
2592
2757
|
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
@@ -2633,9 +2798,16 @@ var $;
|
|
|
2633
2798
|
"use strict";
|
|
2634
2799
|
var $;
|
|
2635
2800
|
(function ($) {
|
|
2801
|
+
/**
|
|
2802
|
+
* Publisher that can auto collect other publishers. 32B
|
|
2803
|
+
*
|
|
2804
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
2805
|
+
* ^ ^
|
|
2806
|
+
* pubs_from subs_from
|
|
2807
|
+
*/
|
|
2636
2808
|
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
2637
|
-
pub_from = 0;
|
|
2638
|
-
cursor = $mol_wire_cursor.stale;
|
|
2809
|
+
pub_from = 0; // 4B
|
|
2810
|
+
cursor = $mol_wire_cursor.stale; // 4B
|
|
2639
2811
|
get temp() {
|
|
2640
2812
|
return false;
|
|
2641
2813
|
}
|
|
@@ -2753,10 +2925,27 @@ var $;
|
|
|
2753
2925
|
return;
|
|
2754
2926
|
this.cursor = quant;
|
|
2755
2927
|
this.emit($mol_wire_cursor.doubt);
|
|
2928
|
+
// if( pos >= 0 && pos < this.sub_from - 2 ) {
|
|
2929
|
+
// const pub = this.data[ pos ] as $mol_wire_pub
|
|
2930
|
+
// if( pub instanceof $mol_wire_task ) return
|
|
2931
|
+
// for(
|
|
2932
|
+
// let cursor = this.pub_from;
|
|
2933
|
+
// cursor < this.sub_from;
|
|
2934
|
+
// cursor += 2
|
|
2935
|
+
// ) {
|
|
2936
|
+
// const pub = this.data[ cursor ] as $mol_wire_pub
|
|
2937
|
+
// if( pub instanceof $mol_wire_task ) {
|
|
2938
|
+
// pub.destructor()
|
|
2939
|
+
// }
|
|
2940
|
+
// }
|
|
2941
|
+
// }
|
|
2756
2942
|
}
|
|
2757
2943
|
[$mol_dev_format_head]() {
|
|
2758
2944
|
return $mol_dev_format_native(this);
|
|
2759
2945
|
}
|
|
2946
|
+
/**
|
|
2947
|
+
* Is subscribed to any publisher or not.
|
|
2948
|
+
*/
|
|
2760
2949
|
get pub_empty() {
|
|
2761
2950
|
return this.sub_from === this.pub_from;
|
|
2762
2951
|
}
|
|
@@ -2812,6 +3001,13 @@ var $;
|
|
|
2812
3001
|
var $;
|
|
2813
3002
|
(function ($) {
|
|
2814
3003
|
const wrappers = new WeakMap();
|
|
3004
|
+
/**
|
|
3005
|
+
* Suspendable task with support both sync/async api.
|
|
3006
|
+
*
|
|
3007
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
3008
|
+
* ^ ^ ^
|
|
3009
|
+
* args_from pubs_from subs_from
|
|
3010
|
+
**/
|
|
2815
3011
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
2816
3012
|
task;
|
|
2817
3013
|
host;
|
|
@@ -2832,6 +3028,7 @@ var $;
|
|
|
2832
3028
|
});
|
|
2833
3029
|
}
|
|
2834
3030
|
static sync() {
|
|
3031
|
+
// Sync whole fiber graph
|
|
2835
3032
|
while (this.planning.size) {
|
|
2836
3033
|
for (const fiber of this.planning) {
|
|
2837
3034
|
this.planning.delete(fiber);
|
|
@@ -2842,6 +3039,7 @@ var $;
|
|
|
2842
3039
|
fiber.fresh();
|
|
2843
3040
|
}
|
|
2844
3041
|
}
|
|
3042
|
+
// Collect garbage
|
|
2845
3043
|
while (this.reaping.size) {
|
|
2846
3044
|
const fibers = this.reaping;
|
|
2847
3045
|
this.reaping = new Set;
|
|
@@ -2993,6 +3191,10 @@ var $;
|
|
|
2993
3191
|
this.cursor = $mol_wire_cursor.stale;
|
|
2994
3192
|
this.fresh();
|
|
2995
3193
|
}
|
|
3194
|
+
/**
|
|
3195
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
3196
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
3197
|
+
*/
|
|
2996
3198
|
sync() {
|
|
2997
3199
|
if (!$mol_wire_fiber.warm) {
|
|
2998
3200
|
return this.result();
|
|
@@ -3007,6 +3209,10 @@ var $;
|
|
|
3007
3209
|
}
|
|
3008
3210
|
return this.cache;
|
|
3009
3211
|
}
|
|
3212
|
+
/**
|
|
3213
|
+
* Asynchronous execution.
|
|
3214
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
3215
|
+
*/
|
|
3010
3216
|
async async_raw() {
|
|
3011
3217
|
while (true) {
|
|
3012
3218
|
this.fresh();
|
|
@@ -3019,6 +3225,7 @@ var $;
|
|
|
3019
3225
|
if (!$mol_promise_like(this.cache))
|
|
3020
3226
|
return this.cache;
|
|
3021
3227
|
if (this.cursor === $mol_wire_cursor.final) {
|
|
3228
|
+
// never ends on destructed fiber
|
|
3022
3229
|
await new Promise(() => { });
|
|
3023
3230
|
}
|
|
3024
3231
|
}
|
|
@@ -3066,6 +3273,7 @@ var $;
|
|
|
3066
3273
|
var $;
|
|
3067
3274
|
(function ($) {
|
|
3068
3275
|
const TypedArray = Object.getPrototypeOf(Uint8Array);
|
|
3276
|
+
/** Returns string key for any value. */
|
|
3069
3277
|
function $mol_key(value) {
|
|
3070
3278
|
primitives: {
|
|
3071
3279
|
if (typeof value === 'bigint')
|
|
@@ -3073,9 +3281,9 @@ var $;
|
|
|
3073
3281
|
if (typeof value === 'symbol')
|
|
3074
3282
|
return `Symbol(${value.description})`;
|
|
3075
3283
|
if (!value)
|
|
3076
|
-
return JSON.stringify(value);
|
|
3284
|
+
return JSON.stringify(value); // 0, null, ""
|
|
3077
3285
|
if (typeof value !== 'object' && typeof value !== 'function')
|
|
3078
|
-
return JSON.stringify(value);
|
|
3286
|
+
return JSON.stringify(value); // boolean, number, string
|
|
3079
3287
|
}
|
|
3080
3288
|
caching: {
|
|
3081
3289
|
let key = $mol_key_store.get(value);
|
|
@@ -3153,6 +3361,10 @@ var $;
|
|
|
3153
3361
|
var $;
|
|
3154
3362
|
(function ($) {
|
|
3155
3363
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
3364
|
+
/**
|
|
3365
|
+
* Deeply compares two values. Returns true if equal.
|
|
3366
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
3367
|
+
*/
|
|
3156
3368
|
function $mol_compare_deep(left, right) {
|
|
3157
3369
|
if (Object.is(left, right))
|
|
3158
3370
|
return true;
|
|
@@ -3292,6 +3504,7 @@ var $;
|
|
|
3292
3504
|
"use strict";
|
|
3293
3505
|
var $;
|
|
3294
3506
|
(function ($) {
|
|
3507
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
3295
3508
|
function $mol_log3_area_lazy(event) {
|
|
3296
3509
|
const self = this.$;
|
|
3297
3510
|
const stack = self.$mol_log3_stack;
|
|
@@ -3316,6 +3529,7 @@ var $;
|
|
|
3316
3529
|
"use strict";
|
|
3317
3530
|
var $;
|
|
3318
3531
|
(function ($) {
|
|
3532
|
+
/** Module for working with terminal. Text coloring when output in terminal */
|
|
3319
3533
|
class $mol_term_color {
|
|
3320
3534
|
static reset = this.ansi(0, 0);
|
|
3321
3535
|
static bold = this.ansi(1, 22);
|
|
@@ -3387,6 +3601,7 @@ var $;
|
|
|
3387
3601
|
"use strict";
|
|
3388
3602
|
var $;
|
|
3389
3603
|
(function ($) {
|
|
3604
|
+
/** One-shot fiber */
|
|
3390
3605
|
class $mol_wire_task extends $mol_wire_fiber {
|
|
3391
3606
|
static getter(task) {
|
|
3392
3607
|
return function $mol_wire_task_get(host, args) {
|
|
@@ -3412,6 +3627,7 @@ var $;
|
|
|
3412
3627
|
}
|
|
3413
3628
|
const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
|
|
3414
3629
|
const next = new $mol_wire_task(key, task, host, args);
|
|
3630
|
+
// Disabled because non-idempotency is required for try-catch
|
|
3415
3631
|
if (existen?.temp) {
|
|
3416
3632
|
$$.$mol_log3_warn({
|
|
3417
3633
|
place: '$mol_wire_task',
|
|
@@ -3444,7 +3660,7 @@ var $;
|
|
|
3444
3660
|
try {
|
|
3445
3661
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
3446
3662
|
}
|
|
3447
|
-
catch {
|
|
3663
|
+
catch { // Promises throw in strict mode
|
|
3448
3664
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
3449
3665
|
}
|
|
3450
3666
|
}
|
|
@@ -3469,6 +3685,9 @@ var $;
|
|
|
3469
3685
|
"use strict";
|
|
3470
3686
|
var $;
|
|
3471
3687
|
(function ($) {
|
|
3688
|
+
/**
|
|
3689
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
3690
|
+
*/
|
|
3472
3691
|
function $mol_wire_method(host, field, descr) {
|
|
3473
3692
|
if (!descr)
|
|
3474
3693
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -3550,6 +3769,7 @@ var $;
|
|
|
3550
3769
|
"use strict";
|
|
3551
3770
|
var $;
|
|
3552
3771
|
(function ($) {
|
|
3772
|
+
/** Long-living fiber. */
|
|
3553
3773
|
class $mol_wire_atom extends $mol_wire_fiber {
|
|
3554
3774
|
static solo(host, task) {
|
|
3555
3775
|
const field = task.name + '()';
|
|
@@ -3600,7 +3820,11 @@ var $;
|
|
|
3600
3820
|
}
|
|
3601
3821
|
$mol_wire_atom.watching.add(this);
|
|
3602
3822
|
}
|
|
3823
|
+
/**
|
|
3824
|
+
* Update atom value through another temp fiber.
|
|
3825
|
+
*/
|
|
3603
3826
|
resync(args) {
|
|
3827
|
+
// enforce pulling tasks abort
|
|
3604
3828
|
for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
|
|
3605
3829
|
const pub = this.data[cursor];
|
|
3606
3830
|
if (pub && pub instanceof $mol_wire_task) {
|
|
@@ -3661,7 +3885,7 @@ var $;
|
|
|
3661
3885
|
try {
|
|
3662
3886
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
3663
3887
|
}
|
|
3664
|
-
catch {
|
|
3888
|
+
catch { // Promises throw in strict mode
|
|
3665
3889
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
3666
3890
|
}
|
|
3667
3891
|
}
|
|
@@ -3689,6 +3913,7 @@ var $;
|
|
|
3689
3913
|
"use strict";
|
|
3690
3914
|
var $;
|
|
3691
3915
|
(function ($) {
|
|
3916
|
+
/** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
|
|
3692
3917
|
function $mol_wire_solo(host, field, descr) {
|
|
3693
3918
|
if (!descr)
|
|
3694
3919
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -3727,6 +3952,7 @@ var $;
|
|
|
3727
3952
|
"use strict";
|
|
3728
3953
|
var $;
|
|
3729
3954
|
(function ($) {
|
|
3955
|
+
/** Reactive memoizing multiplexed property decorator. */
|
|
3730
3956
|
function $mol_wire_plex(host, field, descr) {
|
|
3731
3957
|
if (!descr)
|
|
3732
3958
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -3765,7 +3991,25 @@ var $;
|
|
|
3765
3991
|
"use strict";
|
|
3766
3992
|
var $;
|
|
3767
3993
|
(function ($) {
|
|
3994
|
+
/**
|
|
3995
|
+
* Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
|
|
3996
|
+
* @example
|
|
3997
|
+
* '@' $mol_mem
|
|
3998
|
+
* name(next?: string) {
|
|
3999
|
+
* return next ?? 'default'
|
|
4000
|
+
* }
|
|
4001
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
4002
|
+
*/
|
|
3768
4003
|
$.$mol_mem = $mol_wire_solo;
|
|
4004
|
+
/**
|
|
4005
|
+
* Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
|
|
4006
|
+
* @example
|
|
4007
|
+
* '@' $mol_mem_key
|
|
4008
|
+
* name(id: number, next?: string) {
|
|
4009
|
+
* return next ?? 'default'
|
|
4010
|
+
* }
|
|
4011
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
4012
|
+
*/
|
|
3769
4013
|
$.$mol_mem_key = $mol_wire_plex;
|
|
3770
4014
|
})($ || ($ = {}));
|
|
3771
4015
|
|
|
@@ -3782,7 +4026,7 @@ var $;
|
|
|
3782
4026
|
"use strict";
|
|
3783
4027
|
var $;
|
|
3784
4028
|
(function ($) {
|
|
3785
|
-
const mod = require('module');
|
|
4029
|
+
const mod = require /****/('module');
|
|
3786
4030
|
const internals = mod.builtinModules;
|
|
3787
4031
|
function $node_internal_check(name) {
|
|
3788
4032
|
if (name.startsWith('node:'))
|
|
@@ -3796,8 +4040,8 @@ var $;
|
|
|
3796
4040
|
"use strict";
|
|
3797
4041
|
var $;
|
|
3798
4042
|
(function ($) {
|
|
3799
|
-
const path = require('path');
|
|
3800
|
-
const mod = require('module');
|
|
4043
|
+
const path = require /****/('path');
|
|
4044
|
+
const mod = require /****/('module');
|
|
3801
4045
|
const localRequire = mod.createRequire(path.join(process.cwd(), 'package.json'));
|
|
3802
4046
|
function $node_autoinstall(name) {
|
|
3803
4047
|
try {
|
|
@@ -3872,6 +4116,7 @@ var $;
|
|
|
3872
4116
|
])
|
|
3873
4117
|
].map(frame_normalize).join('\n')
|
|
3874
4118
|
});
|
|
4119
|
+
// в nodejs, что б не дублировалось cause в консоли
|
|
3875
4120
|
Object.defineProperty(this, 'cause', {
|
|
3876
4121
|
get: () => cause
|
|
3877
4122
|
});
|
|
@@ -3940,6 +4185,10 @@ var $;
|
|
|
3940
4185
|
props[field] = get_val;
|
|
3941
4186
|
return get_val;
|
|
3942
4187
|
}
|
|
4188
|
+
/**
|
|
4189
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
4190
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
4191
|
+
*/
|
|
3943
4192
|
function $mol_wire_sync(obj) {
|
|
3944
4193
|
return new Proxy(obj, {
|
|
3945
4194
|
get(obj, field) {
|
|
@@ -4101,6 +4350,9 @@ var $;
|
|
|
4101
4350
|
"use strict";
|
|
4102
4351
|
var $;
|
|
4103
4352
|
(function ($) {
|
|
4353
|
+
/**
|
|
4354
|
+
* Disable reaping of current subscriber
|
|
4355
|
+
*/
|
|
4104
4356
|
function $mol_wire_solid() {
|
|
4105
4357
|
let current = $mol_wire_auto();
|
|
4106
4358
|
if (current.temp)
|
|
@@ -4126,6 +4378,7 @@ var $;
|
|
|
4126
4378
|
"use strict";
|
|
4127
4379
|
var $;
|
|
4128
4380
|
(function ($) {
|
|
4381
|
+
/** Run code without state changes */
|
|
4129
4382
|
function $mol_wire_probe(task, def) {
|
|
4130
4383
|
const warm = $mol_wire_fiber.warm;
|
|
4131
4384
|
try {
|
|
@@ -4284,6 +4537,11 @@ var $;
|
|
|
4284
4537
|
"use strict";
|
|
4285
4538
|
var $;
|
|
4286
4539
|
(function ($) {
|
|
4540
|
+
/**
|
|
4541
|
+
* Returns closure that returns constant value.
|
|
4542
|
+
* @example
|
|
4543
|
+
* const rnd = $mol_const( Math.random() )
|
|
4544
|
+
*/
|
|
4287
4545
|
function $mol_const(value) {
|
|
4288
4546
|
const getter = (() => value);
|
|
4289
4547
|
getter['()'] = value;
|
|
@@ -4298,6 +4556,10 @@ var $;
|
|
|
4298
4556
|
"use strict";
|
|
4299
4557
|
var $;
|
|
4300
4558
|
(function ($) {
|
|
4559
|
+
/**
|
|
4560
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
|
|
4561
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
4562
|
+
*/
|
|
4301
4563
|
$.$mol_action = $mol_wire_method;
|
|
4302
4564
|
})($ || ($ = {}));
|
|
4303
4565
|
|
|
@@ -4305,6 +4567,7 @@ var $;
|
|
|
4305
4567
|
"use strict";
|
|
4306
4568
|
var $;
|
|
4307
4569
|
(function ($) {
|
|
4570
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
4308
4571
|
function $mol_wire_async(obj) {
|
|
4309
4572
|
let fiber;
|
|
4310
4573
|
const temp = $mol_wire_task.getter(obj);
|
|
@@ -4404,7 +4667,8 @@ var $;
|
|
|
4404
4667
|
"use strict";
|
|
4405
4668
|
var $;
|
|
4406
4669
|
(function ($) {
|
|
4407
|
-
let buf = new Uint8Array(2 ** 12);
|
|
4670
|
+
let buf = new Uint8Array(2 ** 12); // 4KB Mem Page
|
|
4671
|
+
/** Temporary buffer. Recursive usage isn't supported. */
|
|
4408
4672
|
function $mol_charset_buffer(size) {
|
|
4409
4673
|
if (buf.byteLength < size)
|
|
4410
4674
|
buf = new Uint8Array(size);
|
|
@@ -4426,19 +4690,19 @@ var $;
|
|
|
4426
4690
|
let pos = from;
|
|
4427
4691
|
for (let i = 0; i < str.length; i++) {
|
|
4428
4692
|
let code = str.charCodeAt(i);
|
|
4429
|
-
if (code < 0x80) {
|
|
4693
|
+
if (code < 0x80) { // ASCII - 1 octet
|
|
4430
4694
|
buf[pos++] = code;
|
|
4431
4695
|
}
|
|
4432
|
-
else if (code < 0x800) {
|
|
4696
|
+
else if (code < 0x800) { // 2 octet
|
|
4433
4697
|
buf[pos++] = 0xc0 | (code >> 6);
|
|
4434
4698
|
buf[pos++] = 0x80 | (code & 0x3f);
|
|
4435
4699
|
}
|
|
4436
|
-
else if (code < 0xd800 || code >= 0xe000) {
|
|
4700
|
+
else if (code < 0xd800 || code >= 0xe000) { // 3 octet
|
|
4437
4701
|
buf[pos++] = 0xe0 | (code >> 12);
|
|
4438
4702
|
buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
|
|
4439
4703
|
buf[pos++] = 0x80 | (code & 0x3f);
|
|
4440
4704
|
}
|
|
4441
|
-
else {
|
|
4705
|
+
else { // surrogate pair
|
|
4442
4706
|
const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
|
|
4443
4707
|
buf[pos++] = 0xf0 | (point >> 18);
|
|
4444
4708
|
buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
|
|
@@ -4502,12 +4766,16 @@ var $;
|
|
|
4502
4766
|
(function ($) {
|
|
4503
4767
|
let file_modes;
|
|
4504
4768
|
(function (file_modes) {
|
|
4769
|
+
/** create if it doesn't already exist */
|
|
4505
4770
|
file_modes[file_modes["create"] = $node.fs.constants.O_CREAT] = "create";
|
|
4771
|
+
/** truncate to zero size if it already exists */
|
|
4506
4772
|
file_modes[file_modes["exists_truncate"] = $node.fs.constants.O_TRUNC] = "exists_truncate";
|
|
4773
|
+
/** throw exception if it already exists */
|
|
4507
4774
|
file_modes[file_modes["exists_fail"] = $node.fs.constants.O_EXCL] = "exists_fail";
|
|
4508
4775
|
file_modes[file_modes["read_only"] = $node.fs.constants.O_RDONLY] = "read_only";
|
|
4509
4776
|
file_modes[file_modes["write_only"] = $node.fs.constants.O_WRONLY] = "write_only";
|
|
4510
4777
|
file_modes[file_modes["read_write"] = $node.fs.constants.O_RDWR] = "read_write";
|
|
4778
|
+
/** data will be appended to the end */
|
|
4511
4779
|
file_modes[file_modes["append"] = $node.fs.constants.O_APPEND] = "append";
|
|
4512
4780
|
})(file_modes || (file_modes = {}));
|
|
4513
4781
|
function mode_mask(modes) {
|
|
@@ -4572,12 +4840,24 @@ var $;
|
|
|
4572
4840
|
root() {
|
|
4573
4841
|
const path = this.path();
|
|
4574
4842
|
const base = this.constructor.base;
|
|
4843
|
+
// Если путь выше или равен base или если parent такойже как и this - считаем это корнем
|
|
4575
4844
|
return base.startsWith(path) || this == this.parent();
|
|
4576
4845
|
}
|
|
4577
4846
|
stat(next, virt) {
|
|
4578
4847
|
const path = this.path();
|
|
4579
4848
|
const parent = this.parent();
|
|
4849
|
+
// Отслеживать проверку наличия родительской папки не стоит до корня диска
|
|
4850
|
+
// Лучше ограничить mam-ом
|
|
4580
4851
|
if (!this.root()) {
|
|
4852
|
+
/*
|
|
4853
|
+
Если parent папка удалилась, надо ресетнуть все объекты в ней на любой глубине.
|
|
4854
|
+
Например, rm -rf с последующим git pull: parent папка может удалиться, потом создасться,
|
|
4855
|
+
а текущая папка успеет только удалиться до момента выполнения stat.
|
|
4856
|
+
Поэтому parent.exists() не запустит перевычисления, нужна именно parent.version()
|
|
4857
|
+
|
|
4858
|
+
Однако, parent.version() меняется не только при удалении, будет ложное срабатывание
|
|
4859
|
+
С этим придется мириться, красивого решения пока нет.
|
|
4860
|
+
*/
|
|
4581
4861
|
parent.version();
|
|
4582
4862
|
}
|
|
4583
4863
|
parent.watcher();
|
|
@@ -4591,9 +4871,19 @@ var $;
|
|
|
4591
4871
|
if (/([\/\\]\.|___$)/.test(path))
|
|
4592
4872
|
return;
|
|
4593
4873
|
const file = this.relative(path.at(-1) === '/' ? path.slice(0, -1) : path);
|
|
4874
|
+
// console.log(type, path)
|
|
4875
|
+
// add (change): добавился файл - у parent надо обновить список sub, если он был заюзан
|
|
4876
|
+
// change, unlink (rename): обновился или удалился файл - ресетим
|
|
4877
|
+
// addDir (change), добавилась папка, у parent обновляем список директорий в sub
|
|
4878
|
+
// дочерние ресетим
|
|
4879
|
+
// unlinkDir (rename), удалилась папка, ресетим ее
|
|
4880
|
+
// stat у всех дочерних обновится сам, т.к. связан с parent.version()
|
|
4594
4881
|
this.changed.add(file);
|
|
4595
4882
|
if (!this.watching)
|
|
4596
4883
|
return;
|
|
4884
|
+
// throttle, пока события поступают не сбрасываем.
|
|
4885
|
+
// аналог awaitWriteFinish из chokidar
|
|
4886
|
+
// интервалы между change-сообщениями модифицируемого файла должны быть меньше watch_debounce
|
|
4597
4887
|
this.frame?.destructor();
|
|
4598
4888
|
this.frame = new this.$.$mol_after_timeout(this.watch_debounce(), () => {
|
|
4599
4889
|
if (!this.watching)
|
|
@@ -4602,8 +4892,16 @@ var $;
|
|
|
4602
4892
|
$mol_wire_async(this).flush();
|
|
4603
4893
|
});
|
|
4604
4894
|
}
|
|
4895
|
+
/**
|
|
4896
|
+
* Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
|
|
4897
|
+
* Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
|
|
4898
|
+
*/
|
|
4605
4899
|
static watch_debounce() { return 500; }
|
|
4606
4900
|
static flush() {
|
|
4901
|
+
// Пока flush работает, вотчер сюда не заходит, но может добавлять новые изменения
|
|
4902
|
+
// на каждом перезапуске они применятся
|
|
4903
|
+
// Пока run выполняется, изменения накапливаются, в конце run вызывается flush
|
|
4904
|
+
// Пока применяются изменения, run должен ожидать конца flush
|
|
4607
4905
|
for (const file of this.changed) {
|
|
4608
4906
|
const parent = file.parent();
|
|
4609
4907
|
try {
|
|
@@ -4618,16 +4916,32 @@ var $;
|
|
|
4618
4916
|
}
|
|
4619
4917
|
this.changed.clear();
|
|
4620
4918
|
this.watching = true;
|
|
4919
|
+
// this.watch_wd?.destructor()
|
|
4920
|
+
// this.watch_wd = null
|
|
4621
4921
|
}
|
|
4622
4922
|
static watching = true;
|
|
4623
4923
|
static lock = new $mol_lock;
|
|
4624
4924
|
static watch_off(path) {
|
|
4625
4925
|
this.watching = false;
|
|
4926
|
+
// run должен ожидать конца flush
|
|
4626
4927
|
this.flush();
|
|
4627
4928
|
this.watching = false;
|
|
4929
|
+
/*
|
|
4930
|
+
watch запаздывает и событие может прилететь через 3 сек после окончания сайд эффекта
|
|
4931
|
+
поэтому добавляем папку, которую меняет side_effect
|
|
4932
|
+
Когда дойдет до выполнения flush, он ресетнет ее
|
|
4933
|
+
|
|
4934
|
+
Иначе будут лишние срабатывания
|
|
4935
|
+
Например, удалили hyoo/board, watch ресетит и exists начинает отдавать false, срабатывает git clone
|
|
4936
|
+
Сразу после него событие addDir еще не успело прийти,
|
|
4937
|
+
на следующем перезапуске вызывается git pull, т.к.
|
|
4938
|
+
с точки зрения реактивной системы hyoo/board еще не существует.
|
|
4939
|
+
*/
|
|
4628
4940
|
this.changed.add(this.absolute(path));
|
|
4629
4941
|
}
|
|
4942
|
+
// protected static watch_wd = null as null | $mol_after_timeout
|
|
4630
4943
|
static unwatched(side_effect, affected_dir) {
|
|
4944
|
+
// ждем, пока выполнится предыдущий unwatched
|
|
4631
4945
|
const unlock = this.lock.grab();
|
|
4632
4946
|
this.watch_off(affected_dir);
|
|
4633
4947
|
try {
|
|
@@ -4650,6 +4964,7 @@ var $;
|
|
|
4650
4964
|
modified() { return this.stat()?.mtime ?? null; }
|
|
4651
4965
|
version() {
|
|
4652
4966
|
const next = this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? '';
|
|
4967
|
+
// console.log('version', next, this.path())
|
|
4653
4968
|
return next;
|
|
4654
4969
|
}
|
|
4655
4970
|
info(path) { return null; }
|
|
@@ -4667,15 +4982,19 @@ var $;
|
|
|
4667
4982
|
writable(opts) {
|
|
4668
4983
|
return new WritableStream;
|
|
4669
4984
|
}
|
|
4985
|
+
// open( ... modes: readonly $mol_file_mode[] ) { return 0 }
|
|
4670
4986
|
buffer(next) {
|
|
4987
|
+
// Если версия пустая - возвращаем пустой буфер
|
|
4671
4988
|
let readed = new Uint8Array();
|
|
4672
4989
|
if (next === undefined) {
|
|
4990
|
+
// Если меняется версия файла, буфер надо перечитать
|
|
4673
4991
|
if (this.version())
|
|
4674
4992
|
readed = this.read();
|
|
4675
4993
|
}
|
|
4676
4994
|
const prev = $mol_mem_cached(() => this.buffer());
|
|
4677
4995
|
const changed = prev === undefined || !$mol_compare_array(prev, next ?? readed);
|
|
4678
4996
|
if (prev !== undefined && changed) {
|
|
4997
|
+
// Логируем, если повторно читаем/пишем и буфер поменялся
|
|
4679
4998
|
this.$.$mol_log3_rise({
|
|
4680
4999
|
place: `$mol_file_node.buffer()`,
|
|
4681
5000
|
message: 'Changed',
|
|
@@ -4684,6 +5003,11 @@ var $;
|
|
|
4684
5003
|
}
|
|
4685
5004
|
if (next === undefined)
|
|
4686
5005
|
return changed ? readed : prev;
|
|
5006
|
+
// Если буфер при записи не поменялся и файл не удаляли перед этим - не записываем новую версию.
|
|
5007
|
+
// Если записывать, это приведет к смене mtime и вотчер снова триггернется, даже если содержимое файла не поменялось.
|
|
5008
|
+
// В этом алгоритме есть изъян.
|
|
5009
|
+
// Если файл записали, потом отключили вотчер, кто-то из вне его поменял, потом включили вотчер, снова записали тот же буфер,
|
|
5010
|
+
// то буфер не запишется на диск, т.к. кэш не консистентен с диском.
|
|
4687
5011
|
if (!changed && this.exists())
|
|
4688
5012
|
return prev;
|
|
4689
5013
|
this.parent().exists(true);
|
|
@@ -4719,13 +5043,21 @@ var $;
|
|
|
4719
5043
|
}
|
|
4720
5044
|
return null;
|
|
4721
5045
|
}
|
|
5046
|
+
// static watch_root = ''
|
|
5047
|
+
// static watcher_warned = false
|
|
4722
5048
|
watcher() {
|
|
5049
|
+
// const constructor = this.constructor as typeof $mol_file_base
|
|
5050
|
+
// if (! constructor.watcher_warned) {
|
|
5051
|
+
// console.warn(`${constructor}.watcher() not implemented`)
|
|
5052
|
+
// constructor.watcher_warned = true
|
|
5053
|
+
// }
|
|
4723
5054
|
return {
|
|
4724
5055
|
destructor() { }
|
|
4725
5056
|
};
|
|
4726
5057
|
}
|
|
4727
5058
|
exists(next) {
|
|
4728
5059
|
const exists = Boolean(this.stat());
|
|
5060
|
+
// console.log('exists current', exists, 'next', next, this.path())
|
|
4729
5061
|
if (next === undefined)
|
|
4730
5062
|
return exists;
|
|
4731
5063
|
if (next === exists)
|
|
@@ -4751,6 +5083,10 @@ var $;
|
|
|
4751
5083
|
return match ? match[1].substring(1) : '';
|
|
4752
5084
|
}
|
|
4753
5085
|
text(next, virt) {
|
|
5086
|
+
// Если записываем text, и вотчер ресетнул записанный файл,
|
|
5087
|
+
// то надо снова его обновить, вызвать логику, которая делала пуш в text.
|
|
5088
|
+
// Например файл удалили, потом снова создали, версия поменялась - перезаписываем
|
|
5089
|
+
// Если использовать version, то вновь созданный файл, через вотчер запустит свое пересоздание
|
|
4754
5090
|
if (next !== undefined)
|
|
4755
5091
|
this.exists();
|
|
4756
5092
|
return this.text_int(next, virt);
|
|
@@ -4775,6 +5111,7 @@ var $;
|
|
|
4775
5111
|
if (this.type() !== 'dir')
|
|
4776
5112
|
return [];
|
|
4777
5113
|
this.version();
|
|
5114
|
+
// Если дочерний file удалился, список надо обновить
|
|
4778
5115
|
return this.kids().filter(file => file.exists());
|
|
4779
5116
|
}
|
|
4780
5117
|
resolve(path) {
|
|
@@ -4919,10 +5256,15 @@ var $;
|
|
|
4919
5256
|
watcher(reset) {
|
|
4920
5257
|
const path = this.path();
|
|
4921
5258
|
const root = this.root();
|
|
5259
|
+
// Если папки/файла нет, watch упадет с ошибкой
|
|
5260
|
+
// exists обратится к parent.version и parent.watcher
|
|
5261
|
+
// Поэтому у root-папки и выше не надо вызывать exists, иначе поднимется выше base до корня диска
|
|
5262
|
+
// exists вызывать надо, что б пересоздавать вотчер при появлении папки или файла
|
|
4922
5263
|
if (!root && !this.exists())
|
|
4923
5264
|
return super.watcher();
|
|
4924
5265
|
let watcher;
|
|
4925
5266
|
try {
|
|
5267
|
+
// Между exists и watch файл может удалиться, в любом случае надо обрабатывать ENOENT
|
|
4926
5268
|
watcher = $node.fs.watch(path);
|
|
4927
5269
|
}
|
|
4928
5270
|
catch (error) {
|
|
@@ -4932,6 +5274,8 @@ var $;
|
|
|
4932
5274
|
if (root || error.code !== 'ENOENT') {
|
|
4933
5275
|
this.$.$mol_fail_log(error);
|
|
4934
5276
|
}
|
|
5277
|
+
// Если файла нет - вотчер не создается, создастся потом, когда exists поменяется на true.
|
|
5278
|
+
// Если создание упало с другой ошибкой - не ломаем работу mol_file, деградируем до не реактивной fs.
|
|
4935
5279
|
return super.watcher();
|
|
4936
5280
|
}
|
|
4937
5281
|
watcher.on('change', (type, name) => {
|
|
@@ -4943,6 +5287,7 @@ var $;
|
|
|
4943
5287
|
watcher.on('error', e => this.$.$mol_fail_log(e));
|
|
4944
5288
|
let destructed = false;
|
|
4945
5289
|
watcher.on('close', () => {
|
|
5290
|
+
// Если в процессе работы вотчер сам закрылся, надо его переоткрыть
|
|
4946
5291
|
if (!destructed)
|
|
4947
5292
|
setTimeout(() => $mol_wire_async(this).watcher(null), 500);
|
|
4948
5293
|
});
|
|
@@ -5124,6 +5469,10 @@ var $;
|
|
|
5124
5469
|
"use strict";
|
|
5125
5470
|
var $;
|
|
5126
5471
|
(function ($) {
|
|
5472
|
+
/**
|
|
5473
|
+
* Localisation in $mol framework
|
|
5474
|
+
* @see https://mol.hyoo.ru/#!section=docs/=s5aqnb_odub8l
|
|
5475
|
+
*/
|
|
5127
5476
|
class $mol_locale extends $mol_object {
|
|
5128
5477
|
static lang_default() {
|
|
5129
5478
|
return 'en';
|
|
@@ -5273,12 +5622,14 @@ var $;
|
|
|
5273
5622
|
'=>': bind => [],
|
|
5274
5623
|
'^': (ref, belt, context) => [
|
|
5275
5624
|
ref.struct('...', [
|
|
5625
|
+
// prop ^ foo
|
|
5276
5626
|
ref.kids[0]?.type
|
|
5277
5627
|
? ref.struct('()', [
|
|
5278
5628
|
ref.struct('this'),
|
|
5279
5629
|
ref.struct('[]', [ref.data(name_of.call(this, ref.kids[0]))]),
|
|
5280
5630
|
args_of.call(this, ref.kids[0])
|
|
5281
5631
|
])
|
|
5632
|
+
// Having $having foo / ^
|
|
5282
5633
|
: context.chain
|
|
5283
5634
|
? ref.struct('()', [
|
|
5284
5635
|
ref.struct('this'),
|
|
@@ -5290,6 +5641,7 @@ var $;
|
|
|
5290
5641
|
ref.struct('(,)', [ref.struct('obj')]),
|
|
5291
5642
|
...context.chain.slice(1).map(field => ref.struct('[]', [ref.data(field)]))
|
|
5292
5643
|
])
|
|
5644
|
+
// prop ^
|
|
5293
5645
|
: ref.struct('()', [
|
|
5294
5646
|
ref.struct('super'),
|
|
5295
5647
|
ref.struct('[]', [ref.data(name)]),
|
|
@@ -5714,6 +6066,12 @@ var $;
|
|
|
5714
6066
|
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
5715
6067
|
};
|
|
5716
6068
|
$.$mol_jsx_frag = '';
|
|
6069
|
+
/**
|
|
6070
|
+
* JSX adapter that makes DOM tree.
|
|
6071
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
6072
|
+
* Ensures all local ids are unique.
|
|
6073
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
6074
|
+
*/
|
|
5717
6075
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
5718
6076
|
const id = props && props.id || '';
|
|
5719
6077
|
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
@@ -5824,6 +6182,8 @@ var $;
|
|
|
5824
6182
|
|
|
5825
6183
|
;
|
|
5826
6184
|
"use strict";
|
|
6185
|
+
/** @jsx $mol_jsx */
|
|
6186
|
+
/** @jsxFrag $mol_jsx_frag */
|
|
5827
6187
|
var $;
|
|
5828
6188
|
(function ($) {
|
|
5829
6189
|
$mol_test({
|
|
@@ -5929,6 +6289,7 @@ var $;
|
|
|
5929
6289
|
"use strict";
|
|
5930
6290
|
var $;
|
|
5931
6291
|
(function ($) {
|
|
6292
|
+
/** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
|
|
5932
6293
|
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
5933
6294
|
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
5934
6295
|
if (typeof item !== 'function') {
|
|
@@ -5977,6 +6338,7 @@ var $;
|
|
|
5977
6338
|
}
|
|
5978
6339
|
$.$mol_range2 = $mol_range2;
|
|
5979
6340
|
class $mol_range2_array extends Array {
|
|
6341
|
+
// Lazy
|
|
5980
6342
|
concat(...tail) {
|
|
5981
6343
|
if (tail.length === 0)
|
|
5982
6344
|
return this;
|
|
@@ -5988,6 +6350,7 @@ var $;
|
|
|
5988
6350
|
}
|
|
5989
6351
|
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
5990
6352
|
}
|
|
6353
|
+
// Lazy
|
|
5991
6354
|
filter(check, context) {
|
|
5992
6355
|
const filtered = [];
|
|
5993
6356
|
let cursor = -1;
|
|
@@ -6000,13 +6363,16 @@ var $;
|
|
|
6000
6363
|
return filtered[index];
|
|
6001
6364
|
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
6002
6365
|
}
|
|
6366
|
+
// Diligent
|
|
6003
6367
|
forEach(proceed, context) {
|
|
6004
6368
|
for (let [key, value] of this.entries())
|
|
6005
6369
|
proceed.call(context, value, key, this);
|
|
6006
6370
|
}
|
|
6371
|
+
// Lazy
|
|
6007
6372
|
map(proceed, context) {
|
|
6008
6373
|
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
6009
6374
|
}
|
|
6375
|
+
// Diligent
|
|
6010
6376
|
reduce(merge, result) {
|
|
6011
6377
|
let index = 0;
|
|
6012
6378
|
if (arguments.length === 1) {
|
|
@@ -6017,12 +6383,15 @@ var $;
|
|
|
6017
6383
|
}
|
|
6018
6384
|
return result;
|
|
6019
6385
|
}
|
|
6386
|
+
// Lazy
|
|
6020
6387
|
toReversed() {
|
|
6021
6388
|
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
6022
6389
|
}
|
|
6390
|
+
// Lazy
|
|
6023
6391
|
slice(from = 0, to = this.length) {
|
|
6024
6392
|
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
6025
6393
|
}
|
|
6394
|
+
// Lazy
|
|
6026
6395
|
some(check, context) {
|
|
6027
6396
|
for (let index = 0; index < this.length; ++index) {
|
|
6028
6397
|
if (check.call(context, this[index], index, this))
|
|
@@ -6215,6 +6584,7 @@ var $;
|
|
|
6215
6584
|
|
|
6216
6585
|
;
|
|
6217
6586
|
"use strict";
|
|
6587
|
+
/** @jsx $mol_jsx */
|
|
6218
6588
|
var $;
|
|
6219
6589
|
(function ($) {
|
|
6220
6590
|
$mol_test({
|
|
@@ -6276,6 +6646,7 @@ var $;
|
|
|
6276
6646
|
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
6277
6647
|
obj1.obj3 = obj3;
|
|
6278
6648
|
obj1_copy.obj3 = obj3_copy;
|
|
6649
|
+
// warmup cache
|
|
6279
6650
|
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
6280
6651
|
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
6281
6652
|
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
@@ -6345,18 +6716,34 @@ var $;
|
|
|
6345
6716
|
"use strict";
|
|
6346
6717
|
var $;
|
|
6347
6718
|
(function ($) {
|
|
6719
|
+
/**
|
|
6720
|
+
* Argument must be Truthy
|
|
6721
|
+
* @deprecated use $mol_assert_equal instead
|
|
6722
|
+
*/
|
|
6348
6723
|
function $mol_assert_ok(value) {
|
|
6349
6724
|
if (value)
|
|
6350
6725
|
return;
|
|
6351
6726
|
$mol_fail(new Error(`${value} ≠ true`));
|
|
6352
6727
|
}
|
|
6353
6728
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
6729
|
+
/**
|
|
6730
|
+
* Argument must be Falsy
|
|
6731
|
+
* @deprecated use $mol_assert_equal instead
|
|
6732
|
+
*/
|
|
6354
6733
|
function $mol_assert_not(value) {
|
|
6355
6734
|
if (!value)
|
|
6356
6735
|
return;
|
|
6357
6736
|
$mol_fail(new Error(`${value} ≠ false`));
|
|
6358
6737
|
}
|
|
6359
6738
|
$.$mol_assert_not = $mol_assert_not;
|
|
6739
|
+
/**
|
|
6740
|
+
* Handler must throw an error.
|
|
6741
|
+
* @example
|
|
6742
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
|
|
6743
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
|
|
6744
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
|
|
6745
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
6746
|
+
*/
|
|
6360
6747
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
6361
6748
|
const fail = $.$mol_fail;
|
|
6362
6749
|
try {
|
|
@@ -6379,10 +6766,18 @@ var $;
|
|
|
6379
6766
|
$mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
|
|
6380
6767
|
}
|
|
6381
6768
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
6769
|
+
/** @deprecated Use $mol_assert_equal */
|
|
6382
6770
|
function $mol_assert_like(...args) {
|
|
6383
6771
|
$mol_assert_equal(...args);
|
|
6384
6772
|
}
|
|
6385
6773
|
$.$mol_assert_like = $mol_assert_like;
|
|
6774
|
+
/**
|
|
6775
|
+
* All arguments must not be structural equal to each other.
|
|
6776
|
+
* @example
|
|
6777
|
+
* $mol_assert_unique( 1 , 2 , 3 ) // Passes
|
|
6778
|
+
* $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
|
|
6779
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
6780
|
+
*/
|
|
6386
6781
|
function $mol_assert_unique(...args) {
|
|
6387
6782
|
for (let i = 0; i < args.length; ++i) {
|
|
6388
6783
|
for (let j = 0; j < args.length; ++j) {
|
|
@@ -6395,6 +6790,13 @@ var $;
|
|
|
6395
6790
|
}
|
|
6396
6791
|
}
|
|
6397
6792
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
6793
|
+
/**
|
|
6794
|
+
* All arguments must be structural equal each other.
|
|
6795
|
+
* @example
|
|
6796
|
+
* $mol_assert_like( [1] , [1] , [1] ) // Passes
|
|
6797
|
+
* $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
|
|
6798
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
6799
|
+
*/
|
|
6398
6800
|
function $mol_assert_equal(...args) {
|
|
6399
6801
|
for (let i = 1; i < args.length; ++i) {
|
|
6400
6802
|
if ($mol_compare_deep(args[0], args[i]))
|
|
@@ -6465,6 +6867,12 @@ var $;
|
|
|
6465
6867
|
'return result without errors'() {
|
|
6466
6868
|
$mol_assert_equal($mol_try(() => false), false);
|
|
6467
6869
|
},
|
|
6870
|
+
//'return error if thrown'() {
|
|
6871
|
+
//
|
|
6872
|
+
// const error = new Error( '$mol_try test error' )
|
|
6873
|
+
// $mol_assert_equal( $mol_try( ()=> { throw error } ) , error )
|
|
6874
|
+
//
|
|
6875
|
+
//} ,
|
|
6468
6876
|
});
|
|
6469
6877
|
})($ || ($ = {}));
|
|
6470
6878
|
|
|
@@ -6662,6 +7070,7 @@ var $;
|
|
|
6662
7070
|
"use strict";
|
|
6663
7071
|
var $;
|
|
6664
7072
|
(function ($) {
|
|
7073
|
+
/// @todo right orderinng
|
|
6665
7074
|
$.$mol_after_mock_queue = [];
|
|
6666
7075
|
function $mol_after_mock_warp() {
|
|
6667
7076
|
const queue = $.$mol_after_mock_queue.splice(0);
|
|
@@ -7430,6 +7839,11 @@ var $;
|
|
|
7430
7839
|
"use strict";
|
|
7431
7840
|
var $;
|
|
7432
7841
|
(function ($) {
|
|
7842
|
+
/**
|
|
7843
|
+
* Combines list of unary functions/classes to one function.
|
|
7844
|
+
*
|
|
7845
|
+
* const reparse = $mol_data_pipe( JSON.stringify , JSON.parse )
|
|
7846
|
+
**/
|
|
7433
7847
|
function $mol_data_pipe(...funcs) {
|
|
7434
7848
|
return $mol_data_setup(function (input) {
|
|
7435
7849
|
let value = input;
|
|
@@ -7446,6 +7860,14 @@ var $;
|
|
|
7446
7860
|
var $;
|
|
7447
7861
|
(function ($) {
|
|
7448
7862
|
$mol_test({
|
|
7863
|
+
// @todo enable on strict
|
|
7864
|
+
// 'no functions'() {
|
|
7865
|
+
// const stringify = $mol_data_pipe()
|
|
7866
|
+
// type Type = $mol_type_assert<
|
|
7867
|
+
// typeof stringify,
|
|
7868
|
+
// ( input : never )=> never
|
|
7869
|
+
// >
|
|
7870
|
+
// },
|
|
7449
7871
|
'single function'() {
|
|
7450
7872
|
const stringify = $mol_data_pipe((input) => input.toString());
|
|
7451
7873
|
$mol_assert_equal(stringify(5), '5');
|
|
@@ -7846,6 +8268,9 @@ var $;
|
|
|
7846
8268
|
;
|
|
7847
8269
|
"use strict";
|
|
7848
8270
|
|
|
8271
|
+
;
|
|
8272
|
+
"use strict";
|
|
8273
|
+
|
|
7849
8274
|
;
|
|
7850
8275
|
"use strict";
|
|
7851
8276
|
var $;
|
|
@@ -8240,6 +8665,10 @@ var $;
|
|
|
8240
8665
|
"use strict";
|
|
8241
8666
|
var $;
|
|
8242
8667
|
(function ($) {
|
|
8668
|
+
/**
|
|
8669
|
+
* CSS Units
|
|
8670
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
8671
|
+
*/
|
|
8243
8672
|
class $mol_style_unit extends $mol_decor {
|
|
8244
8673
|
literal;
|
|
8245
8674
|
constructor(value, literal) {
|
|
@@ -8286,6 +8715,10 @@ var $;
|
|
|
8286
8715
|
var $;
|
|
8287
8716
|
(function ($) {
|
|
8288
8717
|
const { per } = $mol_style_unit;
|
|
8718
|
+
/**
|
|
8719
|
+
* CSS Functions
|
|
8720
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
8721
|
+
*/
|
|
8289
8722
|
class $mol_style_func extends $mol_decor {
|
|
8290
8723
|
name;
|
|
8291
8724
|
constructor(name, value) {
|
|
@@ -8377,6 +8810,7 @@ var $;
|
|
|
8377
8810
|
"use strict";
|
|
8378
8811
|
var $;
|
|
8379
8812
|
(function ($) {
|
|
8813
|
+
/** Create record of CSS variables. */
|
|
8380
8814
|
function $mol_style_prop(prefix, keys) {
|
|
8381
8815
|
const record = keys.reduce((rec, key) => {
|
|
8382
8816
|
rec[key] = $mol_style_func.vary(`--${prefix}_${key}`);
|
|
@@ -8391,6 +8825,10 @@ var $;
|
|
|
8391
8825
|
"use strict";
|
|
8392
8826
|
var $;
|
|
8393
8827
|
(function ($) {
|
|
8828
|
+
/**
|
|
8829
|
+
* Theme css variables
|
|
8830
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_textarea_demo
|
|
8831
|
+
*/
|
|
8394
8832
|
$.$mol_theme = $mol_style_prop('mol_theme', [
|
|
8395
8833
|
'back',
|
|
8396
8834
|
'hover',
|
|
@@ -8419,11 +8857,18 @@ var $;
|
|
|
8419
8857
|
|
|
8420
8858
|
;
|
|
8421
8859
|
"use strict";
|
|
8860
|
+
// namespace $ {
|
|
8861
|
+
// $mol_style_attach( '$mol_theme_lights', `:root { --mol_theme_back: oklch( ${ $$.$mol_lights() ? 92 : 20 }% .01 var(--mol_theme_hue) ) }` )
|
|
8862
|
+
// }
|
|
8422
8863
|
|
|
8423
8864
|
;
|
|
8424
8865
|
"use strict";
|
|
8425
8866
|
var $;
|
|
8426
8867
|
(function ($) {
|
|
8868
|
+
/**
|
|
8869
|
+
* Gap in CSS
|
|
8870
|
+
* @see https://page.hyoo.ru/#!=msdb74_bm7nsq
|
|
8871
|
+
*/
|
|
8427
8872
|
$.$mol_gap = $mol_style_prop('mol_gap', [
|
|
8428
8873
|
'page',
|
|
8429
8874
|
'block',
|
|
@@ -8462,6 +8907,7 @@ var $;
|
|
|
8462
8907
|
var $;
|
|
8463
8908
|
(function ($_1) {
|
|
8464
8909
|
$mol_test({
|
|
8910
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#component-states
|
|
8465
8911
|
'Cached channel'($) {
|
|
8466
8912
|
class App extends $mol_object2 {
|
|
8467
8913
|
static $ = $;
|
|
@@ -8519,6 +8965,7 @@ var $;
|
|
|
8519
8965
|
$mol_assert_equal(App.value(5), 21);
|
|
8520
8966
|
$mol_assert_equal(App.value(), 21);
|
|
8521
8967
|
},
|
|
8968
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-consistency
|
|
8522
8969
|
'Auto recalculation of cached values'($) {
|
|
8523
8970
|
class App extends $mol_object2 {
|
|
8524
8971
|
static $ = $;
|
|
@@ -8546,6 +8993,7 @@ var $;
|
|
|
8546
8993
|
App.xxx(5);
|
|
8547
8994
|
$mol_assert_equal(App.zzz(), 7);
|
|
8548
8995
|
},
|
|
8996
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-reasonability
|
|
8549
8997
|
'Skip recalculation when actually no dependency changes'($) {
|
|
8550
8998
|
const log = [];
|
|
8551
8999
|
class App extends $mol_object2 {
|
|
@@ -8579,6 +9027,7 @@ var $;
|
|
|
8579
9027
|
App.zzz();
|
|
8580
9028
|
$mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
|
|
8581
9029
|
},
|
|
9030
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#flow-auto
|
|
8582
9031
|
'Flow: Auto'($) {
|
|
8583
9032
|
class App extends $mol_object2 {
|
|
8584
9033
|
static get $() { return $; }
|
|
@@ -8616,6 +9065,7 @@ var $;
|
|
|
8616
9065
|
$mol_assert_equal(App.result(), 23);
|
|
8617
9066
|
$mol_assert_equal(App.counter, 4);
|
|
8618
9067
|
},
|
|
9068
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#dupes-equality
|
|
8619
9069
|
'Dupes: Equality'($) {
|
|
8620
9070
|
let counter = 0;
|
|
8621
9071
|
class App extends $mol_object2 {
|
|
@@ -8639,6 +9089,7 @@ var $;
|
|
|
8639
9089
|
App.foo({ numbs: [2] });
|
|
8640
9090
|
$mol_assert_like(App.bar(), { numbs: [2], count: 2 });
|
|
8641
9091
|
},
|
|
9092
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#cycle-fail
|
|
8642
9093
|
'Cycle: Fail'($) {
|
|
8643
9094
|
class App extends $mol_object2 {
|
|
8644
9095
|
static $ = $;
|
|
@@ -8663,6 +9114,29 @@ var $;
|
|
|
8663
9114
|
], App, "test", null);
|
|
8664
9115
|
App.test();
|
|
8665
9116
|
},
|
|
9117
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
9118
|
+
// 'Update deps on push'( $ ) {
|
|
9119
|
+
// class App extends $mol_object2 {
|
|
9120
|
+
// static $ = $
|
|
9121
|
+
// @ $mol_wire_solo
|
|
9122
|
+
// static left( next = false ) {
|
|
9123
|
+
// return next
|
|
9124
|
+
// }
|
|
9125
|
+
// @ $mol_wire_solo
|
|
9126
|
+
// static right( next = false ) {
|
|
9127
|
+
// return next
|
|
9128
|
+
// }
|
|
9129
|
+
// @ $mol_wire_solo
|
|
9130
|
+
// static res( next?: boolean ) {
|
|
9131
|
+
// return this.left( next ) && this.right()
|
|
9132
|
+
// }
|
|
9133
|
+
// }
|
|
9134
|
+
// $mol_assert_equal( App.res(), false )
|
|
9135
|
+
// $mol_assert_equal( App.res( true ), false )
|
|
9136
|
+
// $mol_assert_equal( App.right( true ), true )
|
|
9137
|
+
// $mol_assert_equal( App.res(), true )
|
|
9138
|
+
// } ,
|
|
9139
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
8666
9140
|
'Different order of pull and push'($) {
|
|
8667
9141
|
class App extends $mol_object2 {
|
|
8668
9142
|
static $ = $;
|
|
@@ -8674,7 +9148,7 @@ var $;
|
|
|
8674
9148
|
}
|
|
8675
9149
|
static slow(next) {
|
|
8676
9150
|
if (next !== undefined)
|
|
8677
|
-
this.slow();
|
|
9151
|
+
this.slow(); // enforce pull before push
|
|
8678
9152
|
return this.store(next);
|
|
8679
9153
|
}
|
|
8680
9154
|
}
|
|
@@ -8693,6 +9167,7 @@ var $;
|
|
|
8693
9167
|
App.store(777);
|
|
8694
9168
|
$mol_assert_equal(App.fast(), App.slow(), 777);
|
|
8695
9169
|
},
|
|
9170
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
8696
9171
|
'Actions inside invariant'($) {
|
|
8697
9172
|
class App extends $mol_object2 {
|
|
8698
9173
|
static $ = $;
|
|
@@ -8732,6 +9207,7 @@ var $;
|
|
|
8732
9207
|
static toggle() {
|
|
8733
9208
|
const prev = this.checked();
|
|
8734
9209
|
$mol_assert_unique(this.checked(!prev), prev);
|
|
9210
|
+
// $mol_assert_equal( this.checked() , prev )
|
|
8735
9211
|
}
|
|
8736
9212
|
static res() {
|
|
8737
9213
|
return this.checked();
|
|
@@ -8756,6 +9232,39 @@ var $;
|
|
|
8756
9232
|
], App, "test", null);
|
|
8757
9233
|
await $mol_wire_async(App).test();
|
|
8758
9234
|
},
|
|
9235
|
+
// // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
9236
|
+
// 'Stable order of multiple root'( $ ) {
|
|
9237
|
+
// class App extends $mol_object2 {
|
|
9238
|
+
// static $ = $
|
|
9239
|
+
// static counter = 0
|
|
9240
|
+
// @ $mol_wire_solo
|
|
9241
|
+
// static left_trigger( next = 0 ) {
|
|
9242
|
+
// return next
|
|
9243
|
+
// }
|
|
9244
|
+
// @ $mol_wire_solo
|
|
9245
|
+
// static left_root() {
|
|
9246
|
+
// this.left_trigger()
|
|
9247
|
+
// return ++ this.counter
|
|
9248
|
+
// }
|
|
9249
|
+
// @ $mol_wire_solo
|
|
9250
|
+
// static right_trigger( next = 0 ) {
|
|
9251
|
+
// return next
|
|
9252
|
+
// }
|
|
9253
|
+
// @ $mol_wire_solo
|
|
9254
|
+
// static right_root() {
|
|
9255
|
+
// this.right_trigger()
|
|
9256
|
+
// return ++ this.counter
|
|
9257
|
+
// }
|
|
9258
|
+
// }
|
|
9259
|
+
// $mol_assert_equal( App.left_root(), 1 )
|
|
9260
|
+
// $mol_assert_equal( App.right_root(), 2 )
|
|
9261
|
+
// App.right_trigger( 1 )
|
|
9262
|
+
// App.left_trigger( 1 )
|
|
9263
|
+
// $mol_wire_fiber.sync()
|
|
9264
|
+
// $mol_assert_equal( App.right_root(), 4 )
|
|
9265
|
+
// $mol_assert_equal( App.left_root(), 3 )
|
|
9266
|
+
// } ,
|
|
9267
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#error-store
|
|
8759
9268
|
'Restore after error'($) {
|
|
8760
9269
|
class App extends $mol_object2 {
|
|
8761
9270
|
static get $() { return $; }
|
|
@@ -8853,6 +9362,7 @@ var $;
|
|
|
8853
9362
|
App.showing(true);
|
|
8854
9363
|
$mol_assert_unique(App.render(), details);
|
|
8855
9364
|
},
|
|
9365
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
8856
9366
|
async 'Hold pubs while wait async task'($) {
|
|
8857
9367
|
class App extends $mol_object2 {
|
|
8858
9368
|
static $ = $;
|
|
@@ -9317,6 +9827,7 @@ var $;
|
|
|
9317
9827
|
|
|
9318
9828
|
;
|
|
9319
9829
|
"use strict";
|
|
9830
|
+
/** @jsx $mol_jsx */
|
|
9320
9831
|
var $;
|
|
9321
9832
|
(function ($) {
|
|
9322
9833
|
$mol_test({
|
|
@@ -9395,6 +9906,7 @@ var $;
|
|
|
9395
9906
|
"use strict";
|
|
9396
9907
|
var $;
|
|
9397
9908
|
(function ($) {
|
|
9909
|
+
/** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */
|
|
9398
9910
|
class $mol_wire_log extends $mol_object2 {
|
|
9399
9911
|
static watch(task) {
|
|
9400
9912
|
return task;
|
|
@@ -9468,6 +9980,10 @@ var $;
|
|
|
9468
9980
|
"use strict";
|
|
9469
9981
|
var $;
|
|
9470
9982
|
(function ($) {
|
|
9983
|
+
/**
|
|
9984
|
+
* Real-time refresh current atom.
|
|
9985
|
+
* Don't use if possible. May reduce performance.
|
|
9986
|
+
*/
|
|
9471
9987
|
function $mol_wire_watch() {
|
|
9472
9988
|
const atom = $mol_wire_auto();
|
|
9473
9989
|
if (atom instanceof $mol_wire_atom) {
|
|
@@ -9587,6 +10103,9 @@ var $;
|
|
|
9587
10103
|
;
|
|
9588
10104
|
"use strict";
|
|
9589
10105
|
|
|
10106
|
+
;
|
|
10107
|
+
"use strict";
|
|
10108
|
+
|
|
9590
10109
|
;
|
|
9591
10110
|
"use strict";
|
|
9592
10111
|
var $;
|
|
@@ -9596,6 +10115,7 @@ var $;
|
|
|
9596
10115
|
|
|
9597
10116
|
;
|
|
9598
10117
|
"use strict";
|
|
10118
|
+
/** @jsx $mol_jsx */
|
|
9599
10119
|
var $;
|
|
9600
10120
|
(function ($) {
|
|
9601
10121
|
function $mol_view_visible_width() {
|
|
@@ -9610,6 +10130,11 @@ var $;
|
|
|
9610
10130
|
return suffix;
|
|
9611
10131
|
}
|
|
9612
10132
|
$.$mol_view_state_key = $mol_view_state_key;
|
|
10133
|
+
/**
|
|
10134
|
+
* The base class for all visual components. It provides the infrastructure for reactive lazy rendering, handling exceptions.
|
|
10135
|
+
* @see https://mol.hyoo.ru/#!section=docs/=vv2nig_s5zr0f
|
|
10136
|
+
*/
|
|
10137
|
+
/// Reactive statefull lazy ViewModel
|
|
9613
10138
|
class $mol_view extends $mol_object {
|
|
9614
10139
|
static Root(id) {
|
|
9615
10140
|
return new this;
|
|
@@ -9674,16 +10199,22 @@ var $;
|
|
|
9674
10199
|
state_key(suffix = '') {
|
|
9675
10200
|
return this.$.$mol_view_state_key(suffix);
|
|
9676
10201
|
}
|
|
10202
|
+
/// Name of element that created when element not found in DOM
|
|
9677
10203
|
dom_name() {
|
|
9678
10204
|
return $mol_dom_qname(this.constructor.toString()) || 'div';
|
|
9679
10205
|
}
|
|
10206
|
+
/// NameSpace of element that created when element not found in DOM
|
|
9680
10207
|
dom_name_space() { return 'http://www.w3.org/1999/xhtml'; }
|
|
10208
|
+
/// Raw child views
|
|
9681
10209
|
sub() {
|
|
9682
10210
|
return [];
|
|
9683
10211
|
}
|
|
10212
|
+
/// Visible sub views with defined ambient context
|
|
10213
|
+
/// Render all by default
|
|
9684
10214
|
sub_visible() {
|
|
9685
10215
|
return this.sub();
|
|
9686
10216
|
}
|
|
10217
|
+
/// Minimal width that used for lazy rendering
|
|
9687
10218
|
minimal_width() {
|
|
9688
10219
|
let min = 0;
|
|
9689
10220
|
try {
|
|
@@ -9705,6 +10236,7 @@ var $;
|
|
|
9705
10236
|
maximal_width() {
|
|
9706
10237
|
return this.minimal_width();
|
|
9707
10238
|
}
|
|
10239
|
+
/// Minimal height that used for lazy rendering
|
|
9708
10240
|
minimal_height() {
|
|
9709
10241
|
let min = 0;
|
|
9710
10242
|
try {
|
|
@@ -9724,11 +10256,11 @@ var $;
|
|
|
9724
10256
|
view_rect() {
|
|
9725
10257
|
if ($mol_wire_probe(() => this.view_rect()) === undefined) {
|
|
9726
10258
|
$mol_wire_watch();
|
|
9727
|
-
return null;
|
|
10259
|
+
return null; // don't touch DOM to prevent instant reflow
|
|
9728
10260
|
}
|
|
9729
10261
|
else {
|
|
9730
10262
|
const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect();
|
|
9731
|
-
return { width, height, left, right, top, bottom };
|
|
10263
|
+
return { width, height, left, right, top, bottom }; // pick to optimize compare
|
|
9732
10264
|
}
|
|
9733
10265
|
}
|
|
9734
10266
|
dom_id() {
|
|
@@ -9918,6 +10450,7 @@ var $;
|
|
|
9918
10450
|
[$mol_dev_format_head]() {
|
|
9919
10451
|
return $mol_dev_format_span({}, $mol_dev_format_native(this));
|
|
9920
10452
|
}
|
|
10453
|
+
/** Deep search view by predicate. */
|
|
9921
10454
|
*view_find(check, path = []) {
|
|
9922
10455
|
if (path.length === 0 && check(this))
|
|
9923
10456
|
return yield [this];
|
|
@@ -9946,6 +10479,7 @@ var $;
|
|
|
9946
10479
|
$mol_fail_log(error);
|
|
9947
10480
|
}
|
|
9948
10481
|
}
|
|
10482
|
+
/** Renders path of views to DOM. */
|
|
9949
10483
|
force_render(path) {
|
|
9950
10484
|
const kids = this.sub();
|
|
9951
10485
|
const index = kids.findIndex(item => {
|
|
@@ -9960,6 +10494,7 @@ var $;
|
|
|
9960
10494
|
kids[index].force_render(path);
|
|
9961
10495
|
}
|
|
9962
10496
|
}
|
|
10497
|
+
/** Renders view to DOM and scroll to it. */
|
|
9963
10498
|
ensure_visible(view, align = "start") {
|
|
9964
10499
|
const path = this.view_find(v => v === view).next().value;
|
|
9965
10500
|
this.force_render(new Set(path));
|
|
@@ -9974,6 +10509,9 @@ var $;
|
|
|
9974
10509
|
const win = this.$.$mol_dom_context;
|
|
9975
10510
|
if (win.parent !== win.self && !win.document.hasFocus())
|
|
9976
10511
|
return;
|
|
10512
|
+
// new this.$.$mol_after_frame( ()=> {
|
|
10513
|
+
// this.dom_node().scrollIntoView({ block: 'start', inline: 'nearest' })
|
|
10514
|
+
// } )
|
|
9977
10515
|
new this.$.$mol_after_timeout(0, () => {
|
|
9978
10516
|
this.focused(true);
|
|
9979
10517
|
});
|
|
@@ -10162,6 +10700,7 @@ var $;
|
|
|
10162
10700
|
"use strict";
|
|
10163
10701
|
var $;
|
|
10164
10702
|
(function ($) {
|
|
10703
|
+
/** Plugin is component without its own DOM element, but instead uses the owner DOM element */
|
|
10165
10704
|
class $mol_plugin extends $mol_view {
|
|
10166
10705
|
dom_node_external(next) {
|
|
10167
10706
|
return next ?? $mol_owning_get(this).host.dom_node();
|
|
@@ -10202,6 +10741,10 @@ var $;
|
|
|
10202
10741
|
"use strict";
|
|
10203
10742
|
var $;
|
|
10204
10743
|
(function ($) {
|
|
10744
|
+
/**
|
|
10745
|
+
* Key names code for hotkey
|
|
10746
|
+
* @see [mol_hotkey](../../hotkey/hotkey.view.ts)
|
|
10747
|
+
*/
|
|
10205
10748
|
let $mol_keyboard_code;
|
|
10206
10749
|
(function ($mol_keyboard_code) {
|
|
10207
10750
|
$mol_keyboard_code[$mol_keyboard_code["backspace"] = 8] = "backspace";
|
|
@@ -10310,12 +10853,17 @@ var $;
|
|
|
10310
10853
|
;
|
|
10311
10854
|
"use strict";
|
|
10312
10855
|
|
|
10856
|
+
|
|
10313
10857
|
;
|
|
10314
10858
|
"use strict";
|
|
10315
10859
|
var $;
|
|
10316
10860
|
(function ($) {
|
|
10317
10861
|
var $$;
|
|
10318
10862
|
(function ($$) {
|
|
10863
|
+
/**
|
|
10864
|
+
* Plugin which adds handlers for keyboard keys.
|
|
10865
|
+
* @see [mol_keyboard_code](../keyboard/code/code.ts)
|
|
10866
|
+
*/
|
|
10319
10867
|
class $mol_hotkey extends $.$mol_hotkey {
|
|
10320
10868
|
key() {
|
|
10321
10869
|
return super.key();
|
|
@@ -10491,6 +11039,10 @@ var $;
|
|
|
10491
11039
|
"use strict";
|
|
10492
11040
|
var $;
|
|
10493
11041
|
(function ($) {
|
|
11042
|
+
/**
|
|
11043
|
+
* Z-index values for layers
|
|
11044
|
+
* https://page.hyoo.ru/#!=xthcpx_wqmiba
|
|
11045
|
+
*/
|
|
10494
11046
|
$.$mol_layer = $mol_style_prop('mol_layer', [
|
|
10495
11047
|
'hover',
|
|
10496
11048
|
'focus',
|
|
@@ -10510,12 +11062,17 @@ var $;
|
|
|
10510
11062
|
;
|
|
10511
11063
|
"use strict";
|
|
10512
11064
|
|
|
11065
|
+
|
|
10513
11066
|
;
|
|
10514
11067
|
"use strict";
|
|
10515
11068
|
var $;
|
|
10516
11069
|
(function ($) {
|
|
10517
11070
|
var $$;
|
|
10518
11071
|
(function ($$) {
|
|
11072
|
+
/**
|
|
11073
|
+
* An input field for entering single line text.
|
|
11074
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_string_demo
|
|
11075
|
+
*/
|
|
10519
11076
|
class $mol_string extends $.$mol_string {
|
|
10520
11077
|
event_change(next) {
|
|
10521
11078
|
if (!next)
|
|
@@ -10639,6 +11196,7 @@ var $;
|
|
|
10639
11196
|
;
|
|
10640
11197
|
"use strict";
|
|
10641
11198
|
|
|
11199
|
+
|
|
10642
11200
|
;
|
|
10643
11201
|
"use strict";
|
|
10644
11202
|
var $;
|
|
@@ -10776,12 +11334,17 @@ var $;
|
|
|
10776
11334
|
;
|
|
10777
11335
|
"use strict";
|
|
10778
11336
|
|
|
11337
|
+
|
|
10779
11338
|
;
|
|
10780
11339
|
"use strict";
|
|
10781
11340
|
var $;
|
|
10782
11341
|
(function ($) {
|
|
10783
11342
|
var $$;
|
|
10784
11343
|
(function ($$) {
|
|
11344
|
+
/**
|
|
11345
|
+
* Output text with dimmed mismatched substrings.
|
|
11346
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_dimmer_demo
|
|
11347
|
+
*/
|
|
10785
11348
|
class $mol_dimmer extends $.$mol_dimmer {
|
|
10786
11349
|
parts() {
|
|
10787
11350
|
const needle = this.needle();
|
|
@@ -10851,6 +11414,7 @@ var $;
|
|
|
10851
11414
|
;
|
|
10852
11415
|
"use strict";
|
|
10853
11416
|
|
|
11417
|
+
|
|
10854
11418
|
;
|
|
10855
11419
|
($.$mol_button) = class $mol_button extends ($.$mol_view) {
|
|
10856
11420
|
event_activate(next){
|
|
@@ -10985,12 +11549,17 @@ var $;
|
|
|
10985
11549
|
;
|
|
10986
11550
|
"use strict";
|
|
10987
11551
|
|
|
11552
|
+
|
|
10988
11553
|
;
|
|
10989
11554
|
"use strict";
|
|
10990
11555
|
var $;
|
|
10991
11556
|
(function ($) {
|
|
10992
11557
|
var $$;
|
|
10993
11558
|
(function ($$) {
|
|
11559
|
+
/**
|
|
11560
|
+
* Simple button.
|
|
11561
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_button_demo
|
|
11562
|
+
*/
|
|
10994
11563
|
class $mol_button extends $.$mol_button {
|
|
10995
11564
|
disabled() {
|
|
10996
11565
|
return !this.enabled();
|
|
@@ -11006,6 +11575,7 @@ var $;
|
|
|
11006
11575
|
this.status([null]);
|
|
11007
11576
|
}
|
|
11008
11577
|
catch (error) {
|
|
11578
|
+
// Calling actions from catch section, if throwing promise breaks idempotency
|
|
11009
11579
|
Promise.resolve().then(() => this.status([error]));
|
|
11010
11580
|
$mol_fail_hidden(error);
|
|
11011
11581
|
}
|
|
@@ -11075,6 +11645,7 @@ var $;
|
|
|
11075
11645
|
;
|
|
11076
11646
|
"use strict";
|
|
11077
11647
|
|
|
11648
|
+
|
|
11078
11649
|
;
|
|
11079
11650
|
($.$mol_button_minor) = class $mol_button_minor extends ($.$mol_button_typed) {};
|
|
11080
11651
|
|
|
@@ -11089,6 +11660,7 @@ var $;
|
|
|
11089
11660
|
;
|
|
11090
11661
|
"use strict";
|
|
11091
11662
|
|
|
11663
|
+
|
|
11092
11664
|
;
|
|
11093
11665
|
"use strict";
|
|
11094
11666
|
var $;
|
|
@@ -11118,12 +11690,12 @@ var $;
|
|
|
11118
11690
|
`;
|
|
11119
11691
|
const dest = `
|
|
11120
11692
|
query? \\
|
|
11121
|
-
clear?
|
|
11693
|
+
clear? null
|
|
11122
11694
|
Query $mol_string value? <=> query?
|
|
11123
11695
|
Suggest_label $mol_dimmer
|
|
11124
11696
|
needle <= query?
|
|
11125
11697
|
key * escape? <=> clear?
|
|
11126
|
-
Clear $mol_button_minor click?
|
|
11698
|
+
Clear $mol_button_minor click? <=> clear?
|
|
11127
11699
|
`;
|
|
11128
11700
|
const res = normalize($, src, dest);
|
|
11129
11701
|
$mol_assert_equal(res.input, res.output);
|
|
@@ -11145,10 +11717,10 @@ var $;
|
|
|
11145
11717
|
const dest = `
|
|
11146
11718
|
Close_icon ${d}mol_icon_cross
|
|
11147
11719
|
Title ${d}mol_view sub / <= title
|
|
11148
|
-
close?
|
|
11720
|
+
close? null
|
|
11149
11721
|
Close ${d}mol_button
|
|
11150
11722
|
title \\close
|
|
11151
|
-
click?
|
|
11723
|
+
click? <=> close?
|
|
11152
11724
|
title @ \\title
|
|
11153
11725
|
sub2 / <= Close_icon
|
|
11154
11726
|
sub /
|
|
@@ -11194,7 +11766,7 @@ var $;
|
|
|
11194
11766
|
const dest = `
|
|
11195
11767
|
clear? = Suggest_label clear?
|
|
11196
11768
|
Suggest_label $mol_dimmer clear? => clear?
|
|
11197
|
-
Clear $mol_button_minor click?
|
|
11769
|
+
Clear $mol_button_minor click? <=> clear?
|
|
11198
11770
|
`;
|
|
11199
11771
|
const res = normalize($, src, dest);
|
|
11200
11772
|
$mol_assert_equal(res.input, res.output);
|
|
@@ -11210,7 +11782,7 @@ var $;
|
|
|
11210
11782
|
$mol_assert_fail(() => normalize($, src).input, `Need an equal default values at \`/mol/view/tree2/class/props.test.ts#4:16/5\` vs \`/mol/view/tree2/class/props.test.ts#6:23/11\`
|
|
11211
11783
|
<=>
|
|
11212
11784
|
/mol/view/tree2/class/props.test.ts#6:19/3
|
|
11213
|
-
click?
|
|
11785
|
+
click?
|
|
11214
11786
|
/mol/view/tree2/class/props.test.ts#6:7/11
|
|
11215
11787
|
$mol_button_minor
|
|
11216
11788
|
/mol/view/tree2/class/props.test.ts#5:12/17
|
|
@@ -12196,6 +12768,11 @@ var $;
|
|
|
12196
12768
|
"use strict";
|
|
12197
12769
|
var $;
|
|
12198
12770
|
(function ($) {
|
|
12771
|
+
/**
|
|
12772
|
+
* CSS in TS.
|
|
12773
|
+
* Statically typed CSS style sheets. Following samples show which CSS code are generated from TS code.
|
|
12774
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
12775
|
+
*/
|
|
12199
12776
|
function $mol_style_define(Component, config) {
|
|
12200
12777
|
return $mol_style_attach(Component.name, $mol_style_sheet(Component, config));
|
|
12201
12778
|
}
|
|
@@ -12205,12 +12782,17 @@ var $;
|
|
|
12205
12782
|
;
|
|
12206
12783
|
"use strict";
|
|
12207
12784
|
|
|
12785
|
+
|
|
12208
12786
|
;
|
|
12209
12787
|
"use strict";
|
|
12210
12788
|
var $;
|
|
12211
12789
|
(function ($) {
|
|
12212
12790
|
var $$;
|
|
12213
12791
|
(function ($$) {
|
|
12792
|
+
/**
|
|
12793
|
+
* Scrolling pane.
|
|
12794
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_scroll_demo
|
|
12795
|
+
*/
|
|
12214
12796
|
class $mol_scroll extends $.$mol_scroll {
|
|
12215
12797
|
scroll_top(next, cache) {
|
|
12216
12798
|
const el = this.dom_node();
|
|
@@ -12260,6 +12842,7 @@ var $;
|
|
|
12260
12842
|
direction: 'column',
|
|
12261
12843
|
grow: 1,
|
|
12262
12844
|
shrink: 1,
|
|
12845
|
+
// basis: 0,
|
|
12263
12846
|
},
|
|
12264
12847
|
outline: 'none',
|
|
12265
12848
|
align: {
|
|
@@ -12277,6 +12860,7 @@ var $;
|
|
|
12277
12860
|
contain: 'content',
|
|
12278
12861
|
'>': {
|
|
12279
12862
|
$mol_view: {
|
|
12863
|
+
// transform: 'translateZ(0)', // enforce gpu scroll in all agents
|
|
12280
12864
|
gridArea: '1/1',
|
|
12281
12865
|
},
|
|
12282
12866
|
},
|
|
@@ -12389,6 +12973,7 @@ var $;
|
|
|
12389
12973
|
;
|
|
12390
12974
|
"use strict";
|
|
12391
12975
|
|
|
12976
|
+
|
|
12392
12977
|
;
|
|
12393
12978
|
"use strict";
|
|
12394
12979
|
var $;
|
|
@@ -12409,6 +12994,8 @@ var $;
|
|
|
12409
12994
|
maxHeight: per(100),
|
|
12410
12995
|
boxSizing: 'border-box',
|
|
12411
12996
|
color: $mol_theme.text,
|
|
12997
|
+
// backdropFilter: blur( `3px` ), enforces layering
|
|
12998
|
+
// zIndex: 0 ,
|
|
12412
12999
|
':focus': {
|
|
12413
13000
|
outline: 'none',
|
|
12414
13001
|
},
|
|
@@ -12926,99 +13513,131 @@ var $;
|
|
|
12926
13513
|
;
|
|
12927
13514
|
"use strict";
|
|
12928
13515
|
|
|
13516
|
+
|
|
12929
13517
|
;
|
|
12930
13518
|
"use strict";
|
|
12931
13519
|
|
|
13520
|
+
|
|
12932
13521
|
;
|
|
12933
13522
|
"use strict";
|
|
12934
13523
|
|
|
13524
|
+
|
|
12935
13525
|
;
|
|
12936
13526
|
"use strict";
|
|
12937
13527
|
|
|
13528
|
+
|
|
12938
13529
|
;
|
|
12939
13530
|
"use strict";
|
|
12940
13531
|
|
|
13532
|
+
|
|
12941
13533
|
;
|
|
12942
13534
|
"use strict";
|
|
12943
13535
|
|
|
13536
|
+
|
|
12944
13537
|
;
|
|
12945
13538
|
"use strict";
|
|
12946
13539
|
|
|
13540
|
+
|
|
12947
13541
|
;
|
|
12948
13542
|
"use strict";
|
|
12949
13543
|
|
|
13544
|
+
|
|
12950
13545
|
;
|
|
12951
13546
|
"use strict";
|
|
12952
13547
|
|
|
13548
|
+
|
|
12953
13549
|
;
|
|
12954
13550
|
"use strict";
|
|
12955
13551
|
|
|
13552
|
+
|
|
12956
13553
|
;
|
|
12957
13554
|
"use strict";
|
|
12958
13555
|
|
|
13556
|
+
|
|
12959
13557
|
;
|
|
12960
13558
|
"use strict";
|
|
12961
13559
|
|
|
13560
|
+
|
|
12962
13561
|
;
|
|
12963
13562
|
"use strict";
|
|
12964
13563
|
|
|
13564
|
+
|
|
12965
13565
|
;
|
|
12966
13566
|
"use strict";
|
|
12967
13567
|
|
|
13568
|
+
|
|
12968
13569
|
;
|
|
12969
13570
|
"use strict";
|
|
12970
13571
|
|
|
13572
|
+
|
|
12971
13573
|
;
|
|
12972
13574
|
"use strict";
|
|
12973
13575
|
|
|
13576
|
+
|
|
12974
13577
|
;
|
|
12975
13578
|
"use strict";
|
|
12976
13579
|
|
|
13580
|
+
|
|
12977
13581
|
;
|
|
12978
13582
|
"use strict";
|
|
12979
13583
|
|
|
13584
|
+
|
|
12980
13585
|
;
|
|
12981
13586
|
"use strict";
|
|
12982
13587
|
|
|
13588
|
+
|
|
12983
13589
|
;
|
|
12984
13590
|
"use strict";
|
|
12985
13591
|
|
|
13592
|
+
|
|
12986
13593
|
;
|
|
12987
13594
|
"use strict";
|
|
12988
13595
|
|
|
13596
|
+
|
|
12989
13597
|
;
|
|
12990
13598
|
"use strict";
|
|
12991
13599
|
|
|
13600
|
+
|
|
12992
13601
|
;
|
|
12993
13602
|
"use strict";
|
|
12994
13603
|
|
|
13604
|
+
|
|
12995
13605
|
;
|
|
12996
13606
|
"use strict";
|
|
12997
13607
|
|
|
13608
|
+
|
|
12998
13609
|
;
|
|
12999
13610
|
"use strict";
|
|
13000
13611
|
|
|
13612
|
+
|
|
13001
13613
|
;
|
|
13002
13614
|
"use strict";
|
|
13003
13615
|
|
|
13616
|
+
|
|
13004
13617
|
;
|
|
13005
13618
|
"use strict";
|
|
13006
13619
|
|
|
13620
|
+
|
|
13007
13621
|
;
|
|
13008
13622
|
"use strict";
|
|
13009
13623
|
|
|
13624
|
+
|
|
13010
13625
|
;
|
|
13011
13626
|
"use strict";
|
|
13012
13627
|
|
|
13628
|
+
|
|
13013
13629
|
;
|
|
13014
13630
|
"use strict";
|
|
13015
13631
|
|
|
13632
|
+
|
|
13016
13633
|
;
|
|
13017
13634
|
"use strict";
|
|
13018
13635
|
|
|
13636
|
+
|
|
13019
13637
|
;
|
|
13020
13638
|
"use strict";
|
|
13021
13639
|
|
|
13640
|
+
|
|
13022
13641
|
;
|
|
13023
13642
|
"use strict";
|
|
13024
13643
|
var $;
|
|
@@ -13054,45 +13673,59 @@ var $;
|
|
|
13054
13673
|
;
|
|
13055
13674
|
"use strict";
|
|
13056
13675
|
|
|
13676
|
+
|
|
13057
13677
|
;
|
|
13058
13678
|
"use strict";
|
|
13059
13679
|
|
|
13680
|
+
|
|
13060
13681
|
;
|
|
13061
13682
|
"use strict";
|
|
13062
13683
|
|
|
13684
|
+
|
|
13063
13685
|
;
|
|
13064
13686
|
"use strict";
|
|
13065
13687
|
|
|
13688
|
+
|
|
13066
13689
|
;
|
|
13067
13690
|
"use strict";
|
|
13068
13691
|
|
|
13692
|
+
|
|
13069
13693
|
;
|
|
13070
13694
|
"use strict";
|
|
13071
13695
|
|
|
13696
|
+
|
|
13072
13697
|
;
|
|
13073
13698
|
"use strict";
|
|
13074
13699
|
|
|
13700
|
+
|
|
13075
13701
|
;
|
|
13076
13702
|
"use strict";
|
|
13077
13703
|
|
|
13704
|
+
|
|
13078
13705
|
;
|
|
13079
13706
|
"use strict";
|
|
13080
13707
|
|
|
13708
|
+
|
|
13081
13709
|
;
|
|
13082
13710
|
"use strict";
|
|
13083
13711
|
|
|
13712
|
+
|
|
13084
13713
|
;
|
|
13085
13714
|
"use strict";
|
|
13086
13715
|
|
|
13716
|
+
|
|
13087
13717
|
;
|
|
13088
13718
|
"use strict";
|
|
13089
13719
|
|
|
13720
|
+
|
|
13090
13721
|
;
|
|
13091
13722
|
"use strict";
|
|
13092
13723
|
|
|
13724
|
+
|
|
13093
13725
|
;
|
|
13094
13726
|
"use strict";
|
|
13095
13727
|
|
|
13728
|
+
|
|
13096
13729
|
;
|
|
13097
13730
|
"use strict";
|
|
13098
13731
|
var $;
|
|
@@ -13180,13 +13813,13 @@ var $;
|
|
|
13180
13813
|
$mol_view_tree2_to_js_test_run(`
|
|
13181
13814
|
Foo $mol_view
|
|
13182
13815
|
a!? $mol_view
|
|
13183
|
-
expanded <=> cell_test_expanded!? null
|
|
13816
|
+
expanded? <=> cell_test_expanded!? null
|
|
13184
13817
|
`);
|
|
13185
|
-
}, `Required prop like some*? at \`.view.tree#4:
|
|
13818
|
+
}, `Required prop like some*? at \`.view.tree#4:22/20\`
|
|
13186
13819
|
<=>
|
|
13187
|
-
.view.tree#4:
|
|
13188
|
-
expanded
|
|
13189
|
-
.view.tree#4:8/
|
|
13820
|
+
.view.tree#4:18/3
|
|
13821
|
+
expanded?
|
|
13822
|
+
.view.tree#4:8/9
|
|
13190
13823
|
$mol_view
|
|
13191
13824
|
.view.tree#3:11/9
|
|
13192
13825
|
a!?
|
|
@@ -13220,7 +13853,9 @@ var $;
|
|
|
13220
13853
|
'Left bind read only'($) {
|
|
13221
13854
|
const _foo = $mol_view_tree2_to_js_test_ex_left_read_only_foo;
|
|
13222
13855
|
const foo = _foo.make({ $ });
|
|
13223
|
-
$mol_assert_like(foo.bar1(),
|
|
13856
|
+
$mol_assert_like(foo.bar1(),
|
|
13857
|
+
// @ts-ignore
|
|
13858
|
+
foo.bar1(2), foo.bar1(), foo.bar2(), 1);
|
|
13224
13859
|
$mol_assert_like(foo.bar2(2), foo.bar1(), 2);
|
|
13225
13860
|
},
|
|
13226
13861
|
'Left bind second level index'($) {
|
|
@@ -13247,7 +13882,11 @@ var $;
|
|
|
13247
13882
|
const foo = _foo.make({ $ });
|
|
13248
13883
|
$mol_assert_equal(foo.d(), foo.c(), foo.b(), foo.a(), 0);
|
|
13249
13884
|
$mol_assert_equal(foo.d(1), foo.c(), foo.b(), foo.a(), 1);
|
|
13250
|
-
$mol_assert_equal(
|
|
13885
|
+
$mol_assert_equal(
|
|
13886
|
+
// @ts-ignore
|
|
13887
|
+
foo.a(2),
|
|
13888
|
+
// @ts-ignore
|
|
13889
|
+
foo.b(2), foo.c(), foo.d(), 1);
|
|
13251
13890
|
$mol_assert_equal(foo.c(2), foo.b(), foo.a(), 2);
|
|
13252
13891
|
$mol_assert_equal(foo.d(1), 1);
|
|
13253
13892
|
$mol_assert_equal(foo.d(3), foo.c(), foo.b(), foo.a(), 3);
|
|
@@ -13283,6 +13922,10 @@ var $;
|
|
|
13283
13922
|
'Array of array or object'($) {
|
|
13284
13923
|
const _foo = $mol_view_tree2_to_js_test_ex_array_of_array_or_object_foo;
|
|
13285
13924
|
const foo = _foo.make({ $ });
|
|
13925
|
+
// type a1 = $mol_type_assert<
|
|
13926
|
+
// ReturnType<typeof foo.complex>,
|
|
13927
|
+
// readonly (readonly(number | string)[] | Record<string, number | string>)[]
|
|
13928
|
+
// >
|
|
13286
13929
|
$mol_assert_like(foo.complex(), ['1', [true], ['1', 21], { a: 1, str: 'some' }]);
|
|
13287
13930
|
},
|
|
13288
13931
|
'Array inheritance'($) {
|
|
@@ -13374,7 +14017,9 @@ var $;
|
|
|
13374
14017
|
'simple mutable and read only channels'($) {
|
|
13375
14018
|
const _foo = $mol_view_tree2_to_js_test_ex_simple_mutable_and_read_only_foo;
|
|
13376
14019
|
const foo = _foo.make({ $ });
|
|
13377
|
-
$mol_assert_equal(foo.readonly(),
|
|
14020
|
+
$mol_assert_equal(foo.readonly(),
|
|
14021
|
+
// @ts-ignore
|
|
14022
|
+
foo.readonly(1), foo.readonly(), null);
|
|
13378
14023
|
$mol_assert_equal(foo.mutable(), null);
|
|
13379
14024
|
$mol_assert_equal(foo.mutable(2), foo.mutable(), 2);
|
|
13380
14025
|
},
|