mol_jsx_lib 0.0.412 → 0.0.413
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 +4 -0
- package/node.deps.json +1 -1
- package/node.js +24 -14
- package/node.js.map +1 -1
- package/node.mjs +24 -14
- package/node.mjs.map +1 -1
- package/node.test.js +26 -16
- package/node.test.js.map +1 -1
- package/package.json +4 -2
- package/web.d.ts +4 -0
- package/web.deps.json +1 -1
- package/web.js +24 -14
- package/web.js.map +1 -1
- package/web.mjs +24 -14
- package/web.mjs.map +1 -1
- package/web.test.js +2 -2
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1413,6 +1413,16 @@ var $;
|
|
|
1413
1413
|
;
|
|
1414
1414
|
"use strict";
|
|
1415
1415
|
var $;
|
|
1416
|
+
(function ($) {
|
|
1417
|
+
function $mol_promise_like(val) {
|
|
1418
|
+
return val && typeof val.then === 'function';
|
|
1419
|
+
}
|
|
1420
|
+
$.$mol_promise_like = $mol_promise_like;
|
|
1421
|
+
})($ || ($ = {}));
|
|
1422
|
+
//mol/promise/like/like.ts
|
|
1423
|
+
;
|
|
1424
|
+
"use strict";
|
|
1425
|
+
var $;
|
|
1416
1426
|
(function ($) {
|
|
1417
1427
|
const handled = new WeakSet();
|
|
1418
1428
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
@@ -1461,7 +1471,7 @@ var $;
|
|
|
1461
1471
|
return this.data.slice(0, this.pub_from);
|
|
1462
1472
|
}
|
|
1463
1473
|
result() {
|
|
1464
|
-
if (this.cache
|
|
1474
|
+
if ($mol_promise_like(this.cache))
|
|
1465
1475
|
return;
|
|
1466
1476
|
if (this.cache instanceof Error)
|
|
1467
1477
|
return;
|
|
@@ -1540,7 +1550,7 @@ var $;
|
|
|
1540
1550
|
result = this.task.call(this.host, ...this.args);
|
|
1541
1551
|
break;
|
|
1542
1552
|
}
|
|
1543
|
-
if (result
|
|
1553
|
+
if ($mol_promise_like(result)) {
|
|
1544
1554
|
const put = (res) => {
|
|
1545
1555
|
if (this.cache === result)
|
|
1546
1556
|
this.put(res);
|
|
@@ -1553,13 +1563,13 @@ var $;
|
|
|
1553
1563
|
}
|
|
1554
1564
|
}
|
|
1555
1565
|
catch (error) {
|
|
1556
|
-
if (error instanceof Error || error
|
|
1566
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
|
1557
1567
|
result = error;
|
|
1558
1568
|
}
|
|
1559
1569
|
else {
|
|
1560
1570
|
result = new Error(String(error), { cause: error });
|
|
1561
1571
|
}
|
|
1562
|
-
if (result
|
|
1572
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
1563
1573
|
result = Object.assign(result.finally(() => {
|
|
1564
1574
|
if (this.cache === result)
|
|
1565
1575
|
this.absorb();
|
|
@@ -1569,7 +1579,7 @@ var $;
|
|
|
1569
1579
|
handled.add(result);
|
|
1570
1580
|
}
|
|
1571
1581
|
}
|
|
1572
|
-
if (
|
|
1582
|
+
if (!$mol_promise_like(result)) {
|
|
1573
1583
|
this.track_cut();
|
|
1574
1584
|
}
|
|
1575
1585
|
this.track_off(bu);
|
|
@@ -1588,7 +1598,7 @@ var $;
|
|
|
1588
1598
|
if (this.cache instanceof Error) {
|
|
1589
1599
|
return $mol_fail_hidden(this.cache);
|
|
1590
1600
|
}
|
|
1591
|
-
if (this.cache
|
|
1601
|
+
if ($mol_promise_like(this.cache)) {
|
|
1592
1602
|
return $mol_fail_hidden(this.cache);
|
|
1593
1603
|
}
|
|
1594
1604
|
return this.cache;
|
|
@@ -1599,7 +1609,7 @@ var $;
|
|
|
1599
1609
|
if (this.cache instanceof Error) {
|
|
1600
1610
|
$mol_fail_hidden(this.cache);
|
|
1601
1611
|
}
|
|
1602
|
-
if (
|
|
1612
|
+
if (!$mol_promise_like(this.cache))
|
|
1603
1613
|
return this.cache;
|
|
1604
1614
|
await this.cache;
|
|
1605
1615
|
if (this.cursor === $mol_wire_cursor.final) {
|
|
@@ -1822,14 +1832,14 @@ var $;
|
|
|
1822
1832
|
};
|
|
1823
1833
|
}
|
|
1824
1834
|
complete() {
|
|
1825
|
-
if (this.cache
|
|
1835
|
+
if ($mol_promise_like(this.cache))
|
|
1826
1836
|
return;
|
|
1827
1837
|
this.destructor();
|
|
1828
1838
|
}
|
|
1829
1839
|
put(next) {
|
|
1830
1840
|
const prev = this.cache;
|
|
1831
1841
|
this.cache = next;
|
|
1832
|
-
if (next
|
|
1842
|
+
if ($mol_promise_like(next)) {
|
|
1833
1843
|
this.cursor = $mol_wire_cursor.fresh;
|
|
1834
1844
|
if (next !== prev)
|
|
1835
1845
|
this.emit();
|
|
@@ -1886,7 +1896,7 @@ var $;
|
|
|
1886
1896
|
function $mol_fail_catch(error) {
|
|
1887
1897
|
if (typeof error !== 'object')
|
|
1888
1898
|
return false;
|
|
1889
|
-
if (error
|
|
1899
|
+
if ($mol_promise_like(error))
|
|
1890
1900
|
$mol_fail_hidden(error);
|
|
1891
1901
|
if (catched.get(error))
|
|
1892
1902
|
return false;
|
|
@@ -1901,7 +1911,7 @@ var $;
|
|
|
1901
1911
|
var $;
|
|
1902
1912
|
(function ($) {
|
|
1903
1913
|
function $mol_fail_log(error) {
|
|
1904
|
-
if (error
|
|
1914
|
+
if ($mol_promise_like(error))
|
|
1905
1915
|
return false;
|
|
1906
1916
|
if (!$mol_fail_catch(error))
|
|
1907
1917
|
return false;
|
|
@@ -2025,7 +2035,7 @@ var $;
|
|
|
2025
2035
|
}
|
|
2026
2036
|
this.cache = next;
|
|
2027
2037
|
this.cursor = $mol_wire_cursor.fresh;
|
|
2028
|
-
if (next
|
|
2038
|
+
if ($mol_promise_like(next))
|
|
2029
2039
|
return next;
|
|
2030
2040
|
this.complete_pubs();
|
|
2031
2041
|
return next;
|
|
@@ -2316,7 +2326,7 @@ var $;
|
|
|
2316
2326
|
return error;
|
|
2317
2327
|
}
|
|
2318
2328
|
});
|
|
2319
|
-
const promises = results.filter(res => res
|
|
2329
|
+
const promises = results.filter(res => $mol_promise_like(res));
|
|
2320
2330
|
if (promises.length)
|
|
2321
2331
|
$mol_fail(Promise.race(promises));
|
|
2322
2332
|
const error = results.find(res => res instanceof Error);
|
|
@@ -2597,7 +2607,7 @@ var $;
|
|
|
2597
2607
|
}
|
|
2598
2608
|
$.$mol_promise = $mol_promise;
|
|
2599
2609
|
})($ || ($ = {}));
|
|
2600
|
-
//mol/promise/promise.ts
|
|
2610
|
+
//mol/promise/promise/promise.ts
|
|
2601
2611
|
;
|
|
2602
2612
|
"use strict";
|
|
2603
2613
|
var $;
|
|
@@ -2715,7 +2725,7 @@ var $;
|
|
|
2715
2725
|
for (let mock of $_1.$mol_test_mocks)
|
|
2716
2726
|
await mock(context);
|
|
2717
2727
|
const res = test(context);
|
|
2718
|
-
if (res
|
|
2728
|
+
if ($mol_promise_like(res)) {
|
|
2719
2729
|
await new Promise((done, fail) => {
|
|
2720
2730
|
res.then(done, fail);
|
|
2721
2731
|
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
@@ -3511,7 +3521,7 @@ var $;
|
|
|
3511
3521
|
return $mol_wire_sync(Handle).sum(1, 2);
|
|
3512
3522
|
}
|
|
3513
3523
|
catch (error) {
|
|
3514
|
-
if (error
|
|
3524
|
+
if ($mol_promise_like(error))
|
|
3515
3525
|
$mol_fail_hidden(error);
|
|
3516
3526
|
$mol_assert_equal(error.message, 'test error 3');
|
|
3517
3527
|
}
|