@inweb/client 25.3.19 → 25.3.21

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/client.js CHANGED
@@ -170,8 +170,7 @@
170
170
  .then((array) => array.filter(({ custom_fields = {} }) => custom_fields.modelId === this.id || custom_fields.modelName === this.name));
171
171
  }
172
172
  /**
173
- * Add new model viewpoint. To create a new viewpoint use
174
- * {@link Viewer#createViewpoint | Viewer.createViewpoint()}.
173
+ * Add new model viewpoint. To create a new viewpoint use `Viewer.createViewpoint()`.
175
174
  *
176
175
  * _**Note**: Assemblу models do not support viewpoints_.
177
176
  *
@@ -326,12 +325,12 @@
326
325
  });
327
326
  }
328
327
  async function waitFor(func, params = {}) {
329
- var _a, _b, _c, _d, _e;
330
- const timeout = (_a = params.timeout) !== null && _a !== void 0 ? _a : 600000;
331
- const interval = (_b = params.interval) !== null && _b !== void 0 ? _b : 3000;
332
- const signal = (_c = params.signal) !== null && _c !== void 0 ? _c : new AbortController().signal;
333
- const abortError = (_d = params.abortError) !== null && _d !== void 0 ? _d : new DOMException("Aborted", "AbortError");
334
- const timeoutError = (_e = params.timeoutError) !== null && _e !== void 0 ? _e : new DOMException("Timeout", "TimeoutError");
328
+ var _a, _b, _c;
329
+ const timeout = params.timeout || 600000;
330
+ const interval = params.interval || 3000;
331
+ const signal = (_a = params.signal) !== null && _a !== void 0 ? _a : new AbortController().signal;
332
+ const abortError = (_b = params.abortError) !== null && _b !== void 0 ? _b : new DOMException("Aborted", "AbortError");
333
+ const timeoutError = (_c = params.timeoutError) !== null && _c !== void 0 ? _c : new DOMException("Timeout", "TimeoutError");
335
334
  const end = performance.now() + timeout;
336
335
  let count = timeout / interval;
337
336
  do {
@@ -357,7 +356,7 @@
357
356
  .map((x) => x.concat([""]));
358
357
  return Object.fromEntries(argArray);
359
358
  }
360
- return args !== null && args !== void 0 ? args : {};
359
+ return args || {};
361
360
  }
362
361
  function userFullName(firstName, lastName = "", userName = "") {
363
362
  var _a;
@@ -856,8 +855,7 @@
856
855
  }
857
856
  // Reserved for future use
858
857
  get previewUrl() {
859
- var _a;
860
- return (_a = this.data.previewUrl) !== null && _a !== void 0 ? _a : "";
858
+ return this.data.previewUrl || "";
861
859
  }
862
860
  /**
863
861
  * List of assembly related job IDs.
@@ -878,7 +876,7 @@
878
876
  return this.data.status;
879
877
  }
880
878
  /**
881
- * Assembly type. Returns an `assembly`.
879
+ * Assembly type. Returns an `assembly` string.
882
880
  *
883
881
  * @readonly
884
882
  */
@@ -1117,7 +1115,6 @@
1117
1115
  * href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
1118
1116
  * signal object instance, which can be used to abort waiting as desired.
1119
1117
  * @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
1120
- * @returns {Promise<Assembly>}
1121
1118
  */
