@dabble/patches 0.4.9 → 0.4.11

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.
@@ -62,6 +62,7 @@ class JSONPatch {
62
62
  */
63
63
  replace(path, value, options) {
64
64
  if (value && value.toJSON) value = value.toJSON();
65
+ if (value === void 0) return this.remove(path);
65
66
  return this.op("replace", path, value, void 0, options?.soft);
66
67
  }
67
68
  /**
@@ -153,6 +153,9 @@ class PatchesSync {
153
153
  } else {
154
154
  const snapshot = await this.ws.getDoc(docId);
155
155
  await this.store.saveDoc(docId, snapshot);
156
+ if (doc) {
157
+ doc.import({ ...snapshot, changes: [] });
158
+ }
156
159
  }
157
160
  }
158
161
  if (doc) {
@@ -26,7 +26,7 @@ class FetchTransport {
26
26
  this.onMessage.emit(await response.text());
27
27
  } catch (error) {
28
28
  const message = JSON.parse(raw);
29
- this.onMessage.emit(JSON.stringify(rpcError(-32e3, error.message, message.id)));
29
+ this.onMessage.emit(JSON.stringify(rpcError(-32e3, error.message, void 0, message.id)));
30
30
  }
31
31
  }
32
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "description": "Immutable JSON Patch implementation based on RFC 6902 supporting operational transformation and last-writer-wins",
5
5
  "author": "Jacob Wright <jacwright@gmail.com>",
6
6
  "bugs": {