mam 1.11.809 → 1.11.811

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
@@ -2448,13 +2448,7 @@ var $node = new Proxy({ require }, {
2448
2448
  target.require.resolve(name);
2449
2449
  }
2450
2450
  catch {
2451
- try {
2452
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2453
- }
2454
- catch (e) {
2455
- if ($$.$mol_promise_like(e))
2456
- $$.$mol_fail_hidden(e);
2457
- }
2451
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2458
2452
  try {
2459
2453
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
2460
2454
  }
@@ -2463,6 +2457,11 @@ var $node = new Proxy({ require }, {
2463
2457
  $$.$mol_fail_hidden(e);
2464
2458
  $$.$mol_fail_log(e);
2465
2459
  }
2460
+ const mam_node_modules = target.require('node:path').join(process.cwd(), 'node_modules');
2461
+ if (!process.env.NODE_PATH?.includes(mam_node_modules)) {
2462
+ process.env.NODE_PATH = `${mam_node_modules}${process.env.NODE_PATH ? `:${process.env.NODE_PATH}` : ''}`;
2463
+ target.require('node:module').Module._initPaths();
2464
+ }
2466
2465
  }
2467
2466
  return target.require(name);
2468
2467
  },
package/node.test.js CHANGED
@@ -2439,13 +2439,7 @@ var $node = new Proxy({ require }, {
2439
2439
  target.require.resolve(name);
2440
2440
  }
2441
2441
  catch {
2442
- try {
2443
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2444
- }
2445
- catch (e) {
2446
- if ($$.$mol_promise_like(e))
2447
- $$.$mol_fail_hidden(e);
2448
- }
2442
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2449
2443
  try {
2450
2444
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
2451
2445
  }
@@ -2454,6 +2448,11 @@ var $node = new Proxy({ require }, {
2454
2448
  $$.$mol_fail_hidden(e);
2455
2449
  $$.$mol_fail_log(e);
2456
2450
  }
2451
+ const mam_node_modules = target.require('node:path').join(process.cwd(), 'node_modules');
2452
+ if (!process.env.NODE_PATH?.includes(mam_node_modules)) {
2453
+ process.env.NODE_PATH = `${mam_node_modules}${process.env.NODE_PATH ? `:${process.env.NODE_PATH}` : ''}`;
2454
+ target.require('node:module').Module._initPaths();
2455
+ }
2457
2456
  }
2458
2457
  return target.require(name);
2459
2458
  },
@@ -7965,6 +7964,215 @@ var $;
7965
7964
  $.$mol_test_complete = $mol_test_complete;
7966
7965
  })($ || ($ = {}));
7967
7966
 
