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/web.js CHANGED
@@ -468,7 +468,7 @@ var $;
468
468
  promote() {
469
469
  $mol_wire_auto()?.track_next(this);
470
470
  }
471
- refresh() { }
471
+ fresh() { }
472
472
  complete() { }
473
473
  emit(quant = $mol_wire_cursor.stale) {
474
474
  for (let i = this.sub_from; i < this.data.length; i += 2) {
@@ -671,7 +671,7 @@ var $;
671
671
  }
672
672
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
673
673
  const pub = this.data[cursor];
674
- pub.refresh();
674
+ pub.fresh();
675
675
  }
676
676
  this.cursor = $mol_wire_cursor.fresh;
677
677
  }
@@ -747,18 +747,20 @@ var $;
747
747
  class $mol_after_frame extends $mol_object2 {
748
748
  task;
749
749
  static _promise = null;
750
- static _timeout = null;
751
750
  static get promise() {
752
751
  if (this._promise)
753
752
  return this._promise;
754
753
  return this._promise = new Promise(done => {
755
754
  const complete = () => {
756
755
  this._promise = null;
757
- clearTimeout(this._timeout);
758
756
  done();
759
757
  };
760
- requestAnimationFrame(complete);
761
- this._timeout = setTimeout(complete, 100);
758
+ if (typeof requestAnimationFrame === 'function') {
759
+ requestAnimationFrame(complete);
760
+ }
761
+ else {
762
+ setTimeout(complete, 16);
763
+ }
762
764
  });
763
765
  }
764
766
  cancelled = false;
@@ -811,7 +813,7 @@ var $;
811
813
  continue;
812
814
  if (fiber.cursor === $mol_wire_cursor.final)
813
815
  continue;
814
- fiber.refresh();
816
+ fiber.fresh();
815
817
  }
816
818
  }
817
819
  while (this.reaping.size) {
@@ -879,7 +881,7 @@ var $;
879
881
  else
880
882
  super.emit(quant);
881
883
  }
882
- refresh() {
884
+ fresh() {
883
885
  if (this.cursor === $mol_wire_cursor.fresh)
884
886
  return;
885
887
  if (this.cursor === $mol_wire_cursor.final)
@@ -887,7 +889,7 @@ var $;
887
889
  check: if (this.cursor === $mol_wire_cursor.doubt) {
888
890
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
889
891
  ;
890
- this.data[i]?.refresh();
892
+ this.data[i]?.fresh();
891
893
  if (this.cursor !== $mol_wire_cursor.doubt)
892
894
  break check;
893
895
  }
@@ -943,12 +945,16 @@ var $;
943
945
  this.track_off(bu);
944
946
  this.put(result);
945
947
  }
948
+ refresh() {
949
+ this.cursor = $mol_wire_cursor.stale;
950
+ this.fresh();
951
+ }
946
952
  sync() {
947
953
  if (!$mol_wire_fiber.warm) {
948
954
  return this.result();
949
955
  }
950
956
  this.promote();
951
- this.refresh();
957
+ this.fresh();
952
958
  if (this.cache instanceof Error) {
953
959
  return $mol_fail_hidden(this.cache);
954
960
  }
@@ -959,7 +965,7 @@ var $;
959
965
  }
960
966
  async async() {
961
967
  while (true) {
962
- this.refresh();
968
+ this.fresh();
963
969
  if (this.cache instanceof Error) {
964
970
  $mol_fail_hidden(this.cache);
965
971
  }
@@ -1261,6 +1267,22 @@ var $;
1261
1267
  };
1262
1268
  }
1263
1269
  }
1270
+ static watching = new Set();
1271
+ static watch() {
1272
+ new $mol_after_frame($mol_wire_atom.watch);
1273
+ for (const atom of $mol_wire_atom.watching) {
1274
+ if (atom.cursor === $mol_wire_cursor.final) {
1275
+ $mol_wire_atom.watching.delete(atom);
1276
+ }
1277
+ else {
1278
+ atom.cursor = $mol_wire_cursor.stale;
1279
+ atom.fresh();
1280
+ }
1281
+ }
1282
+ }
1283
+ watch() {
1284
+ $mol_wire_atom.watching.add(this);
1285
+ }
1264
1286
  resync(args) {
1265
1287
  return this.put(this.task.call(this.host, ...args));
1266
1288
  }
@@ -1315,6 +1337,7 @@ var $;
1315
1337
  $mol_wire_method
