3dviewer-sdk 1.0.8 → 1.0.10

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.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;
@@ -400,6 +424,13 @@ var FilesModule = class {
400
424
  baseMinorRev: (_b = options.baseMinorRev) != null ? _b : 0
401
425
  };
402
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
+ }
403
434
  // Submit conversion/caching request and return service response.
404
435
  async cacheFile(file, baseFileId, options = {}) {
405
436
  const hostConversion = await this.resolveHostConversion();
@@ -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;
@@ -155,6 +181,15 @@ export class FilesModule {
155
181
  }
156
182
  // Viewer host used to open iframe after conversion completes.
157
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
+ }
158
193
  const viewerUrl = this.viewer.getOptions().url;
159
194
  if (viewerUrl) {
160
195
  try {
@@ -297,6 +332,15 @@ export class FilesModule {
297
332
  baseMinorRev: (_b = options.baseMinorRev) !== null && _b !== void 0 ? _b : 0,
298
333
  };
299
334
  }
335
+ buildFileInfoPayload(baseFileIds) {
336
+ const ids = (Array.isArray(baseFileIds) ? baseFileIds : [baseFileIds])
337
+ .map((baseFileId) => String(baseFileId).trim())
338
+ .filter(Boolean);
339
+ if (ids.length === 0) {
340
+ throw new Error("No baseFileId provided");
341
+ }
342
+ return ids.map((baseFileId) => ({ baseFileId }));
343
+ }
300
344
  // Submit conversion/caching request and return service response.
301
345
  async cacheFile(file, baseFileId, options = {}) {
302
346
  const hostConversion = await this.resolveHostConversion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3dviewer-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [