cry-synced-db-client 2.0.7 → 2.0.8

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8279,6 +8279,13 @@ function canExpandArrayToBrackets(value) {
8279
8279
  }
8280
8280
  return true;
8281
8281
  }
8282
+ function unwrapWholeElement(value) {
8283
+ if (Array.isArray(value)) {
8284
+ return value.length === 1 && value[0] && typeof value[0] === "object" ? value[0] : null;
8285
+ }
8286
+ if (value && typeof value === "object") return value;
8287
+ return null;
8288
+ }
8282
8289
  function pickLayerTarget(newPath, newValue) {
8283
8290
  if (!isTerminalBracketKey(newPath)) return null;
8284
8291
  if (newValue === void 0) return null;
@@ -8345,6 +8352,15 @@ function mergeDirtyPath(accumulated, newPath, newValue) {
8345
8352
  }
8346
8353
  }
8347
8354
  for (const k of descendants) delete accumulated[k];
8355
+ if (newValue !== void 0 && isTerminalBracketKey(newPath) && Object.prototype.hasOwnProperty.call(accumulated, newPath)) {
8356
+ const existingValue = accumulated[newPath];
8357
+ const existingElement = unwrapWholeElement(existingValue);
8358
+ const newElement = unwrapWholeElement(newValue);
8359
+ if (existingElement && newElement && (Array.isArray(existingValue) || Array.isArray(newValue))) {
8360
+ accumulated[newPath] = [newElement];
8361
+ return;
8362
+ }
8363
+ }
8348
8364
  accumulated[newPath] = newValue;
8349
8365
  }
8350
8366
  function mergeDirtyChanges(accumulated, newChanges) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",