core-3nweb-client-lib 0.53.10 → 0.53.12

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.
@@ -510,10 +510,10 @@ class ObjStatus {
510
510
  }
511
511
  async adoptRemoteVersion(version) {
512
512
  var _a, _b;
513
- if (((_a = this.upload) === null || _a === void 0 ? void 0 : _a.type) === 'removal') {
513
+ if (((_a = this.status.upload) === null || _a === void 0 ? void 0 : _a.type) === 'removal') {
514
514
  // uploads should have be cancelled before this is called (need a check),
515
515
  // yet, outstanding removal was noted
516
- this.upload == undefined;
516
+ this.status.upload = undefined;
517
517
  }
518
518
  const { local, remote } = this.status;
519
519
  if (this.stateIndicator !== 'behind') {
@@ -21,6 +21,7 @@ const rxjs_1 = require("rxjs");
21
21
  const owner_1 = require("../../../lib-common/service-api/3nstorage/owner");
22
22
  const operators_1 = require("rxjs/operators");
23
23
  const ws_ipc_1 = require("../../../lib-common/ipc/ws-ipc");
24
+ const utils_1 = require("../common/utils");
24
25
  function toStorageConnectionStatus(status, params) {
25
26
  return (0, ws_ipc_1.addToStatus)(status, {
26
27
  service: 'storage',
@@ -95,7 +96,7 @@ class RemoteEvents {
95
96
  if (!((_a = syncStatus.synced) === null || _a === void 0 ? void 0 : _a.latest) || (syncStatus.synced.latest >= newRemoteVersion)) {
96
97
  return;
97
98
  }
98
- obj.statusObj().recordRemoteChange(newRemoteVersion);
99
+ obj.statusObj().recordRemoteChange(newRemoteVersion).catch(utils_1.noop);
99
100
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
100
101
  type: 'remote-change',
101
102
  path: '',
@@ -111,7 +112,7 @@ class RemoteEvents {
111
112
  if (!obj) {
112
113
  return;
113
114
  }
114
- obj.statusObj().recordRemoteRemoval();
115
+ obj.statusObj().recordRemoteRemoval().catch(utils_1.noop);
115
116
  this.broadcastNodeEvent(obj.objId, undefined, undefined, {
116
117
  type: 'remote-removal',
117
118
  path: '',
@@ -344,9 +344,13 @@ class UploadTask {
344
344
  upload.newSegsLeft.splice(0, 1);
345
345
  }
346
346
  }
347
- cancel() {
348
- // XXX
349
- throw new Error("UploadTask.cancel() not implemented.");
347
+ async cancel() {
348
+ var _a;
349
+ const transactionId = (_a = this.info.needUpload) === null || _a === void 0 ? void 0 : _a.transactionId;
350
+ if (transactionId) {
351
+ await this.remoteStorage.cancelTransaction(this.objId, transactionId).catch(noop);
352
+ }
353
+ await this.objStatus.recordUploadCancellation(this.info).catch(noop);
350
354
  }
351
355
  }
352
356
  Object.freeze(UploadTask.prototype);
@@ -17,7 +17,7 @@ export interface NetworkFns {
17
17
  openServiceEventsSource: OpenServiceEventsSource;
18
18
  }
19
19
  export interface RegularNetworkFns extends NetworkFns {
20
- naming: DnsResolver[];
20
+ naming: () => DnsResolver[];
21
21
  }
22
22
  export declare function wrapNetworkFns(impls: {
23
23
  regular: RegularNetworkFns;
@@ -154,7 +154,7 @@ function makeMissingImplementationException(networkType, location) {
154
154
  }
155
155
  function wrapNetworkFns(impls) {
156
156
  const { regular, i2p, onion, resetConnectivity } = impls;
157
- const locateInDNS = makeServiceLocatorInDNS(...regular.naming);
157
+ const locateInDNS = makeServiceLocatorInDNS(regular.naming);
158
158
  const locationRequesterInOnion = (onion ?
159
159
  (0, request_utils_1.makeNetClient)(onion.requests, undefined).doBodylessRequest : undefined);
160
160
  const locationRequesterInI2P = (i2p ?
@@ -217,14 +217,15 @@ function wrapNetworkFns(impls) {
217
217
  }
218
218
  return { makeLocator, makeNet };
219
219
  }
220
- function makeServiceLocatorInDNS(...resolvers) {
221
- if (resolvers.length === 0) {
220
+ function makeServiceLocatorInDNS(getResolvers) {
221
+ if (getResolvers().length === 0) {
222
222
  throw Error(`no DNS resolvers given`);
223
223
  }
224
224
  async function locateInDNS(address, serviceLabel, logError) {
225
225
  const domain = domainOfAddress(address);
226
226
  let exc = undefined;
227
227
  let connectionExc = undefined;
228
+ const resolvers = getResolvers();
228
229
  for (let i = 0; i < resolvers.length; i += 1) {
229
230
  const resolver = resolvers[i];
230
231
  let txtRecords;
@@ -843,7 +843,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
843
843
  if (removedNodes.length > 0) {
844
844
  // start upload of children's removal after folder's upload;
845
845
  // we also don't await for chidren removal in returned completion
846
- completion.then(() => this.uploadRemovalOf(removedNodes));
846
+ completion.then(() => this.uploadRemovalOf(removedNodes)).catch(noop);
847
847
  }
848
848
  return {
849
849
  completion: completion.catch(exc => {
@@ -74,7 +74,7 @@ function resolveTxt(domain) {
74
74
  }));
75
75
  }
76
76
  const { makeLocator, makeNet } = (0, networks_1.wrapNetworkFns)({ regular: {
77
- naming: [{ resolveTxt }],
77
+ naming: () => [{ resolveTxt }],
78
78
  openServiceEventsSource: (0, websocket_from_node_1.makeServiceEventsSourceFromNode)(),
79
79
  requests: (0, request_from_node_1.makeRequestFromNode)()
80
80
  } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.53.10",
3
+ "version": "0.53.12",
4
4
  "description": "3NWeb client core library, embeddable into different environments",
5
5
  "main": "build/lib-index.js",
6
6
  "types": "build/lib-index.d.ts",