@cognite/reveal 4.28.5-dev.20251201 → 4.28.5-dev.20251203

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.
@@ -25,6 +25,7 @@ export { unionBoxes } from './src/three/unionBoxes';
25
25
  export { determineCurrentDevice, DeviceDescriptor } from './src/device';
26
26
  export { createRenderTriangle } from './src/three/createFullScreenTriangleGeometry';
27
27
  export { VariableWidthLine } from './src/three/VariableWidthLine';
28
+ export { batchedDebounce, BatchedDebounce } from './src/batchedDebounce';
28
29
  export { fitCameraToBoundingBox } from './src/three/fitCameraToBoundingBox';
29
30
  export { isBox3OnPositiveSideOfPlane } from './src/three/isBox3OnPositiveSideOfPlane';
30
31
  export { visitBox3CornerPoints } from './src/three/visitBox3CornerPoints';
@@ -0,0 +1,43 @@
1
+ /*!
2
+ * Copyright 2025 Cognite AS
3
+ */
4
+ import debounce from 'lodash/debounce';
5
+ export interface BatchedDebounce<T, R> {
6
+ (item: T): Promise<R>;
7
+ cancel: () => void;
8
+ }
9
+ /**
10
+ * Creates a debounced function that batches multiple individual calls into a single batch operation.
11
+ * Each call returns a promise that resolves with the corresponding result from the batch callback.
12
+ *
13
+ * @template T - The type of input items
14
+ * @template R - The type of result items
15
+ *
16
+ * @param callback - Function that processes a batch of items and returns results in the same order.
17
+ * return an array with the same length as the input array.
18
+ * @param wait - The number of milliseconds to delay before processing the batch
19
+ * @param options - Optional debounce options (leading, trailing, maxWait) passed to lodash debounce
20
+ *
21
+ * @returns A debounced function that accepts individual items and returns promises for their results.
22
+ * The function includes a `cancel()` method to cancel pending batches.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const batchedFetch = createBatchedDebounce(
27
+ * async (ids: number[]) => {
28
+ * const response = await fetch('/api/items', {
29
+ * method: 'POST',
30
+ * body: JSON.stringify({ ids })
31
+ * });
32
+ * return response.json();
33
+ * },
34
+ * 100
35
+ * );
36
+ *
37
+ * const item1 = batchedFetch(1);
38
+ * const item2 = batchedFetch(2);
39
+ * const results = await Promise.all([item1, item2]);
40
+ * // Both calls are batched into a single request
41
+ * ```
42
+ */
43
+ export declare function batchedDebounce<T, R>(callback: (items: T[]) => Promise<R[]> | R[], wait: number, options?: Parameters<typeof debounce>[2]): BatchedDebounce<T, R>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal",
3
- "version": "4.28.5-dev.20251201",
3
+ "version": "4.28.5-dev.20251203",
4
4
  "description": "WebGL based 3D viewer for CAD and point clouds processed in Cognite Data Fusion.",
5
5
  "homepage": "https://github.com/cognitedata/reveal/tree/master/viewer",
6
6
  "repository": {