1316
1338
  ], $mol_wire_atom.prototype, "once", null);
1317
1339
  $.$mol_wire_atom = $mol_wire_atom;
1340
+ $mol_wire_atom.watch();
1318
1341
  })($ || ($ = {}));
1319
1342
  //mol/wire/atom/atom.ts
1320
1343
  ;
@@ -1549,6 +1572,22 @@ var $;
1549
1572
  ;
1550
1573
  "use strict";
1551
1574
  var $;
1575
+ (function ($) {
1576
+ function $mol_wire_watch() {
1577
+ const atom = $mol_wire_auto();
1578
+ if (atom instanceof $mol_wire_atom) {
1579
+ atom.watch();
1580
+ }
1581
+ else {
1582
+ $mol_fail(new Error('Atom is equired for watching'));
1583
+ }
1584
+ }
1585
+ $.$mol_wire_watch = $mol_wire_watch;
1586
+ })($ || ($ = {}));
1587
+ //mol/wire/watch/watch.ts
1588
+ ;
1589
+ "use strict";
1590
+ var $;
1552
1591
  (function ($) {
1553
1592
  function $mol_const(value) {
1554
1593
  var getter = (() => value);
@@ -1599,7 +1638,12 @@ var $;
1599
1638
  fiber = temp(obj, args);
1600
1639
  return fiber.async();
1601
1640
  };
1602
- }
1641
+ },
1642
+ apply(obj, self, args) {
1643
+ const temp = $mol_wire_task.getter(obj);
1644
+ const fiber = temp(self, args);
1645
+ return fiber.async();
1646
+ },
1603
1647
  });
1604
1648
  }
1605
1649
  $.$mol_wire_async = $mol_wire_async;
@@ -1831,15 +1875,9 @@ var $;
1831
1875
  }
1832
1876
  static watchers = new Set();
1833
1877
  view_rect() {
1834
- this.view_rect_watcher();
1835
- return this.view_rect_cache();
1836
- }
1837
- view_rect_cache(next = null) {
1838
- return next;
1839
- }
1840
- view_rect_watcher() {
1841
- $mol_view.watchers.add(this);
1842
- return { destructor: () => $mol_view.watchers.delete(this) };
1878
+ $mol_wire_watch();
1879
+ const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect();
1880
+ return { width, height, left, right, top, bottom };
1843
1881
  }
