hyoo_sync_client 0.0.544 → 0.0.546

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
@@ -1256,7 +1256,7 @@ var $;
1256
1256
  "use strict";
1257
1257
  var $;
1258
1258
  (function ($) {
1259
- const handled = new WeakSet();
1259
+ const wrappers = new WeakMap();
1260
1260
  class $mol_wire_fiber extends $mol_wire_pub_sub {
1261
1261
  task;
1262
1262
  host;
@@ -1391,14 +1391,21 @@ var $;
1391
1391
  result = this.task.call(this.host, ...this.args);
1392
1392
  break;
1393
1393
  }
1394
- if ($mol_promise_like(result) && !handled.has(result)) {
1395
- handled.add(result);
1396
- const put = (res) => {
1397
- if (this.cache === result)
1398
- this.put(res);
1399
- return res;
1400
- };
1401
- result = Object.assign(result.then(put, put), { destructor: result.destructor });
1394
+ if ($mol_promise_like(result)) {
1395
+ if (wrappers.has(result)) {
1396
+ result = wrappers.get(result).then(a => a);
1397
+ }
1398
+ else {
1399
+ const put = (res) => {
1400
+ if (this.cache === result)
1401
+ this.put(res);
1402
+ return res;
1403
+ };
1404
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1405
+ wrappers.set(result, result);
1406
+ const error = new Error(`Promise in ${this}`);
1407
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1408
+ }
1402
1409
  }
1403
1410
  }
1404
1411
  catch (error) {
@@ -1408,22 +1415,20 @@ var $;
1408
1415
  else {
1409
1416
  result = new Error(String(error), { cause: error });
1410
1417
  }
1411
- if ($mol_promise_like(result) && !handled.has(result)) {
1412
- handled.add(result);
1413
- result = Object.assign(result.finally(() => {
1414
- if (this.cache === result)
1415
- this.absorb();
1416
- }), { destructor: result.destructor });
1418
+ if ($mol_promise_like(result)) {
1419
+ if (wrappers.has(result)) {
1420
+ result = wrappers.get(result);
1421
+ }
1422
+ else {
1423
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1424
+ if (this.cache === result)
1425
+ this.absorb();
1426
+ }), { destructor: result.destructor || (() => { }) }));
1427
+ const error = new Error(`Promise in ${this}`);
1428
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1429
+ }
1417
1430
  }
1418
1431
  }
1419
- if ($mol_promise_like(result) && !handled.has(result)) {
1420
- result = Object.assign(result, {
1421
- destructor: result['destructor'] ?? (() => { })
1422
- });
1423
- handled.add(result);
1424
- const error = new Error(`Promise in ${this}`);
1425
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1426
- }
1427
1432
  if (!$mol_promise_like(result)) {
1428
1433
  this.track_cut();
1429
1434
  }
@@ -1483,6 +1488,12 @@ var $;
1483
1488
  };
1484
1489
  });
1485
1490
  }
1491
+ destructor() {
1492
+ super.destructor();
1493
+ if ($mol_owning_check(this, this.cache)) {
1494
+ this.cache.destructor();
1495
+ }
1496
+ }
1486
1497
  }
1487
1498
  $.$mol_wire_fiber = $mol_wire_fiber;
1488
1499
  })($ || ($ = {}));
@@ -1507,6 +1518,7 @@ var $;
1507
1518
  var $;
1508
1519
  (function ($) {
1509
1520
  $.$mol_key_store = new WeakMap();
1521
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
1510
1522
  function $mol_key(value) {
1511
1523
  if (typeof value === 'bigint')
1512
1524
  return value.toString() + 'n';
@@ -1536,7 +1548,7 @@ var $;
1536
1548
  return value;
1537
1549
  if (value instanceof RegExp)
1538
1550
  return value.toString();
1539
- if (value instanceof Uint8Array)
1551
+ if (value instanceof TypedArray)
1540
1552
  return [...value];
1541
1553
  let key = $.$mol_key_store.get(value);
1542
1554
  if (key)
@@ -1812,7 +1824,8 @@ var $;
1812
1824
  $$.$mol_log3_warn({
1813
1825
  place: '$mol_wire_task',
1814
1826
  message: `Non idempotency`,
1815
- existen,
1827
+ sub,
1828
+ pubs: [...sub?.pub_list ?? [], existen],
1816
1829
  next,
1817
1830
  hint: 'Ignore it',
1818
1831
  });
@@ -1835,6 +1848,14 @@ var $;
1835
1848
  this.cursor = $mol_wire_cursor.fresh;
1836
1849
  if (next !== prev)
1837
1850
  this.emit();
1851
+ if ($mol_owning_catch(this, next)) {
1852
+ try {
1853
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1854
+ }
1855
+ catch {
1856
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1857
+ }
1858
+ }
1838
1859
  return next;
1839
1860
  }
1840
1861
  this.cursor = $mol_wire_cursor.final;
@@ -1989,10 +2010,6 @@ var $;
1989
2010
  }
1990
2011
  destructor() {
1991
2012
  super.destructor();
1992
- const prev = this.cache;
1993
- if ($mol_owning_check(this, prev)) {
1994
- prev.destructor();
1995
- }
1996
2013
  if (this.pub_from === 0) {
1997
2014
  ;
1998
2015
  (this.host ?? this.task)[this.field()] = null;
@@ -2621,13 +2638,15 @@ var $;
2621
2638
  class $mol_memo extends $mol_wrapper {
2622
2639
  static wrap(task) {
2623
2640
  const store = new WeakMap();
2624
- return function (next) {
2641
+ const fun = function (next) {
2625
2642
  if (next === undefined && store.has(this))
2626
2643
  return store.get(this);
2627
2644
  const val = task.call(this, next) ?? next;
2628
2645
  store.set(this, val);
2629
2646
  return val;
2630
2647
  };
2648
+ Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
2649
+ return fun;
2631
2650
  }
2632
2651
  }
2633
2652
  $.$mol_memo = $mol_memo;
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 $;
@@ -143,6 +154,19 @@ var $;
143
154
  "!");
144
155
  $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
145
156
  },
157
+ 'Make fragment'() {
158
+ const dom = $mol_jsx($mol_jsx_frag, null,
159
+ $mol_jsx("br", null),
160
+ $mol_jsx("hr", null));
161
+ $mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
162
+ },
163
+ 'Spread fragment'() {
164
+ const dom = $mol_jsx("div", null,
165
+ $mol_jsx($mol_jsx_frag, null,
166
+ $mol_jsx("br", null),
167
+ $mol_jsx("hr", null)));
168
+ $mol_assert_equal(dom.outerHTML, '<div><br><hr></div>');
169
+ },
146
170
  'Function as component'() {
147
171
  const Button = (props, target) => {
148
172
  return $mol_jsx("button", { title: props.hint }, target());