@dabble/patches 0.2.12 → 0.2.13

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.
@@ -31,25 +31,6 @@ class LRUCache {
31
31
  this.cache.clear();
32
32
  }
33
33
  }
34
- /**
35
- * Simple event signal for update notifications (like in PatchesDoc)
36
- */
37
- class Signal {
38
- constructor() {
39
- this.listeners = new Set();
40
- }
41
- subscribe(cb) {
42
- this.listeners.add(cb);
43
- return () => this.listeners.delete(cb);
44
- }
45
- emit() {
46
- for (const cb of this.listeners)
47
- cb();
48
- }
49
- clear() {
50
- this.listeners.clear();
51
- }
52
- }
53
34
  /**
54
35
  * Client-side history/scrubbing interface for a document.
55
36
  * Read-only: allows listing versions, loading states/changes, and scrubbing.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { Delta } from '@dabble/delta';
2
2
  export * from './client/Patches.js';
3
3
  export * from './client/PatchesDoc.js';
4
- export * from './event-signal';
4
+ export * from './event-signal.js';
5
5
  export * from './json-patch/JSONPatch.js';
6
6
  export type { ApplyJSONPatchOptions } from './json-patch/types.js';
7
7
  export type * from './persist/PatchesStore.js';
8
- export type * from './types';
8
+ export type * from './types.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Delta } from '@dabble/delta';
2
2
  export * from './client/Patches.js';
3
3
  export * from './client/PatchesDoc.js';
4
- export * from './event-signal';
4
+ export * from './event-signal.js';
5
5
  export * from './json-patch/JSONPatch.js';
@@ -139,7 +139,7 @@ export class JSONPatch {
139
139
  addObjectsInPath(obj, path) {
140
140
  path = checkPath(path);
141
141
  const parts = path.split('/');
142
- for (var i = 1; i < parts.length - 1; i++) {
142
+ for (let i = 1; i < parts.length - 1; i++) {
143
143
  const prop = parts[i];
144
144
  if (!obj || !obj[prop]) {
145
145
  this.add(parts.slice(0, i + 1).join('/'), {});
@@ -5,5 +5,4 @@ export { applyBitmask, bitmask, combineBitmasks } from './ops/bitmask.js';
5
5
  export * as defaultOps from './ops/index.js';
6
6
  export { transformPatch } from './transformPatch.js';
7
7
  export * from './ops/index.js';
8
- export * from './ops/index.js';
9
8
  export type { ApplyJSONPatchOptions, JSONPatchOpHandlerMap as JSONPatchCustomTypes, JSONPatchOp } from './types.js';
@@ -4,5 +4,4 @@ export { invertPatch } from './invertPatch.js';
4
4
  export { applyBitmask, bitmask, combineBitmasks } from './ops/bitmask.js';
5
5
  export * as defaultOps from './ops/index.js';
6
6
  export { transformPatch } from './transformPatch.js';
7
- export * from './ops/index.js'; // Exports all ops: add, remove, etc.
8
7
  export * from './ops/index.js';
@@ -7,7 +7,6 @@ import { move } from './move.js';
7
7
  import { remove } from './remove.js';
8
8
  import { replace } from './replace.js';
9
9
  import { test } from './test.js';
10
- export * from './bitmask.js';
11
10
  export { add, bit, copy, increment, move, remove, replace, test };
12
11
  export declare function getTypes(custom?: JSONPatchOpHandlerMap): {
13
12
  test: import("../types.js").JSONPatchOpHandler;
@@ -7,7 +7,7 @@ import { remove } from './remove.js';
7
7
  import { replace } from './replace.js';
8
8
  import { test } from './test.js';
9
9
  import { text } from './text.js';
10
- export * from './bitmask.js';
10
+ // Export all patch operations
11
11
  export { add, bit, copy, increment, move, remove, replace, test };
12
12
  export function getTypes(custom) {
13
13
  return {
@@ -10,7 +10,7 @@ export const text = {
10
10
  if (!delta || !Array.isArray(delta.ops)) {
11
11
  return 'Invalid delta';
12
12
  }
13
- let existingData = get(state, path);
13
+ const existingData = get(state, path);
14
14
  let doc;
15
15
  if (Array.isArray(existingData)) {
16
16
  if (existingData.length && existingData[0].insert) {
@@ -1,3 +1,4 @@
1
+ import { JSONPatch } from './JSONPatch.js';
1
2
  // We use a function as the target so that `push` and other array methods can be called without error.
2
3
  const proxyFodder = {};
3
4
  export function createPatchProxy(target, patch) {
@@ -1,6 +1,6 @@
1
1
  import { getOpData } from './getOpData.js';
2
2
  export function get(state, path) {
3
3
  // eslint-disable-next-line no-unused-vars
4
- const [keys, lastKey, target] = getOpData(state, path);
4
+ const [, lastKey, target] = getOpData(state, path);
5
5
  return target ? target[lastKey] : undefined;
6
6
  }
@@ -1,3 +1,4 @@
1
+ import { Patches } from '../client/Patches.js';
1
2
  import { signal } from '../event-signal.js';
2
3
  import { breakIntoBatches } from '../utils/batching.js';
3
4
  import { PatchesWebSocket } from './websocket/PatchesWebSocket.js';
@@ -94,7 +94,7 @@ export class PatchesServer {
94
94
  await this._createVersion(docId, currentState, currentChanges);
95
95
  }
96
96
  // 3. Load committed changes *after* the client's baseRev for transformation and idempotency checks
97
- let committedChanges = await this.store.listChanges(docId, {
97
+ const committedChanges = await this.store.listChanges(docId, {
98
98
  startAfter: baseRev,
99
99
  withoutBatchId: batchId,
100
100
  });
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { JSONPatchOp } from './json-patch/types';
1
+ import type { JSONPatchOp } from './json-patch/types.js';
2
2
  export interface Change {
3
3
  /** Unique identifier for the change, generated client-side. */
