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/node.mjs CHANGED
@@ -1277,7 +1277,7 @@ var $;
1277
1277
  "use strict";
1278
1278
  var $;
1279
1279
  (function ($) {
1280
- const handled = new WeakSet();
1280
+ const wrappers = new WeakMap();
1281
1281
  class $mol_wire_fiber extends $mol_wire_pub_sub {
1282
1282
  task;
1283
1283
  host;
@@ -1412,14 +1412,21 @@ var $;
1412
1412
  result = this.task.call(this.host, ...this.args);
1413
1413
  break;
1414
1414
  }
1415
- if ($mol_promise_like(result) && !handled.has(result)) {
1416
- handled.add(result);
1417
- const put = (res) => {
1418
- if (this.cache === result)
1419
- this.put(res);
1420
- return res;
1421
- };
1422
- result = Object.assign(result.then(put, put), { destructor: result.destructor });
1415
+ if ($mol_promise_like(result)) {
1416
+ if (wrappers.has(result)) {
1417
+ result = wrappers.get(result).then(a => a);
1418
+ }
1419
+ else {
1420
+ const put = (res) => {
1421
+ if (this.cache === result)
1422
+ this.put(res);
1423
+ return res;
1424
+ };
1425
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1426
+ wrappers.set(result, result);
1427
+ const error = new Error(`Promise in ${this}`);
1428
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1429
+ }
1423
1430
  }
1424
1431
  }
1425
1432
  catch (error) {
@@ -1429,22 +1436,20 @@ var $;
1429
1436
  else {
1430
1437
  result = new Error(String(error), { cause: error });
1431
1438
  }
1432
- if ($mol_promise_like(result) && !handled.has(result)) {
1433
- handled.add(result);
1434
- result = Object.assign(result.finally(() => {
1435
- if (this.cache === result)
1436
- this.absorb();
1437
- }), { destructor: result.destructor });
1439
+ if ($mol_promise_like(result)) {
1440
+ if (wrappers.has(result)) {
1441
+ result = wrappers.get(result);
1442
+ }
1443
+ else {
1444
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1445
+ if (this.cache === result)
1446
+ this.absorb();
1447
+ }), { destructor: result.destructor || (() => { }) }));
1448
+ const error = new Error(`Promise in ${this}`);
1449
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1450
+ }
1438
1451
  }
1439
1452
  }
1440
- if ($mol_promise_like(result) && !handled.has(result)) {
1441
- result = Object.assign(result, {
1442
- destructor: result['destructor'] ?? (() => { })
1443
- });
1444
- handled.add(result);
1445
- const error = new Error(`Promise in ${this}`);
1446
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1447
- }
1448
1453
  if (!$mol_promise_like(result)) {
1449
1454
  this.track_cut();
1450
1455
  }
@@ -1504,6 +1509,12 @@ var $;
1504
1509
  };
1505
1510
  });
1506
1511
  }
1512
+ destructor() {
1513
+ super.destructor();
1514
+ if ($mol_owning_check(this, this.cache)) {
1515
+ this.cache.destructor();
1516
+ }
1517
+ }
1507
1518
  }
1508
1519
  $.$mol_wire_fiber = $mol_wire_fiber;
1509
1520
  })($ || ($ = {}));
@@ -1674,7 +1685,8 @@ var $;
1674
1685
  $$.$mol_log3_warn({
1675
1686
  place: '$mol_wire_task',
1676
1687
  message: `Non idempotency`,
1677
- existen,
1688
+ sub,
1689
+ pubs: [...sub?.pub_list ?? [], existen],
1678
1690
  next,
1679
1691
  hint: 'Ignore it',
1680
1692
  });
@@ -1697,6 +1709,14 @@ var $;
1697
1709
  this.cursor = $mol_wire_cursor.fresh;
1698
1710
  if (next !== prev)
1699
1711
  this.emit();
1712
+ if ($mol_owning_catch(this, next)) {
1713
+ try {
1714
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1715
+ }
1716
+ catch {
1717
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1718
+ }
1719
+ }
1700
1720
  return next;
1701
1721
  }
1702
1722
  this.cursor = $mol_wire_cursor.final;
@@ -2456,6 +2476,7 @@ var $;
2456
2476
  var $;
