@tap-payments/os-micro-frontend-shared 0.1.135-test.3 → 0.1.135-test.4

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.
@@ -39,6 +39,39 @@ export const usePerformanceOptimizations = (columns) => {
39
39
  currentFilters[columnId] = filterData;
40
40
  }
41
41
  });
42
+ // Safe comparison helper that avoids circular references
43
+ const safeCompare = (obj1, obj2) => {
44
+ // Handle primitive types
45
+ if (obj1 === obj2)
46
+ return true;
47
+ if (obj1 == null || obj2 == null)
48
+ return obj1 === obj2;
49
+ if (typeof obj1 !== 'object' || typeof obj2 !== 'object')
50
+ return obj1 === obj2;
51
+ // Handle arrays
52
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
53
+ if (obj1.length !== obj2.length)
54
+ return false;
55
+ return obj1.every((item, index) => safeCompare(item, obj2[index]));
56
+ }
57
+ if (Array.isArray(obj1) || Array.isArray(obj2))
58
+ return false;
59
+ // Handle objects - only compare basic properties, avoid complex nested objects
60
+ const keys1 = Object.keys(obj1);
61
+ const keys2 = Object.keys(obj2);
62
+ if (keys1.length !== keys2.length)
63
+ return false;
64
+ return keys1.every((key) => {
65
+ const val1 = obj1[key];
66
+ const val2 = obj2[key];
67
+ // Skip complex objects that might have circular references
68
+ if (typeof val1 === 'object' && val1 != null && (val1.constructor === Object || Array.isArray(val1))) {
69
+ return safeCompare(val1, val2);
70
+ }
71
+ // For other object types (like React contexts), just compare references
72
+ return val1 === val2;
73
+ });
74
+ };
42
75
  // Deep comparison of filter state
43
76
  const hasFilterChanged = () => {
44
77
  const currentKeys = Object.keys(currentFilters);
@@ -53,11 +86,10 @@ export const usePerformanceOptimizations = (columns) => {
53
86
  // Compare filter properties that affect rendering
54
87
  if (current.type !== prev.type || current.apiKey !== prev.apiKey)
55
88
  return true;
56
- // Deep compare options array
57
- if (JSON.stringify(current.options) !== JSON.stringify(prev.options))
89
+ // Safe comparison for options and data
90
+ if (!safeCompare(current.options, prev.options))
58
91
  return true;
59
- // Deep compare filter data
60
- if (JSON.stringify(current.data) !== JSON.stringify(prev.data))
92
+ if (!safeCompare(current.data, prev.data))
61
93
  return true;
62
94
  return false;
63
95
  });
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.135-test.3",
5
- "testVersion": 3,
4
+ "version": "0.1.135-test.4",
5
+ "testVersion": 4,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",