mol_plot_all 1.2.244 → 1.2.247

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
@@ -240,6 +240,8 @@ var $node = new Proxy({ require }, {
240
240
  const mod = target.require('module');
241
241
  if (mod.builtinModules.indexOf(name) >= 0)
242
242
  return target.require(name);
243
+ if (name[0] === '.')
244
+ return target.require(name);
243
245
  const path = target.require('path');
244
246
  const fs = target.require('fs');
245
247
  let dir = path.resolve('.');
@@ -627,29 +629,72 @@ var $;
627
629
  ;
628
630
  "use strict";
629
631
  var $;
632
+ (function ($) {
633
+ class $mol_term_color {
634
+ static reset = this.ansi(0, 0);
635
+ static bold = this.ansi(1, 22);
636
+ static italic = this.ansi(3, 23);
637
+ static underline = this.ansi(4, 24);
638
+ static inverse = this.ansi(7, 27);
639
+ static hidden = this.ansi(8, 28);
640
+ static strike = this.ansi(9, 29);
641
+ static gray = this.ansi(90, 39);
642
+ static red = this.ansi(91, 39);
643
+ static green = this.ansi(92, 39);
644
+ static yellow = this.ansi(93, 39);
645
+ static blue = this.ansi(94, 39);
646
+ static magenta = this.ansi(95, 39);
647
+ static cyan = this.ansi(96, 39);
648
+ static white = this.ansi(97, 39);
649
+ static Red = (str) => this.inverse(this.red(str));
650
+ static Green = (str) => this.inverse(this.green(str));
651
+ static Yellow = (str) => this.inverse(this.yellow(str));
652
+ static Blue = (str) => this.inverse(this.blue(str));
653
+ static Magenta = (str) => this.inverse(this.magenta(str));
654
+ static Cyan = (str) => this.inverse(this.cyan(str));
655
+ static White = (str) => this.inverse(this.white(str));
656
+ static ansi(open, close) {
657
+ if (typeof process === 'undefined')
658
+ return String;
659
+ if (!process.stdout.isTTY)
660
+ return String;
661
+ const prefix = `\x1b[${open}m`;
662
+ const postfix = `\x1b[${close}m`;
663
+ const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
664
+ return function colorer(str) {
665
+ str = String(str);
666
+ if (str === '')
667
+ return str;
668
+ const suffix = str.replace(suffix_regexp, prefix);
669
+ return prefix + suffix + postfix;
670
+ };
671
+ }
672
+ }
673
+ $.$mol_term_color = $mol_term_color;
674
+ })($ || ($ = {}));
675
+ //mol/term/color/color.ts
676
+ ;
677
+ "use strict";
678
+ var $;
630
679
  (function ($) {
631
680
  function $mol_log3_node_make(level, output, type, color) {
632
681
  return function $mol_log3_logger(event) {
633
682
  if (!event.time)
634
683
  event = { time: new Date().toISOString(), ...event };
635
684
  const tree = this.$mol_tree.fromJSON(event).clone({ type });
636
- let str = tree.toString();
637
- if (process[output].isTTY) {
638
- str = $node.colorette[color + 'Bright'](str);
639
- }
640
- ;
685
+ let str = color(tree.toString());
641
686
  this.console[level](str);
642
687
  const self = this;
643
688
  return () => self.console.groupEnd();
644
689
  };
645
690
  }
646
691
  $.$mol_log3_node_make = $mol_log3_node_make;
647
- $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
648
- $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
649
- $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
650
- $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
651
- $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
652
- $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
692
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
693
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
694
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
695
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
696
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
697
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
653
698
  })($ || ($ = {}));
654
699
  //mol/log3/log3.node.ts
655
700
  ;
@@ -953,7 +998,7 @@ var $;
953
998
  promote() {
954
999
  $mol_wire_auto()?.track_next(this);
955
1000
  }
956
- refresh() { }
1001
+ fresh() { }
957
1002
  complete() { }
958
1003
  emit(quant = $mol_wire_cursor.stale) {
959
1004
  for (let i = this.sub_from; i < this.data.length; i += 2) {
@@ -1156,7 +1201,7 @@ var $;
1156
1201
  }
1157
1202
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
1158
1203
  const pub = this.data[cursor];
1159
- pub.refresh();
1204
+ pub.fresh();
1160
1205
  }
1161
1206
  this.cursor = $mol_wire_cursor.fresh;
1162
1207
  }
@@ -1292,7 +1337,7 @@ var $;
1292
1337
  continue;
1293
1338
  if (fiber.cursor === $mol_wire_cursor.final)
1294
1339
  continue;
1295
- fiber.refresh();
1340
+ fiber.fresh();
1296
1341
  }
