@dabble/patches 0.3.0 → 0.3.1

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,4 +1,4 @@
1
- import type { Change, PatchesSnapshot } from '../../types';
1
+ import type { Change, PatchesSnapshot } from '../../types.js';
2
2
  /**
3
3
  * Applies incoming changes from the server that were *not* initiated by this client.
4
4
  * @param snapshot The current state of the document (the state without pending changes applied) and the pending changes.
@@ -1,5 +1,5 @@
1
- import { applyChanges } from '../shared/applyChanges';
2
- import { rebaseChanges } from '../shared/rebaseChanges';
1
+ import { applyChanges } from '../shared/applyChanges.js';
2
+ import { rebaseChanges } from '../shared/rebaseChanges.js';
3
3
  /**
4
4
  * Applies incoming changes from the server that were *not* initiated by this client.
5
5
  * @param snapshot The current state of the document (the state without pending changes applied) and the pending changes.
@@ -1,3 +1,3 @@
1
1
  import type { JSONPatch } from '../..';
2
- import type { Change, PatchesSnapshot } from '../../types';
2
+ import type { Change, PatchesSnapshot } from '../../types.js';
3
3
  export declare function makeChange<T = any>(snapshot: PatchesSnapshot<T>, mutator: (draft: T, patch: JSONPatch) => void, changeMetadata?: Record<string, any>, maxPayloadBytes?: number): Change[];
@@ -1,7 +1,7 @@
1
- import { createChange } from '../../data/change';
2
- import { createJSONPatch } from '../../json-patch/createJSONPatch';
3
- import { breakChange } from './breakChange';
4
- import { createStateFromSnapshot } from './createStateFromSnapshot';
1
+ import { createChange } from '../../data/change.js';
2
+ import { createJSONPatch } from '../../json-patch/createJSONPatch.js';
3
+ import { breakChange } from './breakChange.js';
4
+ import { createStateFromSnapshot } from './createStateFromSnapshot.js';
5
5
  export function makeChange(snapshot, mutator, changeMetadata, maxPayloadBytes) {
6
6
  const pendingChanges = snapshot.changes;
7
7
  const pendingRev = pendingChanges[pendingChanges.length - 1]?.rev ?? snapshot.rev;
@@ -1,5 +1,5 @@
1
- import type { PatchesStoreBackend } from '../../server/types';
2
- import type { Change } from '../../types';
1
+ import type { PatchesStoreBackend } from '../../server/types.js';
2
+ import type { Change } from '../../types.js';
3
3
  /**
4
4
  * Commits a set of changes to a document, applying operational transformation as needed.
5
5
  * @param docId - The ID of the document.
@@ -1,9 +1,9 @@
1
- import { applyChanges } from '../shared/applyChanges';
2
- import { createVersion } from './createVersion';
3
- import { getSnapshotAtRevision } from './getSnapshotAtRevision';
4
- import { getStateAtRevision } from './getStateAtRevision';
5
- import { handleOfflineSessionsAndBatches } from './handleOfflineSessionsAndBatches';
6
- import { transformIncomingChanges } from './transformIncomingChanges';
1
+ import { applyChanges } from '../shared/applyChanges.js';
2
+ import { createVersion } from './createVersion.js';
3
+ import { getSnapshotAtRevision } from './getSnapshotAtRevision.js';
4
+ import { getStateAtRevision } from './getStateAtRevision.js';
5
+ import { handleOfflineSessionsAndBatches } from './handleOfflineSessionsAndBatches.js';
6
+ import { transformIncomingChanges } from './transformIncomingChanges.js';
7
7
  /**
8
8
  * Commits a set of changes to a document, applying operational transformation as needed.
9
9
  * @param docId - The ID of the document.
@@ -1,5 +1,5 @@
1
- import type { Change, EditableVersionMetadata, VersionMetadata } from '../../types';
2
- import type { PatchesStoreBackend } from '../../server/types';
1
+ import type { PatchesStoreBackend } from '../../server/types.js';
2
+ import type { Change, EditableVersionMetadata, VersionMetadata } from '../../types.js';
3
3
  /**
4
4
  * Creates a new version snapshot of a document's state from changes.
5
5
  * @param store The storage backend to save the version to.
@@ -1,5 +1,5 @@
1
- import type { PatchesStoreBackend } from '../../server';
2
- import type { PatchesSnapshot } from '../../types';
1
+ import type { PatchesStoreBackend } from '../../server.js';
2
+ import type { PatchesSnapshot } from '../../types.js';
3
3
  /**
4
4
  * Retrieves the document state of the version before the given revision and changes after up to that revision or all
5
5
  * changes since that version.
@@ -1,5 +1,5 @@
1
- import type { PatchesStoreBackend } from '../../server';
2
- import type { PatchesState } from '../../types';
1
+ import type { PatchesStoreBackend } from '../../server.js';
2
+ import type { PatchesState } from '../../types.js';
3
3
  /**
4
4
  * Gets the state at a specific revision.
5
5
  * @param docId The document ID.
@@ -1,5 +1,5 @@
1
- import { applyChanges } from '../shared/applyChanges';
2
- import { getSnapshotAtRevision } from './getSnapshotAtRevision';
1
+ import { applyChanges } from '../shared/applyChanges.js';
2
+ import { getSnapshotAtRevision } from './getSnapshotAtRevision.js';
3
3
  /**
4
4
  * Gets the state at a specific revision.
5
5
  * @param docId The document ID.
@@ -1,5 +1,5 @@
1
- import type { PatchesStoreBackend } from '../../server';
2
- import type { Change } from '../../types';
1
+ import type { PatchesStoreBackend } from '../../server.js';
2
+ import type { Change } from '../../types.js';
3
3
  /**
4
4
  * Handles offline/large batch versioning logic for multi-batch uploads.
5
5
  * Groups changes into sessions, merges with previous batch if needed, and creates/extends versions.
@@ -1,7 +1,7 @@
1
1
  import { createSortableId } from 'crypto-id';
2
- import { createVersionMetadata } from '../../data/version';
3
- import { applyChanges } from '../shared/applyChanges';
4
- import { getStateAtRevision } from './getStateAtRevision';
2
+ import { createVersionMetadata } from '../../data/version.js';
3
+ import { applyChanges } from '../shared/applyChanges.js';
4
+ import { getStateAtRevision } from './getStateAtRevision.js';
5
5
  /**
6
6
  * Handles offline/large batch versioning logic for multi-batch uploads.
7
7
  * Groups changes into sessions, merges with previous batch if needed, and creates/extends versions.
@@ -1,4 +1,4 @@
1
- import type { Change } from '../../types';
1
+ import type { Change } from '../../types.js';
2
2
  /**
3
3
  * Transforms incoming changes against committed changes that happened *after* the client's baseRev.
4
4
  * The state used for transformation should be the server state *at the client's baseRev*.
@@ -1,3 +1,3 @@
1
- import type { JSONPatchOp } from '../json-patch/types';
2
- import type { Change } from '../types';
1
+ import type { JSONPatchOp } from '../json-patch/types.js';
2
+ import type { Change } from '../types.js';
3
3
  export declare function createChange(baseRev: number, rev: number, ops: JSONPatchOp[], metadata?: Record<string, any>): Change;
@@ -1,4 +1,4 @@
1
- import type { VersionMetadata } from '../types';
1
+ import type { VersionMetadata } from '../types.js';
2
2
  /**
3
3
  * Create a version id for a given document. Uses a sortable 16 character id.
4
4
  * @returns The version id.
@@ -1,5 +1,5 @@
1
1
  import type { Unsubscriber } from '../../event-signal.js';
2
- import type { Change, EditableVersionMetadata, ListVersionsOptions, PatchesState, VersionMetadata } from '../../types';
2
+ import type { Change, EditableVersionMetadata, ListVersionsOptions, PatchesState, VersionMetadata } from '../../types.js';
3
3
  /**
4
4
  * Represents the possible states of a network transport connection.
5
5
  * - 'connecting': Connection is being established
@@ -1,5 +1,5 @@
1
1
  declare class OnlineState {
2
- onOnlineChange: import("../../event-signal").Signal<(isOnline: boolean) => void>;
2
+ onOnlineChange: import("../../event-signal.js").Signal<(isOnline: boolean) => void>;
3
3
  protected _isOnline: boolean;
4
4
  constructor();
5
5
  get isOnline(): boolean;
@@ -1,4 +1,4 @@
1
- import { signal } from '../../event-signal';
1
+ import { signal } from '../../event-signal.js';
2
2
  class OnlineState {
3
3
  constructor() {
4
4
  this.onOnlineChange = signal();
@@ -1,4 +1,4 @@
1
- export { PatchesBranchManager } from './PatchesBranchManager';
2
- export { PatchesHistoryManager } from './PatchesHistoryManager';
3
- export { PatchesServer } from './PatchesServer';
4
- export type { BranchingStoreBackend, PatchesStoreBackend } from './types';
1
+ export { PatchesBranchManager } from './PatchesBranchManager.js';
2
+ export { PatchesHistoryManager } from './PatchesHistoryManager.js';
3
+ export { PatchesServer } from './PatchesServer.js';
4
+ export type { BranchingStoreBackend, PatchesStoreBackend } from './types.js';
@@ -1,3 +1,3 @@
1
- export { PatchesBranchManager } from './PatchesBranchManager';
2
- export { PatchesHistoryManager } from './PatchesHistoryManager';
3
- export { PatchesServer } from './PatchesServer';
1
+ export { PatchesBranchManager } from './PatchesBranchManager.js';
2
+ export { PatchesHistoryManager } from './PatchesHistoryManager.js';
3
+ export { PatchesServer } from './PatchesServer.js';
@@ -1,4 +1,4 @@
1
- import type { Branch, Change, EditableVersionMetadata, ListChangesOptions, ListVersionsOptions, PatchesState, VersionMetadata } from '../types';
1
+ import type { Branch, Change, EditableVersionMetadata, ListChangesOptions, ListVersionsOptions, PatchesState, VersionMetadata } from '../types.js';
2
2
  /**
3
3
  * Interface for a backend storage system for patch synchronization.
4
4
  * Defines methods needed by PatchesServer, PatchesHistoryManager, etc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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": {