mol_jsx_lib 0.0.41 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/node.js CHANGED
@@ -46,6 +46,8 @@ var $node = new Proxy({ require }, {
46
46
  const mod = target.require('module');
47
47
  if (mod.builtinModules.indexOf(name) >= 0)
48
48
  return target.require(name);
49
+ if (name[0] === '.')
50
+ return target.require(name);
49
51
  const path = target.require('path');
50
52
  const fs = target.require('fs');
51
53
  let dir = path.resolve('.');
@@ -603,29 +605,72 @@ var $;
603
605
  ;
604
606
  "use strict";
605
607
  var $;
608
+ (function ($) {
609
+ class $mol_term_color {
610
+ static reset = this.ansi(0, 0);
611
+ static bold = this.ansi(1, 22);
612
+ static italic = this.ansi(3, 23);
613
+ static underline = this.ansi(4, 24);
614
+ static inverse = this.ansi(7, 27);
615
+ static hidden = this.ansi(8, 28);
616
+ static strike = this.ansi(9, 29);
617
+ static gray = this.ansi(90, 39);
618
+ static red = this.ansi(91, 39);
619
+ static green = this.ansi(92, 39);
620
+ static yellow = this.ansi(93, 39);
621
+ static blue = this.ansi(94, 39);
622
+ static magenta = this.ansi(95, 39);
623
+ static cyan = this.ansi(96, 39);
624
+ static white = this.ansi(97, 39);
625
+ static Red = (str) => this.inverse(this.red(str));
626
+ static Green = (str) => this.inverse(this.green(str));
627
+ static Yellow = (str) => this.inverse(this.yellow(str));
628
+ static Blue = (str) => this.inverse(this.blue(str));
629
+ static Magenta = (str) => this.inverse(this.magenta(str));
630
+ static Cyan = (str) => this.inverse(this.cyan(str));
631
+ static White = (str) => this.inverse(this.white(str));
632
+ static ansi(open, close) {
633
+ if (typeof process === 'undefined')
634
+ return String;
635
+ if (!process.stdout.isTTY)
636
+ return String;
637
+ const prefix = `\x1b[${open}m`;
638
+ const postfix = `\x1b[${close}m`;
639
+ const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
640
+ return function colorer(str) {
641
+ str = String(str);
642
+ if (str === '')
643
+ return str;
644
+ const suffix = str.replace(suffix_regexp, prefix);
645
+ return prefix + suffix + postfix;
646
+ };
647
+ }
648
+ }
649
+ $.$mol_term_color = $mol_term_color;
650
+ })($ || ($ = {}));
651
+ //mol/term/color/color.ts
652
+ ;
653
+ "use strict";
654
+ var $;
606
655
  (function ($) {
607
656
  function $mol_log3_node_make(level, output, type, color) {
608
657
  return function $mol_log3_logger(event) {
609
658
  if (!event.time)
610
659
  event = { time: new Date().toISOString(), ...event };
611
660
  const tree = this.$mol_tree.fromJSON(event).clone({ type });
612
- let str = tree.toString();
613
- if (process[output].isTTY) {
614
- str = $node.colorette[color + 'Bright'](str);
615
- }
616
- ;
661
+ let str = color(tree.toString());
617
662
  this.console[level](str);
618
663
  const self = this;
619
664
  return () => self.console.groupEnd();
620
665
  };
621
666
  }
622
667
  $.$mol_log3_node_make = $mol_log3_node_make;
623
- $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
624
- $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
625
- $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
626
- $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
627
- $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
628
- $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
668
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
669
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
670
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
671
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
672
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
673
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
629
674
  })($ || ($ = {}));
630
675
  //mol/log3/log3.node.ts
631
676
  ;
@@ -893,7 +938,7 @@ var $;
893
938
  promote() {
894
939
  $mol_wire_auto()?.track_next(this);
895
940
  }
896
- refresh() { }
941
+ fresh() { }
897
942
  complete() { }
898
943
  emit(quant = $mol_wire_cursor.stale) {
899
944
  for (let i = this.sub_from; i < this.data.length; i += 2) {
@@ -1096,7 +1141,7 @@ var $;
1096
1141
  }
1097
1142
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
1098
1143
  const pub = this.data[cursor];
1099
- pub.refresh();
1144
+ pub.fresh();
1100
1145
  }
1101
1146
  this.cursor = $mol_wire_cursor.fresh;
1102
1147
  }
@@ -1226,10 +1271,13 @@ var $;
1226
1271
  }
