mol_db 0.0.1730 → 0.0.1732

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.js CHANGED
@@ -41,7 +41,7 @@ var $;
41
41
  "use strict";
42
42
  var $;
43
43
  (function ($) {
44
- const mod = require('module');
44
+ const mod = require /****/('module');
45
45
  const internals = mod.builtinModules;
46
46
  function $node_internal_check(name) {
47
47
  if (name.startsWith('node:'))
@@ -81,7 +81,7 @@ var $;
81
81
  var $;
82
82
  (function ($) {
83
83
  function $mol_fail_hidden(error) {
84
- throw error;
84
+ throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
85
85
  }
86
86
  $.$mol_fail_hidden = $mol_fail_hidden;
87
87
  })($ || ($ = {}));
@@ -139,8 +139,8 @@ var $;
139
139
  "use strict";
140
140
  var $;
141
141
  (function ($) {
142
- const path = require('path');
143
- const mod = require('module');
142
+ const path = require /****/('path');
143
+ const mod = require /****/('module');
144
144
  const localRequire = mod.createRequire(path.join(process.cwd(), 'package.json'));
145
145
  function $node_autoinstall(name) {
146
146
  try {
@@ -247,6 +247,7 @@ var $;
247
247
  ])
248
248
  ].map(frame_normalize).join('\n')
249
249
  });
250
+ // в nodejs, что б не дублировалось cause в консоли
250
251
  Object.defineProperty(this, 'cause', {
251
252
  get: () => cause
252
253
  });
@@ -280,6 +281,11 @@ var $;
280
281
  var $;
281
282
  (function ($) {
282
283
  const instances = new WeakSet();
284
+ /**
285
+ * Proxy that delegates all to lazy returned target.
286
+ *
287
+ * $mol_delegate( Array.prototype , ()=> fetch_array() )
288
+ */
283
289
  function $mol_delegate(proto, target) {
284
290
  const proxy = new Proxy(proto, {
285
291
  get: (_, field) => {
@@ -423,6 +429,9 @@ var $;
423
429
  [Symbol.dispose]() {
424
430
  this.destructor();
425
431
  }
432
+ //[ Symbol.toPrimitive ]( hint: string ) {
433
+ // return hint === 'number' ? this.valueOf() : this.toString()
434
+ //}
426
435
  toString() {
427
436
  return this[Symbol.toStringTag] || this.constructor.name + '<>';
428
437
  }
@@ -473,6 +482,7 @@ var $;
473
482
  "use strict";
474
483
  var $;
475
484
  (function ($) {
485
+ /** Generates unique identifier. */
476
486
  function $mol_guid(length = 8, exists = () => false) {
477
487
  for (;;) {
478
488
  let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
@@ -488,11 +498,16 @@ var $;
488
498
  "use strict";
489
499
  var $;
490
500
  (function ($) {
501
+ /** Special status statuses. */
491
502
  let $mol_wire_cursor;
492
503
  (function ($mol_wire_cursor) {
504
+ /** Update required. */
493
505
  $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
506
+ /** Some of (transitive) pub update required. */
494
507
  $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
508
+ /** Actual state but may be dropped. */
495
509
  $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
510
+ /** State will never be changed. */
496
511
  $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
497
512
  })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
498
513
  })($ || ($ = {}));
@@ -501,6 +516,9 @@ var $;
501
516
  "use strict";
502
517
  var $;
503
518
  (function ($) {
519
+ /**
520
+ * Collects subscribers in compact array. 28B
521
+ */
504
522
  class $mol_wire_pub extends Object {
505
523
  constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
506
524
  super();
@@ -508,10 +526,17 @@ var $;
508
526
  }
509
527
  [Symbol.toStringTag];
510
528
  data = [];
529
+ // Derived objects should be Arrays.
511
530
  static get [Symbol.species]() {
512
531
  return Array;
513
532
  }
514
- sub_from = 0;
533
+ /**
534
+ * Index of first subscriber.
535
+ */
536
+ sub_from = 0; // 4B
537
+ /**
538
+ * All current subscribers.
539
+ */
515
540
  get sub_list() {
516
541
  const res = [];
517
542
  for (let i = this.sub_from; i < this.data.length; i += 2) {
@@ -519,14 +544,23 @@ var $;
519
544
  }
520
545
  return res;
521
546
  }
547
+ /**
548
+ * Has any subscribers or not.
549
+ */
522
550
  get sub_empty() {
523
551
  return this.sub_from === this.data.length;
524
552
  }
553
+ /**
554
+ * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
555
+ */
525
556
  sub_on(sub, pub_pos) {
526
557
  const pos = this.data.length;
527
558
  this.data.push(sub, pub_pos);
528
559
  return pos;
529
560
  }
561
+ /**
562
+ * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
563
+ */
530
564
  sub_off(sub_pos) {
531
565
  if (!(sub_pos < this.data.length)) {
532
566
  $mol_fail(new Error(`Wrong pos ${sub_pos}`));
@@ -539,21 +573,39 @@ var $;
539
573
  if (end === this.sub_from)
540
574
  this.reap();
541
575
  }
576
+ /**
577
+ * Called when last sub was unsubscribed.
578
+ **/
542
579
  reap() { }
580
+ /**
581
+ * Autowire this publisher with current subscriber.
582
+ **/
543
583
  promote() {
544
584
  $mol_wire_auto()?.track_next(this);
545
585
  }
586
+ /**
587
+ * Enforce actualization. Should not throw errors.
588
+ */
546
589
  fresh() { }
590
+ /**
591
+ * Allow to put data to caches in the subtree.
592
+ */
547
593
  complete() { }
548
594
  get incompleted() {
549
595
  return false;
550
596
  }
597
+ /**
598
+ * Notify subscribers about self changes.
599
+ */
551
600
  emit(quant = $mol_wire_cursor.stale) {
552
601
  for (let i = this.sub_from; i < this.data.length; i += 2) {
553
602
  ;
554
603
  this.data[i].absorb(quant, this.data[i + 1]);
555
604
  }
556
605
  }
606
+ /**
607
+ * Moves peer from one position to another. Doesn't clear data at old position!
608
+ */
557
609
  peer_move(from_pos, to_pos) {
558
610
  const peer = this.data[from_pos];
559
611
  const self_pos = this.data[from_pos + 1];
@@ -561,6 +613,9 @@ var $;
561
613
  this.data[to_pos + 1] = self_pos;
562
614
  peer.peer_repos(self_pos, to_pos);
563
615
  }
616
+ /**
617
+ * Updates self position in the peer.
618
+ */
564
619
  peer_repos(peer_pos, self_pos) {
565
620
  this.data[peer_pos + 1] = self_pos;
566
621
  }
@@ -576,10 +631,16 @@ var $;
576
631
  var $;
577
632
  (function ($) {
578
633
  $.$mol_wire_auto_sub = null;
634
+ /**
635
+ * When fulfilled, all publishers are promoted to this subscriber on access to its.
636
+ */
579
637
  function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
580
638
  return $.$mol_wire_auto_sub = next;
581
639
  }
582
640
  $.$mol_wire_auto = $mol_wire_auto;
641
+ /**
642
+ * Affection queue. Used to prevent accidental stack overflow on emit.
643
+ */
583
644
  $.$mol_wire_affected = [];
584
645
  })($ || ($ = {}));
585
646
 
@@ -587,6 +648,7 @@ var $;
587
648
  "use strict";
588
649
  var $;
589
650
  (function ($) {
651
+ // https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
590
652
  $['devtoolsFormatters'] ||= [];
591
653
  function $mol_dev_format_register(config) {
592
654
  $['devtoolsFormatters'].push(config);
@@ -638,6 +700,7 @@ var $;
638
700
  return false;
639
701
  if (!val)
640
702
  return false;
703
+ // if( Error.isError( val ) ) true
641
704
  if (val[$.$mol_dev_format_body])
642
705
  return true;
643
706
  return false;
@@ -655,12 +718,16 @@ var $;
655
718
  return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
656
719
  }
657
720
  }
721
+ // if( Error.isError( val ) ) {
722
+ // return $mol_dev_format_native( val )
723
+ // }
658
724
  return null;
659
725
  },
660
726
  });
661
727
  function $mol_dev_format_native(obj) {
662
728
  if (typeof obj === 'undefined')
663
729
  return $.$mol_dev_format_shade('undefined');
730
+ // if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
664
731
  return [
665
732
  'object',
666
733
  {
@@ -718,6 +785,9 @@ var $;
718
785
  'margin-left': '13px'
719
786
  });
720
787
  class Stack extends Array {
788
+ // [ Symbol.toPrimitive ]() {
789
+ // return this.toString()
790
+ // }
721
791
  toString() {
722
792
  return this.join('\n');
723
793
  }
@@ -740,6 +810,7 @@ var $;
740
810
  this.method = call.getMethodName() ?? '';
741
811
  if (this.method === this.function)
742
812
  this.method = '';
813
+ // const func = c.getFunction()
743
814
  this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
744
815
  this.eval = call.getEvalOrigin() ?? '';
745
816
  this.source = call.getScriptNameOrSourceURL() ?? '';
@@ -786,9 +857,16 @@ var $;
786
857
  "use strict";
787
858
  var $;
788
859
  (function ($) {
860
+ /**
861
+ * Publisher that can auto collect other publishers. 32B
862
+ *
863
+ * P1 P2 P3 P4 S1 S2 S3
864
+ * ^ ^
865
+ * pubs_from subs_from
866
+ */
789
867
  class $mol_wire_pub_sub extends $mol_wire_pub {
790
- pub_from = 0;
791
- cursor = $mol_wire_cursor.stale;
868
+ pub_from = 0; // 4B
869
+ cursor = $mol_wire_cursor.stale; // 4B
792
870
  get temp() {
793
871
  return false;
794
872
  }
@@ -906,10 +984,27 @@ var $;
906
984
  return;
907
985
  this.cursor = quant;
908
986
  this.emit($mol_wire_cursor.doubt);
987
+ // if( pos >= 0 && pos < this.sub_from - 2 ) {
988
+ // const pub = this.data[ pos ] as $mol_wire_pub
989
+ // if( pub instanceof $mol_wire_task ) return
990
+ // for(
991
+ // let cursor = this.pub_from;
992
+ // cursor < this.sub_from;
993
+ // cursor += 2
994
+ // ) {
995
+ // const pub = this.data[ cursor ] as $mol_wire_pub
996
+ // if( pub instanceof $mol_wire_task ) {
997
+ // pub.destructor()
998
+ // }
999
+ // }
1000
+ // }
909
1001
  }
910
1002
  [$mol_dev_format_head]() {
911
1003
  return $mol_dev_format_native(this);
912
1004
  }
1005
+ /**
1006
+ * Is subscribed to any publisher or not.
1007
+ */
913
1008
  get pub_empty() {
914
1009
  return this.sub_from === this.pub_from;
915
1010
  }
@@ -950,6 +1045,13 @@ var $;
950
1045
  var $;
951
1046
  (function ($) {
952
1047
  const wrappers = new WeakMap();
1048
+ /**
1049
+ * Suspendable task with support both sync/async api.
1050
+ *
1051
+ * A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
1052
+ * ^ ^ ^
1053
+ * args_from pubs_from subs_from
1054
+ **/
953
1055
  class $mol_wire_fiber extends $mol_wire_pub_sub {
954
1056
  task;
955
1057
  host;
@@ -970,6 +1072,7 @@ var $;
970
1072
  });
971
1073
  }
972
1074
  static sync() {
1075
+ // Sync whole fiber graph
973
1076
  while (this.planning.size) {
974
1077
  for (const fiber of this.planning) {
975
1078
  this.planning.delete(fiber);
@@ -980,6 +1083,7 @@ var $;
980
1083
  fiber.fresh();
981
1084
  }
982
1085
  }
1086
+ // Collect garbage
983
1087
  while (this.reaping.size) {
984
1088
  const fibers = this.reaping;
985
1089
  this.reaping = new Set;
@@ -1131,6 +1235,10 @@ var $;
1131
1235
  this.cursor = $mol_wire_cursor.stale;
1132
1236
  this.fresh();
1133
1237
  }
1238
+ /**
1239
+ * Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
1240
+ * Should be called inside SuspenseAPI consumer (ie fiber).
1241
+ */
1134
1242
  sync() {
1135
1243
  if (!$mol_wire_fiber.warm) {
1136
1244
  return this.result();
@@ -1145,6 +1253,10 @@ var $;
1145
1253
  }
1146
1254
  return this.cache;
1147
1255
  }
1256
+ /**
1257
+ * Asynchronous execution.
1258
+ * It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
1259
+ */
1148
1260
  async async_raw() {
1149
1261
  while (true) {
1150
1262
  this.fresh();
@@ -1157,6 +1269,7 @@ var $;
1157
1269
  if (!$mol_promise_like(this.cache))
1158
1270
  return this.cache;
1159
1271
  if (this.cursor === $mol_wire_cursor.final) {
1272
+ // never ends on destructed fiber
1160
1273
  await new Promise(() => { });
1161
1274
  }
1162
1275
  }
@@ -1204,6 +1317,10 @@ var $;
1204
1317
  var $;
1205
1318
  (function ($) {
1206
1319
  $.$mol_compare_deep_cache = new WeakMap();
1320
+ /**
1321
+ * Deeply compares two values. Returns true if equal.
1322
+ * Define `Symbol.toPrimitive` to customize.
1323
+ */
1207
1324
  function $mol_compare_deep(left, right) {
1208
1325
  if (Object.is(left, right))
1209
1326
  return true;
@@ -1343,6 +1460,7 @@ var $;
1343
1460
  "use strict";
1344
1461
  var $;
1345
1462
  (function ($) {
1463
+ /** Log begin of collapsed group only when some logged inside, returns func to close group */
1346
1464
  function $mol_log3_area_lazy(event) {
1347
1465
  const self = this.$;
1348
1466
  const stack = self.$mol_log3_stack;
@@ -1367,6 +1485,7 @@ var $;
1367
1485
  "use strict";
1368
1486
  var $;
1369
1487
  (function ($) {
1488
+ /** Position in any resource. */
1370
1489
  class $mol_span extends $mol_object2 {
1371
1490
  uri;
1372
1491
  source;
@@ -1382,13 +1501,17 @@ var $;
1382
1501
  this.length = length;
1383
1502
  this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
1384
1503
  }
1504
+ /** Span for begin of unknown resource */
1385
1505
  static unknown = $mol_span.begin('?');
1506
+ /** Makes new span for begin of resource. */
1386
1507
  static begin(uri, source = '') {
1387
1508
  return new $mol_span(uri, source, 1, 1, 0);
1388
1509
  }
1510
+ /** Makes new span for end of resource. */
1389
1511
  static end(uri, source) {
1390
1512
  return new $mol_span(uri, source, 1, source.length + 1, 0);
1391
1513
  }
1514
+ /** Makes new span for entire resource. */
1392
1515
  static entire(uri, source) {
1393
1516
  return new $mol_span(uri, source, 1, 1, source.length);
1394
1517
  }
@@ -1403,15 +1526,19 @@ var $;
1403
1526
  length: this.length
1404
1527
  };
1405
1528
  }
1529
+ /** Makes new error for this span. */
1406
1530
  error(message, Class = Error) {
1407
1531
  return new Class(`${message} (${this})`);
1408
1532
  }
1533
+ /** Makes new span for same uri. */
1409
1534
  span(row, col, length) {
1410
1535
  return new $mol_span(this.uri, this.source, row, col, length);
1411
1536
  }
1537
+ /** Makes new span after end of this. */
1412
1538
  after(length = 0) {
1413
1539
  return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
1414
1540
  }
1541
+ /** Makes new span between begin and end. */
1415
1542
  slice(begin, end = -1) {
1416
1543
  let len = this.length;
1417
1544
  if (begin < 0)
@@ -1434,6 +1561,7 @@ var $;
1434
1561
  "use strict";
1435
1562
  var $;
1436
1563
  (function ($) {
1564
+ /** Serializes tree to string in tree format. */
1437
1565
  function $mol_tree2_to_string(tree) {
1438
1566
  let output = [];
1439
1567
  function dump(tree, prefix = '') {
@@ -1477,12 +1605,25 @@ var $;
1477
1605
  "use strict";
1478
1606
  var $;
1479
1607
  (function ($) {
1608
+ /**
1609
+ * Abstract Syntax Tree with human readable serialization.
1610
+ * Avoid direct instantiation. Use static factories instead.
1611
+ * @see https://github.com/nin-jin/tree.d
1612
+ */
1480
1613
  class $mol_tree2 extends Object {
1481
1614
  type;
1482
1615
  value;
1483
1616
  kids;
1484
1617
  span;
1485
- constructor(type, value, kids, span) {
1618
+ constructor(
1619
+ /** Type of structural node, `value` should be empty */
1620
+ type,
1621
+ /** Content of data node, `type` should be empty */
1622
+ value,
1623
+ /** Child nodes */
1624
+ kids,
1625
+ /** Position in most far source resource */
1626
+ span) {
1486
1627
  super();
1487
1628
  this.type = type;
1488
1629
  this.value = value;
@@ -1490,12 +1631,15 @@ var $;
1490
1631
  this.span = span;
1491
1632
  this[Symbol.toStringTag] = type || '\\' + value;
1492
1633
  }
1634
+ /** Makes collection node. */
1493
1635
  static list(kids, span = $mol_span.unknown) {
1494
1636
  return new $mol_tree2('', '', kids, span);
1495
1637
  }
1638
+ /** Makes new derived collection node. */
1496
1639
  list(kids) {
1497
1640
  return $mol_tree2.list(kids, this.span);
1498
1641
  }
1642
+ /** Makes data node for any string. */
1499
1643
  static data(value, kids = [], span = $mol_span.unknown) {
1500
1644
  const chunks = value.split('\n');
1501
1645
  if (chunks.length > 1) {
@@ -1509,21 +1653,26 @@ var $;
1509
1653
  }
1510
1654
  return new $mol_tree2('', value, kids, span);
1511
1655
  }
1656
+ /** Makes new derived data node. */
1512
1657
  data(value, kids = []) {
1513
1658
  return $mol_tree2.data(value, kids, this.span);
1514
1659
  }
1660
+ /** Makes struct node. */
1515
1661
  static struct(type, kids = [], span = $mol_span.unknown) {
1516
1662
  if (/[ \n\t\\]/.test(type)) {
1517
1663
  $$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
1518
1664
  }
1519
1665
  return new $mol_tree2(type, '', kids, span);
1520
1666
  }
1667
+ /** Makes new derived structural node. */
1521
1668
  struct(type, kids = []) {
1522
1669
  return $mol_tree2.struct(type, kids, this.span);
1523
1670
  }
1671
+ /** Makes new derived node with different kids id defined. */
1524
1672
  clone(kids, span = this.span) {
1525
1673
  return new $mol_tree2(this.type, this.value, kids, span);
1526
1674
  }
1675
+ /** Returns multiline text content. */
1527
1676
  text() {
1528
1677
  var values = [];
1529
1678
  for (var kid of this.kids) {
@@ -1533,15 +1682,20 @@ var $;
1533
1682
  }
1534
1683
  return this.value + values.join('\n');
1535
1684
  }
1685
+ /** Parses tree format. */
1686
+ /** @deprecated Use $mol_tree2_from_string */
1536
1687
  static fromString(str, uri = 'unknown') {
1537
1688
  return $$.$mol_tree2_from_string(str, uri);
1538
1689
  }
1690
+ /** Serializes to tree format. */
1539
1691
  toString() {
1540
1692
  return $$.$mol_tree2_to_string(this);
1541
1693
  }
1694
+ /** Makes new tree with node overrided by path. */
1542
1695
  insert(value, ...path) {
1543
1696
  return this.update($mol_maybe(value), ...path)[0];
1544
1697
  }
1698
+ /** Makes new tree with node overrided by path. */
1545
1699
  update(value, ...path) {
1546
1700
  if (path.length === 0)
1547
1701
  return value;
@@ -1574,6 +1728,7 @@ var $;
1574
1728
  return [this.clone(kids)];
1575
1729
  }
1576
1730
  }
1731
+ /** Query nodes by path. */
1577
1732
  select(...path) {
1578
1733
  let next = [this];
1579
1734
  for (const type of path) {
@@ -1600,6 +1755,7 @@ var $;
1600
1755
  }
1601
1756
  return this.list(next);
1602
1757
  }
1758
+ /** Filter kids by path or value. */
1603
1759
  filter(path, value) {
1604
1760
  const sub = this.kids.filter(item => {
1605
1761
  var found = item.select(...path);
@@ -1627,9 +1783,11 @@ var $;
1627
1783
  $mol_fail_hidden(error);
1628
1784
  }
1629
1785
  }
1786
+ /** Transform tree through context with transformers */
1630
1787
  hack(belt, context = {}) {
1631
1788
  return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
1632
1789
  }
1790
+ /** Makes Error with node coordinates. */
1633
1791
  error(message, Class = Error) {
1634
1792
  return this.span.error(`${message}\n${this.clone([])}`, Class);
1635
1793
  }
@@ -1647,6 +1805,7 @@ var $;
1647
1805
  "use strict";
1648
1806
  var $;
1649
1807
  (function ($) {
1808
+ /** Syntax error with cordinates and source line snippet. */
1650
1809
  class $mol_error_syntax extends SyntaxError {
1651
1810
  reason;
1652
1811
  line;
@@ -1665,6 +1824,7 @@ var $;
1665
1824
  "use strict";
1666
1825
  var $;
1667
1826
  (function ($) {
1827
+ /** Parses tree format from string. */
1668
1828
  function $mol_tree2_from_string(str, uri = '?') {
1669
1829
  const span = $mol_span.entire(uri, str);
1670
1830
  var root = $mol_tree2.list([], span);
@@ -1674,6 +1834,7 @@ var $;
1674
1834
  var indent = 0;
1675
1835
  var line_start = pos;
1676
1836
  row++;
1837
+ // read indent
1677
1838
  while (str.length > pos && str[pos] == '\t') {
1678
1839
  indent++;
1679
1840
  pos++;
@@ -1682,8 +1843,10 @@ var $;
1682
1843
  min_indent = indent;
1683
1844
  }
1684
1845
  indent -= min_indent;
1846
+ // invalid tab size
1685
1847
  if (indent < 0 || indent >= stack.length) {
1686
1848
  const sp = span.span(row, 1, pos - line_start);
1849
+ // skip error line
1687
1850
  while (str.length > pos && str[pos] != '\n') {
1688
1851
  pos++;
1689
1852
  }
@@ -1698,7 +1861,9 @@ var $;
1698
1861
  }
1699
1862
  stack.length = indent + 1;
1700
1863
  var parent = stack[indent];
1864
+ // parse types
1701
1865
  while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
1866
+ // type can not contain space and tab
1702
1867
  var error_start = pos;
1703
1868
  while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
1704
1869
  pos++;
@@ -1710,6 +1875,7 @@ var $;
1710
1875
  const sp = span.span(row, error_start - line_start + 1, pos - error_start);
1711
1876
  this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
1712
1877
  }
1878
+ // read type
1713
1879
  var type_start = pos;
1714
1880
  while (str.length > pos &&
1715
1881
  str[pos] != '\\' &&
@@ -1724,10 +1890,12 @@ var $;
1724
1890
  parent_kids.push(next);
1725
1891
  parent = next;
1726
1892
  }
1893
+ // read one space if exists
1727
1894
  if (str.length > pos && str[pos] == ' ') {
1728
1895
  pos++;
1729
1896
  }
1730
1897
  }
1898
+ // read data
1731
1899
  if (str.length > pos && str[pos] == '\\') {
1732
1900
  var data_start = pos;
1733
1901
  while (str.length > pos && str[pos] != '\n') {
@@ -1738,6 +1906,7 @@ var $;
1738
1906
  parent_kids.push(next);
1739
1907
  parent = next;
1740
1908
  }
1909
+ // now must be end of text
1741
1910
  if (str.length === pos && stack.length > 0) {
1742
1911
  const sp = span.span(row, pos - line_start + 1, 1);
1743
1912
  this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
@@ -1830,6 +1999,7 @@ var $;
1830
1999
  "use strict";
1831
2000
  var $;
1832
2001
  (function ($) {
2002
+ /** Module for working with terminal. Text coloring when output in terminal */
1833
2003
  class $mol_term_color {
1834
2004
  static reset = this.ansi(0, 0);
1835
2005
  static bold = this.ansi(1, 22);
@@ -1901,6 +2071,7 @@ var $;
1901
2071
  "use strict";
1902
2072
  var $;
1903
2073
  (function ($) {
2074
+ /** One-shot fiber */
1904
2075
  class $mol_wire_task extends $mol_wire_fiber {
1905
2076
  static getter(task) {
1906
2077
  return function $mol_wire_task_get(host, args) {
@@ -1926,6 +2097,7 @@ var $;
1926
2097
  }
1927
2098
  const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
1928
2099
  const next = new $mol_wire_task(key, task, host, args);
2100
+ // Disabled because non-idempotency is required for try-catch
1929
2101
  if (existen?.temp) {
1930
2102
  $$.$mol_log3_warn({
1931
2103
  place: '$mol_wire_task',
@@ -1958,7 +2130,7 @@ var $;
1958
2130
  try {
1959
2131
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
1960
2132
  }
1961
- catch {
2133
+ catch { // Promises throw in strict mode
1962
2134
  Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1963
2135
  }
1964
2136
  }
@@ -2011,6 +2183,10 @@ var $;
2011
2183
  props[field] = get_val;
2012
2184
  return get_val;
2013
2185
  }
2186
+ /**
2187
+ * Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
2188
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
2189
+ */
2014
2190
  function $mol_wire_sync(obj) {
2015
2191
  return new Proxy(obj, {
2016
2192
  get(obj, field) {
@@ -2172,6 +2348,7 @@ var $;
2172
2348
  "use strict";
2173
2349
  var $;
2174
2350
  (function ($) {
2351
+ /** Converts IDBResult to Promise */
2175
2352
  function $mol_db_response(request) {
2176
2353
  return new Promise((done, fail) => {
2177
2354
  request.onerror = () => fail(new Error(request.error.message));
@@ -2185,6 +2362,14 @@ var $;
2185
2362
  "use strict";
2186
2363
  var $;
2187
2364
  (function ($) {
2365
+ /**
2366
+ * Creates new or returns existen database with automatic schema migration.
2367
+ * Schema version is based on migrations count.
2368
+ * Migrations code mustn't be changed after deploy.
2369
+ * Only adding migrations at the end is allowed.
2370
+ * Only new migrations will be applyed to existen DB.
2371
+ * Schema changes allowed only through migratios.
2372
+ */
2188
2373
  async function $mol_db(name, ...migrations) {
2189
2374
  const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
2190
2375
  request.onupgradeneeded = event => {
@@ -2203,6 +2388,7 @@ var $;
2203
2388
  "use strict";
2204
2389
  var $;
2205
2390
  (function ($) {
2391
+ /** IndexedDB ObjectStore wrapper. */
2206
2392
  class $mol_db_store {
2207
2393
  native;
2208
2394
  constructor(native) {
@@ -2217,6 +2403,7 @@ var $;
2217
2403
  get incremental() {
2218
2404
  return this.native.autoIncrement;
2219
2405
  }
2406
+ /** Returns dictionary of all existen Indexes. */
2220
2407
  get indexes() {
2221
2408
  return new Proxy({}, {
2222
2409
  ownKeys: () => [...this.native.indexNames],
@@ -2224,9 +2411,11 @@ var $;
2224
2411
  get: (_, name) => new $mol_db_index(this.native.index(name))
2225
2412
  });
2226
2413
  }
2414
+ /** Creates new Index */
2227
2415
  index_make(name, path = [], unique = false, multiEntry = false) {
2228
2416
  return this.native.createIndex(name, path, { multiEntry, unique });
2229
2417
  }
2418
+ /** Drops existen Index */
2230
2419
  index_drop(name) {
2231
2420
  this.native.deleteIndex(name);
2232
2421
  return this;
@@ -2237,21 +2426,27 @@ var $;
2237
2426
  get db() {
2238
2427
  return this.transaction.db;
2239
2428
  }
2429
+ /** Deletes all stored Documents */
2240
2430
  clear() {
2241
2431
  return $mol_db_response(this.native.clear());
2242
2432
  }
2433
+ /** Counts Documents by primary key(s) */
2243
2434
  count(keys) {
2244
2435
  return $mol_db_response(this.native.count(keys));
2245
2436
  }
2437
+ /** Stores single Document by primary key. */
2246
2438
  put(doc, key) {
2247
2439
  return $mol_db_response(this.native.put(doc, key));
2248
2440
  }
2441
+ /** Returns Document by primary key. */
2249
2442
  get(key) {
2250
2443
  return $mol_db_response(this.native.get(key));
2251
2444
  }
2445
+ /** Selects Documents by primary keys. */
2252
2446
  select(key, count) {
2253
2447
  return $mol_db_response(this.native.getAll(key, count));
2254
2448
  }
2449
+ /** Deletes Documents by primary key(s). */
2255
2450
  drop(keys) {
2256
2451
  return $mol_db_response(this.native.delete(keys));
2257
2452
  }
@@ -2273,6 +2468,7 @@ var $;
2273
2468
  "use strict";
2274
2469
  var $;
2275
2470
  (function ($) {
2471
+ /** IndexedDB Index wrapper. */
2276
2472
  class $mol_db_index {
2277
2473
  native;
2278
2474
  constructor(native) {
@@ -2299,12 +2495,15 @@ var $;
2299
2495
  get db() {
2300
2496
  return this.store.db;
2301
2497
  }
2498
+ /** Counts Documents by key(s) */
2302
2499
  count(keys) {
2303
2500
  return $mol_db_response(this.native.count(keys));
2304
2501
  }
2502
+ /** Returns Document by primary key. */
2305
2503
  get(key) {
2306
2504
  return $mol_db_response(this.native.get(key));
2307
2505
  }
2506
+ /** Selects Documents by primary keys. */
2308
2507
  select(key, count) {
2309
2508
  return $mol_db_response(this.native.getAll(key, count));
2310
2509
  }
@@ -2340,32 +2539,46 @@ var $;
2340
2539
  "use strict";
2341
2540
  var $;
2342
2541
  (function ($) {
2542
+ /** IndexedDB instance wrapper. */
2343
2543
  class $mol_db_database {
2344
2544
  native;
2345
2545
  constructor(native) {
2346
2546
  this.native = native;
2347
2547
  }
2548
+ /** Returns database name. */
2348
2549
  get name() {
2349
2550
  return this.native.name;
2350
2551
  }
2552
+ /** Returns database schema version. */
2351
2553
  get version() {
2352
2554
  return this.native.version;
2353
2555
  }
2556
+ /** Returns all stores names. */
2354
2557
  get stores() {
2355
2558
  return [...this.native.objectStoreNames];
2356
2559
  }
2560
+ /** Create read-only transaction. */
2357
2561
  read(...names) {
2358
2562
  return new $mol_db_transaction(this.native.transaction(names, 'readonly', { durability: 'relaxed' })).stores;
2359
2563
  }
2564
+ /** Create read/write transaction. */
2360
2565
  change(...names) {
2361
2566
  return new $mol_db_transaction(this.native.transaction(names, 'readwrite', { durability: 'relaxed' }));
2362
2567
  }
2568
+ /**
2569
+ * Deletes database.
2570
+ * DB can be deleted only after end of all transactions.
2571
+ */
2363
2572
  kill() {
2364
2573
  this.native.close();
2365
2574
  const request = $mol_dom_context.indexedDB.deleteDatabase(this.name);
2366
2575
  request.onblocked = console.warn;
2367
2576
  return $mol_db_response(request);
2368
2577
  }
2578
+ /**
2579
+ * Closes DB connection.
2580
+ * Connection really be closed only after end of all transactions.
2581
+ */
2369
2582
  destructor() {
2370
2583
  this.native.close();
2371
2584
  }
@@ -2377,11 +2590,13 @@ var $;
2377
2590
  "use strict";
2378
2591
  var $;
2379
2592
  (function ($) {
2593
+ /** IndexedDB Transaction wrapper. */
2380
2594
  class $mol_db_transaction {
2381
2595
  native;
2382
2596
  constructor(native) {
2383
2597
  this.native = native;
2384
2598
  }
2599
+ /** Returns dictionary of all existen Stores. */
2385
2600
  get stores() {
2386
2601
  return new Proxy({}, {
2387
2602
  ownKeys: () => [...this.native.objectStoreNames],
@@ -2391,18 +2606,22 @@ var $;
2391
2606
  : undefined,
2392
2607
  });
2393
2608
  }
2609
+ /** Creates new Store */
2394
2610
  store_make(name) {
2395
2611
  return this.native.db.createObjectStore(name, { autoIncrement: true });
2396
2612
  }
2613
+ /** Drops existen Store */
2397
2614
  store_drop(name) {
2398
2615
  this.native.db.deleteObjectStore(name);
2399
2616
  return this;
2400
2617
  }
2618
+ /** Instant abort transaction. Any errors aborts transactions automatically. */
2401
2619
  abort() {
2402
2620
  if (this.native.error)
2403
2621
  return;
2404
2622
  this.native.abort();
2405
2623
  }
2624
+ /** Instant commits transaction. Without errors commit proceed automatically later. */
2406
2625
  commit() {
2407
2626
  this.native.commit?.();
2408
2627
  return new Promise((done, fail) => {