mol_view_tree2_lib 1.0.196 → 1.0.197
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 +278 -1
- 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 +675 -36
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +282 -1
- 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 +304 -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');
|
|
@@ -8240,6 +8662,10 @@ var $;
|
|
|
8240
8662
|
"use strict";
|
|
8241
8663
|
var $;
|
|
8242
8664
|
(function ($) {
|
|
8665
|
+
/**
|
|
8666
|
+
* CSS Units
|
|
8667
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
8668
|
+
*/
|
|
8243
8669
|
class $mol_style_unit extends $mol_decor {
|
|
8244
8670
|
literal;
|
|
8245
8671
|
constructor(value, literal) {
|
|
@@ -8286,6 +8712,10 @@ var $;
|
|
|
8286
8712
|
var $;
|
|
8287
8713
|
(function ($) {
|
|
8288
8714
|
const { per } = $mol_style_unit;
|
|
8715
|
+
/**
|
|
8716
|
+
* CSS Functions
|
|
8717
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
8718
|
+
*/
|
|
8289
8719
|
class $mol_style_func extends $mol_decor {
|
|
8290
8720
|
name;
|
|
8291
8721
|
constructor(name, value) {
|
|
@@ -8377,6 +8807,7 @@ var $;
|
|
|
8377
8807
|
"use strict";
|
|
8378
8808
|
var $;
|
|
8379
8809
|
(function ($) {
|
|
8810
|
+
/** Create record of CSS variables. */
|
|
8380
8811
|
function $mol_style_prop(prefix, keys) {
|
|
8381
8812
|
const record = keys.reduce((rec, key) => {
|
|
8382
8813
|
rec[key] = $mol_style_func.vary(`--${prefix}_${key}`);
|
|
@@ -8391,6 +8822,10 @@ var $;
|
|
|
8391
8822
|
"use strict";
|
|
8392
8823
|
var $;
|
|
8393
8824
|
(function ($) {
|
|
8825
|
+
/**
|
|
8826
|
+
* Theme css variables
|
|
8827
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_textarea_demo
|
|
8828
|
+
*/
|
|
8394
8829
|
$.$mol_theme = $mol_style_prop('mol_theme', [
|
|
8395
8830
|
'back',
|
|
8396
8831
|
'hover',
|
|
@@ -8419,11 +8854,18 @@ var $;
|
|
|
8419
8854
|
|
|
8420
8855
|
;
|
|
8421
8856
|
"use strict";
|
|
8857
|
+
// namespace $ {
|
|
8858
|
+
// $mol_style_attach( '$mol_theme_lights', `:root { --mol_theme_back: oklch( ${ $$.$mol_lights() ? 92 : 20 }% .01 var(--mol_theme_hue) ) }` )
|
|
8859
|
+
// }
|
|
8422
8860
|
|
|
8423
8861
|
;
|
|
8424
8862
|
"use strict";
|
|
8425
8863
|
var $;
|
|
8426
8864
|
(function ($) {
|
|
8865
|
+
/**
|
|
8866
|
+
* Gap in CSS
|
|
8867
|
+
* @see https://page.hyoo.ru/#!=msdb74_bm7nsq
|
|
8868
|
+
*/
|
|
8427
8869
|
$.$mol_gap = $mol_style_prop('mol_gap', [
|
|
8428
8870
|
'page',
|
|
8429
8871
|
'block',
|
|
@@ -8462,6 +8904,7 @@ var $;
|
|
|
8462
8904
|
var $;
|
|
8463
8905
|
(function ($_1) {
|
|
8464
8906
|
$mol_test({
|
|
8907
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#component-states
|
|
8465
8908
|
'Cached channel'($) {
|
|
8466
8909
|
class App extends $mol_object2 {
|
|
8467
8910
|
static $ = $;
|
|
@@ -8519,6 +8962,7 @@ var $;
|
|
|
8519
8962
|
$mol_assert_equal(App.value(5), 21);
|
|
8520
8963
|
$mol_assert_equal(App.value(), 21);
|
|
8521
8964
|
},
|
|
8965
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-consistency
|
|
8522
8966
|
'Auto recalculation of cached values'($) {
|
|
8523
8967
|
class App extends $mol_object2 {
|
|
8524
8968
|
static $ = $;
|
|
@@ -8546,6 +8990,7 @@ var $;
|
|
|
8546
8990
|
App.xxx(5);
|
|
8547
8991
|
$mol_assert_equal(App.zzz(), 7);
|
|
8548
8992
|
},
|
|
8993
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-reasonability
|
|
8549
8994
|
'Skip recalculation when actually no dependency changes'($) {
|
|
8550
8995
|
const log = [];
|
|
8551
8996
|
class App extends $mol_object2 {
|
|
@@ -8579,6 +9024,7 @@ var $;
|
|
|
8579
9024
|
App.zzz();
|
|
8580
9025
|
$mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
|
|
8581
9026
|
},
|
|
9027
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#flow-auto
|
|
8582
9028
|
'Flow: Auto'($) {
|
|
8583
9029
|
class App extends $mol_object2 {
|
|
8584
9030
|
static get $() { return $; }
|
|
@@ -8616,6 +9062,7 @@ var $;
|
|
|
8616
9062
|
$mol_assert_equal(App.result(), 23);
|
|
8617
9063
|
$mol_assert_equal(App.counter, 4);
|
|
8618
9064
|
},
|
|
9065
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#dupes-equality
|
|
8619
9066
|
'Dupes: Equality'($) {
|
|
8620
9067
|
let counter = 0;
|
|
8621
9068
|
class App extends $mol_object2 {
|
|
@@ -8639,6 +9086,7 @@ var $;
|
|
|
8639
9086
|
App.foo({ numbs: [2] });
|
|
8640
9087
|
$mol_assert_like(App.bar(), { numbs: [2], count: 2 });
|
|
8641
9088
|
},
|
|
9089
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#cycle-fail
|
|
8642
9090
|
'Cycle: Fail'($) {
|
|
8643
9091
|
class App extends $mol_object2 {
|
|
8644
9092
|
static $ = $;
|
|
@@ -8663,6 +9111,29 @@ var $;
|
|
|
8663
9111
|
], App, "test", null);
|
|
8664
9112
|
App.test();
|
|
8665
9113
|
},
|
|
9114
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
9115
|
+
// 'Update deps on push'( $ ) {
|
|
9116
|
+
// class App extends $mol_object2 {
|
|
9117
|
+
// static $ = $
|
|
9118
|
+
// @ $mol_wire_solo
|
|
9119
|
+
// static left( next = false ) {
|
|
9120
|
+
// return next
|
|
9121
|
+
// }
|
|
9122
|
+
// @ $mol_wire_solo
|
|
9123
|
+
// static right( next = false ) {
|
|
9124
|
+
// return next
|
|
9125
|
+
// }
|
|
9126
|
+
// @ $mol_wire_solo
|
|
9127
|
+
// static res( next?: boolean ) {
|
|
9128
|
+
// return this.left( next ) && this.right()
|
|
9129
|
+
// }
|
|
9130
|
+
// }
|
|
9131
|
+
// $mol_assert_equal( App.res(), false )
|
|
9132
|
+
// $mol_assert_equal( App.res( true ), false )
|
|
9133
|
+
// $mol_assert_equal( App.right( true ), true )
|
|
9134
|
+
// $mol_assert_equal( App.res(), true )
|
|
9135
|
+
// } ,
|
|
9136
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
8666
9137
|
'Different order of pull and push'($) {
|
|
8667
9138
|
class App extends $mol_object2 {
|
|
8668
9139
|
static $ = $;
|
|
@@ -8674,7 +9145,7 @@ var $;
|
|
|
8674
9145
|
}
|
|
8675
9146
|
static slow(next) {
|
|
8676
9147
|
if (next !== undefined)
|
|
8677
|
-
this.slow();
|
|
9148
|
+
this.slow(); // enforce pull before push
|
|
8678
9149
|
return this.store(next);
|
|
8679
9150
|
}
|
|
8680
9151
|
}
|
|
@@ -8693,6 +9164,7 @@ var $;
|
|
|
8693
9164
|
App.store(777);
|
|
8694
9165
|
$mol_assert_equal(App.fast(), App.slow(), 777);
|
|
8695
9166
|
},
|
|
9167
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
8696
9168
|
'Actions inside invariant'($) {
|
|
8697
9169
|
class App extends $mol_object2 {
|
|
8698
9170
|
static $ = $;
|
|
@@ -8732,6 +9204,7 @@ var $;
|
|
|
8732
9204
|
static toggle() {
|
|
8733
9205
|
const prev = this.checked();
|
|
8734
9206
|
$mol_assert_unique(this.checked(!prev), prev);
|
|
9207
|
+
// $mol_assert_equal( this.checked() , prev )
|
|
8735
9208
|
}
|
|
8736
9209
|
static res() {
|
|
8737
9210
|
return this.checked();
|
|
@@ -8756,6 +9229,39 @@ var $;
|
|
|
8756
9229
|
], App, "test", null);
|
|
8757
9230
|
await $mol_wire_async(App).test();
|
|
8758
9231
|
},
|
|
9232
|
+
// // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
9233
|
+
// 'Stable order of multiple root'( $ ) {
|
|
9234
|
+
// class App extends $mol_object2 {
|
|
9235
|
+
// static $ = $
|
|
9236
|
+
// static counter = 0
|
|
9237
|
+
// @ $mol_wire_solo
|
|
9238
|
+
// static left_trigger( next = 0 ) {
|
|
9239
|
+
// return next
|
|
9240
|
+
// }
|
|
9241
|
+
// @ $mol_wire_solo
|
|
9242
|
+
// static left_root() {
|
|
9243
|
+
// this.left_trigger()
|
|
9244
|
+
// return ++ this.counter
|
|
9245
|
+
// }
|
|
9246
|
+
// @ $mol_wire_solo
|
|
9247
|
+
// static right_trigger( next = 0 ) {
|
|
9248
|
+
// return next
|
|
9249
|
+
// }
|
|
9250
|
+
// @ $mol_wire_solo
|
|
9251
|
+
// static right_root() {
|
|
9252
|
+
// this.right_trigger()
|
|
9253
|
+
// return ++ this.counter
|
|
9254
|
+
// }
|
|
9255
|
+
// }
|
|
9256
|
+
// $mol_assert_equal( App.left_root(), 1 )
|
|
9257
|
+
// $mol_assert_equal( App.right_root(), 2 )
|
|
9258
|
+
// App.right_trigger( 1 )
|
|
9259
|
+
// App.left_trigger( 1 )
|
|
9260
|
+
// $mol_wire_fiber.sync()
|
|
9261
|
+
// $mol_assert_equal( App.right_root(), 4 )
|
|
9262
|
+
// $mol_assert_equal( App.left_root(), 3 )
|
|
9263
|
+
// } ,
|
|
9264
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#error-store
|
|
8759
9265
|
'Restore after error'($) {
|
|
8760
9266
|
class App extends $mol_object2 {
|
|
8761
9267
|
static get $() { return $; }
|
|
@@ -8853,6 +9359,7 @@ var $;
|
|
|
8853
9359
|
App.showing(true);
|
|
8854
9360
|
$mol_assert_unique(App.render(), details);
|
|
8855
9361
|
},
|
|
9362
|
+
// https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
|
|
8856
9363
|
async 'Hold pubs while wait async task'($) {
|
|
8857
9364
|
class App extends $mol_object2 {
|
|
8858
9365
|
static $ = $;
|
|
@@ -9317,6 +9824,7 @@ var $;
|
|
|
9317
9824
|
|
|
9318
9825
|
;
|
|
9319
9826
|
"use strict";
|
|
9827
|
+
/** @jsx $mol_jsx */
|
|
9320
9828
|
var $;
|
|
9321
9829
|
(function ($) {
|
|
9322
9830
|
$mol_test({
|
|
@@ -9395,6 +9903,7 @@ var $;
|
|
|
9395
9903
|
"use strict";
|
|
9396
9904
|
var $;
|
|
9397
9905
|
(function ($) {
|
|
9906
|
+
/** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */
|
|
9398
9907
|
class $mol_wire_log extends $mol_object2 {
|
|
9399
9908
|
static watch(task) {
|
|
9400
9909
|
return task;
|
|
@@ -9468,6 +9977,10 @@ var $;
|
|
|
9468
9977
|
"use strict";
|
|
9469
9978
|
var $;
|
|
9470
9979
|
(function ($) {
|
|
9980
|
+
/**
|
|
9981
|
+
* Real-time refresh current atom.
|
|
9982
|
+
* Don't use if possible. May reduce performance.
|
|
9983
|
+
*/
|
|
9471
9984
|
function $mol_wire_watch() {
|
|
9472
9985
|
const atom = $mol_wire_auto();
|
|
9473
9986
|
if (atom instanceof $mol_wire_atom) {
|
|
@@ -9596,6 +10109,7 @@ var $;
|
|
|
9596
10109
|
|
|
9597
10110
|
;
|
|
9598
10111
|
"use strict";
|
|
10112
|
+
/** @jsx $mol_jsx */
|
|
9599
10113
|
var $;
|
|
9600
10114
|
(function ($) {
|
|
9601
10115
|
function $mol_view_visible_width() {
|
|
@@ -9610,6 +10124,11 @@ var $;
|
|
|
9610
10124
|
return suffix;
|
|
9611
10125
|
}
|
|
9612
10126
|
$.$mol_view_state_key = $mol_view_state_key;
|
|
10127
|
+
/**
|
|
10128
|
+
* The base class for all visual components. It provides the infrastructure for reactive lazy rendering, handling exceptions.
|
|
10129
|
+
* @see https://mol.hyoo.ru/#!section=docs/=vv2nig_s5zr0f
|
|
10130
|
+
*/
|
|
10131
|
+
/// Reactive statefull lazy ViewModel
|
|
9613
10132
|
class $mol_view extends $mol_object {
|
|
9614
10133
|
static Root(id) {
|
|
9615
10134
|
return new this;
|
|
@@ -9674,16 +10193,22 @@ var $;
|
|
|
9674
10193
|
state_key(suffix = '') {
|
|
9675
10194
|
return this.$.$mol_view_state_key(suffix);
|
|
9676
10195
|
}
|
|
10196
|
+
/// Name of element that created when element not found in DOM
|
|
9677
10197
|
dom_name() {
|
|
9678
10198
|
return $mol_dom_qname(this.constructor.toString()) || 'div';
|
|
9679
10199
|
}
|
|
10200
|
+
/// NameSpace of element that created when element not found in DOM
|
|
9680
10201
|
dom_name_space() { return 'http://www.w3.org/1999/xhtml'; }
|
|
10202
|
+
/// Raw child views
|
|
9681
10203
|
sub() {
|
|
9682
10204
|
return [];
|
|
9683
10205
|
}
|
|
10206
|
+
/// Visible sub views with defined ambient context
|
|
10207
|
+
/// Render all by default
|
|
9684
10208
|
sub_visible() {
|
|
9685
10209
|
return this.sub();
|
|
9686
10210
|
}
|
|
10211
|
+
/// Minimal width that used for lazy rendering
|
|
9687
10212
|
minimal_width() {
|
|
9688
10213
|
let min = 0;
|
|
9689
10214
|
try {
|
|
@@ -9705,6 +10230,7 @@ var $;
|
|
|
9705
10230
|
maximal_width() {
|
|
9706
10231
|
return this.minimal_width();
|
|
9707
10232
|
}
|
|
10233
|
+
/// Minimal height that used for lazy rendering
|
|
9708
10234
|
minimal_height() {
|
|
9709
10235
|
let min = 0;
|
|
9710
10236
|
try {
|
|
@@ -9724,11 +10250,11 @@ var $;
|
|
|
9724
10250
|
view_rect() {
|
|
9725
10251
|
if ($mol_wire_probe(() => this.view_rect()) === undefined) {
|
|
9726
10252
|
$mol_wire_watch();
|
|
9727
|
-
return null;
|
|
10253
|
+
return null; // don't touch DOM to prevent instant reflow
|
|
9728
10254
|
}
|
|
9729
10255
|
else {
|
|
9730
10256
|
const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect();
|
|
9731
|
-
return { width, height, left, right, top, bottom };
|
|
10257
|
+
return { width, height, left, right, top, bottom }; // pick to optimize compare
|
|
9732
10258
|
}
|
|
9733
10259
|
}
|
|
9734
10260
|
dom_id() {
|
|
@@ -9918,6 +10444,7 @@ var $;
|
|
|
9918
10444
|
[$mol_dev_format_head]() {
|
|
9919
10445
|
return $mol_dev_format_span({}, $mol_dev_format_native(this));
|
|
9920
10446
|
}
|
|
10447
|
+
/** Deep search view by predicate. */
|
|
9921
10448
|
*view_find(check, path = []) {
|
|
9922
10449
|
if (path.length === 0 && check(this))
|
|
9923
10450
|
return yield [this];
|
|
@@ -9946,6 +10473,7 @@ var $;
|
|
|
9946
10473
|
$mol_fail_log(error);
|
|
9947
10474
|
}
|
|
9948
10475
|
}
|
|
10476
|
+
/** Renders path of views to DOM. */
|
|
9949
10477
|
force_render(path) {
|
|
9950
10478
|
const kids = this.sub();
|
|
9951
10479
|
const index = kids.findIndex(item => {
|
|
@@ -9960,6 +10488,7 @@ var $;
|
|
|
9960
10488
|
kids[index].force_render(path);
|
|
9961
10489
|
}
|
|
9962
10490
|
}
|
|
10491
|
+
/** Renders view to DOM and scroll to it. */
|
|
9963
10492
|
ensure_visible(view, align = "start") {
|
|
9964
10493
|
const path = this.view_find(v => v === view).next().value;
|
|
9965
10494
|
this.force_render(new Set(path));
|
|
@@ -9974,6 +10503,9 @@ var $;
|
|
|
9974
10503
|
const win = this.$.$mol_dom_context;
|
|
9975
10504
|
if (win.parent !== win.self && !win.document.hasFocus())
|
|
9976
10505
|
return;
|
|
10506
|
+
// new this.$.$mol_after_frame( ()=> {
|
|
10507
|
+
// this.dom_node().scrollIntoView({ block: 'start', inline: 'nearest' })
|
|
10508
|
+
// } )
|
|
9977
10509
|
new this.$.$mol_after_timeout(0, () => {
|
|
9978
10510
|
this.focused(true);
|
|
9979
10511
|
});
|
|
@@ -10162,6 +10694,7 @@ var $;
|
|
|
10162
10694
|
"use strict";
|
|
10163
10695
|
var $;
|
|
10164
10696
|
(function ($) {
|
|
10697
|
+
/** Plugin is component without its own DOM element, but instead uses the owner DOM element */
|
|
10165
10698
|
class $mol_plugin extends $mol_view {
|
|
10166
10699
|
dom_node_external(next) {
|
|
10167
10700
|
return next ?? $mol_owning_get(this).host.dom_node();
|
|
@@ -10202,6 +10735,10 @@ var $;
|
|
|
10202
10735
|
"use strict";
|
|
10203
10736
|
var $;
|
|
10204
10737
|
(function ($) {
|
|
10738
|
+
/**
|
|
10739
|
+
* Key names code for hotkey
|
|
10740
|
+
* @see [mol_hotkey](../../hotkey/hotkey.view.ts)
|
|
10741
|
+
*/
|
|
10205
10742
|
let $mol_keyboard_code;
|
|
10206
10743
|
(function ($mol_keyboard_code) {
|
|
10207
10744
|
$mol_keyboard_code[$mol_keyboard_code["backspace"] = 8] = "backspace";
|
|
@@ -10310,12 +10847,17 @@ var $;
|
|
|
10310
10847
|
;
|
|
10311
10848
|
"use strict";
|
|
10312
10849
|
|
|
10850
|
+
|
|
10313
10851
|
;
|
|
10314
10852
|
"use strict";
|
|
10315
10853
|
var $;
|
|
10316
10854
|
(function ($) {
|
|
10317
10855
|
var $$;
|
|
10318
10856
|
(function ($$) {
|
|
10857
|
+
/**
|
|
10858
|
+
* Plugin which adds handlers for keyboard keys.
|
|
10859
|
+
* @see [mol_keyboard_code](../keyboard/code/code.ts)
|
|
10860
|
+
*/
|
|
10319
10861
|
class $mol_hotkey extends $.$mol_hotkey {
|
|
10320
10862
|
key() {
|
|
10321
10863
|
return super.key();
|
|
@@ -10491,6 +11033,10 @@ var $;
|
|
|
10491
11033
|
"use strict";
|
|
10492
11034
|
var $;
|
|
10493
11035
|
(function ($) {
|
|
11036
|
+
/**
|
|
11037
|
+
* Z-index values for layers
|
|
11038
|
+
* https://page.hyoo.ru/#!=xthcpx_wqmiba
|
|
11039
|
+
*/
|
|
10494
11040
|
$.$mol_layer = $mol_style_prop('mol_layer', [
|
|
10495
11041
|
'hover',
|
|
10496
11042
|
'focus',
|
|
@@ -10510,12 +11056,17 @@ var $;
|
|
|
10510
11056
|
;
|
|
10511
11057
|
"use strict";
|
|
10512
11058
|
|
|
11059
|
+
|
|
10513
11060
|
;
|
|
10514
11061
|
"use strict";
|
|
10515
11062
|
var $;
|
|
10516
11063
|
(function ($) {
|
|
10517
11064
|
var $$;
|
|
10518
11065
|
(function ($$) {
|
|
11066
|
+
/**
|
|
11067
|
+
* An input field for entering single line text.
|
|
11068
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_string_demo
|
|
11069
|
+
*/
|
|
10519
11070
|
class $mol_string extends $.$mol_string {
|
|
10520
11071
|
event_change(next) {
|
|
10521
11072
|
if (!next)
|
|
@@ -10639,6 +11190,7 @@ var $;
|
|
|
10639
11190
|
;
|
|
10640
11191
|
"use strict";
|
|
10641
11192
|
|
|
11193
|
+
|
|
10642
11194
|
;
|
|
10643
11195
|
"use strict";
|
|
10644
11196
|
var $;
|
|
@@ -10776,12 +11328,17 @@ var $;
|
|
|
10776
11328
|
;
|
|
10777
11329
|
"use strict";
|
|
10778
11330
|
|
|
11331
|
+
|
|
10779
11332
|
;
|
|
10780
11333
|
"use strict";
|
|
10781
11334
|
var $;
|
|
10782
11335
|
(function ($) {
|
|
10783
11336
|
var $$;
|
|
10784
11337
|
(function ($$) {
|
|
11338
|
+
/**
|
|
11339
|
+
* Output text with dimmed mismatched substrings.
|
|
11340
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_dimmer_demo
|
|
11341
|
+
*/
|
|
10785
11342
|
class $mol_dimmer extends $.$mol_dimmer {
|
|
10786
11343
|
parts() {
|
|
10787
11344
|
const needle = this.needle();
|
|
@@ -10851,6 +11408,7 @@ var $;
|
|
|
10851
11408
|
;
|
|
10852
11409
|
"use strict";
|
|
10853
11410
|
|
|
11411
|
+
|
|
10854
11412
|
;
|
|
10855
11413
|
($.$mol_button) = class $mol_button extends ($.$mol_view) {
|
|
10856
11414
|
event_activate(next){
|
|
@@ -10985,12 +11543,17 @@ var $;
|
|
|
10985
11543
|
;
|
|
10986
11544
|
"use strict";
|
|
10987
11545
|
|
|
11546
|
+
|
|
10988
11547
|
;
|
|
10989
11548
|
"use strict";
|
|
10990
11549
|
var $;
|
|
10991
11550
|
(function ($) {
|
|
10992
11551
|
var $$;
|
|
10993
11552
|
(function ($$) {
|
|
11553
|
+
/**
|
|
11554
|
+
* Simple button.
|
|
11555
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_button_demo
|
|
11556
|
+
*/
|
|
10994
11557
|
class $mol_button extends $.$mol_button {
|
|
10995
11558
|
disabled() {
|
|
10996
11559
|
return !this.enabled();
|
|
@@ -11006,6 +11569,7 @@ var $;
|
|
|
11006
11569
|
this.status([null]);
|
|
11007
11570
|
}
|
|
11008
11571
|
catch (error) {
|
|
11572
|
+
// Calling actions from catch section, if throwing promise breaks idempotency
|
|
11009
11573
|
Promise.resolve().then(() => this.status([error]));
|
|
11010
11574
|
$mol_fail_hidden(error);
|
|
11011
11575
|
}
|
|
@@ -11075,6 +11639,7 @@ var $;
|
|
|
11075
11639
|
;
|
|
11076
11640
|
"use strict";
|
|
11077
11641
|
|
|
11642
|
+
|
|
11078
11643
|
;
|
|
11079
11644
|
($.$mol_button_minor) = class $mol_button_minor extends ($.$mol_button_typed) {};
|
|
11080
11645
|
|
|
@@ -11089,6 +11654,7 @@ var $;
|
|
|
11089
11654
|
;
|
|
11090
11655
|
"use strict";
|
|
11091
11656
|
|
|
11657
|
+
|
|
11092
11658
|
;
|
|
11093
11659
|
"use strict";
|
|
11094
11660
|
var $;
|
|
@@ -11118,12 +11684,12 @@ var $;
|
|
|
11118
11684
|
`;
|
|
11119
11685
|
const dest = `
|
|
11120
11686
|
query? \\
|
|
11121
|
-
clear?
|
|
11687
|
+
clear? null
|
|
11122
11688
|
Query $mol_string value? <=> query?
|
|
11123
11689
|
Suggest_label $mol_dimmer
|
|
11124
11690
|
needle <= query?
|
|
11125
11691
|
key * escape? <=> clear?
|
|
11126
|
-
Clear $mol_button_minor click?
|
|
11692
|
+
Clear $mol_button_minor click? <=> clear?
|
|
11127
11693
|
`;
|
|
11128
11694
|
const res = normalize($, src, dest);
|
|
11129
11695
|
$mol_assert_equal(res.input, res.output);
|
|
@@ -11145,10 +11711,10 @@ var $;
|
|
|
11145
11711
|
const dest = `
|
|
11146
11712
|
Close_icon ${d}mol_icon_cross
|
|
11147
11713
|
Title ${d}mol_view sub / <= title
|
|
11148
|
-
close?
|
|
11714
|
+
close? null
|
|
11149
11715
|
Close ${d}mol_button
|
|
11150
11716
|
title \\close
|
|
11151
|
-
click?
|
|
11717
|
+
click? <=> close?
|
|
11152
11718
|
title @ \\title
|
|
11153
11719
|
sub2 / <= Close_icon
|
|
11154
11720
|
sub /
|
|
@@ -11194,7 +11760,7 @@ var $;
|
|
|
11194
11760
|
const dest = `
|
|
11195
11761
|
clear? = Suggest_label clear?
|
|
11196
11762
|
Suggest_label $mol_dimmer clear? => clear?
|
|
11197
|
-
Clear $mol_button_minor click?
|
|
11763
|
+
Clear $mol_button_minor click? <=> clear?
|
|
11198
11764
|
`;
|
|
11199
11765
|
const res = normalize($, src, dest);
|
|
11200
11766
|
$mol_assert_equal(res.input, res.output);
|
|
@@ -11210,7 +11776,7 @@ var $;
|
|
|
11210
11776
|
$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
11777
|
<=>
|
|
11212
11778
|
/mol/view/tree2/class/props.test.ts#6:19/3
|
|
11213
|
-
click?
|
|
11779
|
+
click?
|
|
11214
11780
|
/mol/view/tree2/class/props.test.ts#6:7/11
|
|
11215
11781
|
$mol_button_minor
|
|
11216
11782
|
/mol/view/tree2/class/props.test.ts#5:12/17
|
|
@@ -12196,6 +12762,11 @@ var $;
|
|
|
12196
12762
|
"use strict";
|
|
12197
12763
|
var $;
|
|
12198
12764
|
(function ($) {
|
|
12765
|
+
/**
|
|
12766
|
+
* CSS in TS.
|
|
12767
|
+
* Statically typed CSS style sheets. Following samples show which CSS code are generated from TS code.
|
|
12768
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
12769
|
+
*/
|
|
12199
12770
|
function $mol_style_define(Component, config) {
|
|
12200
12771
|
return $mol_style_attach(Component.name, $mol_style_sheet(Component, config));
|
|
12201
12772
|
}
|
|
@@ -12205,12 +12776,17 @@ var $;
|
|
|
12205
12776
|
;
|
|
12206
12777
|
"use strict";
|
|
12207
12778
|
|
|
12779
|
+
|
|
12208
12780
|
;
|
|
12209
12781
|
"use strict";
|
|
12210
12782
|
var $;
|
|
12211
12783
|
(function ($) {
|
|
12212
12784
|
var $$;
|
|
12213
12785
|
(function ($$) {
|
|
12786
|
+
/**
|
|
12787
|
+
* Scrolling pane.
|
|
12788
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_scroll_demo
|
|
12789
|
+
*/
|
|
12214
12790
|
class $mol_scroll extends $.$mol_scroll {
|
|
12215
12791
|
scroll_top(next, cache) {
|
|
12216
12792
|
const el = this.dom_node();
|
|
@@ -12260,6 +12836,7 @@ var $;
|
|
|
12260
12836
|
direction: 'column',
|
|
12261
12837
|
grow: 1,
|
|
12262
12838
|
shrink: 1,
|
|
12839
|
+
// basis: 0,
|
|
12263
12840
|
},
|
|
12264
12841
|
outline: 'none',
|
|
12265
12842
|
align: {
|
|
@@ -12277,6 +12854,7 @@ var $;
|
|
|
12277
12854
|
contain: 'content',
|
|
12278
12855
|
'>': {
|
|
12279
12856
|
$mol_view: {
|
|
12857
|
+
// transform: 'translateZ(0)', // enforce gpu scroll in all agents
|
|
12280
12858
|
gridArea: '1/1',
|
|
12281
12859
|
},
|
|
12282
12860
|
},
|
|
@@ -12389,6 +12967,7 @@ var $;
|
|
|
12389
12967
|
;
|
|
12390
12968
|
"use strict";
|
|
12391
12969
|
|
|
12970
|
+
|
|
12392
12971
|
;
|
|
12393
12972
|
"use strict";
|
|
12394
12973
|
var $;
|
|
@@ -12409,6 +12988,8 @@ var $;
|
|
|
12409
12988
|
maxHeight: per(100),
|
|
12410
12989
|
boxSizing: 'border-box',
|
|
12411
12990
|
color: $mol_theme.text,
|
|
12991
|
+
// backdropFilter: blur( `3px` ), enforces layering
|
|
12992
|
+
// zIndex: 0 ,
|
|
12412
12993
|
':focus': {
|
|
12413
12994
|
outline: 'none',
|
|
12414
12995
|
},
|
|
@@ -12926,99 +13507,131 @@ var $;
|
|
|
12926
13507
|
;
|
|
12927
13508
|
"use strict";
|
|
12928
13509
|
|
|
13510
|
+
|
|
12929
13511
|
;
|
|
12930
13512
|
"use strict";
|
|
12931
13513
|
|
|
13514
|
+
|
|
12932
13515
|
;
|
|
12933
13516
|
"use strict";
|
|
12934
13517
|
|
|
13518
|
+
|
|
12935
13519
|
;
|
|
12936
13520
|
"use strict";
|
|
12937
13521
|
|
|
13522
|
+
|
|
12938
13523
|
;
|
|
12939
13524
|
"use strict";
|
|
12940
13525
|
|
|
13526
|
+
|
|
12941
13527
|
;
|
|
12942
13528
|
"use strict";
|
|
12943
13529
|
|
|
13530
|
+
|
|
12944
13531
|
;
|
|
12945
13532
|
"use strict";
|
|
12946
13533
|
|
|
13534
|
+
|
|
12947
13535
|
;
|
|
12948
13536
|
"use strict";
|
|
12949
13537
|
|
|
13538
|
+
|
|
12950
13539
|
;
|
|
12951
13540
|
"use strict";
|
|
12952
13541
|
|
|
13542
|
+
|
|
12953
13543
|
;
|
|
12954
13544
|
"use strict";
|
|
12955
13545
|
|
|
13546
|
+
|
|
12956
13547
|
;
|
|
12957
13548
|
"use strict";
|
|
12958
13549
|
|
|
13550
|
+
|
|
12959
13551
|
;
|
|
12960
13552
|
"use strict";
|
|
12961
13553
|
|
|
13554
|
+
|
|
12962
13555
|
;
|
|
12963
13556
|
"use strict";
|
|
12964
13557
|
|
|
13558
|
+
|
|
12965
13559
|
;
|
|
12966
13560
|
"use strict";
|
|
12967
13561
|
|
|
13562
|
+
|
|
12968
13563
|
;
|
|
12969
13564
|
"use strict";
|
|
12970
13565
|
|
|
13566
|
+
|
|
12971
13567
|
;
|
|
12972
13568
|
"use strict";
|
|
12973
13569
|
|
|
13570
|
+
|
|
12974
13571
|
;
|
|
12975
13572
|
"use strict";
|
|
12976
13573
|
|
|
13574
|
+
|
|
12977
13575
|
;
|
|
12978
13576
|
"use strict";
|
|
12979
13577
|
|
|
13578
|
+
|
|
12980
13579
|
;
|
|
12981
13580
|
"use strict";
|
|
12982
13581
|
|
|
13582
|
+
|
|
12983
13583
|
;
|
|
12984
13584
|
"use strict";
|
|
12985
13585
|
|
|
13586
|
+
|
|
12986
13587
|
;
|
|
12987
13588
|
"use strict";
|
|
12988
13589
|
|
|
13590
|
+
|
|
12989
13591
|
;
|
|
12990
13592
|
"use strict";
|
|
12991
13593
|
|
|
13594
|
+
|
|
12992
13595
|
;
|
|
12993
13596
|
"use strict";
|
|
12994
13597
|
|
|
13598
|
+
|
|
12995
13599
|
;
|
|
12996
13600
|
"use strict";
|
|
12997
13601
|
|
|
13602
|
+
|
|
12998
13603
|
;
|
|
12999
13604
|
"use strict";
|
|
13000
13605
|
|
|
13606
|
+
|
|
13001
13607
|
;
|
|
13002
13608
|
"use strict";
|
|
13003
13609
|
|
|
13610
|
+
|
|
13004
13611
|
;
|
|
13005
13612
|
"use strict";
|
|
13006
13613
|
|
|
13614
|
+
|
|
13007
13615
|
;
|
|
13008
13616
|
"use strict";
|
|
13009
13617
|
|
|
13618
|
+
|
|
13010
13619
|
;
|
|
13011
13620
|
"use strict";
|
|
13012
13621
|
|
|
13622
|
+
|
|
13013
13623
|
;
|
|
13014
13624
|
"use strict";
|
|
13015
13625
|
|
|
13626
|
+
|
|
13016
13627
|
;
|
|
13017
13628
|
"use strict";
|
|
13018
13629
|
|
|
13630
|
+
|
|
13019
13631
|
;
|
|
13020
13632
|
"use strict";
|
|
13021
13633
|
|
|
13634
|
+
|
|
13022
13635
|
;
|
|
13023
13636
|
"use strict";
|
|
13024
13637
|
var $;
|
|
@@ -13054,45 +13667,59 @@ var $;
|
|
|
13054
13667
|
;
|
|
13055
13668
|
"use strict";
|
|
13056
13669
|
|
|
13670
|
+
|
|
13057
13671
|
;
|
|
13058
13672
|
"use strict";
|
|
13059
13673
|
|
|
13674
|
+
|
|
13060
13675
|
;
|
|
13061
13676
|
"use strict";
|
|
13062
13677
|
|
|
13678
|
+
|
|
13063
13679
|
;
|
|
13064
13680
|
"use strict";
|
|
13065
13681
|
|
|
13682
|
+
|
|
13066
13683
|
;
|
|
13067
13684
|
"use strict";
|
|
13068
13685
|
|
|
13686
|
+
|
|
13069
13687
|
;
|
|
13070
13688
|
"use strict";
|
|
13071
13689
|
|
|
13690
|
+
|
|
13072
13691
|
;
|
|
13073
13692
|
"use strict";
|
|
13074
13693
|
|
|
13694
|
+
|
|
13075
13695
|
;
|
|
13076
13696
|
"use strict";
|
|
13077
13697
|
|
|
13698
|
+
|
|
13078
13699
|
;
|
|
13079
13700
|
"use strict";
|
|
13080
13701
|
|
|
13702
|
+
|
|
13081
13703
|
;
|
|
13082
13704
|
"use strict";
|
|
13083
13705
|
|
|
13706
|
+
|
|
13084
13707
|
;
|
|
13085
13708
|
"use strict";
|
|
13086
13709
|
|
|
13710
|
+
|
|
13087
13711
|
;
|
|
13088
13712
|
"use strict";
|
|
13089
13713
|
|
|
13714
|
+
|
|
13090
13715
|
;
|
|
13091
13716
|
"use strict";
|
|
13092
13717
|
|
|
13718
|
+
|
|
13093
13719
|
;
|
|
13094
13720
|
"use strict";
|
|
13095
13721
|
|
|
13722
|
+
|
|
13096
13723
|
;
|
|
13097
13724
|
"use strict";
|
|
13098
13725
|
var $;
|
|
@@ -13180,13 +13807,13 @@ var $;
|
|
|
13180
13807
|
$mol_view_tree2_to_js_test_run(`
|
|
13181
13808
|
Foo $mol_view
|
|
13182
13809
|
a!? $mol_view
|
|
13183
|
-
expanded <=> cell_test_expanded!? null
|
|
13810
|
+
expanded? <=> cell_test_expanded!? null
|
|
13184
13811
|
`);
|
|
13185
|
-
}, `Required prop like some*? at \`.view.tree#4:
|
|
13812
|
+
}, `Required prop like some*? at \`.view.tree#4:22/20\`
|
|
13186
13813
|
<=>
|
|
13187
|
-
.view.tree#4:
|
|
13188
|
-
expanded
|
|
13189
|
-
.view.tree#4:8/
|
|
13814
|
+
.view.tree#4:18/3
|
|
13815
|
+
expanded?
|
|
13816
|
+
.view.tree#4:8/9
|
|
13190
13817
|
$mol_view
|
|
13191
13818
|
.view.tree#3:11/9
|
|
13192
13819
|
a!?
|
|
@@ -13220,7 +13847,9 @@ var $;
|
|
|
13220
13847
|
'Left bind read only'($) {
|
|
13221
13848
|
const _foo = $mol_view_tree2_to_js_test_ex_left_read_only_foo;
|
|
13222
13849
|
const foo = _foo.make({ $ });
|
|
13223
|
-
$mol_assert_like(foo.bar1(),
|
|
13850
|
+
$mol_assert_like(foo.bar1(),
|
|
13851
|
+
// @ts-ignore
|
|
13852
|
+
foo.bar1(2), foo.bar1(), foo.bar2(), 1);
|
|
13224
13853
|
$mol_assert_like(foo.bar2(2), foo.bar1(), 2);
|
|
13225
13854
|
},
|
|
13226
13855
|
'Left bind second level index'($) {
|
|
@@ -13247,7 +13876,11 @@ var $;
|
|
|
13247
13876
|
const foo = _foo.make({ $ });
|
|
13248
13877
|
$mol_assert_equal(foo.d(), foo.c(), foo.b(), foo.a(), 0);
|
|
13249
13878
|
$mol_assert_equal(foo.d(1), foo.c(), foo.b(), foo.a(), 1);
|
|
13250
|
-
$mol_assert_equal(
|
|
13879
|
+
$mol_assert_equal(
|
|
13880
|
+
// @ts-ignore
|
|
13881
|
+
foo.a(2),
|
|
13882
|
+
// @ts-ignore
|
|
13883
|
+
foo.b(2), foo.c(), foo.d(), 1);
|
|
13251
13884
|
$mol_assert_equal(foo.c(2), foo.b(), foo.a(), 2);
|
|
13252
13885
|
$mol_assert_equal(foo.d(1), 1);
|
|
13253
13886
|
$mol_assert_equal(foo.d(3), foo.c(), foo.b(), foo.a(), 3);
|
|
@@ -13283,6 +13916,10 @@ var $;
|
|
|
13283
13916
|
'Array of array or object'($) {
|
|
13284
13917
|
const _foo = $mol_view_tree2_to_js_test_ex_array_of_array_or_object_foo;
|
|
13285
13918
|
const foo = _foo.make({ $ });
|
|
13919
|
+
// type a1 = $mol_type_assert<
|
|
13920
|
+
// ReturnType<typeof foo.complex>,
|
|
13921
|
+
// readonly (readonly(number | string)[] | Record<string, number | string>)[]
|
|
13922
|
+
// >
|
|
13286
13923
|
$mol_assert_like(foo.complex(), ['1', [true], ['1', 21], { a: 1, str: 'some' }]);
|
|
13287
13924
|
},
|
|
13288
13925
|
'Array inheritance'($) {
|
|
@@ -13374,7 +14011,9 @@ var $;
|
|
|
13374
14011
|
'simple mutable and read only channels'($) {
|
|
13375
14012
|
const _foo = $mol_view_tree2_to_js_test_ex_simple_mutable_and_read_only_foo;
|
|
13376
14013
|
const foo = _foo.make({ $ });
|
|
13377
|
-
$mol_assert_equal(foo.readonly(),
|
|
14014
|
+
$mol_assert_equal(foo.readonly(),
|
|
14015
|
+
// @ts-ignore
|
|
14016
|
+
foo.readonly(1), foo.readonly(), null);
|
|
13378
14017
|
$mol_assert_equal(foo.mutable(), null);
|
|
13379
14018
|
$mol_assert_equal(foo.mutable(2), foo.mutable(), 2);
|
|
13380
14019
|
},
|