3dviewer-sdk 1.0.7 → 1.0.9
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/contracts/messages.d.ts +6 -0
- package/dist/contracts/messages.js +1 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +80 -1
- package/dist/index.mjs +80 -1
- package/dist/modules/files.module.d.ts +6 -0
- package/dist/modules/files.module.js +59 -1
- package/dist/modules/toolbar.module.d.ts +11 -1
- package/dist/modules/toolbar.module.js +30 -0
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ export declare enum ViewerMessageType {
|
|
|
20
20
|
ZOOM_WINDOW = "viewer-zoom-window",
|
|
21
21
|
ZOOM_FIT = "viewer-zoom-fit",
|
|
22
22
|
TOOLBAR_CONFIG = "viewer-toolbar-config",
|
|
23
|
+
TOOLBAR_VISIBILITY = "viewer-toolbar-visibility",
|
|
23
24
|
PANEL_OPEN = "viewer-panel-open",
|
|
24
25
|
PANEL_CLOSE = "viewer-panel-close",
|
|
25
26
|
CUTTING_PLANE_ACTION = "viewer-cutting-plane-action",
|
|
@@ -63,6 +64,11 @@ export declare type DrawModeValue = "shaded" | "wireframe" | "hidden-line" | "sh
|
|
|
63
64
|
export declare type DrawModePayload = {
|
|
64
65
|
mode: DrawModeValue;
|
|
65
66
|
};
|
|
67
|
+
export declare type ToolbarVisibilityTarget = "all" | "left" | "center" | "right";
|
|
68
|
+
export declare type ToolbarVisibilityPayload = {
|
|
69
|
+
visible: boolean;
|
|
70
|
+
target?: ToolbarVisibilityTarget;
|
|
71
|
+
};
|
|
66
72
|
export declare type ExplodePayload = {
|
|
67
73
|
magnitude: number;
|
|
68
74
|
};
|
|
@@ -22,6 +22,7 @@ export var ViewerMessageType;
|
|
|
22
22
|
ViewerMessageType["ZOOM_WINDOW"] = "viewer-zoom-window";
|
|
23
23
|
ViewerMessageType["ZOOM_FIT"] = "viewer-zoom-fit";
|
|
24
24
|
ViewerMessageType["TOOLBAR_CONFIG"] = "viewer-toolbar-config";
|
|
25
|
+
ViewerMessageType["TOOLBAR_VISIBILITY"] = "viewer-toolbar-visibility";
|
|
25
26
|
ViewerMessageType["PANEL_OPEN"] = "viewer-panel-open";
|
|
26
27
|
ViewerMessageType["PANEL_CLOSE"] = "viewer-panel-close";
|
|
27
28
|
ViewerMessageType["CUTTING_PLANE_ACTION"] = "viewer-cutting-plane-action";
|
package/dist/index.d.mts
CHANGED
|
@@ -20,6 +20,7 @@ declare enum ViewerMessageType {
|
|
|
20
20
|
ZOOM_WINDOW = "viewer-zoom-window",
|
|
21
21
|
ZOOM_FIT = "viewer-zoom-fit",
|
|
22
22
|
TOOLBAR_CONFIG = "viewer-toolbar-config",
|
|
23
|
+
TOOLBAR_VISIBILITY = "viewer-toolbar-visibility",
|
|
23
24
|
PANEL_OPEN = "viewer-panel-open",
|
|
24
25
|
PANEL_CLOSE = "viewer-panel-close",
|
|
25
26
|
CUTTING_PLANE_ACTION = "viewer-cutting-plane-action",
|
|
@@ -41,6 +42,7 @@ declare enum ViewerMessageType {
|
|
|
41
42
|
PAN_CHANGE = "viewer-pan-change"
|
|
42
43
|
}
|
|
43
44
|
type LanguageCode = "en" | "vn";
|
|
45
|
+
type ToolbarVisibilityTarget = "all" | "left" | "center" | "right";
|
|
44
46
|
type MarkupAction = "line" | "arrow" | "circle" | "ellipse" | "rectangle" | "polygon" | "polyline" | "textbox" | "note" | "callout" | "cloud" | "freehand";
|
|
45
47
|
type MarkupOperationResultPayload = {
|
|
46
48
|
requestId: string;
|
|
@@ -247,6 +249,10 @@ type ConvertV2Options = {
|
|
|
247
249
|
project?: string;
|
|
248
250
|
convertOptions?: Partial<StreamConvertOptions>;
|
|
249
251
|
};
|
|
252
|
+
type FileInfoCheckInput = string | string[];
|
|
253
|
+
type FileInfoCheckPayloadItem = {
|
|
254
|
+
baseFileId: string;
|
|
255
|
+
};
|
|
250
256
|
type StreamConvertOptions = {
|
|
251
257
|
convert3DModel: number;
|
|
252
258
|
convert2DSheet: number;
|
|
@@ -305,6 +311,7 @@ declare class FilesModule {
|
|
|
305
311
|
convert(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
306
312
|
prepare(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
307
313
|
convertV2(options: ConvertV2Options): Promise<PreparedViewerData>;
|
|
314
|
+
checkFileInfo(baseFileIds: FileInfoCheckInput): Promise<unknown>;
|
|
308
315
|
open(input: PreparedViewerData | {
|
|
309
316
|
url: string;
|
|
310
317
|
}): void;
|
|
@@ -323,6 +330,7 @@ declare class FilesModule {
|
|
|
323
330
|
private uploadInternal;
|
|
324
331
|
private buildCachePayload;
|
|
325
332
|
private buildConvertV2Payload;
|
|
333
|
+
private buildFileInfoPayload;
|
|
326
334
|
private cacheFile;
|
|
327
335
|
private cacheFileV2;
|
|
328
336
|
private convertInternal;
|
|
@@ -373,6 +381,15 @@ declare class ToolbarModule {
|
|
|
373
381
|
disableAllPdf(): void;
|
|
374
382
|
enableAll3D(): void;
|
|
375
383
|
enableAllPdf(): void;
|
|
384
|
+
hideToolbar(): void;
|
|
385
|
+
showToolbar(): void;
|
|
386
|
+
setToolbarVisible(visible: boolean, target?: ToolbarVisibilityTarget): void;
|
|
387
|
+
hideLeftToolbar(): void;
|
|
388
|
+
showLeftToolbar(): void;
|
|
389
|
+
hideCenterToolbar(): void;
|
|
390
|
+
showCenterToolbar(): void;
|
|
391
|
+
hideRightToolbar(): void;
|
|
392
|
+
showRightToolbar(): void;
|
|
376
393
|
openClippingPlanes(): void;
|
|
377
394
|
closeClippingPlanes(): void;
|
|
378
395
|
openSetting(): void;
|
|
@@ -406,6 +423,7 @@ declare class ToolbarModule {
|
|
|
406
423
|
cuttingReversePlaneY(): void;
|
|
407
424
|
cuttingReversePlaneZ(): void;
|
|
408
425
|
private postConfig;
|
|
426
|
+
private postToolbarVisibility;
|
|
409
427
|
private postPanelOpen;
|
|
410
428
|
private postPanelClose;
|
|
411
429
|
private postCuttingAction;
|
|
@@ -499,4 +517,4 @@ declare class Viewer3D {
|
|
|
499
517
|
private handleMessage;
|
|
500
518
|
}
|
|
501
519
|
|
|
502
|
-
export { type ConvertOptions, type ConvertV2Options, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
|
|
520
|
+
export { type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare enum ViewerMessageType {
|
|
|
20
20
|
ZOOM_WINDOW = "viewer-zoom-window",
|
|
21
21
|
ZOOM_FIT = "viewer-zoom-fit",
|
|
22
22
|
TOOLBAR_CONFIG = "viewer-toolbar-config",
|
|
23
|
+
TOOLBAR_VISIBILITY = "viewer-toolbar-visibility",
|
|
23
24
|
PANEL_OPEN = "viewer-panel-open",
|
|
24
25
|
PANEL_CLOSE = "viewer-panel-close",
|
|
25
26
|
CUTTING_PLANE_ACTION = "viewer-cutting-plane-action",
|
|
@@ -41,6 +42,7 @@ declare enum ViewerMessageType {
|
|
|
41
42
|
PAN_CHANGE = "viewer-pan-change"
|
|
42
43
|
}
|
|
43
44
|
type LanguageCode = "en" | "vn";
|
|
45
|
+
type ToolbarVisibilityTarget = "all" | "left" | "center" | "right";
|
|
44
46
|
type MarkupAction = "line" | "arrow" | "circle" | "ellipse" | "rectangle" | "polygon" | "polyline" | "textbox" | "note" | "callout" | "cloud" | "freehand";
|
|
45
47
|
type MarkupOperationResultPayload = {
|
|
46
48
|
requestId: string;
|
|
@@ -247,6 +249,10 @@ type ConvertV2Options = {
|
|
|
247
249
|
project?: string;
|
|
248
250
|
convertOptions?: Partial<StreamConvertOptions>;
|
|
249
251
|
};
|
|
252
|
+
type FileInfoCheckInput = string | string[];
|
|
253
|
+
type FileInfoCheckPayloadItem = {
|
|
254
|
+
baseFileId: string;
|
|
255
|
+
};
|
|
250
256
|
type StreamConvertOptions = {
|
|
251
257
|
convert3DModel: number;
|
|
252
258
|
convert2DSheet: number;
|
|
@@ -305,6 +311,7 @@ declare class FilesModule {
|
|
|
305
311
|
convert(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
306
312
|
prepare(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
307
313
|
convertV2(options: ConvertV2Options): Promise<PreparedViewerData>;
|
|
314
|
+
checkFileInfo(baseFileIds: FileInfoCheckInput): Promise<unknown>;
|
|
308
315
|
open(input: PreparedViewerData | {
|
|
309
316
|
url: string;
|
|
310
317
|
}): void;
|
|
@@ -323,6 +330,7 @@ declare class FilesModule {
|
|
|
323
330
|
private uploadInternal;
|
|
324
331
|
private buildCachePayload;
|
|
325
332
|
private buildConvertV2Payload;
|
|
333
|
+
private buildFileInfoPayload;
|
|
326
334
|
private cacheFile;
|
|
327
335
|
private cacheFileV2;
|
|
328
336
|
private convertInternal;
|
|
@@ -373,6 +381,15 @@ declare class ToolbarModule {
|
|
|
373
381
|
disableAllPdf(): void;
|
|
374
382
|
enableAll3D(): void;
|
|
375
383
|
enableAllPdf(): void;
|
|
384
|
+
hideToolbar(): void;
|
|
385
|
+
showToolbar(): void;
|
|
386
|
+
setToolbarVisible(visible: boolean, target?: ToolbarVisibilityTarget): void;
|
|
387
|
+
hideLeftToolbar(): void;
|
|
388
|
+
showLeftToolbar(): void;
|
|
389
|
+
hideCenterToolbar(): void;
|
|
390
|
+
showCenterToolbar(): void;
|
|
391
|
+
hideRightToolbar(): void;
|
|
392
|
+
showRightToolbar(): void;
|
|
376
393
|
openClippingPlanes(): void;
|
|
377
394
|
closeClippingPlanes(): void;
|
|
378
395
|
openSetting(): void;
|
|
@@ -406,6 +423,7 @@ declare class ToolbarModule {
|
|
|
406
423
|
cuttingReversePlaneY(): void;
|
|
407
424
|
cuttingReversePlaneZ(): void;
|
|
408
425
|
private postConfig;
|
|
426
|
+
private postToolbarVisibility;
|
|
409
427
|
private postPanelOpen;
|
|
410
428
|
private postPanelClose;
|
|
411
429
|
private postCuttingAction;
|
|
@@ -499,4 +517,4 @@ declare class Viewer3D {
|
|
|
499
517
|
private handleMessage;
|
|
500
518
|
}
|
|
501
519
|
|
|
502
|
-
export { type ConvertOptions, type ConvertV2Options, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
|
|
520
|
+
export { type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
|
package/dist/index.js
CHANGED
|
@@ -231,6 +231,30 @@ var FilesModule = class {
|
|
|
231
231
|
}
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
|
+
// Check stream file info by one or more baseFileId values.
|
|
235
|
+
async checkFileInfo(baseFileIds) {
|
|
236
|
+
const payload = this.buildFileInfoPayload(baseFileIds);
|
|
237
|
+
const hostConversion = await this.resolveHostConversion();
|
|
238
|
+
const url = `${hostConversion}/api/StreamFile/info`;
|
|
239
|
+
const response = await fetch(url, {
|
|
240
|
+
method: "POST",
|
|
241
|
+
headers: {
|
|
242
|
+
"Content-Type": "application/json",
|
|
243
|
+
Accept: "application/json"
|
|
244
|
+
},
|
|
245
|
+
body: JSON.stringify(payload)
|
|
246
|
+
});
|
|
247
|
+
if (!response.ok) {
|
|
248
|
+
throw new Error(`Check file info failed (${response.status} ${response.statusText})`);
|
|
249
|
+
}
|
|
250
|
+
const text = await response.text();
|
|
251
|
+
if (!text) return null;
|
|
252
|
+
try {
|
|
253
|
+
return JSON.parse(text);
|
|
254
|
+
} catch {
|
|
255
|
+
return text;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
234
258
|
// Open iframe with an already prepared viewer URL.
|
|
235
259
|
open(input) {
|
|
236
260
|
const url = input.url;
|
|
@@ -274,12 +298,30 @@ var FilesModule = class {
|
|
|
274
298
|
}
|
|
275
299
|
// Resolve viewer route path (e.g. /mainviewer).
|
|
276
300
|
resolveViewerPath() {
|
|
277
|
-
const
|
|
301
|
+
const configuredPath = this.config.viewerPath || this.viewer.getOptions().viewerPath;
|
|
302
|
+
if (!configuredPath) {
|
|
303
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
304
|
+
if (viewerUrl) {
|
|
305
|
+
try {
|
|
306
|
+
const pathname = new URL(viewerUrl, window.location.href).pathname;
|
|
307
|
+
if (pathname && pathname !== "/") return pathname;
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const p = (configuredPath || "/mainviewer").trim();
|
|
278
313
|
if (!p) return "/mainviewer";
|
|
279
314
|
return p.startsWith("/") ? p : `/${p}`;
|
|
280
315
|
}
|
|
281
316
|
// Viewer host used to open iframe after conversion completes.
|
|
282
317
|
resolveViewerOrigin() {
|
|
318
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
319
|
+
if (viewerUrl) {
|
|
320
|
+
try {
|
|
321
|
+
return this.normalizeBaseUrl(new URL(viewerUrl, window.location.href).origin);
|
|
322
|
+
} catch {
|
|
323
|
+
}
|
|
324
|
+
}
|
|
283
325
|
return this.normalizeBaseUrl(DEFAULT_VIEWER_ORIGIN);
|
|
284
326
|
}
|
|
285
327
|
// Build conversion service root from API base URL.
|
|
@@ -408,6 +450,13 @@ var FilesModule = class {
|
|
|
408
450
|
baseMinorRev: (_b = options.baseMinorRev) != null ? _b : 0
|
|
409
451
|
};
|
|
410
452
|
}
|
|
453
|
+
buildFileInfoPayload(baseFileIds) {
|
|
454
|
+
const ids = (Array.isArray(baseFileIds) ? baseFileIds : [baseFileIds]).map((baseFileId) => String(baseFileId).trim()).filter(Boolean);
|
|
455
|
+
if (ids.length === 0) {
|
|
456
|
+
throw new Error("No baseFileId provided");
|
|
457
|
+
}
|
|
458
|
+
return ids.map((baseFileId) => ({ baseFileId }));
|
|
459
|
+
}
|
|
411
460
|
// Submit conversion/caching request and return service response.
|
|
412
461
|
async cacheFile(file, baseFileId, options = {}) {
|
|
413
462
|
const hostConversion = await this.resolveHostConversion();
|
|
@@ -614,6 +663,33 @@ var ToolbarModule = class {
|
|
|
614
663
|
enableAllPdf() {
|
|
615
664
|
this.clearDisabledPdf();
|
|
616
665
|
}
|
|
666
|
+
hideToolbar() {
|
|
667
|
+
this.setToolbarVisible(false);
|
|
668
|
+
}
|
|
669
|
+
showToolbar() {
|
|
670
|
+
this.setToolbarVisible(true);
|
|
671
|
+
}
|
|
672
|
+
setToolbarVisible(visible, target = "all") {
|
|
673
|
+
this.postToolbarVisibility({ visible, target });
|
|
674
|
+
}
|
|
675
|
+
hideLeftToolbar() {
|
|
676
|
+
this.setToolbarVisible(false, "left");
|
|
677
|
+
}
|
|
678
|
+
showLeftToolbar() {
|
|
679
|
+
this.setToolbarVisible(true, "left");
|
|
680
|
+
}
|
|
681
|
+
hideCenterToolbar() {
|
|
682
|
+
this.setToolbarVisible(false, "center");
|
|
683
|
+
}
|
|
684
|
+
showCenterToolbar() {
|
|
685
|
+
this.setToolbarVisible(true, "center");
|
|
686
|
+
}
|
|
687
|
+
hideRightToolbar() {
|
|
688
|
+
this.setToolbarVisible(false, "right");
|
|
689
|
+
}
|
|
690
|
+
showRightToolbar() {
|
|
691
|
+
this.setToolbarVisible(true, "right");
|
|
692
|
+
}
|
|
617
693
|
openClippingPlanes() {
|
|
618
694
|
this.postPanelOpen({ panel: "clipping-commands", format: "3d" });
|
|
619
695
|
}
|
|
@@ -728,6 +804,9 @@ var ToolbarModule = class {
|
|
|
728
804
|
postConfig(payload) {
|
|
729
805
|
this.viewer.postToViewer("viewer-toolbar-config" /* TOOLBAR_CONFIG */, payload);
|
|
730
806
|
}
|
|
807
|
+
postToolbarVisibility(payload) {
|
|
808
|
+
this.viewer.postToViewer("viewer-toolbar-visibility" /* TOOLBAR_VISIBILITY */, payload);
|
|
809
|
+
}
|
|
731
810
|
postPanelOpen(payload) {
|
|
732
811
|
this.viewer.postToViewer("viewer-panel-open" /* PANEL_OPEN */, payload);
|
|
733
812
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -205,6 +205,30 @@ var FilesModule = class {
|
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
|
+
// Check stream file info by one or more baseFileId values.
|
|
209
|
+
async checkFileInfo(baseFileIds) {
|
|
210
|
+
const payload = this.buildFileInfoPayload(baseFileIds);
|
|
211
|
+
const hostConversion = await this.resolveHostConversion();
|
|
212
|
+
const url = `${hostConversion}/api/StreamFile/info`;
|
|
213
|
+
const response = await fetch(url, {
|
|
214
|
+
method: "POST",
|
|
215
|
+
headers: {
|
|
216
|
+
"Content-Type": "application/json",
|
|
217
|
+
Accept: "application/json"
|
|
218
|
+
},
|
|
219
|
+
body: JSON.stringify(payload)
|
|
220
|
+
});
|
|
221
|
+
if (!response.ok) {
|
|
222
|
+
throw new Error(`Check file info failed (${response.status} ${response.statusText})`);
|
|
223
|
+
}
|
|
224
|
+
const text = await response.text();
|
|
225
|
+
if (!text) return null;
|
|
226
|
+
try {
|
|
227
|
+
return JSON.parse(text);
|
|
228
|
+
} catch {
|
|
229
|
+
return text;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
208
232
|
// Open iframe with an already prepared viewer URL.
|
|
209
233
|
open(input) {
|
|
210
234
|
const url = input.url;
|
|
@@ -248,12 +272,30 @@ var FilesModule = class {
|
|
|
248
272
|
}
|
|
249
273
|
// Resolve viewer route path (e.g. /mainviewer).
|
|
250
274
|
resolveViewerPath() {
|
|
251
|
-
const
|
|
275
|
+
const configuredPath = this.config.viewerPath || this.viewer.getOptions().viewerPath;
|
|
276
|
+
if (!configuredPath) {
|
|
277
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
278
|
+
if (viewerUrl) {
|
|
279
|
+
try {
|
|
280
|
+
const pathname = new URL(viewerUrl, window.location.href).pathname;
|
|
281
|
+
if (pathname && pathname !== "/") return pathname;
|
|
282
|
+
} catch {
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const p = (configuredPath || "/mainviewer").trim();
|
|
252
287
|
if (!p) return "/mainviewer";
|
|
253
288
|
return p.startsWith("/") ? p : `/${p}`;
|
|
254
289
|
}
|
|
255
290
|
// Viewer host used to open iframe after conversion completes.
|
|
256
291
|
resolveViewerOrigin() {
|
|
292
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
293
|
+
if (viewerUrl) {
|
|
294
|
+
try {
|
|
295
|
+
return this.normalizeBaseUrl(new URL(viewerUrl, window.location.href).origin);
|
|
296
|
+
} catch {
|
|
297
|
+
}
|
|
298
|
+
}
|
|
257
299
|
return this.normalizeBaseUrl(DEFAULT_VIEWER_ORIGIN);
|
|
258
300
|
}
|
|
259
301
|
// Build conversion service root from API base URL.
|
|
@@ -382,6 +424,13 @@ var FilesModule = class {
|
|
|
382
424
|
baseMinorRev: (_b = options.baseMinorRev) != null ? _b : 0
|
|
383
425
|
};
|
|
384
426
|
}
|
|
427
|
+
buildFileInfoPayload(baseFileIds) {
|
|
428
|
+
const ids = (Array.isArray(baseFileIds) ? baseFileIds : [baseFileIds]).map((baseFileId) => String(baseFileId).trim()).filter(Boolean);
|
|
429
|
+
if (ids.length === 0) {
|
|
430
|
+
throw new Error("No baseFileId provided");
|
|
431
|
+
}
|
|
432
|
+
return ids.map((baseFileId) => ({ baseFileId }));
|
|
433
|
+
}
|
|
385
434
|
// Submit conversion/caching request and return service response.
|
|
386
435
|
async cacheFile(file, baseFileId, options = {}) {
|
|
387
436
|
const hostConversion = await this.resolveHostConversion();
|
|
@@ -588,6 +637,33 @@ var ToolbarModule = class {
|
|
|
588
637
|
enableAllPdf() {
|
|
589
638
|
this.clearDisabledPdf();
|
|
590
639
|
}
|
|
640
|
+
hideToolbar() {
|
|
641
|
+
this.setToolbarVisible(false);
|
|
642
|
+
}
|
|
643
|
+
showToolbar() {
|
|
644
|
+
this.setToolbarVisible(true);
|
|
645
|
+
}
|
|
646
|
+
setToolbarVisible(visible, target = "all") {
|
|
647
|
+
this.postToolbarVisibility({ visible, target });
|
|
648
|
+
}
|
|
649
|
+
hideLeftToolbar() {
|
|
650
|
+
this.setToolbarVisible(false, "left");
|
|
651
|
+
}
|
|
652
|
+
showLeftToolbar() {
|
|
653
|
+
this.setToolbarVisible(true, "left");
|
|
654
|
+
}
|
|
655
|
+
hideCenterToolbar() {
|
|
656
|
+
this.setToolbarVisible(false, "center");
|
|
657
|
+
}
|
|
658
|
+
showCenterToolbar() {
|
|
659
|
+
this.setToolbarVisible(true, "center");
|
|
660
|
+
}
|
|
661
|
+
hideRightToolbar() {
|
|
662
|
+
this.setToolbarVisible(false, "right");
|
|
663
|
+
}
|
|
664
|
+
showRightToolbar() {
|
|
665
|
+
this.setToolbarVisible(true, "right");
|
|
666
|
+
}
|
|
591
667
|
openClippingPlanes() {
|
|
592
668
|
this.postPanelOpen({ panel: "clipping-commands", format: "3d" });
|
|
593
669
|
}
|
|
@@ -702,6 +778,9 @@ var ToolbarModule = class {
|
|
|
702
778
|
postConfig(payload) {
|
|
703
779
|
this.viewer.postToViewer("viewer-toolbar-config" /* TOOLBAR_CONFIG */, payload);
|
|
704
780
|
}
|
|
781
|
+
postToolbarVisibility(payload) {
|
|
782
|
+
this.viewer.postToViewer("viewer-toolbar-visibility" /* TOOLBAR_VISIBILITY */, payload);
|
|
783
|
+
}
|
|
705
784
|
postPanelOpen(payload) {
|
|
706
785
|
this.viewer.postToViewer("viewer-panel-open" /* PANEL_OPEN */, payload);
|
|
707
786
|
}
|
|
@@ -19,6 +19,10 @@ export declare type ConvertV2Options = {
|
|
|
19
19
|
project?: string;
|
|
20
20
|
convertOptions?: Partial<StreamConvertOptions>;
|
|
21
21
|
};
|
|
22
|
+
export declare type FileInfoCheckInput = string | string[];
|
|
23
|
+
export declare type FileInfoCheckPayloadItem = {
|
|
24
|
+
baseFileId: string;
|
|
25
|
+
};
|
|
22
26
|
declare type StreamConvertOptions = {
|
|
23
27
|
convert3DModel: number;
|
|
24
28
|
convert2DSheet: number;
|
|
@@ -77,6 +81,7 @@ export declare class FilesModule {
|
|
|
77
81
|
convert(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
78
82
|
prepare(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
79
83
|
convertV2(options: ConvertV2Options): Promise<PreparedViewerData>;
|
|
84
|
+
checkFileInfo(baseFileIds: FileInfoCheckInput): Promise<unknown>;
|
|
80
85
|
open(input: PreparedViewerData | {
|
|
81
86
|
url: string;
|
|
82
87
|
}): void;
|
|
@@ -95,6 +100,7 @@ export declare class FilesModule {
|
|
|
95
100
|
private uploadInternal;
|
|
96
101
|
private buildCachePayload;
|
|
97
102
|
private buildConvertV2Payload;
|
|
103
|
+
private buildFileInfoPayload;
|
|
98
104
|
private cacheFile;
|
|
99
105
|
private cacheFileV2;
|
|
100
106
|
private convertInternal;
|
|
@@ -87,6 +87,32 @@ export class FilesModule {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
// Check stream file info by one or more baseFileId values.
|
|
91
|
+
async checkFileInfo(baseFileIds) {
|
|
92
|
+
const payload = this.buildFileInfoPayload(baseFileIds);
|
|
93
|
+
const hostConversion = await this.resolveHostConversion();
|
|
94
|
+
const url = `${hostConversion}/api/StreamFile/info`;
|
|
95
|
+
const response = await fetch(url, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: {
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
Accept: "application/json",
|
|
100
|
+
},
|
|
101
|
+
body: JSON.stringify(payload),
|
|
102
|
+
});
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
throw new Error(`Check file info failed (${response.status} ${response.statusText})`);
|
|
105
|
+
}
|
|
106
|
+
const text = await response.text();
|
|
107
|
+
if (!text)
|
|
108
|
+
return null;
|
|
109
|
+
try {
|
|
110
|
+
return JSON.parse(text);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return text;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
90
116
|
// Open iframe with an already prepared viewer URL.
|
|
91
117
|
open(input) {
|
|
92
118
|
const url = input.url;
|
|
@@ -134,13 +160,36 @@ export class FilesModule {
|
|
|
134
160
|
}
|
|
135
161
|
// Resolve viewer route path (e.g. /mainviewer).
|
|
136
162
|
resolveViewerPath() {
|
|
137
|
-
const
|
|
163
|
+
const configuredPath = this.config.viewerPath || this.viewer.getOptions().viewerPath;
|
|
164
|
+
if (!configuredPath) {
|
|
165
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
166
|
+
if (viewerUrl) {
|
|
167
|
+
try {
|
|
168
|
+
const pathname = new URL(viewerUrl, window.location.href).pathname;
|
|
169
|
+
if (pathname && pathname !== "/")
|
|
170
|
+
return pathname;
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// Fallback to default path below.
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const p = (configuredPath || "/mainviewer").trim();
|
|
138
178
|
if (!p)
|
|
139
179
|
return "/mainviewer";
|
|
140
180
|
return p.startsWith("/") ? p : `/${p}`;
|
|
141
181
|
}
|
|
142
182
|
// Viewer host used to open iframe after conversion completes.
|
|
143
183
|
resolveViewerOrigin() {
|
|
184
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
185
|
+
if (viewerUrl) {
|
|
186
|
+
try {
|
|
187
|
+
return this.normalizeBaseUrl(new URL(viewerUrl, window.location.href).origin);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// Fallback to default origin below.
|
|
191
|
+
}
|
|
192
|
+
}
|
|
144
193
|
return this.normalizeBaseUrl(DEFAULT_VIEWER_ORIGIN);
|
|
145
194
|
}
|
|
146
195
|
// Build conversion service root from API base URL.
|
|
@@ -274,6 +323,15 @@ export class FilesModule {
|
|
|
274
323
|
baseMinorRev: (_b = options.baseMinorRev) !== null && _b !== void 0 ? _b : 0,
|
|
275
324
|
};
|
|
276
325
|
}
|
|
326
|
+
buildFileInfoPayload(baseFileIds) {
|
|
327
|
+
const ids = (Array.isArray(baseFileIds) ? baseFileIds : [baseFileIds])
|
|
328
|
+
.map((baseFileId) => String(baseFileId).trim())
|
|
329
|
+
.filter(Boolean);
|
|
330
|
+
if (ids.length === 0) {
|
|
331
|
+
throw new Error("No baseFileId provided");
|
|
332
|
+
}
|
|
333
|
+
return ids.map((baseFileId) => ({ baseFileId }));
|
|
334
|
+
}
|
|
277
335
|
// Submit conversion/caching request and return service response.
|
|
278
336
|
async cacheFile(file, baseFileId, options = {}) {
|
|
279
337
|
const hostConversion = await this.resolveHostConversion();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Viewer3D } from "../viewer";
|
|
2
|
-
import { type SheetListItem } from "../contracts/messages";
|
|
2
|
+
import { type SheetListItem, type ToolbarVisibilityTarget } from "../contracts/messages";
|
|
3
3
|
export declare type ToolbarFormat = "3d" | "pdf";
|
|
4
4
|
export declare type GetSheetsOptions = {
|
|
5
5
|
timeoutMs?: number;
|
|
@@ -42,6 +42,15 @@ export declare class ToolbarModule {
|
|
|
42
42
|
disableAllPdf(): void;
|
|
43
43
|
enableAll3D(): void;
|
|
44
44
|
enableAllPdf(): void;
|
|
45
|
+
hideToolbar(): void;
|
|
46
|
+
showToolbar(): void;
|
|
47
|
+
setToolbarVisible(visible: boolean, target?: ToolbarVisibilityTarget): void;
|
|
48
|
+
hideLeftToolbar(): void;
|
|
49
|
+
showLeftToolbar(): void;
|
|
50
|
+
hideCenterToolbar(): void;
|
|
51
|
+
showCenterToolbar(): void;
|
|
52
|
+
hideRightToolbar(): void;
|
|
53
|
+
showRightToolbar(): void;
|
|
45
54
|
openClippingPlanes(): void;
|
|
46
55
|
closeClippingPlanes(): void;
|
|
47
56
|
openSetting(): void;
|
|
@@ -75,6 +84,7 @@ export declare class ToolbarModule {
|
|
|
75
84
|
cuttingReversePlaneY(): void;
|
|
76
85
|
cuttingReversePlaneZ(): void;
|
|
77
86
|
private postConfig;
|
|
87
|
+
private postToolbarVisibility;
|
|
78
88
|
private postPanelOpen;
|
|
79
89
|
private postPanelClose;
|
|
80
90
|
private postCuttingAction;
|
|
@@ -86,6 +86,33 @@ export class ToolbarModule {
|
|
|
86
86
|
enableAllPdf() {
|
|
87
87
|
this.clearDisabledPdf();
|
|
88
88
|
}
|
|
89
|
+
hideToolbar() {
|
|
90
|
+
this.setToolbarVisible(false);
|
|
91
|
+
}
|
|
92
|
+
showToolbar() {
|
|
93
|
+
this.setToolbarVisible(true);
|
|
94
|
+
}
|
|
95
|
+
setToolbarVisible(visible, target = "all") {
|
|
96
|
+
this.postToolbarVisibility({ visible, target });
|
|
97
|
+
}
|
|
98
|
+
hideLeftToolbar() {
|
|
99
|
+
this.setToolbarVisible(false, "left");
|
|
100
|
+
}
|
|
101
|
+
showLeftToolbar() {
|
|
102
|
+
this.setToolbarVisible(true, "left");
|
|
103
|
+
}
|
|
104
|
+
hideCenterToolbar() {
|
|
105
|
+
this.setToolbarVisible(false, "center");
|
|
106
|
+
}
|
|
107
|
+
showCenterToolbar() {
|
|
108
|
+
this.setToolbarVisible(true, "center");
|
|
109
|
+
}
|
|
110
|
+
hideRightToolbar() {
|
|
111
|
+
this.setToolbarVisible(false, "right");
|
|
112
|
+
}
|
|
113
|
+
showRightToolbar() {
|
|
114
|
+
this.setToolbarVisible(true, "right");
|
|
115
|
+
}
|
|
89
116
|
openClippingPlanes() {
|
|
90
117
|
this.postPanelOpen({ panel: "clipping-commands", format: "3d" });
|
|
91
118
|
}
|
|
@@ -201,6 +228,9 @@ export class ToolbarModule {
|
|
|
201
228
|
postConfig(payload) {
|
|
202
229
|
this.viewer.postToViewer(ViewerMessageType.TOOLBAR_CONFIG, payload);
|
|
203
230
|
}
|
|
231
|
+
postToolbarVisibility(payload) {
|
|
232
|
+
this.viewer.postToViewer(ViewerMessageType.TOOLBAR_VISIBILITY, payload);
|
|
233
|
+
}
|
|
204
234
|
postPanelOpen(payload) {
|
|
205
235
|
this.viewer.postToViewer(ViewerMessageType.PANEL_OPEN, payload);
|
|
206
236
|
}
|