1297
1342
  }
1298
1343
  while (this.reaping.size) {
@@ -1360,7 +1405,7 @@ var $;
1360
1405
  else
1361
1406
  super.emit(quant);
1362
1407
  }
1363
- refresh() {
1408
+ fresh() {
1364
1409
  if (this.cursor === $mol_wire_cursor.fresh)
1365
1410
  return;
1366
1411
  if (this.cursor === $mol_wire_cursor.final)
@@ -1368,7 +1413,7 @@ var $;
1368
1413
  check: if (this.cursor === $mol_wire_cursor.doubt) {
1369
1414
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
1370
1415
  ;
1371
- this.data[i]?.refresh();
1416
+ this.data[i]?.fresh();
1372
1417
  if (this.cursor !== $mol_wire_cursor.doubt)
1373
1418
  break check;
1374
1419
  }
@@ -1424,12 +1469,16 @@ var $;
1424
1469
  this.track_off(bu);
1425
1470
  this.put(result);
1426
1471
  }
1472
+ refresh() {
1473
+ this.cursor = $mol_wire_cursor.stale;
1474
+ this.fresh();
1475
+ }
1427
1476
  sync() {
1428
1477
  if (!$mol_wire_fiber.warm) {
1429
1478
  return this.result();
1430
1479
  }
1431
1480
  this.promote();
1432
- this.refresh();
1481
+ this.fresh();
1433
1482
  if (this.cache instanceof Error) {
1434
1483
  return $mol_fail_hidden(this.cache);
1435
1484
  }
@@ -1440,7 +1489,7 @@ var $;
1440
1489
  }
1441
1490
  async async() {
1442
1491
  while (true) {
1443
- this.refresh();
1492
+ this.fresh();
1444
1493
  if (this.cache instanceof Error) {
1445
1494
  $mol_fail_hidden(this.cache);
1446
1495
  }
@@ -1742,6 +1791,22 @@ var $;
1742
1791
  };
1743
1792
  }
1744
1793
  }
1794
+ static watching = new Set();
1795
+ static watch() {
1796
+ new $mol_after_frame($mol_wire_atom.watch);
1797
+ for (const atom of $mol_wire_atom.watching) {
1798
+ if (atom.cursor === $mol_wire_cursor.final) {
1799
+ $mol_wire_atom.watching.delete(atom);
1800
+ }
1801
+ else {
1802
+ atom.cursor = $mol_wire_cursor.stale;
1803
+ atom.fresh();
1804
+ }
1805
+ }
1806
+ }
1807
+ watch() {
1808
+ $mol_wire_atom.watching.add(this);
1809
+ }
1745
1810
  resync(args) {
1746
1811
  return this.put(this.task.call(this.host, ...args));
1747
1812
  }
@@ -1796,6 +1861,7 @@ var $;
1796
1861
  $mol_wire_method
1797
1862
  ], $mol_wire_atom.prototype, "once", null);
1798
1863
  $.$mol_wire_atom = $mol_wire_atom;
1864
+ $mol_wire_atom.watch();
1799
1865
  })($ || ($ = {}));
