@yiin/reactive-proxy-state 1.0.23 → 1.0.25

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/index.cjs CHANGED
@@ -35989,6 +35989,80 @@ function wrapArray(arr, emit, path = []) {
35989
35989
  return result;
35990
35990
  };
35991
35991
  return methodCache[prop];
35992
+ case "find": {
35993
+ track(target, Symbol.iterator);
35994
+ if (!methodCache[prop]) {
35995
+ methodCache[prop] = function(predicate, thisArg) {
35996
+ const idx = Array.prototype.findIndex.call(target, predicate, thisArg);
35997
+ if (idx === -1)
35998
+ return;
35999
+ const value2 = target[idx];
36000
+ if (!isObject2(value2))
36001
+ return value2;
36002
+ const propKey = String(idx);
36003
+ const pathKey = path.length > 0 ? `${path.join(".")}.${propKey}` : propKey;
36004
+ let newPath = getPathConcat(pathKey);
36005
+ if (newPath === undefined) {
36006
+ newPath = path.concat(propKey);
36007
+ setPathConcat(pathKey, newPath);
36008
+ }
36009
+ if (globalSeen.has(value2))
36010
+ return globalSeen.get(value2);
36011
+ const cachedValueProxy = wrapperCache.get(value2);
36012
+ if (cachedValueProxy)
36013
+ return cachedValueProxy;
36014
+ if (Array.isArray(value2))
36015
+ return wrapArray(value2, emit, newPath);
36016
+ if (value2 instanceof Map)
36017
+ return wrapMap(value2, emit, newPath);
36018
+ if (value2 instanceof Set)
36019
+ return wrapSet(value2, emit, newPath);
36020
+ if (value2 instanceof Date)
36021
+ return new Date(value2.getTime());
36022
+ return reactive(value2, emit, newPath);
36023
+ };
36024
+ }
36025
+ return methodCache[prop];
36026
+ }
36027
+ case "at": {
36028
+ track(target, Symbol.iterator);
36029
+ if (!methodCache[prop]) {
36030
+ methodCache[prop] = function(index) {
36031
+ let idx = Number(index);
36032
+ if (!Number.isInteger(idx))
36033
+ idx = Math.trunc(idx);
36034
+ if (idx < 0)
36035
+ idx = target.length + idx;
36036
+ if (idx < 0 || idx >= target.length)
36037
+ return;
36038
+ const value2 = target[idx];
36039
+ if (!isObject2(value2))
36040
+ return value2;
36041
+ const propKey = String(idx);
36042
+ const pathKey = path.length > 0 ? `${path.join(".")}.${propKey}` : propKey;
36043
+ let newPath = getPathConcat(pathKey);
36044
+ if (newPath === undefined) {
36045
+ newPath = path.concat(propKey);
36046
+ setPathConcat(pathKey, newPath);
36047
+ }
36048
+ if (globalSeen.has(value2))
36049
+ return globalSeen.get(value2);
36050
+ const cachedValueProxy = wrapperCache.get(value2);
36051
+ if (cachedValueProxy)
36052
+ return cachedValueProxy;
36053
+ if (Array.isArray(value2))
36054
+ return wrapArray(value2, emit, newPath);
36055
+ if (value2 instanceof Map)
36056
+ return wrapMap(value2, emit, newPath);
36057
+ if (value2 instanceof Set)
36058
+ return wrapSet(value2, emit, newPath);
36059
+ if (value2 instanceof Date)
36060
+ return new Date(value2.getTime());
36061
+ return reactive(value2, emit, newPath);
36062
+ };
36063
+ }
36064
+ return methodCache[prop];
36065
+ }
35992
36066
  case Symbol.iterator:
35993
36067
  case "values":
35994
36068
  case "keys":
@@ -35998,7 +36072,6 @@ function wrapArray(arr, emit, path = []) {
35998
36072
  case "filter":
35999
36073
  case "reduce":
36000
36074
  case "reduceRight":
36001
- case "find":
36002
36075
  case "findIndex":
36003
36076
  case "every":
36004
36077
  case "some":
@@ -36403,13 +36476,13 @@ function trackVueReactiveEvents(vueState, emit, options = {}) {
36403
36476
  } catch (e) {}
36404
36477
  }
36405
36478
  let prev = deepClone(vueState);
