hyoo_sync_client 0.0.507 → 0.0.509

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.meta.tree CHANGED
@@ -17,6 +17,7 @@
17
17
  pack aura git \https://github.com/hyoo-ru/aura.hyoo.ru.git
18
18
  pack bench git \https://github.com/hyoo-ru/bench.hyoo.ru.git
19
19
  pack board git \https://github.com/hyoo-ru/board.hyoo.ru.git
20
+ pack bunker git \https://github.com/hyoo-ru/bunker.hyoo.ru.git
20
21
  pack calc git \https://github.com/hyoo-ru/calc.hyoo.ru.git
21
22
  pack case git \https://github.com/hyoo-ru/case.hyoo.ru.git
22
23
  pack crowd git \https://github.com/hyoo-ru/crowd.hyoo.ru.git
package/web.mjs CHANGED
@@ -2123,10 +2123,19 @@ var $;
2123
2123
  "use strict";
2124
2124
  var $;
2125
2125
  (function ($) {
2126
+ const factories = new WeakMap();
2127
+ function factory(val) {
2128
+ let make = factories.get(val);
2129
+ if (make)
2130
+ return make;
2131
+ make = $mol_func_name_from((...args) => new val(...args), val);
2132
+ factories.set(val, make);
2133
+ return make;
2134
+ }
2126
2135
  function $mol_wire_sync(obj) {
2127
2136
  return new Proxy(obj, {
2128
2137
  get(obj, field) {
2129
- const val = obj[field];
2138
+ let val = obj[field];
2130
2139
  if (typeof val !== 'function')
2131
2140
  return val;
2132
2141
  const temp = $mol_wire_task.getter(val);
@@ -2135,10 +2144,13 @@ var $;
2135
2144
  return fiber.sync();
2136
2145
  };
2137
2146
  },
2147
+ construct(obj, args) {
2148
+ const temp = $mol_wire_task.getter(factory(obj));
2149
+ return temp(obj, args).sync();
2150
+ },
2138
2151
  apply(obj, self, args) {
2139
2152
  const temp = $mol_wire_task.getter(obj);
2140
- const fiber = temp(self, args);
2141
- return fiber.sync();
2153
+ return temp(self, args).sync();
2142
2154
  },
2143
2155
  });
2144
2156
  }
package/web.test.js CHANGED
@@ -1342,24 +1342,6 @@ var $;
1342
1342
  });
1343
1343
  })($ || ($ = {}));
1344
1344
 
1345
- ;
1346
- "use strict";
1347
- var $;
1348
- (function ($_1) {
1349
- $mol_test({
1350
- 'test types'($) {
1351
- class A {
1352
- static a() {
1353
- return Promise.resolve('');
1354
- }
1355
- static b() {
1356
- return $mol_wire_sync(this).a();
1357
- }
1358
- }
1359
- },
1360
- });
1361
- })($ || ($ = {}));
1362
-
1363
1345
  ;
1364
1346
  "use strict";
1365
1347
  var $;
@@ -1413,6 +1395,59 @@ var $;
1413
1395
  });
1414
1396
  })($ || ($ = {}));
1415
1397
 
1398
+ ;
1399
+ "use strict";
1400
+ var $;
1401
+ (function ($_1) {
1402
+ $mol_test({
1403
+ 'test types'($) {
1404
+ class A {
1405
+ static a() {
1406
+ return Promise.resolve('');
1407
+ }
1408
+ static b() {
1409
+ return $mol_wire_sync(this).a();
1410
+ }
1411
+ }
1412
+ },
1413
+ async 'test method from host'($) {
1414
+ let count = 0;
1415
+ class A {
1416
+ static a() {
1417
+ return $mol_wire_sync(this).b();
1418
+ }
1419
+ static b() { return Promise.resolve(++count); }
1420
+ }
1421
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
1422
+ },
1423
+ async 'test function'($) {
1424
+ let count = 0;
1425
+ class A {
1426
+ static a() {
1427
+ return $mol_wire_sync(this.b)();
1428
+ }
1429
+ static b() { return Promise.resolve(++count); }
1430
+ }
1431
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
1432
+ },
1433
+ async 'test construct itself'($) {
1434
+ class A {
1435
+ static instances = [];
1436
+ static a() {
1437
+ const a = new ($mol_wire_sync(A))();
1438
+ this.instances.push(a);
1439
+ $mol_wire_sync(this).b();
1440
+ }
1441
+ static b() { return Promise.resolve(); }
1442
+ }
1443
+ await $mol_wire_async(A).a();
1444
+ $mol_assert_equal(A.instances.length, 2);
1445
+ $mol_assert_equal(A.instances[0] instanceof A);
1446
+ $mol_assert_equal(A.instances[0], A.instances[1]);
1447
+ }
1448
+ });
1449
+ })($ || ($ = {}));
1450
+
1416
1451
  ;
1417
1452
  "use strict";
1418
1453
  var $;