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/node.mjs
CHANGED
@@ -2029,18 +2029,42 @@ var $;
|
|
2029
2029
|
factories.set(val, make);
|
2030
2030
|
return make;
|
2031
2031
|
}
|
2032
|
+
const getters = new WeakMap();
|
2033
|
+
function get_prop(host, field) {
|
2034
|
+
let props = getters.get(host);
|
2035
|
+
let get_val = props?.[field];
|
2036
|
+
if (get_val)
|
2037
|
+
return get_val;
|
2038
|
+
get_val = (next) => {
|
2039
|
+
if (next !== undefined)
|
2040
|
+
host[field] = next;
|
2041
|
+
return host[field];
|
2042
|
+
};
|
2043
|
+
Object.defineProperty(get_val, 'name', { value: field });
|
2044
|
+
if (!props) {
|
2045
|
+
props = {};
|
2046
|
+
getters.set(host, props);
|
2047
|
+
}
|
2048
|
+
props[field] = get_val;
|
2049
|
+
return get_val;
|
2050
|
+
}
|
2032
2051
|
function $mol_wire_sync(obj) {
|
2033
2052
|
return new Proxy(obj, {
|
2034
2053
|
get(obj, field) {
|
2035
2054
|
let val = obj[field];
|
2055
|
+
const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
|
2036
2056
|
if (typeof val !== 'function')
|
2037
|
-
return
|
2038
|
-
const temp = $mol_wire_task.getter(val);
|
2057
|
+
return temp(obj, []).sync();
|
2039
2058
|
return function $mol_wire_sync(...args) {
|
2040
2059
|
const fiber = temp(obj, args);
|
2041
2060
|
return fiber.sync();
|
2042
2061
|
};
|
2043
2062
|
},
|
2063
|
+
set(obj, field, next) {
|
2064
|
+
const temp = $mol_wire_task.getter(get_prop(obj, field));
|
2065
|
+
temp(obj, [next]).sync();
|
2066
|
+
return true;
|
2067
|
+
},
|
2044
2068
|
construct(obj, args) {
|
2045
2069
|
const temp = $mol_wire_task.getter(factory(obj));
|
2046
2070
|
return temp(obj, args).sync();
|
package/node.test.js
CHANGED
@@ -2020,18 +2020,42 @@ var $;
|
|
2020
2020
|
factories.set(val, make);
|
2021
2021
|
return make;
|
2022
2022
|
}
|
2023
|
+
const getters = new WeakMap();
|
2024
|
+
function get_prop(host, field) {
|
2025
|
+
let props = getters.get(host);
|
2026
|
+
let get_val = props?.[field];
|
2027
|
+
if (get_val)
|
2028
|
+
return get_val;
|
2029
|
+
get_val = (next) => {
|
2030
|
+
if (next !== undefined)
|
2031
|
+
host[field] = next;
|
2032
|
+
return host[field];
|
2033
|
+
};
|
2034
|
+
Object.defineProperty(get_val, 'name', { value: field });
|
2035
|
+
if (!props) {
|
2036
|
+
props = {};
|
2037
|
+
getters.set(host, props);
|
2038
|
+
}
|
2039
|
+
props[field] = get_val;
|
2040
|
+
return get_val;
|
2041
|
+
}
|
2023
2042
|
function $mol_wire_sync(obj) {
|
2024
2043
|
return new Proxy(obj, {
|
2025
2044
|
get(obj, field) {
|
2026
2045
|
let val = obj[field];
|
2046
|
+
const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
|
2027
2047
|
if (typeof val !== 'function')
|
2028
|
-
return
|
2029
|
-
const temp = $mol_wire_task.getter(val);
|
2048
|
+
return temp(obj, []).sync();
|
2030
2049
|
return function $mol_wire_sync(...args) {
|
2031
2050
|
const fiber = temp(obj, args);
|
2032
2051
|
return fiber.sync();
|
2033
2052
|
};
|
2034
2053
|
},
|
2054
|
+
set(obj, field, next) {
|
2055
|
+
const temp = $mol_wire_task.getter(get_prop(obj, field));
|
2056
|
+
temp(obj, [next]).sync();
|
2057
|
+
return true;
|
2058
|
+
},
|
2035
2059
|
construct(obj, args) {
|
2036
2060
|
const temp = $mol_wire_task.getter(factory(obj));
|
2037
2061
|
return temp(obj, args).sync();
|