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

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.
@@ -9,12 +9,7 @@ export const usePerformanceOptimizations = (columns) => {
9
9
  const hasChanged = columns.length !== stableColumnsRef.current.length ||
10
10
  columns.some((col, index) => {
11
11
  const prevCol = stableColumnsRef.current[index];
12
- return (!prevCol ||
13
- col.id !== prevCol.id ||
14
- col.width !== prevCol.width ||
15
- col.pinned !== prevCol.pinned ||
16
- col.hidden !== prevCol.hidden ||
17
- col.order !== prevCol.order);
12
+ return !prevCol || col.id !== prevCol.id || col.filter !== prevCol.filter;
18
13
  });
19
14
  if (hasChanged) {
20
15
  stableColumnsRef.current = [...columns];
@@ -39,6 +34,39 @@ export const usePerformanceOptimizations = (columns) => {
39
34
  currentFilters[columnId] = filterData;
40
35
  }
41
36
  });
37
+ // Safe comparison helper that avoids circular references
38
+ const safeCompare = (obj1, obj2) => {
39
+ // Handle primitive types
40
+ if (obj1 === obj2)
41
+ return true;
42
+ if (obj1 == null || obj2 == null)
43
+ return obj1 === obj2;
44
+ if (typeof obj1 !== 'object' || typeof obj2 !== 'object')
45
+ return obj1 === obj2;
46
+ // Handle arrays
47
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
48
+ if (obj1.length !== obj2.length)
49
+ return false;
50
+ return obj1.every((item, index) => safeCompare(item, obj2[index]));
51
+ }
52
+ if (Array.isArray(obj1) || Array.isArray(obj2))
53
+ return false;
54
+ // Handle objects - only compare basic properties, avoid complex nested objects
55
+ const keys1 = Object.keys(obj1);
56
+ const keys2 = Object.keys(obj2);
57
+ if (keys1.length !== keys2.length)
58
+ return false;
59
+ return keys1.every((key) => {
60
+ const val1 = obj1[key];
61
+ const val2 = obj2[key];
62
+ // Skip complex objects that might have circular references
63
+ if (typeof val1 === 'object' && val1 != null && (val1.constructor === Object || Array.isArray(val1))) {
64
+ return safeCompare(val1, val2);
65
+ }
66
+ // For other object types (like React contexts), just compare references
67
+ return val1 === val2;
68
+ });
69
+ };
42
70
  // Deep comparison of filter state
43
71
  const hasFilterChanged = () => {
44
72
  const currentKeys = Object.keys(currentFilters);
@@ -53,11 +81,10 @@ export const usePerformanceOptimizations = (columns) => {
53
81
  // Compare filter properties that affect rendering
54
82
  if (current.type !== prev.type || current.apiKey !== prev.apiKey)
55
83
  return true;
56
- // Deep compare options array
57
- if (JSON.stringify(current.options) !== JSON.stringify(prev.options))
84
+ // Safe comparison for options and data
85
+ if (!safeCompare(current.options, prev.options))
58
86
  return true;
59
- // Deep compare filter data
60
- if (JSON.stringify(current.data) !== JSON.stringify(prev.data))
87
+ if (!safeCompare(current.data, prev.data))
61
88
  return true;
62
89
  return false;
63
90
  });
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.5",
5
+ "testVersion": 5,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",