mol_wire_dom 0.0.1324 → 0.0.1326
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.test.js +26 -2
- package/web.test.js.map +1 -1
package/package.json
CHANGED
package/web.test.js
CHANGED
@@ -1402,18 +1402,42 @@ var $;
|
|
1402
1402
|
factories.set(val, make);
|
1403
1403
|
return make;
|
1404
1404
|
}
|
1405
|
+
const getters = new WeakMap();
|
1406
|
+
function get_prop(host, field) {
|
1407
|
+
let props = getters.get(host);
|
1408
|
+
let get_val = props?.[field];
|
1409
|
+
if (get_val)
|
1410
|
+
return get_val;
|
1411
|
+
get_val = (next) => {
|
1412
|
+
if (next !== undefined)
|
1413
|
+
host[field] = next;
|
1414
|
+
return host[field];
|
1415
|
+
};
|
1416
|
+
Object.defineProperty(get_val, 'name', { value: field });
|
1417
|
+
if (!props) {
|
1418
|
+
props = {};
|
1419
|
+
getters.set(host, props);
|
1420
|
+
}
|
1421
|
+
props[field] = get_val;
|
1422
|
+
return get_val;
|
1423
|
+
}
|
1405
1424
|
function $mol_wire_sync(obj) {
|
1406
1425
|
return new Proxy(obj, {
|
1407
1426
|
get(obj, field) {
|
1408
1427
|
let val = obj[field];
|
1428
|
+
const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
|
1409
1429
|
if (typeof val !== 'function')
|
1410
|
-
return
|
1411
|
-
const temp = $mol_wire_task.getter(val);
|
1430
|
+
return temp(obj, []).sync();
|
1412
1431
|
return function $mol_wire_sync(...args) {
|
1413
1432
|
const fiber = temp(obj, args);
|
1414
1433
|
return fiber.sync();
|
1415
1434
|
};
|
1416
1435
|
},
|
1436
|
+
set(obj, field, next) {
|
1437
|
+
const temp = $mol_wire_task.getter(get_prop(obj, field));
|
1438
|
+
temp(obj, [next]).sync();
|
1439
|
+
return true;
|
1440
|
+
},
|
1417
1441
|
construct(obj, args) {
|
1418
1442
|
const temp = $mol_wire_task.getter(factory(obj));
|
1419
1443
|
return temp(obj, args).sync();
|