@dabble/patches 0.2.1 → 0.2.3

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.
@@ -1,10 +1,11 @@
1
+ import type { JSONPatch } from '../json-patch/JSONPatch.js';
1
2
  import type { Change, PatchesSnapshot } from '../types.js';
2
3
  /**
3
4
  * Represents a document synchronized using JSON patches.
4
5
  * Manages committed state, pending (local-only) changes, and
5
6
  * changes currently being sent to the server.
6
7
  */
7
- export declare class PatchesDoc<T extends object> {
8
+ export declare class PatchesDoc<T extends object = object> {
8
9
  protected _id: string | null;
9
10
  protected _state: T;
10
11
  protected _committedState: T;
@@ -55,7 +56,7 @@ export declare class PatchesDoc<T extends object> {
55
56
  * @param mutator Function modifying a draft state.
56
57
  * @returns The generated Change object or null if no changes occurred.
57
58
  */
58
- change(mutator: (draft: T) => void): Change | null;
59
+ change(mutator: (draft: T, patch: JSONPatch) => void): Change | null;
59
60
  /**
60
61
  * Retrieves pending changes and marks them as sending.
61
62
  * @returns Array of changes ready to be sent to the server.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
- export { Patches } from './client/Patches.js';
2
- export { PatchesDoc } from './client/PatchesDoc.js';
1
+ export { Delta } from '@dabble/delta';
2
+ export * from './client/Patches.js';
3
+ export * from './client/PatchesDoc.js';
4
+ export type * from './event-signal';
5
+ export type * from './json-patch/JSONPatch.js';
6
+ export type { ApplyJSONPatchOptions } from './json-patch/types.js';
7
+ export type * from './persist/PatchesStore.js';
3
8
  export type * from './types';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export { Patches } from './client/Patches.js';
2
- export { PatchesDoc } from './client/PatchesDoc.js';
1
+ export { Delta } from '@dabble/delta';
2
+ export * from './client/Patches.js';
3
+ export * from './client/PatchesDoc.js';
@@ -115,12 +115,3 @@ export declare class JSONPatch {
115
115
  new (ops?: JSONPatchOp[], types?: JSONPatchOpHandlerMap): T;
116
116
  }, ops?: JSONPatchOp[], types?: JSONPatchOpHandlerMap): T;
117
117
  }
118
- export type JSONPath<T> = T extends object ? T extends Array<infer U> ? {
119
- readonly [K in keyof T & number]-?: JSONPathValue<U>;
120
- } : {
121
- readonly [K in keyof T as T[K] extends Function ? never : K]-?: JSONPathValue<NonNullable<T[K]>>;
122
- } : never;
123
- export type JSONPathValue<T> = {
124
- toString(): string;
125
- } & (T extends object ? JSONPath<T> : {});
126
- export declare function createJSONPath<T = unknown>(): JSONPath<T>;
@@ -208,14 +208,3 @@ function checkPath(path) {
208
208
  path = `/${path}`;
209
209
  return path;
210
210
  }
211
- export function createJSONPath() {
212
- const handler = {
213
- get(target, prop) {
214
- if (prop === 'toString') {
215
- return () => target.path ?? '';
216
- }
217
- return new Proxy({ path: `${target.path}/${prop}` }, handler);
218
- },
219
- };
220
- return new Proxy({ path: '' }, handler);
221
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
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": {