7967
+ ;
7968
+ "use strict";
7969
+ var $;
7970
+ (function ($_1) {
7971
+ $mol_test({
7972
+ 'FQN of anon function'($) {
7973
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
7974
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
7975
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
7976
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
7977
+ },
7978
+ });
7979
+ })($ || ($ = {}));
7980
+
7981
+ ;
7982
+ "use strict";
7983
+ var $;
7984
+ (function ($) {
7985
+ $mol_test({
7986
+ 'auto name'() {
7987
+ class Invalid extends $mol_error_mix {
7988
+ }
7989
+ const mix = new Invalid('foo');
7990
+ $mol_assert_equal(mix.name, 'Invalid_Error');
7991
+ },
7992
+ 'simpe mix'() {
7993
+ const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
7994
+ $mol_assert_equal(mix.message, 'foo');
7995
+ $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
7996
+ },
7997
+ 'provide additional info'() {
7998
+ class Invalid extends $mol_error_mix {
7999
+ }
8000
+ 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' }));
8001
+ const hints = [];
8002
+ if (mix instanceof $mol_error_mix) {
8003
+ for (const er of mix.errors) {
8004
+ if (er instanceof Invalid) {
8005
+ hints.push(er.cause?.hint ?? '');
8006
+ }
8007
+ }
8008
+ }
8009
+ $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
8010
+ },
8011
+ });
8012
+ })($ || ($ = {}));
8013
+
8014
+ ;
8015
+ "use strict";
8016
+
8017
+ ;
8018
+ "use strict";
8019
+
8020
+ ;
8021
+ "use strict";
8022
+
8023
+ ;
8024
+ "use strict";
8025
+
8026
+ ;
8027
+ "use strict";
8028
+
8029
+ ;
8030
+ "use strict";
8031
+ var $;
8032
+ (function ($_1) {
8033
+ $mol_test({
8034
+ 'init with overload'() {
8035
+ class X extends $mol_object {
8036
+ foo() {
8037
+ return 1;
8038
+ }
8039
+ }
8040
+ var x = X.make({
8041
+ foo: () => 2,
8042
+ });
8043
+ $mol_assert_equal(x.foo(), 2);
8044
+ },
8045
+ 'Context in instance inherits from class'($) {
8046
+ const custom = $.$mol_ambient({});
8047
+ class X extends $.$mol_object {
8048
+ static $ = custom;
8049
+ }
8050
+ $mol_assert_equal(new X().$, custom);
8051
+ },
8052
+ });
8053
+ })($ || ($ = {}));
8054
+
8055
+ ;
8056
+ "use strict";
8057
+ var $;
8058
+ (function ($_1) {
8059
+ $mol_test({
8060
+ 'test types'($) {
8061
+ class A {
8062
+ static a() {
8063
+ return Promise.resolve('');
8064
+ }
8065
+ static b() {
8066
+ return $mol_wire_sync(this).a();
8067
+ }
8068
+ }
8069
+ },
8070
+ async 'test method from host'($) {
8071
+ let count = 0;
8072
+ class A {
8073
+ static a() {
8074
+ return $mol_wire_sync(this).b();
8075
+ }
8076
+ static b() { return Promise.resolve(++count); }
8077
+ }
8078
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
8079
+ },
8080
+ async 'test function'($) {
8081
+ let count = 0;
8082
+ class A {
8083
+ static a() {
8084
+ return $mol_wire_sync(this.b)();
8085
+ }
8086
+ static b() { return Promise.resolve(++count); }
8087
+ }
8088
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
8089
+ },
8090
+ async 'test construct itself'($) {
8091
+ class A {
8092
+ static instances = [];
8093
+ static a() {
8094
+ const a = new ($mol_wire_sync(A))();
8095
+ this.instances.push(a);
8096
+ $mol_wire_sync(this).b();
8097
+ }
8098
+ static b() { return Promise.resolve(); }
8099
+ }
8100
+ await $mol_wire_async(A).a();
8101
+ $mol_assert_equal(A.instances.length, 2);
8102
+ $mol_assert_equal(A.instances[0] instanceof A, true);
8103
+ $mol_assert_equal(A.instances[0], A.instances[1]);
8104
+ }
8105
+ });
8106
+ })($ || ($ = {}));
8107
+
8108
+ ;
8109
+ "use strict";
8110
+ var $;
8111
+ (function ($_1) {
8112
+ $mol_test_mocks.push($ => {
8113
+ $.$mol_log3_come = () => { };
8114
+ $.$mol_log3_done = () => { };
8115
+ $.$mol_log3_fail = () => { };
8116
+ $.$mol_log3_warn = () => { };
8117
+ $.$mol_log3_rise = () => { };
8118
+ $.$mol_log3_area = () => () => { };
8119
+ });
8120
+ })($ || ($ = {}));
8121
+
8122
+ ;
8123
+ "use strict";
8124
+ var $;
8125
+ (function ($_1) {
8126
+ $mol_test({
8127
+ async 'exec timeout auto kill child process'($) {
8128
+ let close_mock = () => { };
8129
+ const error_message = 'Run error, timeout';
8130
+ function mol_run_spawn_sync_mock() {
8131
+ return {
8132
+ output: [],
8133
+ stdout: error_message,
8134
+ stderr: '',
8135
+ status: 0,
8136
+ signal: null,
8137
+ pid: 123,
8138
+ };
8139
+ }
8140
+ function mol_run_spawn_mock() {
8141
+ return {
8142
+ on(name, cb) {
8143
+ if (name === 'exit')
8144
+ close_mock = cb;
8145
+ },
8146
+ kill() { close_mock(); }
8147
+ };
8148
+ }
8149
+ const context_mock = $.$mol_ambient({
8150
+ $mol_run_spawn_sync: mol_run_spawn_sync_mock,
8151
+ $mol_run_spawn: mol_run_spawn_mock
8152
+ });
8153
+ class $mol_run_mock extends $mol_run {
8154
+ static get $() { return context_mock; }
8155
+ static async_enabled() {
8156
+ return true;
8157
+ }
8158
+ }
8159
+ let message = '';
8160
+ try {
8161
+ const res = await $mol_wire_async($mol_run_mock).spawn({
8162
+ command: 'sleep 10',
8163
+ dir: '.',
8164
+ timeout: 10,
8165
+ env: { 'MOL_RUN_ASYNC': '1' }
8166
+ });
8167
+ }
8168
+ catch (e) {
8169
+ message = e.message;
8170
+ }
8171
+ $mol_assert_equal(message, error_message);
8172
+ }
8173
+ });
8174
+ })($ || ($ = {}));
8175
+
7968
8176
  ;