4
4
  id: string;
@@ -205,7 +205,6 @@ function breakLargeValueOp(origChange, op, maxBytes, startRev) {
205
205
  const targetChunkSize = Math.max(1, valueBudget);
206
206
  const numChunks = Math.ceil(text.length / targetChunkSize);
207
207
  const chunkSize = Math.ceil(text.length / numChunks);
208
- let currentPath = op.path;
209
208
  for (let i = 0; i < text.length; i += chunkSize) {
210
209
  const chunk = text.slice(i, i + chunkSize);
211
210
  const newOp = { op: 'add' }; // Default to add?
package/dist/utils.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { Change, Deferred } from './types.js';
7
7
  * @param changes - Array of changes to split
8
8
  * @returns A tuple containing [changes before baseRev, changes with and after baseRev]
9
9
  */
10
- export declare function splitChanges<T>(changes: Change[]): [Change[], Change[]];
10
+ export declare function splitChanges(changes: Change[]): [Change[], Change[]];
11
11
  /**
12
12
  * Applies a sequence of changes to a state object.
13
13
  * Each change is applied in sequence using the applyPatch function.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
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": {
@@ -66,13 +66,13 @@
66
66
  "@dabble/delta": "^1.2.4"
67
67
  },
68
68
  "devDependencies": {
69
- "@sveltejs/package": "^2.3.10",
69
+ "@sveltejs/package": "^2.3.11",
70
70
  "@types/simple-peer": "^9.11.8",
71
71
  "fake-indexeddb": "^6.0.0",
72
72
  "prettier": "^3.5.3",
73
73
  "typescript": "^5.8.3",
74
- "vite": "^6.2.6",
74
+ "vite": "^6.3.5",
75
75
  "vite-plugin-dts": "^4.5.3",
76
- "vitest": "^3.1.1"
76
+ "vitest": "^3.1.3"
77
77
  }
78
78
  }