@inweb/client 25.3.18 → 25.3.20

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
@@ -243,8 +243,8 @@
243
243
  * ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
244
244
  * and abort it if desired.
245
245
  */
246
- downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
247
- return this._file.downloadResourceRange(dataId, ranges, requestId, onProgress, signal);
246
+ downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
247
+ return this._file.downloadResourceRange(dataId, requestId, ranges, onProgress, signal);
248
248
  }
249
249
  /**
250
250
  * Deprecated since `25.3`. Use {@link Model.downloadResource()} instead.
@@ -274,7 +274,7 @@
274
274
  record.delete();
275
275
  }
276
276
  }
277
- await this.downloadResourceRange(dataId, ranges, requestId, onProgress, signal);
277
+ await this.downloadResourceRange(dataId, requestId, ranges, onProgress, signal);
278
278
  }
279
279
  /**
280
280
  * Returns a list of references to files used to extract geometry data.
@@ -326,12 +326,12 @@
326
326
  });
327
327
  }
328
328
  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");
329
+ var _a, _b, _c;
330
+ const timeout = params.timeout || 600000;
331
+ const interval = params.interval || 3000;
332
+ const signal = (_a = params.signal) !== null && _a !== void 0 ? _a : new AbortController().signal;
333
+ const abortError = (_b = params.abortError) !== null && _b !== void 0 ? _b : new DOMException("Aborted", "AbortError");
334
+ const timeoutError = (_c = params.timeoutError) !== null && _c !== void 0 ? _c : new DOMException("Timeout", "TimeoutError");
335
335
  const end = performance.now() + timeout;
336
336
  let count = timeout / interval;
337
337
  do {
@@ -357,7 +357,7 @@
357
357
  .map((x) => x.concat([""]));
358
358
  return Object.fromEntries(argArray);
359
359
  }
360
- return args !== null && args !== void 0 ? args : {};
360
+ return args || {};
361
361
  }
362
362
  function userFullName(firstName, lastName = "", userName = "") {
363
363
  var _a;
@@ -856,8 +856,7 @@
856
856
  }
857
857
  // Reserved for future use
858
858
  get previewUrl() {
859
- var _a;
860
- return (_a = this.data.previewUrl) !== null && _a !== void 0 ? _a : "";
859
+ return this.data.previewUrl || "";
861
860
  }
862
861
  /**
863
862
  * List of assembly related job IDs.
@@ -1081,10 +1080,10 @@
1081
1080
  * ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
1082
1081
  * and abort it if desired.
1083
1082
  */
1084
- downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
1083
+ downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
1085
1084
  const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
1086
1085
  return this.httpClient
1087
- .downloadFileRange(`${this.path}${relativePath}`, ranges, onProgress, signal)
1086
+ .downloadFileRange(`${this.path}${relativePath}`, requestId, ranges, onProgress, signal)
1088
1087
  .then((response) => response.arrayBuffer());
1089
1088
  }
1090
1089
  /**
@@ -1098,7 +1097,7 @@
1098
1097
  * Deprecated since `25.3`. Use {@link Assembly.downloadResourceRange()} instead.
1099
1098
  */
1100
1099
  async downloadFileRange(requestId, records, dataId, onProgress, signal) {
1101
- await this.downloadResourceRange(dataId, records, requestId, onProgress, signal);
1100
+ await this.downloadResourceRange(dataId, requestId, records, onProgress, signal);
1102
1101
  }
1103
1102
  // Reserved for future use
