mol_jsx_lib 0.0.43 → 0.0.46

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
@@ -38,6 +38,8 @@ var $node = new Proxy({ require }, {
38
38
  const mod = target.require('module');
39
39
  if (mod.builtinModules.indexOf(name) >= 0)
40
40
  return target.require(name);
41
+ if (name[0] === '.')
42
+ return target.require(name);
41
43
  const path = target.require('path');
42
44
  const fs = target.require('fs');
43
45
  let dir = path.resolve('.');
@@ -595,29 +597,72 @@ var $;
595
597
  ;
596
598
  "use strict";
597
599
  var $;
600
+ (function ($) {
601
+ class $mol_term_color {
602
+ static reset = this.ansi(0, 0);
603
+ static bold = this.ansi(1, 22);
604
+ static italic = this.ansi(3, 23);
605
+ static underline = this.ansi(4, 24);
606
+ static inverse = this.ansi(7, 27);
607
+ static hidden = this.ansi(8, 28);
608
+ static strike = this.ansi(9, 29);
609
+ static gray = this.ansi(90, 39);
610
+ static red = this.ansi(91, 39);
611
+ static green = this.ansi(92, 39);
612
+ static yellow = this.ansi(93, 39);
613
+ static blue = this.ansi(94, 39);
614
+ static magenta = this.ansi(95, 39);
615
+ static cyan = this.ansi(96, 39);
616
+ static white = this.ansi(97, 39);
617
+ static Red = (str) => this.inverse(this.red(str));
618
+ static Green = (str) => this.inverse(this.green(str));
619
+ static Yellow = (str) => this.inverse(this.yellow(str));
620
+ static Blue = (str) => this.inverse(this.blue(str));
621
+ static Magenta = (str) => this.inverse(this.magenta(str));
622
+ static Cyan = (str) => this.inverse(this.cyan(str));
623
+ static White = (str) => this.inverse(this.white(str));
624
+ static ansi(open, close) {
625
+ if (typeof process === 'undefined')
626
+ return String;
627
+ if (!process.stdout.isTTY)
628
+ return String;
629
+ const prefix = `\x1b[${open}m`;
630
+ const postfix = `\x1b[${close}m`;
631
+ const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
632
+ return function colorer(str) {
633
+ str = String(str);
634
+ if (str === '')
635
+ return str;
636
+ const suffix = str.replace(suffix_regexp, prefix);
637
+ return prefix + suffix + postfix;
638
+ };
639
+ }
640
+ }
641
+ $.$mol_term_color = $mol_term_color;
642
+ })($ || ($ = {}));
643
+ //mol/term/color/color.ts
644
+ ;
645
+ "use strict";
646
+ var $;
598
647
  (function ($) {
599
648
  function $mol_log3_node_make(level, output, type, color) {
600
649
  return function $mol_log3_logger(event) {
601
650
  if (!event.time)
602
651
  event = { time: new Date().toISOString(), ...event };
603
652
  const tree = this.$mol_tree.fromJSON(event).clone({ type });
604
- let str = tree.toString();
605
- if (process[output].isTTY) {
606
- str = $node.colorette[color + 'Bright'](str);
607
- }
608
- ;
653
+ let str = color(tree.toString());
609
654
  this.console[level](str);
610
655
  const self = this;
611
656
  return () => self.console.groupEnd();
612
657
  };
613
658
  }
614
659
  $.$mol_log3_node_make = $mol_log3_node_make;
615
- $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
616
- $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
617
- $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
618
- $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
619
- $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
620
- $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
660
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
661
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
662
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
663
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
664
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
665
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
621
666
  })($ || ($ = {}));
622
667
  //mol/log3/log3.node.ts
623
668
  ;
@@ -885,7 +930,7 @@ var $;
885
930
  promote() {
886
931
  $mol_wire_auto()?.track_next(this);
887
932
  }
888
- refresh() { }
933
+ fresh() { }
889
934
  complete() { }
890
935
  emit(quant = $mol_wire_cursor.stale) {
891
936
  for (let i = this.sub_from; i < this.data.length; i += 2) {
@@ -1088,7 +1133,7 @@ var $;
1088
1133
  }
1089
1134
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
1090
1135
  const pub = this.data[cursor];
1091
- pub.refresh();
1136
+ pub.fresh();
1092
1137
  }
1093
1138
  this.cursor = $mol_wire_cursor.fresh;
1094
1139
  }
@@ -1224,7 +1269,7 @@ var $;
1224
1269
  continue;
1225
1270
  if (fiber.cursor === $mol_wire_cursor.final)
1226
1271
  continue;
1227
- fiber.refresh();
1272
+ fiber.fresh();
1228
1273
  }
1229
1274
  }
1230
1275
  while (this.reaping.size) {
@@ -1292,7 +1337,7 @@ var $;
1292
1337
  else
1293
1338
  super.emit(quant);
1294
1339
  }
1295
- refresh() {
1340
+ fresh() {
1296
1341
  if (this.cursor === $mol_wire_cursor.fresh)
1297
1342
  return;
1298
1343
  if (this.cursor === $mol_wire_cursor.final)
@@ -1300,7 +1345,7 @@ var $;
1300
1345
  check: if (this.cursor === $mol_wire_cursor.doubt) {
1301
1346
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
1302
1347
  ;
1303
- this.data[i]?.refresh();
1348
+ this.data[i]?.fresh();
1304
1349
  if (this.cursor !== $mol_wire_cursor.doubt)
1305
1350
  break check;
1306
1351
  }
@@ -1356,12 +1401,16 @@ var $;
1356
1401
  this.track_off(bu);
1357
1402
  this.put(result);
1358
1403
  }
1404
+ refresh() {
1405
+ this.cursor = $mol_wire_cursor.stale;
1406
+ this.fresh();
1407
+ }
1359
1408
  sync() {
1360
1409
  if (!$mol_wire_fiber.warm) {
1361
1410
  return this.result();
1362
1411
  }
1363
1412
  this.promote();
1364
- this.refresh();
1413
+ this.fresh();
1365
1414
  if (this.cache instanceof Error) {
1366
1415
  return $mol_fail_hidden(this.cache);
1367
1416
  }
@@ -1372,7 +1421,7 @@ var $;
1372
1421
  }
1373
1422
  async async() {
1374
1423
  while (true) {
1375
- this.refresh();
1424
+ this.fresh();
1376
1425
  if (this.cache instanceof Error) {
1377
1426
  $mol_fail_hidden(this.cache);
1378
1427
  }
@@ -1470,6 +1519,8 @@ var $;
1470
1519
  return Object.is(left.valueOf(), right['valueOf']());
1471
1520
  if (left instanceof RegExp)
1472
1521
  return left.source === right['source'] && left.flags === right['flags'];
1522
+ if (left instanceof Error)
1523
+ return left.stack === right['stack'];
1473
1524
  let left_cache = $.$mol_compare_deep_cache.get(left);
1474
1525
  if (left_cache) {
1475
1526
  const right_cache = left_cache.get(right);
@@ -1490,8 +1541,6 @@ var $;
1490
1541
  result = compare_set(left, right);
1491
1542
  else if (left instanceof Map)
1492
1543
  result = compare_map(left, right);
1493
- else if (left instanceof Error)
1494
- result = left.stack === right.stack;
1495
1544
  else if (ArrayBuffer.isView(left))
1496
1545
  result = compare_buffer(left, right);
1497
1546
  else if (Symbol.toPrimitive in left)
@@ -1588,8 +1637,7 @@ var $;
1588
1637
  };
1589
1638
  }
1590
1639
  complete() {
1591
- if (this.sub_empty)
1592
- this.destructor();
1640
+ this.destructor();
1593
1641
  }
1594
1642
  put(next) {
1595
1643
  const prev = this.cache;
@@ -1674,6 +1722,22 @@ var $;
1674
1722
  };
1675
1723
  }
1676
1724
  }
1725
+ static watching = new Set();
1726
+ static watch() {
1727
+ new $mol_after_frame($mol_wire_atom.watch);
1728
+ for (const atom of $mol_wire_atom.watching) {
1729
+ if (atom.cursor === $mol_wire_cursor.final) {
1730
+ $mol_wire_atom.watching.delete(atom);
1731
+ }
1732
+ else {
1733
+ atom.cursor = $mol_wire_cursor.stale;
1734
+ atom.fresh();
1735
+ }
1736
+ }
1737
+ }
1738
+ watch() {
1739
+ $mol_wire_atom.watching.add(this);
1740
+ }
1677
1741
  resync(args) {
1678
1742
  return this.put(this.task.call(this.host, ...args));
1679
1743
  }
@@ -1728,6 +1792,7 @@ var $;
1728
1792
  $mol_wire_method
1729
1793
  ], $mol_wire_atom.prototype, "once", null);
1730
1794
  $.$mol_wire_atom = $mol_wire_atom;
1795
+ $mol_wire_atom.watch();
1731
1796
  })($ || ($ = {}));
