3dviewer-sdk 1.0.3 → 1.0.6

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
@@ -236,6 +236,23 @@ type FilesConfig = {
236
236
  type ConvertOptions = {
237
237
  downloadUrl?: string;
238
238
  };
239
+ type ConvertV2Options = {
240
+ filename: string;
241
+ originalFilePath: string;
242
+ downloadUrl: string;
243
+ baseFileId: string;
244
+ baseMajorRev?: number;
245
+ baseMinorRev?: number;
246
+ overwrite?: boolean;
247
+ project?: string;
248
+ convertOptions?: Partial<StreamConvertOptions>;
249
+ };
250
+ type StreamConvertOptions = {
251
+ convert3DModel: number;
252
+ convert2DSheet: number;
253
+ extractProperties: number;
254
+ childModels: number;
255
+ };
239
256
  declare class FilesModule {
240
257
  private viewer;
241
258
  on: {
@@ -287,6 +304,7 @@ declare class FilesModule {
287
304
  }>;
288
305
  convert(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
289
306
  prepare(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
307
+ convertV2(options: ConvertV2Options): Promise<PreparedViewerData>;
290
308
  open(input: PreparedViewerData | {
291
309
  url: string;
292
310
  }): void;
@@ -297,6 +315,7 @@ declare class FilesModule {
297
315
  private resolveViewerPath;
298
316
  private resolveViewerOrigin;
299
317
  private resolveHostConversion;
318
+ private resolveApiRoot;
300
319
  private getUploadPath;
301
320
  private fileSignature;
302
321
  private createBaseFileId;
@@ -304,8 +323,11 @@ declare class FilesModule {
304
323
  private getUploadSessionForFile;
305
324
  private uploadInternal;
306
325
  private buildCachePayload;
326
+ private buildConvertV2Payload;
307
327
  private cacheFile;
328
+ private cacheFileV2;
308
329
  private convertInternal;
330
+ private convertV2Internal;
309
331
  private updateState;
310
332
  private withOperation;
311
333
  private toErrorMessage;
@@ -478,4 +500,4 @@ declare class Viewer3D {
478
500
  private handleMessage;
479
501
  }
480
502
 
481
- export { type ConvertOptions, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
503
+ export { type ConvertOptions, type ConvertV2Options, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
package/dist/index.d.ts CHANGED
@@ -236,6 +236,23 @@ type FilesConfig = {
236
236
  type ConvertOptions = {
237
237
  downloadUrl?: string;
238
238
  };
239
+ type ConvertV2Options = {
240
+ filename: string;
241
+ originalFilePath: string;
242
+ downloadUrl: string;
243
+ baseFileId: string;
244
+ baseMajorRev?: number;
245
+ baseMinorRev?: number;
246
+ overwrite?: boolean;
247
+ project?: string;
248
+ convertOptions?: Partial<StreamConvertOptions>;
249
+ };
250
+ type StreamConvertOptions = {
251
+ convert3DModel: number;
252
+ convert2DSheet: number;
253
+ extractProperties: number;
254
+ childModels: number;
255
+ };
239
256
  declare class FilesModule {
240
257
  private viewer;
241
258
  on: {
@@ -287,6 +304,7 @@ declare class FilesModule {
287
304
  }>;
288
305
  convert(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
289
306
  prepare(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
307
+ convertV2(options: ConvertV2Options): Promise<PreparedViewerData>;
290
308
  open(input: PreparedViewerData | {
291
309
  url: string;
292
310
  }): void;
@@ -297,6 +315,7 @@ declare class FilesModule {
297
315
  private resolveViewerPath;
298
316
  private resolveViewerOrigin;
299
317
  private resolveHostConversion;
318
+ private resolveApiRoot;
300
319
  private getUploadPath;
301
320
  private fileSignature;
302
321
  private createBaseFileId;
@@ -304,8 +323,11 @@ declare class FilesModule {
304
323
  private getUploadSessionForFile;
305
324
  private uploadInternal;
306
325
  private buildCachePayload;
326
+ private buildConvertV2Payload;
307
327
  private cacheFile;
328
+ private cacheFileV2;
308
329
  private convertInternal;
330
+ private convertV2Internal;
309
331
  private updateState;
310
332
  private withOperation;
311
333
  private toErrorMessage;
@@ -478,4 +500,4 @@ declare class Viewer3D {
478
500
  private handleMessage;
479
501
  }
480
502
 
481
- export { type ConvertOptions, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
503
+ export { type ConvertOptions, type ConvertV2Options, type FilesConfig, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
package/dist/index.js CHANGED
@@ -217,6 +217,20 @@ var FilesModule = class {
217
217
  return prepared;
218
218
  });
219
219
  }
220
+ // Trigger the newer downloadUrl-based conversion flow.
221
+ async convertV2(options) {
222
+ return this.withOperation({ stage: "converting", message: "Converting file..." }, async () => {
223
+ this.viewer._emit("files:conversion:start", { fileName: options.filename });
224
+ try {
225
+ const prepared = await this.convertV2Internal(options);
226
+ this.viewer._emit("files:conversion:success", prepared);
227
+ return prepared;
228
+ } catch (e) {
229
+ this.viewer._emit("files:conversion:error", { fileName: options.filename, error: this.toErrorMessage(e) });
230
+ throw e;
231
+ }
232
+ });
233
+ }
220
234
  // Open iframe with an already prepared viewer URL.
221
235
  open(input) {
222
236
  const url = input.url;
@@ -273,6 +287,10 @@ var FilesModule = class {
273
287
  const baseUrl = this.resolveBaseUrl();
274
288
  return baseUrl.endsWith("/service/conversion") ? baseUrl : `${baseUrl}/service/conversion`;
275
289
  }
290
+ // Newer convert endpoint is served from the API root, not /service/conversion.
291
+ resolveApiRoot() {
292
+ return this.resolveBaseUrl();
293
+ }
276
294
  // Resolve upload path sent to conversion APIs.
277
295
  getUploadPath() {
278
296
  return this.config.uploadPath || this.viewer.getOptions().uploadPath || ".";
@@ -374,6 +392,26 @@ var FilesModule = class {
374
392
  attemptedConvertTimes: 0
375
393
  };
376
394
  }
395
+ // Build payload for POST /api/StreamFile/convert.
396
+ buildConvertV2Payload(options) {
397
+ var _a, _b;
398
+ const convertOptions = {
399
+ convert3DModel: 1,
400
+ convert2DSheet: 1,
401
+ extractProperties: 1,
402
+ childModels: 0,
403
+ ...options.convertOptions
404
+ };
405
+ return {
406
+ filename: options.filename,
407
+ originalFilePath: options.originalFilePath,
408
+ convertOptions,
409
+ downloadUrl: options.downloadUrl,
410
+ baseFileId: options.baseFileId,
411
+ baseMajorRev: (_a = options.baseMajorRev) != null ? _a : 0,
412
+ baseMinorRev: (_b = options.baseMinorRev) != null ? _b : 0
413
+ };
414
+ }
377
415
  // Submit conversion/caching request and return service response.
378
416
  async cacheFile(file, baseFileId, options = {}) {
379
417
  const hostConversion = await this.resolveHostConversion();
@@ -394,6 +432,34 @@ var FilesModule = class {
394
432
  }
395
433
  return await response.json();
396
434
  }
435
+ // Submit conversion request to the newer downloadUrl-based endpoint.
436
+ async cacheFileV2(options) {
437
+ const apiRoot = await this.resolveApiRoot();
438
+ const params = new URLSearchParams();
439
+ if (typeof options.overwrite === "boolean") {
440
+ params.set("overwrite", String(options.overwrite));
441
+ }
442
+ if (options.project) {
443
+ params.set("project", options.project);
444
+ }
445
+ const query = params.toString();
446
+ const url = `${apiRoot}/api/StreamFile/convert${query ? `?${query}` : ""}`;
447
+ const payload = this.buildConvertV2Payload(options);
448
+ const response = await fetch(url, {
449
+ method: "POST",
450
+ headers: {
451
+ "Content-Type": "application/json",
452
+ Accept: "application/json"
453
+ },
454
+ body: JSON.stringify(payload)
455
+ });
456
+ if (!response.ok) {
457
+ throw new Error(
458
+ `Cache/convert v2 failed (${response.status} ${response.statusText})`
459
+ );
460
+ }
461
+ return await response.json();
462
+ }
397
463
  // Convert file and generate final iframe URL with query string.
398
464
  async convertInternal(file, options = {}) {
399
465
  var _a, _b, _c, _d;
@@ -404,7 +470,7 @@ var FilesModule = class {
404
470
  const baseFileId = (_a = cacheResult.baseFileId) != null ? _a : seedBaseFileId;
405
471
  const baseMajorRev = (_b = cacheResult.baseMajorRev) != null ? _b : 0;
406
472
  const baseMinorRev = (_c = cacheResult.baseMinorRev) != null ? _c : 0;
407
- const fileName = cacheResult.filename || file.name;
473
+ const fileName = cacheResult.filename || cacheResult.fileName || file.name;
408
474
  const cacheListItem = { baseFileId, baseMajorRev, baseMinorRev, fileName };
409
475
  if (cacheResult.cacheStatus !== 2) {
410
476
  throw new Error(`Conversion not ready after first request (cacheStatus=${(_d = cacheResult.cacheStatus) != null ? _d : "unknown"})`);
@@ -415,6 +481,24 @@ var FilesModule = class {
415
481
  const url = `${viewerBase}${viewerPath}?${query}`;
416
482
  return { baseFileId, baseMajorRev, baseMinorRev, fileName, query, url };
417
483
  }
484
+ async convertV2Internal(options) {
485
+ var _a, _b, _c, _d, _e;
486
+ this.updateState({ stage: "converting", message: "Converting file..." });
487
+ const cacheResult = await this.cacheFileV2(options);
488
+ const baseFileId = (_a = cacheResult.baseFileId) != null ? _a : options.baseFileId;
489
+ const baseMajorRev = (_c = (_b = cacheResult.baseMajorRev) != null ? _b : options.baseMajorRev) != null ? _c : 0;
490
+ const baseMinorRev = (_e = (_d = cacheResult.baseMinorRev) != null ? _d : options.baseMinorRev) != null ? _e : 0;
491
+ const fileName = cacheResult.filename || cacheResult.fileName || options.filename;
492
+ if (cacheResult.cacheStatus !== void 0 && cacheResult.cacheStatus !== 2) {
493
+ throw new Error(`Conversion not ready after v2 request (cacheStatus=${cacheResult.cacheStatus})`);
494
+ }
495
+ const cacheListItem = { baseFileId, baseMajorRev, baseMinorRev, fileName };
496
+ const query = new URLSearchParams({ fileList: JSON.stringify([cacheListItem]) }).toString();
497
+ const viewerBase = this.resolveViewerOrigin();
498
+ const viewerPath = this.resolveViewerPath();
499
+ const url = `${viewerBase}${viewerPath}?${query}`;
500
+ return { baseFileId, baseMajorRev, baseMinorRev, fileName, query, url };
501
+ }
418
502
  // Update internal loading state and emit state event.
419
503
  updateState(next) {
420
504
  const elapsedMs = this.operationStartTime > 0 ? Date.now() - this.operationStartTime : 0;
package/dist/index.mjs CHANGED
@@ -191,6 +191,20 @@ var FilesModule = class {
191
191
  return prepared;
192
192
  });
193
193
  }
194
+ // Trigger the newer downloadUrl-based conversion flow.
195
+ async convertV2(options) {
196
+ return this.withOperation({ stage: "converting", message: "Converting file..." }, async () => {
197
+ this.viewer._emit("files:conversion:start", { fileName: options.filename });
198
+ try {
199
+ const prepared = await this.convertV2Internal(options);
200
+ this.viewer._emit("files:conversion:success", prepared);
201
+ return prepared;
202
+ } catch (e) {
203
+ this.viewer._emit("files:conversion:error", { fileName: options.filename, error: this.toErrorMessage(e) });
204
+ throw e;
205
+ }
206
+ });
207
+ }
194
208
  // Open iframe with an already prepared viewer URL.
195
209
  open(input) {
196
210
  const url = input.url;
@@ -247,6 +261,10 @@ var FilesModule = class {
247
261
  const baseUrl = this.resolveBaseUrl();
248
262
  return baseUrl.endsWith("/service/conversion") ? baseUrl : `${baseUrl}/service/conversion`;
249
263
  }
264
+ // Newer convert endpoint is served from the API root, not /service/conversion.
265
+ resolveApiRoot() {
266
+ return this.resolveBaseUrl();
267
+ }
250
268
  // Resolve upload path sent to conversion APIs.
251
269
  getUploadPath() {
252
270
  return this.config.uploadPath || this.viewer.getOptions().uploadPath || ".";
@@ -348,6 +366,26 @@ var FilesModule = class {
348
366
  attemptedConvertTimes: 0
349
367
  };
350
368
  }
369
+ // Build payload for POST /api/StreamFile/convert.
370
+ buildConvertV2Payload(options) {
371
+ var _a, _b;
372
+ const convertOptions = {
373
+ convert3DModel: 1,
374
+ convert2DSheet: 1,
375
+ extractProperties: 1,
376
+ childModels: 0,
377
+ ...options.convertOptions
378
+ };
379
+ return {
380
+ filename: options.filename,
381
+ originalFilePath: options.originalFilePath,
382
+ convertOptions,
383
+ downloadUrl: options.downloadUrl,
384
+ baseFileId: options.baseFileId,
385
+ baseMajorRev: (_a = options.baseMajorRev) != null ? _a : 0,
386
+ baseMinorRev: (_b = options.baseMinorRev) != null ? _b : 0
387
+ };
388
+ }
351
389
  // Submit conversion/caching request and return service response.
352
390
  async cacheFile(file, baseFileId, options = {}) {
353
391
  const hostConversion = await this.resolveHostConversion();
@@ -368,6 +406,34 @@ var FilesModule = class {
368
406
  }
369
407
  return await response.json();
370
408
  }
409
+ // Submit conversion request to the newer downloadUrl-based endpoint.
410
+ async cacheFileV2(options) {
411
+ const apiRoot = await this.resolveApiRoot();
412
+ const params = new URLSearchParams();
413
+ if (typeof options.overwrite === "boolean") {
414
+ params.set("overwrite", String(options.overwrite));
415
+ }
416
+ if (options.project) {
417
+ params.set("project", options.project);
418
+ }
419
+ const query = params.toString();
420
+ const url = `${apiRoot}/api/StreamFile/convert${query ? `?${query}` : ""}`;
421
+ const payload = this.buildConvertV2Payload(options);
422
+ const response = await fetch(url, {
423
+ method: "POST",
424
+ headers: {
425
+ "Content-Type": "application/json",
426
+ Accept: "application/json"
427
+ },
428
+ body: JSON.stringify(payload)
429
+ });
430
+ if (!response.ok) {
431
+ throw new Error(
432
+ `Cache/convert v2 failed (${response.status} ${response.statusText})`
433
+ );
434
+ }
435
+ return await response.json();
436
+ }
371
437
  // Convert file and generate final iframe URL with query string.
372
438
  async convertInternal(file, options = {}) {
373
439
  var _a, _b, _c, _d;
@@ -378,7 +444,7 @@ var FilesModule = class {
378
444
  const baseFileId = (_a = cacheResult.baseFileId) != null ? _a : seedBaseFileId;
379
445
  const baseMajorRev = (_b = cacheResult.baseMajorRev) != null ? _b : 0;
380
446
  const baseMinorRev = (_c = cacheResult.baseMinorRev) != null ? _c : 0;
381
- const fileName = cacheResult.filename || file.name;
447
+ const fileName = cacheResult.filename || cacheResult.fileName || file.name;
382
448
  const cacheListItem = { baseFileId, baseMajorRev, baseMinorRev, fileName };
383
449
  if (cacheResult.cacheStatus !== 2) {
384
450
  throw new Error(`Conversion not ready after first request (cacheStatus=${(_d = cacheResult.cacheStatus) != null ? _d : "unknown"})`);
@@ -389,6 +455,24 @@ var FilesModule = class {
389
455
  const url = `${viewerBase}${viewerPath}?${query}`;
390
456
  return { baseFileId, baseMajorRev, baseMinorRev, fileName, query, url };
391
457
  }
458
+ async convertV2Internal(options) {
459
+ var _a, _b, _c, _d, _e;
460
+ this.updateState({ stage: "converting", message: "Converting file..." });
461
+ const cacheResult = await this.cacheFileV2(options);
462
+ const baseFileId = (_a = cacheResult.baseFileId) != null ? _a : options.baseFileId;
463
+ const baseMajorRev = (_c = (_b = cacheResult.baseMajorRev) != null ? _b : options.baseMajorRev) != null ? _c : 0;
464
+ const baseMinorRev = (_e = (_d = cacheResult.baseMinorRev) != null ? _d : options.baseMinorRev) != null ? _e : 0;
465
+ const fileName = cacheResult.filename || cacheResult.fileName || options.filename;
466
+ if (cacheResult.cacheStatus !== void 0 && cacheResult.cacheStatus !== 2) {
467
+ throw new Error(`Conversion not ready after v2 request (cacheStatus=${cacheResult.cacheStatus})`);
468
+ }
469
+ const cacheListItem = { baseFileId, baseMajorRev, baseMinorRev, fileName };
470
+ const query = new URLSearchParams({ fileList: JSON.stringify([cacheListItem]) }).toString();
471
+ const viewerBase = this.resolveViewerOrigin();
472
+ const viewerPath = this.resolveViewerPath();
473
+ const url = `${viewerBase}${viewerPath}?${query}`;
474
+ return { baseFileId, baseMajorRev, baseMinorRev, fileName, query, url };
475
+ }
392
476
  // Update internal loading state and emit state event.
393
477
  updateState(next) {
394
478
  const elapsedMs = this.operationStartTime > 0 ? Date.now() - this.operationStartTime : 0;
@@ -8,6 +8,23 @@ export declare type FilesConfig = {
8
8
  export declare type ConvertOptions = {
9
9
  downloadUrl?: string;
10
10
  };
11
+ export declare type ConvertV2Options = {
12
+ filename: string;
13
+ originalFilePath: string;
14
+ downloadUrl: string;
15
+ baseFileId: string;
16
+ baseMajorRev?: number;
17
+ baseMinorRev?: number;
18
+ overwrite?: boolean;
19
+ project?: string;
20
+ convertOptions?: Partial<StreamConvertOptions>;
21
+ };
22
+ declare type StreamConvertOptions = {
23
+ convert3DModel: number;
24
+ convert2DSheet: number;
25
+ extractProperties: number;
26
+ childModels: number;
27
+ };
11
28
  export declare class FilesModule {
12
29
  private viewer;
13
30
  on: {
@@ -59,6 +76,7 @@ export declare class FilesModule {
59
76
  }>;
60
77
  convert(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
61
78
  prepare(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
79
+ convertV2(options: ConvertV2Options): Promise<PreparedViewerData>;
62
80
  open(input: PreparedViewerData | {
63
81
  url: string;
64
82
  }): void;
@@ -69,6 +87,7 @@ export declare class FilesModule {
69
87
  private resolveViewerPath;
70
88
  private resolveViewerOrigin;
71
89
  private resolveHostConversion;
90
+ private resolveApiRoot;
72
91
  private getUploadPath;
73
92
  private fileSignature;
74
93
  private createBaseFileId;
@@ -76,9 +95,13 @@ export declare class FilesModule {
76
95
  private getUploadSessionForFile;
77
96
  private uploadInternal;
78
97
  private buildCachePayload;
98
+ private buildConvertV2Payload;
79
99
  private cacheFile;
100
+ private cacheFileV2;
80
101
  private convertInternal;
102
+ private convertV2Internal;
81
103
  private updateState;
82
104
  private withOperation;
83
105
  private toErrorMessage;
84
106
  }
107
+ export {};
@@ -72,6 +72,21 @@ export class FilesModule {
72
72
  return prepared;
73
73
  });
74
74
  }
75
+ // Trigger the newer downloadUrl-based conversion flow.
76
+ async convertV2(options) {
77
+ return this.withOperation({ stage: "converting", message: "Converting file..." }, async () => {
78
+ this.viewer._emit("files:conversion:start", { fileName: options.filename });
79
+ try {
80
+ const prepared = await this.convertV2Internal(options);
81
+ this.viewer._emit("files:conversion:success", prepared);
82
+ return prepared;
83
+ }
84
+ catch (e) {
85
+ this.viewer._emit("files:conversion:error", { fileName: options.filename, error: this.toErrorMessage(e) });
86
+ throw e;
87
+ }
88
+ });
89
+ }
75
90
  // Open iframe with an already prepared viewer URL.
76
91
  open(input) {
77
92
  const url = input.url;
@@ -133,6 +148,10 @@ export class FilesModule {
133
148
  const baseUrl = this.resolveBaseUrl();
134
149
  return baseUrl.endsWith("/service/conversion") ? baseUrl : `${baseUrl}/service/conversion`;
135
150
  }
151
+ // Newer convert endpoint is served from the API root, not /service/conversion.
152
+ resolveApiRoot() {
153
+ return this.resolveBaseUrl();
154
+ }
136
155
  // Resolve upload path sent to conversion APIs.
137
156
  getUploadPath() {
138
157
  return this.config.uploadPath || this.viewer.getOptions().uploadPath || ".";
@@ -239,6 +258,26 @@ export class FilesModule {
239
258
  attemptedConvertTimes: 0,
240
259
  };
241
260
  }
261
+ // Build payload for POST /api/StreamFile/convert.
262
+ buildConvertV2Payload(options) {
263
+ var _a, _b;
264
+ const convertOptions = {
265
+ convert3DModel: 1,
266
+ convert2DSheet: 1,
267
+ extractProperties: 1,
268
+ childModels: 0,
269
+ ...options.convertOptions,
270
+ };
271
+ return {
272
+ filename: options.filename,
273
+ originalFilePath: options.originalFilePath,
274
+ convertOptions,
275
+ downloadUrl: options.downloadUrl,
276
+ baseFileId: options.baseFileId,
277
+ baseMajorRev: (_a = options.baseMajorRev) !== null && _a !== void 0 ? _a : 0,
278
+ baseMinorRev: (_b = options.baseMinorRev) !== null && _b !== void 0 ? _b : 0,
279
+ };
280
+ }
242
281
  // Submit conversion/caching request and return service response.
243
282
  async cacheFile(file, baseFileId, options = {}) {
244
283
  const hostConversion = await this.resolveHostConversion();
@@ -257,6 +296,32 @@ export class FilesModule {
257
296
  }
258
297
  return (await response.json());
259
298
  }
299
+ // Submit conversion request to the newer downloadUrl-based endpoint.
300
+ async cacheFileV2(options) {
301
+ const apiRoot = await this.resolveApiRoot();
302
+ const params = new URLSearchParams();
303
+ if (typeof options.overwrite === "boolean") {
304
+ params.set("overwrite", String(options.overwrite));
305
+ }
306
+ if (options.project) {
307
+ params.set("project", options.project);
308
+ }
309
+ const query = params.toString();
310
+ const url = `${apiRoot}/api/StreamFile/convert${query ? `?${query}` : ""}`;
311
+ const payload = this.buildConvertV2Payload(options);
312
+ const response = await fetch(url, {
313
+ method: "POST",
314
+ headers: {
315
+ "Content-Type": "application/json",
316
+ Accept: "application/json",
317
+ },
318
+ body: JSON.stringify(payload),
319
+ });
320
+ if (!response.ok) {
321
+ throw new Error(`Cache/convert v2 failed (${response.status} ${response.statusText})`);
322
+ }
323
+ return (await response.json());
324
+ }
260
325
  // Convert file and generate final iframe URL with query string.
261
326
  async convertInternal(file, options = {}) {
262
327
  var _a, _b, _c, _d;
@@ -268,7 +333,7 @@ export class FilesModule {
268
333
  const baseFileId = (_a = cacheResult.baseFileId) !== null && _a !== void 0 ? _a : seedBaseFileId;
269
334
  const baseMajorRev = (_b = cacheResult.baseMajorRev) !== null && _b !== void 0 ? _b : 0;
270
335
  const baseMinorRev = (_c = cacheResult.baseMinorRev) !== null && _c !== void 0 ? _c : 0;
271
- const fileName = cacheResult.filename || file.name;
336
+ const fileName = cacheResult.filename || cacheResult.fileName || file.name;
272
337
  const cacheListItem = { baseFileId, baseMajorRev, baseMinorRev, fileName };
273
338
  // Single-shot mode: one conversion request only, no polling retry.
274
339
  if (cacheResult.cacheStatus !== 2) {
@@ -281,6 +346,24 @@ export class FilesModule {
281
346
  const url = `${viewerBase}${viewerPath}?${query}`;
282
347
  return { baseFileId, baseMajorRev, baseMinorRev, fileName, query, url };
283
348
  }
349
+ async convertV2Internal(options) {
350
+ var _a, _b, _c, _d, _e;
351
+ this.updateState({ stage: "converting", message: "Converting file..." });
352
+ const cacheResult = await this.cacheFileV2(options);
353
+ const baseFileId = (_a = cacheResult.baseFileId) !== null && _a !== void 0 ? _a : options.baseFileId;
354
+ const baseMajorRev = (_c = (_b = cacheResult.baseMajorRev) !== null && _b !== void 0 ? _b : options.baseMajorRev) !== null && _c !== void 0 ? _c : 0;
355
+ const baseMinorRev = (_e = (_d = cacheResult.baseMinorRev) !== null && _d !== void 0 ? _d : options.baseMinorRev) !== null && _e !== void 0 ? _e : 0;
356
+ const fileName = cacheResult.filename || cacheResult.fileName || options.filename;
357
+ if (cacheResult.cacheStatus !== undefined && cacheResult.cacheStatus !== 2) {
358
+ throw new Error(`Conversion not ready after v2 request (cacheStatus=${cacheResult.cacheStatus})`);
359
+ }
360
+ const cacheListItem = { baseFileId, baseMajorRev, baseMinorRev, fileName };
361
+ const query = new URLSearchParams({ fileList: JSON.stringify([cacheListItem]) }).toString();
362
+ const viewerBase = this.resolveViewerOrigin();
363
+ const viewerPath = this.resolveViewerPath();
364
+ const url = `${viewerBase}${viewerPath}?${query}`;
365
+ return { baseFileId, baseMajorRev, baseMinorRev, fileName, query, url };
366
+ }
284
367
  // Update internal loading state and emit state event.
285
368
  updateState(next) {
286
369
  const elapsedMs = this.operationStartTime > 0 ? Date.now() - this.operationStartTime : 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3dviewer-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [