cry-synced-db-client 2.0.3 → 2.0.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.
package/dist/index.js CHANGED
@@ -509,6 +509,9 @@ function computeObjDiff(existing, update) {
509
509
  continue;
510
510
  computeDiffInto(existing[key], update[key], key, diff);
511
511
  }
512
+ if (Object.prototype.hasOwnProperty.call(update, "_lastUpdaterId")) {
513
+ diff._lastUpdaterId = update._lastUpdaterId;
514
+ }
512
515
  return diff;
513
516
  }
514
517
  function tokenizePath(path) {
@@ -4794,8 +4797,7 @@ var ServerUpdateHandler = class {
4794
4797
  return "ignore";
4795
4798
  }
4796
4799
  if (incomingRev === localRev + 1) {
4797
- const updaterId = incomingUpdaterId != null ? incomingUpdaterId : localItem._lastUpdaterId;
4798
- if (updaterId === this.updaterId) {
4800
+ if (incomingUpdaterId !== void 0 && incomingUpdaterId === this.updaterId) {
4799
4801
  return "bump-meta";
4800
4802
  }
4801
4803
  return "apply";
@@ -4876,7 +4878,7 @@ var ServerUpdateHandler = class {
4876
4878
  }
4877
4879
  const pendingChange = this.deps.getPendingChange(collection, serverDelta._id);
4878
4880
  if (pendingChange) {
4879
- const newFields = this.getNewFieldsFromServer(localItem, serverDelta);
4881
+ const newFields = this.getNewFieldsFromServer(pendingChange.data, serverDelta);
4880
4882
  if (Object.keys(newFields).length > 0) {
4881
4883
  Object.assign(pendingChange.data, newFields);
4882
4884
  }
@@ -4973,10 +4975,26 @@ var ServerUpdateHandler = class {
4973
4975
  }
4974
4976
  return local;
4975
4977
  }
4976
- getNewFieldsFromServer(local, server) {
4978
+ /**
4979
+ * Fields from an incoming server delta that our OWN in-flight pending
4980
+ * change doesn't already touch — safe to backfill into it so a later
4981
+ * merge doesn't clobber a concurrent server-side edit to an unrelated
4982
+ * field.
4983
+ *
4984
+ * Checked against `pendingChange.data`'s own keys (not the dexie-persisted
4985
+ * `local` snapshot): a field we're deliberately clearing shows up as
4986
+ * `undefined` on `local` too (once `applyObjDiff` deletes it), which is
4987
+ * indistinguishable from "local never knew about this field" if you test
4988
+ * `local[key] === undefined`. That conflation let a slower, older echo
4989
+ * (e.g. a lock-write's own confirmation arriving after we've already
4990
+ * locally reverted it) resurrect a field our pending change had just
4991
+ * unset — reproduced with izdajRacun.vue's sedajObdeluje lock/unlock race
4992
+ * (2026-07-14).
4993
+ */
4994
+ getNewFieldsFromServer(pendingData, server) {
4977
4995
  const newFields = {};
4978
4996
  for (const key of Object.keys(server)) {
4979
- if (key !== "_id" && key !== "_dirty" && local[key] === void 0) {
4997
+ if (key !== "_id" && key !== "_dirty" && !Object.prototype.hasOwnProperty.call(pendingData, key)) {
4980
4998
  newFields[key] = server[key];
4981
4999
  }
4982
5000
  }
@@ -81,6 +81,22 @@ export declare class ServerUpdateHandler implements I_ServerUpdateHandler {
81
81
  private timestampsEqual;
82
82
  /** @mutates local — mutira vhodni objekt namesto kopiranja */
83
83
  private mergeLocalWithDelta;
84
+ /**
85
+ * Fields from an incoming server delta that our OWN in-flight pending
86
+ * change doesn't already touch — safe to backfill into it so a later
87
+ * merge doesn't clobber a concurrent server-side edit to an unrelated
88
+ * field.
89
+ *
90
+ * Checked against `pendingChange.data`'s own keys (not the dexie-persisted
91
+ * `local` snapshot): a field we're deliberately clearing shows up as
92
+ * `undefined` on `local` too (once `applyObjDiff` deletes it), which is
93
+ * indistinguishable from "local never knew about this field" if you test
94
+ * `local[key] === undefined`. That conflation let a slower, older echo
95
+ * (e.g. a lock-write's own confirmation arriving after we've already
96
+ * locally reverted it) resurrect a field our pending change had just
97
+ * unset — reproduced with izdajRacun.vue's sedajObdeluje lock/unlock race
98
+ * (2026-07-14).
99
+ */
84
100
  private getNewFieldsFromServer;
85
101
  private callOnWsNotification;
86
102
  private callOnEbusNotificationReceived;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "vitest": "^4.1.10"
38
38
  },
39
39
  "dependencies": {
40
- "cry-db": "^2.6.2",
40
+ "cry-db": "^2.6.3",
41
41
  "cry-helpers": "^2.1.207",
42
42
  "msgpackr": "^2.0.4",
43
43
  "superjson": "^2.2.6"