1732
1797
  //mol/wire/atom/atom.ts
1733
1798
  ;
@@ -1938,6 +2003,20 @@ var $;
1938
2003
  ;
1939
2004
  "use strict";
1940
2005
  var $;
2006
+ (function ($_1) {
2007
+ $mol_test_mocks.push($ => {
2008
+ $.$mol_log3_come = () => { };
2009
+ $.$mol_log3_done = () => { };
2010
+ $.$mol_log3_fail = () => { };
2011
+ $.$mol_log3_warn = () => { };
2012
+ $.$mol_log3_rise = () => { };
2013
+ $.$mol_log3_area = () => () => { };
2014
+ });
2015
+ })($ || ($ = {}));
2016
+ //mol/log3/log3.test.ts
2017
+ ;
2018
+ "use strict";
2019
+ var $;
1941
2020
  (function ($) {
1942
2021
  function $mol_dom_serialize(node) {
1943
2022
  const serializer = new $mol_dom_context.XMLSerializer;
@@ -2093,20 +2172,6 @@ var $;
2093
2172
  ;
2094
2173
  "use strict";
2095
2174
  var $;
2096
- (function ($_1) {
2097
- $mol_test_mocks.push($ => {
2098
- $.$mol_log3_come = () => { };
2099
- $.$mol_log3_done = () => { };
2100
- $.$mol_log3_fail = () => { };
2101
- $.$mol_log3_warn = () => { };
2102
- $.$mol_log3_rise = () => { };
2103
- $.$mol_log3_area = () => () => { };
2104
- });
2105
- })($ || ($ = {}));
2106
- //mol/log3/log3.test.ts
2107
- ;
2108
- "use strict";
2109
- var $;
2110
2175
  (function ($) {
2111
2176
  $mol_test({
2112
2177
  'get'() {
@@ -2327,6 +2392,25 @@ var $;
2327
2392
  ;
2328
2393
  "use strict";
2329
2394
  var $;
2395
+ (function ($) {
2396
+ function $mol_promise() {
2397
+ let done;
2398
+ let fail;
2399
+ const promise = new Promise((d, f) => {
2400
+ done = d;
2401
+ fail = f;
2402
+ });
2403
+ return Object.assign(promise, {
2404
+ done,
2405
+ fail,
2406
+ });
2407
+ }
2408
+ $.$mol_promise = $mol_promise;
2409
+ })($ || ($ = {}));
2410
+ //mol/promise/promise.ts
2411
+ ;
2412
+ "use strict";
2413
+ var $;
2330
2414
  (function ($) {
2331
2415
  $.$mol_after_mock_queue = [];
2332
2416
  function $mol_after_mock_warp() {
@@ -2365,6 +2449,59 @@ var $;
2365
2449
  ;
2366
2450
  "use strict";
2367
2451
  var $;
2452
+ (function ($_1) {
2453
+ $mol_test_mocks.push($ => {
2454
+ $.$mol_after_timeout = $mol_after_mock_timeout;
2455
+ });
2456
+ })($ || ($ = {}));
2457
+ //mol/after/timeout/timeout.test.ts
2458
+ ;
2459
+ "use strict";
2460
+ var $;
2461
+ (function ($) {
2462
+ function $mol_wire_sync(obj) {
2463
+ return new Proxy(obj, {
2464
+ get(obj, field) {
2465
+ const val = obj[field];
2466
+ if (typeof val !== 'function')
2467
+ return val;
2468
+ const temp = $mol_wire_task.getter(val);
2469
+ return function $mol_wire_sync(...args) {
2470
+ const fiber = temp(obj, args);
2471
+ return fiber.sync();
2472
+ };
2473
+ },
2474
+ apply(obj, self, args) {
2475
+ const temp = $mol_wire_task.getter(obj);
2476
+ const fiber = temp(self, args);
2477
+ return fiber.sync();
2478
+ },
2479
+ });
2480
+ }
2481
+ $.$mol_wire_sync = $mol_wire_sync;
2482
+ })($ || ($ = {}));
2483
+ //mol/wire/sync/sync.ts
2484
+ ;
2485
+ "use strict";
2486
+ var $;
2487
+ (function ($) {
2488
+ function $mol_wait_timeout_async(timeout) {
2489
+ const promise = $mol_promise();
2490
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
2491
+ return Object.assign(promise, {
2492
+ destructor: () => task.destructor()
2493
+ });
2494
+ }
2495
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
2496
+ function $mol_wait_timeout(timeout) {
2497
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
2498
+ }
2499
+ $.$mol_wait_timeout = $mol_wait_timeout;
2500
+ })($ || ($ = {}));
2501
+ //mol/wait/timeout/timeout.ts
2502
+ ;
2503
+ "use strict";
2504
+ var $;
2368
2505
  (function ($_1) {
2369
2506
  $mol_test({
2370
2507
  async 'Latest Calls Wins on Concurrency'($) {
@@ -2386,6 +2523,15 @@ var $;
2386
2523
  $mol_assert_like(NameLogger.first, ['john', 'jin']);
2387
2524
  $mol_assert_like(NameLogger.last, ['jin']);
2388
2525
  },
2526
+ async 'Wrap function'($) {
2527
+ const name = $mol_wire_async(function (name) {
2528
+ $.$mol_wait_timeout(0);
2529
+ return name;
2530
+ });
2531
+ const promise = name('jin');
2532
+ $.$mol_after_mock_warp();
2533
+ $mol_assert_like(await promise, 'jin');
2534
+ },
2389
2535
  });
2390
2536
  })($ || ($ = {}));
2391
2537
  //mol/wire/async/async.test.ts
@@ -2406,7 +2552,12 @@ var $;
2406
2552
  fiber = temp(obj, args);
2407
2553
  return fiber.async();
2408
2554
  };
2409
- }
2555
+ },
2556
+ apply(obj, self, args) {
2557
+ const temp = $mol_wire_task.getter(obj);
2558
+ const fiber = temp(self, args);
2559
+ return fiber.async();
2560
+ },
2410
2561
  });
2411
2562
  }
2412
2563
  $.$mol_wire_async = $mol_wire_async;
@@ -2473,15 +2624,6 @@ var $;
2473
2624
  ;
2474
2625
  "use strict";
2475
2626
  var $;
2476
- (function ($_1) {
2477
- $mol_test_mocks.push($ => {
2478
- $.$mol_after_timeout = $mol_after_mock_timeout;
2479
- });
2480
- })($ || ($ = {}));
2481
- //mol/after/timeout/timeout.test.ts
2482
- ;
2483
- "use strict";
2484
- var $;
2485
2627
  (function ($_1) {
2486
2628
  $mol_test_mocks.push($ => {
2487
2629
  $.$mol_after_frame = $mol_after_mock_commmon;
@@ -2668,64 +2810,6 @@ var $;
2668
2810
  ;
2669
2811
  "use strict";
2670
2812
  var $;
2671
- (function ($) {
2672
- function $mol_wire_sync(obj) {
2673
- return new Proxy(obj, {
2674
- get(obj, field) {
2675
- const val = obj[field];
2676
- if (typeof val !== 'function')
2677
- return val;
2678
- const temp = $mol_wire_task.getter(val);
2679
- return function $mol_wire_sync(...args) {
2680
- const fiber = temp(obj, args);
2681
- return fiber.sync();
2682
- };
2683
- }
2684
- });
2685
- }
2686
- $.$mol_wire_sync = $mol_wire_sync;
2687
- })($ || ($ = {}));
2688
- //mol/wire/sync/sync.ts
2689
- ;
2690
- "use strict";
2691
- var $;
2692
- (function ($) {
2693
- function $mol_promise() {
2694
- let done;
2695
- let fail;
2696
- const promise = new Promise((d, f) => {
2697
- done = d;
2698
- fail = f;
2699
- });
2700
- return Object.assign(promise, {
2701
- done,
2702
- fail,
2703
- });
2704
- }
2705
- $.$mol_promise = $mol_promise;
2706
- })($ || ($ = {}));
2707
- //mol/promise/promise.ts
2708
- ;
2709
- "use strict";
2710
- var $;
2711
- (function ($) {
2712
- function $mol_wait_timeout_async(timeout) {
2713
- const promise = $mol_promise();
2714
- const task = new this.$mol_after_timeout(timeout, () => promise.done());
2715
- return Object.assign(promise, {
2716
- destructor: () => task.destructor()
2717
- });
2718
- }
2719
- $.$mol_wait_timeout_async = $mol_wait_timeout_async;
2720
- function $mol_wait_timeout(timeout) {
2721
- return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
2722
- }
2723
- $.$mol_wait_timeout = $mol_wait_timeout;
2724
- })($ || ($ = {}));
2725
- //mol/wait/timeout/timeout.ts
2726
- ;
2727
- "use strict";
2728
- var $;
2729
2813
  (function ($_1) {
2730
2814
  $mol_test({
2731
2815
  'Cached channel'($) {