1844
1882
  dom_id() {
1845
1883
  return this.toString();
@@ -2011,11 +2049,18 @@ var $;
2011
2049
  *view_find(check, path = []) {
2012
2050
  if (check(this))
2013
2051
  return yield [...path, this];
2014
- for (const item of this.sub()) {
2015
- if (item instanceof $mol_view) {
2016
- yield* item.view_find(check, [...path, this]);
2052
+ try {
2053
+ for (const item of this.sub()) {
2054
+ if (item instanceof $mol_view) {
2055
+ yield* item.view_find(check, [...path, this]);
2056
+ }
2017
2057
  }
2018
2058
  }
2059
+ catch (error) {
2060
+ if (error instanceof Promise)
2061
+ $mol_fail_hidden(error);
2062
+ $mol_fail_log(error);
2063
+ }
2019
2064
  }
2020
2065
  force_render(path) {
2021
2066
  const kids = this.sub();
@@ -2056,12 +2101,6 @@ var $;
2056
2101
  __decorate([
2057
2102
  $mol_mem
2058
2103
  ], $mol_view.prototype, "view_rect", null);
2059
- __decorate([
2060
- $mol_mem
2061
- ], $mol_view.prototype, "view_rect_cache", null);
2062
- __decorate([
2063
- $mol_mem
2064
- ], $mol_view.prototype, "view_rect_watcher", null);
2065
2104
  __decorate([
2066
2105
  $mol_mem
2067
2106
  ], $mol_view.prototype, "dom_node", null);
@@ -2108,22 +2147,6 @@ var $;
2108
2147
  (function ($) {
2109
2148
  if ($mol_dom_context.document) {
2110
2149
  setTimeout(() => $mol_view.autobind());
2111
- function $mol_view_watch() {
2112
- new $mol_after_frame($mol_view_watch);
2113
- for (const view of $mol_view.watchers) {
2114
- const prev = view.view_rect_cache();
2115
- const next = view.dom_node().getBoundingClientRect();
2116
- if (next.left === 0 && next.right === 0 && next.width === 0) {
2117
- if (prev)
2118
- view.view_rect_cache(null);
2119
- continue;
2120
- }
2121
- if (!prev || prev.x !== next.x || prev.y !== next.y || prev.width !== next.width || prev.height !== next.height) {
2122
- view.view_rect_cache(next);
2123
- }
2124
- }
2125
- }
2126
- $mol_view_watch();
2127
2150
  }
2128
2151
  })($ || ($ = {}));
2129
2152
  //mol/view/view/view.web.ts
@@ -3338,7 +3361,7 @@ var $;
3338
3361
  return this.graphs_sorted();
3339
3362
  }
3340
3363
  graphs_colored() {
3341
- return this.graphs_positioned();
3364
+ return this.graphs_visible();
3342
3365
  }
3343
3366
  plugins() {
3344
3367
  return [
@@ -3392,11 +3415,11 @@ var $;
3392
3415
  graphs() {
3393
3416
  return [];
3394
3417
  }
3395
- graphs_visible() {
3418
+ graphs_positioned() {
3396
3419
  return this.graphs();
3397
3420
  }
3398
- graphs_positioned() {
3399
- return this.graphs_visible();
3421
+ graphs_visible() {
3422
+ return this.graphs_positioned();
3400
3423
  }
3401
3424
  zoom(val) {
3402
3425
  if (val !== undefined)
@@ -3596,7 +3619,7 @@ var $;
3596
3619
  return (360 + (this.hue_base() + this.hue_shift() * index) % 360) % 360;
3597
3620
  }
3598
3621
  graphs_colored() {
3599
- const graphs = this.graphs_positioned();
3622
+ const graphs = this.graphs_visible();
3600
3623
  for (let index = 0; index < graphs.length; index++) {
3601
3624
  graphs[index].hue = () => this.graph_hue(index);
3602
3625
  }
@@ -3679,13 +3702,15 @@ var $;
3679
3702
  const size_real = this.size_real();
3680
3703
  const max_x = (viewport.x.max - viewport.x.min) / size_real.x;
3681
3704
  const max_y = (viewport.y.max - viewport.y.min) / size_real.y;
3682
- return this.graphs().filter(graph => {
3705
+ return this.graphs_positioned().filter(graph => {
3683
3706
  const dims = graph.dimensions();
3684
3707
  if (dims.x.min > dims.x.max)
3685
3708
  return true;
3686
3709
  if (dims.y.min > dims.y.max)
3687
3710
  return true;
3688
- if (dims.x.max - dims.x.min < max_x && dims.y.max - dims.y.min < max_y)
3711
+ const size_x = dims.x.max - dims.x.min;
3712
+ const size_y = dims.y.max - dims.y.min;
3713
+ if ((size_x || size_y) && size_x < max_x && size_y < max_y)
3689
3714
  return false;
3690
3715
  if (dims.x.min > viewport.x.max)
3691
3716
  return false;
@@ -3699,7 +3724,7 @@ var $;
3699
3724
  });
3700
3725
  }
3701
3726
  graphs_positioned() {
3702
- const graphs = this.graphs_visible();
3727
+ const graphs = this.graphs();
3703
3728
  for (let graph of graphs) {
3704
3729
  graph.shift = () => this.shift();
3705
3730
  graph.scale = () => this.scale();
@@ -4147,12 +4172,6 @@ var $;
4147
4172
  const size_x = Math.max(0, Math.ceil((1 / aspect - 1) * diameter));
4148
4173
  return points.map(point => `M ${point[0] - shift_x} ${point[1] - shift_y} l ${size_x} ${size_y}`).join(' ');
4149
4174
  }
4150
- dimensions() {
4151
- const scale = this.scale();
4152
- const radius = this.diameter() / Math.min(...scale) / 2;
4153
- const dims = super.dimensions();
4154
- 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));
4155
- }
4156
4175
  }
4157
4176
  __decorate([
4158
4177
  $mol_mem
@@ -4160,9 +4179,6 @@ var $;
4160
4179
  __decorate([
4161
4180
  $mol_mem
4162
4181
  ], $mol_plot_dot.prototype, "indexes", null);
4163
- __decorate([
4164
- $mol_mem
4165
- ], $mol_plot_dot.prototype, "dimensions", null);
4166
4182
  $$.$mol_plot_dot = $mol_plot_dot;
4167
4183
  })($$ = $.$$ || ($.$$ = {}));
4168
4184
  })($ || ($ = {}));