mam 1.11.921 → 1.11.923

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
@@ -35,6 +35,11 @@ var $;
35
35
  var $;
36
36
  (function ($) {
37
37
  const instances = new WeakSet();
38
+ /**
39
+ * Proxy that delegates all to lazy returned target.
40
+ *
41
+ * $mol_delegate( Array.prototype , ()=> fetch_array() )
42
+ */
38
43
  function $mol_delegate(proto, target) {
39
44
  const proxy = new Proxy(proto, {
40
45
  get: (_, field) => {
@@ -138,7 +143,7 @@ var $;
138
143
  var $;
139
144
  (function ($) {
140
145
  function $mol_fail_hidden(error) {
141
- throw error;
146
+ throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
142
147
  }
143
148
  $.$mol_fail_hidden = $mol_fail_hidden;
144
149
  })($ || ($ = {}));
@@ -230,6 +235,9 @@ var $;
230
235
  [Symbol.dispose]() {
231
236
  this.destructor();
232
237
  }
238
+ //[ Symbol.toPrimitive ]( hint: string ) {
239
+ // return hint === 'number' ? this.valueOf() : this.toString()
240
+ //}
233
241
  toString() {
234
242
  return this[Symbol.toStringTag] || this.constructor.name + '<>';
235
243
  }
@@ -261,6 +269,7 @@ var $;
261
269
  "use strict";
262
270
  var $;
263
271
  (function ($) {
272
+ /** Generates unique identifier. */
264
273
  function $mol_guid(length = 8, exists = () => false) {
265
274
  for (;;) {
266
275
  let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
@@ -276,11 +285,16 @@ var $;
276
285
  "use strict";
277
286
  var $;
278
287
  (function ($) {
288
+ /** Special status statuses. */
279
289
  let $mol_wire_cursor;
280
290
  (function ($mol_wire_cursor) {
291
+ /** Update required. */
281
292
  $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
293
+ /** Some of (transitive) pub update required. */
282
294
  $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
295
+ /** Actual state but may be dropped. */
283
296
  $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
297
+ /** State will never be changed. */
284
298
  $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
285
299
  })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
286
300
  })($ || ($ = {}));
@@ -289,6 +303,9 @@ var $;
289
303
  "use strict";
290
304
  var $;
291
305
  (function ($) {
306
+ /**
307
+ * Collects subscribers in compact array. 28B
308
+ */
292
309
  class $mol_wire_pub extends Object {
293
310
  constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
294
311
  super();
@@ -296,10 +313,17 @@ var $;
296
313
  }
297
314
  [Symbol.toStringTag];
298
315
  data = [];
316
+ // Derived objects should be Arrays.
299
317
  static get [Symbol.species]() {
300
318
  return Array;
301
319
  }
302
- sub_from = 0;
320
+ /**
321
+ * Index of first subscriber.
322
+ */
323
+ sub_from = 0; // 4B
324
+ /**
325
+ * All current subscribers.
326
+ */
303
327
  get sub_list() {
304
328
  const res = [];
305
329
  for (let i = this.sub_from; i < this.data.length; i += 2) {
@@ -307,14 +331,23 @@ var $;
307
331
  }
308
332
  return res;
309
333
  }
334
+ /**
335
+ * Has any subscribers or not.
336
+ */
310
337
  get sub_empty() {
311
338
  return this.sub_from === this.data.length;
312
339
  }
340
+ /**
341
+ * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
342
+ */
313
343
  sub_on(sub, pub_pos) {
314
344
  const pos = this.data.length;
315
345
  this.data.push(sub, pub_pos);
316
346
  return pos;
317
347
  }
348
+ /**
349
+ * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
350
+ */
318
351
  sub_off(sub_pos) {
319
352
  if (!(sub_pos < this.data.length)) {
320
353
  $mol_fail(new Error(`Wrong pos ${sub_pos}`));
@@ -327,21 +360,39 @@ var $;
327
360
  if (end === this.sub_from)
328
361
  this.reap();
329
362
  }
363
+ /**
364
+ * Called when last sub was unsubscribed.
365
+ **/
330
366
  reap() { }
367
+ /**
368
+ * Autowire this publisher with current subscriber.
369
+ **/
331
370
  promote() {
332
371
  $mol_wire_auto()?.track_next(this);
333
372
  }
373
+ /**
374
+ * Enforce actualization. Should not throw errors.
375
+ */
334
376
  fresh() { }
377
+ /**
378
+ * Allow to put data to caches in the subtree.
379
+ */
335
380
  complete() { }
336
381
  get incompleted() {
337
382
  return false;
338
383
  }
384
+ /**
385
+ * Notify subscribers about self changes.
386
+ */
339
387
  emit(quant = $mol_wire_cursor.stale) {
340
388
  for (let i = this.sub_from; i < this.data.length; i += 2) {
341
389
  ;
342
390
  this.data[i].absorb(quant, this.data[i + 1]);
343
391
  }
344
392
  }
393
+ /**
394
+ * Moves peer from one position to another. Doesn't clear data at old position!
395
+ */
345
396
  peer_move(from_pos, to_pos) {
346
397
  const peer = this.data[from_pos];
347
398
  const self_pos = this.data[from_pos + 1];
@@ -349,6 +400,9 @@ var $;
349
400
  this.data[to_pos + 1] = self_pos;
350
401
  peer.peer_repos(self_pos, to_pos);
351
402
  }
403
+ /**
404
+ * Updates self position in the peer.
405
+ */
352
406
  peer_repos(peer_pos, self_pos) {
353
407
  this.data[peer_pos + 1] = self_pos;
354
408
  }
@@ -364,10 +418,16 @@ var $;
364
418
  var $;
365
419
  (function ($) {
366
420
  $.$mol_wire_auto_sub = null;
421
+ /**
422
+ * When fulfilled, all publishers are promoted to this subscriber on access to its.
423
+ */
367
424
  function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
368
425
  return $.$mol_wire_auto_sub = next;
369
426
  }
370
427
  $.$mol_wire_auto = $mol_wire_auto;
428
+ /**
429
+ * Affection queue. Used to prevent accidental stack overflow on emit.
430
+ */
371
431
  $.$mol_wire_affected = [];
372
432
  })($ || ($ = {}));
373
433
 
@@ -375,6 +435,7 @@ var $;
375
435
  "use strict";
376
436
  var $;
377
437
  (function ($) {
438
+ // https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
378
439
  $['devtoolsFormatters'] ||= [];
379
440
  function $mol_dev_format_register(config) {
380
441
  $['devtoolsFormatters'].push(config);
@@ -426,6 +487,7 @@ var $;
426
487
  return false;
427
488
  if (!val)
428
489
  return false;
490
+ // if( Error.isError( val ) ) true
429
491
  if (val[$.$mol_dev_format_body])
430
492
  return true;
431
493
  return false;
@@ -443,12 +505,16 @@ var $;
443
505
  return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
444
506
  }
445
507
  }
508
+ // if( Error.isError( val ) ) {
509
+ // return $mol_dev_format_native( val )
510
+ // }
446
511
  return null;
447
512
  },
448
513
  });
449
514
  function $mol_dev_format_native(obj) {
450
515
  if (typeof obj === 'undefined')
451
516
  return $.$mol_dev_format_shade('undefined');
517
+ // if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
452
518
  return [
453
519
  'object',
454
520
  {
@@ -506,6 +572,9 @@ var $;
506
572
  'margin-left': '13px'
507
573
  });
508
574
  class Stack extends Array {
575
+ // [ Symbol.toPrimitive ]() {
576
+ // return this.toString()
577
+ // }
509
578
  toString() {
510
579
  return this.join('\n');
511
580
  }
@@ -528,6 +597,7 @@ var $;
528
597
  this.method = call.getMethodName() ?? '';
529
598
  if (this.method === this.function)
530
599
  this.method = '';
600
+ // const func = c.getFunction()
531
601
  this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
532
602
  this.eval = call.getEvalOrigin() ?? '';
533
603
  this.source = call.getScriptNameOrSourceURL() ?? '';
@@ -574,9 +644,16 @@ var $;
574
644
  "use strict";
575
645
  var $;
576
646
  (function ($) {
647
+ /**
648
+ * Publisher that can auto collect other publishers. 32B
649
+ *
650
+ * P1 P2 P3 P4 S1 S2 S3
651
+ * ^ ^
652
+ * pubs_from subs_from
653
+ */
577
654
  class $mol_wire_pub_sub extends $mol_wire_pub {
578
- pub_from = 0;
579
- cursor = $mol_wire_cursor.stale;
655
+ pub_from = 0; // 4B
656
+ cursor = $mol_wire_cursor.stale; // 4B
580
657
  get temp() {
581
658
  return false;
582
659
  }
@@ -694,10 +771,27 @@ var $;
694
771
  return;
695
772
  this.cursor = quant;
696
773
  this.emit($mol_wire_cursor.doubt);
774
+ // if( pos >= 0 && pos < this.sub_from - 2 ) {
775
+ // const pub = this.data[ pos ] as $mol_wire_pub
776
+ // if( pub instanceof $mol_wire_task ) return
777
+ // for(
778
+ // let cursor = this.pub_from;
779
+ // cursor < this.sub_from;
780
+ // cursor += 2
781
+ // ) {
782
+ // const pub = this.data[ cursor ] as $mol_wire_pub
783
+ // if( pub instanceof $mol_wire_task ) {
784
+ // pub.destructor()
785
+ // }
786
+ // }
787
+ // }
697
788
  }
698
789
  [$mol_dev_format_head]() {
699
790
  return $mol_dev_format_native(this);
700
791
  }
792
+ /**
793
+ * Is subscribed to any publisher or not.
794
+ */
701
795
  get pub_empty() {
702
796
  return this.sub_from === this.pub_from;
703
797
  }
@@ -753,6 +847,13 @@ var $;
753
847
  var $;
754
848
  (function ($) {
755
849
  const wrappers = new WeakMap();
850
+ /**
851
+ * Suspendable task with support both sync/async api.
852
+ *
853
+ * A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
854
+ * ^ ^ ^
855
+ * args_from pubs_from subs_from
856
+ **/
756
857
  class $mol_wire_fiber extends $mol_wire_pub_sub {
757
858
  task;
758
859
  host;
@@ -773,6 +874,7 @@ var $;
773
874
  });
774
875
  }
775
876
  static sync() {
877
+ // Sync whole fiber graph
776
878
  while (this.planning.size) {
777
879
  for (const fiber of this.planning) {
778
880
  this.planning.delete(fiber);
@@ -783,6 +885,7 @@ var $;
783
885
  fiber.fresh();
784
886
  }
785
887
  }
888
+ // Collect garbage
786
889
  while (this.reaping.size) {
787
890
  const fibers = this.reaping;
788
891
  this.reaping = new Set;
@@ -934,6 +1037,10 @@ var $;
934
1037
  this.cursor = $mol_wire_cursor.stale;
935
1038
  this.fresh();
936
1039
  }
1040
+ /**
1041
+ * Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
1042
+ * Should be called inside SuspenseAPI consumer (ie fiber).
1043
+ */
937
1044
  sync() {
938
1045
  if (!$mol_wire_fiber.warm) {
939
1046
  return this.result();
@@ -948,6 +1055,10 @@ var $;
948
1055
  }
949
1056
  return this.cache;
950
1057
  }
1058
+ /**
1059
+ * Asynchronous execution.
1060
+ * It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
1061
+ */
951
1062
  async async_raw() {
952
1063
  while (true) {
953
1064
  this.fresh();
@@ -960,6 +1071,7 @@ var $;
960
1071
  if (!$mol_promise_like(this.cache))
961
1072
  return this.cache;
962
1073
  if (this.cursor === $mol_wire_cursor.final) {
1074
+ // never ends on destructed fiber
963
1075
  await new Promise(() => { });
964
1076
  }
965
1077
  }
@@ -1007,6 +1119,10 @@ var $;
1007
1119
  var $;
1008
1120
  (function ($) {
1009
1121
  $.$mol_compare_deep_cache = new WeakMap();
1122
+ /**
1123
+ * Deeply compares two values. Returns true if equal.
1124
+ * Define `Symbol.toPrimitive` to customize.
1125
+ */
1010
1126
  function $mol_compare_deep(left, right) {
1011
1127
  if (Object.is(left, right))
1012
1128
  return true;
@@ -1146,6 +1262,7 @@ var $;
1146
1262
  "use strict";
1147
1263
  var $;
1148
1264
  (function ($) {
1265
+ /** Log begin of collapsed group only when some logged inside, returns func to close group */
1149
1266
  function $mol_log3_area_lazy(event) {
1150
1267
  const self = this.$;
1151
1268
  const stack = self.$mol_log3_stack;
@@ -1170,6 +1287,7 @@ var $;
1170
1287
  "use strict";
1171
1288
  var $;
1172
1289
  (function ($) {
1290
+ /** Position in any resource. */
1173
1291
  class $mol_span extends $mol_object2 {
1174
1292
  uri;
1175
1293
  source;
@@ -1185,13 +1303,17 @@ var $;
1185
1303
  this.length = length;
1186
1304
  this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
1187
1305
  }
1306
+ /** Span for begin of unknown resource */
1188
1307
  static unknown = $mol_span.begin('?');
1308
+ /** Makes new span for begin of resource. */
1189
1309
  static begin(uri, source = '') {
1190
1310
  return new $mol_span(uri, source, 1, 1, 0);
1191
1311
  }
1312
+ /** Makes new span for end of resource. */
1192
1313
  static end(uri, source) {
1193
1314
  return new $mol_span(uri, source, 1, source.length + 1, 0);
1194
1315
  }
1316
+ /** Makes new span for entire resource. */
1195
1317
  static entire(uri, source) {
1196
1318
  return new $mol_span(uri, source, 1, 1, source.length);
1197
1319
  }
@@ -1206,15 +1328,19 @@ var $;
1206
1328
  length: this.length
1207
1329
  };
1208
1330
  }
1331
+ /** Makes new error for this span. */
1209
1332
  error(message, Class = Error) {
1210
1333
  return new Class(`${message} (${this})`);
1211
1334
  }
1335
+ /** Makes new span for same uri. */
1212
1336
  span(row, col, length) {
1213
1337
  return new $mol_span(this.uri, this.source, row, col, length);
1214
1338
  }
1339
+ /** Makes new span after end of this. */
1215
1340
  after(length = 0) {
1216
1341
  return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
1217
1342
  }
1343
+ /** Makes new span between begin and end. */
1218
1344
  slice(begin, end = -1) {
1219
1345
  let len = this.length;
1220
1346
  if (begin < 0)
@@ -1237,6 +1363,7 @@ var $;
1237
1363
  "use strict";
1238
1364
  var $;
1239
1365
  (function ($) {
1366
+ /** Serializes tree to string in tree format. */
1240
1367
  function $mol_tree2_to_string(tree) {
1241
1368
  let output = [];
1242
1369
  function dump(tree, prefix = '') {
@@ -1280,12 +1407,25 @@ var $;
1280
1407
  "use strict";
1281
1408
  var $;
1282
1409
  (function ($) {
1410
+ /**
1411
+ * Abstract Syntax Tree with human readable serialization.
1412
+ * Avoid direct instantiation. Use static factories instead.
1413
+ * @see https://github.com/nin-jin/tree.d
1414
+ */
1283
1415
  class $mol_tree2 extends Object {
1284
1416
  type;
1285
1417
  value;
1286
1418
  kids;
1287
1419
  span;
1288
- constructor(type, value, kids, span) {
1420
+ constructor(
1421
+ /** Type of structural node, `value` should be empty */
1422
+ type,
1423
+ /** Content of data node, `type` should be empty */
1424
+ value,
1425
+ /** Child nodes */
1426
+ kids,
1427
+ /** Position in most far source resource */
1428
+ span) {
1289
1429
  super();
1290
1430
  this.type = type;
1291
1431
  this.value = value;
@@ -1293,12 +1433,15 @@ var $;
1293
1433
  this.span = span;
1294
1434
  this[Symbol.toStringTag] = type || '\\' + value;
1295
1435
  }
1436
+ /** Makes collection node. */
1296
1437
  static list(kids, span = $mol_span.unknown) {
1297
1438
  return new $mol_tree2('', '', kids, span);
1298
1439
  }
1440
+ /** Makes new derived collection node. */
1299
1441
  list(kids) {
1300
1442
  return $mol_tree2.list(kids, this.span);
1301
1443
  }
1444
+ /** Makes data node for any string. */
1302
1445
  static data(value, kids = [], span = $mol_span.unknown) {
1303
1446
  const chunks = value.split('\n');
1304
1447
  if (chunks.length > 1) {
@@ -1312,21 +1455,26 @@ var $;
1312
1455
  }
1313
1456
  return new $mol_tree2('', value, kids, span);
1314
1457
  }
1458
+ /** Makes new derived data node. */
1315
1459
  data(value, kids = []) {
1316
1460
  return $mol_tree2.data(value, kids, this.span);
1317
1461
  }
1462
+ /** Makes struct node. */
1318
1463
  static struct(type, kids = [], span = $mol_span.unknown) {
1319
1464
  if (/[ \n\t\\]/.test(type)) {
1320
1465
  $$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
1321
1466
  }
1322
1467
  return new $mol_tree2(type, '', kids, span);
1323
1468
  }
1469
+ /** Makes new derived structural node. */
1324
1470
  struct(type, kids = []) {
1325
1471
  return $mol_tree2.struct(type, kids, this.span);
1326
1472
  }
1473
+ /** Makes new derived node with different kids id defined. */
1327
1474
  clone(kids, span = this.span) {
1328
1475
  return new $mol_tree2(this.type, this.value, kids, span);
1329
1476
  }
1477
+ /** Returns multiline text content. */
1330
1478
  text() {
1331
1479
  var values = [];
1332
1480
  for (var kid of this.kids) {
@@ -1336,15 +1484,20 @@ var $;
1336
1484
  }
1337
1485
  return this.value + values.join('\n');
1338
1486
  }
1487
+ /** Parses tree format. */
1488
+ /** @deprecated Use $mol_tree2_from_string */
1339
1489
  static fromString(str, uri = 'unknown') {
1340
1490
  return $$.$mol_tree2_from_string(str, uri);
1341
1491
  }
1492
+ /** Serializes to tree format. */
1342
1493
  toString() {
1343
1494
  return $$.$mol_tree2_to_string(this);
1344
1495
  }
1496
+ /** Makes new tree with node overrided by path. */
1345
1497
  insert(value, ...path) {
1346
1498
  return this.update($mol_maybe(value), ...path)[0];
1347
1499
  }
1500
+ /** Makes new tree with node overrided by path. */
1348
1501
  update(value, ...path) {
1349
1502
  if (path.length === 0)
1350
1503
  return value;
@@ -1377,6 +1530,7 @@ var $;
1377
1530
  return [this.clone(kids)];
1378
1531
  }
1379
1532
  }
1533
+ /** Query nodes by path. */
1380
1534
  select(...path) {
1381
1535
  let next = [this];
1382
1536
  for (const type of path) {
@@ -1403,6 +1557,7 @@ var $;
1403
1557
  }
1404
1558
  return this.list(next);
1405
1559
  }
1560
+ /** Filter kids by path or value. */
1406
1561
  filter(path, value) {
1407
1562
  const sub = this.kids.filter(item => {
1408
1563
  var found = item.select(...path);
@@ -1430,9 +1585,11 @@ var $;
1430
1585
  $mol_fail_hidden(error);
1431
1586
  }
1432
1587
  }
1588
+ /** Transform tree through context with transformers */
1433
1589
  hack(belt, context = {}) {
1434
1590
  return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
1435
1591
  }
1592
+ /** Makes Error with node coordinates. */
1436
1593
  error(message, Class = Error) {
1437
1594
  return this.span.error(`${message}\n${this.clone([])}`, Class);
1438
1595
  }
@@ -1450,6 +1607,7 @@ var $;
1450
1607
  "use strict";
1451
1608
  var $;
1452
1609
  (function ($) {
1610
+ /** Syntax error with cordinates and source line snippet. */
1453
1611
  class $mol_error_syntax extends SyntaxError {
1454
1612
  reason;
1455
1613
  line;
@@ -1468,6 +1626,7 @@ var $;
1468
1626
  "use strict";
1469
1627
  var $;
1470
1628
  (function ($) {
1629
+ /** Parses tree format from string. */
1471
1630
  function $mol_tree2_from_string(str, uri = '?') {
1472
1631
  const span = $mol_span.entire(uri, str);
1473
1632
  var root = $mol_tree2.list([], span);
@@ -1477,6 +1636,7 @@ var $;
1477
1636
  var indent = 0;
1478
1637
  var line_start = pos;
1479
1638
  row++;
1639
+ // read indent
1480
1640
  while (str.length > pos && str[pos] == '\t') {
1481
1641
  indent++;
1482
1642
  pos++;
@@ -1485,8 +1645,10 @@ var $;
1485
1645
  min_indent = indent;
1486
1646
  }
1487
1647
  indent -= min_indent;
1648
+ // invalid tab size
1488
1649
  if (indent < 0 || indent >= stack.length) {
1489
1650
  const sp = span.span(row, 1, pos - line_start);
1651
+ // skip error line
1490
1652
  while (str.length > pos && str[pos] != '\n') {
1491
1653
  pos++;
1492
1654
  }
@@ -1501,7 +1663,9 @@ var $;
1501
1663
  }
1502
1664
  stack.length = indent + 1;
1503
1665
  var parent = stack[indent];
1666
+ // parse types
1504
1667
  while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
1668
+ // type can not contain space and tab
1505
1669
  var error_start = pos;
1506
1670
  while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
1507
1671
  pos++;
@@ -1513,6 +1677,7 @@ var $;
1513
1677
  const sp = span.span(row, error_start - line_start + 1, pos - error_start);
1514
1678
  this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
1515
1679
  }
1680
+ // read type
1516
1681
  var type_start = pos;
1517
1682
  while (str.length > pos &&
1518
1683
  str[pos] != '\\' &&
@@ -1527,10 +1692,12 @@ var $;
1527
1692
  parent_kids.push(next);
1528
1693
  parent = next;
1529
1694
  }
1695
+ // read one space if exists
1530
1696
  if (str.length > pos && str[pos] == ' ') {
1531
1697
  pos++;
1532
1698
  }
1533
1699
  }
1700
+ // read data
1534
1701
  if (str.length > pos && str[pos] == '\\') {
1535
1702
  var data_start = pos;
1536
1703
  while (str.length > pos && str[pos] != '\n') {
@@ -1541,6 +1708,7 @@ var $;
1541
1708
  parent_kids.push(next);
1542
1709
  parent = next;
1543
1710
  }
1711
+ // now must be end of text
1544
1712
  if (str.length === pos && stack.length > 0) {
1545
1713
  const sp = span.span(row, pos - line_start + 1, 1);
1546
1714
  this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
@@ -1633,6 +1801,7 @@ var $;
1633
1801
  "use strict";
1634
1802
  var $;
1635
1803
  (function ($) {
1804
+ /** Module for working with terminal. Text coloring when output in terminal */
1636
1805
  class $mol_term_color {
1637
1806
  static reset = this.ansi(0, 0);
1638
1807
  static bold = this.ansi(1, 22);
@@ -1704,6 +1873,7 @@ var $;
1704
1873
  "use strict";
1705
1874
  var $;
1706
1875
  (function ($) {
1876
+ /** One-shot fiber */
1707
1877
  class $mol_wire_task extends $mol_wire_fiber {
1708
1878
  static getter(task) {
1709
1879
  return function $mol_wire_task_get(host, args) {
@@ -1729,6 +1899,7 @@ var $;
1729
1899
  }
1730
1900
  const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
1731
1901
  const next = new $mol_wire_task(key, task, host, args);
1902
+ // Disabled because non-idempotency is required for try-catch
1732
1903
  if (existen?.temp) {
1733
1904
  $$.$mol_log3_warn({
1734
1905
  place: '$mol_wire_task',
@@ -1761,7 +1932,7 @@ var $;
1761
1932
  try {
1762
1933
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
1763
1934
  }
1764
- catch {
1935
+ catch { // Promises throw in strict mode
1765
1936
  Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1766
1937
  }
1767
1938
  }
@@ -1786,6 +1957,7 @@ var $;
1786
1957
  "use strict";
1787
1958
  var $;
1788
1959
  (function ($) {
1960
+ /** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
1789
1961
  function $mol_wire_async(obj) {
1790
1962
  let fiber;
1791
1963
  const temp = $mol_wire_task.getter(obj);
@@ -1866,6 +2038,7 @@ var $;
1866
2038
  var $;
1867
2039
  (function ($) {
1868
2040
  const TypedArray = Object.getPrototypeOf(Uint8Array);
2041
+ /** Returns string key for any value. */
1869
2042
  function $mol_key(value) {
1870
2043
  primitives: {
1871
2044
  if (typeof value === 'bigint')
@@ -1873,9 +2046,9 @@ var $;
1873
2046
  if (typeof value === 'symbol')
1874
2047
  return `Symbol(${value.description})`;
1875
2048
  if (!value)
1876
- return JSON.stringify(value);
2049
+ return JSON.stringify(value); // 0, null, ""
1877
2050
  if (typeof value !== 'object' && typeof value !== 'function')
1878
- return JSON.stringify(value);
2051
+ return JSON.stringify(value); // boolean, number, string
1879
2052
  }
1880
2053
  caching: {
1881
2054
  let key = $mol_key_store.get(value);
@@ -1952,6 +2125,9 @@ var $;
1952
2125
  "use strict";
1953
2126
  var $;
1954
2127
  (function ($) {
2128
+ /**
2129
+ * Decorates method to fiber to ensure it is executed only once inside other fiber.
2130
+ */
1955
2131
  function $mol_wire_method(host, field, descr) {
1956
2132
  if (!descr)
1957
2133
  descr = Reflect.getOwnPropertyDescriptor(host, field);
@@ -1984,6 +2160,7 @@ var $;
1984
2160
  "use strict";
1985
2161
  var $;
1986
2162
  (function ($) {
2163
+ /** Long-living fiber. */
1987
2164
  class $mol_wire_atom extends $mol_wire_fiber {
1988
2165
  static solo(host, task) {
1989
2166
  const field = task.name + '()';
@@ -2034,7 +2211,11 @@ var $;
2034
2211
  }
2035
2212
  $mol_wire_atom.watching.add(this);
2036
2213
  }
2214
+ /**
2215
+ * Update atom value through another temp fiber.
2216
+ */
2037
2217
  resync(args) {
2218
+ // enforce pulling tasks abort
2038
2219
  for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
2039
2220
  const pub = this.data[cursor];
2040
2221
  if (pub && pub instanceof $mol_wire_task) {
@@ -2095,7 +2276,7 @@ var $;
2095
2276
  try {
2096
2277
  next[Symbol.toStringTag] = this[Symbol.toStringTag];
2097
2278
  }
2098
- catch {
2279
+ catch { // Promises throw in strict mode
2099
2280
  Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
2100
2281
  }
2101
2282
  }
@@ -2123,6 +2304,7 @@ var $;
2123
2304
  "use strict";
2124
2305
  var $;
2125
2306
  (function ($) {
2307
+ /** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
2126
2308
  function $mol_wire_solo(host, field, descr) {
2127
2309
  if (!descr)
2128
2310
  descr = Reflect.getOwnPropertyDescriptor(host, field);
@@ -2161,6 +2343,7 @@ var $;
2161
2343
  "use strict";
2162
2344
  var $;
2163
2345
  (function ($) {
2346
+ /** Reactive memoizing multiplexed property decorator. */
2164
2347
  function $mol_wire_plex(host, field, descr) {
2165
2348
  if (!descr)
2166
2349
  descr = Reflect.getOwnPropertyDescriptor(host, field);
@@ -2199,7 +2382,25 @@ var $;
2199
2382
  "use strict";
2200
2383
  var $;
2201
2384
  (function ($) {
2385
+ /**
2386
+ * Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
2387
+ * @example
2388
+ * '@' $mol_mem
2389
+ * name(next?: string) {
2390
+ * return next ?? 'default'
2391
+ * }
2392
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
2393
+ */
2202
2394
  $.$mol_mem = $mol_wire_solo;
2395
+ /**
2396
+ * Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
2397
+ * @example
2398
+ * '@' $mol_mem_key
2399
+ * name(id: number, next?: string) {
2400
+ * return next ?? 'default'
2401
+ * }
2402
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
2403
+ */
2203
2404
  $.$mol_mem_key = $mol_wire_plex;
2204
2405
  })($ || ($ = {}));
2205
2406
 
@@ -2235,6 +2436,10 @@ var $;
2235
2436
  props[field] = get_val;
2236
2437
  return get_val;
2237
2438
  }
2439
+ /**
2440
+ * Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
2441
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
2442
+ */
2238
2443
  function $mol_wire_sync(obj) {
2239
2444
  return new Proxy(obj, {
2240
2445
  get(obj, field) {
@@ -2359,7 +2564,7 @@ var $;
2359
2564
  "use strict";
2360
2565
  var $;
2361
2566
  (function ($) {
2362
- const mod = require('module');
2567
+ const mod = require /****/('module');
2363
2568
  const internals = mod.builtinModules;
2364
2569
  function $node_internal_check(name) {
2365
2570
  if (name.startsWith('node:'))
@@ -2373,8 +2578,8 @@ var $;
2373
2578
  "use strict";
2374
2579
  var $;
2375
2580
  (function ($) {
2376
- const path = require('path');
2377
- const mod = require('module');
2581
+ const path = require /****/('path');
2582
+ const mod = require /****/('module');
2378
2583
  const localRequire = mod.createRequire(path.join(process.cwd(), 'package.json'));
2379
2584
  function $node_autoinstall(name) {
2380
2585
  try {
@@ -2421,6 +2626,7 @@ require = (req => Object.assign(function require(name) {
2421
2626
  "use strict";
2422
2627
  var $;
2423
2628
  (function ($) {
2629
+ /** Run code without state changes */
2424
2630
  function $mol_wire_probe(task, def) {
2425
2631
  const warm = $mol_wire_fiber.warm;
2426
2632
  try {
@@ -2469,6 +2675,7 @@ var $;
2469
2675
  ])
2470
2676
  ].map(frame_normalize).join('\n')
2471
2677
  });
2678
+ // в nodejs, что б не дублировалось cause в консоли
2472
2679
  Object.defineProperty(this, 'cause', {
2473
2680
  get: () => cause
2474
2681
  });
@@ -2672,7 +2879,7 @@ var $;
2672
2879
  const err = new Error('Worker exited', { cause: { code } });
2673
2880
  if (!inited)
2674
2881
  return fail(err);
2675
- this.error([err]);
2882
+ this.error([err]); // Need to reset callers fail callbacks
2676
2883
  this.restarts(null);
2677
2884
  });
2678
2885
  worker.on('message', e => {
@@ -2732,6 +2939,10 @@ var $;
2732
2939
  "use strict";
2733
2940
  var $;
2734
2941
  (function ($) {
2942
+ /**
2943
+ * Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
2944
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
2945
+ */
2735
2946
  $.$mol_action = $mol_wire_method;
2736
2947
  })($ || ($ = {}));
2737
2948
 
@@ -2818,6 +3029,7 @@ var $;
2818
3029
  $mol_error_fence(() => this.remote().changes(changes), e => ($mol_fail_log(e), null));
2819
3030
  }
2820
3031
  changes_schedule() {
3032
+ // ts watcher calls it in host syncronously
2821
3033
  if (this.changes_tick === undefined)
2822
3034
  return;
2823
3035
  if (this.changes_tick !== null)
@@ -2847,11 +3059,12 @@ var $;
2847
3059
  }
2848
3060
  this.run();
2849
3061
  }
3062
+ // Do not place async logic here, to prevent recheck calls race
2850
3063
  recheck() {
2851
3064
  this.changes_tick?.destructor();
2852
- this.changes_tick = undefined;
2853
- this.watching(true);
2854
- this.host();
3065
+ this.changes_tick = undefined; // disable watch sending
3066
+ this.watching(true); // enable host pull in start
3067
+ this.host(); // wait host started
2855
3068
  this.recheck_internal();
2856
3069
  return this.changes_cut();
2857
3070
  }
@@ -2868,6 +3081,7 @@ var $;
2868
3081
  }, {
2869
3082
  ...$node.typescript.sys,
2870
3083
  watchDirectory: (path, cb) => {
3084
+ // console.log('watchDirectory', path )
2871
3085
  this.watchers.set(path, cb);
2872
3086
  return { close() { } };
2873
3087
  },
@@ -2878,6 +3092,7 @@ var $;
2878
3092
  this.run = cb;
2879
3093
  },
2880
3094
  watchFile: (path, cb) => {
3095
+ // console.log('watchFile', path )
2881
3096
  this.watchers.set(path, cb);
2882
3097
  return { close() { } };
2883
3098
  },
@@ -2898,7 +3113,9 @@ var $;
2898
3113
  message: typeof text === 'string' ? text : text.messageText,
2899
3114
  });
2900
3115
  }
2901
- }, () => { }, [], {
3116
+ }, () => { }, //watch reports
3117
+ [], // project refs
3118
+ {
2902
3119
  synchronousWatchDirectory: true,
2903
3120
  watchFile: 5,
2904
3121
  watchDirectory: 0,
@@ -2999,6 +3216,11 @@ var $;
2999
3216
  "use strict";
3000
3217
  var $;
3001
3218
  (function ($) {
3219
+ /**
3220
+ * Returns closure that returns constant value.
3221
+ * @example
3222
+ * const rnd = $mol_const( Math.random() )
3223
+ */
3002
3224
  function $mol_const(value) {
3003
3225
  const getter = (() => value);
3004
3226
  getter['()'] = value;
@@ -3089,7 +3311,8 @@ var $;
3089
3311
  "use strict";
3090
3312
  var $;
3091
3313
  (function ($) {
3092
- let buf = new Uint8Array(2 ** 12);
3314
+ let buf = new Uint8Array(2 ** 12); // 4KB Mem Page
3315
+ /** Temporary buffer. Recursive usage isn't supported. */
3093
3316
  function $mol_charset_buffer(size) {
3094
3317
  if (buf.byteLength < size)
3095
3318
  buf = new Uint8Array(size);
@@ -3111,19 +3334,19 @@ var $;
3111
3334
  let pos = from;
3112
3335
  for (let i = 0; i < str.length; i++) {
3113
3336
  let code = str.charCodeAt(i);
3114
- if (code < 0x80) {
3337
+ if (code < 0x80) { // ASCII - 1 octet
3115
3338
  buf[pos++] = code;
3116
3339
  }
3117
- else if (code < 0x800) {
3340
+ else if (code < 0x800) { // 2 octet
3118
3341
  buf[pos++] = 0xc0 | (code >> 6);
3119
3342
  buf[pos++] = 0x80 | (code & 0x3f);
3120
3343
  }
3121
- else if (code < 0xd800 || code >= 0xe000) {
3344
+ else if (code < 0xd800 || code >= 0xe000) { // 3 octet
3122
3345
  buf[pos++] = 0xe0 | (code >> 12);
3123
3346
  buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
3124
3347
  buf[pos++] = 0x80 | (code & 0x3f);
3125
3348
  }
3126
- else {
3349
+ else { // surrogate pair
3127
3350
  const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
3128
3351
  buf[pos++] = 0xf0 | (point >> 18);
3129
3352
  buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
@@ -3185,6 +3408,9 @@ var $;
3185
3408
  "use strict";
3186
3409
  var $;
3187
3410
  (function ($) {
3411
+ /**
3412
+ * Disable reaping of current subscriber
3413
+ */
3188
3414
  function $mol_wire_solid() {
3189
3415
  let current = $mol_wire_auto();
3190
3416
  if (current.temp)
@@ -3205,12 +3431,16 @@ var $;
3205
3431
  (function ($) {
3206
3432
  let file_modes;
3207
3433
  (function (file_modes) {
3434
+ /** create if it doesn't already exist */
3208
3435
  file_modes[file_modes["create"] = $node.fs.constants.O_CREAT] = "create";
3436
+ /** truncate to zero size if it already exists */
3209
3437
  file_modes[file_modes["exists_truncate"] = $node.fs.constants.O_TRUNC] = "exists_truncate";
3438
+ /** throw exception if it already exists */
3210
3439
  file_modes[file_modes["exists_fail"] = $node.fs.constants.O_EXCL] = "exists_fail";
3211
3440
  file_modes[file_modes["read_only"] = $node.fs.constants.O_RDONLY] = "read_only";
3212
3441
  file_modes[file_modes["write_only"] = $node.fs.constants.O_WRONLY] = "write_only";
3213
3442
  file_modes[file_modes["read_write"] = $node.fs.constants.O_RDWR] = "read_write";
3443
+ /** data will be appended to the end */
3214
3444
  file_modes[file_modes["append"] = $node.fs.constants.O_APPEND] = "append";
3215
3445
  })(file_modes || (file_modes = {}));
3216
3446
  function mode_mask(modes) {
@@ -3275,12 +3505,24 @@ var $;
3275
3505
  root() {
3276
3506
  const path = this.path();
3277
3507
  const base = this.constructor.base;
3508
+ // Если путь выше или равен base или если parent такойже как и this - считаем это корнем
3278
3509
  return base.startsWith(path) || this == this.parent();
3279
3510
  }
3280
3511
  stat(next, virt) {
3281
3512
  const path = this.path();
3282
3513
  const parent = this.parent();
3514
+ // Отслеживать проверку наличия родительской папки не стоит до корня диска
3515
+ // Лучше ограничить mam-ом
3283
3516
  if (!this.root()) {
3517
+ /*
3518
+ Если parent папка удалилась, надо ресетнуть все объекты в ней на любой глубине.
3519
+ Например, rm -rf с последующим git pull: parent папка может удалиться, потом создасться,
3520
+ а текущая папка успеет только удалиться до момента выполнения stat.
3521
+ Поэтому parent.exists() не запустит перевычисления, нужна именно parent.version()
3522
+
3523
+ Однако, parent.version() меняется не только при удалении, будет ложное срабатывание
3524
+ С этим придется мириться, красивого решения пока нет.
3525
+ */
3284
3526
  parent.version();
3285
3527
  }
3286
3528
  parent.watcher();
@@ -3294,9 +3536,19 @@ var $;
3294
3536
  if (/([\/\\]\.|___$)/.test(path))
3295
3537
  return;
3296
3538
  const file = this.relative(path.at(-1) === '/' ? path.slice(0, -1) : path);
3539
+ // console.log(type, path)
3540
+ // add (change): добавился файл - у parent надо обновить список sub, если он был заюзан
3541
+ // change, unlink (rename): обновился или удалился файл - ресетим
3542
+ // addDir (change), добавилась папка, у parent обновляем список директорий в sub
3543
+ // дочерние ресетим
3544
+ // unlinkDir (rename), удалилась папка, ресетим ее
3545
+ // stat у всех дочерних обновится сам, т.к. связан с parent.version()
3297
3546
  this.changed.add(file);
3298
3547
  if (!this.watching)
3299
3548
  return;
3549
+ // throttle, пока события поступают не сбрасываем.
3550
+ // аналог awaitWriteFinish из chokidar
3551
+ // интервалы между change-сообщениями модифицируемого файла должны быть меньше watch_debounce
3300
3552
  this.frame?.destructor();
3301
3553
  this.frame = new this.$.$mol_after_timeout(this.watch_debounce(), () => {
3302
3554
  if (!this.watching)
@@ -3305,8 +3557,16 @@ var $;
3305
3557
  $mol_wire_async(this).flush();
3306
3558
  });
3307
3559
  }
3560
+ /**
3561
+ * Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
3562
+ * Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
3563
+ */
3308
3564
  static watch_debounce() { return 500; }
3309
3565
  static flush() {
3566
+ // Пока flush работает, вотчер сюда не заходит, но может добавлять новые изменения
3567
+ // на каждом перезапуске они применятся
3568
+ // Пока run выполняется, изменения накапливаются, в конце run вызывается flush
3569
+ // Пока применяются изменения, run должен ожидать конца flush
3310
3570
  for (const file of this.changed) {
3311
3571
  const parent = file.parent();
3312
3572
  try {
@@ -3321,16 +3581,32 @@ var $;
3321
3581
  }
3322
3582
  this.changed.clear();
3323
3583
  this.watching = true;
3584
+ // this.watch_wd?.destructor()
3585
+ // this.watch_wd = null
3324
3586
  }
3325
3587
  static watching = true;
3326
3588
  static lock = new $mol_lock;
3327
3589
  static watch_off(path) {
3328
3590
  this.watching = false;
3591
+ // run должен ожидать конца flush
3329
3592
  this.flush();
3330
3593
  this.watching = false;
3594
+ /*
3595
+ watch запаздывает и событие может прилететь через 3 сек после окончания сайд эффекта
3596
+ поэтому добавляем папку, которую меняет side_effect
3597
+ Когда дойдет до выполнения flush, он ресетнет ее
3598
+
3599
+ Иначе будут лишние срабатывания
3600
+ Например, удалили hyoo/board, watch ресетит и exists начинает отдавать false, срабатывает git clone
3601
+ Сразу после него событие addDir еще не успело прийти,
3602
+ на следующем перезапуске вызывается git pull, т.к.
3603
+ с точки зрения реактивной системы hyoo/board еще не существует.
3604
+ */
3331
3605
  this.changed.add(this.absolute(path));
3332
3606
  }
3607
+ // protected static watch_wd = null as null | $mol_after_timeout
3333
3608
  static unwatched(side_effect, affected_dir) {
3609
+ // ждем, пока выполнится предыдущий unwatched
3334
3610
  const unlock = this.lock.grab();
3335
3611
  this.watch_off(affected_dir);
3336
3612
  try {
@@ -3353,6 +3629,7 @@ var $;
3353
3629
  modified() { return this.stat()?.mtime ?? null; }
3354
3630
  version() {
3355
3631
  const next = this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? '';
3632
+ // console.log('version', next, this.path())
3356
3633
  return next;
3357
3634
  }
3358
3635
  info(path) { return null; }
@@ -3370,15 +3647,19 @@ var $;
3370
3647
  writable(opts) {
3371
3648
  return new WritableStream;
3372
3649
  }
3650
+ // open( ... modes: readonly $mol_file_mode[] ) { return 0 }
3373
3651
  buffer(next) {
3652
+ // Если версия пустая - возвращаем пустой буфер
3374
3653
  let readed = new Uint8Array();
3375
3654
  if (next === undefined) {
3655
+ // Если меняется версия файла, буфер надо перечитать
3376
3656
  if (this.version())
3377
3657
  readed = this.read();
3378
3658
  }
3379
3659
  const prev = $mol_mem_cached(() => this.buffer());
3380
3660
  const changed = prev === undefined || !$mol_compare_array(prev, next ?? readed);
3381
3661
  if (prev !== undefined && changed) {
3662
+ // Логируем, если повторно читаем/пишем и буфер поменялся
3382
3663
  this.$.$mol_log3_rise({
3383
3664
  place: `$mol_file_node.buffer()`,
3384
3665
  message: 'Changed',
@@ -3387,6 +3668,11 @@ var $;
3387
3668
  }
3388
3669
  if (next === undefined)
3389
3670
  return changed ? readed : prev;
3671
+ // Если буфер при записи не поменялся и файл не удаляли перед этим - не записываем новую версию.
3672
+ // Если записывать, это приведет к смене mtime и вотчер снова триггернется, даже если содержимое файла не поменялось.
3673
+ // В этом алгоритме есть изъян.
3674
+ // Если файл записали, потом отключили вотчер, кто-то из вне его поменял, потом включили вотчер, снова записали тот же буфер,
3675
+ // то буфер не запишется на диск, т.к. кэш не консистентен с диском.
3390
3676
  if (!changed && this.exists())
3391
3677
  return prev;
3392
3678
  this.parent().exists(true);
@@ -3422,13 +3708,21 @@ var $;
3422
3708
  }
3423
3709
  return null;
3424
3710
  }
3711
+ // static watch_root = ''
3712
+ // static watcher_warned = false
3425
3713
  watcher() {
3714
+ // const constructor = this.constructor as typeof $mol_file_base
3715
+ // if (! constructor.watcher_warned) {
3716
+ // console.warn(`${constructor}.watcher() not implemented`)
3717
+ // constructor.watcher_warned = true
3718
+ // }
3426
3719
  return {
3427
3720
  destructor() { }
3428
3721
  };
3429
3722
  }
3430
3723
  exists(next) {
3431
3724
  const exists = Boolean(this.stat());
3725
+ // console.log('exists current', exists, 'next', next, this.path())
3432
3726
  if (next === undefined)
3433
3727
  return exists;
3434
3728
  if (next === exists)
@@ -3454,6 +3748,10 @@ var $;
3454
3748
  return match ? match[1].substring(1) : '';
3455
3749
  }
3456
3750
  text(next, virt) {
3751
+ // Если записываем text, и вотчер ресетнул записанный файл,
3752
+ // то надо снова его обновить, вызвать логику, которая делала пуш в text.
3753
+ // Например файл удалили, потом снова создали, версия поменялась - перезаписываем
3754
+ // Если использовать version, то вновь созданный файл, через вотчер запустит свое пересоздание
3457
3755
  if (next !== undefined)
3458
3756
  this.exists();
3459
3757
  return this.text_int(next, virt);
@@ -3478,6 +3776,7 @@ var $;
3478
3776
  if (this.type() !== 'dir')
3479
3777
  return [];
3480
3778
  this.version();
3779
+ // Если дочерний file удалился, список надо обновить
3481
3780
  return this.kids().filter(file => file.exists());
3482
3781
  }
3483
3782
  resolve(path) {
@@ -3622,10 +3921,15 @@ var $;
3622
3921
  watcher(reset) {
3623
3922
  const path = this.path();
3624
3923
  const root = this.root();
3924
+ // Если папки/файла нет, watch упадет с ошибкой
3925
+ // exists обратится к parent.version и parent.watcher
3926
+ // Поэтому у root-папки и выше не надо вызывать exists, иначе поднимется выше base до корня диска
3927
+ // exists вызывать надо, что б пересоздавать вотчер при появлении папки или файла
3625
3928
  if (!root && !this.exists())
3626
3929
  return super.watcher();
3627
3930
  let watcher;
3628
3931
  try {
3932
+ // Между exists и watch файл может удалиться, в любом случае надо обрабатывать ENOENT
3629
3933
  watcher = $node.fs.watch(path);
3630
3934
  }
3631
3935
  catch (error) {
@@ -3635,6 +3939,8 @@ var $;
3635
3939
  if (root || error.code !== 'ENOENT') {
3636
3940
  this.$.$mol_fail_log(error);
3637
3941
  }
3942
+ // Если файла нет - вотчер не создается, создастся потом, когда exists поменяется на true.
3943
+ // Если создание упало с другой ошибкой - не ломаем работу mol_file, деградируем до не реактивной fs.
3638
3944
  return super.watcher();
3639
3945
  }
3640
3946
  watcher.on('change', (type, name) => {
@@ -3646,6 +3952,7 @@ var $;
3646
3952
  watcher.on('error', e => this.$.$mol_fail_log(e));
3647
3953
  let destructed = false;
3648
3954
  watcher.on('close', () => {
3955
+ // Если в процессе работы вотчер сам закрылся, надо его переоткрыть
3649
3956
  if (!destructed)
3650
3957
  setTimeout(() => $mol_wire_async(this).watcher(null), 500);
3651
3958
  });
@@ -4001,14 +4308,18 @@ var $;
4001
4308
  ];
4002
4309
  },
4003
4310
  '': (input, belt) => {
4311
+ // string
4004
4312
  if (!input.type)
4005
4313
  return [
4006
4314
  input.data(JSON.stringify(input.text())),
4007
4315
  ];
4316
+ // variable
4008
4317
  if (/^[\w$#][\w0-9$]*$/i.test(input.type))
4009
4318
  return [
4010
4319
  input.data(input.type),
4320
+ // ... input.hack( context ),
4011
4321
  ];
4322
+ // number
4012
4323
  if ($mol_tree2_js_is_number(input.type))
4013
4324
  return [
4014
4325
  input.data(input.type)
@@ -4140,8 +4451,10 @@ var $;
4140
4451
  var $;
4141
4452
  (function ($) {
4142
4453
  let x = /x/[Symbol.matchAll];
4454
+ /** Type safe reguar expression builder */
4143
4455
  class $mol_regexp extends RegExp {
4144
4456
  groups;
4457
+ /** Prefer to use $mol_regexp.from */
4145
4458
  constructor(source, flags = 'gsu', groups = []) {
4146
4459
  super(source, flags);
4147
4460
  this.groups = groups;
@@ -4161,12 +4474,14 @@ var $;
4161
4474
  this.lastIndex = index;
4162
4475
  }
4163
4476
  }
4477
+ /** Parses input and returns found capture groups or null */
4164
4478
  [Symbol.match](str) {
4165
4479
  const res = [...this[Symbol.matchAll](str)].filter(r => r.groups).map(r => r[0]);
4166
4480
  if (!res.length)
4167
4481
  return null;
4168
4482
  return res;
4169
4483
  }
4484
+ /** Splits string by regexp edges */
4170
4485
  [Symbol.split](str) {
4171
4486
  const res = [];
4172
4487
  let token_last = null;
@@ -4221,12 +4536,14 @@ var $;
4221
4536
  get native() {
4222
4537
  return new RegExp(this.source, this.flags);
4223
4538
  }
4539
+ /** Makes regexp that greedy repeats this pattern with delimiter */
4224
4540
  static separated(chunk, sep) {
4225
4541
  return $mol_regexp.from([
4226
4542
  $mol_regexp.repeat_greedy([[chunk], sep], 0),
4227
4543
  chunk,
4228
4544
  ]);
4229
4545
  }
4546
+ /** Makes regexp that non-greedy repeats this pattern from min to max count */
4230
4547
  static repeat(source, min = 0, max = Number.POSITIVE_INFINITY) {
4231
4548
  const regexp = $mol_regexp.from(source);
4232
4549
  const upper = Number.isFinite(max) ? max : '';
@@ -4242,6 +4559,7 @@ var $;
4242
4559
  };
4243
4560
  return regexp2;
4244
4561
  }
4562
+ /** Makes regexp that greedy repeats this pattern from min to max count */
4245
4563
  static repeat_greedy(source, min = 0, max = Number.POSITIVE_INFINITY) {
4246
4564
  const regexp = $mol_regexp.from(source);
4247
4565
  const upper = Number.isFinite(max) ? max : '';
@@ -4257,6 +4575,7 @@ var $;
4257
4575
  };
4258
4576
  return regexp2;
4259
4577
  }
4578
+ /** Makes regexp that match any of options */
4260
4579
  static vary(sources, flags = 'gsu') {
4261
4580
  const groups = [];
4262
4581
  const chunks = sources.map(source => {
@@ -4266,17 +4585,21 @@ var $;
4266
4585
  });
4267
4586
  return new $mol_regexp(`(?:${chunks.join('|')})`, flags, groups);
4268
4587
  }
4588
+ /** Makes regexp that allow absent of this pattern */
4269
4589
  static optional(source) {
4270
4590
  return $mol_regexp.repeat_greedy(source, 0, 1);
4271
4591
  }
4592
+ /** Makes regexp that look ahead for pattern */
4272
4593
  static force_after(source) {
4273
4594
  const regexp = $mol_regexp.from(source);
4274
4595
  return new $mol_regexp(`(?=${regexp.source})`, regexp.flags, regexp.groups);
4275
4596
  }
4597
+ /** Makes regexp that look ahead for pattern */
4276
4598
  static forbid_after(source) {
4277
4599
  const regexp = $mol_regexp.from(source);
4278
4600
  return new $mol_regexp(`(?!${regexp.source})`, regexp.flags, regexp.groups);
4279
4601
  }
4602
+ /** Converts some js values to regexp */
4280
4603
  static from(source, { ignoreCase, multiline } = {
4281
4604
  ignoreCase: false,
4282
4605
  multiline: false,
@@ -4377,9 +4700,11 @@ var $;
4377
4700
  return regexp;
4378
4701
  }
4379
4702
  }
4703
+ /** Makes regexp which includes only unicode category */
4380
4704
  static unicode_only(...category) {
4381
4705
  return new $mol_regexp(`\\p{${category.join('=')}}`);
4382
4706
  }
4707
+ /** Makes regexp which excludes unicode category */
4383
4708
  static unicode_except(...category) {
4384
4709
  return new $mol_regexp(`\\P{${category.join('=')}}`);
4385
4710
  }
@@ -4500,13 +4825,23 @@ var $;
4500
4825
  var $;
4501
4826
  (function ($) {
4502
4827
  const err = $mol_view_tree2_error_str;
4828
+ const is_writable = (input) => input.type.includes('?');
4503
4829
  function $mol_view_tree2_class_props(klass) {
4504
4830
  let props = this.$mol_view_tree2_class_super(klass);
4831
+ // ! syntax to * and ?val syntax to ?
4505
4832
  props = props.clone(props.hack({
4506
4833
  '': (node, belt) => {
4507
- const normal = node.type.replace(/!\w+/, '*');
4834
+ const next = node.type.indexOf('?');
4835
+ const id = node.type.indexOf('!');
4836
+ let normal = node.type;
4837
+ const ch = node.type[id + 1];
4838
+ if (id !== -1 && ch?.toUpperCase() !== ch?.toLowerCase())
4839
+ normal = `${normal.substring(0, id)}*${next === -1 ? '' : '?'}`;
4840
+ else if (next !== -1)
4841
+ normal = normal.substring(0, next + 1);
4508
4842
  if (node.type === normal)
4509
4843
  return [node.clone(node.hack(belt))];
4844
+ console.warn(`Syntax ${node.type} is deprecated. Use ${normal} instead`);
4510
4845
  return [node.struct(normal, node.hack(belt))];
4511
4846
  }
4512
4847
  }));
@@ -4543,12 +4878,26 @@ var $;
4543
4878
  this.$mol_fail(err `Need a child ${operator.span}`);
4544
4879
  if (!context.factory)
4545
4880
  this.$mol_fail(err `Need a parent ${left.span}`);
4881
+ if (is_writable(left) !== is_writable(right))
4882
+ this.$mol_fail(err `Left and right operands are not compatible at ${operator.span}`);
4546
4883
  add_inner(right.clone([
4547
4884
  right.struct('=', [
4548
4885
  context.factory.struct(context.factory.type.replace(/\*.*/, '*'), [left.clone([])]),
4549
4886
  ]),
4550
4887
  ]));
4551
4888
  }
4889
+ else if (operator?.type === "<=>") {
4890
+ const right = operator.kids[0];
4891
+ if (!right)
4892
+ this.$mol_fail(err `Need a child ${operator.span}`);
4893
+ if (!is_writable(left))
4894
+ this.$mol_fail(err `Expected writable at ${left.span}`);
4895
+ if (!is_writable(right))
4896
+ this.$mol_fail(err `Expected writable at ${right.span}`);
4897
+ }
4898
+ else if (operator?.type === "<=" && is_writable(left)) {
4899
+ this.$mol_fail(err `Expected readonly at ${left.span}`);
4900
+ }
4552
4901
  if (right)
4553
4902
  context = { factory: right.clone([]) };
4554
4903
  else if (operator && !context.factory && $mol_view_tree2_class_match(operator)) {
@@ -4749,6 +5098,10 @@ var $;
4749
5098
  "use strict";
4750
5099
  var $;
4751
5100
  (function ($) {
5101
+ /**
5102
+ * Localisation in $mol framework
5103
+ * @see https://mol.hyoo.ru/#!section=docs/=s5aqnb_odub8l
5104
+ */
4752
5105
  class $mol_locale extends $mol_object {
4753
5106
  static lang_default() {
4754
5107
  return 'en';
@@ -4908,12 +5261,14 @@ var $;
4908
5261
  '=>': bind => [],
4909
5262
  '^': (ref, belt, context) => [
4910
5263
  ref.struct('...', [
5264
+ // prop ^ foo
4911
5265
  ref.kids[0]?.type
4912
5266
  ? ref.struct('()', [
4913
5267
  ref.struct('this'),
4914
5268
  ref.struct('[]', [ref.data(name_of.call(this, ref.kids[0]))]),
4915
5269
  args_of.call(this, ref.kids[0])
4916
5270
  ])
5271
+ // Having $having foo / ^
4917
5272
  : context.chain
4918
5273
  ? ref.struct('()', [
4919
5274
  ref.struct('this'),
@@ -4925,6 +5280,7 @@ var $;
4925
5280
  ref.struct('(,)', [ref.struct('obj')]),
4926
5281
  ...context.chain.slice(1).map(field => ref.struct('[]', [ref.data(field)]))
4927
5282
  ])
5283
+ // prop ^
4928
5284
  : ref.struct('()', [
4929
5285
  ref.struct('super'),
4930
5286
  ref.struct('[]', [ref.data(name)]),
@@ -5206,6 +5562,7 @@ var $;
5206
5562
  const left_parts = this.$mol_view_tree2_prop_parts(left);
5207
5563
  const right_parts = this.$mol_view_tree2_prop_parts(right);
5208
5564
  let conflict;
5565
+ // if (left_parts.next && right_parts.next) conflict = 'next'
5209
5566
  if (left_parts.key && right_parts.key)
5210
5567
  conflict = 'key';
5211
5568
  if (conflict) {
@@ -5330,7 +5687,7 @@ var $;
5330
5687
  }, context);
5331
5688
  return prop.struct('indent', [
5332
5689
  prop.struct('line', [
5333
- channel_signature.call(this, prop, ...val),
5690
+ channel_signature.call(this, prop, ...val), // Parameter, not Return
5334
5691
  prop.data(': '),
5335
5692
  ...val,
5336
5693
  ])
@@ -5556,18 +5913,33 @@ var $;
5556
5913
  "use strict";
5557
5914
  var $;
5558
5915
  (function ($) {
5916
+ /**
5917
+ * # Generic Graph model
5918
+ * - Supports any type of Nodes and Edges.
5919
+ * - All links are ordered, but this may be ignored.
5920
+ * - Multigraph supported using arrays of Edges.
5921
+ * - Hypergraph supported by reusing same Edge on set of links.
5922
+ * - Ubergraph supported using Edges as Nodes to.
5923
+ **/
5559
5924
  class $mol_graph {
5925
+ /** All registered Nodes */
5560
5926
  nodes = new Set();
5927
+ /** Edges for Nodes pairs (from-to-edge) */
5561
5928
  edges_out = new Map();
5929
+ /** Edges for Nodes pairs (to-from-edge) */
5562
5930
  edges_in = new Map();
5931
+ // LINKING NODES
5932
+ /** Full connect two Nodes */
5563
5933
  link(from, to, edge) {
5564
5934
  this.link_out(from, to, edge);
5565
5935
  this.link_in(to, from, edge);
5566
5936
  }
5937
+ /** Full disconnect two Nodes */
5567
5938
  unlink(from, to) {
5568
5939
  this.edges_in.get(to)?.delete(from);
5569
5940
  this.edges_out.get(from)?.delete(to);
5570
5941
  }
5942
+ /** Forward connect two Nodes */
5571
5943
  link_out(from, to, edge) {
5572
5944
  let pair = this.edges_out.get(from);
5573
5945
  if (!pair) {
@@ -5578,6 +5950,7 @@ var $;
5578
5950
  pair.set(to, edge);
5579
5951
  this.nodes.add(to);
5580
5952
  }
5953
+ /** Backward connect two Nodes */
5581
5954
  link_in(to, from, edge) {
5582
5955
  let pair = this.edges_in.get(to);
5583
5956
  if (!pair) {
@@ -5588,15 +5961,21 @@ var $;
5588
5961
  pair.set(from, edge);
5589
5962
  this.nodes.add(to);
5590
5963
  }
5964
+ // GETTING EDGES
5965
+ /** Return any Edge for two Nodes or null */
5591
5966
  edge(from, to) {
5592
5967
  return this.edge_out(from, to) ?? this.edge_in(to, from);
5593
5968
  }
5969
+ /** Return output Edge for two Nodes or null */
5594
5970
  edge_out(from, to) {
5595
5971
  return this.edges_out.get(from)?.get(to) ?? null;
5596
5972
  }
5973
+ /** Return input Edge for two Nodes or null */
5597
5974
  edge_in(to, from) {
5598
5975
  return this.edges_in.get(to)?.get(from) ?? null;
5599
5976
  }
5977
+ // MUTATIONS
5978
+ /** Cut cycles at lowest priority of Edges */
5600
5979
  acyclic(get_weight) {
5601
5980
  const checked = [];
5602
5981
  for (const start of this.nodes) {
@@ -5641,6 +6020,8 @@ var $;
5641
6020
  visit(start);
5642
6021
  }
5643
6022
  }
6023
+ // NODES SELECTION
6024
+ /** Topoligical ordered set of all Nodes for acyclic graph */
5644
6025
  get sorted() {
5645
6026
  const sorted = new Set();
5646
6027
  const visit = (node) => {
@@ -5658,6 +6039,7 @@ var $;
5658
6039
  }
5659
6040
  return sorted;
5660
6041
  }
6042
+ /** All Nodes which don't have input Edges */
5661
6043
  get roots() {
5662
6044
  const roots = [];
5663
6045
  for (const node of this.nodes) {
@@ -5667,6 +6049,13 @@ var $;
5667
6049
  }
5668
6050
  return roots;
5669
6051
  }
6052
+ // DEPTH STATS
6053
+ /**
6054
+ * Nodes depth statistics for acyclic graph
6055
+ * @example
6056
+ * graph.depth_stat( Math.min )
6057
+ * graph.depth_stat( Math.max )
6058
+ **/
5670
6059
  nodes_depth(select) {
5671
6060
  const stat = new Map();
5672
6061
  const visit = (node, depth = 0) => {
@@ -5681,6 +6070,12 @@ var $;
5681
6070
  visit(root);
5682
6071
  return stat;
5683
6072
  }
6073
+ /**
6074
+ * Depth's Nodes statistics for acyclic graph
6075
+ * @example
6076
+ * graph.depth_nodes( Math.min )
6077
+ * graph.depth_nodes( Math.max )
6078
+ **/
5684
6079
  depth_nodes(select) {
5685
6080
  const groups = [];
5686
6081
  for (const [node, depth] of this.nodes_depth(select).entries()) {
@@ -5889,6 +6284,7 @@ var $;
5889
6284
  return new $mol_graph();
5890
6285
  }
5891
6286
  path_added(path) { return this.added.has(path); }
6287
+ // @ $mol_mem_key
5892
6288
  add_module(path) {
5893
6289
  this.added.add(path);
5894
6290
  const mod = this.$.$mol_file.absolute(path);
@@ -5911,6 +6307,7 @@ var $;
5911
6307
  }
5912
6308
  return root.resolve('node_modules').resolve('./' + target);
5913
6309
  }
6310
+ // @ $mol_mem_key
5914
6311
  check_dep([path, target]) {
5915
6312
  const root = this.root();
5916
6313
  const deps = this.dependencies(path);
@@ -5932,6 +6329,7 @@ var $;
5932
6329
  if (index.exists())
5933
6330
  dep = index;
5934
6331
  }
6332
+ //if( dep.type() === 'file' ) dep = dep.parent()
5935
6333
  if (mod === dep)
5936
6334
  return null;
5937
6335
  const from = mod.relate(root);
@@ -6006,6 +6404,7 @@ var $;
6006
6404
  version: this.version,
6007
6405
  sources: this.sources,
6008
6406
  names: this.names,
6407
+ // sourceRoot: this.sourceRoot || undefined,
6009
6408
  mappings: sourcemap_codec.encode(this.segment_lines),
6010
6409
  file: this.file,
6011
6410
  sourcesContent: this.sourceContent,
@@ -6075,7 +6474,7 @@ var $;
6075
6474
  for (let line of lines) {
6076
6475
  const mergedLine = [];
6077
6476
  for (let segment of line) {
6078
- const mergedSegment = [segment[0]];
6477
+ const mergedSegment = [segment[0]]; // generatedColumn
6079
6478
  if (segment.length >= 2) {
6080
6479
  const sourceIndex = segment[1];
6081
6480
  const source = bundleSourceRoot + sourceRoot + raw.sources[sourceIndex];
@@ -6090,9 +6489,9 @@ var $;
6090
6489
  mergedSegment.push(mergedSourceIndex);
6091
6490
  }
6092
6491
  if (segment.length >= 3)
6093
- mergedSegment.push(segment[2]);
6492
+ mergedSegment.push(segment[2]); // originalLine
6094
6493
  if (segment.length >= 4)
6095
- mergedSegment.push(segment[3]);
6494
+ mergedSegment.push(segment[3]); // originalColumn
6096
6495
  if (segment.length >= 5) {
6097
6496
  const nameIndex = segment[4];
6098
6497
  const name = raw.names?.[nameIndex];
@@ -6290,10 +6689,14 @@ var $;
6290
6689
  return true;
6291
6690
  }
6292
6691
  this.update_safe(path);
6692
+ // mod.reset()
6693
+ // for ( const sub of mod.sub() ) sub.reset()
6293
6694
  return true;
6294
6695
  }
6295
6696
  if (this.repo(path)) {
6296
6697
  this.$.$mol_file.unwatched(() => this.init(path), path);
6698
+ // mod.reset()
6699
+ // for ( const sub of mod.sub() ) sub.reset()
6297
6700
  return true;
6298
6701
  }
6299
6702
  return false;
@@ -6370,10 +6773,21 @@ var $;
6370
6773
  command: 'git rev-parse --abbrev-ref --symbolic-full-name HEAD', dir,
6371
6774
  });
6372
6775
  const current_branch = out.stdout.toString().trim();
6776
+ // когда не на ветке - не надо пулить, например сборка во время git bisect
6373
6777
  if (!current_branch)
6374
6778
  return false;
6375
6779
  const command = ['git', 'pull'];
6376
6780
  if (!this.interactive() && this.deepen_supported()) {
6781
+ /**
6782
+ depth и deepen не годятся для локальной разработки, поэтому оставляем ограничение глубины пула только для CI
6783
+
6784
+ --depth=1 в сочетании с сабмодулями обрезает историю, кроме первого коммита
6785
+
6786
+ --deepen=1 если не сделать unset GIT_DIR
6787
+ в git-конфиге сабмодуля выставляет bare=true, после этого все команды падают с сообщением
6788
+ warning: core.bare and core.worktree do not make sense
6789
+ fatal: unable to set up work tree using invalid config
6790
+ */
6377
6791
  command.push('--deepen=1');
6378
6792
  }
6379
6793
  const timeout = this.pull_timeout();
@@ -6446,6 +6860,8 @@ var $;
6446
6860
  return res.stdout.toString().match(/HEAD branch: (.*?)\n/)?.[1] ?? 'master';
6447
6861
  }
6448
6862
  init_existing(dir) {
6863
+ // Например, если вручную склонить ревизию папки в глубине (например, hyoo/mol) перед запуском билда,
6864
+ // то hyoo надо проинициалзировать в соответствии с meta.ree
6449
6865
  const repo = this.repo_ensured(dir);
6450
6866
  const { url, branch } = repo;
6451
6867
  this.$.$mol_run.spawn({ command: ['git', 'init'], dir });
@@ -6501,12 +6917,12 @@ var $;
6501
6917
  if ([node, node_modules].includes(parent)
6502
6918
  && mod.name() !== 'node'
6503
6919
  && !mod.name().startsWith('@')) {
6504
- this.$.$node_autoinstall(mod.name());
6920
+ this.$.$node_autoinstall(mod.name()); // force autoinstall through npm
6505
6921
  return true;
6506
6922
  }
6507
6923
  if ([node, node_modules].includes(parent.parent())
6508
6924
  && parent.name().startsWith('@')) {
6509
- this.$.$node_autoinstall(`${parent.name()}/${mod.name()}`);
6925
+ this.$.$node_autoinstall(`${parent.name()}/${mod.name()}`); // force autoinstall through npm
6510
6926
  return true;
6511
6927
  }
6512
6928
  return false;
@@ -6700,6 +7116,7 @@ var $;
6700
7116
  continue;
6701
7117
  if (exclude && RegExp('[.=](' + exclude.join('|') + ')[.]', 'i').test(name))
6702
7118
  continue;
7119
+ // if (! child.exists()) return false
6703
7120
  const child_path = child.path();
6704
7121
  let files = [];
6705
7122
  if (/(meta\.tree)$/.test(name)) {
@@ -6716,8 +7133,29 @@ var $;
6716
7133
  }
6717
7134
  mods.push(...files, child);
6718
7135
  }
7136
+ //mods.sort( ( a , b )=> a.name().length - b.name().length )
6719
7137
  return mods;
6720
7138
  }
7139
+ // @ $mol_mem_key
7140
+ // modsRecursive( [ path , exclude ] : [ path : string , exclude? : readonly string[] ] ) : $mol_file[] {
7141
+ // var mod = $mol_file.absolute( path )
7142
+ // switch( mod.type() ) {
7143
+ // case 'file' :
7144
+ // return [ mod ]
7145
+ // case 'dir' :
7146
+ // var mods = [ mod ]
7147
+ // for( var m of this.mods( [ path , exclude ] ) ) {
7148
+ // if( m.type() !== 'dir' ) continue
7149
+ // for( var dep of this.modsRecursive( { path : m.path() , exclude } ) ) {
7150
+ // if( mods.indexOf( dep ) !== -1 ) continue
7151
+ // mods.push( dep )
7152
+ // }
7153
+ // }
7154
+ // return mods
7155
+ // default :
7156
+ // throw new Error( `Unsupported type "${mod.type()}" of "${mod.relate()}"` )
7157
+ // }
7158
+ // }
6721
7159
  sources([path, exclude]) {
6722
7160
  const mod = $mol_file.absolute(path);
6723
7161
  if (!mod.exists())
@@ -6826,6 +7264,7 @@ var $;
6826
7264
  }, {
6827
7265
  ...$node.typescript.sys,
6828
7266
  watchDirectory: (path, cb) => {
7267
+ // console.log('watchDirectory', path )
6829
7268
  watchers.set(path, cb);
6830
7269
  return { close() { } };
6831
7270
  },
@@ -6836,6 +7275,7 @@ var $;
6836
7275
  run = cb;
6837
7276
  },
6838
7277
  watchFile: (path, cb) => {
7278
+ // console.log('watchFile', path )
6839
7279
  watchers.set(path, cb);
6840
7280
  return { close() { } };
6841
7281
  },
@@ -6855,7 +7295,9 @@ var $;
6855
7295
  message: typeof text === 'string' ? text : text.messageText,
6856
7296
  });
6857
7297
  }
6858
- }, () => { }, [], {
7298
+ }, () => { }, //watch reports
7299
+ [], // project refs
7300
+ {
6859
7301
  synchronousWatchDirectory: true,
6860
7302
  watchFile: 5,
6861
7303
  watchDirectory: 0,
@@ -6866,6 +7308,7 @@ var $;
6866
7308
  recheck: () => {
6867
7309
  for (const path of paths) {
6868
7310
  const version = $node.fs.statSync(path).mtime.valueOf();
7311
+ // this.js_error( path, null )
6869
7312
  if (versions[path] && versions[path] !== version) {
6870
7313
  const watcher = watchers.get(path);
6871
7314
  if (watcher)
@@ -6898,6 +7341,7 @@ var $;
6898
7341
  map.sources = [src.relate()];
6899
7342
  return {
6900
7343
  text: this.$.$mol_sourcemap_strip(res.outputText),
7344
+ // .replace( /^\/\/#\ssourceMappingURL=[^\n]*/mg , '//' + src.relate() )+'\n',
6901
7345
  map: map,
6902
7346
  };
6903
7347
  }
@@ -7216,12 +7660,12 @@ var $;
7216
7660
  const errors = [];
7217
7661
  const paths = this.tsPaths({ path, exclude: exclude_ext, bundle });
7218
7662
  for (const path of paths) {
7219
- this.js_content(path);
7663
+ this.js_content(path); // recheck on file change
7220
7664
  const error = this.js_error(path);
7221
7665
  if (!error)
7222
7666
  continue;
7223
7667
  errors.push(new Error(error));
7224
- this.js_error(path, null);
7668
+ this.js_error(path, null); // ts will refill it on change
7225
7669
  }
7226
7670
  this.logBundle(target, Date.now() - start);
7227
7671
  if (errors.length) {
@@ -7480,7 +7924,7 @@ var $;
7480
7924
  if ($node_internal_check(dep))
7481
7925
  continue;
7482
7926
  if (dep === 'internal')
7483
- continue;
7927
+ continue; // @TODO: Prevent `internal` deps from `node:internal`.
7484
7928
  json.dependencies[dep] ??= `*`;
7485
7929
  }
7486
7930
  json.keywords = [...this.graph([path, exclude]).nodes]
@@ -7595,9 +8039,23 @@ var $;
7595
8039
  return [];
7596
8040
  const start = this.now();
7597
8041
  var pack = $mol_file.absolute(path);
7598
- var sources = [];
8042
+ var sources = []; // this.sourcesCSS( [ path , exclude ] )
7599
8043
  var target = pack.resolve(`-/${bundle}.css`);
7600
8044
  var targetMap = pack.resolve(`-/${bundle}.css.map`);
8045
+ // var root : any = null //$node['postcss'].root({})
8046
+ // sources.forEach(
8047
+ // src => {
8048
+ // var root2 = $node['postcss'].parse( src.content() , { from : src.path() } )
8049
+ // root = root ? root.append( root2 ) : root2
8050
+ // }
8051
+ // )
8052
+ // var processor = $node['postcss']([
8053
+ // $node[ 'postcss-custom-properties' ]({
8054
+ // preserve : true ,
8055
+ // }) ,
8056
+ // $node[ 'postcss-color-function' ]() ,
8057
+ // ])
8058
+ // var result = processor.process( root , { to : target.relate() , map : { inline : false } } )
7601
8059
  const result = {
7602
8060
  css: '/* CSS compiles into js bundle now! */',
7603
8061
  map: '/* CSS compiles into js bundle now! */',
@@ -7880,8 +8338,8 @@ var $;
7880
8338
  $mol_build.dependors['js'] = source => {
7881
8339
  var depends = {};
7882
8340
  var lines = String(source.text())
7883
- .replace(/\/\*[^]*?\*\//g, '')
7884
- .replace(/\/\/.*$/gm, '')
8341
+ .replace(/\/\*[^]*?\*\//g, '') // drop block comments
8342
+ .replace(/\/\/.*$/gm, '') // drop inline comments
7885
8343
  .split('\n');
7886
8344
  lines.forEach(function (line) {
7887
8345
  var indent = /^([\s\t]*)/.exec(line);
@@ -7901,8 +8359,8 @@ var $;
7901
8359
  $mol_build.dependors['ts'] = $mol_build.dependors['tsx'] = $mol_build.dependors['jam.js'] = $mol_build.dependors['tree.js'] = source => {
7902
8360
  var depends = {};
7903
8361
  var lines = String(source.text())
7904
- .replace(/\/\*(?!\*)[\s\S]*?\*\//g, '')
7905
- .replace(/\/\/.*$/gm, '')
8362
+ .replace(/\/\*(?!\*)[\s\S]*?\*\//g, '') // drop block comments except doc-comments
8363
+ .replace(/\/\/.*$/gm, '') // drop inline comments
7906
8364
  .split('\n');
7907
8365
  lines.forEach(function (line) {
7908
8366
  var indent = /^([\s\t]*)/.exec(line);
@@ -7948,8 +8406,8 @@ var $;
7948
8406
  '/mol/style/attach': 0,
7949
8407
  };
7950
8408
  var lines = String(source.text())
7951
- .replace(/\/\*[^]*?\*\//g, '')
7952
- .replace(/\/\/.*$/gm, '')
8409
+ .replace(/\/\*[^]*?\*\//g, '') // drop block comments
8410
+ .replace(/\/\/.*$/gm, '') // drop inline comments
7953
8411
  .split('\n');
7954
8412
  lines.forEach(function (line) {
7955
8413
  var indent = /^([\s\t]*)/.exec(line);
@@ -7966,8 +8424,8 @@ var $;
7966
8424
  '/mol/3d/glsl': 0,
7967
8425
  };
7968
8426
  var lines = String(source.text())
7969
- .replace(/\/\*[^]*?\*\//g, '')
7970
- .replace(/\/\/.*$/gm, '')
8427
+ .replace(/\/\*[^]*?\*\//g, '') // drop block comments
8428
+ .replace(/\/\/.*$/gm, '') // drop inline comments
7971
8429
  .split('\n');
7972
8430
  lines.forEach(function (line) {
7973
8431
  var indent = /^([\s\t]*)/.exec(line);
@@ -8015,6 +8473,8 @@ var $;
8015
8473
  const results = Object.create(null);
8016
8474
  for (const name of Object.keys(nets)) {
8017
8475
  for (const net of nets[name]) {
8476
+ // Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
8477
+ // 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
8018
8478
  const familyV4Value = typeof net.family === 'string' ? 'IPv4' : 4;
8019
8479
  if (net.family === familyV4Value && !net.internal) {
8020
8480
  if (!results[name]) {
@@ -8042,6 +8502,16 @@ var $;
8042
8502
  socket() {
8043
8503
  const socket = new $node.ws.WebSocketServer({
8044
8504
  server: this.http(),
8505
+ // perMessageDeflate: {
8506
+ // zlibDeflateOptions: {
8507
+ // chunkSize: 1024,
8508
+ // memLevel: 7,
8509
+ // level: 3
8510
+ // },
8511
+ // zlibInflateOptions: {
8512
+ // chunkSize: 10 * 1024
8513
+ // },
8514
+ // }
8045
8515
  });
8046
8516
  socket.on('connection', line => {
8047
8517
  this.connections.add(line);
@@ -8125,6 +8595,7 @@ var $;
8125
8595
  class $mol_build_server extends $mol_server {
8126
8596
  static trace = false;
8127
8597
  sync_middleware(mdl) {
8598
+ // const wrapped = $mol_wire_async(mdl)
8128
8599
  return $mol_func_name_from(async (req, res, next) => {
8129
8600
  const wrapped = $mol_wire_async(mdl);
8130
8601
  try {
@@ -8151,6 +8622,13 @@ var $;
8151
8622
  expressGenerator() { return this.sync_middleware(this.handleRequest.bind(this)); }
8152
8623
  handleRequest(req, res) {
8153
8624
  try {
8625
+ // if( req.query._escaped_fragment_ ) {
8626
+ // const fragment = decodeURIComponent( String( req.query._escaped_fragment_ ) )
8627
+ // const url = req.protocol + '://' + req.get( 'host' ) + req.path + '#!' + fragment
8628
+ // const html = $mol_browser.html( url )
8629
+ // res.send( html ).end()
8630
+ // return
8631
+ // }
8154
8632
  if (!this.generate(req.url))
8155
8633
  return false;
8156
8634
  res.set('Cache-Control', 'no-cache, public');
@@ -8178,6 +8656,15 @@ var $;
8178
8656
  }
8179
8657
  generate(url) {
8180
8658
  $mol_wire_solid();
8659
+ /*
8660
+ Если использовать динамически подгружаемые через $mol_script модули
8661
+ То урл тут может быть вида /demo/app/-/node_modules/stockfish/-/stockfish.js
8662
+ В path должна попасть часть до первого /-/
8663
+ Динамически подгружаться могут обособленные, редко используемые скрипты.
8664
+ Например шахматы, встроенные в основное приложение.
8665
+ У которых здоровый двиг stockfish.js динамически загружается в воркер
8666
+ только при открытии шахмат.
8667
+ */
8181
8668
  const matched = url.match(/^(.*?)\/-\/((?:(?:\w+(?:.\w+)+)(?:\/-\/)?)+)$/);
8182
8669
  if (!matched)
8183
8670
  return null;
@@ -8204,6 +8691,7 @@ var $;
8204
8691
  const root = this.$.$mol_file.absolute(this.rootPublic());
8205
8692
  const dir = root.resolve(req.path);
8206
8693
  const path = dir.path();
8694
+ // Handle .well-known paths (browser/dev tools standard paths)
8207
8695
  if (req.path === '/.well-known/appspecific/com.chrome.devtools.json') {
8208
8696
  const root = this.build().root().path();
8209
8697
  const config = {
@@ -8223,7 +8711,10 @@ var $;
8223
8711
  res.end(JSON.stringify(config, null, 2));
8224
8712
  return true;
8225
8713
  }
8714
+ // ensure загружает сорцы, делает git pull, это не стоит делать на build-папках
8715
+ // Поэтому регулярка выше отсеивает build-папки
8226
8716
  this.ensure(path);
8717
+ // a/b/?c#d, a/b/-/
8227
8718
  const match = req.url.match(/(\/|.*[^\-]\/)([\?#].*)?$/);
8228
8719
  if (!match)
8229
8720
  return;
@@ -8322,11 +8813,16 @@ var $;
8322
8813
  for (const [line, path] of this.lines()) {
8323
8814
  this.notify([line, path]);
8324
8815
  }
8816
+ // this.bundles_keep()
8325
8817
  return socket;
8326
8818
  }
8327
8819
  bundles_count(reset) {
8328
8820
  return 1 + ($mol_wire_probe(() => this.bundles_count()) ?? 0);
8329
8821
  }
8822
+ /**
8823
+ * Держать в памяти собранные бандлы плохо, т.к. gc их может долго не утилизировать и node сожрет память и упадет.
8824
+ * Логичнее удалять отложенно, после того как reload-сокет отписался от пути и повторно не подписался.
8825
+ */
8330
8826
  bundles_keep() {
8331
8827
  const build = this.build();
8332
8828
  this.bundles_count();
@@ -8371,6 +8867,12 @@ var $;
8371
8867
  const build = this.build();
8372
8868
  try {
8373
8869
  const sources = build.sourcesAll([path, ['node']]);
8870
+ /**
8871
+ Бывает надо какой-то внешней программой в watch-режиме компилить js-ки или wasm
8872
+ и класть как артефакт в - (например, игровой движок на unity)
8873
+ При изменении этих файлов, надо перезапускать страницу.
8874
+ Если их класть не в -, а рядом с сорцами, то билдер mol будет пытаться их анализировать и упадет.
8875
+ */
8374
8876
  const resources = build.bundleFiles([path, ['node']]);
8375
8877
  for (const src of [...sources, ...resources])
8376
8878
  src.version();
@@ -8388,6 +8890,7 @@ var $;
8388
8890
  }
8389
8891
  notify([line, path]) {
8390
8892
  this.bundle_changed_at(path);
8893
+ // ignore initial
8391
8894
  if (!$mol_mem_cached(() => this.notify([line, path])))
8392
8895
  return true;
8393
8896
  this.$.$mol_log3_rise({
@@ -8475,6 +8978,11 @@ var $;
8475
8978
  })
8476
8979
  .on('SIGINT', () => process.exit(0))
8477
8980
  .on('close', () => process.exit(0));
8981
+ // this.$.$mol_log3_done({
8982
+ // place: this,
8983
+ // message: 'Watch dog started',
8984
+ // hint,
8985
+ // })
8478
8986
  return terminal;
8479
8987
  }
8480
8988
  }
@@ -8728,6 +9236,12 @@ var $;
8728
9236
  createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
8729
9237
  };
8730
9238
  $.$mol_jsx_frag = '';
9239
+ /**
9240
+ * JSX adapter that makes DOM tree.
9241
+ * Generates global unique ids for every DOM-element by components tree with ids.
9242
+ * Ensures all local ids are unique.
9243
+ * Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
9244
+ */
8731
9245
  function $mol_jsx(Elem, props, ...childNodes) {
8732
9246
  const id = props && props.id || '';
8733
9247
  const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
@@ -8838,6 +9352,8 @@ var $;
8838
9352
 
8839
9353
  ;
8840
9354
  "use strict";
9355
+ /** @jsx $mol_jsx */
9356
+ /** @jsxFrag $mol_jsx_frag */
8841
9357
  var $;
8842
9358
  (function ($) {
8843
9359
  $mol_test({
@@ -8943,6 +9459,7 @@ var $;
8943
9459
  "use strict";
8944
9460
  var $;
8945
9461
  (function ($) {
9462
+ /** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
8946
9463
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
8947
9464
  const source = typeof item === 'function' ? new $mol_range2_array() : item;
8948
9465
  if (typeof item !== 'function') {
@@ -8991,6 +9508,7 @@ var $;
8991
9508
  }
8992
9509
  $.$mol_range2 = $mol_range2;
8993
9510
  class $mol_range2_array extends Array {
9511
+ // Lazy
8994
9512
  concat(...tail) {
8995
9513
  if (tail.length === 0)
8996
9514
  return this;
@@ -9002,6 +9520,7 @@ var $;
9002
9520
  }
9003
9521
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
9004
9522
  }
9523
+ // Lazy
9005
9524
  filter(check, context) {
9006
9525
  const filtered = [];
9007
9526
  let cursor = -1;
@@ -9014,13 +9533,16 @@ var $;
9014
9533
  return filtered[index];
9015
9534
  }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
9016
9535
  }
9536
+ // Diligent
9017
9537
  forEach(proceed, context) {
9018
9538
  for (let [key, value] of this.entries())
9019
9539
  proceed.call(context, value, key, this);
9020
9540
  }
9541
+ // Lazy
9021
9542
  map(proceed, context) {
9022
9543
  return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
9023
9544
  }
9545
+ // Diligent
9024
9546
  reduce(merge, result) {
9025
9547
  let index = 0;
9026
9548
  if (arguments.length === 1) {
@@ -9031,12 +9553,15 @@ var $;
9031
9553
  }
9032
9554
  return result;
9033
9555
  }
9556
+ // Lazy
9034
9557
  toReversed() {
9035
9558
  return $mol_range2(index => this[this.length - 1 - index], () => this.length);
9036
9559
  }
9560
+ // Lazy
9037
9561
  slice(from = 0, to = this.length) {
9038
9562
  return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
9039
9563
  }
9564
+ // Lazy
9040
9565
  some(check, context) {
9041
9566
  for (let index = 0; index < this.length; ++index) {
9042
9567
  if (check.call(context, this[index], index, this))
@@ -9229,6 +9754,7 @@ var $;
9229
9754
 
9230
9755
  ;
9231
9756
  "use strict";
9757
+ /** @jsx $mol_jsx */
9232
9758
  var $;
9233
9759
  (function ($) {
9234
9760
  $mol_test({
@@ -9290,6 +9816,7 @@ var $;
9290
9816
  const obj3_copy = { test: 3, obj2: obj2_copy };
9291
9817
  obj1.obj3 = obj3;
9292
9818
  obj1_copy.obj3 = obj3_copy;
9819
+ // warmup cache
9293
9820
  $mol_assert_not($mol_compare_deep(obj1, {}));
9294
9821
  $mol_assert_not($mol_compare_deep(obj2, {}));
9295
9822
  $mol_assert_not($mol_compare_deep(obj3, {}));
@@ -9359,18 +9886,34 @@ var $;
9359
9886
  "use strict";
9360
9887
  var $;
9361
9888
  (function ($) {
9889
+ /**
9890
+ * Argument must be Truthy
9891
+ * @deprecated use $mol_assert_equal instead
9892
+ */
9362
9893
  function $mol_assert_ok(value) {
9363
9894
  if (value)
9364
9895
  return;
9365
9896
  $mol_fail(new Error(`${value} ≠ true`));
9366
9897
  }
9367
9898
  $.$mol_assert_ok = $mol_assert_ok;
9899
+ /**
9900
+ * Argument must be Falsy
9901
+ * @deprecated use $mol_assert_equal instead
9902
+ */
9368
9903
  function $mol_assert_not(value) {
9369
9904
  if (!value)
9370
9905
  return;
9371
9906
  $mol_fail(new Error(`${value} ≠ false`));
9372
9907
  }
9373
9908
  $.$mol_assert_not = $mol_assert_not;
9909
+ /**
9910
+ * Handler must throw an error.
9911
+ * @example
9912
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
9913
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
9914
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
9915
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
9916
+ */
9374
9917
  function $mol_assert_fail(handler, ErrorRight) {
9375
9918
  const fail = $.$mol_fail;
9376
9919
  try {
@@ -9393,10 +9936,18 @@ var $;
9393
9936
  $mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
9394
9937
  }
9395
9938
  $.$mol_assert_fail = $mol_assert_fail;
9939
+ /** @deprecated Use $mol_assert_equal */
9396
9940
  function $mol_assert_like(...args) {
9397
9941
  $mol_assert_equal(...args);
9398
9942
  }
9399
9943
  $.$mol_assert_like = $mol_assert_like;
9944
+ /**
9945
+ * All arguments must not be structural equal to each other.
9946
+ * @example
9947
+ * $mol_assert_unique( 1 , 2 , 3 ) // Passes
9948
+ * $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
9949
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
9950
+ */
9400
9951
  function $mol_assert_unique(...args) {
9401
9952
  for (let i = 0; i < args.length; ++i) {
9402
9953
  for (let j = 0; j < args.length; ++j) {
@@ -9409,6 +9960,13 @@ var $;
9409
9960
  }
9410
9961
  }
9411
9962
  $.$mol_assert_unique = $mol_assert_unique;
9963
+ /**
9964
+ * All arguments must be structural equal each other.
9965
+ * @example
9966
+ * $mol_assert_like( [1] , [1] , [1] ) // Passes
9967
+ * $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
9968
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
9969
+ */
9412
9970
  function $mol_assert_equal(...args) {
9413
9971
  for (let i = 1; i < args.length; ++i) {
9414
9972
  if ($mol_compare_deep(args[0], args[i]))
@@ -9479,6 +10037,12 @@ var $;
9479
10037
  'return result without errors'() {
9480
10038
  $mol_assert_equal($mol_try(() => false), false);
9481
10039
  },
10040
+ //'return error if thrown'() {
10041
+ //
10042
+ // const error = new Error( '$mol_try test error' )
10043
+ // $mol_assert_equal( $mol_try( ()=> { throw error } ) , error )
10044
+ //
10045
+ //} ,
9482
10046
  });
9483
10047
  })($ || ($ = {}));
9484
10048
 
@@ -9911,6 +10475,7 @@ var $;
9911
10475
  "use strict";
9912
10476
  var $;
9913
10477
  (function ($) {
10478
+ /// @todo right orderinng
9914
10479
  $.$mol_after_mock_queue = [];
9915
10480
  function $mol_after_mock_warp() {
9916
10481
  const queue = $.$mol_after_mock_queue.splice(0);
@@ -10274,6 +10839,7 @@ var $;
10274
10839
  var $;
10275
10840
  (function ($_1) {
10276
10841
  $mol_test({
10842
+ // https://github.com/nin-jin/slides/tree/master/reactivity#component-states
10277
10843
  'Cached channel'($) {
10278
10844
  class App extends $mol_object2 {
10279
10845
  static $ = $;
@@ -10331,6 +10897,7 @@ var $;
10331
10897
  $mol_assert_equal(App.value(5), 21);
10332
10898
  $mol_assert_equal(App.value(), 21);
10333
10899
  },
10900
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-consistency
10334
10901
  'Auto recalculation of cached values'($) {
10335
10902
  class App extends $mol_object2 {
10336
10903
  static $ = $;
@@ -10358,6 +10925,7 @@ var $;
10358
10925
  App.xxx(5);
10359
10926
  $mol_assert_equal(App.zzz(), 7);
10360
10927
  },
10928
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-reasonability
10361
10929
  'Skip recalculation when actually no dependency changes'($) {
10362
10930
  const log = [];
10363
10931
  class App extends $mol_object2 {
@@ -10391,6 +10959,7 @@ var $;
10391
10959
  App.zzz();
10392
10960
  $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
10393
10961
  },
10962
+ // https://github.com/nin-jin/slides/tree/master/reactivity#flow-auto
10394
10963
  'Flow: Auto'($) {
10395
10964
  class App extends $mol_object2 {
10396
10965
  static get $() { return $; }
@@ -10428,6 +10997,7 @@ var $;
10428
10997
  $mol_assert_equal(App.result(), 23);
10429
10998
  $mol_assert_equal(App.counter, 4);
10430
10999
  },
11000
+ // https://github.com/nin-jin/slides/tree/master/reactivity#dupes-equality
10431
11001
  'Dupes: Equality'($) {
10432
11002
  let counter = 0;
10433
11003
  class App extends $mol_object2 {
@@ -10451,6 +11021,7 @@ var $;
10451
11021
  App.foo({ numbs: [2] });
10452
11022
  $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
10453
11023
  },
11024
+ // https://github.com/nin-jin/slides/tree/master/reactivity#cycle-fail
10454
11025
  'Cycle: Fail'($) {
10455
11026
  class App extends $mol_object2 {
10456
11027
  static $ = $;
@@ -10475,6 +11046,29 @@ var $;
10475
11046
  ], App, "test", null);
10476
11047
  App.test();
10477
11048
  },
11049
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
11050
+ // 'Update deps on push'( $ ) {
11051
+ // class App extends $mol_object2 {
11052
+ // static $ = $
11053
+ // @ $mol_wire_solo
11054
+ // static left( next = false ) {
11055
+ // return next
11056
+ // }
11057
+ // @ $mol_wire_solo
11058
+ // static right( next = false ) {
11059
+ // return next
11060
+ // }
11061
+ // @ $mol_wire_solo
11062
+ // static res( next?: boolean ) {
11063
+ // return this.left( next ) && this.right()
11064
+ // }
11065
+ // }
11066
+ // $mol_assert_equal( App.res(), false )
11067
+ // $mol_assert_equal( App.res( true ), false )
11068
+ // $mol_assert_equal( App.right( true ), true )
11069
+ // $mol_assert_equal( App.res(), true )
11070
+ // } ,
11071
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
10478
11072
  'Different order of pull and push'($) {
10479
11073
  class App extends $mol_object2 {
10480
11074
  static $ = $;
@@ -10486,7 +11080,7 @@ var $;
10486
11080
  }
10487
11081
  static slow(next) {
10488
11082
  if (next !== undefined)
10489
- this.slow();
11083
+ this.slow(); // enforce pull before push
10490
11084
  return this.store(next);
10491
11085
  }
10492
11086
  }
@@ -10505,6 +11099,7 @@ var $;
10505
11099
  App.store(777);
10506
11100
  $mol_assert_equal(App.fast(), App.slow(), 777);
10507
11101
  },
11102
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
10508
11103
  'Actions inside invariant'($) {
10509
11104
  class App extends $mol_object2 {
10510
11105
  static $ = $;
@@ -10544,6 +11139,7 @@ var $;
10544
11139
  static toggle() {
10545
11140
  const prev = this.checked();
10546
11141
  $mol_assert_unique(this.checked(!prev), prev);
11142
+ // $mol_assert_equal( this.checked() , prev )
10547
11143
  }
10548
11144
  static res() {
10549
11145
  return this.checked();
@@ -10568,6 +11164,39 @@ var $;
10568
11164
  ], App, "test", null);
10569
11165
  await $mol_wire_async(App).test();
10570
11166
  },
11167
+ // // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
11168
+ // 'Stable order of multiple root'( $ ) {
11169
+ // class App extends $mol_object2 {
11170
+ // static $ = $
11171
+ // static counter = 0
11172
+ // @ $mol_wire_solo
11173
+ // static left_trigger( next = 0 ) {
11174
+ // return next
11175
+ // }
11176
+ // @ $mol_wire_solo
11177
+ // static left_root() {
11178
+ // this.left_trigger()
11179
+ // return ++ this.counter
11180
+ // }
11181
+ // @ $mol_wire_solo
11182
+ // static right_trigger( next = 0 ) {
11183
+ // return next
11184
+ // }
11185
+ // @ $mol_wire_solo
11186
+ // static right_root() {
11187
+ // this.right_trigger()
11188
+ // return ++ this.counter
11189
+ // }
11190
+ // }
11191
+ // $mol_assert_equal( App.left_root(), 1 )
11192
+ // $mol_assert_equal( App.right_root(), 2 )
11193
+ // App.right_trigger( 1 )
11194
+ // App.left_trigger( 1 )
11195
+ // $mol_wire_fiber.sync()
11196
+ // $mol_assert_equal( App.right_root(), 4 )
11197
+ // $mol_assert_equal( App.left_root(), 3 )
11198
+ // } ,
11199
+ // https://github.com/nin-jin/slides/tree/master/reactivity#error-store
10571
11200
  'Restore after error'($) {
10572
11201
  class App extends $mol_object2 {
10573
11202
  static get $() { return $; }
@@ -10665,6 +11294,7 @@ var $;
10665
11294
  App.showing(true);
10666
11295
  $mol_assert_unique(App.render(), details);
10667
11296
  },
11297
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
10668
11298
  async 'Hold pubs while wait async task'($) {
10669
11299
  class App extends $mol_object2 {
10670
11300
  static $ = $;
@@ -10967,6 +11597,7 @@ var $;
10967
11597
 
10968
11598
  ;
10969
11599
  "use strict";
11600
+ /** @jsx $mol_jsx */
10970
11601
  var $;
10971
11602
  (function ($) {
10972
11603
  $mol_test({
@@ -11048,6 +11679,7 @@ var $;
11048
11679
  "use strict";
11049
11680
  var $;
11050
11681
  (function ($) {
11682
+ /** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */
11051
11683
  class $mol_wire_log extends $mol_object2 {
11052
11684
  static watch(task) {
11053
11685
  return task;
@@ -11353,6 +11985,11 @@ var $;
11353
11985
  "use strict";
11354
11986
  var $;
11355
11987
  (function ($) {
11988
+ /**
11989
+ * Combines list of unary functions/classes to one function.
11990
+ *
11991
+ * const reparse = $mol_data_pipe( JSON.stringify , JSON.parse )
11992
+ **/
11356
11993
  function $mol_data_pipe(...funcs) {
11357
11994
  return $mol_data_setup(function (input) {
11358
11995
  let value = input;
@@ -11369,6 +12006,14 @@ var $;
11369
12006
  var $;
11370
12007
  (function ($) {
11371
12008
  $mol_test({
12009
+ // @todo enable on strict
12010
+ // 'no functions'() {
12011
+ // const stringify = $mol_data_pipe()
12012
+ // type Type = $mol_type_assert<
12013
+ // typeof stringify,
12014
+ // ( input : never )=> never
12015
+ // >
12016
+ // },
11372
12017
  'single function'() {
11373
12018
  const stringify = $mol_data_pipe((input) => input.toString());
11374
12019
  $mol_assert_equal(stringify(5), '5');
@@ -11675,6 +12320,9 @@ var $;
11675
12320
  ;
11676
12321
  "use strict";
11677
12322
 
12323
+ ;
12324
+ "use strict";
12325
+
11678
12326
  ;
11679
12327
  "use strict";
11680
12328
  var $;
@@ -12066,6 +12714,10 @@ var $;
12066
12714
  "use strict";
12067
12715
  var $;
12068
12716
  (function ($) {
12717
+ /**
12718
+ * CSS Units
12719
+ * @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
12720
+ */
12069
12721
  class $mol_style_unit extends $mol_decor {
12070
12722
  literal;
12071
12723
  constructor(value, literal) {
@@ -12112,6 +12764,10 @@ var $;
12112
12764
  var $;
12113
12765
  (function ($) {
12114
12766
  const { per } = $mol_style_unit;
12767
+ /**
12768
+ * CSS Functions
12769
+ * @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
12770
+ */
12115
12771
  class $mol_style_func extends $mol_decor {
12116
12772
  name;
12117
12773
  constructor(name, value) {
@@ -12203,6 +12859,7 @@ var $;
12203
12859
  "use strict";
12204
12860
  var $;
12205
12861
  (function ($) {
12862
+ /** Create record of CSS variables. */
12206
12863
  function $mol_style_prop(prefix, keys) {
12207
12864
  const record = keys.reduce((rec, key) => {
12208
12865
  rec[key] = $mol_style_func.vary(`--${prefix}_${key}`);
@@ -12217,6 +12874,10 @@ var $;
12217
12874
  "use strict";
12218
12875
  var $;
12219
12876
  (function ($) {
12877
+ /**
12878
+ * Theme css variables
12879
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_textarea_demo
12880
+ */
12220
12881
  $.$mol_theme = $mol_style_prop('mol_theme', [
12221
12882
  'back',
12222
12883
  'hover',
@@ -12245,11 +12906,18 @@ var $;
12245
12906
 
12246
12907
  ;
12247
12908
  "use strict";
12909
+ // namespace $ {
12910
+ // $mol_style_attach( '$mol_theme_lights', `:root { --mol_theme_back: oklch( ${ $$.$mol_lights() ? 92 : 20 }% .01 var(--mol_theme_hue) ) }` )
12911
+ // }
12248
12912
 
12249
12913
  ;
12250
12914
  "use strict";
12251
12915
  var $;
12252
12916
  (function ($) {
12917
+ /**
12918
+ * Gap in CSS
12919
+ * @see https://page.hyoo.ru/#!=msdb74_bm7nsq
12920
+ */
12253
12921
  $.$mol_gap = $mol_style_prop('mol_gap', [
12254
12922
  'page',
12255
12923
  'block',
@@ -12536,6 +13204,10 @@ var $;
12536
13204
  "use strict";
12537
13205
  var $;
12538
13206
  (function ($) {
13207
+ /**
13208
+ * Real-time refresh current atom.
13209
+ * Don't use if possible. May reduce performance.
13210
+ */
12539
13211
  function $mol_wire_watch() {
12540
13212
  const atom = $mol_wire_auto();
12541
13213
  if (atom instanceof $mol_wire_atom) {
@@ -12642,6 +13314,9 @@ var $;
12642
13314
  ;
12643
13315
  "use strict";
12644
13316
 
13317
+ ;
13318
+ "use strict";
13319
+
12645
13320
  ;
12646
13321
  "use strict";
12647
13322
  var $;
@@ -12651,6 +13326,7 @@ var $;
12651
13326
 
12652
13327
  ;
12653
13328
  "use strict";
13329
+ /** @jsx $mol_jsx */
12654
13330
  var $;
12655
13331
  (function ($) {
12656
13332
  function $mol_view_visible_width() {
@@ -12665,6 +13341,11 @@ var $;
12665
13341
  return suffix;
12666
13342
  }
12667
13343
  $.$mol_view_state_key = $mol_view_state_key;
13344
+ /**
13345
+ * The base class for all visual components. It provides the infrastructure for reactive lazy rendering, handling exceptions.
13346
+ * @see https://mol.hyoo.ru/#!section=docs/=vv2nig_s5zr0f
13347
+ */
13348
+ /// Reactive statefull lazy ViewModel
12668
13349
  class $mol_view extends $mol_object {
12669
13350
  static Root(id) {
12670
13351
  return new this;
@@ -12729,16 +13410,22 @@ var $;
12729
13410
  state_key(suffix = '') {
12730
13411
  return this.$.$mol_view_state_key(suffix);
12731
13412
  }
13413
+ /// Name of element that created when element not found in DOM
12732
13414
  dom_name() {
12733
13415
  return $mol_dom_qname(this.constructor.toString()) || 'div';
12734
13416
  }
13417
+ /// NameSpace of element that created when element not found in DOM
12735
13418
  dom_name_space() { return 'http://www.w3.org/1999/xhtml'; }
13419
+ /// Raw child views
12736
13420
  sub() {
12737
13421
  return [];
12738
13422
  }
13423
+ /// Visible sub views with defined ambient context
13424
+ /// Render all by default
12739
13425
  sub_visible() {
12740
13426
  return this.sub();
12741
13427
  }
13428
+ /// Minimal width that used for lazy rendering
12742
13429
  minimal_width() {
12743
13430
  let min = 0;
12744
13431
  try {
@@ -12760,6 +13447,7 @@ var $;
12760
13447
  maximal_width() {
12761
13448
  return this.minimal_width();
12762
13449
  }
13450
+ /// Minimal height that used for lazy rendering
12763
13451
  minimal_height() {
12764
13452
  let min = 0;
12765
13453
  try {
@@ -12779,11 +13467,11 @@ var $;
12779
13467
  view_rect() {
12780
13468
  if ($mol_wire_probe(() => this.view_rect()) === undefined) {
12781
13469
  $mol_wire_watch();
12782
- return null;
13470
+ return null; // don't touch DOM to prevent instant reflow
12783
13471
  }
12784
13472
  else {
12785
13473
  const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect();
12786
- return { width, height, left, right, top, bottom };
13474
+ return { width, height, left, right, top, bottom }; // pick to optimize compare
12787
13475
  }
12788
13476
  }
12789
13477
  dom_id() {
@@ -12973,6 +13661,7 @@ var $;
12973
13661
  [$mol_dev_format_head]() {
12974
13662
  return $mol_dev_format_span({}, $mol_dev_format_native(this));
12975
13663
  }
13664
+ /** Deep search view by predicate. */
12976
13665
  *view_find(check, path = []) {
12977
13666
  if (path.length === 0 && check(this))
12978
13667
  return yield [this];
@@ -13001,6 +13690,7 @@ var $;
13001
13690
  $mol_fail_log(error);
13002
13691
  }
13003
13692
  }
13693
+ /** Renders path of views to DOM. */
13004
13694
  force_render(path) {
13005
13695
  const kids = this.sub();
13006
13696
  const index = kids.findIndex(item => {
@@ -13015,6 +13705,7 @@ var $;
13015
13705
  kids[index].force_render(path);
13016
13706
  }
13017
13707
  }
13708
+ /** Renders view to DOM and scroll to it. */
13018
13709
  ensure_visible(view, align = "start") {
13019
13710
  const path = this.view_find(v => v === view).next().value;
13020
13711
  this.force_render(new Set(path));
@@ -13029,6 +13720,9 @@ var $;
13029
13720
  const win = this.$.$mol_dom_context;
13030
13721
  if (win.parent !== win.self && !win.document.hasFocus())
13031
13722
  return;
13723
+ // new this.$.$mol_after_frame( ()=> {
13724
+ // this.dom_node().scrollIntoView({ block: 'start', inline: 'nearest' })
13725
+ // } )
13032
13726
  new this.$.$mol_after_timeout(0, () => {
13033
13727
  this.focused(true);
13034
13728
  });
@@ -13217,6 +13911,7 @@ var $;
13217
13911
  "use strict";
13218
13912
  var $;
13219
13913
  (function ($) {
13914
+ /** Plugin is component without its own DOM element, but instead uses the owner DOM element */
13220
13915
  class $mol_plugin extends $mol_view {
13221
13916
  dom_node_external(next) {
13222
13917
  return next ?? $mol_owning_get(this).host.dom_node();
@@ -13257,6 +13952,10 @@ var $;
13257
13952
  "use strict";
13258
13953
  var $;
13259
13954
  (function ($) {
13955
+ /**
13956
+ * Key names code for hotkey
13957
+ * @see [mol_hotkey](../../hotkey/hotkey.view.ts)
13958
+ */
13260
13959
  let $mol_keyboard_code;
13261
13960
  (function ($mol_keyboard_code) {
13262
13961
  $mol_keyboard_code[$mol_keyboard_code["backspace"] = 8] = "backspace";
@@ -13365,12 +14064,17 @@ var $;
13365
14064
  ;
13366
14065
  "use strict";
13367
14066
 
14067
+
13368
14068
  ;
13369
14069
  "use strict";
13370
14070
  var $;
13371
14071
  (function ($) {
13372
14072
  var $$;
13373
14073
  (function ($$) {
14074
+ /**
14075
+ * Plugin which adds handlers for keyboard keys.
14076
+ * @see [mol_keyboard_code](../keyboard/code/code.ts)
14077
+ */
13374
14078
  class $mol_hotkey extends $.$mol_hotkey {
13375
14079
  key() {
13376
14080
  return super.key();
@@ -13546,6 +14250,10 @@ var $;
13546
14250
  "use strict";
13547
14251
  var $;
13548
14252
  (function ($) {
14253
+ /**
14254
+ * Z-index values for layers
14255
+ * https://page.hyoo.ru/#!=xthcpx_wqmiba
14256
+ */
13549
14257
  $.$mol_layer = $mol_style_prop('mol_layer', [
13550
14258
  'hover',
13551
14259
  'focus',
@@ -13568,12 +14276,17 @@ var $;
13568
14276
  ;
13569
14277
  "use strict";
13570
14278
 
14279
+
13571
14280
  ;
13572
14281
  "use strict";
13573
14282
  var $;
13574
14283
  (function ($) {
13575
14284
  var $$;
13576
14285
  (function ($$) {
14286
+ /**
14287
+ * An input field for entering single line text.
14288
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_string_demo
14289
+ */
13577
14290
  class $mol_string extends $.$mol_string {
13578
14291
  event_change(next) {
13579
14292
  if (!next)
@@ -13697,6 +14410,7 @@ var $;
13697
14410
  ;
13698
14411
  "use strict";
13699
14412
 
14413
+
13700
14414
  ;
13701
14415
  "use strict";
13702
14416
  var $;
@@ -13834,12 +14548,17 @@ var $;
13834
14548
  ;
13835
14549
  "use strict";
13836
14550
 
14551
+
13837
14552
  ;
13838
14553
  "use strict";
13839
14554
  var $;
13840
14555
  (function ($) {
13841
14556
  var $$;
13842
14557
  (function ($$) {
14558
+ /**
14559
+ * Output text with dimmed mismatched substrings.
14560
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_dimmer_demo
14561
+ */
13843
14562
  class $mol_dimmer extends $.$mol_dimmer {
13844
14563
  parts() {
13845
14564
  const needle = this.needle();
@@ -13909,6 +14628,7 @@ var $;
13909
14628
  ;
13910
14629
  "use strict";
13911
14630
 
14631
+
13912
14632
  ;
13913
14633
  ($.$mol_button) = class $mol_button extends ($.$mol_view) {
13914
14634
  event_activate(next){
@@ -14043,12 +14763,17 @@ var $;
14043
14763
  ;
14044
14764
  "use strict";
14045
14765
 
14766
+
14046
14767
  ;
14047
14768
  "use strict";
14048
14769
  var $;
14049
14770
  (function ($) {
14050
14771
  var $$;
14051
14772
  (function ($$) {
14773
+ /**
14774
+ * Simple button.
14775
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_button_demo
14776
+ */
14052
14777
  class $mol_button extends $.$mol_button {
14053
14778
  disabled() {
14054
14779
  return !this.enabled();
@@ -14064,6 +14789,7 @@ var $;
14064
14789
  this.status([null]);
14065
14790
  }
14066
14791
  catch (error) {
14792
+ // Calling actions from catch section, if throwing promise breaks idempotency
14067
14793
  Promise.resolve().then(() => this.status([error]));
14068
14794
  $mol_fail_hidden(error);
14069
14795
  }
@@ -14133,6 +14859,7 @@ var $;
14133
14859
  ;
14134
14860
  "use strict";
14135
14861
 
14862
+
14136
14863
  ;
14137
14864
  ($.$mol_button_minor) = class $mol_button_minor extends ($.$mol_button_typed) {};
14138
14865
 
@@ -14147,6 +14874,7 @@ var $;
14147
14874
  ;
14148
14875
  "use strict";
14149
14876
 
14877
+
14150
14878
  ;
14151
14879
  "use strict";
14152
14880
  var $;
@@ -14176,12 +14904,12 @@ var $;
14176
14904
  `;
14177
14905
  const dest = `
14178
14906
  query? \\
14179
- clear?event null
14907
+ clear? null
14180
14908
  Query $mol_string value? <=> query?
14181
14909
  Suggest_label $mol_dimmer
14182
14910
  needle <= query?
14183
14911
  key * escape? <=> clear?
14184
- Clear $mol_button_minor click?event <=> clear?event
14912
+ Clear $mol_button_minor click? <=> clear?
14185
14913
  `;
14186
14914
  const res = normalize($, src, dest);
14187
14915
  $mol_assert_equal(res.input, res.output);
@@ -14203,10 +14931,10 @@ var $;
14203
14931
  const dest = `
14204
14932
  Close_icon ${d}mol_icon_cross
14205
14933
  Title ${d}mol_view sub / <= title
14206
- close?event null
14934
+ close? null
14207
14935
  Close ${d}mol_button
14208
14936
  title \\close
14209
- click?event <=> close?event
14937
+ click? <=> close?
14210
14938
  title @ \\title
14211
14939
  sub2 / <= Close_icon
14212
14940
  sub /
@@ -14252,7 +14980,7 @@ var $;
14252
14980
  const dest = `
14253
14981
  clear? = Suggest_label clear?
14254
14982
  Suggest_label $mol_dimmer clear? => clear?
14255
- Clear $mol_button_minor click?e <=> clear?e
14983
+ Clear $mol_button_minor click? <=> clear?
14256
14984
  `;
14257
14985
  const res = normalize($, src, dest);
14258
14986
  $mol_assert_equal(res.input, res.output);
@@ -14268,7 +14996,7 @@ var $;
14268
14996
  $mol_assert_fail(() => normalize($, src).input, `Need an equal default values at \`/mol/view/tree2/class/props.test.ts#4:16/5\` vs \`/mol/view/tree2/class/props.test.ts#6:23/11\`
14269
14997
  <=>
14270
14998
  /mol/view/tree2/class/props.test.ts#6:19/3
14271
- click?event
14999
+ click?
14272
15000
  /mol/view/tree2/class/props.test.ts#6:7/11
14273
15001
  $mol_button_minor
14274
15002
  /mol/view/tree2/class/props.test.ts#5:12/17
@@ -15371,6 +16099,11 @@ var $;
15371
16099
  "use strict";
15372
16100
  var $;
15373
16101
  (function ($) {
16102
+ /**
16103
+ * CSS in TS.
16104
+ * Statically typed CSS style sheets. Following samples show which CSS code are generated from TS code.
16105
+ * @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
16106
+ */
15374
16107
  function $mol_style_define(Component, config) {
15375
16108
  return $mol_style_attach(Component.name, $mol_style_sheet(Component, config));
15376
16109
  }
@@ -15380,12 +16113,17 @@ var $;
15380
16113
  ;
15381
16114
  "use strict";
15382
16115
 
16116
+
15383
16117
  ;
15384
16118
  "use strict";
15385
16119
  var $;
15386
16120
  (function ($) {
15387
16121
  var $$;
15388
16122
  (function ($$) {
16123
+ /**
16124
+ * Scrolling pane.
16125
+ * @see https://mol.hyoo.ru/#!section=demos/demo=mol_scroll_demo
16126
+ */
15389
16127
  class $mol_scroll extends $.$mol_scroll {
15390
16128
  scroll_top(next, cache) {
15391
16129
  const el = this.dom_node();
@@ -15435,6 +16173,7 @@ var $;
15435
16173
  direction: 'column',
15436
16174
  grow: 1,
15437
16175
  shrink: 1,
16176
+ // basis: 0,
15438
16177
  },
15439
16178
  outline: 'none',
15440
16179
  align: {
@@ -15452,6 +16191,7 @@ var $;
15452
16191
  contain: 'content',
15453
16192
  '>': {
15454
16193
  $mol_view: {
16194
+ // transform: 'translateZ(0)', // enforce gpu scroll in all agents
15455
16195
  gridArea: '1/1',
15456
16196
  },
15457
16197
  },
@@ -15564,6 +16304,7 @@ var $;
15564
16304
  ;
15565
16305
  "use strict";
15566
16306
 
16307
+
15567
16308
  ;
15568
16309
  "use strict";
15569
16310
  var $;
@@ -15584,6 +16325,8 @@ var $;
15584
16325
  maxHeight: per(100),
15585
16326
  boxSizing: 'border-box',
15586
16327
  color: $mol_theme.text,
16328
+ // backdropFilter: blur( `3px` ), enforces layering
16329
+ // zIndex: 0 ,
15587
16330
  ':focus': {
15588
16331
  outline: 'none',
15589
16332
  },
@@ -16101,99 +16844,131 @@ var $;
16101
16844
  ;
16102
16845
  "use strict";
16103
16846
 
16847
+
16104
16848
  ;
16105
16849
  "use strict";
16106
16850
 
16851
+
16107
16852
  ;
16108
16853
  "use strict";
16109
16854
 
16855
+
16110
16856
  ;
16111
16857
  "use strict";
16112
16858
 
16859
+
16113
16860
  ;
16114
16861
  "use strict";
16115
16862
 
16863
+
16116
16864
  ;
16117
16865
  "use strict";
16118
16866
 
16867
+
16119
16868
  ;
16120
16869
  "use strict";
16121
16870
 
16871
+
16122
16872
  ;
16123
16873
  "use strict";
16124
16874
 
16875
+
16125
16876
  ;
16126
16877
  "use strict";
16127
16878
 
16879
+
16128
16880
  ;
16129
16881
  "use strict";
16130
16882
 
16883
+
16131
16884
  ;
16132
16885
  "use strict";
16133
16886
 
16887
+
16134
16888
  ;
16135
16889
  "use strict";
16136
16890
 
16891
+
16137
16892
  ;
16138
16893
  "use strict";
16139
16894
 
16895
+
16140
16896
  ;
16141
16897
  "use strict";
16142
16898
 
16899
+
16143
16900
  ;
16144
16901
  "use strict";
16145
16902
 
16903
+
16146
16904
  ;
16147
16905
  "use strict";
16148
16906
 
16907
+
16149
16908
  ;
16150
16909
  "use strict";
16151
16910
 
16911
+
16152
16912
  ;
16153
16913
  "use strict";
16154
16914
 
16915
+
16155
16916
  ;
16156
16917
  "use strict";
16157
16918
 
16919
+
16158
16920
  ;
16159
16921
  "use strict";
16160
16922
 
16923
+
16161
16924
  ;
16162
16925
  "use strict";
16163
16926
 
16927
+
16164
16928
  ;
16165
16929
  "use strict";
16166
16930
 
16931
+
16167
16932
  ;
16168
16933
  "use strict";
16169
16934
 
16935
+
16170
16936
  ;
16171
16937
  "use strict";
16172
16938
 
16939
+
16173
16940
  ;
16174
16941
  "use strict";
16175
16942
 
16943
+
16176
16944
  ;
16177
16945
  "use strict";
16178
16946
 
16947
+
16179
16948
  ;
16180
16949
  "use strict";
16181
16950
 
16951
+
16182
16952
  ;
16183
16953
  "use strict";
16184
16954
 
16955
+
16185
16956
  ;
16186
16957
  "use strict";
16187
16958
 
16959
+
16188
16960
  ;
16189
16961
  "use strict";
16190
16962
 
16963
+
16191
16964
  ;
16192
16965
  "use strict";
16193
16966
 
16967
+
16194
16968
  ;
16195
16969
  "use strict";
16196
16970
 
16971
+
16197
16972
  ;
16198
16973
  "use strict";
16199
16974
  var $;
@@ -16229,45 +17004,59 @@ var $;
16229
17004
  ;
16230
17005
  "use strict";
16231
17006
 
17007
+
16232
17008
  ;
16233
17009
  "use strict";
16234
17010
 
17011
+
16235
17012
  ;
16236
17013
  "use strict";
16237
17014
 
17015
+
16238
17016
  ;
16239
17017
  "use strict";
16240
17018
 
17019
+
16241
17020
  ;
16242
17021
  "use strict";
16243
17022
 
17023
+
16244
17024
  ;
16245
17025
  "use strict";
16246
17026
 
17027
+
16247
17028
  ;
16248
17029
  "use strict";
16249
17030
 
17031
+
16250
17032
  ;
16251
17033
  "use strict";
16252
17034
 
17035
+
16253
17036
  ;
16254
17037
  "use strict";
16255
17038
 
17039
+
16256
17040
  ;
16257
17041
  "use strict";
16258
17042
 
17043
+
16259
17044
  ;
16260
17045
  "use strict";
16261
17046
 
17047
+
16262
17048
  ;
16263
17049
  "use strict";
16264
17050
 
17051
+
16265
17052
  ;
16266
17053
  "use strict";
16267
17054
 
17055
+
16268
17056
  ;
16269
17057
  "use strict";
16270
17058
 
17059
+
16271
17060
  ;
16272
17061
  "use strict";
16273
17062
  var $;
@@ -16355,13 +17144,13 @@ var $;
16355
17144
  $mol_view_tree2_to_js_test_run(`
16356
17145
  Foo $mol_view
16357
17146
  a!? $mol_view
16358
- expanded <=> cell_test_expanded!? null
17147
+ expanded? <=> cell_test_expanded!? null
16359
17148
  `);
16360
- }, `Required prop like some*? at \`.view.tree#4:21/20\`
17149
+ }, `Required prop like some*? at \`.view.tree#4:22/20\`
16361
17150
  <=>
16362
- .view.tree#4:17/3
16363
- expanded
16364
- .view.tree#4:8/8
17151
+ .view.tree#4:18/3
17152
+ expanded?
17153
+ .view.tree#4:8/9
16365
17154
  $mol_view
16366
17155
  .view.tree#3:11/9
16367
17156
  a!?
@@ -16395,7 +17184,9 @@ var $;
16395
17184
  'Left bind read only'($) {
16396
17185
  const _foo = $mol_view_tree2_to_js_test_ex_left_read_only_foo;
16397
17186
  const foo = _foo.make({ $ });
16398
- $mol_assert_like(foo.bar1(), foo.bar1(2), foo.bar1(), foo.bar2(), 1);
17187
+ $mol_assert_like(foo.bar1(),
17188
+ // @ts-ignore
17189
+ foo.bar1(2), foo.bar1(), foo.bar2(), 1);
16399
17190
  $mol_assert_like(foo.bar2(2), foo.bar1(), 2);
16400
17191
  },
16401
17192
  'Left bind second level index'($) {
@@ -16422,7 +17213,11 @@ var $;
16422
17213
  const foo = _foo.make({ $ });
16423
17214
  $mol_assert_equal(foo.d(), foo.c(), foo.b(), foo.a(), 0);
16424
17215
  $mol_assert_equal(foo.d(1), foo.c(), foo.b(), foo.a(), 1);
16425
- $mol_assert_equal(foo.a(2), foo.b(2), foo.c(), foo.d(), 1);
17216
+ $mol_assert_equal(
17217
+ // @ts-ignore
17218
+ foo.a(2),
17219
+ // @ts-ignore
17220
+ foo.b(2), foo.c(), foo.d(), 1);
16426
17221
  $mol_assert_equal(foo.c(2), foo.b(), foo.a(), 2);
16427
17222
  $mol_assert_equal(foo.d(1), 1);
16428
17223
  $mol_assert_equal(foo.d(3), foo.c(), foo.b(), foo.a(), 3);
@@ -16458,6 +17253,10 @@ var $;
16458
17253
  'Array of array or object'($) {
16459
17254
  const _foo = $mol_view_tree2_to_js_test_ex_array_of_array_or_object_foo;
16460
17255
  const foo = _foo.make({ $ });
17256
+ // type a1 = $mol_type_assert<
17257
+ // ReturnType<typeof foo.complex>,
17258
+ // readonly (readonly(number | string)[] | Record<string, number | string>)[]
17259
+ // >
16461
17260
  $mol_assert_like(foo.complex(), ['1', [true], ['1', 21], { a: 1, str: 'some' }]);
16462
17261
  },
16463
17262
  'Array inheritance'($) {
@@ -16549,7 +17348,9 @@ var $;
16549
17348
  'simple mutable and read only channels'($) {
16550
17349
  const _foo = $mol_view_tree2_to_js_test_ex_simple_mutable_and_read_only_foo;
16551
17350
  const foo = _foo.make({ $ });
16552
- $mol_assert_equal(foo.readonly(), foo.readonly(1), foo.readonly(), null);
17351
+ $mol_assert_equal(foo.readonly(),
17352
+ // @ts-ignore
17353
+ foo.readonly(1), foo.readonly(), null);
16553
17354
  $mol_assert_equal(foo.mutable(), null);
16554
17355
  $mol_assert_equal(foo.mutable(2), foo.mutable(), 2);
16555
17356
  },