mol_wire_lib 1.0.1341 → 1.0.1342
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.deps.json +1 -1
- package/node.js +26 -2
- package/node.js.map +1 -1
- package/node.mjs +26 -2
- package/node.test.js +26 -2
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +26 -2
- package/web.js.map +1 -1
- package/web.mjs +26 -2
package/web.mjs
CHANGED
|
@@ -1479,18 +1479,42 @@ var $;
|
|
|
1479
1479
|
factories.set(val, make);
|
|
1480
1480
|
return make;
|
|
1481
1481
|
}
|
|
1482
|
+
const getters = new WeakMap();
|
|
1483
|
+
function get_prop(host, field) {
|
|
1484
|
+
let props = getters.get(host);
|
|
1485
|
+
let get_val = props?.[field];
|
|
1486
|
+
if (get_val)
|
|
1487
|
+
return get_val;
|
|
1488
|
+
get_val = (next) => {
|
|
1489
|
+
if (next !== undefined)
|
|
1490
|
+
host[field] = next;
|
|
1491
|
+
return host[field];
|
|
1492
|
+
};
|
|
1493
|
+
Object.defineProperty(get_val, 'name', { value: field });
|
|
1494
|
+
if (!props) {
|
|
1495
|
+
props = {};
|
|
1496
|
+
getters.set(host, props);
|
|
1497
|
+
}
|
|
1498
|
+
props[field] = get_val;
|
|
1499
|
+
return get_val;
|
|
1500
|
+
}
|
|
1482
1501
|
function $mol_wire_sync(obj) {
|
|
1483
1502
|
return new Proxy(obj, {
|
|
1484
1503
|
get(obj, field) {
|
|
1485
1504
|
let val = obj[field];
|
|
1505
|
+
const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
|
|
1486
1506
|
if (typeof val !== 'function')
|
|
1487
|
-
return
|
|
1488
|
-
const temp = $mol_wire_task.getter(val);
|
|
1507
|
+
return temp(obj, []).sync();
|
|
1489
1508
|
return function $mol_wire_sync(...args) {
|
|
1490
1509
|
const fiber = temp(obj, args);
|
|
1491
1510
|
return fiber.sync();
|
|
1492
1511
|
};
|
|
1493
1512
|
},
|
|
1513
|
+
set(obj, field, next) {
|
|
1514
|
+
const temp = $mol_wire_task.getter(get_prop(obj, field));
|
|
1515
|
+
temp(obj, [next]).sync();
|
|
1516
|
+
return true;
|
|
1517
|
+
},
|
|
1494
1518
|
construct(obj, args) {
|
|
1495
1519
|
const temp = $mol_wire_task.getter(factory(obj));
|
|
1496
1520
|
return temp(obj, args).sync();
|