@cognite/reveal 4.28.5-dev.20251202 → 4.28.5-dev.20251204

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.
@@ -30,7 +30,6 @@ export declare class RevealManager {
30
30
  private _isDisposed;
31
31
  private readonly _subscriptions;
32
32
  private readonly _events;
33
- private readonly _updateSubject;
34
33
  private readonly _cameraManager;
35
34
  private readonly _onCameraChange;
36
35
  private readonly _onCameraStop;
@@ -62,6 +61,5 @@ export declare class RevealManager {
62
61
  addModel<T extends DataSourceType>(type: 'pointcloud', modelIdentifier: AddModelOptionsWithModelRevisionId<T>): Promise<PointCloudNode<T>>;
63
62
  removeModel(type: 'cad', model: CadNode): void;
64
63
  removeModel(type: 'pointcloud', model: PointCloudNode): void;
65
- private notifyLoadingStateChanged;
66
64
  private initLoadingStateObserver;
67
65
  }
@@ -27,6 +27,7 @@ import { Image360Action } from '../../../../360-images/src/Image360Action';
27
27
  export declare class Cognite3DViewer<DataSourceT extends DataSourceType = ClassicDataSourceType> {
28
28
  private readonly _domElementResizeObserver;
29
29
  private readonly _image360ApiHelper;
30
+ private readonly _unsubsribeOnLoading;
30
31
  /**
31
32
  * Returns the rendering canvas, the DOM element where the renderer draws its output.
32
33
  */
@@ -50,7 +51,6 @@ export declare class Cognite3DViewer<DataSourceT extends DataSourceType = Classi
50
51
  private readonly _dataSource;
51
52
  private readonly _sceneHandler;
52
53
  private readonly _activeCameraManager;
53
- private readonly _subscription;
54
54
  private readonly _revealManagerHelper;
55
55
  private readonly _domElement;
56
56
  private readonly _renderer;
@@ -2,7 +2,6 @@
2
2
  * Copyright 2021 Cognite AS
3
3
  */
4
4
  import * as THREE from 'three';
5
- import { Observable } from 'rxjs';
6
5
  import { CadModelMetadata } from '../../cad-parsers';
7
6
  import { CadModelUpdateHandler } from './CadModelUpdateHandler';
8
7
  import { LoadingState } from '../../model-base';
@@ -15,9 +14,10 @@ export declare class CadManager {
15
14
  private readonly _cadModelFactory;
16
15
  private readonly _cadModelUpdateHandler;
17
16
  private readonly _cadModelMap;
18
- private readonly _subscription;
17
+ private readonly _unsubscribeConsumedSectors;
19
18
  private _compatibleFileFormat;
20
19
  private _needsRedraw;
20
+ private readonly _loadingStateChangedTrigger;
21
21
  private readonly _markNeedsRedrawBound;
22
22
  private readonly _materialsChangedListener;
23
23
  private readonly _sectorBufferTime;
@@ -42,7 +42,8 @@ export declare class CadManager {
42
42
  updateModelCompatibilityFormat(modelMetadata: CadModelMetadata): void;
43
43
  addModel(modelIdentifier: ModelIdentifier, geometryFilter?: GeometryFilter): Promise<CadNode>;
44
44
  removeModel(model: CadNode): void;
45
- getLoadingStateObserver(): Observable<LoadingState>;
45
+ on(event: 'loadingStateChanged', listener: (loadingState: LoadingState) => void): void;
46
+ off(event: 'loadingStateChanged', listener: (loadingState: LoadingState) => void): void;
46
47
  /**
47
48
  * Sets the Memory Cache size for all loaded models to the current budget
48
49
  * @param budget The budget to calculate cache size by
@@ -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,58 @@
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
+ type BatchCallback<T, R> = (items: T[]) => R extends void ? Promise<void> | void : Promise<R[]> | R[];
10
+ /**
11
+ * Creates a debounced function that batches multiple individual calls into a single batch operation.
12
+ * Each call returns a promise that resolves with the corresponding result from the batch callback.
13
+ *
14
+ * @template T - The type of input items
15
+ * @template R - The type of result items (use void for callbacks that don't return results)
16
+ *
17
+ * @param callback - Function that processes a batch of items. Should return an array with the same
18
+ * length as the input array, or void if no results are needed.
19
+ * @param wait - The number of milliseconds to delay before processing the batch
20
+ * @param options - Optional debounce options (leading, trailing, maxWait) passed to lodash debounce
21
+ *
22
+ * @returns A debounced function that accepts individual items and returns promises for their results.
23
+ * The function includes a `cancel()` method to cancel pending batches.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // With results
28
+ * const batchedFetch = batchedDebounce(
29
+ * async (ids: number[]) => {
30
+ * const response = await fetch('/api/items', {
31
+ * method: 'POST',
32
+ * body: JSON.stringify({ ids })
33
+ * });
34
+ * return response.json();
35
+ * },
36
+ * 100
37
+ * );
38
+ *
39
+ * const item1 = batchedFetch(1);
40
+ * const item2 = batchedFetch(2);
41
+ * const results = await Promise.all([item1, item2]);
42
+ *
43
+ * // Without results (void)
44
+ * const batchedLog = batchedDebounce(
45
+ * async (ids: number[]) => {
46
+ * await fetch('/api/log', {
47
+ * method: 'POST',
48
+ * body: JSON.stringify({ ids })
49
+ * });
50
+ * },
51
+ * 100
52
+ * );
53
+ *
54
+ * await batchedLog(1);
55
+ * ```
56
+ */
57
+ export declare function batchedDebounce<T, R = void>(callback: BatchCallback<T, R>, wait: number, options?: Parameters<typeof debounce>[2]): BatchedDebounce<T, R>;
58
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal",
3
- "version": "4.28.5-dev.20251202",
3
+ "version": "4.28.5-dev.20251204",
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": {