@happyvertical/smrt-web 0.57.35 → 0.57.37
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.
|
@@ -3475,11 +3475,8 @@ function createSmrtCollection(definition, options) {
|
|
|
3475
3475
|
return cacheId;
|
|
3476
3476
|
},
|
|
3477
3477
|
invalidate: () => invalidateRelated(),
|
|
3478
|
-
snapshot: () =>
|
|
3479
|
-
subscribe: (callback) =>
|
|
3480
|
-
const subscription = collection.subscribeChanges((changes) => callback(projectChanges(changes)));
|
|
3481
|
-
return { unsubscribe: () => subscription.unsubscribe() };
|
|
3482
|
-
}
|
|
3478
|
+
snapshot: () => listOrderedRows(),
|
|
3479
|
+
subscribe: (callback) => subscribeWithListOrder(callback)
|
|
3483
3480
|
};
|
|
3484
3481
|
for (const capability of capabilities) {
|
|
3485
3482
|
let extra;
|
|
@@ -3635,9 +3632,49 @@ function createSmrtCollection(definition, options) {
|
|
|
3635
3632
|
invalidateRelated();
|
|
3636
3633
|
} : void 0
|
|
3637
3634
|
}));
|
|
3635
|
+
function listOrderedRows() {
|
|
3636
|
+
const rows = collection.toArray.map((row) => toPlainRow(row));
|
|
3637
|
+
const listed = queryClient.getQueryData(queryKey);
|
|
3638
|
+
if (!Array.isArray(listed) || listed.length === 0) return rows;
|
|
3639
|
+
const position = /* @__PURE__ */ new Map();
|
|
3640
|
+
listed.forEach((row, index) => {
|
|
3641
|
+
const key = String(row[idField]);
|
|
3642
|
+
if (!position.has(key)) position.set(key, index);
|
|
3643
|
+
});
|
|
3644
|
+
const at = (row) => position.get(String(row[idField])) ?? Number.POSITIVE_INFINITY;
|
|
3645
|
+
return rows.sort((left, right) => {
|
|
3646
|
+
const a = at(left);
|
|
3647
|
+
const b = at(right);
|
|
3648
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
3649
|
+
});
|
|
3650
|
+
}
|
|
3651
|
+
function subscribeWithListOrder(callback) {
|
|
3652
|
+
const idsOf = () => {
|
|
3653
|
+
const listed = queryClient.getQueryData(queryKey);
|
|
3654
|
+
return Array.isArray(listed) ? listed.map((row) => String(row[idField])) : [];
|
|
3655
|
+
};
|
|
3656
|
+
let lastIds = idsOf();
|
|
3657
|
+
const subscription = collection.subscribeChanges((changes) => callback(projectChanges(changes)));
|
|
3658
|
+
const unwatch = queryClient.getQueryCache().subscribe((event) => {
|
|
3659
|
+
if (event.type !== "updated") return;
|
|
3660
|
+
if (JSON.stringify(event.query.queryKey) !== JSON.stringify(queryKey)) return;
|
|
3661
|
+
const nextIds = idsOf();
|
|
3662
|
+
const before = new Set(lastIds);
|
|
3663
|
+
const after = new Set(nextIds);
|
|
3664
|
+
const common = (ids, other) => ids.filter((id) => other.has(id));
|
|
3665
|
+
const prev = common(lastIds, after);
|
|
3666
|
+
const next = common(nextIds, before);
|
|
3667
|
+
lastIds = nextIds;
|
|
3668
|
+
if (prev.length > 1 && prev.some((id, index) => id !== next[index])) callback(projectChanges([]));
|
|
3669
|
+
});
|
|
3670
|
+
return { unsubscribe: () => {
|
|
3671
|
+
unwatch();
|
|
3672
|
+
subscription.unsubscribe();
|
|
3673
|
+
} };
|
|
3674
|
+
}
|
|
3638
3675
|
const handle = {
|
|
3639
3676
|
get toArray() {
|
|
3640
|
-
return
|
|
3677
|
+
return listOrderedRows();
|
|
3641
3678
|
},
|
|
3642
3679
|
get size() {
|
|
3643
3680
|
return collection.size;
|
|
@@ -3666,8 +3703,7 @@ function createSmrtCollection(definition, options) {
|
|
|
3666
3703
|
}
|
|
3667
3704
|
},
|
|
3668
3705
|
subscribeChanges(callback) {
|
|
3669
|
-
|
|
3670
|
-
return { unsubscribe: () => subscription.unsubscribe() };
|
|
3706
|
+
return subscribeWithListOrder(callback);
|
|
3671
3707
|
},
|
|
3672
3708
|
insert(row) {
|
|
3673
3709
|
return collection.insert(row);
|
|
@@ -3707,4 +3743,4 @@ function createSmrtCollection(definition, options) {
|
|
|
3707
3743
|
//#endregion
|
|
3708
3744
|
export { wipeDurableStore as A, MAX_SMRT_WEB_DATA_QUERY_FACETS as B, getOutboxHandle as C, pruneDurableNamespace as D, listDurableNamespaces as E, classifySmrtWebDataSurfaceActionResult as F, MAX_SMRT_WEB_DATA_QUERY_ROWS as G, MAX_SMRT_WEB_DATA_QUERY_OFFSET as H, dataSurfaceActionCommandTransport as I, executeSmrtWebDataQuery as J, MAX_SMRT_WEB_DATA_QUERY_STRING_LENGTH as K, executeSmrtWebDataSurfaceAction as L, MAX_SMRT_WEB_DATA_SURFACE_ACTION_IDENTIFIER_LENGTH as M, MAX_SMRT_WEB_DATA_SURFACE_ACTION_JSON_DEPTH as N, durableStoreNamespace as O, MAX_SMRT_WEB_DATA_SURFACE_ACTION_RESULT_BYTES as P, normalizeSmrtWebDataSurfaceActionResult as R, persistDataSurface as S, offlineOutbox as T, MAX_SMRT_WEB_DATA_QUERY_PAGE_LIMIT as U, MAX_SMRT_WEB_DATA_QUERY_FACET_VALUES as V, MAX_SMRT_WEB_DATA_QUERY_RESULT_BYTES as W, runWrapMutation as X, normalizeSmrtWebDataQueryResult as Y, createSmrtWebEventSubscriber as _, createSmrtWebClient as a, DEFAULT_PERSIST_DEBOUNCE_MS as b, newLocalId as c, unwrapListResult as d, validateSmrtWebClient as f, createUpdateState as g, registerWebMcpTools as h, createSmrtCollection as i, MAX_SMRT_WEB_DATA_SURFACE_ACTION_CONTAINER_ITEMS as j, registerDurableResource as k, throwIfSmrtWebError as l, registerWebMcpBespokeTool as m, buildListQuery as n, getEngineCollection as o, registerViewIntent as p, MAX_SMRT_WEB_DATA_QUERY_WARNINGS as q, createDefinitionFetchers as r, invalidateSmrtWebCollections as s, SmrtWebRequestError as t, unwrapItemResult as u, liveInvalidation as v, offlineCommandQueue as w, persistCollection as x, createSmrtWebQuery as y, MAX_SMRT_WEB_DATA_QUERY_CONTAINER_ITEMS as z };
|
|
3709
3745
|
|
|
3710
|
-
//# sourceMappingURL=src-
|
|
3746
|
+
//# sourceMappingURL=src-CG_-RoZq.js.map
|