mol_jsx_lib 0.0.1205 → 0.0.1207

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/web.mjs CHANGED
@@ -1869,18 +1869,42 @@ var $;
1869
1869
  factories.set(val, make);
1870
1870
  return make;
1871
1871
  }
1872
+ const getters = new WeakMap();
1873
+ function get_prop(host, field) {
1874
+ let props = getters.get(host);
1875
+ let get_val = props?.[field];
1876
+ if (get_val)
1877
+ return get_val;
1878
+ get_val = (next) => {
1879
+ if (next !== undefined)
1880
+ host[field] = next;
1881
+ return host[field];
1882
+ };
1883
+ Object.defineProperty(get_val, 'name', { value: field });
1884
+ if (!props) {
1885
+ props = {};
1886
+ getters.set(host, props);
1887
+ }
1888
+ props[field] = get_val;
1889
+ return get_val;
1890
+ }
1872
1891
  function $mol_wire_sync(obj) {
1873
1892
  return new Proxy(obj, {
1874
1893
  get(obj, field) {
1875
1894
  let val = obj[field];
1895
+ const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
1876
1896
  if (typeof val !== 'function')
1877
- return val;
1878
- const temp = $mol_wire_task.getter(val);
1897
+ return temp(obj, []).sync();
1879
1898
  return function $mol_wire_sync(...args) {
1880
1899
  const fiber = temp(obj, args);
1881
1900
  return fiber.sync();
1882
1901
  };
1883
1902
  },
1903
+ set(obj, field, next) {
1904
+ const temp = $mol_wire_task.getter(get_prop(obj, field));
1905
+ temp(obj, [next]).sync();
1906
+ return true;
1907
+ },
1884
1908
  construct(obj, args) {
1885
1909
  const temp = $mol_wire_task.getter(factory(obj));
1886
1910
  return temp(obj, args).sync();