1800
1866
  //mol/wire/atom/atom.ts
1801
1867
  ;
@@ -1985,6 +2051,22 @@ var $;
1985
2051
  ;
1986
2052
  "use strict";
1987
2053
  var $;
2054
+ (function ($) {
2055
+ function $mol_wire_watch() {
2056
+ const atom = $mol_wire_auto();
2057
+ if (atom instanceof $mol_wire_atom) {
2058
+ atom.watch();
2059
+ }
2060
+ else {
2061
+ $mol_fail(new Error('Atom is equired for watching'));
2062
+ }
2063
+ }
2064
+ $.$mol_wire_watch = $mol_wire_watch;
2065
+ })($ || ($ = {}));
2066
+ //mol/wire/watch/watch.ts
2067
+ ;
2068
+ "use strict";
2069
+ var $;
1988
2070
  (function ($) {
1989
2071
  function $mol_const(value) {
1990
2072
  var getter = (() => value);
@@ -2035,7 +2117,12 @@ var $;
2035
2117
  fiber = temp(obj, args);
2036
2118
  return fiber.async();
2037
2119
  };
2038
- }
2120
+ },
2121
+ apply(obj, self, args) {
2122
+ const temp = $mol_wire_task.getter(obj);
2123
+ const fiber = temp(self, args);
2124
+ return fiber.async();
2125
+ },
2039
2126
  });
2040
2127
  }
2041
2128
  $.$mol_wire_async = $mol_wire_async;
@@ -2274,15 +2361,9 @@ var $;
2274
2361
  }
2275
2362
  static watchers = new Set();
2276
2363
  view_rect() {
2277
- this.view_rect_watcher();
2278
- return this.view_rect_cache();
2279
- }
2280
- view_rect_cache(next = null) {
2281
- return next;
2282
- }
2283
- view_rect_watcher() {
2284
- $mol_view.watchers.add(this);
2285
- return { destructor: () => $mol_view.watchers.delete(this) };
2364
+ $mol_wire_watch();
2365
+ const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect();
2366
+ return { width, height, left, right, top, bottom };
2286
2367
  }