7969
8177
  "use strict";
7970
8178
  var $;
@@ -8026,15 +8234,6 @@ var $;
8026
8234
  ;
8027
8235
  "use strict";
8028
8236
 
8029
- ;
8030
- "use strict";
8031
-
8032
- ;
8033
- "use strict";
8034
-
8035
- ;
8036
- "use strict";
8037
-
8038
8237
  ;
8039
8238
  "use strict";
8040
8239
  var $;
@@ -8791,45 +8990,11 @@ var $;
8791
8990
  ;
8792
8991
  "use strict";
8793
8992
  var $;
8794
- (function ($_1) {
8795
- $mol_test_mocks.push($ => {
8796
- $.$mol_log3_come = () => { };
8797
- $.$mol_log3_done = () => { };
8798
- $.$mol_log3_fail = () => { };
8799
- $.$mol_log3_warn = () => { };
8800
- $.$mol_log3_rise = () => { };
8801
- $.$mol_log3_area = () => () => { };
8802
- });
8803
- })($ || ($ = {}));
8804
-
8805
- ;
8806
- "use strict";
8807
-
8808
- ;
8809
- "use strict";
8810
-
8811
- ;
8812
- "use strict";
8813
- var $;
8814
- (function ($_1) {
8993
+ (function ($) {
8815
8994
  $mol_test({
8816
- 'FQN of anon function'($) {
8817
- const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
8818
- $mol_assert_equal($$.$mol_func_name_test.name, '');
8819
- $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
8820
- $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
8821
- },
8822
- });
8823
- })($ || ($ = {}));
8824
-
8825
- ;
8826
- "use strict";
8827
- var $;
8828
- (function ($) {
8829
- $mol_test({
8830
- 'get'() {
8831
- const proxy = $mol_delegate({}, () => ({ foo: 777 }));
8832
- $mol_assert_equal(proxy.foo, 777);
8995
+ 'get'() {
8996
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
8997
+ $mol_assert_equal(proxy.foo, 777);
8833
8998
  },
8834
8999
  'has'() {
8835
9000
  const proxy = $mol_delegate({}, () => ({ foo: 777 }));
@@ -9335,88 +9500,6 @@ var $;
9335
9500
  });
9336
9501
  })($ || ($ = {}));
9337
9502
 
9338
- ;
9339
- "use strict";
9340
- var $;
9341
- (function ($_1) {
9342
- $mol_test({
9343
- 'test types'($) {
9344
- class A {
9345
- static a() {
9346
- return '';
9347
- }
9348
- static b() {
9349
- return $mol_wire_async(this).a();
9350
- }
9351
- }
9352
- },
9353
- async 'Latest method calls wins'($) {
9354
- class NameLogger extends $mol_object2 {
9355
- static $ = $;
9356
- static first = [];
9357
- static last = [];
9358
- static send(next) {
9359
- $mol_wire_sync(this.first).push(next);
9360
- $$.$mol_wait_timeout(0);
9361
- this.last.push(next);
9362
- }
9363
- }
9364
- const name = $mol_wire_async(NameLogger).send;
9365
- name('john');
9366
- const promise = name('jin');
9367
- $.$mol_after_mock_warp();
9368
- await promise;
9369
- $mol_assert_equal(NameLogger.first, ['john', 'jin']);
9370
- $mol_assert_equal(NameLogger.last, ['jin']);
9371
- },
9372
- async 'Latest function calls wins'($) {
9373
- const first = [];
9374
- const last = [];
9375
- function send_name(next) {
9376
- $mol_wire_sync(first).push(next);
9377
- $$.$mol_wait_timeout(0);
9378
- last.push(next);
9379
- }
9380
- const name = $mol_wire_async(send_name);
9381
- name('john');
9382
- const promise = name('jin');
9383
- $.$mol_after_mock_warp();
9384
- await promise;
9385
- $mol_assert_equal(first, ['john', 'jin']);
9386
- $mol_assert_equal(last, ['jin']);
9387
- },
9388
- });
9389
- })($ || ($ = {}));
9390
-
9391
- ;
9392
- "use strict";
9393
- var $;
9394
- (function ($_1) {
9395
- $mol_test({
9396
- 'init with overload'() {
9397
- class X extends $mol_object {
9398
- foo() {
9399
- return 1;
9400
- }
9401
- }
9402
- var x = X.make({
9403
- foo: () => 2,
9404
- });
9405
- $mol_assert_equal(x.foo(), 2);
9406
- },
9407
- 'Context in instance inherits from class'($) {
9408
- const custom = $.$mol_ambient({});
9409
- class X extends $.$mol_object {
9410
- static $ = custom;
9411
- }
9412
- $mol_assert_equal(new X().$, custom);
9413
- },
9414
- });
9415
- })($ || ($ = {}));
9416
-
9417
- ;
9418
- "use strict";
9419
-
9420
9503
  ;
9421
9504
  "use strict";
9422
9505
  var $;
@@ -9448,59 +9531,6 @@ var $;
9448
9531
  });
9449
9532
  })($ || ($ = {}));
