mol_crypto_lib 0.1.1289 → 0.1.1290
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.d.ts +7 -5
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +31 -5
- package/node.js.map +1 -1
- package/node.mjs +31 -5
- package/node.test.js +93 -32
- package/node.test.js.map +1 -1
- package/package.json +2 -2
package/node.mjs
CHANGED
@@ -122,7 +122,11 @@ var $node = new Proxy({ require }, {
|
|
122
122
|
try {
|
123
123
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
124
124
|
}
|
125
|
-
catch {
|
125
|
+
catch (e) {
|
126
|
+
if ($$.$mol_fail_catch(e)) {
|
127
|
+
$$.$mol_fail_log(e);
|
128
|
+
}
|
129
|
+
}
|
126
130
|
break;
|
127
131
|
}
|
128
132
|
else {
|
@@ -133,7 +137,7 @@ var $node = new Proxy({ require }, {
|
|
133
137
|
return target.require(name);
|
134
138
|
}
|
135
139
|
catch (error) {
|
136
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
140
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
137
141
|
const module = cache.get(name);
|
138
142
|
if (module)
|
139
143
|
return module;
|
@@ -1703,10 +1707,19 @@ var $;
|
|
1703
1707
|
"use strict";
|
1704
1708
|
var $;
|
1705
1709
|
(function ($) {
|
1710
|
+
const factories = new WeakMap();
|
1711
|
+
function factory(val) {
|
1712
|
+
let make = factories.get(val);
|
1713
|
+
if (make)
|
1714
|
+
return make;
|
1715
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
1716
|
+
factories.set(val, make);
|
1717
|
+
return make;
|
1718
|
+
}
|
1706
1719
|
function $mol_wire_sync(obj) {
|
1707
1720
|
return new Proxy(obj, {
|
1708
1721
|
get(obj, field) {
|
1709
|
-
|
1722
|
+
let val = obj[field];
|
1710
1723
|
if (typeof val !== 'function')
|
1711
1724
|
return val;
|
1712
1725
|
const temp = $mol_wire_task.getter(val);
|
@@ -1715,10 +1728,13 @@ var $;
|
|
1715
1728
|
return fiber.sync();
|
1716
1729
|
};
|
1717
1730
|
},
|
1731
|
+
construct(obj, args) {
|
1732
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
1733
|
+
return temp(obj, args).sync();
|
1734
|
+
},
|
1718
1735
|
apply(obj, self, args) {
|
1719
1736
|
const temp = $mol_wire_task.getter(obj);
|
1720
|
-
|
1721
|
-
return fiber.sync();
|
1737
|
+
return temp(self, args).sync();
|
1722
1738
|
},
|
1723
1739
|
});
|
1724
1740
|
}
|
@@ -1734,9 +1750,19 @@ var $;
|
|
1734
1750
|
$.$mol_run_error = $mol_run_error;
|
1735
1751
|
const child_process = $node['child_process'];
|
1736
1752
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
1753
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
1737
1754
|
function $mol_run_async({ dir, timeout, command, env }) {
|
1738
1755
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
1739
1756
|
const [app, ...args] = args_raw;
|
1757
|
+
if (!env?.MOL_RUN_ASYNC) {
|
1758
|
+
this.$mol_log3_come({
|
1759
|
+
place: '$mol_run_sync',
|
1760
|
+
message: 'Run',
|
1761
|
+
command: args_raw.join(' '),
|
1762
|
+
dir: $node.path.relative('', dir),
|
1763
|
+
});
|
1764
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
1765
|
+
}
|
1740
1766
|
const sub = this.$mol_run_spawn(app, args, {
|
1741
1767
|
shell: true,
|
1742
1768
|
cwd: dir,
|
package/node.test.js
CHANGED
@@ -113,7 +113,11 @@ var $node = new Proxy({ require }, {
|
|
113
113
|
try {
|
114
114
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
115
115
|
}
|
116
|
-
catch {
|
116
|
+
catch (e) {
|
117
|
+
if ($$.$mol_fail_catch(e)) {
|
118
|
+
$$.$mol_fail_log(e);
|
119
|
+
}
|
120
|
+
}
|
117
121
|
break;
|
118
122
|
}
|
119
123
|
else {
|
@@ -124,7 +128,7 @@ var $node = new Proxy({ require }, {
|
|
124
128
|
return target.require(name);
|
125
129
|
}
|
126
130
|
catch (error) {
|
127
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
131
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
128
132
|
const module = cache.get(name);
|
129
133
|
if (module)
|
130
134
|
return module;
|
@@ -1694,10 +1698,19 @@ var $;
|
|
1694
1698
|
"use strict";
|
1695
1699
|
var $;
|
1696
1700
|
(function ($) {
|
1701
|
+
const factories = new WeakMap();
|
1702
|
+
function factory(val) {
|
1703
|
+
let make = factories.get(val);
|
1704
|
+
if (make)
|
1705
|
+
return make;
|
1706
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
1707
|
+
factories.set(val, make);
|
1708
|
+
return make;
|
1709
|
+
}
|
1697
1710
|
function $mol_wire_sync(obj) {
|
1698
1711
|
return new Proxy(obj, {
|
1699
1712
|
get(obj, field) {
|
1700
|
-
|
1713
|
+
let val = obj[field];
|
1701
1714
|
if (typeof val !== 'function')
|
1702
1715
|
return val;
|
1703
1716
|
const temp = $mol_wire_task.getter(val);
|
@@ -1706,10 +1719,13 @@ var $;
|
|
1706
1719
|
return fiber.sync();
|
1707
1720
|
};
|
1708
1721
|
},
|
1722
|
+
construct(obj, args) {
|
1723
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
1724
|
+
return temp(obj, args).sync();
|
1725
|
+
},
|
1709
1726
|
apply(obj, self, args) {
|
1710
1727
|
const temp = $mol_wire_task.getter(obj);
|
1711
|
-
|
1712
|
-
return fiber.sync();
|
1728
|
+
return temp(self, args).sync();
|
1713
1729
|
},
|
1714
1730
|
});
|
1715
1731
|
}
|
@@ -1725,9 +1741,19 @@ var $;
|
|
1725
1741
|
$.$mol_run_error = $mol_run_error;
|
1726
1742
|
const child_process = $node['child_process'];
|
1727
1743
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
1744
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
1728
1745
|
function $mol_run_async({ dir, timeout, command, env }) {
|
1729
1746
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
1730
1747
|
const [app, ...args] = args_raw;
|
1748
|
+
if (!env?.MOL_RUN_ASYNC) {
|
1749
|
+
this.$mol_log3_come({
|
1750
|
+
place: '$mol_run_sync',
|
1751
|
+
message: 'Run',
|
1752
|
+
command: args_raw.join(' '),
|
1753
|
+
dir: $node.path.relative('', dir),
|
1754
|
+
});
|
1755
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
1756
|
+
}
|
1731
1757
|
const sub = this.$mol_run_spawn(app, args, {
|
1732
1758
|
shell: true,
|
1733
1759
|
cwd: dir,
|
@@ -3854,32 +3880,6 @@ var $;
|
|
3854
3880
|
});
|
3855
3881
|
})($ || ($ = {}));
|
3856
3882
|
|
3857
|
-
;
|
3858
|
-
"use strict";
|
3859
|
-
var $;
|
3860
|
-
(function ($) {
|
3861
|
-
function $mol_wire_method(host, field, descr) {
|
3862
|
-
if (!descr)
|
3863
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
3864
|
-
const orig = descr?.value ?? host[field];
|
3865
|
-
const sup = Reflect.getPrototypeOf(host);
|
3866
|
-
if (typeof sup[field] === 'function') {
|
3867
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
3868
|
-
}
|
3869
|
-
const temp = $mol_wire_task.getter(orig);
|
3870
|
-
const value = function (...args) {
|
3871
|
-
const fiber = temp(this ?? null, args);
|
3872
|
-
return fiber.sync();
|
3873
|
-
};
|
3874
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
3875
|
-
Object.assign(value, { orig });
|
3876
|
-
const descr2 = { ...descr, value };
|
3877
|
-
Reflect.defineProperty(host, field, descr2);
|
3878
|
-
return descr2;
|
3879
|
-
}
|
3880
|
-
$.$mol_wire_method = $mol_wire_method;
|
3881
|
-
})($ || ($ = {}));
|
3882
|
-
|
3883
3883
|
;
|
3884
3884
|
"use strict";
|
3885
3885
|
var $;
|
@@ -3963,6 +3963,32 @@ var $;
|
|
3963
3963
|
});
|
3964
3964
|
})($ || ($ = {}));
|
3965
3965
|
|
3966
|
+
;
|
3967
|
+
"use strict";
|
3968
|
+
var $;
|
3969
|
+
(function ($) {
|
3970
|
+
function $mol_wire_method(host, field, descr) {
|
3971
|
+
if (!descr)
|
3972
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
3973
|
+
const orig = descr?.value ?? host[field];
|
3974
|
+
const sup = Reflect.getPrototypeOf(host);
|
3975
|
+
if (typeof sup[field] === 'function') {
|
3976
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
3977
|
+
}
|
3978
|
+
const temp = $mol_wire_task.getter(orig);
|
3979
|
+
const value = function (...args) {
|
3980
|
+
const fiber = temp(this ?? null, args);
|
3981
|
+
return fiber.sync();
|
3982
|
+
};
|
3983
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
3984
|
+
Object.assign(value, { orig });
|
3985
|
+
const descr2 = { ...descr, value };
|
3986
|
+
Reflect.defineProperty(host, field, descr2);
|
3987
|
+
return descr2;
|
3988
|
+
}
|
3989
|
+
$.$mol_wire_method = $mol_wire_method;
|
3990
|
+
})($ || ($ = {}));
|
3991
|
+
|
3966
3992
|
;
|
3967
3993
|
"use strict";
|
3968
3994
|
var $;
|
@@ -3978,6 +4004,41 @@ var $;
|
|
3978
4004
|
}
|
3979
4005
|
}
|
3980
4006
|
},
|
4007
|
+
async 'test method from host'($) {
|
4008
|
+
let count = 0;
|
4009
|
+
class A {
|
4010
|
+
static a() {
|
4011
|
+
return $mol_wire_sync(this).b();
|
4012
|
+
}
|
4013
|
+
static b() { return Promise.resolve(++count); }
|
4014
|
+
}
|
4015
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
4016
|
+
},
|
4017
|
+
async 'test function'($) {
|
4018
|
+
let count = 0;
|
4019
|
+
class A {
|
4020
|
+
static a() {
|
4021
|
+
return $mol_wire_sync(this.b)();
|
4022
|
+
}
|
4023
|
+
static b() { return Promise.resolve(++count); }
|
4024
|
+
}
|
4025
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
4026
|
+
},
|
4027
|
+
async 'test construct itself'($) {
|
4028
|
+
class A {
|
4029
|
+
static instances = [];
|
4030
|
+
static a() {
|
4031
|
+
const a = new ($mol_wire_sync(A))();
|
4032
|
+
this.instances.push(a);
|
4033
|
+
$mol_wire_sync(this).b();
|
4034
|
+
}
|
4035
|
+
static b() { return Promise.resolve(); }
|
4036
|
+
}
|
4037
|
+
await $mol_wire_async(A).a();
|
4038
|
+
$mol_assert_equal(A.instances.length, 2);
|
4039
|
+
$mol_assert_equal(A.instances[0] instanceof A);
|
4040
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
4041
|
+
}
|
3981
4042
|
});
|
3982
4043
|
})($ || ($ = {}));
|
3983
4044
|
|
@@ -4066,7 +4127,7 @@ var $;
|
|
4066
4127
|
});
|
4067
4128
|
let message = '';
|
4068
4129
|
try {
|
4069
|
-
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
|
4130
|
+
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
|
4070
4131
|
}
|
4071
4132
|
catch (e) {
|
4072
4133
|
message = e.message;
|