@firtoz/collection-sync 4.0.0 → 6.0.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 +46 -0
- package/dist/cache-manager.d.ts +52 -0
- package/dist/cache-manager.js +5 -0
- package/dist/cache-manager.js.map +1 -0
- package/dist/chunk-3EHHMLSV.js +57 -0
- package/dist/chunk-3EHHMLSV.js.map +1 -0
- package/dist/chunk-43KYAIKY.js +46 -0
- package/dist/chunk-43KYAIKY.js.map +1 -0
- package/dist/chunk-4BEXLBCH.js +64 -0
- package/dist/chunk-4BEXLBCH.js.map +1 -0
- package/dist/chunk-5V6BSQAB.js +148 -0
- package/dist/chunk-5V6BSQAB.js.map +1 -0
- package/dist/chunk-5VMFQT5Z.js +112 -0
- package/dist/chunk-5VMFQT5Z.js.map +1 -0
- package/dist/chunk-6EHROJFY.js +111 -0
- package/dist/chunk-6EHROJFY.js.map +1 -0
- package/dist/chunk-6X3434GJ.js +21 -0
- package/dist/chunk-6X3434GJ.js.map +1 -0
- package/dist/chunk-BGJH6PH2.js +175 -0
- package/dist/chunk-BGJH6PH2.js.map +1 -0
- package/dist/chunk-BJJEAKXL.js +252 -0
- package/dist/chunk-BJJEAKXL.js.map +1 -0
- package/dist/chunk-GWIOC5CP.js +51 -0
- package/dist/chunk-GWIOC5CP.js.map +1 -0
- package/dist/chunk-HMLY7DHA.js +12 -0
- package/dist/chunk-HMLY7DHA.js.map +1 -0
- package/dist/chunk-I6RJWBGF.js +112 -0
- package/dist/chunk-I6RJWBGF.js.map +1 -0
- package/dist/chunk-M5MJHS6A.js +10 -0
- package/dist/chunk-M5MJHS6A.js.map +1 -0
- package/dist/chunk-O3KBDCEI.js +615 -0
- package/dist/chunk-O3KBDCEI.js.map +1 -0
- package/dist/chunk-OP53UBPN.js +19 -0
- package/dist/chunk-OP53UBPN.js.map +1 -0
- package/dist/chunk-P3JOTUAB.js +802 -0
- package/dist/chunk-P3JOTUAB.js.map +1 -0
- package/dist/chunk-QJP4GSJH.js +373 -0
- package/dist/chunk-QJP4GSJH.js.map +1 -0
- package/dist/chunk-RDDS7JQW.js +623 -0
- package/dist/chunk-RDDS7JQW.js.map +1 -0
- package/dist/chunk-TEH7V76G.js +209 -0
- package/dist/chunk-TEH7V76G.js.map +1 -0
- package/dist/chunk-UJ24XW52.js +20 -0
- package/dist/chunk-UJ24XW52.js.map +1 -0
- package/dist/chunk-UVZJL6QV.js +18 -0
- package/dist/chunk-UVZJL6QV.js.map +1 -0
- package/dist/chunk-XC4QNFSQ.js +238 -0
- package/dist/chunk-XC4QNFSQ.js.map +1 -0
- package/dist/chunk-YD5LVGWX.js +125 -0
- package/dist/chunk-YD5LVGWX.js.map +1 -0
- package/dist/chunk-YYGPIHHJ.js +166 -0
- package/dist/chunk-YYGPIHHJ.js.map +1 -0
- package/dist/connect-partial-sync.d.ts +41 -0
- package/dist/connect-partial-sync.js +6 -0
- package/dist/connect-partial-sync.js.map +1 -0
- package/dist/connect-sync.d.ts +26 -0
- package/dist/connect-sync.js +5 -0
- package/dist/connect-sync.js.map +1 -0
- package/dist/create-partial-synced-collection.d.ts +24 -0
- package/dist/create-partial-synced-collection.js +8 -0
- package/dist/create-partial-synced-collection.js.map +1 -0
- package/dist/create-synced-collection.d.ts +26 -0
- package/dist/create-synced-collection.js +8 -0
- package/dist/create-synced-collection.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/partial-sync-client-bridge.d.ts +157 -0
- package/dist/partial-sync-client-bridge.js +6 -0
- package/dist/partial-sync-client-bridge.js.map +1 -0
- package/dist/partial-sync-interest.d.ts +48 -0
- package/dist/partial-sync-interest.js +6 -0
- package/dist/partial-sync-interest.js.map +1 -0
- package/dist/partial-sync-mutation-handler.d.ts +31 -0
- package/dist/partial-sync-mutation-handler.js +6 -0
- package/dist/partial-sync-mutation-handler.js.map +1 -0
- package/dist/partial-sync-predicate-match.d.ts +8 -0
- package/dist/partial-sync-predicate-match.js +4 -0
- package/dist/partial-sync-predicate-match.js.map +1 -0
- package/dist/partial-sync-row-key.d.ts +41 -0
- package/dist/partial-sync-row-key.js +4 -0
- package/dist/partial-sync-row-key.js.map +1 -0
- package/dist/partial-sync-server-bridge.d.ts +102 -0
- package/dist/partial-sync-server-bridge.js +8 -0
- package/dist/partial-sync-server-bridge.js.map +1 -0
- package/dist/react/constants.d.ts +12 -0
- package/dist/react/constants.js +4 -0
- package/dist/react/constants.js.map +1 -0
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.js +17 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/partial-sync-adapter.d.ts +40 -0
- package/dist/react/partial-sync-adapter.js +4 -0
- package/dist/react/partial-sync-adapter.js.map +1 -0
- package/dist/react/partial-sync-utils.d.ts +42 -0
- package/dist/react/partial-sync-utils.js +5 -0
- package/dist/react/partial-sync-utils.js.map +1 -0
- package/dist/react/range-conditions-expression.d.ts +49 -0
- package/dist/react/range-conditions-expression.js +4 -0
- package/dist/react/range-conditions-expression.js.map +1 -0
- package/dist/react/types.d.ts +196 -0
- package/dist/react/types.js +3 -0
- package/dist/react/types.js.map +1 -0
- package/dist/react/usePartialSyncCollection.d.ts +20 -0
- package/dist/react/usePartialSyncCollection.js +10 -0
- package/dist/react/usePartialSyncCollection.js.map +1 -0
- package/dist/react/usePartialSyncViewport.d.ts +20 -0
- package/dist/react/usePartialSyncViewport.js +7 -0
- package/dist/react/usePartialSyncViewport.js.map +1 -0
- package/dist/react/usePartialSyncWindow.d.ts +17 -0
- package/dist/react/usePartialSyncWindow.js +12 -0
- package/dist/react/usePartialSyncWindow.js.map +1 -0
- package/dist/react/usePredicateFilteredRows.d.ts +20 -0
- package/dist/react/usePredicateFilteredRows.js +6 -0
- package/dist/react/usePredicateFilteredRows.js.map +1 -0
- package/dist/sync-client-bridge.d.ts +48 -0
- package/dist/sync-client-bridge.js +6 -0
- package/dist/sync-client-bridge.js.map +1 -0
- package/dist/sync-protocol.d.ts +378 -0
- package/dist/sync-protocol.js +4 -0
- package/dist/sync-protocol.js.map +1 -0
- package/dist/sync-server-bridge.d.ts +35 -0
- package/dist/sync-server-bridge.js +6 -0
- package/dist/sync-server-bridge.js.map +1 -0
- package/dist/with-sync.d.ts +107 -0
- package/dist/with-sync.js +7 -0
- package/dist/with-sync.js.map +1 -0
- package/package.json +27 -21
- package/src/connect-partial-sync.ts +16 -12
- package/src/connect-sync.ts +12 -10
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Ref } from '@tanstack/db';
|
|
2
|
+
import { PartialSyncRowShape } from '../partial-sync-row-key.js';
|
|
3
|
+
import { RangeCondition } from '../sync-protocol.js';
|
|
4
|
+
import '@firtoz/db-helpers';
|
|
5
|
+
import 'zod';
|
|
6
|
+
|
|
7
|
+
declare abstract class BaseExpression<T = any> {
|
|
8
|
+
abstract type: string;
|
|
9
|
+
/** @internal - Type brand for TypeScript inference */
|
|
10
|
+
readonly __returnType: T;
|
|
11
|
+
}
|
|
12
|
+
declare class PropRef<T = any> extends BaseExpression<T> {
|
|
13
|
+
path: Array<string>;
|
|
14
|
+
type: "ref";
|
|
15
|
+
constructor(path: Array<string>);
|
|
16
|
+
}
|
|
17
|
+
declare class Value<T = any> extends BaseExpression<T> {
|
|
18
|
+
value: T;
|
|
19
|
+
type: "val";
|
|
20
|
+
constructor(value: T);
|
|
21
|
+
}
|
|
22
|
+
declare class Func<T = any> extends BaseExpression<T> {
|
|
23
|
+
name: string;
|
|
24
|
+
args: Array<BasicExpression>;
|
|
25
|
+
type: "func";
|
|
26
|
+
constructor(name: string, // such as eq, gt, lt, upper, lower, etc.
|
|
27
|
+
args: Array<BasicExpression>);
|
|
28
|
+
}
|
|
29
|
+
type BasicExpression<T = any> = PropRef<T> | Value<T> | Func<T>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Row ref from `q.from({ items: collection }).where(({ items }) => …)`.
|
|
33
|
+
* Column access must match {@link RangeCondition.column} names on the stored row shape.
|
|
34
|
+
*
|
|
35
|
+
* Uses TanStack {@link Ref} so column reads are `ExpressionLike` (e.g. for `inArray`), not `unknown`.
|
|
36
|
+
*/
|
|
37
|
+
type PredicateRowRef = Ref<PartialSyncRowShape & Record<string, unknown>>;
|
|
38
|
+
/**
|
|
39
|
+
* Row accepted by {@link buildRangeConditionsAndExpression}: live query refs or plain objects (e.g. tests).
|
|
40
|
+
* Dynamic `column` access yields `unknown`, which TanStack comparison helpers still accept.
|
|
41
|
+
*/
|
|
42
|
+
type PredicateRangeBuildRow = PredicateRowRef | Record<string, unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Builds a TanStack DB `where` expression AND-ing all conditions (same semantics as
|
|
45
|
+
* {@link matchesPredicate} for plain property rows).
|
|
46
|
+
*/
|
|
47
|
+
declare function buildRangeConditionsAndExpression(row: PredicateRangeBuildRow, conditions: RangeCondition[]): BasicExpression<boolean>;
|
|
48
|
+
|
|
49
|
+
export { type PredicateRangeBuildRow, type PredicateRowRef, buildRangeConditionsAndExpression };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"range-conditions-expression.js"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { UtilsRecord, Collection } from '@tanstack/db';
|
|
2
|
+
import { CacheManager } from '../cache-manager.js';
|
|
3
|
+
import { PartialSyncClientBridge, PartialSyncState, PartialSyncReconcileResult } from '../partial-sync-client-bridge.js';
|
|
4
|
+
import { PartialSyncViewportAdapter } from './partial-sync-adapter.js';
|
|
5
|
+
import { ConnectPartialSyncTransport } from '../connect-partial-sync.js';
|
|
6
|
+
import { SyncClientBridge } from '../sync-client-bridge.js';
|
|
7
|
+
import { PartialSyncRowShape } from '../partial-sync-row-key.js';
|
|
8
|
+
export { PartialSyncRowRef, PartialSyncRowVersion } from '../partial-sync-row-key.js';
|
|
9
|
+
import { SyncClientMessage, RangeCondition } from '../sync-protocol.js';
|
|
10
|
+
import '@firtoz/db-helpers';
|
|
11
|
+
import '../partial-sync-interest.js';
|
|
12
|
+
import 'zod';
|
|
13
|
+
|
|
14
|
+
/** Row shape for partial-sync React hooks (mandatory `updatedAt` for fingerprints / reconciliation). */
|
|
15
|
+
type PartialSyncItem = PartialSyncRowShape;
|
|
16
|
+
/**
|
|
17
|
+
* Minimal collection surface for partial-sync window hooks (TanStack `Collection` satisfies this
|
|
18
|
+
* when `get` / `entries` are typed consistently).
|
|
19
|
+
*/
|
|
20
|
+
type PartialSyncCollection<TItem extends PartialSyncItem> = {
|
|
21
|
+
get(key: string | number): TItem | undefined;
|
|
22
|
+
subscribeChanges(callback: (changes: unknown[]) => void, options?: {
|
|
23
|
+
includeInitialState?: boolean;
|
|
24
|
+
}): {
|
|
25
|
+
unsubscribe: () => void;
|
|
26
|
+
};
|
|
27
|
+
entries(): IterableIterator<[string | number, TItem]>;
|
|
28
|
+
/** TanStack collections use `UtilsRecord`; runtime must include `receiveSync` / `truncate`. */
|
|
29
|
+
utils: UtilsRecord;
|
|
30
|
+
};
|
|
31
|
+
type ViewportInfo = {
|
|
32
|
+
firstVisibleIndex: number;
|
|
33
|
+
lastVisibleIndex: number;
|
|
34
|
+
};
|
|
35
|
+
/** Per global row index: where the cell’s data comes from (for UI / debugging). */
|
|
36
|
+
type PartialSyncRowSlot = "ready" | "ready_global" | "stale_map" | "server" | "none";
|
|
37
|
+
type PartialSyncRowSlotView<TItem extends PartialSyncItem> = {
|
|
38
|
+
row: TItem | undefined;
|
|
39
|
+
slot: PartialSyncRowSlot;
|
|
40
|
+
};
|
|
41
|
+
type UsePartialSyncWindowOptions<TItem extends PartialSyncItem, TSortColumn extends keyof TItem & string = keyof TItem & string> = {
|
|
42
|
+
collection: PartialSyncCollection<TItem>;
|
|
43
|
+
sort: {
|
|
44
|
+
column: TSortColumn;
|
|
45
|
+
direction: "asc" | "desc";
|
|
46
|
+
};
|
|
47
|
+
getSortValue: (row: TItem, column: TSortColumn) => unknown;
|
|
48
|
+
wsUrl: string;
|
|
49
|
+
wsTransport?: ConnectPartialSyncTransport;
|
|
50
|
+
/** Use a module-level function or `useCallback`; inline arrows are a new reference every render. */
|
|
51
|
+
serializeJson?: (value: unknown) => string;
|
|
52
|
+
/** Use a module-level function or `useCallback`; inline arrows are a new reference every render. */
|
|
53
|
+
deserializeJson?: (raw: string) => unknown;
|
|
54
|
+
getVersionMs?: (row: TItem) => number;
|
|
55
|
+
getSortPositions?: (row: TItem) => Record<string, unknown>;
|
|
56
|
+
pageLimit?: number;
|
|
57
|
+
seekCooldownMs?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Stable id for the **logical** collection instance (e.g. `${backend}-${roomId}`). The partial
|
|
60
|
+
* window resets (truncate + index map) when this or {@link sort} changes — **not** when the
|
|
61
|
+
* TanStack `collection` reference churns. Omit only if the collection instance is stable for the
|
|
62
|
+
* hook lifetime; otherwise local edits can spuriously reset the window.
|
|
63
|
+
*/
|
|
64
|
+
partialWindowResetKey?: string;
|
|
65
|
+
/**
|
|
66
|
+
* When set, `mutateBatch` / ack / `syncBatch` route through this bridge; `clientId` matches
|
|
67
|
+
* {@link PartialSyncClientBridge}. Use with {@link createPartialSyncedCollection} / {@link withSync}.
|
|
68
|
+
*/
|
|
69
|
+
mutationBridge?: SyncClientBridge<TItem>;
|
|
70
|
+
/**
|
|
71
|
+
* Called once when the WebSocket transport `send` is ready (same function {@link withSync} / mutation bridge use).
|
|
72
|
+
*/
|
|
73
|
+
mergeTransportSend?: (send: (msg: SyncClientMessage) => void) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Must match the server's partial-sync {@link PartialSyncServerBridgeOptions.collectionId} and align with
|
|
76
|
+
* {@link SyncClientBridgeOptions.collectionId} on {@link mutationBridge}.
|
|
77
|
+
*/
|
|
78
|
+
collectionId?: string;
|
|
79
|
+
/**
|
|
80
|
+
* `confirmed` filters dense `rows` to {@link PartialSyncClientBridge.serverConfirmedKeys} only
|
|
81
|
+
* (same semantics as {@link UsePartialSyncViewportOptions.cacheDisplayMode}).
|
|
82
|
+
*/
|
|
83
|
+
cacheDisplayMode?: CacheDisplayMode;
|
|
84
|
+
};
|
|
85
|
+
type UsePartialSyncWindowResult<TItem extends PartialSyncItem> = {
|
|
86
|
+
rows: TItem[];
|
|
87
|
+
windowStartIndex: number;
|
|
88
|
+
totalCount: number;
|
|
89
|
+
/**
|
|
90
|
+
* True while a server `requestRangeQuery` is in flight (cursor append or offset seek).
|
|
91
|
+
* False for cache-only window moves (`tryIds` / fingerprint `upToDate` without a round-trip).
|
|
92
|
+
*/
|
|
93
|
+
rangeRequestInFlight: boolean;
|
|
94
|
+
hasMore: boolean;
|
|
95
|
+
bridgeState: PartialSyncState;
|
|
96
|
+
bridge: PartialSyncClientBridge<TItem>;
|
|
97
|
+
cacheManager: CacheManager<TItem>;
|
|
98
|
+
fetchNext: () => Promise<void>;
|
|
99
|
+
seekToViewport: (firstVisibleIndex: number, opts?: {
|
|
100
|
+
scrollSettled?: boolean;
|
|
101
|
+
lastVisibleIndex?: number;
|
|
102
|
+
/** Skip density/cooldown short-circuits (e.g. index map out of sync with collection). */
|
|
103
|
+
force?: boolean;
|
|
104
|
+
}) => void;
|
|
105
|
+
seekAfterScrollSettled: (firstVisibleIndex: number, lastVisibleIndex?: number) => void;
|
|
106
|
+
viewportInfo: ViewportInfo;
|
|
107
|
+
setViewportInfo: (info: ViewportInfo) => void;
|
|
108
|
+
lastSeekMeta: {
|
|
109
|
+
offset: number;
|
|
110
|
+
reason: "scroll" | "scrollSettled";
|
|
111
|
+
} | null;
|
|
112
|
+
/**
|
|
113
|
+
* Resolve one global index via index map + collection, and classify the cell.
|
|
114
|
+
* Use this for row UI so cached rows still render when the dense `rows` window has not caught up.
|
|
115
|
+
*/
|
|
116
|
+
getRowSlot: (globalIndex: number) => PartialSyncRowSlotView<TItem>;
|
|
117
|
+
};
|
|
118
|
+
/** Collection usable with {@link useLiveQuery} and partial-sync helpers. */
|
|
119
|
+
type PartialSyncLiveCollection<TItem extends PartialSyncItem> = PartialSyncCollection<TItem> & Collection<TItem, string | number, UtilsRecord>;
|
|
120
|
+
type CacheDisplayMode = "immediate" | "confirmed";
|
|
121
|
+
type UsePredicateFilteredRowsOptions<TItem extends PartialSyncItem, TSortColumn extends keyof TItem & string = keyof TItem & string> = {
|
|
122
|
+
collection: PartialSyncLiveCollection<TItem>;
|
|
123
|
+
conditions: RangeCondition[];
|
|
124
|
+
sort: {
|
|
125
|
+
column: TSortColumn;
|
|
126
|
+
direction: "asc" | "desc";
|
|
127
|
+
};
|
|
128
|
+
getSortValue: (row: TItem, column: TSortColumn) => unknown;
|
|
129
|
+
/**
|
|
130
|
+
* For predicate `column` strings when using a custom row shape; the live-query path reads
|
|
131
|
+
* properties named in {@link RangeCondition.column} on each row (same as default column read).
|
|
132
|
+
*/
|
|
133
|
+
getColumnValue?: (row: TItem, column: string) => unknown;
|
|
134
|
+
limit?: number;
|
|
135
|
+
/**
|
|
136
|
+
* `immediate`: show all rows matching the predicate (including cache-only).
|
|
137
|
+
* `confirmed`: only rows whose keys appear in {@link confirmedRowKeys} (from the bridge).
|
|
138
|
+
*/
|
|
139
|
+
cacheDisplayMode?: CacheDisplayMode;
|
|
140
|
+
/** Required when `cacheDisplayMode` is `"confirmed"`; typically `bridge.serverConfirmedKeys`. */
|
|
141
|
+
confirmedRowKeys?: ReadonlySet<string | number>;
|
|
142
|
+
/** Pass `bridge.serverConfirmedKeysRevision` so React re-runs the query when the set mutates. */
|
|
143
|
+
confirmedKeysRevision?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Row ids that stay visible even when they no longer match the viewport predicate (union with
|
|
146
|
+
* predicate hits). Useful for in-progress drags or pinned selections. Rows must already exist
|
|
147
|
+
* in the local collection.
|
|
148
|
+
*/
|
|
149
|
+
alwaysIncludeRowIds?: readonly string[];
|
|
150
|
+
};
|
|
151
|
+
type UsePartialSyncCollectionOptions<TItem extends PartialSyncItem> = {
|
|
152
|
+
collection: PartialSyncCollection<TItem>;
|
|
153
|
+
mutationBridge: SyncClientBridge<TItem>;
|
|
154
|
+
wsUrl: string;
|
|
155
|
+
wsTransport?: ConnectPartialSyncTransport;
|
|
156
|
+
serializeJson?: (value: unknown) => string;
|
|
157
|
+
deserializeJson?: (raw: string) => unknown;
|
|
158
|
+
mergeTransportSend?: (send: (msg: SyncClientMessage) => void) => void;
|
|
159
|
+
collectionId?: string;
|
|
160
|
+
beforeApplyRows?: (rows: TItem[]) => Promise<void>;
|
|
161
|
+
};
|
|
162
|
+
type UsePartialSyncCollectionResult<TItem extends PartialSyncItem> = {
|
|
163
|
+
bridge: PartialSyncClientBridge<TItem>;
|
|
164
|
+
bridgeState: PartialSyncState;
|
|
165
|
+
};
|
|
166
|
+
type UsePartialSyncViewportOptions<TItem extends PartialSyncItem, TViewport, TSortColumn extends keyof TItem & string> = {
|
|
167
|
+
bridge: PartialSyncClientBridge<TItem>;
|
|
168
|
+
/** From {@link usePartialSyncCollection}; drives {@link UsePartialSyncViewportResult.totalCount}. */
|
|
169
|
+
bridgeState: PartialSyncState;
|
|
170
|
+
collection: PartialSyncLiveCollection<TItem>;
|
|
171
|
+
adapter: PartialSyncViewportAdapter<TItem, TViewport, TSortColumn>;
|
|
172
|
+
viewport: TViewport;
|
|
173
|
+
predicateLimit: number;
|
|
174
|
+
prefetchPad?: number;
|
|
175
|
+
quietMs?: number;
|
|
176
|
+
maxWaitMs?: number;
|
|
177
|
+
/**
|
|
178
|
+
* Used when the bridge has not yet reported `totalCount` (e.g. world size for sparse grids).
|
|
179
|
+
*/
|
|
180
|
+
totalCountFallback?: number;
|
|
181
|
+
getColumnValue?: (row: TItem, column: string) => unknown;
|
|
182
|
+
cacheDisplayMode?: CacheDisplayMode;
|
|
183
|
+
/**
|
|
184
|
+
* Ids to always include in {@link UsePartialSyncViewportResult.viewportRows} in addition to
|
|
185
|
+
* rows matching the viewport predicate (see {@link UsePredicateFilteredRowsOptions.alwaysIncludeRowIds}).
|
|
186
|
+
*/
|
|
187
|
+
alwaysIncludeRowIds?: readonly string[];
|
|
188
|
+
/** After a successful manifest reconcile (re-entry with cached keys), receive `movedHints` etc. */
|
|
189
|
+
onRangeReconcile?: (result: PartialSyncReconcileResult<TItem>) => void;
|
|
190
|
+
};
|
|
191
|
+
type UsePartialSyncViewportResult<TItem extends PartialSyncItem> = {
|
|
192
|
+
viewportRows: TItem[];
|
|
193
|
+
totalCount: number;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export { type CacheDisplayMode, type PartialSyncCollection, type PartialSyncItem, type PartialSyncLiveCollection, PartialSyncRowShape, type PartialSyncRowSlot, type PartialSyncRowSlotView, type UsePartialSyncCollectionOptions, type UsePartialSyncCollectionResult, type UsePartialSyncViewportOptions, type UsePartialSyncViewportResult, type UsePartialSyncWindowOptions, type UsePartialSyncWindowResult, type UsePredicateFilteredRowsOptions, type ViewportInfo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PartialSyncItem, UsePartialSyncCollectionOptions, UsePartialSyncCollectionResult } from './types.js';
|
|
2
|
+
import '@tanstack/db';
|
|
3
|
+
import '../cache-manager.js';
|
|
4
|
+
import '../partial-sync-row-key.js';
|
|
5
|
+
import '../partial-sync-client-bridge.js';
|
|
6
|
+
import '@firtoz/db-helpers';
|
|
7
|
+
import '../sync-protocol.js';
|
|
8
|
+
import 'zod';
|
|
9
|
+
import '../partial-sync-interest.js';
|
|
10
|
+
import './partial-sync-adapter.js';
|
|
11
|
+
import '../connect-partial-sync.js';
|
|
12
|
+
import '../sync-client-bridge.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* WebSocket + {@link PartialSyncClientBridge} wiring shared by predicate viewports and custom UIs.
|
|
16
|
+
* Pair with {@link usePartialSyncViewport} for N-dimensional `rangeQuery` + local predicate rows.
|
|
17
|
+
*/
|
|
18
|
+
declare function usePartialSyncCollection<TItem extends PartialSyncItem>({ collection, mutationBridge, wsUrl, wsTransport, serializeJson, deserializeJson, mergeTransportSend, collectionId, beforeApplyRows, }: UsePartialSyncCollectionOptions<TItem>): UsePartialSyncCollectionResult<TItem>;
|
|
19
|
+
|
|
20
|
+
export { usePartialSyncCollection };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { usePartialSyncCollection } from '../chunk-I6RJWBGF.js';
|
|
2
|
+
import '../chunk-4BEXLBCH.js';
|
|
3
|
+
import '../chunk-XC4QNFSQ.js';
|
|
4
|
+
import '../chunk-P3JOTUAB.js';
|
|
5
|
+
import '../chunk-BJJEAKXL.js';
|
|
6
|
+
import '../chunk-3EHHMLSV.js';
|
|
7
|
+
import '../chunk-UJ24XW52.js';
|
|
8
|
+
import '../chunk-HMLY7DHA.js';
|
|
9
|
+
//# sourceMappingURL=usePartialSyncCollection.js.map
|
|
10
|
+
//# sourceMappingURL=usePartialSyncCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"usePartialSyncCollection.js"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PartialSyncItem, UsePartialSyncViewportOptions, UsePartialSyncViewportResult } from './types.js';
|
|
2
|
+
import '@tanstack/db';
|
|
3
|
+
import '../cache-manager.js';
|
|
4
|
+
import '../partial-sync-row-key.js';
|
|
5
|
+
import '../partial-sync-client-bridge.js';
|
|
6
|
+
import '@firtoz/db-helpers';
|
|
7
|
+
import '../sync-protocol.js';
|
|
8
|
+
import 'zod';
|
|
9
|
+
import '../partial-sync-interest.js';
|
|
10
|
+
import './partial-sync-adapter.js';
|
|
11
|
+
import '../connect-partial-sync.js';
|
|
12
|
+
import '../sync-client-bridge.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Predicate viewport sync: debounced server `rangeQuery` for a moving logical viewport plus
|
|
16
|
+
* {@link usePredicateFilteredRows} for the visible rows already in the local collection.
|
|
17
|
+
*/
|
|
18
|
+
declare function usePartialSyncViewport<TItem extends PartialSyncItem, TViewport, TSortColumn extends keyof TItem & string>({ bridge, bridgeState, collection, adapter, viewport, predicateLimit, prefetchPad, quietMs, maxWaitMs, totalCountFallback, getColumnValue, cacheDisplayMode, alwaysIncludeRowIds, onRangeReconcile, }: UsePartialSyncViewportOptions<TItem, TViewport, TSortColumn>): UsePartialSyncViewportResult<TItem>;
|
|
19
|
+
|
|
20
|
+
export { usePartialSyncViewport };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { usePartialSyncViewport } from '../chunk-BGJH6PH2.js';
|
|
2
|
+
import '../chunk-YD5LVGWX.js';
|
|
3
|
+
import '../chunk-43KYAIKY.js';
|
|
4
|
+
import '../chunk-M5MJHS6A.js';
|
|
5
|
+
import '../chunk-HMLY7DHA.js';
|
|
6
|
+
//# sourceMappingURL=usePartialSyncViewport.js.map
|
|
7
|
+
//# sourceMappingURL=usePartialSyncViewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"usePartialSyncViewport.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PartialSyncItem, UsePartialSyncWindowOptions, UsePartialSyncWindowResult } from './types.js';
|
|
2
|
+
export { DEFAULT_PAGE_LIMIT, DEFAULT_SEEK_COOLDOWN_MS, DEFAULT_SEEK_ROW_GAP, DEFAULT_VIEWPORT_RANGE_MAX_WAIT_MS, DEFAULT_VIEWPORT_RANGE_QUIET_MS } from './constants.js';
|
|
3
|
+
import '@tanstack/db';
|
|
4
|
+
import '../cache-manager.js';
|
|
5
|
+
import '../partial-sync-row-key.js';
|
|
6
|
+
import '../partial-sync-client-bridge.js';
|
|
7
|
+
import '@firtoz/db-helpers';
|
|
8
|
+
import '../sync-protocol.js';
|
|
9
|
+
import 'zod';
|
|
10
|
+
import '../partial-sync-interest.js';
|
|
11
|
+
import './partial-sync-adapter.js';
|
|
12
|
+
import '../connect-partial-sync.js';
|
|
13
|
+
import '../sync-client-bridge.js';
|
|
14
|
+
|
|
15
|
+
declare function usePartialSyncWindow<TItem extends PartialSyncItem, TSortColumn extends keyof TItem & string>({ collection, sort, getSortValue, wsUrl, wsTransport, serializeJson, deserializeJson, getVersionMs, getSortPositions, pageLimit, seekCooldownMs, partialWindowResetKey, mutationBridge, mergeTransportSend, collectionId, cacheDisplayMode, }: UsePartialSyncWindowOptions<TItem, TSortColumn>): UsePartialSyncWindowResult<TItem>;
|
|
16
|
+
|
|
17
|
+
export { usePartialSyncWindow };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { usePartialSyncWindow } from '../chunk-O3KBDCEI.js';
|
|
2
|
+
export { DEFAULT_PAGE_LIMIT, DEFAULT_SEEK_COOLDOWN_MS, DEFAULT_SEEK_ROW_GAP, DEFAULT_VIEWPORT_RANGE_MAX_WAIT_MS, DEFAULT_VIEWPORT_RANGE_QUIET_MS } from '../chunk-M5MJHS6A.js';
|
|
3
|
+
import '../chunk-4BEXLBCH.js';
|
|
4
|
+
import '../chunk-5V6BSQAB.js';
|
|
5
|
+
import '../chunk-XC4QNFSQ.js';
|
|
6
|
+
import '../chunk-P3JOTUAB.js';
|
|
7
|
+
import '../chunk-BJJEAKXL.js';
|
|
8
|
+
import '../chunk-3EHHMLSV.js';
|
|
9
|
+
import '../chunk-UJ24XW52.js';
|
|
10
|
+
import '../chunk-HMLY7DHA.js';
|
|
11
|
+
//# sourceMappingURL=usePartialSyncWindow.js.map
|
|
12
|
+
//# sourceMappingURL=usePartialSyncWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"usePartialSyncWindow.js"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PartialSyncItem, UsePredicateFilteredRowsOptions } from './types.js';
|
|
2
|
+
import '@tanstack/db';
|
|
3
|
+
import '../cache-manager.js';
|
|
4
|
+
import '../partial-sync-row-key.js';
|
|
5
|
+
import '../partial-sync-client-bridge.js';
|
|
6
|
+
import '@firtoz/db-helpers';
|
|
7
|
+
import '../sync-protocol.js';
|
|
8
|
+
import 'zod';
|
|
9
|
+
import '../partial-sync-interest.js';
|
|
10
|
+
import './partial-sync-adapter.js';
|
|
11
|
+
import '../connect-partial-sync.js';
|
|
12
|
+
import '../sync-client-bridge.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Reactive predicate filter + sort + limit via TanStack DB `useLiveQuery` (IVM), instead of
|
|
16
|
+
* scanning the whole collection on each change.
|
|
17
|
+
*/
|
|
18
|
+
declare function usePredicateFilteredRows<TItem extends PartialSyncItem, TSortColumn extends keyof TItem & string>({ collection, conditions, sort, getSortValue, getColumnValue: _getColumnValue, limit, cacheDisplayMode, confirmedRowKeys, confirmedKeysRevision, alwaysIncludeRowIds, }: UsePredicateFilteredRowsOptions<TItem, TSortColumn>): TItem[];
|
|
19
|
+
|
|
20
|
+
export { usePredicateFilteredRows };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { usePredicateFilteredRows } from '../chunk-YD5LVGWX.js';
|
|
2
|
+
import '../chunk-43KYAIKY.js';
|
|
3
|
+
import '../chunk-M5MJHS6A.js';
|
|
4
|
+
import '../chunk-HMLY7DHA.js';
|
|
5
|
+
//# sourceMappingURL=usePredicateFilteredRows.js.map
|
|
6
|
+
//# sourceMappingURL=usePredicateFilteredRows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"usePredicateFilteredRows.js"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SyncMessage } from '@firtoz/db-helpers';
|
|
2
|
+
import { PartialSyncRowShape } from './partial-sync-row-key.js';
|
|
3
|
+
import { SyncClientMessage, SyncServerMessage } from './sync-protocol.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
type CollectionWithReceiveSync<TItem> = {
|
|
7
|
+
utils: {
|
|
8
|
+
receiveSync: (messages: SyncMessage<TItem>[]) => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type SendFn = (msg: SyncClientMessage) => void;
|
|
12
|
+
interface SyncClientBridgeOptions<TItem extends PartialSyncRowShape> {
|
|
13
|
+
clientId: string;
|
|
14
|
+
/** Must match the server's {@link SyncServerBridgeOptions.collectionId}. */
|
|
15
|
+
collectionId?: string;
|
|
16
|
+
collection: CollectionWithReceiveSync<TItem>;
|
|
17
|
+
send: SendFn;
|
|
18
|
+
initialLastAckedServerVersion?: number;
|
|
19
|
+
onLastAckedServerVersionChange?: (version: number) => void;
|
|
20
|
+
onRejectedMutation?: (reason: string, mutationId: string) => void;
|
|
21
|
+
/**
|
|
22
|
+
* When `false`, `setConnected(true)` does not send `syncHello` (partial-sync + `mutateBatch` only).
|
|
23
|
+
* Default `true` for full sync.
|
|
24
|
+
*/
|
|
25
|
+
sendSyncHelloOnConnect?: boolean;
|
|
26
|
+
}
|
|
27
|
+
declare class SyncClientBridge<TItem extends PartialSyncRowShape> {
|
|
28
|
+
#private;
|
|
29
|
+
private readonly options;
|
|
30
|
+
readonly clientId: string;
|
|
31
|
+
readonly collectionId: string;
|
|
32
|
+
constructor(options: SyncClientBridgeOptions<TItem>);
|
|
33
|
+
get pendingCount(): number;
|
|
34
|
+
setConnected(connected: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Wire `collection.get` after the TanStack collection exists so mutation-path `receiveSync` can
|
|
37
|
+
* coerce duplicate `insert` echoes to `update` (partial sync + `mutateBatch`).
|
|
38
|
+
*/
|
|
39
|
+
setRowGet(get: ((key: string | number) => TItem | undefined) | undefined): void;
|
|
40
|
+
sendHello(): void;
|
|
41
|
+
onLocalMutation(changes: SyncMessage<TItem>[]): void;
|
|
42
|
+
sendInsert(value: TItem): string;
|
|
43
|
+
sendUpdate(updated: TItem, previousValue: TItem): string;
|
|
44
|
+
sendDelete(key: string | number): string;
|
|
45
|
+
handleServerMessage(message: SyncServerMessage<TItem>): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { SyncClientBridge, type SyncClientBridgeOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sync-client-bridge.js"}
|