9450
9533
 
9451
- ;
9452
- "use strict";
9453
- var $;
9454
- (function ($_1) {
9455
- $mol_test({
9456
- 'test types'($) {
9457
- class A {
9458
- static a() {
9459
- return Promise.resolve('');
9460
- }
9461
- static b() {
9462
- return $mol_wire_sync(this).a();
9463
- }
9464
- }
9465
- },
9466
- async 'test method from host'($) {
9467
- let count = 0;
9468
- class A {
9469
- static a() {
9470
- return $mol_wire_sync(this).b();
9471
- }
9472
- static b() { return Promise.resolve(++count); }
9473
- }
9474
- $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
9475
- },
9476
- async 'test function'($) {
9477
- let count = 0;
9478
- class A {
9479
- static a() {
9480
- return $mol_wire_sync(this.b)();
9481
- }
9482
- static b() { return Promise.resolve(++count); }
9483
- }
9484
- $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
9485
- },
9486
- async 'test construct itself'($) {
9487
- class A {
9488
- static instances = [];
9489
- static a() {
9490
- const a = new ($mol_wire_sync(A))();
9491
- this.instances.push(a);
9492
- $mol_wire_sync(this).b();
9493
- }
9494
- static b() { return Promise.resolve(); }
9495
- }
9496
- await $mol_wire_async(A).a();
9497
- $mol_assert_equal(A.instances.length, 2);
9498
- $mol_assert_equal(A.instances[0] instanceof A, true);
9499
- $mol_assert_equal(A.instances[0], A.instances[1]);
9500
- }
9501
- });
9502
- })($ || ($ = {}));
9503
-
9504
9534
  ;
9505
9535
  "use strict";
9506
9536
  var $;
@@ -9594,6 +9624,62 @@ var $;
9594
9624
  })($$ = $_1.$$ || ($_1.$$ = {}));
9595
9625
  })($ || ($ = {}));
9596
9626
 