1122
1119
  waitForDone(params) {
1123
1120
  const checkDone = () => this.checkout().then((assembly) => {
@@ -1265,27 +1262,24 @@
1265
1262
 
1266
1263
  class EventEmitter2 {
1267
1264
  constructor() {
1268
- this._listeners = undefined;
1265
+ this._listeners = {};
1269
1266
  }
1270
1267
  addEventListener(type, listener) {
1271
- if (this._listeners === undefined) this._listeners = {};
1272
1268
  if (this._listeners[type] === undefined) this._listeners[type] = [];
1273
1269
  this._listeners[type].push(listener);
1274
1270
  return this;
1275
1271
  }
1276
1272
  removeEventListener(type, listener) {
1277
- if (this._listeners === undefined) return this;
1278
1273
  if (this._listeners[type] === undefined) return this;
1279
1274
  const listeners = this._listeners[type].filter((x => x !== listener));
1280
- this._listeners[type] = listeners.length === 0 ? undefined : listeners;
1275
+ if (listeners.length !== 0) this._listeners[type] = listeners; else delete this._listeners[type];
1281
1276
  return this;
1282
1277
  }
1283
1278
  removeAllListeners(type) {
1284
- if (type) this._listeners[type] = undefined; else this._listeners = undefined;
1279
+ if (type) delete this._listeners[type]; else this._listeners = {};
1285
1280
  return this;
1286
1281
  }
1287
1282
  emitEvent(event) {
1288
- if (this._listeners === undefined) return false;
1289
1283
  if (this._listeners[event.type] === undefined) return false;
1290
1284
  const invoke = this._listeners[event.type].slice();
1291
1285
  invoke.forEach((listener => listener.call(this, event)));
@@ -1330,7 +1324,7 @@
1330
1324
  function $fetch(url, params = { method: "GET" }) {
1331
1325
  const headers = { ...params.headers };
1332
1326
  delete headers["Content-Type"];
1333
- let body;
1327
+ let body = undefined;
1334
1328
  if (params.method === "POST" || params.method === "PUT") {
1335
1329
  if (params.body instanceof FormData) {
1336
1330
  body = params.body;
@@ -1402,6 +1396,8 @@
1402
1396
  ///////////////////////////////////////////////////////////////////////////////
1403
1397
  class HttpClient {
1404
1398
  constructor(serverUrl) {
1399
+ this.headers = {};
1400
+ this.signInUserId = "";
1405
1401
  this.serverUrl = serverUrl;
1406
1402
  }
1407
1403
  get(relativePath, signal) {
@@ -1450,7 +1446,7 @@
1450
1446
  async downloadFile(relativePath, onProgress, signal) {
1451
1447
  const response = await this.get(relativePath, signal);
1452
1448
  const contentLength = response.headers.get("Content-Length");
1453
- const total = parseInt(contentLength, 10) || 1;
1449
+ const total = parseInt(contentLength || "", 10) || 1;
1454
1450
  return new Response(new ReadableStream({
1455
1451
  async start(controller) {
1456
1452
  const reader = response.body.getReader();
@@ -1473,7 +1469,7 @@
1473
1469
  headers["Range"] = "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(",");
1474
1470
  const response = await $fetch(`${this.serverUrl}${relativePath}`, { method: "GET", headers, signal });
1475
1471
  const contentLength = response.headers.get("content-length");
1476
- const total = parseInt(contentLength, 10) || 1;
1472
+ const total = parseInt(contentLength || "", 10) || 1;
1477
1473
  return new Response(new ReadableStream({
1478
1474
  async start(controller) {
1479
1475
  const reader = response.body.getReader();
@@ -2277,8 +2273,7 @@
2277
2273
  .then((viewpoints) => viewpoints.result);
2278
2274
  }
2279
2275
  /**
2280
- * Add new file viewpoint. To create a new viewpoint use
2281
- * {@link Viewer#createViewpoint | Viewer.createViewpoint()}.
2276
+ * Add new file viewpoint. To create a new viewpoint use `Viewer.createViewpoint()`.
2282
2277
  *
2283
2278
  * @async
2284
2279
  * @param viewpoint - Viewpoint.
@@ -2502,14 +2497,16 @@
2502
2497
  * @returns {Promise<File>}
2503
2498
  */
2504
2499
  waitForDone(jobs, waitAll, params) {
2505
- if (!Array.isArray(jobs))
2506
- jobs = [jobs];
2500
+ const waitJobs = Array.isArray(jobs) ? jobs : [jobs];
2507
2501
  if (waitAll === undefined)
2508
2502
  waitAll = true;
2509
2503
  const checkDone = () => this.checkout().then((file) => {
2510
2504
  var _a;
2511
- const readyJobs = jobs.filter((x) => { var _a, _b; return ["none", "done", "failed"].includes((_b = (_a = file.status[x]) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : "none"); });
2512
- const ready = waitAll ? readyJobs.length === jobs.length : readyJobs.length > 0;
2505
+ const readyJobs = waitJobs.filter((job) => {
2506
+ const jobStatus = file.status[job] || { state: none };
2507
+ return ["none", "done", "failed"].includes(jobStatus.state);
2508
+ });
2509
+ const ready = waitAll ? readyJobs.length === waitJobs.length : readyJobs.length > 0;
2513
2510
  const cancel = (_a = params === null || params === void 0 ? void 0 : params.onCheckout) === null || _a === void 0 ? void 0 : _a.call(params, file, ready);
2514
2511
  return cancel || ready;
2515
2512
  });
@@ -3633,9 +3630,11 @@
3633
3630
  */
3634
3631
  constructor(params = {}) {
3635
3632
  super();
3636
- this.configure(params);
3637
- this.eventEmitter = this;
3633
+ this._serverUrl = "";
3634
+ this._httpClient = new HttpClient("");
3638
3635
  this._user = null;
3636
+ this.eventEmitter = this;
3637
+ this.configure(params);
3639
3638
  }
3640
3639
  /**
3641
3640
  * Open Cloud Server URL. Use {@link Client.configure()} to change server URL.
@@ -3646,7 +3645,7 @@
3646
3645
  return this._serverUrl;
3647
3646
  }
3648
3647
  /**
3649
- * Deprecated since `25.3`. Use {@link Viewer.options()} instead to change Viewer parameters.
3648
+ * Deprecated since `25.3`. Use `Viewer.options()` instead to change Viewer parameters.
3650
3649
  */
3651
3650
  get options() {
3652
3651
  console.warn("Client.options has been deprecated since 25.3 and will be removed in a future release, use Viewer.options instead.");
@@ -3717,7 +3716,7 @@
3717
3716
  .then((data) => ({
3718
3717
  ...data,
3719
3718
  server: data.version,
3720
- client: "25.3.19",
3719
+ client: "25.3.21",
3721
3720
  }));
3722
3721
  }
3723
3722
  /**
@@ -4394,7 +4393,7 @@
4394
4393
  }
4395
4394
 
4396
4395
  ///////////////////////////////////////////////////////////////////////////////
4397
- const version = "25.3.19";
4396
+ const version = "25.3.21";
4398
4397
 
4399
4398
  exports.Assembly = Assembly;
4400
4399
  exports.ClashTest = ClashTest;