1227
1272
  static sync() {
1228
1273
  while (this.planning.size) {
1229
- const fibers = this.planning;
1230
- this.planning = new Set;
1231
- for (const fiber of fibers) {
1232
- fiber.refresh();
1274
+ for (const fiber of this.planning) {
1275
+ this.planning.delete(fiber);
1276
+ if (fiber.cursor >= 0)
1277
+ continue;
1278
+ if (fiber.cursor === $mol_wire_cursor.final)
1279
+ continue;
1280
+ fiber.fresh();
1233
1281
  }
1234
1282
  }
1235
1283
  while (this.reaping.size) {
@@ -1256,12 +1304,13 @@ var $;
1256
1304
  field() {
1257
1305
  return this.task.name + '()';
1258
1306
  }
1259
- constructor(id, task, host, ...args) {
1307
+ constructor(id, task, host, args) {
1260
1308
  super();
1261
1309
  this.task = task;
1262
1310
  this.host = host;
1263
- this.data.push(...args);
1264
- this.pub_from = this.sub_from = args.length;
1311
+ if (args)
1312
+ this.data.push(...args);
1313
+ this.pub_from = this.sub_from = args?.length ?? 0;
1265
1314
  this[Symbol.toStringTag] = id;
1266
1315
  }
1267
1316
  plan() {
@@ -1296,7 +1345,7 @@ var $;
1296
1345
  else
1297
1346
  super.emit(quant);
1298
1347
  }
1299
- refresh() {
1348
+ fresh() {
1300
1349
  if (this.cursor === $mol_wire_cursor.fresh)
1301
1350
  return;
1302
1351
  if (this.cursor === $mol_wire_cursor.final)
@@ -1304,7 +1353,7 @@ var $;
1304
1353
  check: if (this.cursor === $mol_wire_cursor.doubt) {
1305
1354
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
1306
1355
  ;
1307
- this.data[i]?.refresh();
1356
+ this.data[i]?.fresh();
1308
1357
  if (this.cursor !== $mol_wire_cursor.doubt)
1309
1358
  break check;
1310
1359
  }
@@ -1322,7 +1371,7 @@ var $;
1322
1371
  result = this.task.call(this.host, this.data[0]);
1323
1372
  break;
1324
1373
  default:
1325
- result = this.task.call(this.host, ...this.data.slice(0, this.pub_from));
1374
+ result = this.task.call(this.host, ...this.args);
1326
1375
  break;
1327
1376
  }
1328
1377
  if (result instanceof Promise) {
@@ -1360,12 +1409,16 @@ var $;
1360
1409
  this.track_off(bu);
1361
1410
  this.put(result);
1362
1411
  }
1412
+ refresh() {
1413
+ this.cursor = $mol_wire_cursor.stale;
1414
+ this.fresh();
1415
+ }
1363
1416
  sync() {
1364
1417
  if (!$mol_wire_fiber.warm) {
1365
1418
  return this.result();
1366
1419
  }
1367
1420
  this.promote();
1368
- this.refresh();
1421
+ this.fresh();
1369
1422
  if (this.cache instanceof Error) {
1370
1423
  return $mol_fail_hidden(this.cache);
1371
1424
  }
@@ -1376,7 +1429,7 @@ var $;
1376
1429
  }
1377
1430
  async async() {
1378
1431
  while (true) {
1379
- this.refresh();
1432
+ this.fresh();
1380
1433
  if (this.cache instanceof Error) {
1381
1434
  $mol_fail_hidden(this.cache);
1382
1435
  }
@@ -1588,7 +1641,7 @@ var $;
1588
1641
  break reuse;
1589
1642
  return existen;
1590
1643
  }
1591
- return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
1644
+ return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
1592
1645
  };
1593
1646
  }
1594
1647
  complete() {
@@ -1661,7 +1714,7 @@ var $;
1661
1714
  else {
1662
1715
  dict = (host ?? task)[field] = new Map();
1663
1716
  }
1664
- fiber = new $mol_wire_atom(key, task, host, ...args);
1717
+ fiber = new $mol_wire_atom(key, task, host, args);
1665
1718
  dict.set(key, fiber);
1666
1719
  return fiber;
1667
1720
  };
@@ -1672,13 +1725,29 @@ var $;
1672
1725
  if (existen)
1673
1726
  return existen;
1674
1727
  const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
1675
- const fiber = new $mol_wire_atom(key, task, host, ...args);
1728
+ const fiber = new $mol_wire_atom(key, task, host, args);
1676
1729
  (host ?? task)[field] = fiber;
1677
1730
  return fiber;
1678
1731
  };
1679
1732
  }
1680
1733
  }
1681
- resync(...args) {
1734
+ static watching = new Set();
1735
+ static watch() {
1736
+ new $mol_after_frame($mol_wire_atom.watch);
1737
+ for (const atom of $mol_wire_atom.watching) {
1738
+ if (atom.cursor === $mol_wire_cursor.final) {
1739
+ $mol_wire_atom.watching.delete(atom);
1740
+ }
1741
+ else {
1742
+ atom.cursor = $mol_wire_cursor.stale;
1743
+ atom.fresh();
1744
+ }
1745
+ }
1746
+ }
1747
+ watch() {
1748
+ $mol_wire_atom.watching.add(this);
1749
+ }
1750
+ resync(args) {
1682
1751
  return this.put(this.task.call(this.host, ...args));
1683
1752
  }
1684
1753
  once() {
@@ -1732,6 +1801,7 @@ var $;
1732
1801
  $mol_wire_method
1733
1802
  ], $mol_wire_atom.prototype, "once", null);
1734
1803
  $.$mol_wire_atom = $mol_wire_atom;
1804
+ $mol_wire_atom.watch();
1735
1805
  })($ || ($ = {}));
1736
1806
  //mol/wire/atom/atom.ts
1737
1807
  ;
@@ -1764,7 +1834,7 @@ var $;
1764
1834
  let atom = persist(this, args.slice(0, keys));
1765
1835
  if (args.length <= keys || args[keys] === undefined) {
1766
1836
  if (!$mol_wire_fiber.warm)
1767
- return atom.sync();
1837
+ return atom.result();
1768
1838
  if ($mol_wire_auto() instanceof $mol_wire_task) {
1769
1839
  return atom.once();
1770
1840
  }
@@ -1772,7 +1842,7 @@ var $;
1772
1842
  return atom.sync();
1773
1843
  }
1774
1844
  }
1775
- return atom.resync(...args);
1845
+ return atom.resync(args);
1776
1846
  };
1777
1847
  Object.defineProperty(wrapper, 'name', { value: func.name + ' ' });
1778
1848
  Object.assign(wrapper, { orig: func });