mol_plot_all 1.2.1216 → 1.2.1218

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.mjs CHANGED
@@ -638,7 +638,7 @@ var $;
638
638
  "use strict";
639
639
  var $;
640
640
  (function ($) {
641
- const handled = new WeakSet();
641
+ const wrappers = new WeakMap();
642
642
  class $mol_wire_fiber extends $mol_wire_pub_sub {
643
643
  task;
644
644
  host;
@@ -773,14 +773,21 @@ var $;
773
773
  result = this.task.call(this.host, ...this.args);
774
774
  break;
775
775
  }
776
- if ($mol_promise_like(result) && !handled.has(result)) {
777
- handled.add(result);
778
- const put = (res) => {
779
- if (this.cache === result)
780
- this.put(res);
781
- return res;
782
- };
783
- result = Object.assign(result.then(put, put), { destructor: result.destructor });
776
+ if ($mol_promise_like(result)) {
777
+ if (wrappers.has(result)) {
778
+ result = wrappers.get(result).then(a => a);
779
+ }
780
+ else {
781
+ const put = (res) => {
782
+ if (this.cache === result)
783
+ this.put(res);
784
+ return res;
785
+ };
786
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
787
+ wrappers.set(result, result);
788
+ const error = new Error(`Promise in ${this}`);
789
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
790
+ }
784
791
  }
785
792
  }
786
793
  catch (error) {
@@ -790,22 +797,20 @@ var $;
790
797
  else {
791
798
  result = new Error(String(error), { cause: error });
792
799
  }
793
- if ($mol_promise_like(result) && !handled.has(result)) {
794
- handled.add(result);
795
- result = Object.assign(result.finally(() => {
796
- if (this.cache === result)
797
- this.absorb();
798
- }), { destructor: result.destructor });
800
+ if ($mol_promise_like(result)) {
801
+ if (wrappers.has(result)) {
802
+ result = wrappers.get(result);
803
+ }
804
+ else {
805
+ wrappers.set(result, result = Object.assign(result.finally(() => {
806
+ if (this.cache === result)
807
+ this.absorb();
808
+ }), { destructor: result.destructor || (() => { }) }));
809
+ const error = new Error(`Promise in ${this}`);
810
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
811
+ }
799
812
  }
800
813
  }
801
- if ($mol_promise_like(result) && !handled.has(result)) {
802
- result = Object.assign(result, {
803
- destructor: result['destructor'] ?? (() => { })
804
- });
805
- handled.add(result);
806
- const error = new Error(`Promise in ${this}`);
807
- Object.defineProperty(result, 'stack', { get: () => error.stack });
808
- }
809
814
  if (!$mol_promise_like(result)) {
810
815
  this.track_cut();
811
816
  }
@@ -865,6 +870,12 @@ var $;
865
870
  };
866
871
  });
867
872
  }
873
+ destructor() {
874
+ super.destructor();
875
+ if ($mol_owning_check(this, this.cache)) {
876
+ this.cache.destructor();
877
+ }
878
+ }
868
879
  }
869
880
  $.$mol_wire_fiber = $mol_wire_fiber;
870
881
  })($ || ($ = {}));
@@ -889,6 +900,7 @@ var $;
889
900
  var $;
890
901
  (function ($) {
891
902
  $.$mol_key_store = new WeakMap();
903
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
892
904
  function $mol_key(value) {
893
905
  if (typeof value === 'bigint')
894
906
  return value.toString() + 'n';
@@ -918,7 +930,7 @@ var $;
918
930
  return value;
919
931
  if (value instanceof RegExp)
920
932
  return value.toString();
921
- if (value instanceof Uint8Array)
933
+ if (value instanceof TypedArray)
922
934
  return [...value];
923
935
  let key = $.$mol_key_store.get(value);
924
936
  if (key)
@@ -1194,7 +1206,8 @@ var $;
1194
1206
  $$.$mol_log3_warn({
1195
1207
  place: '$mol_wire_task',
1196
1208
  message: `Non idempotency`,
1197
- existen,
1209
+ sub,
1210
+ pubs: [...sub?.pub_list ?? [], existen],
1198
1211
  next,
1199
1212
  hint: 'Ignore it',
1200
1213
  });
@@ -1217,6 +1230,14 @@ var $;
1217
1230
  this.cursor = $mol_wire_cursor.fresh;
1218
1231
  if (next !== prev)
1219
1232
  this.emit();
1233
+ if ($mol_owning_catch(this, next)) {
1234
+ try {
1235
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1236
+ }
1237
+ catch {
1238
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1239
+ }
1240
+ }
1220
1241
  return next;
1221
1242
  }
1222
1243
  this.cursor = $mol_wire_cursor.final;
@@ -1371,10 +1392,6 @@ var $;
1371
1392
  }
1372
1393
  destructor() {
1373
1394
  super.destructor();
1374
- const prev = this.cache;
1375
- if ($mol_owning_check(this, prev)) {
1376
- prev.destructor();
1377
- }
1378
1395
  if (this.pub_from === 0) {
1379
1396
  ;
1380
1397
  (this.host ?? this.task)[this.field()] = null;
@@ -1642,13 +1659,15 @@ var $;
1642
1659
  class $mol_memo extends $mol_wrapper {
1643
1660
  static wrap(task) {
1644
1661
  const store = new WeakMap();
1645
- return function (next) {
1662
+ const fun = function (next) {
1646
1663
  if (next === undefined && store.has(this))
1647
1664
  return store.get(this);
1648
1665
  const val = task.call(this, next) ?? next;
1649
1666
  store.set(this, val);
1650
1667
  return val;
1651
1668
  };
1669
+ Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
1670
+ return fun;
1652
1671
  }
1653
1672
  }
1654
1673
  $.$mol_memo = $mol_memo;
@@ -2482,7 +2501,6 @@ var $;
2482
2501
  const win = this.$.$mol_dom_context;
2483
2502
  if (win.parent !== win.self && !win.document.hasFocus())
2484
2503
  return;
2485
- this.focused(true);
2486
2504
  }
2487
2505
  destructor() {
2488
2506
  const node = $mol_wire_probe(() => this.dom_node());
package/web.test.js CHANGED
@@ -110,6 +110,17 @@ var $;
110
110
  ;
111
111
  "use strict";
112
112
 
113
+ ;
114
+ "use strict";
115
+ var $;
116
+ (function ($) {
117
+ function $mol_dom_serialize(node) {
118
+ const serializer = new $mol_dom_context.XMLSerializer;
119
+ return serializer.serializeToString(node);
120
+ }
121
+ $.$mol_dom_serialize = $mol_dom_serialize;
122
+ })($ || ($ = {}));
123
+
113
124
  ;
114
125
  "use strict";
115
126
  var $;
@@ -267,6 +278,19 @@ var $;
267
278
  "!");
268
279
  $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
269
280
  },
281
+ 'Make fragment'() {
282
+ const dom = $mol_jsx($mol_jsx_frag, null,
283
+ $mol_jsx("br", null),
284
+ $mol_jsx("hr", null));
285
+ $mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
286
+ },
287
+ 'Spread fragment'() {
288
+ const dom = $mol_jsx("div", null,
289
+ $mol_jsx($mol_jsx_frag, null,
290
+ $mol_jsx("br", null),
291
+ $mol_jsx("hr", null)));
292
+ $mol_assert_equal(dom.outerHTML, '<div><br><hr></div>');
293
+ },
270
294
  'Function as component'() {
271
295
  const Button = (props, target) => {
272
296
  return $mol_jsx("button", { title: props.hint }, target());