36406
- const stop = exports_vue.watch(() => vueState, () => {
36479
+ const stop = exports_vue.watch(() => traverse(vueState), () => {
36407
36480
  try {
36408
36481
  diffAndEmit(vueState, prev, []);
36409
36482
  } finally {
36410
36483
  prev = deepClone(vueState);
36411
36484
  }
36412
- }, { deep: true, flush: "sync" });
36485
+ }, { flush: "sync" });
36413
36486
  function diffAndEmit(curr, old, basePath) {
36414
36487
  if (curr instanceof Date && old instanceof Date) {
36415
36488
  if (+curr !== +old) {
package/dist/index.js CHANGED
@@ -35930,6 +35930,80 @@ function wrapArray(arr, emit, path = []) {
35930
35930
  return result;
35931
35931
  };
35932
35932
  return methodCache[prop];
35933
+ case "find": {
35934
+ track(target, Symbol.iterator);
35935
+ if (!methodCache[prop]) {
35936
+ methodCache[prop] = function(predicate, thisArg) {
35937
+ const idx = Array.prototype.findIndex.call(target, predicate, thisArg);
35938
+ if (idx === -1)
35939
+ return;
35940
+ const value2 = target[idx];
35941
+ if (!isObject2(value2))
35942
+ return value2;
35943
+ const propKey = String(idx);
35944
+ const pathKey = path.length > 0 ? `${path.join(".")}.${propKey}` : propKey;
35945
+ let newPath = getPathConcat(pathKey);
35946
+ if (newPath === undefined) {
35947
+ newPath = path.concat(propKey);
35948
+ setPathConcat(pathKey, newPath);
35949
+ }
35950
+ if (globalSeen.has(value2))
35951
+ return globalSeen.get(value2);
35952
+ const cachedValueProxy = wrapperCache.get(value2);
35953
+ if (cachedValueProxy)
35954
+ return cachedValueProxy;
35955
+ if (Array.isArray(value2))
35956
+ return wrapArray(value2, emit, newPath);
35957
+ if (value2 instanceof Map)
35958
+ return wrapMap(value2, emit, newPath);
35959
+ if (value2 instanceof Set)
35960
+ return wrapSet(value2, emit, newPath);
35961
+ if (value2 instanceof Date)
35962
+ return new Date(value2.getTime());
35963
+ return reactive(value2, emit, newPath);
35964
+ };
35965
+ }
35966
+ return methodCache[prop];
35967
+ }
35968
+ case "at": {
35969
+ track(target, Symbol.iterator);
35970
+ if (!methodCache[prop]) {
35971
+ methodCache[prop] = function(index) {
35972
+ let idx = Number(index);
35973
+ if (!Number.isInteger(idx))
35974
+ idx = Math.trunc(idx);
35975
+ if (idx < 0)
35976
+ idx = target.length + idx;
35977
+ if (idx < 0 || idx >= target.length)
35978
+ return;
35979
+ const value2 = target[idx];
35980
+ if (!isObject2(value2))
35981
+ return value2;
35982
+ const propKey = String(idx);
35983
+ const pathKey = path.length > 0 ? `${path.join(".")}.${propKey}` : propKey;
35984
+ let newPath = getPathConcat(pathKey);
35985
+ if (newPath === undefined) {
35986
+ newPath = path.concat(propKey);
35987
+ setPathConcat(pathKey, newPath);
35988
+ }
35989
+ if (globalSeen.has(value2))
35990
+ return globalSeen.get(value2);
35991
+ const cachedValueProxy = wrapperCache.get(value2);
35992
+ if (cachedValueProxy)
35993
+ return cachedValueProxy;
35994
+ if (Array.isArray(value2))
35995
+ return wrapArray(value2, emit, newPath);
35996
+ if (value2 instanceof Map)
35997
+ return wrapMap(value2, emit, newPath);
35998
+ if (value2 instanceof Set)
35999
+ return wrapSet(value2, emit, newPath);
36000
+ if (value2 instanceof Date)
36001
+ return new Date(value2.getTime());
36002
+ return reactive(value2, emit, newPath);
36003
+ };
36004
+ }
36005
+ return methodCache[prop];
36006
+ }
35933
36007
  case Symbol.iterator:
35934
36008
  case "values":
35935
36009
  case "keys":
@@ -35939,7 +36013,6 @@ function wrapArray(arr, emit, path = []) {
35939
36013
  case "filter":
35940
36014
  case "reduce":
35941
36015
  case "reduceRight":
35942
- case "find":
35943
36016
  case "findIndex":
35944
36017
  case "every":
35945
36018
  case "some":
@@ -36344,13 +36417,13 @@ function trackVueReactiveEvents(vueState, emit, options = {}) {
36344
36417
  } catch (e) {}
36345
36418
  }
36346
36419
  let prev = deepClone(vueState);
36347
- const stop = exports_vue.watch(() => vueState, () => {
36420
+ const stop = exports_vue.watch(() => traverse(vueState), () => {
36348
36421
  try {
36349
36422
  diffAndEmit(vueState, prev, []);
36350
36423
  } finally {
36351
36424
  prev = deepClone(vueState);
36352
36425
  }
36353
- }, { deep: true, flush: "sync" });
36426
+ }, { flush: "sync" });
36354
36427
  function diffAndEmit(curr, old, basePath) {
36355
36428
  if (curr instanceof Date && old instanceof Date) {
36356
36429
  if (+curr !== +old) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yiin/reactive-proxy-state",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "author": "Yiin <stanislovas@yiin.lt>",
5
5
  "repository": {
6
6
  "type": "git",