mol_plot_all 1.2.1175 → 1.2.1177

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
@@ -2003,7 +2003,11 @@ var $node = new Proxy({ require }, {
2003
2003
  try {
2004
2004
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
2005
2005
  }
2006
- catch { }
2006
+ catch (e) {
2007
+ if ($$.$mol_fail_catch(e)) {
2008
+ $$.$mol_fail_log(e);
2009
+ }
2010
+ }
2007
2011
  break;
2008
2012
  }
2009
2013
  else {
@@ -2014,7 +2018,7 @@ var $node = new Proxy({ require }, {
2014
2018
  return target.require(name);
2015
2019
  }
2016
2020
  catch (error) {
2017
- if (error.code === 'ERR_REQUIRE_ESM') {
2021
+ if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
2018
2022
  const module = cache.get(name);
2019
2023
  if (module)
2020
2024
  return module;
@@ -2087,10 +2091,19 @@ var $;
2087
2091
  "use strict";
2088
2092
  var $;
2089
2093
  (function ($) {
2094
+ const factories = new WeakMap();
2095
+ function factory(val) {
2096
+ let make = factories.get(val);
2097
+ if (make)
2098
+ return make;
2099
+ make = $mol_func_name_from((...args) => new val(...args), val);
2100
+ factories.set(val, make);
2101
+ return make;
2102
+ }
2090
2103
  function $mol_wire_sync(obj) {
2091
2104
  return new Proxy(obj, {
2092
2105
  get(obj, field) {
2093
- const val = obj[field];
2106
+ let val = obj[field];
2094
2107
  if (typeof val !== 'function')
2095
2108
  return val;
2096
2109
  const temp = $mol_wire_task.getter(val);
@@ -2099,10 +2112,13 @@ var $;
2099
2112
  return fiber.sync();
2100
2113
  };
2101
2114
  },
2115
+ construct(obj, args) {
2116
+ const temp = $mol_wire_task.getter(factory(obj));
2117
+ return temp(obj, args).sync();
2118
+ },
2102
2119
  apply(obj, self, args) {
2103
2120
  const temp = $mol_wire_task.getter(obj);
2104
- const fiber = temp(self, args);
2105
- return fiber.sync();
2121
+ return temp(self, args).sync();
2106
2122
  },
2107
2123
  });
2108
2124
  }
@@ -2118,9 +2134,19 @@ var $;
2118
2134
  $.$mol_run_error = $mol_run_error;
2119
2135
  const child_process = $node['child_process'];
2120
2136
  $.$mol_run_spawn = child_process.spawn.bind(child_process);
2137
+ $.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
2121
2138
  function $mol_run_async({ dir, timeout, command, env }) {
2122
2139
  const args_raw = typeof command === 'string' ? command.split(' ') : command;
2123
2140
  const [app, ...args] = args_raw;
2141
+ if (!env?.MOL_RUN_ASYNC) {
2142
+ this.$mol_log3_come({
2143
+ place: '$mol_run_sync',
2144
+ message: 'Run',
2145
+ command: args_raw.join(' '),
2146
+ dir: $node.path.relative('', dir),
2147
+ });
2148
+ return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
2149
+ }
2124
2150
  const sub = this.$mol_run_spawn(app, args, {
2125
2151
  shell: true,
2126
2152
  cwd: dir,
package/node.test.js CHANGED
@@ -1994,7 +1994,11 @@ var $node = new Proxy({ require }, {
1994
1994
  try {
1995
1995
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
1996
1996
  }
1997
- catch { }
1997
+ catch (e) {
1998
+ if ($$.$mol_fail_catch(e)) {
1999
+ $$.$mol_fail_log(e);
2000
+ }
2001
+ }
1998
2002
  break;
1999
2003
  }
2000
2004
  else {
@@ -2005,7 +2009,7 @@ var $node = new Proxy({ require }, {
2005
2009
  return target.require(name);
2006
2010
  }
2007
2011
  catch (error) {
2008
- if (error.code === 'ERR_REQUIRE_ESM') {
2012
+ if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
2009
2013
  const module = cache.get(name);
2010
2014
  if (module)
2011
2015
  return module;
@@ -2078,10 +2082,19 @@ var $;
2078
2082
  "use strict";
2079
2083
  var $;
2080
2084
  (function ($) {
2085
+ const factories = new WeakMap();
2086
+ function factory(val) {
2087
+ let make = factories.get(val);
2088
+ if (make)
2089
+ return make;
2090
+ make = $mol_func_name_from((...args) => new val(...args), val);
2091
+ factories.set(val, make);
2092
+ return make;
2093
+ }
2081
2094
  function $mol_wire_sync(obj) {
2082
2095
  return new Proxy(obj, {
2083
2096
  get(obj, field) {
2084
- const val = obj[field];
2097
+ let val = obj[field];
2085
2098
  if (typeof val !== 'function')
2086
2099
  return val;
2087
2100
  const temp = $mol_wire_task.getter(val);
@@ -2090,10 +2103,13 @@ var $;
2090
2103
  return fiber.sync();
2091
2104
  };
2092
2105
  },
2106
+ construct(obj, args) {
2107
+ const temp = $mol_wire_task.getter(factory(obj));
2108
+ return temp(obj, args).sync();
2109
+ },
2093
2110
  apply(obj, self, args) {
2094
2111
  const temp = $mol_wire_task.getter(obj);
2095
- const fiber = temp(self, args);
2096
- return fiber.sync();
2112
+ return temp(self, args).sync();
2097
2113
  },
2098
2114
  });
2099
2115
  }
@@ -2109,9 +2125,19 @@ var $;
2109
2125
  $.$mol_run_error = $mol_run_error;
2110
2126
  const child_process = $node['child_process'];
2111
2127
  $.$mol_run_spawn = child_process.spawn.bind(child_process);
2128
+ $.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
2112
2129
  function $mol_run_async({ dir, timeout, command, env }) {
2113
2130
  const args_raw = typeof command === 'string' ? command.split(' ') : command;
2114
2131
  const [app, ...args] = args_raw;
2132
+ if (!env?.MOL_RUN_ASYNC) {
2133
+ this.$mol_log3_come({
2134
+ place: '$mol_run_sync',
2135
+ message: 'Run',
2136
+ command: args_raw.join(' '),
2137
+ dir: $node.path.relative('', dir),
2138
+ });
2139
+ return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
2140
+ }
2115
2141
  const sub = this.$mol_run_spawn(app, args, {
2116
2142
  shell: true,
2117
2143
  cwd: dir,
@@ -7074,85 +7100,6 @@ var $;
7074
7100
  });
7075
7101
  })($ || ($ = {}));
7076
7102
 
7077
- ;
7078
- "use strict";
7079
- var $;
7080
- (function ($) {
7081
- $mol_test({
7082
- 'auto name'() {
7083
- class Invalid extends $mol_error_mix {
7084
- }
7085
- const mix = new Invalid('foo');
7086
- $mol_assert_equal(mix.name, 'Invalid_Error');
7087
- },
7088
- 'simpe mix'() {
7089
- const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
7090
- $mol_assert_equal(mix.message, 'foo');
7091
- $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
7092
- },
7093
- 'provide additional info'() {
7094
- class Invalid extends $mol_error_mix {
7095
- }
7096
- const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
7097
- const hints = [];
7098
- if (mix instanceof $mol_error_mix) {
7099
- for (const er of mix.errors) {
7100
- if (er instanceof Invalid) {
7101
- hints.push(er.cause?.hint ?? '');
7102
- }
7103
- }
7104
- }
7105
- $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
7106
- },
7107
- });
7108
- })($ || ($ = {}));
7109
-
7110
- ;
7111
- "use strict";
7112
- var $;
7113
- (function ($_1) {
7114
- $mol_test({
7115
- 'test types'($) {
7116
- class A {
7117
- static a() {
7118
- return Promise.resolve('');
7119
- }
7120
- static b() {
7121
- return $mol_wire_sync(this).a();
7122
- }
7123
- }
7124
- },
7125
- });
7126
- })($ || ($ = {}));
7127
-
7128
- ;
7129
- "use strict";
7130
- var $;
7131
- (function ($_1) {
7132
- $mol_test({
7133
- async 'exec timeout auto kill child process'($) {
7134
- let close_mock = () => { };
7135
- const context_mock = $.$mol_ambient({
7136
- $mol_run_spawn: () => ({
7137
- on(name, cb) {
7138
- if (name === 'exit')
7139
- close_mock = cb;
7140
- },
7141
- kill() { close_mock(); }
7142
- })
7143
- });
7144
- let message = '';
7145
- try {
7146
- const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
7147
- }
7148
- catch (e) {
7149
- message = e.message;
7150
- }
7151
- $mol_assert_equal(message, 'Run error, timeout');
7152
- }
7153
- });
7154
- })($ || ($ = {}));
7155
-
7156
7103
  ;
7157
7104
  "use strict";
7158
7105
  var $;
@@ -7400,6 +7347,39 @@ var $;
7400
7347
  });
7401
7348
  })($ || ($ = {}));
7402
7349
 
7350
+ ;
7351
+ "use strict";
7352
+ var $;
7353
+ (function ($) {
7354
+ $mol_test({
7355
+ 'auto name'() {
7356
+ class Invalid extends $mol_error_mix {
7357
+ }
7358
+ const mix = new Invalid('foo');
7359
+ $mol_assert_equal(mix.name, 'Invalid_Error');
7360
+ },
7361
+ 'simpe mix'() {
7362
+ const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
7363
+ $mol_assert_equal(mix.message, 'foo');
7364
+ $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
7365
+ },
7366
+ 'provide additional info'() {
7367
+ class Invalid extends $mol_error_mix {
7368
+ }
7369
+ const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
7370
+ const hints = [];
7371
+ if (mix instanceof $mol_error_mix) {
7372
+ for (const er of mix.errors) {
7373
+ if (er instanceof Invalid) {
7374
+ hints.push(er.cause?.hint ?? '');
7375
+ }
7376
+ }
7377
+ }
7378
+ $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
7379
+ },
7380
+ });
7381
+ })($ || ($ = {}));
7382
+
7403
7383
  ;
7404
7384
  "use strict";
7405
7385
  var $;
@@ -7587,6 +7567,112 @@ var $;
7587
7567
  });
7588
7568
  })($ || ($ = {}));
7589
7569
 
7570
+ ;
7571
+ "use strict";
7572
+ var $;
7573
+ (function ($_1) {
7574
+ $mol_test({
7575
+ 'test types'($) {
7576
+ class A {
7577
+ static a() {
7578
+ return '';
7579
+ }
7580
+ static b() {
7581
+ return $mol_wire_async(this).a();
7582
+ }
7583
+ }
7584
+ },
7585
+ async 'Latest method calls wins'($) {
7586
+ class NameLogger extends $mol_object2 {
7587
+ static $ = $;
7588
+ static first = [];
7589
+ static last = [];
7590
+ static send(next) {
7591
+ $mol_wire_sync(this.first).push(next);
7592
+ this.$.$mol_wait_timeout(0);
7593
+ this.last.push(next);
7594
+ }
7595
+ }
7596
+ const name = $mol_wire_async(NameLogger).send;
7597
+ name('john');
7598
+ const promise = name('jin');
7599
+ $.$mol_after_mock_warp();
7600
+ await promise;
7601
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
7602
+ $mol_assert_like(NameLogger.last, ['jin']);
7603
+ },
7604
+ async 'Latest function calls wins'($) {
7605
+ const first = [];
7606
+ const last = [];
7607
+ function send_name(next) {
7608
+ $mol_wire_sync(first).push(next);
7609
+ $.$mol_wait_timeout(0);
7610
+ last.push(next);
7611
+ }
7612
+ const name = $mol_wire_async(send_name);
7613
+ name('john');
7614
+ const promise = name('jin');
7615
+ $.$mol_after_mock_warp();
7616
+ await promise;
7617
+ $mol_assert_like(first, ['john', 'jin']);
7618
+ $mol_assert_like(last, ['jin']);
7619
+ },
7620
+ });
7621
+ })($ || ($ = {}));
7622
+
7623
+ ;
7624
+ "use strict";
7625
+ var $;
7626
+ (function ($_1) {
7627
+ $mol_test({
7628
+ 'test types'($) {
7629
+ class A {
7630
+ static a() {
7631
+ return Promise.resolve('');
7632
+ }
7633
+ static b() {
7634
+ return $mol_wire_sync(this).a();
7635
+ }
7636
+ }
7637
+ },
7638
+ async 'test method from host'($) {
7639
+ let count = 0;
7640
+ class A {
7641
+ static a() {
7642
+ return $mol_wire_sync(this).b();
7643
+ }
7644
+ static b() { return Promise.resolve(++count); }
7645
+ }
7646
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
7647
+ },
7648
+ async 'test function'($) {
7649
+ let count = 0;
7650
+ class A {
7651
+ static a() {
7652
+ return $mol_wire_sync(this.b)();
7653
+ }
7654
+ static b() { return Promise.resolve(++count); }
7655
+ }
7656
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
7657
+ },
7658
+ async 'test construct itself'($) {
7659
+ class A {
7660
+ static instances = [];
7661
+ static a() {
7662
+ const a = new ($mol_wire_sync(A))();
7663
+ this.instances.push(a);
7664
+ $mol_wire_sync(this).b();
7665
+ }
7666
+ static b() { return Promise.resolve(); }
7667
+ }
7668
+ await $mol_wire_async(A).a();
7669
+ $mol_assert_equal(A.instances.length, 2);
7670
+ $mol_assert_equal(A.instances[0] instanceof A);
7671
+ $mol_assert_equal(A.instances[0], A.instances[1]);
7672
+ }
7673
+ });
7674
+ })($ || ($ = {}));
7675
+
7590
7676
  ;
7591
7677
  "use strict";
7592
7678
  var $;
@@ -7638,51 +7724,26 @@ var $;
7638
7724
  var $;
7639
7725
  (function ($_1) {
7640
7726
  $mol_test({
7641
- 'test types'($) {
7642
- class A {
7643
- static a() {
7644
- return '';
7645
- }
7646
- static b() {
7647
- return $mol_wire_async(this).a();
7648
- }
7649
- }
7650
- },
7651
- async 'Latest method calls wins'($) {
7652
- class NameLogger extends $mol_object2 {
7653
- static $ = $;
7654
- static first = [];
7655
- static last = [];
7656
- static send(next) {
7657
- $mol_wire_sync(this.first).push(next);
7658
- this.$.$mol_wait_timeout(0);
7659
- this.last.push(next);
7660
- }
7727
+ async 'exec timeout auto kill child process'($) {
7728
+ let close_mock = () => { };
7729
+ const context_mock = $.$mol_ambient({
7730
+ $mol_run_spawn: () => ({
7731
+ on(name, cb) {
7732
+ if (name === 'exit')
7733
+ close_mock = cb;
7734
+ },
7735
+ kill() { close_mock(); }
7736
+ })
7737
+ });
7738
+ let message = '';
7739
+ try {
7740
+ const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
7661
7741
  }
7662
- const name = $mol_wire_async(NameLogger).send;
7663
- name('john');
7664
- const promise = name('jin');
7665
- $.$mol_after_mock_warp();
7666
- await promise;
7667
- $mol_assert_like(NameLogger.first, ['john', 'jin']);
7668
- $mol_assert_like(NameLogger.last, ['jin']);
7669
- },
7670
- async 'Latest function calls wins'($) {
7671
- const first = [];
7672
- const last = [];
7673
- function send_name(next) {
7674
- $mol_wire_sync(first).push(next);
7675
- $.$mol_wait_timeout(0);
7676
- last.push(next);
7742
+ catch (e) {
7743
+ message = e.message;
7677
7744
  }
7678
- const name = $mol_wire_async(send_name);
7679
- name('john');
7680
- const promise = name('jin');
7681
- $.$mol_after_mock_warp();
7682
- await promise;
7683
- $mol_assert_like(first, ['john', 'jin']);
7684
- $mol_assert_like(last, ['jin']);
7685
- },
7745
+ $mol_assert_equal(message, 'Run error, timeout');
7746
+ }
7686
7747
  });
7687
7748
  })($ || ($ = {}));
7688
7749