9627
+ ;
9628
+ "use strict";
9629
+ var $;
9630
+ (function ($_1) {
9631
+ $mol_test({
9632
+ 'test types'($) {
9633
+ class A {
9634
+ static a() {
9635
+ return '';
9636
+ }
9637
+ static b() {
9638
+ return $mol_wire_async(this).a();
9639
+ }
9640
+ }
9641
+ },
9642
+ async 'Latest method calls wins'($) {
9643
+ class NameLogger extends $mol_object2 {
9644
+ static $ = $;
9645
+ static first = [];
9646
+ static last = [];
9647
+ static send(next) {
9648
+ $mol_wire_sync(this.first).push(next);
9649
+ $$.$mol_wait_timeout(0);
9650
+ this.last.push(next);
9651
+ }
9652
+ }
9653
+ const name = $mol_wire_async(NameLogger).send;
9654
+ name('john');
9655
+ const promise = name('jin');
9656
+ $.$mol_after_mock_warp();
9657
+ await promise;
9658
+ $mol_assert_equal(NameLogger.first, ['john', 'jin']);
9659
+ $mol_assert_equal(NameLogger.last, ['jin']);
9660
+ },
9661
+ async 'Latest function calls wins'($) {
9662
+ const first = [];
9663
+ const last = [];
9664
+ function send_name(next) {
9665
+ $mol_wire_sync(first).push(next);
9666
+ $$.$mol_wait_timeout(0);
9667
+ last.push(next);
9668
+ }
9669
+ const name = $mol_wire_async(send_name);
9670
+ name('john');
9671
+ const promise = name('jin');
9672
+ $.$mol_after_mock_warp();
9673
+ await promise;
9674
+ $mol_assert_equal(first, ['john', 'jin']);
9675
+ $mol_assert_equal(last, ['jin']);
9676
+ },
9677
+ });
9678
+ })($ || ($ = {}));
9679
+
9680
+ ;
9681
+ "use strict";
9682
+
9597
9683
  ;
9598
9684
  "use strict";
9599
9685
  var $;
@@ -10278,93 +10364,6 @@ var $;
10278
10364
  });
10279
10365
  })($ || ($ = {}));
10280
10366
 
10281
- ;
10282
- "use strict";
10283
- var $;
10284
- (function ($) {
10285
- $mol_test({
10286
- 'auto name'() {
10287
- class Invalid extends $mol_error_mix {
10288
- }
10289
- const mix = new Invalid('foo');
10290
- $mol_assert_equal(mix.name, 'Invalid_Error');
10291
- },
10292
- 'simpe mix'() {
10293
- const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
10294
- $mol_assert_equal(mix.message, 'foo');
10295
- $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
10296
- },
10297
- 'provide additional info'() {
10298
- class Invalid extends $mol_error_mix {
10299
- }
10300
- 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' }));
10301
- const hints = [];
10302
- if (mix instanceof $mol_error_mix) {
10303
- for (const er of mix.errors) {
10304
- if (er instanceof Invalid) {
10305
- hints.push(er.cause?.hint ?? '');
10306
- }
10307
- }
10308
- }
10309
- $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
10310
- },
10311
- });
10312
- })($ || ($ = {}));
10313
-
10314
- ;
10315
- "use strict";
10316
- var $;
10317
- (function ($_1) {
10318
- $mol_test({
10319
- async 'exec timeout auto kill child process'($) {
10320
- let close_mock = () => { };
10321
- const error_message = 'Run error, timeout';
10322
- function mol_run_spawn_sync_mock() {
10323
- return {
10324
- output: [],
10325
- stdout: error_message,
10326
- stderr: '',
10327
- status: 0,
10328
- signal: null,
10329
- pid: 123,
10330
- };
10331
- }
10332
- function mol_run_spawn_mock() {
10333
- return {
10334
- on(name, cb) {
10335
- if (name === 'exit')
10336
- close_mock = cb;
10337
- },
10338
- kill() { close_mock(); }
10339
- };
10340
- }
10341
- const context_mock = $.$mol_ambient({
10342
- $mol_run_spawn_sync: mol_run_spawn_sync_mock,
10343
- $mol_run_spawn: mol_run_spawn_mock
10344
- });
10345
- class $mol_run_mock extends $mol_run {
10346
- static get $() { return context_mock; }
10347
- static async_enabled() {
10348
- return true;
10349
- }
10350
- }
10351
- let message = '';
10352
- try {
10353
- const res = await $mol_wire_async($mol_run_mock).spawn({
10354
- command: 'sleep 10',
10355
- dir: '.',
10356
- timeout: 10,
10357
- env: { 'MOL_RUN_ASYNC': '1' }
10358
- });
10359
- }
10360
- catch (e) {
10361
- message = e.message;
10362
- }
10363
- $mol_assert_equal(message, error_message);
10364
- }
10365
- });
10366
- })($ || ($ = {}));
10367
-
10368
10367
  ;
10369
10368
  "use strict";
10370
10369