2287
2368
  dom_id() {
2288
2369
  return this.toString();
@@ -2454,11 +2535,18 @@ var $;
2454
2535
  *view_find(check, path = []) {
2455
2536
  if (check(this))
2456
2537
  return yield [...path, this];
2457
- for (const item of this.sub()) {
2458
- if (item instanceof $mol_view) {
2459
- yield* item.view_find(check, [...path, this]);
2538
+ try {
2539
+ for (const item of this.sub()) {
2540
+ if (item instanceof $mol_view) {
2541
+ yield* item.view_find(check, [...path, this]);
2542
+ }
2460
2543
  }
2461
2544
  }
2545
+ catch (error) {
2546
+ if (error instanceof Promise)
2547
+ $mol_fail_hidden(error);
2548
+ $mol_fail_log(error);
2549
+ }
2462
2550
  }
2463
2551
  force_render(path) {
2464
2552
  const kids = this.sub();
@@ -2499,12 +2587,6 @@ var $;
2499
2587
  __decorate([
2500
2588
  $mol_mem
2501
2589
  ], $mol_view.prototype, "view_rect", null);
2502
- __decorate([
2503
- $mol_mem
2504
- ], $mol_view.prototype, "view_rect_cache", null);
2505
- __decorate([
2506
- $mol_mem
2507
- ], $mol_view.prototype, "view_rect_watcher", null);
2508
2590
  __decorate([
2509
2591
  $mol_mem
2510
2592
  ], $mol_view.prototype, "dom_node", null);
@@ -3728,7 +3810,7 @@ var $;
3728
3810
  return this.graphs_sorted();
3729
3811
  }
3730
3812
  graphs_colored() {
3731
- return this.graphs_positioned();
3813
+ return this.graphs_visible();
3732
3814
  }
3733
3815
  plugins() {
3734
3816
  return [
@@ -3782,11 +3864,11 @@ var $;
3782
3864
  graphs() {
3783
3865
  return [];
3784
3866
  }
3785
- graphs_visible() {
3867
+ graphs_positioned() {
3786
3868
  return this.graphs();
3787
3869
  }
3788
- graphs_positioned() {
3789
- return this.graphs_visible();
3870
+ graphs_visible() {
3871
+ return this.graphs_positioned();
3790
3872
  }
3791
3873
  zoom(val) {
3792
3874
  if (val !== undefined)
@@ -3986,7 +4068,7 @@ var $;
3986
4068
  return (360 + (this.hue_base() + this.hue_shift() * index) % 360) % 360;
3987
4069
  }
3988
4070
  graphs_colored() {
3989
- const graphs = this.graphs_positioned();
4071
+ const graphs = this.graphs_visible();
3990
4072
  for (let index = 0; index < graphs.length; index++) {
3991
4073
  graphs[index].hue = () => this.graph_hue(index);
3992
4074
  }
@@ -4069,13 +4151,15 @@ var $;
4069
4151
  const size_real = this.size_real();
4070
4152
  const max_x = (viewport.x.max - viewport.x.min) / size_real.x;
4071
4153
  const max_y = (viewport.y.max - viewport.y.min) / size_real.y;
4072
- return this.graphs().filter(graph => {
4154
+ return this.graphs_positioned().filter(graph => {
4073
4155
  const dims = graph.dimensions();
4074
4156
  if (dims.x.min > dims.x.max)
4075
4157
  return true;
4076
4158
  if (dims.y.min > dims.y.max)
4077
4159
  return true;
4078
- if (dims.x.max - dims.x.min < max_x && dims.y.max - dims.y.min < max_y)
4160
+ const size_x = dims.x.max - dims.x.min;
4161
+ const size_y = dims.y.max - dims.y.min;
4162
+ if ((size_x || size_y) && size_x < max_x && size_y < max_y)
4079
4163
  return false;
4080
4164
  if (dims.x.min > viewport.x.max)
4081
4165
  return false;
@@ -4089,7 +4173,7 @@ var $;
4089
4173
  });
4090
4174
  }
4091
4175
  graphs_positioned() {
4092
- const graphs = this.graphs_visible();
4176
+ const graphs = this.graphs();
4093
4177
  for (let graph of graphs) {
4094
4178
  graph.shift = () => this.shift();
4095
4179
  graph.scale = () => this.scale();
@@ -4537,12 +4621,6 @@ var $;
4537
4621
  const size_x = Math.max(0, Math.ceil((1 / aspect - 1) * diameter));
4538
4622
  return points.map(point => `M ${point[0] - shift_x} ${point[1] - shift_y} l ${size_x} ${size_y}`).join(' ');
4539
4623
  }
4540
- dimensions() {
4541
- const scale = this.scale();
4542
- const radius = this.diameter() / Math.min(...scale) / 2;
4543
- const dims = super.dimensions();
4544
- return new this.$.$mol_vector_2d(new $mol_vector_range(dims.x.min - radius, dims.x.max + radius), new $mol_vector_range(dims.y.min - radius, dims.y.max + radius));
4545
- }
4546
4624
  }
4547
4625
  __decorate([
4548
4626
  $mol_mem
@@ -4550,9 +4628,6 @@ var $;
4550
4628
  __decorate([
4551
4629
  $mol_mem
4552
4630
  ], $mol_plot_dot.prototype, "indexes", null);
4553
- __decorate([
4554
- $mol_mem
4555
- ], $mol_plot_dot.prototype, "dimensions", null);
4556
4631
  $$.$mol_plot_dot = $mol_plot_dot;
4557
4632
  })($$ = $.$$ || ($.$$ = {}));
4558
4633
  })($ || ($ = {}));