@seekora-ai/ui-sdk-core 0.2.24 → 0.2.26
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/dist/index.d.ts +3 -0
- package/dist/index.esm.js +17 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -326,6 +326,8 @@ declare class SearchStateManager {
|
|
|
326
326
|
private notifyScheduled;
|
|
327
327
|
private autoSearch;
|
|
328
328
|
private debounceMs;
|
|
329
|
+
private searchCoalesceTimer;
|
|
330
|
+
private searchCoalesceResolvers;
|
|
329
331
|
private defaultSearchOptions;
|
|
330
332
|
private keepResultsOnClear;
|
|
331
333
|
private abTestId?;
|
|
@@ -346,6 +348,7 @@ declare class SearchStateManager {
|
|
|
346
348
|
setSortBy(sortBy: string, triggerSearch?: boolean): void;
|
|
347
349
|
setItemsPerPage(itemsPerPage: number, triggerSearch?: boolean): void;
|
|
348
350
|
search(additionalOptions?: Partial<SearchOptions>): Promise<SearchResponse | null>;
|
|
351
|
+
private _executeSearch;
|
|
349
352
|
private buildSearchOptions;
|
|
350
353
|
private debouncedSearch;
|
|
351
354
|
subscribe(listener: (state: SearchState) => void): () => void;
|
package/dist/index.esm.js
CHANGED
|
@@ -1393,6 +1393,8 @@ class SearchStateManager {
|
|
|
1393
1393
|
this.listeners = [];
|
|
1394
1394
|
this.debounceTimer = null;
|
|
1395
1395
|
this.notifyScheduled = false;
|
|
1396
|
+
this.searchCoalesceTimer = null;
|
|
1397
|
+
this.searchCoalesceResolvers = [];
|
|
1396
1398
|
this.client = config.client;
|
|
1397
1399
|
this.autoSearch = config.autoSearch !== false;
|
|
1398
1400
|
this.debounceMs = config.debounceMs || 300;
|
|
@@ -1537,13 +1539,27 @@ class SearchStateManager {
|
|
|
1537
1539
|
this.debouncedSearch();
|
|
1538
1540
|
}
|
|
1539
1541
|
}
|
|
1540
|
-
// Manual search trigger
|
|
1542
|
+
// Manual search trigger — coalesces rapid calls within 10ms into a single API request
|
|
1541
1543
|
async search(additionalOptions) {
|
|
1542
1544
|
// Clear debounce timer if exists
|
|
1543
1545
|
if (this.debounceTimer) {
|
|
1544
1546
|
clearTimeout(this.debounceTimer);
|
|
1545
1547
|
this.debounceTimer = null;
|
|
1546
1548
|
}
|
|
1549
|
+
return new Promise((resolve, reject) => {
|
|
1550
|
+
this.searchCoalesceResolvers.push({ resolve, reject });
|
|
1551
|
+
if (this.searchCoalesceTimer) {
|
|
1552
|
+
clearTimeout(this.searchCoalesceTimer);
|
|
1553
|
+
}
|
|
1554
|
+
this.searchCoalesceTimer = setTimeout(() => {
|
|
1555
|
+
this.searchCoalesceTimer = null;
|
|
1556
|
+
const resolvers = [...this.searchCoalesceResolvers];
|
|
1557
|
+
this.searchCoalesceResolvers = [];
|
|
1558
|
+
this._executeSearch(additionalOptions).then((result) => resolvers.forEach(r => r.resolve(result)), (err) => resolvers.forEach(r => r.reject(err)));
|
|
1559
|
+
}, 10);
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
async _executeSearch(additionalOptions) {
|
|
1547
1563
|
this.setState({ loading: true, error: null });
|
|
1548
1564
|
try {
|
|
1549
1565
|
const searchOptions = this.buildSearchOptions(additionalOptions);
|