mol_dump_lib 0.0.1026 → 0.0.1028

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.test.js CHANGED
@@ -32,7 +32,7 @@ var $;
32
32
  "use strict";
33
33
  var $;
34
34
  (function ($) {
35
- const mod = require('module');
35
+ const mod = require /****/('module');
36
36
  const internals = mod.builtinModules;
37
37
  function $node_internal_check(name) {
38
38
  if (name.startsWith('node:'))
@@ -72,7 +72,7 @@ var $;
72
72
  var $;
73
73
  (function ($) {
74
74
  function $mol_fail_hidden(error) {
75
- throw error;
75
+ throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
76
76
  }
77
77
  $.$mol_fail_hidden = $mol_fail_hidden;
78
78
  })($ || ($ = {}));
@@ -130,8 +130,8 @@ var $;
130
130
  "use strict";
131
131
  var $;
132
132
  (function ($) {
133
- const path = require('path');
134
- const mod = require('module');
133
+ const path = require /****/('path');
134
+ const mod = require /****/('module');
135
135
  const localRequire = mod.createRequire(path.join(process.cwd(), 'package.json'));
136
136
  function $node_autoinstall(name) {
137
137
  try {
@@ -238,6 +238,7 @@ var $;
238
238
  ])
239
239
  ].map(frame_normalize).join('\n')
240
240
  });
241
+ // в nodejs, что б не дублировалось cause в консоли
241
242
  Object.defineProperty(this, 'cause', {
242
243
  get: () => cause
243
244
  });
@@ -271,6 +272,11 @@ var $;
271
272
  var $;
272
273
  (function ($) {
273
274
  const instances = new WeakSet();
275
+ /**
276
+ * Proxy that delegates all to lazy returned target.
277
+ *
278
+ * $mol_delegate( Array.prototype , ()=> fetch_array() )
279
+ */
274
280
  function $mol_delegate(proto, target) {
275
281
  const proxy = new Proxy(proto, {
276
282
  get: (_, field) => {
@@ -414,6 +420,9 @@ var $;
414
420
  [Symbol.dispose]() {
415
421
  this.destructor();
416
422
  }
423
+ //[ Symbol.toPrimitive ]( hint: string ) {
424
+ // return hint === 'number' ? this.valueOf() : this.toString()
425
+ //}
417
426
  toString() {
418
427
  return this[Symbol.toStringTag] || this.constructor.name + '<>';
419
428
  }
@@ -464,6 +473,7 @@ var $;
464
473
  "use strict";
465
474
  var $;
466
475
  (function ($) {
476
+ /** Generates unique identifier. */
467
477
  function $mol_guid(length = 8, exists = () => false) {
468
478
  for (;;) {
469
479
  let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
@@ -479,11 +489,16 @@ var $;
479
489
  "use strict";
480
490
  var $;
481
491
  (function ($) {
492
+ /** Special status statuses. */
482
493
  let $mol_wire_cursor;
483
494
  (function ($mol_wire_cursor) {
495
+ /** Update required. */
484
496
  $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
497
+ /** Some of (transitive) pub update required. */
485
498
  $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
499
+ /** Actual state but may be dropped. */
486
500
  $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
501
+ /** State will never be changed. */
487
502
  $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
488
503
  })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
489
504
  })($ || ($ = {}));
@@ -492,6 +507,9 @@ var $;
492
507
  "use strict";
493
508
  var $;
494
509
  (function ($) {
510
+ /**
511
+ * Collects subscribers in compact array. 28B
512
+ */
495
513
  class $mol_wire_pub extends Object {
496
514
  constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
497
515
  super();
@@ -499,10 +517,17 @@ var $;
499
517
  }
500
518
  [Symbol.toStringTag];
501
519
  data = [];
520
+ // Derived objects should be Arrays.
502
521
  static get [Symbol.species]() {
503
522
  return Array;
504
523
  }
505
- sub_from = 0;
524
+ /**
525
+ * Index of first subscriber.
526
+ */
527
+ sub_from = 0; // 4B
528
+ /**
529
+ * All current subscribers.
530
+ */
506
531
  get sub_list() {
507
532
  const res = [];
508
533
  for (let i = this.sub_from; i < this.data.length; i += 2) {
@@ -510,14 +535,23 @@ var $;
510
535
  }
511
536
  return res;
512
537
  }
538
+ /**
539
+ * Has any subscribers or not.
540
+ */
513
541
  get sub_empty() {
514
542
  return this.sub_from === this.data.length;
515
543
  }
544
+ /**
545
+ * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
546
+ */
516
547
  sub_on(sub, pub_pos) {
517
548
  const pos = this.data.length;
518
549
  this.data.push(sub, pub_pos);
519
550
  return pos;
520
551
  }
552
+ /**
553
+ * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
554
+ */
521
555
  sub_off(sub_pos) {
522
556
  if (!(sub_pos < this.data.length)) {
523
557
  $mol_fail(new Error(`Wrong pos ${sub_pos}`));
@@ -530,21 +564,39 @@ var $;
530
564
  if (end === this.sub_from)
531
565
  this.reap();
532
566
  }
567
+ /**
568
+ * Called when last sub was unsubscribed.
569
+ **/
533
570
  reap() { }
571
+ /**
572
+ * Autowire this publisher with current subscriber.
573
+ **/
534
574
  promote() {
535
575
  $mol_wire_auto()?.track_next(this);
536
576
  }
577
+ /**
578
+ * Enforce actualization. Should not throw errors.
579
+ */
537
580
  fresh() { }
581
+ /**
582
+ * Allow to put data to caches in the subtree.
583
+ */
538
584
  complete() { }
539
585
  get incompleted() {
540
586
  return false;
541
587
  }
588
+ /**
589
+ * Notify subscribers about self changes.
590
+ */
542
591
  emit(quant = $mol_wire_cursor.stale) {
543
592
  for (let i = this.sub_from; i < this.data.length; i += 2) {
544
593
  ;
545
594
  this.data[i].absorb(quant, this.data[i + 1]);
546
595
  }
547
596
  }
597
+ /**
598
+ * Moves peer from one position to another. Doesn't clear data at old position!
599
+ */
548
600
  peer_move(from_pos, to_pos) {
549
601
  const peer = this.data[from_pos];
550
602
  const self_pos = this.data[from_pos + 1];
@@ -552,6 +604,9 @@ var $;
552
604
  this.data[to_pos + 1] = self_pos;
553
605
  peer.peer_repos(self_pos, to_pos);
554
606
  }
607
+ /**
608
+ * Updates self position in the peer.
609
+ */
555
610
  peer_repos(peer_pos, self_pos) {
556
611
  this.data[peer_pos + 1] = self_pos;
557
612
  }
@@ -567,10 +622,16 @@ var $;
567
622
  var $;
568
623
  (function ($) {
569
624
  $.$mol_wire_auto_sub = null;
625
+ /**
626
+ * When fulfilled, all publishers are promoted to this subscriber on access to its.
627
+ */
570
628
  function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
571
629
  return $.$mol_wire_auto_sub = next;
572
630
  }
573
631
  $.$mol_wire_auto = $mol_wire_auto;
632
+ /**
633
+ * Affection queue. Used to prevent accidental stack overflow on emit.
634
+ */
574
635
  $.$mol_wire_affected = [];
575
636
  })($ || ($ = {}));
576
637
 
@@ -578,6 +639,7 @@ var $;
578
639
  "use strict";
579
640
  var $;
580
641
  (function ($) {
642
+ // https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
581
643
  $['devtoolsFormatters'] ||= [];
582
644
  function $mol_dev_format_register(config) {
583
645
  $['devtoolsFormatters'].push(config);
@@ -629,6 +691,7 @@ var $;
629
691
  return false;
630
692
  if (!val)
631
693
  return false;
694
+ // if( Error.isError( val ) ) true
632
695
  if (val[$.$mol_dev_format_body])
633
696
  return true;
634
697
  return false;
@@ -646,12 +709,16 @@ var $;
646
709
  return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
647
710
  }
648
711
  }
712
+ // if( Error.isError( val ) ) {
713
+ // return $mol_dev_format_native( val )
714
+ // }
649
715
  return null;
650
716
  },
651
717
  });
652
718
  function $mol_dev_format_native(obj) {
653
719
  if (typeof obj === 'undefined')
654
720
  return $.$mol_dev_format_shade('undefined');
721
+ // if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
655
722
  return [
656
723
  'object',
657
724
  {
@@ -709,6 +776,9 @@ var $;
709
776
  'margin-left': '13px'
710
777
  });
711
778
  class Stack extends Array {
779
+ // [ Symbol.toPrimitive ]() {
780
+ // return this.toString()
781
+ // }
712
782
  toString() {
713
783
  return this.join('\n');
714
784
  }
@@ -731,6 +801,7 @@ var $;
731
801
  this.method = call.getMethodName() ?? '';
732
802
  if (this.method === this.function)
733
803
  this.method = '';
804
+ // const func = c.getFunction()
734
805
  this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
735
806
  this.eval = call.getEvalOrigin() ?? '';
736
807
  this.source = call.getScriptNameOrSourceURL() ?? '';
@@ -777,9 +848,16 @@ var $;
777
848
  "use strict";
778
849
  var $;
779
850
  (function ($) {
851
+ /**
852
+ * Publisher that can auto collect other publishers. 32B
853
+ *
854
+ * P1 P2 P3 P4 S1 S2 S3
855
+ * ^ ^
856
+ * pubs_from subs_from
857
+ */
780
858
  class $mol_wire_pub_sub extends $mol_wire_pub {
781
- pub_from = 0;
782
- cursor = $mol_wire_cursor.stale;
859
+ pub_from = 0; // 4B
860
+ cursor = $mol_wire_cursor.stale; // 4B
783
861
  get temp() {
784
862
  return false;
785
863
  }
@@ -897,10 +975,27 @@ var $;
897
975
  return;
898
976
  this.cursor = quant;
899
977
  this.emit($mol_wire_cursor.doubt);
978
+ // if( pos >= 0 && pos < this.sub_from - 2 ) {
979
+ // const pub = this.data[ pos ] as $mol_wire_pub
980
+ // if( pub instanceof $mol_wire_task ) return
981
+ // for(
982
+ // let cursor = this.pub_from;
983
+ // cursor < this.sub_from;
984
+ // cursor += 2
985
+ // ) {
986
+ // const pub = this.data[ cursor ] as $mol_wire_pub
987
+ // if( pub instanceof $mol_wire_task ) {
988
+ // pub.destructor()
989
+ // }
990
+ // }
991
+ // }
900
992
  }
901
993
  [$mol_dev_format_head]() {
902
994
  return $mol_dev_format_native(this);
903
995
  }
996
+ /**
997
+ * Is subscribed to any publisher or not.
998
+ */
904
999
  get pub_empty() {
905
1000
  return this.sub_from === this.pub_from;
906
1001
  }
@@ -941,6 +1036,13 @@ var $;
941
1036
  var $;
942
1037
  (function ($) {
943
1038
  const wrappers = new WeakMap();
1039
+ /**
1040
+ * Suspendable task with support both sync/async api.
1041
+ *
1042
+ * A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
1043
+ * ^ ^ ^
1044
+ * args_from pubs_from subs_from
1045
+ **/
944
1046
  class $mol_wire_fiber extends $mol_wire_pub_sub {
945
1047
  task;
946
1048
  host;
@@ -961,6 +1063,7 @@ var $;
961
1063
  });
962
1064
  }
963
1065
  static sync() {
1066
+ // Sync whole fiber graph
964
1067
  while (this.planning.size) {
965
1068
  for (const fiber of this.planning) {
966
1069
  this.planning.delete(fiber);
@@ -971,6 +1074,7 @@ var $;
971
1074
  fiber.fresh();
972
1075
  }
973
1076
  }
1077
+ // Collect garbage
974
1078
  while (this.reaping.size) {
975
1079
  const fibers = this.reaping;
976
1080
  this.reaping = new Set;
@@ -1122,6 +1226,10 @@ var $;
1122
1226
  this.cursor = $mol_wire_cursor.stale;
1123
1227
  this.fresh();
1124
1228
  }
1229
+ /**
1230
+ * Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
1231
+ * Should be called inside SuspenseAPI consumer (ie fiber).
1232
+ */
1125
1233
  sync() {
1126
1234
  if (!$mol_wire_fiber.warm) {
1127
1235
  return this.result();
@@ -1136,6 +1244,10 @@ var $;
1136
1244
  }
1137
1245
  return this.cache;
1138
1246
  }
1247
+ /**
1248
+ * Asynchronous execution.
1249
+ * It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
1250
+ */
1139
1251
  async async_raw() {
1140
1252
  while (true) {
1141
1253
  this.fresh();
@@ -1148,6 +1260,7 @@ var $;
1148
1260
  if (!$mol_promise_like(this.cache))
1149
1261
  return this.cache;
1150
1262
  if (this.cursor === $mol_wire_cursor.final) {
1263
+ // never ends on destructed fiber
1151
1264
  await new Promise(() => { });
1152
1265
  }
1153
1266
  }
@@ -1195,6 +1308,10 @@ var $;
1195
1308
  var $;
1196
1309
  (function ($) {
1197
1310
  $.$mol_compare_deep_cache = new WeakMap();
1311
+ /**
1312
+ * Deeply compares two values. Returns true if equal.
1313
+ * Define `Symbol.toPrimitive` to customize.
1314
+ */
1198
1315
  function $mol_compare_deep(left, right) {
1199
1316
  if (Object.is(left, right))
1200
1317
  return true;
@@ -1334,6 +1451,7 @@ var $;
1334
1451
  "use strict";
1335
1452
  var $;
1336
1453
  (function ($) {
1454
+ /** Log begin of collapsed group only when some logged inside, returns func to close group */
1337
1455
  function $mol_log3_area_lazy(event) {
1338
1456
  const self = this.$;
1339
1457
  const stack = self.$mol_log3_stack;
@@ -1358,6 +1476,7 @@ var $;
1358
1476
  "use strict";
1359
1477
  var $;
1360
1478
  (function ($) {
1479
+ /** Position in any resource. */
1361
1480
  class $mol_span extends $mol_object2 {
1362
1481
  uri;
1363
1482
  source;
@@ -1373,13 +1492,17 @@ var $;
1373
1492
  this.length = length;
1374
1493
  this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
1375
1494
  }
1495
+ /** Span for begin of unknown resource */
1376
1496
  static unknown = $mol_span.begin('?');
1497
+ /** Makes new span for begin of resource. */
1377
1498
  static begin(uri, source = '') {
1378
1499
  return new $mol_span(uri, source, 1, 1, 0);
1379
1500
  }
1501
+ /** Makes new span for end of resource. */
1380
1502
  static end(uri, source) {
1381
1503
  return new $mol_span(uri, source, 1, source.length + 1, 0);
1382
1504
  }
1505
+ /** Makes new span for entire resource. */
1383
1506
  static entire(uri, source) {
1384
1507
  return new $mol_span(uri, source, 1, 1, source.length);
1385
1508
  }
@@ -1394,15 +1517,19 @@ var $;
1394
1517
  length: this.length
1395
1518
  };
1396
1519
  }
1520
+ /** Makes new error for this span. */
1397
1521
  error(message, Class = Error) {
1398
1522
  return new Class(`${message} (${this})`);
1399
1523
  }
1524
+ /** Makes new span for same uri. */
1400
1525
  span(row, col, length) {
1401
1526
  return new $mol_span(this.uri, this.source, row, col, length);
1402
1527
  }
1528
+ /** Makes new span after end of this. */
1403
1529
  after(length = 0) {
1404
1530
  return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
1405
1531
  }
1532
+ /** Makes new span between begin and end. */
1406
1533
  slice(begin, end = -1) {
1407
1534
  let len = this.length;
1408
1535
  if (begin < 0)
@@ -1425,6 +1552,7 @@ var $;
1425
1552
  "use strict";
1426
1553
  var $;
1427
1554
  (function ($) {
1555
+ /** Serializes tree to string in tree format. */
1428
1556
  function $mol_tree2_to_string(tree) {
1429
1557
  let output = [];
1430
1558
  function dump(tree, prefix = '') {
@@ -1468,12 +1596,25 @@ var $;
1468
1596
  "use strict";
1469
1597
  var $;
1470
1598
  (function ($) {
1599
+ /**
1600
+ * Abstract Syntax Tree with human readable serialization.
1601
+ * Avoid direct instantiation. Use static factories instead.
1602
+ * @see https://github.com/nin-jin/tree.d
1603
+ */
1471
1604
  class $mol_tree2 extends Object {
1472
1605
  type;
1473
1606
  value;
1474
1607
  kids;
1475
1608
  span;
1476
- constructor(type, value, kids, span) {
1609
+ constructor(
1610
+ /** Type of structural node, `value` should be empty */
1611
+ type,
1612
+ /** Content of data node, `type` should be empty */
1613
+ value,
1614
+ /** Child nodes */
1615
+ kids,
1616
+ /** Position in most far source resource */
1617
+ span) {
1477
1618
  super();
1478
1619
  this.type = type;
1479
1620
  this.value = value;
@@ -1481,12 +1622,15 @@ var $;
1481
1622
  this.span = span;
1482
1623
  this[Symbol.toStringTag] = type || '\\' + value;
1483
1624
  }
1625
+ /** Makes collection node. */
1484
1626
  static list(kids, span = $mol_span.unknown) {
1485
1627
  return new $mol_tree2('', '', kids, span);
1486
1628
  }
1629
+ /** Makes new derived collection node. */
1487
1630
  list(kids) {
1488
1631
  return $mol_tree2.list(kids, this.span);
1489
1632
  }
1633
+ /** Makes data node for any string. */
1490
1634
  static data(value, kids = [], span = $mol_span.unknown) {
1491
1635
  const chunks = value.split('\n');
1492
1636
  if (chunks.length > 1) {
@@ -1500,21 +1644,26 @@ var $;
1500
1644
  }
1501
1645
  return new $mol_tree2('', value, kids, span);
1502
1646
  }
1647
+ /** Makes new derived data node. */
1503
1648
  data(value, kids = []) {
1504
1649
  return $mol_tree2.data(value, kids, this.span);
1505
1650
  }
1651
+ /** Makes struct node. */
1506
1652
  static struct(type, kids = [], span = $mol_span.unknown) {
1507
1653
  if (/[ \n\t\\]/.test(type)) {
1508
1654
  $$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
1509
1655
  }
1510
1656
  return new $mol_tree2(type, '', kids, span);
1511
1657
  }
1658
+ /** Makes new derived structural node. */
1512
1659
  struct(type, kids = []) {
1513
1660
  return $mol_tree2.struct(type, kids, this.span);
1514
1661
  }
1662
+ /** Makes new derived node with different kids id defined. */
1515
1663
  clone(kids, span = this.span) {
1516
1664
  return new $mol_tree2(this.type, this.value, kids, span);
1517
1665
  }
1666
+ /** Returns multiline text content. */
1518
1667
  text() {
1519
1668
  var values = [];
1520
1669
  for (var kid of this.kids) {
@@ -1524,15 +1673,20 @@ var $;
1524
1673
  }
1525
1674
  return this.value + values.join('\n');
1526
1675
  }
1676
+ /** Parses tree format. */
1677
+ /** @deprecated Use $mol_tree2_from_string */
1527
1678
  static fromString(str, uri = 'unknown') {
1528
1679
  return $$.$mol_tree2_from_string(str, uri);
1529
1680
  }
1681
+ /** Serializes to tree format. */
1530
1682
  toString() {
1531
1683
  return $$.$mol_tree2_to_string(this);
1532
1684
  }
1685
+ /** Makes new tree with node overrided by path. */
1533
1686
  insert(value, ...path) {
1534
1687
  return this.update($mol_maybe(value), ...path)[0];
1535
1688
  }
1689
+ /** Makes new tree with node overrided by path. */
1536
1690
  update(value, ...path) {
1537
1691
  if (path.length === 0)
1538
1692
  return value;
@@ -1565,6 +1719,7 @@ var $;
1565
1719
  return [this.clone(kids)];
1566
1720
  }
1567
1721
  }
1722
+ /** Query nodes by path. */
1568
1723
  select(...path) {
1569
1724
  let next = [this];
1570
1725
  for (const type of path) {
@@ -1591,6 +1746,7 @@ var $;
1591
1746
  }
1592
1747
  return this.list(next);
1593
1748
  }
1749
+ /** Filter kids by path or value. */
1594
1750
  filter(path, value) {
1595
1751
  const sub = this.kids.filter(item => {
1596
1752
  var found = item.select(...path);
@@ -1618,9 +1774,11 @@ var $;
1618
1774
  $mol_fail_hidden(error);
1619
1775
  }
1620
1776
  }
1777
+ /** Transform tree through context with transformers */
1621
1778
  hack(belt, context = {}) {
1622
1779
  return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
1623
1780
  }
1781
+ /** Makes Error with node coordinates. */
1624
1782
  error(message, Class = Error) {
1625
1783
  return this.span.error(`${message}\n${this.clone([])}`, Class);
1626
1784
  }
@@ -1638,6 +1796,7 @@ var $;
1638
1796
  "use strict";
1639
1797
  var $;
1640
1798
  (function ($) {
1799
+ /** Syntax error with cordinates and source line snippet. */
1641
1800
  class $mol_error_syntax extends SyntaxError {
1642
1801
  reason;
1643
1802
  line;
@@ -1656,6 +1815,7 @@ var $;
1656
1815
  "use strict";
1657
1816
  var $;
1658
1817
  (function ($) {
1818
+ /** Parses tree format from string. */
1659
1819
  function $mol_tree2_from_string(str, uri = '?') {
1660
1820
  const span = $mol_span.entire(uri, str);
1661
1821
  var root = $mol_tree2.list([], span);
@@ -1665,6 +1825,7 @@ var $;
1665
1825
  var indent = 0;
1666
1826
  var line_start = pos;
1667
1827
  row++;
1828
+ // read indent
1668
1829
  while (str.length > pos && str[pos] == '\t') {
1669
1830
  indent++;
1670
1831
  pos++;
@@ -1673,8 +1834,10 @@ var $;
1673
1834
  min_indent = indent;
1674
1835
  }
1675
1836
  indent -= min_indent;
1837
+ // invalid tab size
1676
1838
  if (indent < 0 || indent >= stack.length) {
1677
1839
  const sp = span.span(row, 1, pos - line_start);
1840
+ // skip error line
1678
1841
  while (str.length > pos && str[pos] != '\n') {
1679
1842
  pos++;
1680
1843
  }
@@ -1689,7 +1852,9 @@ var $;
1689
1852
  }
1690
1853
  stack.length = indent + 1;
1691
1854
  var parent = stack[indent];
1855
+ // parse types
1692
1856
  while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
1857
+ // type can not contain space and tab
1693
1858
  var error_start = pos;
1694
1859
  while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
1695
1860
  pos++;
@@ -1701,6 +1866,7 @@ var $;
1701
1866
  const sp = span.span(row, error_start - line_start + 1, pos - error_start);
1702
1867
  this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
1703
1868
  }
1869
+ // read type
1704
1870
  var type_start = pos;
1705
1871
  while (str.length > pos &&
1706
1872
  str[pos] != '\\' &&
@@ -1715,10 +1881,12 @@ var $;
1715
1881
  parent_kids.push(next);
1716
1882
  parent = next;
1717
1883
  }
1884
+ // read one space if exists
1718
1885
  if (str.length > pos && str[pos] == ' ') {
1719
1886
  pos++;
1720
1887
  }
1721
1888
  }
1889
+ // read data
1722
1890
  if (str.length > pos && str[pos] == '\\') {
1723
1891
  var data_start = pos;
1724
1892
  while (str.length > pos && str[pos] != '\n') {
@@ -1729,6 +1897,7 @@ var $;
1729
1897
  parent_kids.push(next);
1730
1898
  parent = next;
1731
1899
  }
1900
+ // now must be end of text
1732
1901
  if (str.length === pos && stack.length > 0) {
1733
1902
  const sp = span.span(row, pos - line_start + 1, 1);
1734
1903
  this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
@@ -1821,6 +1990,7 @@ var $;
1821
1990
  "use strict";
1822
1991
  var $;
1823
1992
  (function ($) {
1993
+ /** Module for working with terminal. Text coloring when output in terminal */
1824
1994
  class $mol_term_color {
1825
1995
  static reset = this.ansi(0, 0);
1826
1996
  static bold = this.ansi(1, 22);
@@ -1892,6 +2062,7 @@ var $;
1892
2062
  "use strict";
1893
2063
  var $;
1894
2064
  (function ($) {
2065
+ /** One-shot fiber */
1895
2066
  class $mol_wire_task extends $mol_wire_fiber {
1896
2067
  static getter(task) {
1897
2068
  return function $mol_wire_task_get(host, args) {
@@ -1917,6 +2088,7 @@ var $;
1917
2088
  }
1918
2089
  const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
1919
2090
  const next = new $mol_wire_task(key, task, host, args);
2091
+ // Disabled because non-idempotency is required for try-catch
1920
2092
  if (existen?.temp) {
1921
2093
  $$.$mol_log3_warn({
1922
2094
  place: '$mol_wire_task',
@@ -1949,7 +2121,7 @@ var $;
1949
2121
  try {
1950
2122
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
1951
2123
  }
1952
- catch {
2124
+ catch { // Promises throw in strict mode
1953
2125
  Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1954
2126
  }
1955
2127
  }
@@ -2002,6 +2174,10 @@ var $;
2002
2174
  props[field] = get_val;
2003
2175
  return get_val;
2004
2176
  }
2177
+ /**
2178
+ * Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
2179
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
2180
+ */
2005
2181
  function $mol_wire_sync(obj) {
2006
2182
  return new Proxy(obj, {
2007
2183
  get(obj, field) {
@@ -2243,6 +2419,10 @@ var $;
2243
2419
  "use strict";
2244
2420
  var $;
2245
2421
  (function ($) {
2422
+ /**
2423
+ * CSS Units
2424
+ * @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
2425
+ */
2246
2426
  class $mol_style_unit extends $mol_decor {
2247
2427
  literal;
2248
2428
  constructor(value, literal) {
@@ -2289,6 +2469,10 @@ var $;
2289
2469
  var $;
2290
2470
  (function ($) {
2291
2471
  const { per } = $mol_style_unit;
2472
+ /**
2473
+ * CSS Functions
2474
+ * @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
2475
+ */
2292
2476
  class $mol_style_func extends $mol_decor {
2293
2477
  name;
2294
2478
  constructor(name, value) {
@@ -2383,6 +2567,7 @@ var $;
2383
2567
  "use strict";
2384
2568
  var $;
2385
2569
  (function ($) {
2570
+ /** Create record of CSS variables. */
2386
2571
  function $mol_style_prop(prefix, keys) {
2387
2572
  const record = keys.reduce((rec, key) => {
2388
2573
  rec[key] = $mol_style_func.vary(`--${prefix}_${key}`);
@@ -2397,6 +2582,10 @@ var $;
2397
2582
  "use strict";
2398
2583
  var $;
2399
2584
  (function ($) {
2585
+ /**
2586
+ * Theme css variables
2587
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_textarea_demo
2588
+ */
2400
2589
  $.$mol_theme = $mol_style_prop('mol_theme', [
2401
2590
  'back',
2402
2591
  'hover',
@@ -2425,11 +2614,18 @@ var $;
2425
2614
 
2426
2615
  ;
2427
2616
  "use strict";
2617
+ // namespace $ {
2618
+ // $mol_style_attach( '$mol_theme_lights', `:root { --mol_theme_back: oklch( ${ $$.$mol_lights() ? 92 : 20 }% .01 var(--mol_theme_hue) ) }` )
2619
+ // }
2428
2620
 
2429
2621
  ;
2430
2622
  "use strict";
2431
2623
  var $;
2432
2624
  (function ($) {
2625
+ /**
2626
+ * Gap in CSS
2627
+ * @see https://page.hyoo.ru/#!=msdb74_bm7nsq
2628
+ */
2433
2629
  $.$mol_gap = $mol_style_prop('mol_gap', [
2434
2630
  'page',
2435
2631
  'block',
@@ -2519,6 +2715,12 @@ var $;
2519
2715
  createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
2520
2716
  };
2521
2717
  $.$mol_jsx_frag = '';
2718
+ /**
2719
+ * JSX adapter that makes DOM tree.
2720
+ * Generates global unique ids for every DOM-element by components tree with ids.
2721
+ * Ensures all local ids are unique.
2722
+ * Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
2723
+ */
2522
2724
  function $mol_jsx(Elem, props, ...childNodes) {
2523
2725
  const id = props && props.id || '';
2524
2726
  const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
@@ -2647,6 +2849,7 @@ var $;
2647
2849
  var $;
2648
2850
  (function ($) {
2649
2851
  const TypedArray = Object.getPrototypeOf(Uint8Array);
2852
+ /** Returns string key for any value. */
2650
2853
  function $mol_key(value) {
2651
2854
  primitives: {
2652
2855
  if (typeof value === 'bigint')
@@ -2654,9 +2857,9 @@ var $;
2654
2857
  if (typeof value === 'symbol')
2655
2858
  return `Symbol(${value.description})`;
2656
2859
  if (!value)
2657
- return JSON.stringify(value);
2860
+ return JSON.stringify(value); // 0, null, ""
2658
2861
  if (typeof value !== 'object' && typeof value !== 'function')
2659
- return JSON.stringify(value);
2862
+ return JSON.stringify(value); // boolean, number, string
2660
2863
  }
2661
2864
  caching: {
2662
2865
  let key = $mol_key_store.get(value);
@@ -2733,6 +2936,9 @@ var $;
2733
2936
  "use strict";
2734
2937
  var $;
2735
2938
  (function ($) {
2939
+ /**
2940
+ * Decorates method to fiber to ensure it is executed only once inside other fiber.
2941
+ */
2736
2942
  function $mol_wire_method(host, field, descr) {
2737
2943
  if (!descr)
2738
2944
  descr = Reflect.getOwnPropertyDescriptor(host, field);
@@ -2765,6 +2971,7 @@ var $;
2765
2971
  "use strict";
2766
2972
  var $;
2767
2973
  (function ($) {
2974
+ /** Long-living fiber. */
2768
2975
  class $mol_wire_atom extends $mol_wire_fiber {
2769
2976
  static solo(host, task) {
2770
2977
  const field = task.name + '()';
@@ -2815,7 +3022,11 @@ var $;
2815
3022
  }
2816
3023
  $mol_wire_atom.watching.add(this);
2817
3024
  }
3025
+ /**
3026
+ * Update atom value through another temp fiber.
3027
+ */
2818
3028
  resync(args) {
3029
+ // enforce pulling tasks abort
2819
3030
  for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
2820
3031
  const pub = this.data[cursor];
2821
3032
  if (pub && pub instanceof $mol_wire_task) {
@@ -2876,7 +3087,7 @@ var $;
2876
3087
  try {
2877
3088
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
2878
3089
  }
2879
- catch {
3090
+ catch { // Promises throw in strict mode
2880
3091
  Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
2881
3092
  }
2882
3093
  }
@@ -2904,6 +3115,7 @@ var $;
2904
3115
  "use strict";
2905
3116
  var $;
2906
3117
  (function ($) {
3118
+ /** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
2907
3119
  function $mol_wire_solo(host, field, descr) {
2908
3120
  if (!descr)
2909
3121
  descr = Reflect.getOwnPropertyDescriptor(host, field);
@@ -2942,6 +3154,7 @@ var $;
2942
3154
  "use strict";
2943
3155
  var $;
2944
3156
  (function ($) {
3157
+ /** Reactive memoizing multiplexed property decorator. */
2945
3158
  function $mol_wire_plex(host, field, descr) {
2946
3159
  if (!descr)
2947
3160
  descr = Reflect.getOwnPropertyDescriptor(host, field);
@@ -2980,7 +3193,25 @@ var $;
2980
3193
  "use strict";
2981
3194
  var $;
2982
3195
  (function ($) {
3196
+ /**
3197
+ * Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
3198
+ * @example
3199
+ * '@' $mol_mem
3200
+ * name(next?: string) {
3201
+ * return next ?? 'default'
3202
+ * }
3203
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
3204
+ */
2983
3205
  $.$mol_mem = $mol_wire_solo;
3206
+ /**
3207
+ * Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
3208
+ * @example
3209
+ * '@' $mol_mem_key
3210
+ * name(id: number, next?: string) {
3211
+ * return next ?? 'default'
3212
+ * }
3213
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
3214
+ */
2984
3215
  $.$mol_mem_key = $mol_wire_plex;
2985
3216
  })($ || ($ = {}));
2986
3217
 
@@ -3104,6 +3335,7 @@ var $;
3104
3335
  "use strict";
3105
3336
  var $;
3106
3337
  (function ($) {
3338
+ /** Run code without state changes */
3107
3339
  function $mol_wire_probe(task, def) {
3108
3340
  const warm = $mol_wire_fiber.warm;
3109
3341
  try {
@@ -3124,6 +3356,10 @@ var $;
3124
3356
  "use strict";
3125
3357
  var $;
3126
3358
  (function ($) {
3359
+ /**
3360
+ * Real-time refresh current atom.
3361
+ * Don't use if possible. May reduce performance.
3362
+ */
3127
3363
  function $mol_wire_watch() {
3128
3364
  const atom = $mol_wire_auto();
3129
3365
  if (atom instanceof $mol_wire_atom) {
@@ -3140,6 +3376,11 @@ var $;
3140
3376
  "use strict";
3141
3377
  var $;
3142
3378
  (function ($) {
3379
+ /**
3380
+ * Returns closure that returns constant value.
3381
+ * @example
3382
+ * const rnd = $mol_const( Math.random() )
3383
+ */
3143
3384
  function $mol_const(value) {
3144
3385
  const getter = (() => value);
3145
3386
  getter['()'] = value;
@@ -3154,6 +3395,9 @@ var $;
3154
3395
  "use strict";
3155
3396
  var $;
3156
3397
  (function ($) {
3398
+ /**
3399
+ * Disable reaping of current subscriber
3400
+ */
3157
3401
  function $mol_wire_solid() {
3158
3402
  let current = $mol_wire_auto();
3159
3403
  if (current.temp)
@@ -3257,6 +3501,7 @@ var $;
3257
3501
  "use strict";
3258
3502
  var $;
3259
3503
  (function ($) {
3504
+ /** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
3260
3505
  function $mol_wire_async(obj) {
3261
3506
  let fiber;
3262
3507
  const temp = $mol_wire_task.getter(obj);
@@ -3298,6 +3543,7 @@ var $;
3298
3543
 
3299
3544
  ;
3300
3545
  "use strict";
3546
+ /** @jsx $mol_jsx */
3301
3547
  var $;
3302
3548
  (function ($) {
3303
3549
  function $mol_view_visible_width() {
@@ -3312,6 +3558,11 @@ var $;
3312
3558
  return suffix;
3313
3559
  }
3314
3560
  $.$mol_view_state_key = $mol_view_state_key;
3561
+ /**
3562
+ * The base class for all visual components. It provides the infrastructure for reactive lazy rendering, handling exceptions.
3563
+ * @see https://mol.hyoo.ru/#!section=docs/=vv2nig_s5zr0f
3564
+ */
3565
+ /// Reactive statefull lazy ViewModel
3315
3566
  class $mol_view extends $mol_object {
3316
3567
  static Root(id) {
3317
3568
  return new this;
@@ -3376,16 +3627,22 @@ var $;
3376
3627
  state_key(suffix = '') {
3377
3628
  return this.$.$mol_view_state_key(suffix);
3378
3629
  }
3630
+ /// Name of element that created when element not found in DOM
3379
3631
  dom_name() {
3380
3632
  return $mol_dom_qname(this.constructor.toString()) || 'div';
3381
3633
  }
3634
+ /// NameSpace of element that created when element not found in DOM
3382
3635
  dom_name_space() { return 'http://www.w3.org/1999/xhtml'; }
3636
+ /// Raw child views
3383
3637
  sub() {
3384
3638
  return [];
3385
3639
  }
3640
+ /// Visible sub views with defined ambient context
3641
+ /// Render all by default
3386
3642
  sub_visible() {
3387
3643
  return this.sub();
3388
3644
  }
3645
+ /// Minimal width that used for lazy rendering
3389
3646
  minimal_width() {
3390
3647
  let min = 0;
3391
3648
  try {
@@ -3407,6 +3664,7 @@ var $;
3407
3664
  maximal_width() {
3408
3665
  return this.minimal_width();
3409
3666
  }
3667
+ /// Minimal height that used for lazy rendering
3410
3668
  minimal_height() {
3411
3669
  let min = 0;
3412
3670
  try {
@@ -3426,11 +3684,11 @@ var $;
3426
3684
  view_rect() {
3427
3685
  if ($mol_wire_probe(() => this.view_rect()) === undefined) {
3428
3686
  $mol_wire_watch();
3429
- return null;
3687
+ return null; // don't touch DOM to prevent instant reflow
3430
3688
  }
3431
3689
  else {
3432
3690
  const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect();
3433
- return { width, height, left, right, top, bottom };
3691
+ return { width, height, left, right, top, bottom }; // pick to optimize compare
3434
3692
  }
3435
3693
  }
3436
3694
  dom_id() {
@@ -3620,6 +3878,7 @@ var $;
3620
3878
  [$mol_dev_format_head]() {
3621
3879
  return $mol_dev_format_span({}, $mol_dev_format_native(this));
3622
3880
  }
3881
+ /** Deep search view by predicate. */
3623
3882
  *view_find(check, path = []) {
3624
3883
  if (path.length === 0 && check(this))
3625
3884
  return yield [this];
@@ -3648,6 +3907,7 @@ var $;
3648
3907
  $mol_fail_log(error);
3649
3908
  }
3650
3909
  }
3910
+ /** Renders path of views to DOM. */
3651
3911
  force_render(path) {
3652
3912
  const kids = this.sub();
3653
3913
  const index = kids.findIndex(item => {
@@ -3662,6 +3922,7 @@ var $;
3662
3922
  kids[index].force_render(path);
3663
3923
  }
3664
3924
  }
3925
+ /** Renders view to DOM and scroll to it. */
3665
3926
  ensure_visible(view, align = "start") {
3666
3927
  const path = this.view_find(v => v === view).next().value;
3667
3928
  this.force_render(new Set(path));
@@ -3676,6 +3937,9 @@ var $;
3676
3937
  const win = this.$.$mol_dom_context;
3677
3938
  if (win.parent !== win.self && !win.document.hasFocus())
3678
3939
  return;
3940
+ // new this.$.$mol_after_frame( ()=> {
3941
+ // this.dom_node().scrollIntoView({ block: 'start', inline: 'nearest' })
3942
+ // } )
3679
3943
  new this.$.$mol_after_timeout(0, () => {
3680
3944
  this.focused(true);
3681
3945
  });
@@ -3756,6 +4020,7 @@ var $;
3756
4020
  "use strict";
3757
4021
  var $;
3758
4022
  (function ($) {
4023
+ /** Plugin is component without its own DOM element, but instead uses the owner DOM element */
3759
4024
  class $mol_plugin extends $mol_view {
3760
4025
  dom_node_external(next) {
3761
4026
  return next ?? $mol_owning_get(this).host.dom_node();
@@ -3772,6 +4037,7 @@ var $;
3772
4037
  var $;
3773
4038
  (function ($) {
3774
4039
  function $mol_view_component(View) {
4040
+ // service worker
3775
4041
  if (typeof HTMLElement !== 'function')
3776
4042
  return;
3777
4043
  class Component extends HTMLElement {
@@ -3783,6 +4049,7 @@ var $;
3783
4049
  if (!this.shadowRoot) {
3784
4050
  this.attachShadow({ mode: 'open' });
3785
4051
  const node = this.view.dom_node();
4052
+ // node.setAttribute( 'mol_view_root', '' )
3786
4053
  for (const style of $mol_dom_context.document.getElementsByTagName('style')) {
3787
4054
  this.shadowRoot.append(style.cloneNode(true));
3788
4055
  }
@@ -3824,6 +4091,7 @@ var $;
3824
4091
  const descr = Reflect.getOwnPropertyDescriptor(proto, field);
3825
4092
  if (typeof descr.value !== 'function')
3826
4093
  continue;
4094
+ // if( descr.value.length === 0 ) continue
3827
4095
  Component.observedAttributes.add(field);
3828
4096
  Component.observedAttributes.add('#' + field);
3829
4097
  }
@@ -3850,6 +4118,7 @@ var $;
3850
4118
  ;
3851
4119
  "use strict";
3852
4120
 
4121
+
3853
4122
  ;
3854
4123
  ($.$mol_paragraph) = class $mol_paragraph extends ($.$mol_view) {
3855
4124
  line_height(){
@@ -3873,6 +4142,7 @@ var $;
3873
4142
  ;
3874
4143
  "use strict";
3875
4144
 
4145
+
3876
4146
  ;
3877
4147
  "use strict";
3878
4148
  var $;
@@ -3977,8 +4247,10 @@ var $;
3977
4247
  var $;
3978
4248
  (function ($) {
3979
4249
  let x = /x/[Symbol.matchAll];
4250
+ /** Type safe reguar expression builder */
3980
4251
  class $mol_regexp extends RegExp {
3981
4252
  groups;
4253
+ /** Prefer to use $mol_regexp.from */
3982
4254
  constructor(source, flags = 'gsu', groups = []) {
3983
4255
  super(source, flags);
3984
4256
  this.groups = groups;
@@ -3998,12 +4270,14 @@ var $;
3998
4270
  this.lastIndex = index;
3999
4271
  }
4000
4272
  }
4273
+ /** Parses input and returns found capture groups or null */
4001
4274
  [Symbol.match](str) {
4002
4275
  const res = [...this[Symbol.matchAll](str)].filter(r => r.groups).map(r => r[0]);
4003
4276
  if (!res.length)
4004
4277
  return null;
4005
4278
  return res;
4006
4279
  }
4280
+ /** Splits string by regexp edges */
4007
4281
  [Symbol.split](str) {
4008
4282
  const res = [];
4009
4283
  let token_last = null;
@@ -4058,12 +4332,14 @@ var $;
4058
4332
  get native() {
4059
4333
  return new RegExp(this.source, this.flags);
4060
4334
  }
4335
+ /** Makes regexp that greedy repeats this pattern with delimiter */
4061
4336
  static separated(chunk, sep) {
4062
4337
  return $mol_regexp.from([
4063
4338
  $mol_regexp.repeat_greedy([[chunk], sep], 0),
4064
4339
  chunk,
4065
4340
  ]);
4066
4341
  }
4342
+ /** Makes regexp that non-greedy repeats this pattern from min to max count */
4067
4343
  static repeat(source, min = 0, max = Number.POSITIVE_INFINITY) {
4068
4344
  const regexp = $mol_regexp.from(source);
4069
4345
  const upper = Number.isFinite(max) ? max : '';
@@ -4079,6 +4355,7 @@ var $;
4079
4355
  };
4080
4356
  return regexp2;
4081
4357
  }
4358
+ /** Makes regexp that greedy repeats this pattern from min to max count */
4082
4359
  static repeat_greedy(source, min = 0, max = Number.POSITIVE_INFINITY) {
4083
4360
  const regexp = $mol_regexp.from(source);
4084
4361
  const upper = Number.isFinite(max) ? max : '';
@@ -4094,6 +4371,7 @@ var $;
4094
4371
  };
4095
4372
  return regexp2;
4096
4373
  }
4374
+ /** Makes regexp that match any of options */
4097
4375
  static vary(sources, flags = 'gsu') {
4098
4376
  const groups = [];
4099
4377
  const chunks = sources.map(source => {
@@ -4103,17 +4381,21 @@ var $;
4103
4381
  });
4104
4382
  return new $mol_regexp(`(?:${chunks.join('|')})`, flags, groups);
4105
4383
  }
4384
+ /** Makes regexp that allow absent of this pattern */
4106
4385
  static optional(source) {
4107
4386
  return $mol_regexp.repeat_greedy(source, 0, 1);
4108
4387
  }
4388
+ /** Makes regexp that look ahead for pattern */
4109
4389
  static force_after(source) {
4110
4390
  const regexp = $mol_regexp.from(source);
4111
4391
  return new $mol_regexp(`(?=${regexp.source})`, regexp.flags, regexp.groups);
4112
4392
  }
4393
+ /** Makes regexp that look ahead for pattern */
4113
4394
  static forbid_after(source) {
4114
4395
  const regexp = $mol_regexp.from(source);
4115
4396
  return new $mol_regexp(`(?!${regexp.source})`, regexp.flags, regexp.groups);
4116
4397
  }
4398
+ /** Converts some js values to regexp */
4117
4399
  static from(source, { ignoreCase, multiline } = {
4118
4400
  ignoreCase: false,
4119
4401
  multiline: false,
@@ -4214,9 +4496,11 @@ var $;
4214
4496
  return regexp;
4215
4497
  }
4216
4498
  }
4499
+ /** Makes regexp which includes only unicode category */
4217
4500
  static unicode_only(...category) {
4218
4501
  return new $mol_regexp(`\\p{${category.join('=')}}`);
4219
4502
  }
4503
+ /** Makes regexp which excludes unicode category */
4220
4504
  static unicode_except(...category) {
4221
4505
  return new $mol_regexp(`\\P{${category.join('=')}}`);
4222
4506
  }
@@ -4260,12 +4544,17 @@ var $;
4260
4544
  ;
4261
4545
  "use strict";
4262
4546
 
4547
+
4263
4548
  ;
4264
4549
  "use strict";
4265
4550
  var $;
4266
4551
  (function ($) {
4267
4552
  var $$;
4268
4553
  (function ($$) {
4554
+ /**
4555
+ * Output text with dimmed mismatched substrings.
4556
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_dimmer_demo
4557
+ */
4269
4558
  class $mol_dimmer extends $.$mol_dimmer {
4270
4559
  parts() {
4271
4560
  const needle = this.needle();
@@ -4460,6 +4749,11 @@ var $;
4460
4749
  "use strict";
4461
4750
  var $;
4462
4751
  (function ($) {
4752
+ /**
4753
+ * CSS in TS.
4754
+ * Statically typed CSS style sheets. Following samples show which CSS code are generated from TS code.
4755
+ * @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
4756
+ */
4463
4757
  function $mol_style_define(Component, config) {
4464
4758
  return $mol_style_attach(Component.name, $mol_style_sheet(Component, config));
4465
4759
  }
@@ -4469,6 +4763,7 @@ var $;
4469
4763
  ;
4470
4764
  "use strict";
4471
4765
 
4766
+
4472
4767
  ;
4473
4768
  "use strict";
4474
4769
  var $;
@@ -4590,6 +4885,7 @@ var $;
4590
4885
  "use strict";
4591
4886
  var $;
4592
4887
  (function ($) {
4888
+ /** Creates lexer by dictionary of lexems. Lexem that started first wins. Then lexem that declared earlier wins. Use regexp capture to take parts of token. */
4593
4889
  class $mol_syntax2 {
4594
4890
  lexems;
4595
4891
  constructor(lexems) {
@@ -4661,6 +4957,8 @@ var $;
4661
4957
  'code': /```(.+?)```|;;(.+?);;|`(.+?)`/,
4662
4958
  'insert': /\+\+(.+?)\+\+/,
4663
4959
  'delete': /~~(.+?)~~|--(.+?)--/,
4960
+ // 'remark' : /(\()(.+?)(\))/ ,
4961
+ // 'quote' : /(")(.+?)(")/ ,
4664
4962
  'embed': /""(?:(.*?)\\)?(.*?)""/,
4665
4963
  'link': /\\\\(?:(.*?)\\)?(.*?)\\\\/,
4666
4964
  'image-link': /!\[([^\[\]]*?)\]\((.*?)\)/,
@@ -4690,6 +4988,7 @@ var $;
4690
4988
  ;
4691
4989
  "use strict";
4692
4990
 
4991
+
4693
4992
  ;
4694
4993
  "use strict";
4695
4994
  var $;
@@ -4706,6 +5005,7 @@ var $;
4706
5005
  tokens(path) {
4707
5006
  const tokens = [];
4708
5007
  const text = (path.length > 0)
5008
+ // @FIXME: this logic compatible only with `string`
4709
5009
  ? this.tokens(path.slice(0, path.length - 1))[path[path.length - 1]].found.slice(1, -1)
4710
5010
  : this.text();
4711
5011
  this.syntax().tokenize(text, (name, found, chunks) => {
@@ -4971,12 +5271,18 @@ var $;
4971
5271
  ;
4972
5272
  "use strict";
4973
5273
 
5274
+
4974
5275
  ;
4975
5276
  "use strict";
4976
5277
  var $;
4977
5278
  (function ($) {
4978
5279
  var $$;
4979
5280
  (function ($$) {
5281
+ /**
5282
+ * The list of rows with lazy/virtual rendering support based on `minimal_height` of rows.
5283
+ * `mol_list` should contain only components that inherits `mol_view`. You should not place raw strings or numbers in list.
5284
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_list_demo
5285
+ */
4980
5286
  class $mol_list extends $.$mol_list {
4981
5287
  sub() {
4982
5288
  const rows = this.rows();
@@ -5018,9 +5324,11 @@ var $;
5018
5324
  const gap_after = $mol_mem_cached(() => this.gap_after()) ?? 0;
5019
5325
  let top = Math.ceil(rect?.top ?? 0) + gap_before;
5020
5326
  let bottom = Math.ceil(rect?.bottom ?? 0) - gap_after;
5327
+ // change nothing when already covers all limits
5021
5328
  if (top <= limit_top && bottom >= limit_bottom) {
5022
5329
  return [min2, max2];
5023
5330
  }
5331
+ // jumps when fully over limits
5024
5332
  if (anchoring && ((bottom < limit_top) || (top > limit_bottom))) {
5025
5333
  min = 0;
5026
5334
  top = Math.ceil(rect?.top ?? 0);
@@ -5037,18 +5345,22 @@ var $;
5037
5345
  }
5038
5346
  let top2 = top;
5039
5347
  let bottom2 = bottom;
5348
+ // force recalc min when overlapse top limit
5040
5349
  if (anchoring && (top < limit_top) && (bottom < limit_bottom) && (max < kids.length)) {
5041
5350
  min2 = max;
5042
5351
  top2 = bottom;
5043
5352
  }
5353
+ // force recalc max when overlapse bottom limit
5044
5354
  if ((bottom > limit_bottom) && (top > limit_top) && (min > 0)) {
5045
5355
  max2 = min;
5046
5356
  bottom2 = top;
5047
5357
  }
5358
+ // extend min to cover top limit
5048
5359
  while (anchoring && ((top2 > limit_top) && (min2 > 0))) {
5049
5360
  --min2;
5050
5361
  top2 -= this.item_height_min(min2);
5051
5362
  }
5363
+ // extend max to cover bottom limit
5052
5364
  while (bottom2 < limit_bottom && max2 < kids.length) {
5053
5365
  bottom2 += this.item_height_min(max2);
5054
5366
  ++max2;
@@ -5171,6 +5483,10 @@ var $;
5171
5483
  "use strict";
5172
5484
  var $;
5173
5485
  (function ($) {
5486
+ /**
5487
+ * Z-index values for layers
5488
+ * https://page.hyoo.ru/#!=xthcpx_wqmiba
5489
+ */
5174
5490
  $.$mol_layer = $mol_style_prop('mol_layer', [
5175
5491
  'hover',
5176
5492
  'focus',
@@ -5197,6 +5513,7 @@ var $;
5197
5513
  ;
5198
5514
  "use strict";
5199
5515
 
5516
+
5200
5517
  ;
5201
5518
  ($.$mol_button) = class $mol_button extends ($.$mol_view) {
5202
5519
  event_activate(next){
@@ -5286,6 +5603,10 @@ var $;
5286
5603
  "use strict";
5287
5604
  var $;
5288
5605
  (function ($) {
5606
+ /**
5607
+ * Key names code for hotkey
5608
+ * @see [mol_hotkey](../../hotkey/hotkey.view.ts)
5609
+ */
5289
5610
  let $mol_keyboard_code;
5290
5611
  (function ($mol_keyboard_code) {
5291
5612
  $mol_keyboard_code[$mol_keyboard_code["backspace"] = 8] = "backspace";
@@ -5394,12 +5715,17 @@ var $;
5394
5715
  ;
5395
5716
  "use strict";
5396
5717
 
5718
+
5397
5719
  ;
5398
5720
  "use strict";
5399
5721
  var $;
5400
5722
  (function ($) {
5401
5723
  var $$;
5402
5724
  (function ($$) {
5725
+ /**
5726
+ * Simple button.
5727
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_button_demo
5728
+ */
5403
5729
  class $mol_button extends $.$mol_button {
5404
5730
  disabled() {
5405
5731
  return !this.enabled();
@@ -5415,6 +5741,7 @@ var $;
5415
5741
  this.status([null]);
5416
5742
  }
5417
5743
  catch (error) {
5744
+ // Calling actions from catch section, if throwing promise breaks idempotency
5418
5745
  Promise.resolve().then(() => this.status([error]));
5419
5746
  $mol_fail_hidden(error);
5420
5747
  }
@@ -5484,6 +5811,7 @@ var $;
5484
5811
  ;
5485
5812
  "use strict";
5486
5813
 
5814
+
5487
5815
  ;
5488
5816
  ($.$mol_button_minor) = class $mol_button_minor extends ($.$mol_button_typed) {};
5489
5817
 
@@ -5498,6 +5826,7 @@ var $;
5498
5826
  ;
5499
5827
  "use strict";
5500
5828
 
5829
+
5501
5830
  ;
5502
5831
  "use strict";
5503
5832
  var $;
@@ -5529,6 +5858,7 @@ var $;
5529
5858
  "use strict";
5530
5859
  var $;
5531
5860
  (function ($) {
5861
+ /** State of time moment */
5532
5862
  class $mol_state_time extends $mol_object {
5533
5863
  static task(precision, reset) {
5534
5864
  if (precision) {
@@ -5555,12 +5885,14 @@ var $;
5555
5885
  ;
5556
5886
  "use strict";
5557
5887
 
5888
+
5558
5889
  ;
5559
5890
  "use strict";
5560
5891
  var $;
5561
5892
  (function ($) {
5562
5893
  var $$;
5563
5894
  (function ($$) {
5895
+ /** Base SVG component to display SVG images or icons. */
5564
5896
  class $mol_svg extends $.$mol_svg {
5565
5897
  computed_style() {
5566
5898
  const win = this.$.$mol_dom_context;
@@ -5620,6 +5952,7 @@ var $;
5620
5952
  ;
5621
5953
  "use strict";
5622
5954
 
5955
+
5623
5956
  ;
5624
5957
  ($.$mol_svg_path) = class $mol_svg_path extends ($.$mol_svg) {
5625
5958
  geometry(){
@@ -5637,6 +5970,7 @@ var $;
5637
5970
  ;
5638
5971
  "use strict";
5639
5972
 
5973
+
5640
5974
  ;
5641
5975
  ($.$mol_icon) = class $mol_icon extends ($.$mol_svg_root) {
5642
5976
  path(){
@@ -5673,6 +6007,7 @@ var $;
5673
6007
  ;
5674
6008
  "use strict";
5675
6009
 
6010
+
5676
6011
  ;
5677
6012
  ($.$mol_icon_clipboard) = class $mol_icon_clipboard extends ($.$mol_icon) {
5678
6013
  path(){
@@ -5684,6 +6019,7 @@ var $;
5684
6019
  ;
5685
6020
  "use strict";
5686
6021
 
6022
+
5687
6023
  ;
5688
6024
  ($.$mol_icon_clipboard_outline) = class $mol_icon_clipboard_outline extends ($.$mol_icon) {
5689
6025
  path(){
@@ -5695,6 +6031,7 @@ var $;
5695
6031
  ;
5696
6032
  "use strict";
5697
6033
 
6034
+
5698
6035
  ;
5699
6036
  ($.$mol_button_copy) = class $mol_button_copy extends ($.$mol_button_minor) {
5700
6037
  text(){
@@ -5754,12 +6091,17 @@ var $;
5754
6091
  ;
5755
6092
  "use strict";
5756
6093
 
6094
+
5757
6095
  ;
5758
6096
  "use strict";
5759
6097
  var $;
5760
6098
  (function ($) {
5761
6099
  var $$;
5762
6100
  (function ($$) {
6101
+ /**
6102
+ * Button copy text() value to clipboard
6103
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_button_demo
6104
+ */
5763
6105
  class $mol_button_copy extends $.$mol_button_copy {
5764
6106
  data() {
5765
6107
  return Object.fromEntries(this.blobs().map(blob => [blob.type, blob]));
@@ -5924,6 +6266,10 @@ var $;
5924
6266
  "use strict";
5925
6267
  var $;
5926
6268
  (function ($) {
6269
+ /**
6270
+ * Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
6271
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
6272
+ */
5927
6273
  $.$mol_action = $mol_wire_method;
5928
6274
  })($ || ($ = {}));
5929
6275
 
@@ -6000,7 +6346,8 @@ var $;
6000
6346
  "use strict";
6001
6347
  var $;
6002
6348
  (function ($) {
6003
- let buf = new Uint8Array(2 ** 12);
6349
+ let buf = new Uint8Array(2 ** 12); // 4KB Mem Page
6350
+ /** Temporary buffer. Recursive usage isn't supported. */
6004
6351
  function $mol_charset_buffer(size) {
6005
6352
  if (buf.byteLength < size)
6006
6353
  buf = new Uint8Array(size);
@@ -6022,19 +6369,19 @@ var $;
6022
6369
  let pos = from;
6023
6370
  for (let i = 0; i < str.length; i++) {
6024
6371
  let code = str.charCodeAt(i);
6025
- if (code < 0x80) {
6372
+ if (code < 0x80) { // ASCII - 1 octet
6026
6373
  buf[pos++] = code;
6027
6374
  }
6028
- else if (code < 0x800) {
6375
+ else if (code < 0x800) { // 2 octet
6029
6376
  buf[pos++] = 0xc0 | (code >> 6);
6030
6377
  buf[pos++] = 0x80 | (code & 0x3f);
6031
6378
  }
6032
- else if (code < 0xd800 || code >= 0xe000) {
6379
+ else if (code < 0xd800 || code >= 0xe000) { // 3 octet
6033
6380
  buf[pos++] = 0xe0 | (code >> 12);
6034
6381
  buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
6035
6382
  buf[pos++] = 0x80 | (code & 0x3f);
6036
6383
  }
6037
- else {
6384
+ else { // surrogate pair
6038
6385
  const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
6039
6386
  buf[pos++] = 0xf0 | (point >> 18);
6040
6387
  buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
@@ -6098,12 +6445,16 @@ var $;
6098
6445
  (function ($) {
6099
6446
  let file_modes;
6100
6447
  (function (file_modes) {
6448
+ /** create if it doesn't already exist */
6101
6449
  file_modes[file_modes["create"] = $node.fs.constants.O_CREAT] = "create";
6450
+ /** truncate to zero size if it already exists */
6102
6451
  file_modes[file_modes["exists_truncate"] = $node.fs.constants.O_TRUNC] = "exists_truncate";
6452
+ /** throw exception if it already exists */
6103
6453
  file_modes[file_modes["exists_fail"] = $node.fs.constants.O_EXCL] = "exists_fail";
6104
6454
  file_modes[file_modes["read_only"] = $node.fs.constants.O_RDONLY] = "read_only";
6105
6455
  file_modes[file_modes["write_only"] = $node.fs.constants.O_WRONLY] = "write_only";
6106
6456
  file_modes[file_modes["read_write"] = $node.fs.constants.O_RDWR] = "read_write";
6457
+ /** data will be appended to the end */
6107
6458
  file_modes[file_modes["append"] = $node.fs.constants.O_APPEND] = "append";
6108
6459
  })(file_modes || (file_modes = {}));
6109
6460
  function mode_mask(modes) {
@@ -6168,12 +6519,24 @@ var $;
6168
6519
  root() {
6169
6520
  const path = this.path();
6170
6521
  const base = this.constructor.base;
6522
+ // Если путь выше или равен base или если parent такойже как и this - считаем это корнем
6171
6523
  return base.startsWith(path) || this == this.parent();
6172
6524
  }
6173
6525
  stat(next, virt) {
6174
6526
  const path = this.path();
6175
6527
  const parent = this.parent();
6528
+ // Отслеживать проверку наличия родительской папки не стоит до корня диска
6529
+ // Лучше ограничить mam-ом
6176
6530
  if (!this.root()) {
6531
+ /*
6532
+ Если parent папка удалилась, надо ресетнуть все объекты в ней на любой глубине.
6533
+ Например, rm -rf с последующим git pull: parent папка может удалиться, потом создасться,
6534
+ а текущая папка успеет только удалиться до момента выполнения stat.
6535
+ Поэтому parent.exists() не запустит перевычисления, нужна именно parent.version()
6536
+
6537
+ Однако, parent.version() меняется не только при удалении, будет ложное срабатывание
6538
+ С этим придется мириться, красивого решения пока нет.
6539
+ */
6177
6540
  parent.version();
6178
6541
  }
6179
6542
  parent.watcher();
@@ -6187,9 +6550,19 @@ var $;
6187
6550
  if (/([\/\\]\.|___$)/.test(path))
6188
6551
  return;
6189
6552
  const file = this.relative(path.at(-1) === '/' ? path.slice(0, -1) : path);
6553
+ // console.log(type, path)
6554
+ // add (change): добавился файл - у parent надо обновить список sub, если он был заюзан
6555
+ // change, unlink (rename): обновился или удалился файл - ресетим
6556
+ // addDir (change), добавилась папка, у parent обновляем список директорий в sub
6557
+ // дочерние ресетим
6558
+ // unlinkDir (rename), удалилась папка, ресетим ее
6559
+ // stat у всех дочерних обновится сам, т.к. связан с parent.version()
6190
6560
  this.changed.add(file);
6191
6561
  if (!this.watching)
6192
6562
  return;
6563
+ // throttle, пока события поступают не сбрасываем.
6564
+ // аналог awaitWriteFinish из chokidar
6565
+ // интервалы между change-сообщениями модифицируемого файла должны быть меньше watch_debounce
6193
6566
  this.frame?.destructor();
6194
6567
  this.frame = new this.$.$mol_after_timeout(this.watch_debounce(), () => {
6195
6568
  if (!this.watching)
@@ -6198,8 +6571,16 @@ var $;
6198
6571
  $mol_wire_async(this).flush();
6199
6572
  });
6200
6573
  }
6574
+ /**
6575
+ * Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
6576
+ * Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
6577
+ */
6201
6578
  static watch_debounce() { return 500; }
6202
6579
  static flush() {
6580
+ // Пока flush работает, вотчер сюда не заходит, но может добавлять новые изменения
6581
+ // на каждом перезапуске они применятся
6582
+ // Пока run выполняется, изменения накапливаются, в конце run вызывается flush
6583
+ // Пока применяются изменения, run должен ожидать конца flush
6203
6584
  for (const file of this.changed) {
6204
6585
  const parent = file.parent();
6205
6586
  try {
@@ -6214,16 +6595,32 @@ var $;
6214
6595
  }
6215
6596
  this.changed.clear();
6216
6597
  this.watching = true;
6598
+ // this.watch_wd?.destructor()
6599
+ // this.watch_wd = null
6217
6600
  }
6218
6601
  static watching = true;
6219
6602
  static lock = new $mol_lock;
6220
6603
  static watch_off(path) {
6221
6604
  this.watching = false;
6605
+ // run должен ожидать конца flush
6222
6606
  this.flush();
6223
6607
  this.watching = false;
6608
+ /*
6609
+ watch запаздывает и событие может прилететь через 3 сек после окончания сайд эффекта
6610
+ поэтому добавляем папку, которую меняет side_effect
6611
+ Когда дойдет до выполнения flush, он ресетнет ее
6612
+
6613
+ Иначе будут лишние срабатывания
6614
+ Например, удалили hyoo/board, watch ресетит и exists начинает отдавать false, срабатывает git clone
6615
+ Сразу после него событие addDir еще не успело прийти,
6616
+ на следующем перезапуске вызывается git pull, т.к.
6617
+ с точки зрения реактивной системы hyoo/board еще не существует.
6618
+ */
6224
6619
  this.changed.add(this.absolute(path));
6225
6620
  }
6621
+ // protected static watch_wd = null as null | $mol_after_timeout
6226
6622
  static unwatched(side_effect, affected_dir) {
6623
+ // ждем, пока выполнится предыдущий unwatched
6227
6624
  const unlock = this.lock.grab();
6228
6625
  this.watch_off(affected_dir);
6229
6626
  try {
@@ -6246,6 +6643,7 @@ var $;
6246
6643
  modified() { return this.stat()?.mtime ?? null; }
6247
6644
  version() {
6248
6645
  const next = this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? '';
6646
+ // console.log('version', next, this.path())
6249
6647
  return next;
6250
6648
  }
6251
6649
  info(path) { return null; }
@@ -6263,15 +6661,19 @@ var $;
6263
6661
  writable(opts) {
6264
6662
  return new WritableStream;
6265
6663
  }
6664
+ // open( ... modes: readonly $mol_file_mode[] ) { return 0 }
6266
6665
  buffer(next) {
6666
+ // Если версия пустая - возвращаем пустой буфер
6267
6667
  let readed = new Uint8Array();
6268
6668
  if (next === undefined) {
6669
+ // Если меняется версия файла, буфер надо перечитать
6269
6670
  if (this.version())
6270
6671
  readed = this.read();
6271
6672
  }
6272
6673
  const prev = $mol_mem_cached(() => this.buffer());
6273
6674
  const changed = prev === undefined || !$mol_compare_array(prev, next ?? readed);
6274
6675
  if (prev !== undefined && changed) {
6676
+ // Логируем, если повторно читаем/пишем и буфер поменялся
6275
6677
  this.$.$mol_log3_rise({
6276
6678
  place: `$mol_file_node.buffer()`,
6277
6679
  message: 'Changed',
@@ -6280,6 +6682,11 @@ var $;
6280
6682
  }
6281
6683
  if (next === undefined)
6282
6684
  return changed ? readed : prev;
6685
+ // Если буфер при записи не поменялся и файл не удаляли перед этим - не записываем новую версию.
6686
+ // Если записывать, это приведет к смене mtime и вотчер снова триггернется, даже если содержимое файла не поменялось.
6687
+ // В этом алгоритме есть изъян.
6688
+ // Если файл записали, потом отключили вотчер, кто-то из вне его поменял, потом включили вотчер, снова записали тот же буфер,
6689
+ // то буфер не запишется на диск, т.к. кэш не консистентен с диском.
6283
6690
  if (!changed && this.exists())
6284
6691
  return prev;
6285
6692
  this.parent().exists(true);
@@ -6315,13 +6722,21 @@ var $;
6315
6722
  }
6316
6723
  return null;
6317
6724
  }
6725
+ // static watch_root = ''
6726
+ // static watcher_warned = false
6318
6727
  watcher() {
6728
+ // const constructor = this.constructor as typeof $mol_file_base
6729
+ // if (! constructor.watcher_warned) {
6730
+ // console.warn(`${constructor}.watcher() not implemented`)
6731
+ // constructor.watcher_warned = true
6732
+ // }
6319
6733
  return {
6320
6734
  destructor() { }
6321
6735
  };
6322
6736
  }
6323
6737
  exists(next) {
6324
6738
  const exists = Boolean(this.stat());
6739
+ // console.log('exists current', exists, 'next', next, this.path())
6325
6740
  if (next === undefined)
6326
6741
  return exists;
6327
6742
  if (next === exists)
@@ -6347,6 +6762,10 @@ var $;
6347
6762
  return match ? match[1].substring(1) : '';
6348
6763
  }
6349
6764
  text(next, virt) {
6765
+ // Если записываем text, и вотчер ресетнул записанный файл,
6766
+ // то надо снова его обновить, вызвать логику, которая делала пуш в text.
6767
+ // Например файл удалили, потом снова создали, версия поменялась - перезаписываем
6768
+ // Если использовать version, то вновь созданный файл, через вотчер запустит свое пересоздание
6350
6769
  if (next !== undefined)
6351
6770
  this.exists();
6352
6771
  return this.text_int(next, virt);
@@ -6371,6 +6790,7 @@ var $;
6371
6790
  if (this.type() !== 'dir')
6372
6791
  return [];
6373
6792
  this.version();
6793
+ // Если дочерний file удалился, список надо обновить
6374
6794
  return this.kids().filter(file => file.exists());
6375
6795
  }
6376
6796
  resolve(path) {
@@ -6515,10 +6935,15 @@ var $;
6515
6935
  watcher(reset) {
6516
6936
  const path = this.path();
6517
6937
  const root = this.root();
6938
+ // Если папки/файла нет, watch упадет с ошибкой
6939
+ // exists обратится к parent.version и parent.watcher
6940
+ // Поэтому у root-папки и выше не надо вызывать exists, иначе поднимется выше base до корня диска
6941
+ // exists вызывать надо, что б пересоздавать вотчер при появлении папки или файла
6518
6942
  if (!root && !this.exists())
6519
6943
  return super.watcher();
6520
6944
  let watcher;
6521
6945
  try {
6946
+ // Между exists и watch файл может удалиться, в любом случае надо обрабатывать ENOENT
6522
6947
  watcher = $node.fs.watch(path);
6523
6948
  }
6524
6949
  catch (error) {
@@ -6528,6 +6953,8 @@ var $;
6528
6953
  if (root || error.code !== 'ENOENT') {
6529
6954
  this.$.$mol_fail_log(error);
6530
6955
  }
6956
+ // Если файла нет - вотчер не создается, создастся потом, когда exists поменяется на true.
6957
+ // Если создание упало с другой ошибкой - не ломаем работу mol_file, деградируем до не реактивной fs.
6531
6958
  return super.watcher();
6532
6959
  }
6533
6960
  watcher.on('change', (type, name) => {
@@ -6539,6 +6966,7 @@ var $;
6539
6966
  watcher.on('error', e => this.$.$mol_fail_log(e));
6540
6967
  let destructed = false;
6541
6968
  watcher.on('close', () => {
6969
+ // Если в процессе работы вотчер сам закрылся, надо его переоткрыть
6542
6970
  if (!destructed)
6543
6971
  setTimeout(() => $mol_wire_async(this).watcher(null), 500);
6544
6972
  });
@@ -6720,6 +7148,10 @@ var $;
6720
7148
  "use strict";
6721
7149
  var $;
6722
7150
  (function ($) {
7151
+ /**
7152
+ * Localisation in $mol framework
7153
+ * @see https://mol.hyoo.ru/#!section=docs/=s5aqnb_odub8l
7154
+ */
6723
7155
  class $mol_locale extends $mol_object {
6724
7156
  static lang_default() {
6725
7157
  return 'en';
@@ -6867,12 +7299,17 @@ var $;
6867
7299
  ;
6868
7300
  "use strict";
6869
7301
 
7302
+
6870
7303
  ;
6871
7304
  "use strict";
6872
7305
  var $;
6873
7306
  (function ($) {
6874
7307
  var $$;
6875
7308
  (function ($$) {
7309
+ /**
7310
+ * Code visualizer.
7311
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_text_code_demo
7312
+ */
6876
7313
  class $mol_text_code extends $.$mol_text_code {
6877
7314
  render_visible_only() {
6878
7315
  return this.$.$mol_support_css_overflow_anchor();
@@ -7073,12 +7510,17 @@ var $;
7073
7510
  ;
7074
7511
  "use strict";
7075
7512
 
7513
+
7076
7514
  ;
7077
7515
  "use strict";
7078
7516
  var $;
7079
7517
  (function ($) {
7080
7518
  var $$;
7081
7519
  (function ($$) {
7520
+ /**
7521
+ * Checkbox UI component. See Variants for more concrete implementations.
7522
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_check_box_demo
7523
+ */
7082
7524
  class $mol_check extends $.$mol_check {
7083
7525
  click(next) {
7084
7526
  const event = next ? $mol_dom_event.wrap(next) : null;
@@ -7115,6 +7557,7 @@ var $;
7115
7557
  ;
7116
7558
  "use strict";
7117
7559
 
7560
+
7118
7561
  ;
7119
7562
  ($.$mol_check_expand) = class $mol_check_expand extends ($.$mol_check) {
7120
7563
  level_style(){
@@ -7151,12 +7594,17 @@ var $;
7151
7594
  ;
7152
7595
  "use strict";
7153
7596
 
7597
+
7154
7598
  ;
7155
7599
  "use strict";
7156
7600
  var $;
7157
7601
  (function ($) {
7158
7602
  var $$;
7159
7603
  (function ($$) {
7604
+ /**
7605
+ * Expander for trees, lists, etc
7606
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_check_expand_demo
7607
+ */
7160
7608
  class $mol_check_expand extends $.$mol_check_expand {
7161
7609
  level_style() {
7162
7610
  return `${this.level() * 1 - 1}rem`;
@@ -7213,12 +7661,17 @@ var $;
7213
7661
  ;
7214
7662
  "use strict";
7215
7663
 
7664
+
7216
7665
  ;
7217
7666
  "use strict";
7218
7667
  var $;
7219
7668
  (function ($) {
7220
7669
  var $$;
7221
7670
  (function ($$) {
7671
+ /**
7672
+ * Dumps any JS values.
7673
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_dump_demo
7674
+ */
7222
7675
  class $mol_dump_list extends $.$mol_dump_list {
7223
7676
  sub() {
7224
7677
  return this.values().map((_, index) => this.Dump(index));
@@ -7292,12 +7745,17 @@ var $;
7292
7745
  ;
7293
7746
  "use strict";
7294
7747
 
7748
+
7295
7749
  ;
7296
7750
  "use strict";
7297
7751
  var $;
7298
7752
  (function ($) {
7299
7753
  var $$;
7300
7754
  (function ($$) {
7755
+ /**
7756
+ * Component which expands any content on title click.
7757
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_expander_demo
7758
+ */
7301
7759
  class $mol_expander extends $.$mol_expander {
7302
7760
  rows() {
7303
7761
  return [
@@ -7430,12 +7888,17 @@ var $;
7430
7888
  ;
7431
7889
  "use strict";
7432
7890
 
7891
+
7433
7892
  ;
7434
7893
  "use strict";
7435
7894
  var $;
7436
7895
  (function ($) {
7437
7896
  var $$;
7438
7897
  (function ($$) {
7898
+ /**
7899
+ * Dumps any JS values.
7900
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_dump_demo
7901
+ */
7439
7902
  class $mol_dump_value extends $.$mol_dump_value {
7440
7903
  sub() {
7441
7904
  const value = this.value();
@@ -7524,6 +7987,11 @@ var $;
7524
7987
  const descr = Reflect.getOwnPropertyDescriptor(value, key);
7525
7988
  if ('value' in descr) {
7526
7989
  const line = [prefix, descr.value];
7990
+ // let proto = descr.value
7991
+ // while( proto && typeof proto === 'object' ) {
7992
+ // proto = Reflect.getPrototypeOf( proto )
7993
+ // if( proto ) line.push( ' - ', proto )
7994
+ // }
7527
7995
  res.push(line);
7528
7996
  }
7529
7997
  else {
@@ -7700,18 +8168,34 @@ var $;
7700
8168
  "use strict";
7701
8169
  var $;
7702
8170
  (function ($) {
8171
+ /**
8172
+ * Argument must be Truthy
8173
+ * @deprecated use $mol_assert_equal instead
8174
+ */
7703
8175
  function $mol_assert_ok(value) {
7704
8176
  if (value)
7705
8177
  return;
7706
8178
  $mol_fail(new Error(`${value} ≠ true`));
7707
8179
  }
7708
8180
  $.$mol_assert_ok = $mol_assert_ok;
8181
+ /**
8182
+ * Argument must be Falsy
8183
+ * @deprecated use $mol_assert_equal instead
8184
+ */
7709
8185
  function $mol_assert_not(value) {
7710
8186
  if (!value)
7711
8187
  return;
7712
8188
  $mol_fail(new Error(`${value} ≠ false`));
7713
8189
  }
7714
8190
  $.$mol_assert_not = $mol_assert_not;
8191
+ /**
8192
+ * Handler must throw an error.
8193
+ * @example
8194
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
8195
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
8196
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
8197
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
8198
+ */
7715
8199
  function $mol_assert_fail(handler, ErrorRight) {
7716
8200
  const fail = $.$mol_fail;
7717
8201
  try {
@@ -7734,10 +8218,18 @@ var $;
7734
8218
  $mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
7735
8219
  }
7736
8220
  $.$mol_assert_fail = $mol_assert_fail;
8221
+ /** @deprecated Use $mol_assert_equal */
7737
8222
  function $mol_assert_like(...args) {
7738
8223
  $mol_assert_equal(...args);
7739
8224
  }
7740
8225
  $.$mol_assert_like = $mol_assert_like;
8226
+ /**
8227
+ * All arguments must not be structural equal to each other.
8228
+ * @example
8229
+ * $mol_assert_unique( 1 , 2 , 3 ) // Passes
8230
+ * $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
8231
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
8232
+ */
7741
8233
  function $mol_assert_unique(...args) {
7742
8234
  for (let i = 0; i < args.length; ++i) {
7743
8235
  for (let j = 0; j < args.length; ++j) {
@@ -7750,6 +8242,13 @@ var $;
7750
8242
  }
7751
8243
  }
7752
8244
  $.$mol_assert_unique = $mol_assert_unique;
8245
+ /**
8246
+ * All arguments must be structural equal each other.
8247
+ * @example
8248
+ * $mol_assert_like( [1] , [1] , [1] ) // Passes
8249
+ * $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
8250
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
8251
+ */
7753
8252
  function $mol_assert_equal(...args) {
7754
8253
  for (let i = 1; i < args.length; ++i) {
7755
8254
  if ($mol_compare_deep(args[0], args[i]))
@@ -7806,6 +8305,12 @@ var $;
7806
8305
  'return result without errors'() {
7807
8306
  $mol_assert_equal($mol_try(() => false), false);
7808
8307
  },
8308
+ //'return error if thrown'() {
8309
+ //
8310
+ // const error = new Error( '$mol_try test error' )
8311
+ // $mol_assert_equal( $mol_try( ()=> { throw error } ) , error )
8312
+ //
8313
+ //} ,
7809
8314
  });
7810
8315
  })($ || ($ = {}));
7811
8316
 
@@ -8308,6 +8813,7 @@ var $;
8308
8813
  "use strict";
8309
8814
  var $;
8310
8815
  (function ($) {
8816
+ /// @todo right orderinng
8311
8817
  $.$mol_after_mock_queue = [];
8312
8818
  function $mol_after_mock_warp() {
8313
8819
  const queue = $.$mol_after_mock_queue.splice(0);
@@ -8711,6 +9217,8 @@ var $;
8711
9217
 
8712
9218
  ;
8713
9219
  "use strict";
9220
+ /** @jsx $mol_jsx */
9221
+ /** @jsxFrag $mol_jsx_frag */
8714
9222
  var $;
8715
9223
  (function ($) {
8716
9224
  $mol_test({
@@ -8816,6 +9324,7 @@ var $;
8816
9324
  "use strict";
8817
9325
  var $;
8818
9326
  (function ($) {
9327
+ /** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
8819
9328
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
8820
9329
  const source = typeof item === 'function' ? new $mol_range2_array() : item;
8821
9330
  if (typeof item !== 'function') {
@@ -8864,6 +9373,7 @@ var $;
8864
9373
  }
8865
9374
  $.$mol_range2 = $mol_range2;
8866
9375
  class $mol_range2_array extends Array {
9376
+ // Lazy
8867
9377
  concat(...tail) {
8868
9378
  if (tail.length === 0)
8869
9379
  return this;
@@ -8875,6 +9385,7 @@ var $;
8875
9385
  }
8876
9386
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
8877
9387
  }
9388
+ // Lazy
8878
9389
  filter(check, context) {
8879
9390
  const filtered = [];
8880
9391
  let cursor = -1;
@@ -8887,13 +9398,16 @@ var $;
8887
9398
  return filtered[index];
8888
9399
  }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
8889
9400
  }
9401
+ // Diligent
8890
9402
  forEach(proceed, context) {
8891
9403
  for (let [key, value] of this.entries())
8892
9404
  proceed.call(context, value, key, this);
8893
9405
  }
9406
+ // Lazy
8894
9407
  map(proceed, context) {
8895
9408
  return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
8896
9409
  }
9410
+ // Diligent
8897
9411
  reduce(merge, result) {
8898
9412
  let index = 0;
8899
9413
  if (arguments.length === 1) {
@@ -8904,12 +9418,15 @@ var $;
8904
9418
  }
8905
9419
  return result;
8906
9420
  }
9421
+ // Lazy
8907
9422
  toReversed() {
8908
9423
  return $mol_range2(index => this[this.length - 1 - index], () => this.length);
8909
9424
  }
9425
+ // Lazy
8910
9426
  slice(from = 0, to = this.length) {
8911
9427
  return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
8912
9428
  }
9429
+ // Lazy
8913
9430
  some(check, context) {
8914
9431
  for (let index = 0; index < this.length; ++index) {
8915
9432
  if (check.call(context, this[index], index, this))
@@ -9102,6 +9619,7 @@ var $;
9102
9619
 
9103
9620
  ;
9104
9621
  "use strict";
9622
+ /** @jsx $mol_jsx */
9105
9623
  var $;
9106
9624
  (function ($) {
9107
9625
  $mol_test({
@@ -9163,6 +9681,7 @@ var $;
9163
9681
  const obj3_copy = { test: 3, obj2: obj2_copy };
9164
9682
  obj1.obj3 = obj3;
9165
9683
  obj1_copy.obj3 = obj3_copy;
9684
+ // warmup cache
9166
9685
  $mol_assert_not($mol_compare_deep(obj1, {}));
9167
9686
  $mol_assert_not($mol_compare_deep(obj2, {}));
9168
9687
  $mol_assert_not($mol_compare_deep(obj3, {}));
@@ -9231,11 +9750,15 @@ var $;
9231
9750
  ;
9232
9751
  "use strict";
9233
9752
 
9753
+ ;
9754
+ "use strict";
9755
+
9234
9756
  ;
9235
9757
  "use strict";
9236
9758
  var $;
9237
9759
  (function ($_1) {
9238
9760
  $mol_test({
9761
+ // https://github.com/nin-jin/slides/tree/master/reactivity#component-states
9239
9762
  'Cached channel'($) {
9240
9763
  class App extends $mol_object2 {
9241
9764
  static $ = $;
@@ -9293,6 +9816,7 @@ var $;
9293
9816
  $mol_assert_equal(App.value(5), 21);
9294
9817
  $mol_assert_equal(App.value(), 21);
9295
9818
  },
9819
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-consistency
9296
9820
  'Auto recalculation of cached values'($) {
9297
9821
  class App extends $mol_object2 {
9298
9822
  static $ = $;
@@ -9320,6 +9844,7 @@ var $;
9320
9844
  App.xxx(5);
9321
9845
  $mol_assert_equal(App.zzz(), 7);
9322
9846
  },
9847
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-reasonability
9323
9848
  'Skip recalculation when actually no dependency changes'($) {
9324
9849
  const log = [];
9325
9850
  class App extends $mol_object2 {
@@ -9353,6 +9878,7 @@ var $;
9353
9878
  App.zzz();
9354
9879
  $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
9355
9880
  },
9881
+ // https://github.com/nin-jin/slides/tree/master/reactivity#flow-auto
9356
9882
  'Flow: Auto'($) {
9357
9883
  class App extends $mol_object2 {
9358
9884
  static get $() { return $; }
@@ -9390,6 +9916,7 @@ var $;
9390
9916
  $mol_assert_equal(App.result(), 23);
9391
9917
  $mol_assert_equal(App.counter, 4);
9392
9918
  },
9919
+ // https://github.com/nin-jin/slides/tree/master/reactivity#dupes-equality
9393
9920
  'Dupes: Equality'($) {
9394
9921
  let counter = 0;
9395
9922
  class App extends $mol_object2 {
@@ -9413,6 +9940,7 @@ var $;
9413
9940
  App.foo({ numbs: [2] });
9414
9941
  $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
9415
9942
  },
9943
+ // https://github.com/nin-jin/slides/tree/master/reactivity#cycle-fail
9416
9944
  'Cycle: Fail'($) {
9417
9945
  class App extends $mol_object2 {
9418
9946
  static $ = $;
@@ -9437,6 +9965,29 @@ var $;
9437
9965
  ], App, "test", null);
9438
9966
  App.test();
9439
9967
  },
9968
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
9969
+ // 'Update deps on push'( $ ) {
9970
+ // class App extends $mol_object2 {
9971
+ // static $ = $
9972
+ // @ $mol_wire_solo
9973
+ // static left( next = false ) {
9974
+ // return next
9975
+ // }
9976
+ // @ $mol_wire_solo
9977
+ // static right( next = false ) {
9978
+ // return next
9979
+ // }
9980
+ // @ $mol_wire_solo
9981
+ // static res( next?: boolean ) {
9982
+ // return this.left( next ) && this.right()
9983
+ // }
9984
+ // }
9985
+ // $mol_assert_equal( App.res(), false )
9986
+ // $mol_assert_equal( App.res( true ), false )
9987
+ // $mol_assert_equal( App.right( true ), true )
9988
+ // $mol_assert_equal( App.res(), true )
9989
+ // } ,
9990
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
9440
9991
  'Different order of pull and push'($) {
9441
9992
  class App extends $mol_object2 {
9442
9993
  static $ = $;
@@ -9448,7 +9999,7 @@ var $;
9448
9999
  }
9449
10000
  static slow(next) {
9450
10001
  if (next !== undefined)
9451
- this.slow();
10002
+ this.slow(); // enforce pull before push
9452
10003
  return this.store(next);
9453
10004
  }
9454
10005
  }
@@ -9467,6 +10018,7 @@ var $;
9467
10018
  App.store(777);
9468
10019
  $mol_assert_equal(App.fast(), App.slow(), 777);
9469
10020
  },
10021
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
9470
10022
  'Actions inside invariant'($) {
9471
10023
  class App extends $mol_object2 {
9472
10024
  static $ = $;
@@ -9506,6 +10058,7 @@ var $;
9506
10058
  static toggle() {
9507
10059
  const prev = this.checked();
9508
10060
  $mol_assert_unique(this.checked(!prev), prev);
10061
+ // $mol_assert_equal( this.checked() , prev )
9509
10062
  }
9510
10063
  static res() {
9511
10064
  return this.checked();
@@ -9530,6 +10083,39 @@ var $;
9530
10083
  ], App, "test", null);
9531
10084
  await $mol_wire_async(App).test();
9532
10085
  },
10086
+ // // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
10087
+ // 'Stable order of multiple root'( $ ) {
10088
+ // class App extends $mol_object2 {
10089
+ // static $ = $
10090
+ // static counter = 0
10091
+ // @ $mol_wire_solo
10092
+ // static left_trigger( next = 0 ) {
10093
+ // return next
10094
+ // }
10095
+ // @ $mol_wire_solo
10096
+ // static left_root() {
10097
+ // this.left_trigger()
10098
+ // return ++ this.counter
10099
+ // }
10100
+ // @ $mol_wire_solo
10101
+ // static right_trigger( next = 0 ) {
10102
+ // return next
10103
+ // }
10104
+ // @ $mol_wire_solo
10105
+ // static right_root() {
10106
+ // this.right_trigger()
10107
+ // return ++ this.counter
10108
+ // }
10109
+ // }
10110
+ // $mol_assert_equal( App.left_root(), 1 )
10111
+ // $mol_assert_equal( App.right_root(), 2 )
10112
+ // App.right_trigger( 1 )
10113
+ // App.left_trigger( 1 )
10114
+ // $mol_wire_fiber.sync()
10115
+ // $mol_assert_equal( App.right_root(), 4 )
10116
+ // $mol_assert_equal( App.left_root(), 3 )
10117
+ // } ,
10118
+ // https://github.com/nin-jin/slides/tree/master/reactivity#error-store
9533
10119
  'Restore after error'($) {
9534
10120
  class App extends $mol_object2 {
9535
10121
  static get $() { return $; }
@@ -9627,6 +10213,7 @@ var $;
9627
10213
  App.showing(true);
9628
10214
  $mol_assert_unique(App.render(), details);
9629
10215
  },
10216
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
9630
10217
  async 'Hold pubs while wait async task'($) {
9631
10218
  class App extends $mol_object2 {
9632
10219
  static $ = $;
@@ -9985,6 +10572,7 @@ var $;
9985
10572
 
9986
10573
  ;
9987
10574
  "use strict";
10575
+ /** @jsx $mol_jsx */
9988
10576
  var $;
9989
10577
  (function ($) {
9990
10578
  $mol_test({
@@ -10066,6 +10654,7 @@ var $;
10066
10654
  "use strict";
10067
10655
  var $;
10068
10656
  (function ($) {
10657
+ /** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */
10069
10658
  class $mol_wire_log extends $mol_object2 {
10070
10659
  static watch(task) {
10071
10660
  return task;
@@ -10151,6 +10740,9 @@ var $;
10151
10740
  ;
10152
10741
  "use strict";
10153
10742
 
10743
+ ;
10744
+ "use strict";
10745
+
10154
10746
  ;
10155
10747
  "use strict";
10156
10748
  var $;