3dviewer-sdk 1.0.28 → 1.1.1

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.mts CHANGED
@@ -3,6 +3,8 @@ declare enum ViewerMessageType {
3
3
  ZOOM = "viewer-zoom",
4
4
  CAMERA_GET_ZOOM = "viewer-camera-get-zoom",
5
5
  CAMERA_ZOOM = "viewer-camera-zoom",
6
+ LOADING_CHANGE = "viewer-loading-change",
7
+ READY = "viewer-ready",
6
8
  DRAW_MODE = "viewer-draw-mode",
7
9
  EXPLODE = "viewer-explode",
8
10
  MARKUP_ACTION = "viewer-markup-action",
@@ -49,7 +51,6 @@ declare enum ViewerMessageType {
49
51
  PDF_LAST_PAGE = "viewer-pdf-last-page",
50
52
  PDF_CURRENT_PAGE = "viewer-pdf-current-page",
51
53
  HOME_CLICK = "viewer-home-click",
52
- NODE_SELECT = "viewer-node-select",
53
54
  NODE_SELECTION_CHANGE = "viewer-node-selection-change",
54
55
  PAN_CHANGE = "viewer-pan-change"
55
56
  }
@@ -64,6 +65,20 @@ type CameraZoomPayload = {
64
65
  zoomFactor: number;
65
66
  timestamp: number;
66
67
  };
68
+ type ViewerLoadingPhase = "loading" | "ready" | "error";
69
+ type ViewerLoadingChangePayload = {
70
+ loading: boolean;
71
+ phase: ViewerLoadingPhase;
72
+ viewId?: string;
73
+ modelFileId?: string;
74
+ timestamp?: number;
75
+ };
76
+ type ViewerReadyPayload = {
77
+ ready: true;
78
+ viewId?: string;
79
+ modelFileId?: string;
80
+ timestamp: number;
81
+ };
67
82
  type ToolbarUseTarget = "all" | "left" | "center" | "right";
68
83
  type MarkupAction = "line" | "arrow" | "circle" | "ellipse" | "rectangle" | "polygon" | "polyline" | "textbox" | "note" | "callout" | "cloud" | "freehand";
69
84
  type MarkupOperationResultPayload = {
@@ -142,14 +157,12 @@ type PdfCurrentPagePayload = {
142
157
  };
143
158
 
144
159
  type ViewerEventMap = {
160
+ "loading:change": ViewerLoadingChangePayload;
161
+ "viewer:ready": ViewerReadyPayload;
145
162
  "camera:home": {
146
163
  timestamp: number;
147
164
  };
148
165
  "camera:zoom": CameraZoomPayload;
149
- "node:select": {
150
- nodeId: string;
151
- timestamp: number;
152
- };
153
166
  "node:selection-change": NodeSelectionChangePayload;
154
167
  "interaction:pan-change": {
155
168
  enabled: boolean;
@@ -306,10 +319,6 @@ declare class InteractionModule {
306
319
  declare class NodeModule {
307
320
  private viewer;
308
321
  on: {
309
- select: (cb: (payload: {
310
- nodeId: string;
311
- timestamp: number;
312
- }) => void) => () => void;
313
322
  selectionChange: (cb: (payload: {
314
323
  nodeIds: string[];
315
324
  timestamp: number;
@@ -435,6 +444,7 @@ declare class FilesModule {
435
444
  private convertInternal;
436
445
  private convertV2Internal;
437
446
  private updateState;
447
+ private toViewerLoadingPhase;
438
448
  private withOperation;
439
449
  private toErrorMessage;
440
450
  }
@@ -623,6 +633,9 @@ type Viewer3DOptions = {
623
633
  uploadPath?: string;
624
634
  file?: File;
625
635
  initialToolbar?: InitialToolbarUse;
636
+ ui?: {
637
+ loadingIndicator?: boolean;
638
+ };
626
639
  width?: string;
627
640
  height?: string;
628
641
  sandbox?: string;
@@ -633,6 +646,10 @@ declare class Viewer3D {
633
646
  private containerEl;
634
647
  private iframeEl;
635
648
  private initialized;
649
+ private viewerReady;
650
+ private readyPayload;
651
+ private readyWaiters;
652
+ private loadingState;
636
653
  private emitter;
637
654
  camera: CameraModule;
638
655
  interaction: InteractionModule;
@@ -647,6 +664,12 @@ declare class Viewer3D {
647
664
  getOptions(): Viewer3DOptions;
648
665
  patchOptions(next: Partial<Viewer3DOptions>): void;
649
666
  getUrl(): string | null;
667
+ on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
668
+ off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
669
+ getLoadingState(): ViewerLoadingChangePayload;
670
+ ready(options?: {
671
+ timeoutMs?: number;
672
+ }): Promise<ViewerReadyPayload>;
650
673
  init(): void;
651
674
  render(file?: File): Promise<PreparedViewerData | void>;
652
675
  open(url: string): void;
@@ -657,8 +680,12 @@ declare class Viewer3D {
657
680
  _on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
658
681
  _off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
659
682
  _emit<K extends SdkEventKey>(event: K, payload: SdkEventPayload<K>): void;
683
+ private resetReadyState;
684
+ private setLoadingState;
685
+ private resolveReady;
686
+ private rejectReadyWaiters;
660
687
  postToViewer<TPayload = unknown>(type: ViewerMessageType, payload?: TPayload): void;
661
688
  private handleMessage;
662
689
  }
663
690
 
664
- export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, Viewer3D };
691
+ export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, Viewer3D, type Viewer3DOptions, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,8 @@ declare enum ViewerMessageType {
3
3
  ZOOM = "viewer-zoom",
4
4
  CAMERA_GET_ZOOM = "viewer-camera-get-zoom",
5
5
  CAMERA_ZOOM = "viewer-camera-zoom",
6
+ LOADING_CHANGE = "viewer-loading-change",
7
+ READY = "viewer-ready",
6
8
  DRAW_MODE = "viewer-draw-mode",
7
9
  EXPLODE = "viewer-explode",
8
10
  MARKUP_ACTION = "viewer-markup-action",
@@ -49,7 +51,6 @@ declare enum ViewerMessageType {
49
51
  PDF_LAST_PAGE = "viewer-pdf-last-page",
50
52
  PDF_CURRENT_PAGE = "viewer-pdf-current-page",
51
53
  HOME_CLICK = "viewer-home-click",
52
- NODE_SELECT = "viewer-node-select",
53
54
  NODE_SELECTION_CHANGE = "viewer-node-selection-change",
54
55
  PAN_CHANGE = "viewer-pan-change"
55
56
  }
@@ -64,6 +65,20 @@ type CameraZoomPayload = {
64
65
  zoomFactor: number;
65
66
  timestamp: number;
66
67
  };
68
+ type ViewerLoadingPhase = "loading" | "ready" | "error";
69
+ type ViewerLoadingChangePayload = {
70
+ loading: boolean;
71
+ phase: ViewerLoadingPhase;
72
+ viewId?: string;
73
+ modelFileId?: string;
74
+ timestamp?: number;
75
+ };
76
+ type ViewerReadyPayload = {
77
+ ready: true;
78
+ viewId?: string;
79
+ modelFileId?: string;
80
+ timestamp: number;
81
+ };
67
82
  type ToolbarUseTarget = "all" | "left" | "center" | "right";
68
83
  type MarkupAction = "line" | "arrow" | "circle" | "ellipse" | "rectangle" | "polygon" | "polyline" | "textbox" | "note" | "callout" | "cloud" | "freehand";
69
84
  type MarkupOperationResultPayload = {
@@ -142,14 +157,12 @@ type PdfCurrentPagePayload = {
142
157
  };
143
158
 
144
159
  type ViewerEventMap = {
160
+ "loading:change": ViewerLoadingChangePayload;
161
+ "viewer:ready": ViewerReadyPayload;
145
162
  "camera:home": {
146
163
  timestamp: number;
147
164
  };
148
165
  "camera:zoom": CameraZoomPayload;
149
- "node:select": {
150
- nodeId: string;
151
- timestamp: number;
152
- };
153
166
  "node:selection-change": NodeSelectionChangePayload;
154
167
  "interaction:pan-change": {
155
168
  enabled: boolean;
@@ -306,10 +319,6 @@ declare class InteractionModule {
306
319
  declare class NodeModule {
307
320
  private viewer;
308
321
  on: {
309
- select: (cb: (payload: {
310
- nodeId: string;
311
- timestamp: number;
312
- }) => void) => () => void;
313
322
  selectionChange: (cb: (payload: {
314
323
  nodeIds: string[];
315
324
  timestamp: number;
@@ -435,6 +444,7 @@ declare class FilesModule {
435
444
  private convertInternal;
436
445
  private convertV2Internal;
437
446
  private updateState;
447
+ private toViewerLoadingPhase;
438
448
  private withOperation;
439
449
  private toErrorMessage;
440
450
  }
@@ -623,6 +633,9 @@ type Viewer3DOptions = {
623
633
  uploadPath?: string;
624
634
  file?: File;
625
635
  initialToolbar?: InitialToolbarUse;
636
+ ui?: {
637
+ loadingIndicator?: boolean;
638
+ };
626
639
  width?: string;
627
640
  height?: string;
628
641
  sandbox?: string;
@@ -633,6 +646,10 @@ declare class Viewer3D {
633
646
  private containerEl;
634
647
  private iframeEl;
635
648
  private initialized;
649
+ private viewerReady;
650
+ private readyPayload;
651
+ private readyWaiters;
652
+ private loadingState;
636
653
  private emitter;
637
654
  camera: CameraModule;
638
655
  interaction: InteractionModule;
@@ -647,6 +664,12 @@ declare class Viewer3D {
647
664
  getOptions(): Viewer3DOptions;
648
665
  patchOptions(next: Partial<Viewer3DOptions>): void;
649
666
  getUrl(): string | null;
667
+ on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
668
+ off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
669
+ getLoadingState(): ViewerLoadingChangePayload;
670
+ ready(options?: {
671
+ timeoutMs?: number;
672
+ }): Promise<ViewerReadyPayload>;
650
673
  init(): void;
651
674
  render(file?: File): Promise<PreparedViewerData | void>;
652
675
  open(url: string): void;
@@ -657,8 +680,12 @@ declare class Viewer3D {
657
680
  _on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
658
681
  _off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
659
682
  _emit<K extends SdkEventKey>(event: K, payload: SdkEventPayload<K>): void;
683
+ private resetReadyState;
684
+ private setLoadingState;
685
+ private resolveReady;
686
+ private rejectReadyWaiters;
660
687
  postToViewer<TPayload = unknown>(type: ViewerMessageType, payload?: TPayload): void;
661
688
  private handleMessage;
662
689
  }
663
690
 
664
- export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, Viewer3D };
691
+ export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, Viewer3D, type Viewer3DOptions, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload };