mol_dump_lib 0.0.536 → 0.0.538

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