2457
2477
  (function ($) {
2458
2478
  $.$mol_key_store = new WeakMap();
2479
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
2459
2480
  function $mol_key(value) {
2460
2481
  if (typeof value === 'bigint')
2461
2482
  return value.toString() + 'n';
@@ -2485,7 +2506,7 @@ var $;
2485
2506
  return value;
2486
2507
  if (value instanceof RegExp)
2487
2508
  return value.toString();
2488
- if (value instanceof Uint8Array)
2509
+ if (value instanceof TypedArray)
2489
2510
  return [...value];
2490
2511
  let key = $.$mol_key_store.get(value);
2491
2512
  if (key)
@@ -2641,10 +2662,6 @@ var $;
2641
2662
  }
2642
2663
  destructor() {
2643
2664
  super.destructor();
2644
- const prev = this.cache;
2645
- if ($mol_owning_check(this, prev)) {
2646
- prev.destructor();
2647
- }
2648
2665
  if (this.pub_from === 0) {
2649
2666
  ;
2650
2667
  (this.host ?? this.task)[this.field()] = null;
@@ -3196,8 +3213,11 @@ var $;
3196
3213
  stabilityThreshold: 100,
3197
3214
  },
3198
3215
  });
3199
- watcher
3200
- .on('all', (type, path) => {
3216
+ watcher.on('all', (type, path) => {
3217
+ if (path instanceof Error) {
3218
+ this.$.$mol_fail_log(path);
3219
+ return;
3220
+ }
3201
3221
  const file = $mol_file.relative(path.replace(/\\/g, '/'));
3202
3222
  file.reset();
3203
3223
  if (type === 'change') {
@@ -3206,8 +3226,7 @@ var $;
3206
3226
  else {
3207
3227
  file.parent().reset();
3208
3228
  }
3209
- })
3210
- .on('error', $mol_fail_log);
3229
+ });
3211
3230
  return {
3212
3231
  destructor() {
3213
3232
  watcher.close();
@@ -3436,13 +3455,15 @@ var $;
3436
3455
  class $mol_memo extends $mol_wrapper {
3437
3456
  static wrap(task) {
3438
3457
  const store = new WeakMap();
3439
- return function (next) {
3458
+ const fun = function (next) {
3440
3459
  if (next === undefined && store.has(this))
3441
3460
  return store.get(this);
3442
3461
  const val = task.call(this, next) ?? next;
3443
3462
  store.set(this, val);
3444
3463
  return val;
3445
3464
  };
3465
+ Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
3466
+ return fun;
3446
3467
  }
3447
3468
  }
3448
3469
  $.$mol_memo = $mol_memo;
package/node.test.js CHANGED
@@ -1268,7 +1268,7 @@ var $;
1268
1268
  "use strict";
1269
1269
  var $;
1270
1270
  (function ($) {
1271
- const handled = new WeakSet();
1271
+ const wrappers = new WeakMap();
1272
1272
  class $mol_wire_fiber extends $mol_wire_pub_sub {
1273
1273
  task;
1274
1274
  host;
@@ -1403,14 +1403,21 @@ var $;
1403
1403
  result = this.task.call(this.host, ...this.args);
1404
1404
  break;
1405
1405
  }
1406
- if ($mol_promise_like(result) && !handled.has(result)) {
1407
- handled.add(result);
1408
- const put = (res) => {
1409
- if (this.cache === result)
1410
- this.put(res);
1411
- return res;
1412
- };
1413
- result = Object.assign(result.then(put, put), { destructor: result.destructor });
1406
+ if ($mol_promise_like(result)) {
1407
+ if (wrappers.has(result)) {
1408
+ result = wrappers.get(result).then(a => a);
1409
+ }
1410
+ else {
1411
+ const put = (res) => {
1412
+ if (this.cache === result)
1413
+ this.put(res);
1414
+ return res;
1415
+ };
1416
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1417
+ wrappers.set(result, result);
1418
+ const error = new Error(`Promise in ${this}`);
1419
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1420
+ }
1414
1421
  }
1415
1422
  }
1416
1423
  catch (error) {
@@ -1420,22 +1427,20 @@ var $;
1420
1427
  else {
1421
1428
  result = new Error(String(error), { cause: error });
1422
1429
  }
1423
- if ($mol_promise_like(result) && !handled.has(result)) {
1424
- handled.add(result);
1425
- result = Object.assign(result.finally(() => {
1426
- if (this.cache === result)
1427
- this.absorb();
1428
- }), { destructor: result.destructor });
1430
+ if ($mol_promise_like(result)) {
1431
+ if (wrappers.has(result)) {
1432
+ result = wrappers.get(result);
1433
+ }
1434
+ else {
1435
+ wrappers.set(result, result = Object.assign(result.finally(() => {
1436
+ if (this.cache === result)
1437
+ this.absorb();
1438
+ }), { destructor: result.destructor || (() => { }) }));
1439
+ const error = new Error(`Promise in ${this}`);
1440
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1441
+ }
1429
1442
  }
1430
1443
  }
1431
- if ($mol_promise_like(result) && !handled.has(result)) {
1432
- result = Object.assign(result, {
1433
- destructor: result['destructor'] ?? (() => { })
1434
- });
1435
- handled.add(result);
1436
- const error = new Error(`Promise in ${this}`);
1437
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1438
- }
1439
1444
  if (!$mol_promise_like(result)) {
1440
1445
  this.track_cut();
1441
1446
  }
@@ -1495,6 +1500,12 @@ var $;
1495
1500
  };
1496
1501
  });
1497
1502
  }
1503
+ destructor() {
1504
+ super.destructor();
1505
+ if ($mol_owning_check(this, this.cache)) {
1506
+ this.cache.destructor();
1507
+ }
1508
+ }
1498
1509
  }
1499
1510
  $.$mol_wire_fiber = $mol_wire_fiber;
1500
1511
  })($ || ($ = {}));
@@ -1665,7 +1676,8 @@ var $;
1665
1676
  $$.$mol_log3_warn({
1666
1677
  place: '$mol_wire_task',
1667
1678
  message: `Non idempotency`,
1668
- existen,
1679
+ sub,
1680
+ pubs: [...sub?.pub_list ?? [], existen],
1669
1681
  next,
1670
1682
  hint: 'Ignore it',
1671
1683
  });
@@ -1688,6 +1700,14 @@ var $;
1688
1700
  this.cursor = $mol_wire_cursor.fresh;
1689
1701
  if (next !== prev)
1690
1702
  this.emit();
1703
+ if ($mol_owning_catch(this, next)) {
1704
+ try {
1705
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1706
+ }
1707
+ catch {
1708
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1709
+ }
1710
+ }
1691
1711
  return next;
1692
1712
  }
1693
1713
  this.cursor = $mol_wire_cursor.final;
@@ -2447,6 +2467,7 @@ var $;
2447
2467
  var $;
2448
2468
  (function ($) {
2449
2469
  $.$mol_key_store = new WeakMap();
2470
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
2450
2471
  function $mol_key(value) {
2451
2472
  if (typeof value === 'bigint')
2452
2473
  return value.toString() + 'n';
@@ -2476,7 +2497,7 @@ var $;
2476
2497
  return value;
2477
2498
  if (value instanceof RegExp)
2478
2499
  return value.toString();
2479
- if (value instanceof Uint8Array)
2500
+ if (value instanceof TypedArray)
2480
2501
  return [...value];
2481
2502
  let key = $.$mol_key_store.get(value);
2482
2503
  if (key)
@@ -2632,10 +2653,6 @@ var $;
2632
2653
  }
2633
2654
  destructor() {
2634
2655
  super.destructor();
2635
- const prev = this.cache;
2636
- if ($mol_owning_check(this, prev)) {
2637
- prev.destructor();
2638
- }
2639
2656
  if (this.pub_from === 0) {
2640
2657
  ;
2641
2658
  (this.host ?? this.task)[this.field()] = null;
@@ -3187,8 +3204,11 @@ var $;
3187
3204
  stabilityThreshold: 100,
3188
3205
  },
3189
3206
  });
3190
- watcher
3191
- .on('all', (type, path) => {
3207
+ watcher.on('all', (type, path) => {
3208
+ if (path instanceof Error) {
3209
+ this.$.$mol_fail_log(path);
3210
+ return;
3211
+ }
3192
3212
  const file = $mol_file.relative(path.replace(/\\/g, '/'));
3193
3213
  file.reset();
3194
3214
  if (type === 'change') {
@@ -3197,8 +3217,7 @@ var $;
3197
3217
  else {
3198
3218
  file.parent().reset();
3199
3219
  }
3200
- })
3201
- .on('error', $mol_fail_log);
3220
+ });
3202
3221
  return {
3203
3222
  destructor() {
3204
3223
  watcher.close();
@@ -3427,13 +3446,15 @@ var $;
3427
3446
  class $mol_memo extends $mol_wrapper {
3428
3447
  static wrap(task) {
3429
3448
  const store = new WeakMap();
3430
- return function (next) {
3449
+ const fun = function (next) {
3431
3450
  if (next === undefined && store.has(this))
3432
3451
  return store.get(this);
3433
3452
  const val = task.call(this, next) ?? next;
3434
3453
  store.set(this, val);
3435
3454
  return val;
3436
3455
  };
3456
+ Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
3457
+ return fun;
3437
3458
  }
3438
3459
  }
3439
3460
  $.$mol_memo = $mol_memo;
@@ -5480,6 +5501,17 @@ var $;
5480
5501
  ;
5481
5502
  "use strict";
5482
5503
 
5504
+ ;
5505
+ "use strict";
5506
+ var $;
5507
+ (function ($) {
5508
+ function $mol_dom_serialize(node) {
5509
+ const serializer = new $mol_dom_context.XMLSerializer;
5510
+ return serializer.serializeToString(node);
5511
+ }
5512
+ $.$mol_dom_serialize = $mol_dom_serialize;
5513
+ })($ || ($ = {}));
5514
+
5483
5515
  ;
5484
5516
  "use strict";
5485
5517
  var $;
@@ -5637,6 +5669,19 @@ var $;
5637
5669
  "!");
5638
5670
  $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
5639
5671
  },
5672
+ 'Make fragment'() {
5673
+ const dom = $mol_jsx($mol_jsx_frag, null,
5674
+ $mol_jsx("br", null),
5675
+ $mol_jsx("hr", null));
5676
+ $mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
5677
+ },
5678
+ 'Spread fragment'() {
5679
+ const dom = $mol_jsx("div", null,
5680
+ $mol_jsx($mol_jsx_frag, null,
5681
+ $mol_jsx("br", null),
5682
+ $mol_jsx("hr", null)));
5683
+ $mol_assert_equal(dom.outerHTML, '<div><br><hr></div>');
5684
+ },
5640
5685
  'Function as component'() {
5641
5686
  const Button = (props, target) => {
5642
5687
  return $mol_jsx("button", { title: props.hint }, target());