@topgunbuild/client 0.12.0 → 0.13.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/LICENSE +201 -0
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -949,14 +949,17 @@ var QueryManager = class {
|
|
|
949
949
|
}
|
|
950
950
|
/**
|
|
951
951
|
* Send query subscription message to server.
|
|
952
|
+
* Includes field projection when specified in the query filter.
|
|
952
953
|
*/
|
|
953
954
|
sendQuerySubscription(query) {
|
|
955
|
+
const filter = query.getFilter();
|
|
954
956
|
this.config.sendMessage({
|
|
955
957
|
type: "QUERY_SUB",
|
|
956
958
|
payload: {
|
|
957
959
|
queryId: query.id,
|
|
958
960
|
mapName: query.getMapName(),
|
|
959
|
-
query:
|
|
961
|
+
query: filter,
|
|
962
|
+
fields: filter.fields
|
|
960
963
|
}
|
|
961
964
|
});
|
|
962
965
|
}
|
|
@@ -1126,6 +1129,16 @@ var QueryManager = class {
|
|
|
1126
1129
|
logger.debug({ queryCount: this.queries.size, hybridCount: this.hybridQueries.size }, "QueryManager: resubscribing all queries");
|
|
1127
1130
|
for (const query of this.queries.values()) {
|
|
1128
1131
|
this.sendQuerySubscription(query);
|
|
1132
|
+
const filter = query.getFilter();
|
|
1133
|
+
if (filter.fields && filter.fields.length > 0 && query.merkleRootHash !== 0) {
|
|
1134
|
+
this.config.sendMessage({
|
|
1135
|
+
type: "QUERY_SYNC_INIT",
|
|
1136
|
+
payload: {
|
|
1137
|
+
queryId: query.id,
|
|
1138
|
+
rootHash: query.merkleRootHash
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1129
1142
|
}
|
|
1130
1143
|
for (const query of this.hybridQueries.values()) {
|
|
1131
1144
|
if (query.hasFTSPredicate()) {
|
|
@@ -2733,10 +2746,10 @@ var SyncEngine = class {
|
|
|
2733
2746
|
}
|
|
2734
2747
|
}
|
|
2735
2748
|
handleQueryResp(message) {
|
|
2736
|
-
const { queryId, results, nextCursor, hasMore, cursorStatus } = message.payload;
|
|
2749
|
+
const { queryId, results, nextCursor, hasMore, cursorStatus, merkleRootHash } = message.payload;
|
|
2737
2750
|
const query = this.queryManager.getQueries().get(queryId);
|
|
2738
2751
|
if (query) {
|
|
2739
|
-
query.onResult(results, "server");
|
|
2752
|
+
query.onResult(results, "server", merkleRootHash);
|
|
2740
2753
|
query.updatePaginationInfo({ nextCursor, hasMore, cursorStatus });
|
|
2741
2754
|
}
|
|
2742
2755
|
}
|
|
@@ -3273,12 +3286,15 @@ var QueryHandle = class {
|
|
|
3273
3286
|
// Pagination info
|
|
3274
3287
|
this._paginationInfo = { hasMore: false, cursorStatus: "none" };
|
|
3275
3288
|
this.paginationListeners = /* @__PURE__ */ new Set();
|
|
3289
|
+
/** Merkle root hash from last server QUERY_RESP — used for delta reconnect */
|
|
3290
|
+
this.merkleRootHash = 0;
|
|
3276
3291
|
// Track if we've received authoritative server response
|
|
3277
3292
|
this.hasReceivedServerData = false;
|
|
3278
3293
|
this.id = crypto.randomUUID();
|
|
3279
3294
|
this.syncEngine = syncEngine;
|
|
3280
3295
|
this.mapName = mapName;
|
|
3281
3296
|
this.filter = filter;
|
|
3297
|
+
this.fields = filter.fields;
|
|
3282
3298
|
}
|
|
3283
3299
|
subscribe(callback) {
|
|
3284
3300
|
this.listeners.add(callback);
|
|
@@ -3314,7 +3330,7 @@ var QueryHandle = class {
|
|
|
3314
3330
|
* - This prevents clearing local data when server hasn't loaded from storage yet
|
|
3315
3331
|
* - Works with any async storage adapter (PostgreSQL, SQLite, Redis, etc.)
|
|
3316
3332
|
*/
|
|
3317
|
-
onResult(items, source = "server") {
|
|
3333
|
+
onResult(items, source = "server", merkleRootHash) {
|
|
3318
3334
|
logger.debug({
|
|
3319
3335
|
mapName: this.mapName,
|
|
3320
3336
|
itemCount: items.length,
|
|
@@ -3329,6 +3345,9 @@ var QueryHandle = class {
|
|
|
3329
3345
|
if (source === "server" && items.length > 0) {
|
|
3330
3346
|
this.hasReceivedServerData = true;
|
|
3331
3347
|
}
|
|
3348
|
+
if (merkleRootHash !== void 0) {
|
|
3349
|
+
this.merkleRootHash = merkleRootHash;
|
|
3350
|
+
}
|
|
3332
3351
|
const newKeys = new Set(items.map((i) => i.key));
|
|
3333
3352
|
const removedKeys = [];
|
|
3334
3353
|
for (const key of this.currentResults.keys()) {
|