@mintjamsinc/ichigojs 0.1.53 → 0.1.54

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.
@@ -7904,22 +7904,42 @@ class ReactiveProxy {
7904
7904
  const nestedPath = path ? (Array.isArray(obj) ? `${path}[${keyStr}]` : `${path}.${keyStr}`) : keyStr;
7905
7905
  return ReactiveProxy.create(value, onChange, nestedPath);
7906
7906
  }
7907
- // For arrays and Maps, intercept mutation methods
7907
+ // If the value is a function, we need to wrap it to ensure that any mutations it performs also trigger onChange
7908
7908
  if (typeof value === 'function') {
7909
- let mutationMethods = [];
7909
+ // For arrays, we only want to wrap mutation methods, not read methods like 'slice', 'concat', etc.
7910
7910
  if (Array.isArray(obj)) {
7911
- mutationMethods.push('push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse');
7911
+ const arrayMutationMethods = ['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'];
7912
+ if (!arrayMutationMethods.includes(key)) {
7913
+ return value;
7914
+ }
7915
+ return function (...args) {
7916
+ const result = value.apply(this === receiver ? obj : this, args);
7917
+ onChange(path || undefined);
7918
+ return result;
7919
+ };
7912
7920
  }
7913
- else if (obj.constructor.name === 'Map') {
7914
- mutationMethods.push('set', 'delete', 'clear');
7921
+ // For Map, we only want to wrap mutation methods, not read methods like 'get' or 'has'
7922
+ if (obj.constructor.name === 'Map') {
7923
+ const mapMutationMethods = ['set', 'delete', 'clear'];
7924
+ return function (...args) {
7925
+ const result = value.apply(this === receiver ? obj : this, args);
7926
+ if (mapMutationMethods.includes(key)) {
7927
+ onChange(path || undefined);
7928
+ }
7929
+ return result;
7930
+ };
7931
+ }
7932
+ // For Set, we only want to wrap mutation methods, not read methods like 'has'
7933
+ if (obj.constructor.name === 'Set') {
7934
+ const setMutationMethods = ['add', 'delete', 'clear'];
7935
+ return function (...args) {
7936
+ const result = value.apply(this === receiver ? obj : this, args);
7937
+ if (setMutationMethods.includes(key)) {
7938
+ onChange(path || undefined);
7939
+ }
7940
+ return result;
7941
+ };
7915
7942
  }
7916
- return function (...args) {
7917
- const result = value.apply(this === receiver ? obj : this, args);
7918
- if (mutationMethods.includes(key)) {
7919
- onChange(path || undefined);
7920
- }
7921
- return result;
7922
- };
7923
7943
  }
7924
7944
  return value;
7925
7945
  },