3dviewer-sdk 1.0.13 → 1.0.15
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +18 -21
- package/dist/index.mjs +18 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -270,6 +270,7 @@ declare class NodeModule {
|
|
|
270
270
|
|
|
271
271
|
type FilesConfig = {
|
|
272
272
|
baseUrl?: string;
|
|
273
|
+
conversionUrl?: string;
|
|
273
274
|
viewerPath?: string;
|
|
274
275
|
uploadPath?: string;
|
|
275
276
|
};
|
|
@@ -280,6 +281,8 @@ type ConvertV2Options = {
|
|
|
280
281
|
filename: string;
|
|
281
282
|
originalFilePath: string;
|
|
282
283
|
downloadUrl: string;
|
|
284
|
+
workflowId: string;
|
|
285
|
+
taskId: string;
|
|
283
286
|
baseFileId: string;
|
|
284
287
|
baseMajorRev?: number;
|
|
285
288
|
baseMinorRev?: number;
|
|
@@ -356,7 +359,7 @@ declare class FilesModule {
|
|
|
356
359
|
render(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
357
360
|
private resolveFile;
|
|
358
361
|
private normalizeBaseUrl;
|
|
359
|
-
private
|
|
362
|
+
private resolveConversionUrl;
|
|
360
363
|
private resolveViewerPath;
|
|
361
364
|
private normalizeSdkViewerPath;
|
|
362
365
|
private resolveViewerOrigin;
|
|
@@ -522,6 +525,7 @@ type Viewer3DOptions = {
|
|
|
522
525
|
container: HTMLElement | string;
|
|
523
526
|
url?: string;
|
|
524
527
|
baseUrl?: string;
|
|
528
|
+
conversionUrl?: string;
|
|
525
529
|
viewerPath?: string;
|
|
526
530
|
uploadPath?: string;
|
|
527
531
|
file?: File;
|
package/dist/index.d.ts
CHANGED
|
@@ -270,6 +270,7 @@ declare class NodeModule {
|
|
|
270
270
|
|
|
271
271
|
type FilesConfig = {
|
|
272
272
|
baseUrl?: string;
|
|
273
|
+
conversionUrl?: string;
|
|
273
274
|
viewerPath?: string;
|
|
274
275
|
uploadPath?: string;
|
|
275
276
|
};
|
|
@@ -280,6 +281,8 @@ type ConvertV2Options = {
|
|
|
280
281
|
filename: string;
|
|
281
282
|
originalFilePath: string;
|
|
282
283
|
downloadUrl: string;
|
|
284
|
+
workflowId: string;
|
|
285
|
+
taskId: string;
|
|
283
286
|
baseFileId: string;
|
|
284
287
|
baseMajorRev?: number;
|
|
285
288
|
baseMinorRev?: number;
|
|
@@ -356,7 +359,7 @@ declare class FilesModule {
|
|
|
356
359
|
render(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
357
360
|
private resolveFile;
|
|
358
361
|
private normalizeBaseUrl;
|
|
359
|
-
private
|
|
362
|
+
private resolveConversionUrl;
|
|
360
363
|
private resolveViewerPath;
|
|
361
364
|
private normalizeSdkViewerPath;
|
|
362
365
|
private resolveViewerOrigin;
|
|
@@ -522,6 +525,7 @@ type Viewer3DOptions = {
|
|
|
522
525
|
container: HTMLElement | string;
|
|
523
526
|
url?: string;
|
|
524
527
|
baseUrl?: string;
|
|
528
|
+
conversionUrl?: string;
|
|
525
529
|
viewerPath?: string;
|
|
526
530
|
uploadPath?: string;
|
|
527
531
|
file?: File;
|
package/dist/index.js
CHANGED
|
@@ -145,8 +145,8 @@ var NodeModule = class {
|
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
// src/modules/files.module.ts
|
|
148
|
-
var
|
|
149
|
-
var
|
|
148
|
+
var DEFAULT_CONVERSION_URL = "https://dev.3dviewer.anybim.vn/service/conversion";
|
|
149
|
+
var DEFAULT_VIEWER_BASE_URL = "https://dev.3dviewer.anybim.vn";
|
|
150
150
|
var SDK_VIEWER_PATH = "/mainviewer-sdk";
|
|
151
151
|
var LEGACY_VIEWER_PATH = "/mainviewer";
|
|
152
152
|
var FilesModule = class {
|
|
@@ -293,9 +293,9 @@ var FilesModule = class {
|
|
|
293
293
|
normalizeBaseUrl(input) {
|
|
294
294
|
return input.trim().replace(/\/+$/, "");
|
|
295
295
|
}
|
|
296
|
-
// Resolve API
|
|
297
|
-
|
|
298
|
-
const raw = this.config.
|
|
296
|
+
// Resolve conversion API URL with default fallback.
|
|
297
|
+
resolveConversionUrl() {
|
|
298
|
+
const raw = this.config.conversionUrl || this.viewer.getOptions().conversionUrl || DEFAULT_CONVERSION_URL;
|
|
299
299
|
return this.normalizeBaseUrl(raw);
|
|
300
300
|
}
|
|
301
301
|
// Resolve viewer route path for all SDK flows.
|
|
@@ -321,31 +321,26 @@ var FilesModule = class {
|
|
|
321
321
|
}
|
|
322
322
|
// Viewer host used to open iframe after conversion completes.
|
|
323
323
|
resolveViewerOrigin() {
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
324
|
+
const configuredViewerBaseUrl = this.config.baseUrl || this.viewer.getOptions().baseUrl;
|
|
325
|
+
if (configuredViewerBaseUrl) {
|
|
326
326
|
try {
|
|
327
|
-
return this.normalizeBaseUrl(new URL(
|
|
327
|
+
return this.normalizeBaseUrl(new URL(configuredViewerBaseUrl, window.location.href).origin);
|
|
328
328
|
} catch {
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
331
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
332
|
+
if (viewerUrl) {
|
|
333
333
|
try {
|
|
334
|
-
return this.normalizeBaseUrl(new URL(
|
|
334
|
+
return this.normalizeBaseUrl(new URL(viewerUrl, window.location.href).origin);
|
|
335
335
|
} catch {
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
return this.normalizeBaseUrl(
|
|
338
|
+
return this.normalizeBaseUrl(DEFAULT_VIEWER_BASE_URL);
|
|
339
339
|
}
|
|
340
|
-
//
|
|
340
|
+
// Resolve conversion service root from configured conversion URL.
|
|
341
|
+
// Do not auto-append path segments (e.g. "/service/conversion").
|
|
341
342
|
resolveHostConversion() {
|
|
342
|
-
|
|
343
|
-
try {
|
|
344
|
-
const parsed = new URL(baseUrl, window.location.href);
|
|
345
|
-
if (parsed.hostname.includes("conversion")) return baseUrl;
|
|
346
|
-
} catch {
|
|
347
|
-
}
|
|
348
|
-
return baseUrl.endsWith("/service/conversion") ? baseUrl : `${baseUrl}/service/conversion`;
|
|
343
|
+
return this.resolveConversionUrl();
|
|
349
344
|
}
|
|
350
345
|
// Resolve upload path sent to conversion APIs.
|
|
351
346
|
getUploadPath() {
|
|
@@ -463,6 +458,8 @@ var FilesModule = class {
|
|
|
463
458
|
originalFilePath: options.originalFilePath,
|
|
464
459
|
convertOptions,
|
|
465
460
|
downloadUrl: options.downloadUrl,
|
|
461
|
+
workflowId: options.workflowId,
|
|
462
|
+
taskId: options.taskId,
|
|
466
463
|
baseFileId: options.baseFileId,
|
|
467
464
|
baseMajorRev: (_a = options.baseMajorRev) != null ? _a : 0,
|
|
468
465
|
baseMinorRev: (_b = options.baseMinorRev) != null ? _b : 0
|
|
@@ -506,7 +503,7 @@ var FilesModule = class {
|
|
|
506
503
|
params.set("project", options.project);
|
|
507
504
|
}
|
|
508
505
|
const query = params.toString();
|
|
509
|
-
const url = `${hostConversion}/api/StreamFile${query ? `?${query}` : ""}`;
|
|
506
|
+
const url = `${hostConversion}/api/StreamFile/convert${query ? `?${query}` : ""}`;
|
|
510
507
|
const payload = this.buildConvertV2Payload(options);
|
|
511
508
|
const response = await fetch(url, {
|
|
512
509
|
method: "POST",
|
package/dist/index.mjs
CHANGED
|
@@ -119,8 +119,8 @@ var NodeModule = class {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
// src/modules/files.module.ts
|
|
122
|
-
var
|
|
123
|
-
var
|
|
122
|
+
var DEFAULT_CONVERSION_URL = "https://dev.3dviewer.anybim.vn/service/conversion";
|
|
123
|
+
var DEFAULT_VIEWER_BASE_URL = "https://dev.3dviewer.anybim.vn";
|
|
124
124
|
var SDK_VIEWER_PATH = "/mainviewer-sdk";
|
|
125
125
|
var LEGACY_VIEWER_PATH = "/mainviewer";
|
|
126
126
|
var FilesModule = class {
|
|
@@ -267,9 +267,9 @@ var FilesModule = class {
|
|
|
267
267
|
normalizeBaseUrl(input) {
|
|
268
268
|
return input.trim().replace(/\/+$/, "");
|
|
269
269
|
}
|
|
270
|
-
// Resolve API
|
|
271
|
-
|
|
272
|
-
const raw = this.config.
|
|
270
|
+
// Resolve conversion API URL with default fallback.
|
|
271
|
+
resolveConversionUrl() {
|
|
272
|
+
const raw = this.config.conversionUrl || this.viewer.getOptions().conversionUrl || DEFAULT_CONVERSION_URL;
|
|
273
273
|
return this.normalizeBaseUrl(raw);
|
|
274
274
|
}
|
|
275
275
|
// Resolve viewer route path for all SDK flows.
|
|
@@ -295,31 +295,26 @@ var FilesModule = class {
|
|
|
295
295
|
}
|
|
296
296
|
// Viewer host used to open iframe after conversion completes.
|
|
297
297
|
resolveViewerOrigin() {
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
298
|
+
const configuredViewerBaseUrl = this.config.baseUrl || this.viewer.getOptions().baseUrl;
|
|
299
|
+
if (configuredViewerBaseUrl) {
|
|
300
300
|
try {
|
|
301
|
-
return this.normalizeBaseUrl(new URL(
|
|
301
|
+
return this.normalizeBaseUrl(new URL(configuredViewerBaseUrl, window.location.href).origin);
|
|
302
302
|
} catch {
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
305
|
+
const viewerUrl = this.viewer.getOptions().url;
|
|
306
|
+
if (viewerUrl) {
|
|
307
307
|
try {
|
|
308
|
-
return this.normalizeBaseUrl(new URL(
|
|
308
|
+
return this.normalizeBaseUrl(new URL(viewerUrl, window.location.href).origin);
|
|
309
309
|
} catch {
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
return this.normalizeBaseUrl(
|
|
312
|
+
return this.normalizeBaseUrl(DEFAULT_VIEWER_BASE_URL);
|
|
313
313
|
}
|
|
314
|
-
//
|
|
314
|
+
// Resolve conversion service root from configured conversion URL.
|
|
315
|
+
// Do not auto-append path segments (e.g. "/service/conversion").
|
|
315
316
|
resolveHostConversion() {
|
|
316
|
-
|
|
317
|
-
try {
|
|
318
|
-
const parsed = new URL(baseUrl, window.location.href);
|
|
319
|
-
if (parsed.hostname.includes("conversion")) return baseUrl;
|
|
320
|
-
} catch {
|
|
321
|
-
}
|
|
322
|
-
return baseUrl.endsWith("/service/conversion") ? baseUrl : `${baseUrl}/service/conversion`;
|
|
317
|
+
return this.resolveConversionUrl();
|
|
323
318
|
}
|
|
324
319
|
// Resolve upload path sent to conversion APIs.
|
|
325
320
|
getUploadPath() {
|
|
@@ -437,6 +432,8 @@ var FilesModule = class {
|
|
|
437
432
|
originalFilePath: options.originalFilePath,
|
|
438
433
|
convertOptions,
|
|
439
434
|
downloadUrl: options.downloadUrl,
|
|
435
|
+
workflowId: options.workflowId,
|
|
436
|
+
taskId: options.taskId,
|
|
440
437
|
baseFileId: options.baseFileId,
|
|
441
438
|
baseMajorRev: (_a = options.baseMajorRev) != null ? _a : 0,
|
|
442
439
|
baseMinorRev: (_b = options.baseMinorRev) != null ? _b : 0
|
|
@@ -480,7 +477,7 @@ var FilesModule = class {
|
|
|
480
477
|
params.set("project", options.project);
|
|
481
478
|
}
|
|
482
479
|
const query = params.toString();
|
|
483
|
-
const url = `${hostConversion}/api/StreamFile${query ? `?${query}` : ""}`;
|
|
480
|
+
const url = `${hostConversion}/api/StreamFile/convert${query ? `?${query}` : ""}`;
|
|
484
481
|
const payload = this.buildConvertV2Payload(options);
|
|
485
482
|
const response = await fetch(url, {
|
|
486
483
|
method: "POST",
|