@mintjamsinc/ichigojs 0.1.52 → 0.1.53

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/dist/ichigo.cjs CHANGED
@@ -7891,7 +7891,7 @@
7891
7891
  }
7892
7892
  // Create the proxy with path captured in closure
7893
7893
  const proxy = new Proxy(target, {
7894
- get(obj, key) {
7894
+ get(obj, key, receiver) {
7895
7895
  const value = Reflect.get(obj, key);
7896
7896
  // If the value is an object or array, make it reactive too
7897
7897
  if (typeof value === 'object' && value !== null) {
@@ -7910,16 +7910,22 @@
7910
7910
  const nestedPath = path ? (Array.isArray(obj) ? `${path}[${keyStr}]` : `${path}.${keyStr}`) : keyStr;
7911
7911
  return ReactiveProxy.create(value, onChange, nestedPath);
7912
7912
  }
7913
- // For arrays, intercept mutation methods
7914
- if (Array.isArray(obj) && typeof value === 'function') {
7915
- const arrayMutationMethods = ['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'];
7916
- if (arrayMutationMethods.includes(key)) {
7917
- return function (...args) {
7918
- const result = value.apply(obj, args);
7919
- onChange(path || undefined);
7920
- return result;
7921
- };
7913
+ // For arrays and Maps, intercept mutation methods
7914
+ if (typeof value === 'function') {
7915
+ let mutationMethods = [];
7916
+ if (Array.isArray(obj)) {
7917
+ mutationMethods.push('push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse');
7918
+ }
7919
+ else if (obj.constructor.name === 'Map') {
7920
+ mutationMethods.push('set', 'delete', 'clear');
7922
7921
  }
7922
+ return function (...args) {
7923
+ const result = value.apply(this === receiver ? obj : this, args);
7924
+ if (mutationMethods.includes(key)) {
7925
+ onChange(path || undefined);
7926
+ }
7927
+ return result;
7928
+ };
7923
7929
  }
7924
7930
  return value;
7925
7931
  },