1104
1103
  getReferences(signal) {
@@ -1117,7 +1116,6 @@
1117
1116
  * href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
1118
1117
  * signal object instance, which can be used to abort waiting as desired.
1119
1118
  * @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
1120
- * @returns {Promise<Assembly>}
1121
1119
  */
1122
1120
  waitForDone(params) {
1123
1121
  const checkDone = () => this.checkout().then((assembly) => {
@@ -1265,27 +1263,24 @@
1265
1263
 
1266
1264
  class EventEmitter2 {
1267
1265
  constructor() {
1268
- this._listeners = undefined;
1266
+ this._listeners = {};
1269
1267
  }
1270
1268
  addEventListener(type, listener) {
1271
- if (this._listeners === undefined) this._listeners = {};
1272
1269
  if (this._listeners[type] === undefined) this._listeners[type] = [];
1273
1270
  this._listeners[type].push(listener);
1274
1271
  return this;
1275
1272
  }
1276
1273
  removeEventListener(type, listener) {
1277
- if (this._listeners === undefined) return this;
1278
1274
  if (this._listeners[type] === undefined) return this;
1279
1275
  const listeners = this._listeners[type].filter((x => x !== listener));
1280
- this._listeners[type] = listeners.length === 0 ? undefined : listeners;
1276
+ if (listeners.length !== 0) this._listeners[type] = listeners; else delete this._listeners[type];
1281
1277
  return this;
1282
1278
  }
1283
1279
  removeAllListeners(type) {
1284
- if (type) this._listeners[type] = undefined; else this._listeners = undefined;
1280
+ if (type) delete this._listeners[type]; else this._listeners = {};
1285
1281
  return this;
1286
1282
  }
1287
1283
  emitEvent(event) {
1288
- if (this._listeners === undefined) return false;
1289
1284
  if (this._listeners[event.type] === undefined) return false;
1290
1285
  const invoke = this._listeners[event.type].slice();
1291
1286
  invoke.forEach((listener => listener.call(this, event)));
@@ -1330,7 +1325,7 @@
1330
1325
  function $fetch(url, params = { method: "GET" }) {
1331
1326
  const headers = { ...params.headers };
1332
1327
  delete headers["Content-Type"];
1333
- let body;
1328
+ let body = undefined;
1334
1329
  if (params.method === "POST" || params.method === "PUT") {
1335
1330
  if (params.body instanceof FormData) {
1336
1331
  body = params.body;
@@ -1402,6 +1397,8 @@
1402
1397
  ///////////////////////////////////////////////////////////////////////////////
1403
1398
  class HttpClient {
1404
1399
  constructor(serverUrl) {
1400
+ this.headers = {};
1401
+ this.signInUserId = "";
1405
1402
  this.serverUrl = serverUrl;
1406
1403
  }
1407
1404
  get(relativePath, signal) {
@@ -1450,7 +1447,7 @@
1450
1447
  async downloadFile(relativePath, onProgress, signal) {
1451
1448
  const response = await this.get(relativePath, signal);
1452
1449
  const contentLength = response.headers.get("Content-Length");
1453
- const total = parseInt(contentLength, 10) || 1;
1450
+ const total = parseInt(contentLength || "", 10) || 1;
1454
1451
  return new Response(new ReadableStream({
1455
1452
  async start(controller) {
1456
1453
  const reader = response.body.getReader();
@@ -1468,12 +1465,12 @@
1468
1465
  },
1469
1466
  }));
1470
1467
  }
1471
- async downloadFileRange(relativePath, ranges, onProgress, signal) {
1468
+ async downloadFileRange(relativePath, requestId, ranges, onProgress, signal) {
1472
1469
  const headers = { ...this.headers };
1473
1470
  headers["Range"] = "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(",");
1474
1471
  const response = await $fetch(`${this.serverUrl}${relativePath}`, { method: "GET", headers, signal });
1475
1472
  const contentLength = response.headers.get("content-length");
1476
- const total = parseInt(contentLength, 10) || 1;
1473
+ const total = parseInt(contentLength || "", 10) || 1;
1477
1474
  return new Response(new ReadableStream({
1478
1475
  async start(controller) {
1479
1476
  const reader = response.body.getReader();
@@ -2369,10 +2366,10 @@
2369
2366
  * ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
2370
2367
  * and abort it if desired.
2371
2368
  */
2372
- downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
2369
+ downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
2373
2370
  const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
2374
2371
  return this.httpClient
2375
- .downloadFileRange(`${this.path}${relativePath}`, ranges, onProgress, signal)
2372
+ .downloadFileRange(`${this.path}${relativePath}`, requestId, ranges, onProgress, signal)
2376
2373
  .then((response) => response.arrayBuffer());
2377
2374
  }
2378
2375
  /**
@@ -2386,7 +2383,7 @@
2386
2383
  * Deprecated since `25.3`. Use {@link File.downloadResourceRange()} instead.
2387
2384
  */
2388
2385
  async downloadFileRange(requestId, records, dataId, onProgress, signal) {
2389
- await this.downloadResourceRange(dataId, records, requestId, onProgress, signal);
2386
+ await this.downloadResourceRange(dataId, requestId, records, onProgress, signal);
2390
2387
  }
2391
2388
  /**
2392
2389
  * Returns a list of references to files used to correct rendering of the current file.
@@ -2508,7 +2505,7 @@
2508
2505
  waitAll = true;
2509
2506
  const checkDone = () => this.checkout().then((file) => {
2510
2507
  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"); });
2508
+ const readyJobs = jobs.filter((x) => { var _a; return ["none", "done", "failed"].includes(((_a = file.status[x]) === null || _a === void 0 ? void 0 : _a.state) || "none"); });
2512
2509
  const ready = waitAll ? readyJobs.length === jobs.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;
@@ -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.
@@ -3717,7 +3716,7 @@
3717
3716
  .then((data) => ({
3718
3717
  ...data,
3719
3718
  server: data.version,
3720
- client: "25.3.18",
3719
+ client: "25.3.20",
3721
3720
  }));
3722
3721
  }
3723
3722
  /**
@@ -4394,7 +4393,7 @@
4394
4393
  }
4395
4394
 
4396
4395
  ///////////////////////////////////////////////////////////////////////////////
4397
- const version = "25.3.18";
4396
+ const version = "25.3.20";
4398
4397
 
4399
4398
  exports.Assembly = Assembly;
4400
4399
  exports.ClashTest = ClashTest;