mol_data_all 1.1.1256 → 1.1.1258

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.test.js CHANGED
@@ -777,7 +777,11 @@ var $node = new Proxy({ require }, {
777
777
  try {
778
778
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
779
779
  }
780
- catch { }
780
+ catch (e) {
781
+ if ($$.$mol_fail_catch(e)) {
782
+ $$.$mol_fail_log(e);
783
+ }
784
+ }
781
785
  break;
782
786
  }
783
787
  else {
@@ -788,7 +792,7 @@ var $node = new Proxy({ require }, {
788
792
  return target.require(name);
789
793
  }
790
794
  catch (error) {
791
- if (error.code === 'ERR_REQUIRE_ESM') {
795
+ if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
792
796
  const module = cache.get(name);
793
797
  if (module)
794
798
  return module;
@@ -3489,32 +3493,6 @@ var $;
3489
3493
  $.$mol_wire_task = $mol_wire_task;
3490
3494
  })($ || ($ = {}));
3491
3495
 
3492
- ;
3493
- "use strict";
3494
- var $;
3495
- (function ($) {
3496
- function $mol_wire_method(host, field, descr) {
3497
- if (!descr)
3498
- descr = Reflect.getOwnPropertyDescriptor(host, field);
3499
- const orig = descr?.value ?? host[field];
3500
- const sup = Reflect.getPrototypeOf(host);
3501
- if (typeof sup[field] === 'function') {
3502
- Object.defineProperty(orig, 'name', { value: sup[field].name });
3503
- }
3504
- const temp = $mol_wire_task.getter(orig);
3505
- const value = function (...args) {
3506
- const fiber = temp(this ?? null, args);
3507
- return fiber.sync();
3508
- };
3509
- Object.defineProperty(value, 'name', { value: orig.name + ' ' });
3510
- Object.assign(value, { orig });
3511
- const descr2 = { ...descr, value };
3512
- Reflect.defineProperty(host, field, descr2);
3513
- return descr2;
3514
- }
3515
- $.$mol_wire_method = $mol_wire_method;
3516
- })($ || ($ = {}));
3517
-
3518
3496
  ;
3519
3497
  "use strict";
3520
3498
  var $;
@@ -3602,10 +3580,45 @@ var $;
3602
3580
  "use strict";
3603
3581
  var $;
3604
3582
  (function ($) {
3583
+ function $mol_wire_method(host, field, descr) {
3584
+ if (!descr)
3585
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
3586
+ const orig = descr?.value ?? host[field];
3587
+ const sup = Reflect.getPrototypeOf(host);
3588
+ if (typeof sup[field] === 'function') {
3589
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
3590
+ }
3591
+ const temp = $mol_wire_task.getter(orig);
3592
+ const value = function (...args) {
3593
+ const fiber = temp(this ?? null, args);
3594
+ return fiber.sync();
3595
+ };
3596
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
3597
+ Object.assign(value, { orig });
3598
+ const descr2 = { ...descr, value };
3599
+ Reflect.defineProperty(host, field, descr2);
3600
+ return descr2;
3601
+ }
3602
+ $.$mol_wire_method = $mol_wire_method;
3603
+ })($ || ($ = {}));
3604
+
3605
+ ;
3606
+ "use strict";
3607
+ var $;
3608
+ (function ($) {
3609
+ const factories = new WeakMap();
3610
+ function factory(val) {
3611
+ let make = factories.get(val);
3612
+ if (make)
3613
+ return make;
3614
+ make = $mol_func_name_from((...args) => new val(...args), val);
3615
+ factories.set(val, make);
3616
+ return make;
3617
+ }
3605
3618
  function $mol_wire_sync(obj) {
3606
3619
  return new Proxy(obj, {
3607
3620
  get(obj, field) {
3608
- const val = obj[field];
3621
+ let val = obj[field];
3609
3622
  if (typeof val !== 'function')
3610
3623
  return val;
3611
3624
  const temp = $mol_wire_task.getter(val);
@@ -3614,10 +3627,13 @@ var $;
3614
3627
  return fiber.sync();
3615
3628
  };
3616
3629
  },
3630
+ construct(obj, args) {
3631
+ const temp = $mol_wire_task.getter(factory(obj));
3632
+ return temp(obj, args).sync();
3633
+ },
3617
3634
  apply(obj, self, args) {
3618
3635
  const temp = $mol_wire_task.getter(obj);
3619
- const fiber = temp(self, args);
3620
- return fiber.sync();
3636
+ return temp(self, args).sync();
3621
3637
  },
3622
3638
  });
3623
3639
  }
@@ -3639,6 +3655,41 @@ var $;
3639
3655
  }
3640
3656
  }
3641
3657
  },
3658
+ async 'test method from host'($) {
3659
+ let count = 0;
3660
+ class A {
3661
+ static a() {
3662
+ return $mol_wire_sync(this).b();
3663
+ }
3664
+ static b() { return Promise.resolve(++count); }
3665
+ }
3666
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
3667
+ },
3668
+ async 'test function'($) {
3669
+ let count = 0;
3670
+ class A {
3671
+ static a() {
3672
+ return $mol_wire_sync(this.b)();
3673
+ }
3674
+ static b() { return Promise.resolve(++count); }
3675
+ }
3676
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
3677
+ },
3678
+ async 'test construct itself'($) {
3679
+ class A {
3680
+ static instances = [];
3681
+ static a() {
3682
+ const a = new ($mol_wire_sync(A))();
3683
+ this.instances.push(a);
3684
+ $mol_wire_sync(this).b();
3685
+ }
3686
+ static b() { return Promise.resolve(); }
3687
+ }
3688
+ await $mol_wire_async(A).a();
3689
+ $mol_assert_equal(A.instances.length, 2);
3690
+ $mol_assert_equal(A.instances[0] instanceof A);
3691
+ $mol_assert_equal(A.instances[0], A.instances[1]);
3692
+ }
3642
3693
  });
3643
3694
  })($ || ($ = {}));
3644
3695
 
@@ -3718,9 +3769,19 @@ var $;
3718
3769
  $.$mol_run_error = $mol_run_error;
3719
3770
  const child_process = $node['child_process'];
3720
3771
  $.$mol_run_spawn = child_process.spawn.bind(child_process);
3772
+ $.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
3721
3773
  function $mol_run_async({ dir, timeout, command, env }) {
3722
3774
  const args_raw = typeof command === 'string' ? command.split(' ') : command;
3723
3775
  const [app, ...args] = args_raw;
3776
+ if (!env?.MOL_RUN_ASYNC) {
3777
+ this.$mol_log3_come({
3778
+ place: '$mol_run_sync',
3779
+ message: 'Run',
3780
+ command: args_raw.join(' '),
3781
+ dir: $node.path.relative('', dir),
3782
+ });
3783
+ return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
3784
+ }
3724
3785
  const sub = this.$mol_run_spawn(app, args, {
3725
3786
  shell: true,
3726
3787
  cwd: dir,
@@ -3816,7 +3877,7 @@ var $;
3816
3877
  });
3817
3878
  let message = '';
3818
3879
  try {
3819
- const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
3880
+ const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
3820
3881
  }
3821
3882
  catch (e) {
3822
3883
  message = e.message;