mol_jsx_lib 0.0.1049 → 0.0.1051
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 +67 -6
- package/node.test.js.map +1 -1
- package/package.json +2 -2
- package/web.d.ts +2 -1
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +15 -3
- package/web.js.map +1 -1
- package/web.mjs +15 -3
- package/web.test.js +53 -18
- package/web.test.js.map +1 -1
package/node.mjs
CHANGED
|
@@ -128,7 +128,11 @@ var $node = new Proxy({ require }, {
|
|
|
128
128
|
try {
|
|
129
129
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
130
130
|
}
|
|
131
|
-
catch {
|
|
131
|
+
catch (e) {
|
|
132
|
+
if ($$.$mol_fail_catch(e)) {
|
|
133
|
+
$$.$mol_fail_log(e);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
132
136
|
break;
|
|
133
137
|
}
|
|
134
138
|
else {
|
|
@@ -139,7 +143,7 @@ var $node = new Proxy({ require }, {
|
|
|
139
143
|
return target.require(name);
|
|
140
144
|
}
|
|
141
145
|
catch (error) {
|
|
142
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
146
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
|
143
147
|
const module = cache.get(name);
|
|
144
148
|
if (module)
|
|
145
149
|
return module;
|
|
@@ -1709,10 +1713,19 @@ var $;
|
|
|
1709
1713
|
"use strict";
|
|
1710
1714
|
var $;
|
|
1711
1715
|
(function ($) {
|
|
1716
|
+
const factories = new WeakMap();
|
|
1717
|
+
function factory(val) {
|
|
1718
|
+
let make = factories.get(val);
|
|
1719
|
+
if (make)
|
|
1720
|
+
return make;
|
|
1721
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
1722
|
+
factories.set(val, make);
|
|
1723
|
+
return make;
|
|
1724
|
+
}
|
|
1712
1725
|
function $mol_wire_sync(obj) {
|
|
1713
1726
|
return new Proxy(obj, {
|
|
1714
1727
|
get(obj, field) {
|
|
1715
|
-
|
|
1728
|
+
let val = obj[field];
|
|
1716
1729
|
if (typeof val !== 'function')
|
|
1717
1730
|
return val;
|
|
1718
1731
|
const temp = $mol_wire_task.getter(val);
|
|
@@ -1721,10 +1734,13 @@ var $;
|
|
|
1721
1734
|
return fiber.sync();
|
|
1722
1735
|
};
|
|
1723
1736
|
},
|
|
1737
|
+
construct(obj, args) {
|
|
1738
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
|
1739
|
+
return temp(obj, args).sync();
|
|
1740
|
+
},
|
|
1724
1741
|
apply(obj, self, args) {
|
|
1725
1742
|
const temp = $mol_wire_task.getter(obj);
|
|
1726
|
-
|
|
1727
|
-
return fiber.sync();
|
|
1743
|
+
return temp(self, args).sync();
|
|
1728
1744
|
},
|
|
1729
1745
|
});
|
|
1730
1746
|
}
|
|
@@ -1740,9 +1756,19 @@ var $;
|
|
|
1740
1756
|
$.$mol_run_error = $mol_run_error;
|
|
1741
1757
|
const child_process = $node['child_process'];
|
|
1742
1758
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
|
1759
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
|
1743
1760
|
function $mol_run_async({ dir, timeout, command, env }) {
|
|
1744
1761
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
1745
1762
|
const [app, ...args] = args_raw;
|
|
1763
|
+
if (!env?.MOL_RUN_ASYNC) {
|
|
1764
|
+
this.$mol_log3_come({
|
|
1765
|
+
place: '$mol_run_sync',
|
|
1766
|
+
message: 'Run',
|
|
1767
|
+
command: args_raw.join(' '),
|
|
1768
|
+
dir: $node.path.relative('', dir),
|
|
1769
|
+
});
|
|
1770
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
|
1771
|
+
}
|
|
1746
1772
|
const sub = this.$mol_run_spawn(app, args, {
|
|
1747
1773
|
shell: true,
|
|
1748
1774
|
cwd: dir,
|
package/node.test.js
CHANGED
|
@@ -119,7 +119,11 @@ var $node = new Proxy({ require }, {
|
|
|
119
119
|
try {
|
|
120
120
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
121
121
|
}
|
|
122
|
-
catch {
|
|
122
|
+
catch (e) {
|
|
123
|
+
if ($$.$mol_fail_catch(e)) {
|
|
124
|
+
$$.$mol_fail_log(e);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
123
127
|
break;
|
|
124
128
|
}
|
|
125
129
|
else {
|
|
@@ -130,7 +134,7 @@ var $node = new Proxy({ require }, {
|
|
|
130
134
|
return target.require(name);
|
|
131
135
|
}
|
|
132
136
|
catch (error) {
|
|
133
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
137
|
+
if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
|
|
134
138
|
const module = cache.get(name);
|
|
135
139
|
if (module)
|
|
136
140
|
return module;
|
|
@@ -1700,10 +1704,19 @@ var $;
|
|
|
1700
1704
|
"use strict";
|
|
1701
1705
|
var $;
|
|
1702
1706
|
(function ($) {
|
|
1707
|
+
const factories = new WeakMap();
|
|
1708
|
+
function factory(val) {
|
|
1709
|
+
let make = factories.get(val);
|
|
1710
|
+
if (make)
|
|
1711
|
+
return make;
|
|
1712
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
1713
|
+
factories.set(val, make);
|
|
1714
|
+
return make;
|
|
1715
|
+
}
|
|
1703
1716
|
function $mol_wire_sync(obj) {
|
|
1704
1717
|
return new Proxy(obj, {
|
|
1705
1718
|
get(obj, field) {
|
|
1706
|
-
|
|
1719
|
+
let val = obj[field];
|
|
1707
1720
|
if (typeof val !== 'function')
|
|
1708
1721
|
return val;
|
|
1709
1722
|
const temp = $mol_wire_task.getter(val);
|
|
@@ -1712,10 +1725,13 @@ var $;
|
|
|
1712
1725
|
return fiber.sync();
|
|
1713
1726
|
};
|
|
1714
1727
|
},
|
|
1728
|
+
construct(obj, args) {
|
|
1729
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
|
1730
|
+
return temp(obj, args).sync();
|
|
1731
|
+
},
|
|
1715
1732
|
apply(obj, self, args) {
|
|
1716
1733
|
const temp = $mol_wire_task.getter(obj);
|
|
1717
|
-
|
|
1718
|
-
return fiber.sync();
|
|
1734
|
+
return temp(self, args).sync();
|
|
1719
1735
|
},
|
|
1720
1736
|
});
|
|
1721
1737
|
}
|
|
@@ -1731,9 +1747,19 @@ var $;
|
|
|
1731
1747
|
$.$mol_run_error = $mol_run_error;
|
|
1732
1748
|
const child_process = $node['child_process'];
|
|
1733
1749
|
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
|
1750
|
+
$.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
|
|
1734
1751
|
function $mol_run_async({ dir, timeout, command, env }) {
|
|
1735
1752
|
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
1736
1753
|
const [app, ...args] = args_raw;
|
|
1754
|
+
if (!env?.MOL_RUN_ASYNC) {
|
|
1755
|
+
this.$mol_log3_come({
|
|
1756
|
+
place: '$mol_run_sync',
|
|
1757
|
+
message: 'Run',
|
|
1758
|
+
command: args_raw.join(' '),
|
|
1759
|
+
dir: $node.path.relative('', dir),
|
|
1760
|
+
});
|
|
1761
|
+
return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
|
1762
|
+
}
|
|
1737
1763
|
const sub = this.$mol_run_spawn(app, args, {
|
|
1738
1764
|
shell: true,
|
|
1739
1765
|
cwd: dir,
|
|
@@ -3728,6 +3754,41 @@ var $;
|
|
|
3728
3754
|
}
|
|
3729
3755
|
}
|
|
3730
3756
|
},
|
|
3757
|
+
async 'test method from host'($) {
|
|
3758
|
+
let count = 0;
|
|
3759
|
+
class A {
|
|
3760
|
+
static a() {
|
|
3761
|
+
return $mol_wire_sync(this).b();
|
|
3762
|
+
}
|
|
3763
|
+
static b() { return Promise.resolve(++count); }
|
|
3764
|
+
}
|
|
3765
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3766
|
+
},
|
|
3767
|
+
async 'test function'($) {
|
|
3768
|
+
let count = 0;
|
|
3769
|
+
class A {
|
|
3770
|
+
static a() {
|
|
3771
|
+
return $mol_wire_sync(this.b)();
|
|
3772
|
+
}
|
|
3773
|
+
static b() { return Promise.resolve(++count); }
|
|
3774
|
+
}
|
|
3775
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
3776
|
+
},
|
|
3777
|
+
async 'test construct itself'($) {
|
|
3778
|
+
class A {
|
|
3779
|
+
static instances = [];
|
|
3780
|
+
static a() {
|
|
3781
|
+
const a = new ($mol_wire_sync(A))();
|
|
3782
|
+
this.instances.push(a);
|
|
3783
|
+
$mol_wire_sync(this).b();
|
|
3784
|
+
}
|
|
3785
|
+
static b() { return Promise.resolve(); }
|
|
3786
|
+
}
|
|
3787
|
+
await $mol_wire_async(A).a();
|
|
3788
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
3789
|
+
$mol_assert_equal(A.instances[0] instanceof A);
|
|
3790
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
3791
|
+
}
|
|
3731
3792
|
});
|
|
3732
3793
|
})($ || ($ = {}));
|
|
3733
3794
|
|
|
@@ -3758,7 +3819,7 @@ var $;
|
|
|
3758
3819
|
});
|
|
3759
3820
|
let message = '';
|
|
3760
3821
|
try {
|
|
3761
|
-
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
|
|
3822
|
+
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
|
|
3762
3823
|
}
|
|
3763
3824
|
catch (e) {
|
|
3764
3825
|
message = e.message;
|