@onebuffalolabs/herd-sync 0.1.0 → 0.2.0
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/README.md +36 -4
- package/dist/index.d.mts +90 -8
- package/dist/index.d.ts +90 -8
- package/dist/index.js +311 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +319 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -45,21 +45,53 @@ export default nextConfig;
|
|
|
45
45
|
|
|
46
46
|
### `HerdSyncProvider`
|
|
47
47
|
|
|
48
|
-
Initializes the browser database
|
|
48
|
+
Initializes the browser database, orchestrates background replication, handles conflicts, and manages the inactivity timer.
|
|
49
49
|
|
|
50
50
|
```tsx
|
|
51
51
|
import { HerdSyncProvider } from "@onebuffalolabs/herd-sync";
|
|
52
52
|
|
|
53
53
|
<HerdSyncProvider
|
|
54
|
-
live="{true}"
|
|
55
54
|
name="my_local_db"
|
|
56
|
-
remoteUrl="
|
|
57
|
-
|
|
55
|
+
remoteUrl="https://couchdb.example.com/my_remote_db"
|
|
56
|
+
live
|
|
57
|
+
retry
|
|
58
|
+
idleTimeoutMs={20 * 60 * 1000}
|
|
59
|
+
onConflict={async ({ localDoc, remoteDoc }) => {
|
|
60
|
+
// Return the merged or chosen document; losing revisions are pruned automatically.
|
|
61
|
+
return localDoc;
|
|
62
|
+
}}
|
|
58
63
|
>
|
|
59
64
|
{children}
|
|
60
65
|
</HerdSyncProvider>;
|
|
61
66
|
```
|
|
62
67
|
|
|
68
|
+
- `createPeerAdapter(db)`: Optional factory to host a persistent peer adapter (such as `WebRTCAdapter`) in context across modal toggles and navigation.
|
|
69
|
+
- `onConflict(conflict)`: Optional async resolver receiving `{ docId, localDoc, remoteDoc, conflictingRevs }`. If omitted, unresolved conflicts are exposed via `useHerdSync().conflicts`.
|
|
70
|
+
- `idleTimeoutMs`: Inactivity timeout in milliseconds (defaults to 20 minutes). Pass `0` or `null` to disable auto-disconnect.
|
|
71
|
+
|
|
72
|
+
### `useHerdSync()`
|
|
73
|
+
|
|
74
|
+
Returns the active database, sync status, unresolved conflicts, and manual session controls:
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
const {
|
|
78
|
+
db,
|
|
79
|
+
status,
|
|
80
|
+
peerAdapter,
|
|
81
|
+
peerStatus,
|
|
82
|
+
conflicts,
|
|
83
|
+
conflictCount,
|
|
84
|
+
resolveConflict,
|
|
85
|
+
syncNow,
|
|
86
|
+
disconnect
|
|
87
|
+
} = useHerdSync();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- `syncNow()`: Resets the inactivity timer, triggers an immediate sync on active adapters, and scans for conflicts.
|
|
91
|
+
- `disconnect()`: Stops active adapters and marks the session disconnected (`disconnectReason: "manual"`).
|
|
92
|
+
- `conflicts` / `conflictCount`: Unresolved conflicts when no `onConflict` handler is registered.
|
|
93
|
+
- `resolveConflict(docId, resolver)`: Resolves a specific document conflict and prunes losing revisions.
|
|
94
|
+
|
|
63
95
|
### `useHerdDoc(id, initialDoc?)`
|
|
64
96
|
|
|
65
97
|
Binds a single document to reactive React state. Subscribes to live local and remote database changes automatically.
|
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,11 @@ type PouchDBCtor<T extends HerdDoc> = new (name?: string, options?: PouchDB.Conf
|
|
|
7
7
|
/**
|
|
8
8
|
* Lifecycle connection state for the sync adapter.
|
|
9
9
|
*/
|
|
10
|
-
type SyncConnectionState = "uninitialized" | "idle" | "connecting" | "connected" | "syncing" | "paused" | "error" | "denied";
|
|
10
|
+
type SyncConnectionState = "uninitialized" | "idle" | "connecting" | "connected" | "syncing" | "paused" | "disconnected" | "error" | "denied";
|
|
11
|
+
/**
|
|
12
|
+
* Reason why a sync session transitioned to a disconnected state.
|
|
13
|
+
*/
|
|
14
|
+
type DisconnectReason = "idle" | "manual" | "peer_closed";
|
|
11
15
|
/**
|
|
12
16
|
* Base document shape managed by HerdSync.
|
|
13
17
|
*/
|
|
@@ -46,16 +50,37 @@ interface HerdSyncStatus {
|
|
|
46
50
|
lastSyncedAt: string | null;
|
|
47
51
|
pendingPushes: number;
|
|
48
52
|
error: string | null;
|
|
53
|
+
disconnectReason?: DisconnectReason | null;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* Contract implemented by HerdSync storage adapters.
|
|
52
57
|
*/
|
|
53
58
|
interface SyncAdapter {
|
|
54
|
-
start(): void
|
|
59
|
+
start(): void | Promise<void>;
|
|
55
60
|
stop(): Promise<void>;
|
|
61
|
+
syncNow?(): Promise<void>;
|
|
56
62
|
getStatus(): HerdSyncStatus;
|
|
57
63
|
subscribe(callback: (status: HerdSyncStatus) => void): () => void;
|
|
58
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Context passed to a host-supplied `onConflict` handler when a document has divergent revisions.
|
|
67
|
+
*/
|
|
68
|
+
interface ConflictContext<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
69
|
+
docId: string;
|
|
70
|
+
localDoc: T & {
|
|
71
|
+
_id: string;
|
|
72
|
+
_rev: string;
|
|
73
|
+
};
|
|
74
|
+
remoteDoc: T & {
|
|
75
|
+
_id: string;
|
|
76
|
+
_rev: string;
|
|
77
|
+
};
|
|
78
|
+
conflictingRevs: string[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Async host-supplied conflict resolver invoked when a replicated document has `_conflicts`.
|
|
82
|
+
*/
|
|
83
|
+
type OnConflictHandler<T extends Record<string, unknown> = Record<string, unknown>> = (conflict: ConflictContext<T>) => Promise<T>;
|
|
59
84
|
/**
|
|
60
85
|
* Signature for pluggable conflict resolution functions.
|
|
61
86
|
*/
|
|
@@ -90,7 +115,8 @@ declare class CouchDBAdapter<T extends HerdDoc = HerdDoc> implements SyncAdapter
|
|
|
90
115
|
subscribe(callback: (status: HerdSyncStatus) => void): () => void;
|
|
91
116
|
private updateStatus;
|
|
92
117
|
start(): Promise<void>;
|
|
93
|
-
|
|
118
|
+
syncNow(): Promise<void>;
|
|
119
|
+
stop(reason?: DisconnectReason): Promise<void>;
|
|
94
120
|
}
|
|
95
121
|
|
|
96
122
|
/**
|
|
@@ -110,6 +136,50 @@ declare function createArrayMergeResolver<T extends HerdDoc>(arrayKeys: (keyof T
|
|
|
110
136
|
* writes the winning revision, and marks losing branches as deleted.
|
|
111
137
|
*/
|
|
112
138
|
declare function resolveDocConflicts<T extends HerdDoc>(db: PouchDB.Database<T>, docId: string, options?: ConflictResolutionOptions<T>): Promise<ConflictResolutionResult<T> | null>;
|
|
139
|
+
/**
|
|
140
|
+
* Inspects a single document for `_conflicts` using `open_revs: "all"` and builds a generic `ConflictContext`.
|
|
141
|
+
* Returns `null` if the document does not exist or has no conflicting revisions.
|
|
142
|
+
*/
|
|
143
|
+
declare function getDocumentConflictContext<T extends Record<string, unknown>>(db: PouchDB.Database<T>, docId: string): Promise<ConflictContext<T> | null>;
|
|
144
|
+
/**
|
|
145
|
+
* Resolves a `ConflictContext` using the provided async `onConflict` handler,
|
|
146
|
+
* writes the resolved document, and prunes all losing `_rev` branches via `bulkDocs`.
|
|
147
|
+
*/
|
|
148
|
+
declare function applyConflictResolution<T extends Record<string, unknown>>(db: PouchDB.Database<T>, conflict: ConflictContext<T>, onConflict: OnConflictHandler<T>): Promise<string[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Scans either the given `docIds` or all documents in `db` for `_conflicts`.
|
|
151
|
+
* When `onConflict` is provided, resolves and prunes each conflict; otherwise returns unresolved conflicts.
|
|
152
|
+
*/
|
|
153
|
+
declare function processDatabaseConflicts<T extends Record<string, unknown>>(db: PouchDB.Database<T>, options?: {
|
|
154
|
+
docIds?: string[];
|
|
155
|
+
onConflict?: OnConflictHandler<T>;
|
|
156
|
+
}): Promise<ConflictContext<T>[]>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Default inactivity timeout before an active sync session disconnects (20 minutes).
|
|
160
|
+
*/
|
|
161
|
+
declare const DEFAULT_IDLE_TIMEOUT_MS: number;
|
|
162
|
+
interface IdleSessionControllerOptions {
|
|
163
|
+
idleTimeoutMs?: number | null;
|
|
164
|
+
onIdleTimeout: () => void | Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Tracks sync/peer activity and triggers an idle disconnect callback
|
|
168
|
+
* after `idleTimeoutMs` of inactivity.
|
|
169
|
+
*/
|
|
170
|
+
declare class IdleSessionController {
|
|
171
|
+
private timeoutMs;
|
|
172
|
+
private onIdleTimeout;
|
|
173
|
+
private timer;
|
|
174
|
+
private active;
|
|
175
|
+
constructor(options: IdleSessionControllerOptions);
|
|
176
|
+
isEnabled(): boolean;
|
|
177
|
+
start(): void;
|
|
178
|
+
recordActivity(): void;
|
|
179
|
+
stop(): void;
|
|
180
|
+
updateTimeout(idleTimeoutMs?: number | null): void;
|
|
181
|
+
private scheduleTimer;
|
|
182
|
+
}
|
|
113
183
|
|
|
114
184
|
/**
|
|
115
185
|
* React Context value shape for HerdSync.
|
|
@@ -118,20 +188,32 @@ interface HerdSyncContextValue<T extends HerdDoc = HerdDoc> {
|
|
|
118
188
|
db: PouchDB.Database<T> | null;
|
|
119
189
|
status: HerdSyncStatus;
|
|
120
190
|
adapter: CouchDBAdapter<T> | null;
|
|
191
|
+
peerAdapter: SyncAdapter | null;
|
|
192
|
+
peerStatus: HerdSyncStatus;
|
|
193
|
+
setPeerAdapter: (adapter: SyncAdapter | null) => void;
|
|
194
|
+
conflicts: ConflictContext<T>[];
|
|
195
|
+
conflictCount: number;
|
|
196
|
+
resolveConflict: (docId: string, resolver: OnConflictHandler<T>) => Promise<void>;
|
|
197
|
+
syncNow: () => Promise<void>;
|
|
198
|
+
disconnect: () => Promise<void>;
|
|
121
199
|
}
|
|
122
200
|
/**
|
|
123
201
|
* Props for the HerdSyncProvider component.
|
|
124
202
|
*/
|
|
125
|
-
interface HerdSyncProviderProps extends CouchDBAdapterOptions {
|
|
203
|
+
interface HerdSyncProviderProps<T extends HerdDoc = HerdDoc> extends CouchDBAdapterOptions {
|
|
126
204
|
name: string;
|
|
205
|
+
createPeerAdapter?: (db: PouchDB.Database<T>) => SyncAdapter;
|
|
206
|
+
onConflict?: OnConflictHandler<T>;
|
|
207
|
+
idleTimeoutMs?: number | null;
|
|
127
208
|
children: React.ReactNode;
|
|
128
209
|
}
|
|
129
210
|
/**
|
|
130
|
-
* Top-level provider establishing the local PouchDB instance
|
|
211
|
+
* Top-level provider establishing the local PouchDB instance, sync adapters,
|
|
212
|
+
* generic conflict handling, and configurable inactivity timeout.
|
|
131
213
|
*/
|
|
132
|
-
declare function HerdSyncProvider<T extends HerdDoc = HerdDoc>({ name, remoteUrl, auth, live, retry, backOffMultiplier, initialBackOffMs, maxBackOffMs, children }: HerdSyncProviderProps): React.JSX.Element;
|
|
214
|
+
declare function HerdSyncProvider<T extends HerdDoc = HerdDoc>({ name, remoteUrl, auth, live, retry, backOffMultiplier, initialBackOffMs, maxBackOffMs, createPeerAdapter, onConflict, idleTimeoutMs, children }: HerdSyncProviderProps<T>): React.JSX.Element;
|
|
133
215
|
/**
|
|
134
|
-
* Hook to access the current database instance and
|
|
216
|
+
* Hook to access the current database instance, replication status, conflict state, and session controls.
|
|
135
217
|
*/
|
|
136
218
|
declare function useHerdSync<T extends HerdDoc = HerdDoc>(): HerdSyncContextValue<T>;
|
|
137
219
|
|
|
@@ -150,4 +232,4 @@ interface UseHerdDocReturn<T extends HerdDoc> {
|
|
|
150
232
|
*/
|
|
151
233
|
declare function useHerdDoc<T extends HerdDoc>(id: string, initialDoc?: Partial<T>): UseHerdDocReturn<T>;
|
|
152
234
|
|
|
153
|
-
export { type ConflictResolutionOptions, type ConflictResolutionResult, type ConflictResolver, CouchDBAdapter, type CouchDBAdapterOptions, type HerdDoc, type HerdSyncContextValue, HerdSyncProvider, type HerdSyncProviderProps, type HerdSyncStatus, type PouchDBCtor, type RemoteAuthConfig, type SyncAdapter, type SyncConnectionState, type UseHerdDocReturn, createArrayMergeResolver, resolveDocConflicts, resolveLWW, useHerdDoc, useHerdSync };
|
|
235
|
+
export { type ConflictContext, type ConflictResolutionOptions, type ConflictResolutionResult, type ConflictResolver, CouchDBAdapter, type CouchDBAdapterOptions, DEFAULT_IDLE_TIMEOUT_MS, type DisconnectReason, type HerdDoc, type HerdSyncContextValue, HerdSyncProvider, type HerdSyncProviderProps, type HerdSyncStatus, IdleSessionController, type IdleSessionControllerOptions, type OnConflictHandler, type PouchDBCtor, type RemoteAuthConfig, type SyncAdapter, type SyncConnectionState, type UseHerdDocReturn, applyConflictResolution, createArrayMergeResolver, getDocumentConflictContext, processDatabaseConflicts, resolveDocConflicts, resolveLWW, useHerdDoc, useHerdSync };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,11 @@ type PouchDBCtor<T extends HerdDoc> = new (name?: string, options?: PouchDB.Conf
|
|
|
7
7
|
/**
|
|
8
8
|
* Lifecycle connection state for the sync adapter.
|
|
9
9
|
*/
|
|
10
|
-
type SyncConnectionState = "uninitialized" | "idle" | "connecting" | "connected" | "syncing" | "paused" | "error" | "denied";
|
|
10
|
+
type SyncConnectionState = "uninitialized" | "idle" | "connecting" | "connected" | "syncing" | "paused" | "disconnected" | "error" | "denied";
|
|
11
|
+
/**
|
|
12
|
+
* Reason why a sync session transitioned to a disconnected state.
|
|
13
|
+
*/
|
|
14
|
+
type DisconnectReason = "idle" | "manual" | "peer_closed";
|
|
11
15
|
/**
|
|
12
16
|
* Base document shape managed by HerdSync.
|
|
13
17
|
*/
|
|
@@ -46,16 +50,37 @@ interface HerdSyncStatus {
|
|
|
46
50
|
lastSyncedAt: string | null;
|
|
47
51
|
pendingPushes: number;
|
|
48
52
|
error: string | null;
|
|
53
|
+
disconnectReason?: DisconnectReason | null;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* Contract implemented by HerdSync storage adapters.
|
|
52
57
|
*/
|
|
53
58
|
interface SyncAdapter {
|
|
54
|
-
start(): void
|
|
59
|
+
start(): void | Promise<void>;
|
|
55
60
|
stop(): Promise<void>;
|
|
61
|
+
syncNow?(): Promise<void>;
|
|
56
62
|
getStatus(): HerdSyncStatus;
|
|
57
63
|
subscribe(callback: (status: HerdSyncStatus) => void): () => void;
|
|
58
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Context passed to a host-supplied `onConflict` handler when a document has divergent revisions.
|
|
67
|
+
*/
|
|
68
|
+
interface ConflictContext<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
69
|
+
docId: string;
|
|
70
|
+
localDoc: T & {
|
|
71
|
+
_id: string;
|
|
72
|
+
_rev: string;
|
|
73
|
+
};
|
|
74
|
+
remoteDoc: T & {
|
|
75
|
+
_id: string;
|
|
76
|
+
_rev: string;
|
|
77
|
+
};
|
|
78
|
+
conflictingRevs: string[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Async host-supplied conflict resolver invoked when a replicated document has `_conflicts`.
|
|
82
|
+
*/
|
|
83
|
+
type OnConflictHandler<T extends Record<string, unknown> = Record<string, unknown>> = (conflict: ConflictContext<T>) => Promise<T>;
|
|
59
84
|
/**
|
|
60
85
|
* Signature for pluggable conflict resolution functions.
|
|
61
86
|
*/
|
|
@@ -90,7 +115,8 @@ declare class CouchDBAdapter<T extends HerdDoc = HerdDoc> implements SyncAdapter
|
|
|
90
115
|
subscribe(callback: (status: HerdSyncStatus) => void): () => void;
|
|
91
116
|
private updateStatus;
|
|
92
117
|
start(): Promise<void>;
|
|
93
|
-
|
|
118
|
+
syncNow(): Promise<void>;
|
|
119
|
+
stop(reason?: DisconnectReason): Promise<void>;
|
|
94
120
|
}
|
|
95
121
|
|
|
96
122
|
/**
|
|
@@ -110,6 +136,50 @@ declare function createArrayMergeResolver<T extends HerdDoc>(arrayKeys: (keyof T
|
|
|
110
136
|
* writes the winning revision, and marks losing branches as deleted.
|
|
111
137
|
*/
|
|
112
138
|
declare function resolveDocConflicts<T extends HerdDoc>(db: PouchDB.Database<T>, docId: string, options?: ConflictResolutionOptions<T>): Promise<ConflictResolutionResult<T> | null>;
|
|
139
|
+
/**
|
|
140
|
+
* Inspects a single document for `_conflicts` using `open_revs: "all"` and builds a generic `ConflictContext`.
|
|
141
|
+
* Returns `null` if the document does not exist or has no conflicting revisions.
|
|
142
|
+
*/
|
|
143
|
+
declare function getDocumentConflictContext<T extends Record<string, unknown>>(db: PouchDB.Database<T>, docId: string): Promise<ConflictContext<T> | null>;
|
|
144
|
+
/**
|
|
145
|
+
* Resolves a `ConflictContext` using the provided async `onConflict` handler,
|
|
146
|
+
* writes the resolved document, and prunes all losing `_rev` branches via `bulkDocs`.
|
|
147
|
+
*/
|
|
148
|
+
declare function applyConflictResolution<T extends Record<string, unknown>>(db: PouchDB.Database<T>, conflict: ConflictContext<T>, onConflict: OnConflictHandler<T>): Promise<string[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Scans either the given `docIds` or all documents in `db` for `_conflicts`.
|
|
151
|
+
* When `onConflict` is provided, resolves and prunes each conflict; otherwise returns unresolved conflicts.
|
|
152
|
+
*/
|
|
153
|
+
declare function processDatabaseConflicts<T extends Record<string, unknown>>(db: PouchDB.Database<T>, options?: {
|
|
154
|
+
docIds?: string[];
|
|
155
|
+
onConflict?: OnConflictHandler<T>;
|
|
156
|
+
}): Promise<ConflictContext<T>[]>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Default inactivity timeout before an active sync session disconnects (20 minutes).
|
|
160
|
+
*/
|
|
161
|
+
declare const DEFAULT_IDLE_TIMEOUT_MS: number;
|
|
162
|
+
interface IdleSessionControllerOptions {
|
|
163
|
+
idleTimeoutMs?: number | null;
|
|
164
|
+
onIdleTimeout: () => void | Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Tracks sync/peer activity and triggers an idle disconnect callback
|
|
168
|
+
* after `idleTimeoutMs` of inactivity.
|
|
169
|
+
*/
|
|
170
|
+
declare class IdleSessionController {
|
|
171
|
+
private timeoutMs;
|
|
172
|
+
private onIdleTimeout;
|
|
173
|
+
private timer;
|
|
174
|
+
private active;
|
|
175
|
+
constructor(options: IdleSessionControllerOptions);
|
|
176
|
+
isEnabled(): boolean;
|
|
177
|
+
start(): void;
|
|
178
|
+
recordActivity(): void;
|
|
179
|
+
stop(): void;
|
|
180
|
+
updateTimeout(idleTimeoutMs?: number | null): void;
|
|
181
|
+
private scheduleTimer;
|
|
182
|
+
}
|
|
113
183
|
|
|
114
184
|
/**
|
|
115
185
|
* React Context value shape for HerdSync.
|
|
@@ -118,20 +188,32 @@ interface HerdSyncContextValue<T extends HerdDoc = HerdDoc> {
|
|
|
118
188
|
db: PouchDB.Database<T> | null;
|
|
119
189
|
status: HerdSyncStatus;
|
|
120
190
|
adapter: CouchDBAdapter<T> | null;
|
|
191
|
+
peerAdapter: SyncAdapter | null;
|
|
192
|
+
peerStatus: HerdSyncStatus;
|
|
193
|
+
setPeerAdapter: (adapter: SyncAdapter | null) => void;
|
|
194
|
+
conflicts: ConflictContext<T>[];
|
|
195
|
+
conflictCount: number;
|
|
196
|
+
resolveConflict: (docId: string, resolver: OnConflictHandler<T>) => Promise<void>;
|
|
197
|
+
syncNow: () => Promise<void>;
|
|
198
|
+
disconnect: () => Promise<void>;
|
|
121
199
|
}
|
|
122
200
|
/**
|
|
123
201
|
* Props for the HerdSyncProvider component.
|
|
124
202
|
*/
|
|
125
|
-
interface HerdSyncProviderProps extends CouchDBAdapterOptions {
|
|
203
|
+
interface HerdSyncProviderProps<T extends HerdDoc = HerdDoc> extends CouchDBAdapterOptions {
|
|
126
204
|
name: string;
|
|
205
|
+
createPeerAdapter?: (db: PouchDB.Database<T>) => SyncAdapter;
|
|
206
|
+
onConflict?: OnConflictHandler<T>;
|
|
207
|
+
idleTimeoutMs?: number | null;
|
|
127
208
|
children: React.ReactNode;
|
|
128
209
|
}
|
|
129
210
|
/**
|
|
130
|
-
* Top-level provider establishing the local PouchDB instance
|
|
211
|
+
* Top-level provider establishing the local PouchDB instance, sync adapters,
|
|
212
|
+
* generic conflict handling, and configurable inactivity timeout.
|
|
131
213
|
*/
|
|
132
|
-
declare function HerdSyncProvider<T extends HerdDoc = HerdDoc>({ name, remoteUrl, auth, live, retry, backOffMultiplier, initialBackOffMs, maxBackOffMs, children }: HerdSyncProviderProps): React.JSX.Element;
|
|
214
|
+
declare function HerdSyncProvider<T extends HerdDoc = HerdDoc>({ name, remoteUrl, auth, live, retry, backOffMultiplier, initialBackOffMs, maxBackOffMs, createPeerAdapter, onConflict, idleTimeoutMs, children }: HerdSyncProviderProps<T>): React.JSX.Element;
|
|
133
215
|
/**
|
|
134
|
-
* Hook to access the current database instance and
|
|
216
|
+
* Hook to access the current database instance, replication status, conflict state, and session controls.
|
|
135
217
|
*/
|
|
136
218
|
declare function useHerdSync<T extends HerdDoc = HerdDoc>(): HerdSyncContextValue<T>;
|
|
137
219
|
|
|
@@ -150,4 +232,4 @@ interface UseHerdDocReturn<T extends HerdDoc> {
|
|
|
150
232
|
*/
|
|
151
233
|
declare function useHerdDoc<T extends HerdDoc>(id: string, initialDoc?: Partial<T>): UseHerdDocReturn<T>;
|
|
152
234
|
|
|
153
|
-
export { type ConflictResolutionOptions, type ConflictResolutionResult, type ConflictResolver, CouchDBAdapter, type CouchDBAdapterOptions, type HerdDoc, type HerdSyncContextValue, HerdSyncProvider, type HerdSyncProviderProps, type HerdSyncStatus, type PouchDBCtor, type RemoteAuthConfig, type SyncAdapter, type SyncConnectionState, type UseHerdDocReturn, createArrayMergeResolver, resolveDocConflicts, resolveLWW, useHerdDoc, useHerdSync };
|
|
235
|
+
export { type ConflictContext, type ConflictResolutionOptions, type ConflictResolutionResult, type ConflictResolver, CouchDBAdapter, type CouchDBAdapterOptions, DEFAULT_IDLE_TIMEOUT_MS, type DisconnectReason, type HerdDoc, type HerdSyncContextValue, HerdSyncProvider, type HerdSyncProviderProps, type HerdSyncStatus, IdleSessionController, type IdleSessionControllerOptions, type OnConflictHandler, type PouchDBCtor, type RemoteAuthConfig, type SyncAdapter, type SyncConnectionState, type UseHerdDocReturn, applyConflictResolution, createArrayMergeResolver, getDocumentConflictContext, processDatabaseConflicts, resolveDocConflicts, resolveLWW, useHerdDoc, useHerdSync };
|