3dviewer-sdk 1.0.9 → 1.0.11
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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +23 -2
- package/dist/index.mjs +23 -2
- package/dist/modules/files.module.js +9 -0
- package/dist/viewer.d.ts +4 -1
- package/dist/viewer.js +15 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -475,6 +475,7 @@ declare class LanguageModule {
|
|
|
475
475
|
set(language: LanguageCode): void;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
+
type InitialToolbarVisibility = Partial<Record<ToolbarVisibilityTarget, boolean>>;
|
|
478
479
|
type Viewer3DOptions = {
|
|
479
480
|
container: HTMLElement | string;
|
|
480
481
|
url?: string;
|
|
@@ -482,6 +483,7 @@ type Viewer3DOptions = {
|
|
|
482
483
|
viewerPath?: string;
|
|
483
484
|
uploadPath?: string;
|
|
484
485
|
file?: File;
|
|
486
|
+
initialToolbarVisibility?: InitialToolbarVisibility;
|
|
485
487
|
width?: string;
|
|
486
488
|
height?: string;
|
|
487
489
|
sandbox?: string;
|
|
@@ -510,6 +512,7 @@ declare class Viewer3D {
|
|
|
510
512
|
open(url: string): void;
|
|
511
513
|
destroy(): void;
|
|
512
514
|
private ensureInit;
|
|
515
|
+
private withInitialOptions;
|
|
513
516
|
_on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
|
|
514
517
|
_off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
|
|
515
518
|
_emit<K extends SdkEventKey>(event: K, payload: SdkEventPayload<K>): void;
|
|
@@ -517,4 +520,4 @@ declare class Viewer3D {
|
|
|
517
520
|
private handleMessage;
|
|
518
521
|
}
|
|
519
522
|
|
|
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 };
|
|
523
|
+
export { type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarVisibility, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
|
package/dist/index.d.ts
CHANGED
|
@@ -475,6 +475,7 @@ declare class LanguageModule {
|
|
|
475
475
|
set(language: LanguageCode): void;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
+
type InitialToolbarVisibility = Partial<Record<ToolbarVisibilityTarget, boolean>>;
|
|
478
479
|
type Viewer3DOptions = {
|
|
479
480
|
container: HTMLElement | string;
|
|
480
481
|
url?: string;
|
|
@@ -482,6 +483,7 @@ type Viewer3DOptions = {
|
|
|
482
483
|
viewerPath?: string;
|
|
483
484
|
uploadPath?: string;
|
|
484
485
|
file?: File;
|
|
486
|
+
initialToolbarVisibility?: InitialToolbarVisibility;
|
|
485
487
|
width?: string;
|
|
486
488
|
height?: string;
|
|
487
489
|
sandbox?: string;
|
|
@@ -510,6 +512,7 @@ declare class Viewer3D {
|
|
|
510
512
|
open(url: string): void;
|
|
511
513
|
destroy(): void;
|
|
512
514
|
private ensureInit;
|
|
515
|
+
private withInitialOptions;
|
|
513
516
|
_on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
|
|
514
517
|
_off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
|
|
515
518
|
_emit<K extends SdkEventKey>(event: K, payload: SdkEventPayload<K>): void;
|
|
@@ -517,4 +520,4 @@ declare class Viewer3D {
|
|
|
517
520
|
private handleMessage;
|
|
518
521
|
}
|
|
519
522
|
|
|
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 };
|
|
523
|
+
export { type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarVisibility, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
|
package/dist/index.js
CHANGED
|
@@ -315,6 +315,13 @@ var FilesModule = class {
|
|
|
315
315
|
}
|
|
316
316
|
// Viewer host used to open iframe after conversion completes.
|
|
317
317
|
resolveViewerOrigin() {
|
|
318
|
+
const configuredBaseUrl = this.config.baseUrl || this.viewer.getOptions().baseUrl;
|
|
319
|
+
if (configuredBaseUrl) {
|
|
320
|
+
try {
|
|
321
|
+
return this.normalizeBaseUrl(new URL(configuredBaseUrl, window.location.href).origin);
|
|
322
|
+
} catch {
|
|
323
|
+
}
|
|
324
|
+
}
|
|
318
325
|
const viewerUrl = this.viewer.getOptions().url;
|
|
319
326
|
if (viewerUrl) {
|
|
320
327
|
try {
|
|
@@ -1165,7 +1172,7 @@ var Viewer3D = class {
|
|
|
1165
1172
|
if (this.iframeEl) return;
|
|
1166
1173
|
if (!this.options.url) return this.files.render(file);
|
|
1167
1174
|
const iframe = document.createElement("iframe");
|
|
1168
|
-
iframe.src = this.options.url;
|
|
1175
|
+
iframe.src = this.withInitialOptions(this.options.url);
|
|
1169
1176
|
iframe.style.border = "none";
|
|
1170
1177
|
iframe.style.width = this.options.width || "100%";
|
|
1171
1178
|
iframe.style.height = this.options.height || "100%";
|
|
@@ -1178,11 +1185,12 @@ var Viewer3D = class {
|
|
|
1178
1185
|
open(url) {
|
|
1179
1186
|
this.ensureInit();
|
|
1180
1187
|
this.options.url = url;
|
|
1188
|
+
const finalUrl = this.withInitialOptions(url);
|
|
1181
1189
|
if (!this.iframeEl) {
|
|
1182
1190
|
this.render();
|
|
1183
1191
|
return;
|
|
1184
1192
|
}
|
|
1185
|
-
this.iframeEl.src =
|
|
1193
|
+
this.iframeEl.src = finalUrl;
|
|
1186
1194
|
}
|
|
1187
1195
|
destroy() {
|
|
1188
1196
|
window.removeEventListener("message", this.handleMessage);
|
|
@@ -1199,6 +1207,19 @@ var Viewer3D = class {
|
|
|
1199
1207
|
ensureInit() {
|
|
1200
1208
|
if (!this.initialized) throw new Error("Call viewer.init() before using viewer");
|
|
1201
1209
|
}
|
|
1210
|
+
withInitialOptions(url) {
|
|
1211
|
+
if (!this.options.initialToolbarVisibility) return url;
|
|
1212
|
+
try {
|
|
1213
|
+
const parsedUrl = new URL(url, window.location.href);
|
|
1214
|
+
parsedUrl.searchParams.set(
|
|
1215
|
+
"toolbarVisibility",
|
|
1216
|
+
JSON.stringify(this.options.initialToolbarVisibility)
|
|
1217
|
+
);
|
|
1218
|
+
return parsedUrl.toString();
|
|
1219
|
+
} catch {
|
|
1220
|
+
return url;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1202
1223
|
// ===== typed internal events used by modules =====
|
|
1203
1224
|
_on(event, cb) {
|
|
1204
1225
|
return this.emitter.on(event, cb);
|
package/dist/index.mjs
CHANGED
|
@@ -289,6 +289,13 @@ var FilesModule = class {
|
|
|
289
289
|
}
|
|
290
290
|
// Viewer host used to open iframe after conversion completes.
|
|
291
291
|
resolveViewerOrigin() {
|
|
292
|
+
const configuredBaseUrl = this.config.baseUrl || this.viewer.getOptions().baseUrl;
|
|
293
|
+
if (configuredBaseUrl) {
|
|
294
|
+
try {
|
|
295
|
+
return this.normalizeBaseUrl(new URL(configuredBaseUrl, window.location.href).origin);
|
|
296
|
+
} catch {
|
|
297
|
+
}
|
|
298
|
+
}
|
|
292
299
|
const viewerUrl = this.viewer.getOptions().url;
|
|
293
300
|
if (viewerUrl) {
|
|
294
301
|
try {
|
|
@@ -1139,7 +1146,7 @@ var Viewer3D = class {
|
|
|
1139
1146
|
if (this.iframeEl) return;
|
|
1140
1147
|
if (!this.options.url) return this.files.render(file);
|
|
1141
1148
|
const iframe = document.createElement("iframe");
|
|
1142
|
-
iframe.src = this.options.url;
|
|
1149
|
+
iframe.src = this.withInitialOptions(this.options.url);
|
|
1143
1150
|
iframe.style.border = "none";
|
|
1144
1151
|
iframe.style.width = this.options.width || "100%";
|
|
1145
1152
|
iframe.style.height = this.options.height || "100%";
|
|
@@ -1152,11 +1159,12 @@ var Viewer3D = class {
|
|
|
1152
1159
|
open(url) {
|
|
1153
1160
|
this.ensureInit();
|
|
1154
1161
|
this.options.url = url;
|
|
1162
|
+
const finalUrl = this.withInitialOptions(url);
|
|
1155
1163
|
if (!this.iframeEl) {
|
|
1156
1164
|
this.render();
|
|
1157
1165
|
return;
|
|
1158
1166
|
}
|
|
1159
|
-
this.iframeEl.src =
|
|
1167
|
+
this.iframeEl.src = finalUrl;
|
|
1160
1168
|
}
|
|
1161
1169
|
destroy() {
|
|
1162
1170
|
window.removeEventListener("message", this.handleMessage);
|
|
@@ -1173,6 +1181,19 @@ var Viewer3D = class {
|
|
|
1173
1181
|
ensureInit() {
|
|
1174
1182
|
if (!this.initialized) throw new Error("Call viewer.init() before using viewer");
|
|
1175
1183
|
}
|
|
1184
|
+
withInitialOptions(url) {
|
|
1185
|
+
if (!this.options.initialToolbarVisibility) return url;
|
|
1186
|
+
try {
|
|
1187
|
+
const parsedUrl = new URL(url, window.location.href);
|
|
1188
|
+
parsedUrl.searchParams.set(
|
|
1189
|
+
"toolbarVisibility",
|
|
1190
|
+
JSON.stringify(this.options.initialToolbarVisibility)
|
|
1191
|
+
);
|
|
1192
|
+
return parsedUrl.toString();
|
|
1193
|
+
} catch {
|
|
1194
|
+
return url;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1176
1197
|
// ===== typed internal events used by modules =====
|
|
1177
1198
|
_on(event, cb) {
|
|
1178
1199
|
return this.emitter.on(event, cb);
|
|
@@ -181,6 +181,15 @@ export class FilesModule {
|
|
|
181
181
|
}
|
|
182
182
|
// Viewer host used to open iframe after conversion completes.
|
|
183
183
|
resolveViewerOrigin() {
|
|
184
|
+
const configuredBaseUrl = this.config.baseUrl || this.viewer.getOptions().baseUrl;
|
|
185
|
+
if (configuredBaseUrl) {
|
|
186
|
+
try {
|
|
187
|
+
return this.normalizeBaseUrl(new URL(configuredBaseUrl, window.location.href).origin);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// Fallback to viewer URL below.
|
|
191
|
+
}
|
|
192
|
+
}
|
|
184
193
|
const viewerUrl = this.viewer.getOptions().url;
|
|
185
194
|
if (viewerUrl) {
|
|
186
195
|
try {
|
package/dist/viewer.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { ToolbarModule } from "./modules/toolbar.module";
|
|
|
7
7
|
import { ModelTreeModule } from "./modules/model-tree.module";
|
|
8
8
|
import { MarkupModule } from "./modules/markup.module";
|
|
9
9
|
import { LanguageModule } from "./modules/language.module";
|
|
10
|
-
import { ViewerMessageType } from "./contracts/messages";
|
|
10
|
+
import { ViewerMessageType, type ToolbarVisibilityTarget } from "./contracts/messages";
|
|
11
|
+
export declare type InitialToolbarVisibility = Partial<Record<ToolbarVisibilityTarget, boolean>>;
|
|
11
12
|
export declare type Viewer3DOptions = {
|
|
12
13
|
container: HTMLElement | string;
|
|
13
14
|
url?: string;
|
|
@@ -15,6 +16,7 @@ export declare type Viewer3DOptions = {
|
|
|
15
16
|
viewerPath?: string;
|
|
16
17
|
uploadPath?: string;
|
|
17
18
|
file?: File;
|
|
19
|
+
initialToolbarVisibility?: InitialToolbarVisibility;
|
|
18
20
|
width?: string;
|
|
19
21
|
height?: string;
|
|
20
22
|
sandbox?: string;
|
|
@@ -43,6 +45,7 @@ export declare class Viewer3D {
|
|
|
43
45
|
open(url: string): void;
|
|
44
46
|
destroy(): void;
|
|
45
47
|
private ensureInit;
|
|
48
|
+
private withInitialOptions;
|
|
46
49
|
_on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
|
|
47
50
|
_off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
|
|
48
51
|
_emit<K extends SdkEventKey>(event: K, payload: SdkEventPayload<K>): void;
|
package/dist/viewer.js
CHANGED
|
@@ -211,7 +211,7 @@ export class Viewer3D {
|
|
|
211
211
|
if (!this.options.url)
|
|
212
212
|
return this.files.render(file);
|
|
213
213
|
const iframe = document.createElement("iframe");
|
|
214
|
-
iframe.src = this.options.url;
|
|
214
|
+
iframe.src = this.withInitialOptions(this.options.url);
|
|
215
215
|
iframe.style.border = "none";
|
|
216
216
|
iframe.style.width = this.options.width || "100%";
|
|
217
217
|
iframe.style.height = this.options.height || "100%";
|
|
@@ -225,11 +225,12 @@ export class Viewer3D {
|
|
|
225
225
|
open(url) {
|
|
226
226
|
this.ensureInit();
|
|
227
227
|
this.options.url = url;
|
|
228
|
+
const finalUrl = this.withInitialOptions(url);
|
|
228
229
|
if (!this.iframeEl) {
|
|
229
230
|
this.render();
|
|
230
231
|
return;
|
|
231
232
|
}
|
|
232
|
-
this.iframeEl.src =
|
|
233
|
+
this.iframeEl.src = finalUrl;
|
|
233
234
|
}
|
|
234
235
|
destroy() {
|
|
235
236
|
// remove listener using the same function reference
|
|
@@ -251,6 +252,18 @@ export class Viewer3D {
|
|
|
251
252
|
if (!this.initialized)
|
|
252
253
|
throw new Error("Call viewer.init() before using viewer");
|
|
253
254
|
}
|
|
255
|
+
withInitialOptions(url) {
|
|
256
|
+
if (!this.options.initialToolbarVisibility)
|
|
257
|
+
return url;
|
|
258
|
+
try {
|
|
259
|
+
const parsedUrl = new URL(url, window.location.href);
|
|
260
|
+
parsedUrl.searchParams.set("toolbarVisibility", JSON.stringify(this.options.initialToolbarVisibility));
|
|
261
|
+
return parsedUrl.toString();
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
return url;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
254
267
|
// ===== typed internal events used by modules =====
|
|
255
268
|
_on(event, cb) {
|
|
256
269
|
return this.emitter.on(event, cb);
|