mol_jsx_lib 0.0.1048 → 0.0.1050

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
@@ -1838,10 +1838,19 @@ var $;
1838
1838
  "use strict";
1839
1839
  var $;
1840
1840
  (function ($) {
1841
+ const factories = new WeakMap();
1842
+ function factory(val) {
1843
+ let make = factories.get(val);
1844
+ if (make)
1845
+ return make;
1846
+ make = $mol_func_name_from((...args) => new val(...args), val);
1847
+ factories.set(val, make);
1848
+ return make;
1849
+ }
1841
1850
  function $mol_wire_sync(obj) {
1842
1851
  return new Proxy(obj, {
1843
1852
  get(obj, field) {
1844
- const val = obj[field];
1853
+ let val = obj[field];
1845
1854
  if (typeof val !== 'function')
1846
1855
  return val;
1847
1856
  const temp = $mol_wire_task.getter(val);
@@ -1850,10 +1859,13 @@ var $;
1850
1859
  return fiber.sync();
1851
1860
  };
1852
1861
  },
1862
+ construct(obj, args) {
1863
+ const temp = $mol_wire_task.getter(factory(obj));
1864
+ return temp(obj, args).sync();
1865
+ },
1853
1866
  apply(obj, self, args) {
1854
1867
  const temp = $mol_wire_task.getter(obj);
1855
- const fiber = temp(self, args);
1856
- return fiber.sync();
1868
+ return temp(self, args).sync();
1857
1869
  },
1858
1870
  });
1859
1871
  }
package/web.test.js CHANGED
@@ -1156,24 +1156,6 @@ var $;
1156
1156
  });
1157
1157
  })($ || ($ = {}));
1158
1158
 
1159
- ;
1160
- "use strict";
1161
- var $;
1162
- (function ($_1) {
1163
- $mol_test({
1164
- 'test types'($) {
1165
- class A {
1166
- static a() {
1167
- return Promise.resolve('');
1168
- }
1169
- static b() {
1170
- return $mol_wire_sync(this).a();
1171
- }
1172
- }
1173
- },
1174
- });
1175
- })($ || ($ = {}));
1176
-
1177
1159
  ;
1178
1160
  "use strict";
1179
1161
  var $;
@@ -1227,6 +1209,59 @@ var $;
1227
1209
  });
1228
1210
  })($ || ($ = {}));
1229
1211
 
1212
+ ;
1213
+ "use strict";
1214
+ var $;
1215
+ (function ($_1) {
1216
+ $mol_test({
1217
+ 'test types'($) {
1218
+ class A {
1219
+ static a() {
1220
+ return Promise.resolve('');
1221
+ }
1222
+ static b() {
1223
+ return $mol_wire_sync(this).a();
1224
+ }
1225
+ }
1226
+ },
1227
+ async 'test method from host'($) {
1228
+ let count = 0;
1229
+ class A {
1230
+ static a() {
1231
+ return $mol_wire_sync(this).b();
1232
+ }
1233
+ static b() { return Promise.resolve(++count); }
1234
+ }
1235
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
1236
+ },
1237
+ async 'test function'($) {
1238
+ let count = 0;
1239
+ class A {
1240
+ static a() {
1241
+ return $mol_wire_sync(this.b)();
1242
+ }
1243
+ static b() { return Promise.resolve(++count); }
1244
+ }
1245
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
1246
+ },
1247
+ async 'test construct itself'($) {
1248
+ class A {
1249
+ static instances = [];
1250
+ static a() {
1251
+ const a = new ($mol_wire_sync(A))();
1252
+ this.instances.push(a);
1253
+ $mol_wire_sync(this).b();
1254
+ }
1255
+ static b() { return Promise.resolve(); }
1256
+ }
1257
+ await $mol_wire_async(A).a();
1258
+ $mol_assert_equal(A.instances.length, 2);
1259
+ $mol_assert_equal(A.instances[0] instanceof A);
1260
+ $mol_assert_equal(A.instances[0], A.instances[1]);
1261
+ }
1262
+ });
1263
+ })($ || ($ = {}));
1264
+
1230
1265
  ;
1231
1266
  "use strict";
1232
1267
  var $;