@dnd-kit/state 0.1.18 → 0.1.19-beta-20250610183225

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.js CHANGED
@@ -122,9 +122,10 @@ function computed(compute, comparator) {
122
122
 
123
123
  // src/comparators.ts
124
124
  function deepEqual(a, b) {
125
- if (a === b) {
125
+ if (Object.is(a, b)) {
126
126
  return true;
127
127
  }
128
+ if (a === null || b === null) return false;
128
129
  if (typeof a === "function" && typeof b === "function") {
129
130
  return a === b;
130
131
  }
@@ -148,11 +149,13 @@ function deepEqual(a, b) {
148
149
  );
149
150
  return !hasDifferentValues;
150
151
  }
151
- try {
152
- return JSON.stringify(a) === JSON.stringify(b);
153
- } catch (e) {
154
- return false;
152
+ if (typeof a === "object" && typeof b === "object") {
153
+ const aKeys = Object.keys(a);
154
+ const bKeys = Object.keys(b);
155
+ if (aKeys.length !== bKeys.length) return false;
156
+ return aKeys.some((key) => deepEqual(a[key], b[key]));
155
157
  }
158
+ return false;
156
159
  }
157
160
 
158
161
  // src/decorators.ts
package/dist/index.mjs CHANGED
@@ -97,9 +97,10 @@ function computed(compute, comparator) {
97
97
 
98
98
  // src/comparators.ts
99
99
  function deepEqual(a, b) {
100
- if (a === b) {
100
+ if (Object.is(a, b)) {
101
101
  return true;
102
102
  }
103
+ if (a === null || b === null) return false;
103
104
  if (typeof a === "function" && typeof b === "function") {
104
105
  return a === b;
105
106
  }
@@ -123,11 +124,13 @@ function deepEqual(a, b) {
123
124
  );
124
125
  return !hasDifferentValues;
125
126
  }
126
- try {
127
- return JSON.stringify(a) === JSON.stringify(b);
128
- } catch (e) {
129
- return false;
127
+ if (typeof a === "object" && typeof b === "object") {
128
+ const aKeys = Object.keys(a);
129
+ const bKeys = Object.keys(b);
130
+ if (aKeys.length !== bKeys.length) return false;
131
+ return aKeys.some((key) => deepEqual(a[key], b[key]));
130
132
  }
133
+ return false;
131
134
  }
132
135
 
133
136
  // src/decorators.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnd-kit/state",
3
- "version": "0.1.18",
3
+ "version": "0.1.19-beta-20250610183225",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "scripts": {
13
13
  "build": "tsup src/index.ts --format esm,cjs --dts --external react",
14
14
  "dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
15
+ "test": "bun run tests",
15
16
  "lint": "TIMING=1 eslint src/**/*.ts* --fix",
16
17
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
17
18
  },
@@ -21,6 +22,7 @@
21
22
  },
22
23
  "devDependencies": {
23
24
  "@dnd-kit/eslint-config": "*",
25
+ "bun-types": "^1.2.15",
24
26
  "eslint": "^8.38.0",
25
27
  "tsup": "8.3.0",
26
28
  "typescript": "^5.5.2"