core-3nweb-client-lib 0.26.0 → 0.27.1

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.
Files changed (199) hide show
  1. package/build/api-defs/asmail.d.ts +1 -1
  2. package/build/api-defs/files.d.ts +278 -69
  3. package/build/core/app-files.js +7 -7
  4. package/build/core/asmail/config/common.js +2 -2
  5. package/build/core/asmail/config/index.js +2 -2
  6. package/build/core/asmail/config/published-intro-key.js +1 -1
  7. package/build/core/asmail/delivery/common.js +7 -7
  8. package/build/core/asmail/delivery/index.js +5 -5
  9. package/build/core/asmail/delivery/msg.js +4 -4
  10. package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
  11. package/build/core/asmail/inbox/attachments/fs.js +5 -1
  12. package/build/core/asmail/inbox/cached-msgs.js +1 -1
  13. package/build/core/asmail/inbox/inbox-events.js +4 -4
  14. package/build/core/asmail/inbox/index.js +10 -10
  15. package/build/core/asmail/inbox/msg-downloader.js +1 -1
  16. package/build/core/asmail/inbox/msg-indexing.js +1 -1
  17. package/build/core/asmail/inbox/msg-on-disk.js +5 -5
  18. package/build/core/asmail/index.d.ts +3 -3
  19. package/build/core/asmail/index.js +13 -8
  20. package/build/core/asmail/key-verification.js +5 -5
  21. package/build/core/asmail/keyring/common.js +7 -6
  22. package/build/core/asmail/keyring/correspondent-keys.js +8 -7
  23. package/build/core/asmail/keyring/id-to-email-map.js +2 -1
  24. package/build/core/asmail/keyring/index.d.ts +7 -8
  25. package/build/core/asmail/keyring/index.js +15 -14
  26. package/build/core/asmail/keyring/keyring-storage.js +2 -1
  27. package/build/core/asmail/msg/opener.js +3 -3
  28. package/build/core/asmail/msg/packer.js +13 -13
  29. package/build/core/asmail/sending-params/own-params.js +2 -2
  30. package/build/core/asmail/sending-params/params-from-others.js +1 -1
  31. package/build/core/id-manager.js +6 -3
  32. package/build/core/index.d.ts +2 -1
  33. package/build/core/index.js +14 -14
  34. package/build/core/sign-in.js +5 -5
  35. package/build/core/sign-up.js +9 -9
  36. package/build/core/storage/common/json-saving.js +2 -2
  37. package/build/core/storage/common/obj-info-file.d.ts +12 -4
  38. package/build/core/storage/common/obj-info-file.js +66 -34
  39. package/build/core/storage/common/utils.d.ts +2 -0
  40. package/build/core/storage/common/utils.js +32 -0
  41. package/build/core/storage/index.d.ts +3 -17
  42. package/build/core/storage/index.js +56 -76
  43. package/build/core/storage/local/obj-files-gc.d.ts +2 -0
  44. package/build/core/storage/local/obj-files-gc.js +49 -37
  45. package/build/core/storage/local/obj-files.d.ts +4 -7
  46. package/build/core/storage/local/obj-files.js +7 -10
  47. package/build/core/storage/local/obj-status.d.ts +12 -6
  48. package/build/core/storage/local/obj-status.js +24 -9
  49. package/build/core/storage/local/storage.d.ts +9 -6
  50. package/build/core/storage/local/storage.js +29 -18
  51. package/build/core/storage/synced/downloader.js +1 -1
  52. package/build/core/storage/synced/obj-files-gc.d.ts +5 -1
  53. package/build/core/storage/synced/obj-files-gc.js +91 -37
  54. package/build/core/storage/synced/obj-files.d.ts +42 -36
  55. package/build/core/storage/synced/obj-files.js +178 -147
  56. package/build/core/storage/synced/obj-status.d.ts +87 -85
  57. package/build/core/storage/synced/obj-status.js +463 -259
  58. package/build/core/storage/synced/remote-events.d.ts +11 -12
  59. package/build/core/storage/synced/remote-events.js +73 -56
  60. package/build/core/storage/synced/storage.d.ts +18 -9
  61. package/build/core/storage/synced/storage.js +108 -48
  62. package/build/core/storage/synced/upload-header-file.d.ts +4 -0
  63. package/build/core/storage/synced/upload-header-file.js +64 -0
  64. package/build/core/storage/synced/upsyncer.d.ts +12 -7
  65. package/build/core/storage/synced/upsyncer.js +204 -280
  66. package/build/core/storage/system-folders/apps-data.d.ts +16 -0
  67. package/build/core/storage/system-folders/apps-data.js +110 -0
  68. package/build/core/storage/system-folders/index.d.ts +18 -0
  69. package/build/core/storage/system-folders/index.js +77 -0
  70. package/build/core-ipc/common-caps.js +3 -3
  71. package/build/core-ipc/generic.js +8 -8
  72. package/build/core-ipc/startup-caps.js +2 -2
  73. package/build/cryptors.js +6 -2
  74. package/build/ipc-via-protobuf/asmail-cap.js +58 -57
  75. package/build/ipc-via-protobuf/bytes.js +16 -17
  76. package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -0
  77. package/build/ipc-via-protobuf/connector-clients-side.js +61 -24
  78. package/build/ipc-via-protobuf/connector-services-side.js +10 -10
  79. package/build/ipc-via-protobuf/connector.js +4 -4
  80. package/build/ipc-via-protobuf/file.d.ts +48 -12
  81. package/build/ipc-via-protobuf/file.js +474 -126
  82. package/build/ipc-via-protobuf/fs.d.ts +8 -0
  83. package/build/ipc-via-protobuf/fs.js +577 -142
  84. package/build/ipc-via-protobuf/log-cap.js +2 -2
  85. package/build/ipc-via-protobuf/mailerid.js +3 -3
  86. package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
  87. package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
  88. package/build/ipc-via-protobuf/startup-cap.js +21 -21
  89. package/build/ipc-via-protobuf/storage-cap.js +12 -12
  90. package/build/ipc.js +7 -2
  91. package/build/lib-client/3nstorage/exceptions.d.ts +3 -0
  92. package/build/lib-client/3nstorage/exceptions.js +13 -1
  93. package/build/lib-client/3nstorage/service.d.ts +15 -2
  94. package/build/lib-client/3nstorage/service.js +104 -38
  95. package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
  96. package/build/lib-client/3nstorage/util/file-based-json.js +1 -1
  97. package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
  98. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +42 -18
  99. package/build/lib-client/3nstorage/xsp-fs/common.js +29 -19
  100. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
  101. package/build/lib-client/3nstorage/xsp-fs/file-node.js +17 -13
  102. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
  103. package/build/lib-client/3nstorage/xsp-fs/file.js +73 -25
  104. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
  105. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +24 -11
  106. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +575 -179
  107. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
  108. package/build/lib-client/3nstorage/xsp-fs/fs.js +231 -110
  109. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
  110. package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
  111. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -24
  112. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +229 -123
  113. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
  114. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +17 -18
  115. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -3
  116. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +53 -53
  117. package/build/lib-client/3nweb-signup.js +4 -4
  118. package/build/lib-client/asmail/recipient.js +15 -15
  119. package/build/lib-client/asmail/sender.js +22 -22
  120. package/build/lib-client/asmail/service-config.js +3 -3
  121. package/build/lib-client/cryptor/cryptor-in-worker.js +18 -16
  122. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  123. package/build/lib-client/cryptor/cryptor.js +4 -2
  124. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  125. package/build/lib-client/cryptor/in-proc-js.js +1 -1
  126. package/build/lib-client/cryptor/in-proc-wasm.js +6 -6
  127. package/build/lib-client/cryptor/worker-js.js +2 -2
  128. package/build/lib-client/cryptor/worker-wasm.js +2 -2
  129. package/build/lib-client/files-select.js +1 -1
  130. package/build/lib-client/files.d.ts +1 -1
  131. package/build/lib-client/files.js +71 -6
  132. package/build/lib-client/fs-collection.js +1 -1
  133. package/build/lib-client/fs-sync-utils.d.ts +5 -0
  134. package/build/lib-client/fs-sync-utils.js +61 -0
  135. package/build/lib-client/fs-view.d.ts +14 -0
  136. package/build/lib-client/fs-view.js +33 -0
  137. package/build/lib-client/key-derivation.js +1 -1
  138. package/build/lib-client/local-files/dev-file-sink.js +9 -9
  139. package/build/lib-client/local-files/dev-file-src.js +2 -2
  140. package/build/lib-client/local-files/device-fs.d.ts +1 -1
  141. package/build/lib-client/local-files/device-fs.js +56 -54
  142. package/build/lib-client/logging/log-to-file.d.ts +1 -1
  143. package/build/lib-client/logging/log-to-file.js +7 -7
  144. package/build/lib-client/mailer-id/login.js +7 -7
  145. package/build/lib-client/mailer-id/provisioner.js +12 -12
  146. package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -3
  147. package/build/lib-client/objs-on-disk/obj-folders.js +31 -31
  148. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
  149. package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
  150. package/build/lib-client/request-utils.d.ts +1 -0
  151. package/build/lib-client/request-utils.js +13 -13
  152. package/build/lib-client/server-events.d.ts +3 -3
  153. package/build/lib-client/server-events.js +9 -8
  154. package/build/lib-client/service-locator.js +10 -10
  155. package/build/lib-client/user-with-mid-session.js +7 -7
  156. package/build/lib-client/user-with-pkl-session.js +25 -25
  157. package/build/lib-client/ws-utils.js +2 -2
  158. package/build/lib-common/async-cryptor-wrap.js +4 -4
  159. package/build/lib-common/async-fs-node.d.ts +5 -3
  160. package/build/lib-common/async-fs-node.js +16 -16
  161. package/build/lib-common/byte-streaming/pipe.js +1 -1
  162. package/build/lib-common/byte-streaming/wrapping.js +13 -13
  163. package/build/lib-common/canonical-address.js +1 -1
  164. package/build/lib-common/exceptions/error.d.ts +1 -0
  165. package/build/lib-common/exceptions/error.js +7 -6
  166. package/build/lib-common/exceptions/file.js +4 -0
  167. package/build/lib-common/ipc/ws-ipc.js +2 -2
  168. package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
  169. package/build/lib-common/objs-on-disk/file-layout.d.ts +19 -0
  170. package/build/lib-common/objs-on-disk/file-layout.js +130 -12
  171. package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
  172. package/build/lib-common/objs-on-disk/obj-file.js +96 -35
  173. package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
  174. package/build/lib-common/objs-on-disk/utils.js +3 -3
  175. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
  176. package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
  177. package/build/lib-common/processes/labelled-exec-pools.js +1 -1
  178. package/build/lib-common/processes/pressure.js +2 -2
  179. package/build/lib-common/processes/synced.js +1 -1
  180. package/build/lib-common/processes/timeout.js +2 -2
  181. package/build/lib-common/random-node.js +7 -7
  182. package/build/lib-common/service-api/3nstorage/owner.d.ts +95 -39
  183. package/build/lib-common/service-api/3nstorage/owner.js +82 -40
  184. package/build/lib-common/service-api/asmail/delivery.js +2 -2
  185. package/build/lib-common/service-api/asmail/retrieval.js +1 -1
  186. package/build/lib-common/timed-cache.d.ts +1 -0
  187. package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
  188. package/build/lib-common/timed-non-weak-cache.js +11 -0
  189. package/build/lib-common/utils-for-observables.js +4 -4
  190. package/build/lib-common/weak-cache.d.ts +1 -0
  191. package/build/lib-common/weak-cache.js +12 -1
  192. package/build/lib-index.d.ts +2 -1
  193. package/build/lib-index.js +10 -7
  194. package/build/protos/asmail.proto.js +12955 -7496
  195. package/build/protos/file.proto.js +4867 -2744
  196. package/build/protos/fs.proto.js +9227 -3768
  197. package/package.json +6 -5
  198. package/protos/file.proto +91 -19
  199. package/protos/fs.proto +107 -8
@@ -22,7 +22,7 @@ const protobuf_type_1 = require("../lib-client/protobuf-type");
22
22
  const bytes_proto_1 = require("../protos/bytes.proto");
23
23
  const connector_1 = require("./connector");
24
24
  function makeSinkCaller(caller, ref) {
25
- connector_1.checkRefObjTypeIs('FileByteSink', ref);
25
+ (0, connector_1.checkRefObjTypeIs)('FileByteSink', ref);
26
26
  const objPath = ref.path;
27
27
  const sink = {
28
28
  done: sinkDone.makeCaller(caller, objPath),
@@ -48,7 +48,7 @@ function exposeSinkService(sink, expServices) {
48
48
  }
49
49
  exports.exposeSinkService = exposeSinkService;
50
50
  function makeSrcCaller(caller, ref) {
51
- connector_1.checkRefObjTypeIs('FileByteSource', ref);
51
+ (0, connector_1.checkRefObjTypeIs)('FileByteSource', ref);
52
52
  const objPath = ref.path;
53
53
  const src = {
54
54
  getPosition: srcGetPosition.makeCaller(caller, objPath),
@@ -96,7 +96,7 @@ var sinkSplice;
96
96
  function wrapService(fn) {
97
97
  return buf => {
98
98
  const { pos, del, bytes } = requestType.unpack(buf);
99
- const promise = fn(protobuf_msg_1.fixInt(pos), protobuf_msg_1.fixInt(del), protobuf_msg_1.valOfOpt(bytes));
99
+ const promise = fn((0, protobuf_msg_1.fixInt)(pos), (0, protobuf_msg_1.fixInt)(del), (0, protobuf_msg_1.valOfOpt)(bytes));
100
100
  return { promise };
101
101
  };
102
102
  }
@@ -106,8 +106,7 @@ var sinkSplice;
106
106
  return async (pos, del, bytes) => {
107
107
  await caller
108
108
  .startPromiseCall(path, requestType.pack({
109
- pos, del,
110
- bytes: protobuf_msg_1.toOptVal(bytes)
109
+ pos, del, bytes: (0, protobuf_msg_1.toOptVal)(bytes)
111
110
  }));
112
111
  };
113
112
  }
@@ -120,7 +119,7 @@ var sinkTruncate;
120
119
  function wrapService(fn) {
121
120
  return buf => {
122
121
  const { size } = requestType.unpack(buf);
123
- const promise = fn(protobuf_msg_1.fixInt(size));
122
+ const promise = fn((0, protobuf_msg_1.fixInt)(size));
124
123
  return { promise };
125
124
  };
126
125
  }
@@ -140,15 +139,15 @@ var sinkShowLayout;
140
139
  const replyType = protobuf_type_1.ProtoType.for(bytes_proto_1.bytes.FileLayoutMsg);
141
140
  function packLayout(l) {
142
141
  return {
143
- base: protobuf_msg_1.toOptVal(l.base),
142
+ base: (0, protobuf_msg_1.toOptVal)(l.base),
144
143
  sections: l.sections
145
144
  };
146
145
  }
147
146
  function unpackLayout(msg) {
148
147
  return {
149
- base: protobuf_msg_1.valOfOptInt(msg.base),
150
- sections: protobuf_msg_1.fixArray(msg.sections).map(({ src, ofs, len }) => ({
151
- src, ofs: protobuf_msg_1.fixInt(ofs), len: protobuf_msg_1.fixInt(len)
148
+ base: (0, protobuf_msg_1.valOfOptInt)(msg.base),
149
+ sections: (0, protobuf_msg_1.fixArray)(msg.sections).map(({ src, ofs, len }) => ({
150
+ src, ofs: (0, protobuf_msg_1.fixInt)(ofs), len: (0, protobuf_msg_1.fixInt)(len)
152
151
  }))
153
152
  };
154
153
  }
@@ -175,7 +174,7 @@ var sinkDone;
175
174
  function wrapService(fn) {
176
175
  return buf => {
177
176
  const { err } = requestType.unpack(buf);
178
- const promise = (err ? fn(protobuf_msg_1.errFromMsg(err)) : fn());
177
+ const promise = (err ? fn((0, protobuf_msg_1.errFromMsg)(err)) : fn());
179
178
  return { promise };
180
179
  };
181
180
  }
@@ -183,7 +182,7 @@ var sinkDone;
183
182
  function makeCaller(caller, objPath) {
184
183
  const path = objPath.concat('done');
185
184
  return async (err) => {
186
- const req = (err ? { err: protobuf_msg_1.errToMsg(err) } : {});
185
+ const req = (err ? { err: (0, protobuf_msg_1.errToMsg)(err) } : {});
187
186
  await caller
188
187
  .startPromiseCall(path, requestType.pack(req));
189
188
  };
@@ -236,8 +235,8 @@ var srcRead;
236
235
  function wrapService(fn) {
237
236
  return buf => {
238
237
  const { len } = requestType.unpack(buf);
239
- const promise = fn(protobuf_msg_1.valOfOptInt(len))
240
- .then(bytes => replyType.pack({ bytes: protobuf_msg_1.toOptVal(bytes) }));
238
+ const promise = fn((0, protobuf_msg_1.valOfOptInt)(len))
239
+ .then(bytes => replyType.pack({ bytes: (0, protobuf_msg_1.toOptVal)(bytes) }));
241
240
  return { promise };
242
241
  };
243
242
  }
@@ -245,8 +244,8 @@ var srcRead;
245
244
  function makeCaller(caller, objPath) {
246
245
  const path = objPath.concat('read');
247
246
  return len => caller
248
- .startPromiseCall(path, requestType.pack({ len: protobuf_msg_1.toOptVal(len) }))
249
- .then(buf => protobuf_msg_1.valOfOpt(replyType.unpack(buf).bytes));
247
+ .startPromiseCall(path, requestType.pack({ len: (0, protobuf_msg_1.toOptVal)(len) }))
248
+ .then(buf => (0, protobuf_msg_1.valOfOpt)(replyType.unpack(buf).bytes));
250
249
  }
251
250
  srcRead.makeCaller = makeCaller;
252
251
  })(srcRead || (srcRead = {}));
@@ -257,7 +256,7 @@ var srcSeek;
257
256
  function wrapService(fn) {
258
257
  return buf => {
259
258
  const { offset } = requestType.unpack(buf);
260
- const promise = fn(protobuf_msg_1.fixInt(offset));
259
+ const promise = fn((0, protobuf_msg_1.fixInt)(offset));
261
260
  return { promise };
262
261
  };
263
262
  }
@@ -16,9 +16,12 @@ export declare class ClientsSideImpl implements ClientsSide {
16
16
  processInterimCallReply(fnCallNum: number, body: EnvelopeBody): void;
17
17
  processEndCallReply(fnCallNum: number, body: EnvelopeBody): void;
18
18
  processCallError(fnCallNum: number, body: EnvelopeBody): void;
19
+ private retryWithOtherCallNum;
19
20
  private nextFnCallNum;
20
21
  caller(): Caller;
22
+ private throwIfStopped;
21
23
  private startCall;
24
+ private setupFnCall;
22
25
  startPromiseCall(path: string[], req: EnvelopeBody): Promise<EnvelopeBody>;
23
26
  startObservableCall(path: string[], req: EnvelopeBody, obs: Subject<EnvelopeBody>): () => void;
24
27
  registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
@@ -21,6 +21,7 @@ const protobuf_msg_1 = require("./protobuf-msg");
21
21
  const deferred_1 = require("../lib-common/processes/deferred");
22
22
  const weakref_1 = require("../lib-common/weakref");
23
23
  const connector_1 = require("./connector");
24
+ const MAX_DUPLICATE_ATTEMPTS = 100;
24
25
  // XXX can have an optimized use of WeakRef and FinalizationRegistry, when
25
26
  // these are available.
26
27
  class ClientsSideImpl {
@@ -60,7 +61,7 @@ class ClientsSideImpl {
60
61
  }
61
62
  sendCallCancellation(fnCallNum) {
62
63
  this.sendMsg({
63
- headers: { fnCallNum: protobuf_msg_1.toVal(fnCallNum), msgType: 'cancel' }
64
+ headers: { fnCallNum: (0, protobuf_msg_1.toVal)(fnCallNum), msgType: 'cancel' }
64
65
  });
65
66
  }
66
67
  processInterimCallReply(fnCallNum, body) {
@@ -104,7 +105,13 @@ class ClientsSideImpl {
104
105
  if (!call) {
105
106
  return;
106
107
  }
107
- const err = (body ? protobuf_msg_1.errFromMsg(protobuf_msg_1.errBodyType.unpack(body)) : undefined);
108
+ this.fnCalls.delete(fnCallNum);
109
+ const err = (body ? (0, protobuf_msg_1.errFromMsg)(protobuf_msg_1.errBodyType.unpack(body)) : undefined);
110
+ if (err && (err.type === 'ipc')
111
+ && err.duplicateFnCallNum) {
112
+ this.retryWithOtherCallNum(call);
113
+ return;
114
+ }
108
115
  if (call.obs) {
109
116
  call.obs.error(err);
110
117
  }
@@ -114,7 +121,32 @@ class ClientsSideImpl {
114
121
  else {
115
122
  // XXX log presence of fn call without fields to signal reply
116
123
  }
117
- this.fnCalls.delete(fnCallNum);
124
+ }
125
+ retryWithOtherCallNum(call) {
126
+ if (call.countOfDuplicateFnCallNum) {
127
+ call.countOfDuplicateFnCallNum += 1;
128
+ if (call.countOfDuplicateFnCallNum >= MAX_DUPLICATE_ATTEMPTS) {
129
+ return;
130
+ }
131
+ }
132
+ else {
133
+ call.countOfDuplicateFnCallNum = 1;
134
+ }
135
+ const fnCallNum = this.nextFnCallNum();
136
+ call.reqEnv.headers.fnCallNum.value = fnCallNum;
137
+ this.fnCalls.set(fnCallNum, call);
138
+ try {
139
+ this.sendMsg(call.reqEnv);
140
+ }
141
+ catch (err) {
142
+ this.fnCalls.delete(fnCallNum);
143
+ if (call.deferred) {
144
+ call.deferred.reject(err);
145
+ }
146
+ else if (call.obs) {
147
+ call.obs.error(err);
148
+ }
149
+ }
118
150
  }
119
151
  nextFnCallNum() {
120
152
  while (this.fnCalls.has(this.fnCallCounter)) {
@@ -141,21 +173,30 @@ class ClientsSideImpl {
141
173
  };
142
174
  return callerWrap;
143
175
  }
144
- startCall(fnCallNum, path, body) {
176
+ throwIfStopped() {
145
177
  if (this.isStopped) {
146
- throw connector_1.makeIPCException({ 'ipcNotConnected': true });
178
+ throw (0, connector_1.makeIPCException)({ ipcNotConnected: true });
147
179
  }
148
- this.sendMsg({
149
- headers: { fnCallNum: protobuf_msg_1.toVal(fnCallNum), msgType: 'start', path },
150
- body: protobuf_msg_1.toOptVal(body)
151
- });
152
180
  }
153
- startPromiseCall(path, req) {
154
- const deferred = deferred_1.defer();
181
+ startCall(reqEnv) {
182
+ this.throwIfStopped();
183
+ this.sendMsg(reqEnv);
184
+ }
185
+ setupFnCall(path, body, deferred, obs) {
155
186
  const fnCallNum = this.nextFnCallNum();
156
- this.fnCalls.set(fnCallNum, { deferred });
187
+ const reqEnv = {
188
+ headers: { fnCallNum: (0, protobuf_msg_1.toVal)(fnCallNum), msgType: 'start', path },
189
+ body: (0, protobuf_msg_1.toOptVal)(body)
190
+ };
191
+ this.fnCalls.set(fnCallNum, { deferred, obs, reqEnv });
192
+ return reqEnv;
193
+ }
194
+ startPromiseCall(path, req) {
195
+ const deferred = (0, deferred_1.defer)();
196
+ const reqEnv = this.setupFnCall(path, req, deferred, undefined);
197
+ const fnCallNum = reqEnv.headers.fnCallNum.value;
157
198
  try {
158
- this.startCall(fnCallNum, path, req);
199
+ this.startCall(reqEnv);
159
200
  return deferred.promise;
160
201
  }
161
202
  catch (err) {
@@ -164,10 +205,10 @@ class ClientsSideImpl {
164
205
  }
165
206
  }
166
207
  startObservableCall(path, req, obs) {
167
- const fnCallNum = this.nextFnCallNum();
168
- this.fnCalls.set(fnCallNum, { obs });
208
+ const reqEnv = this.setupFnCall(path, req, undefined, obs);
209
+ const fnCallNum = reqEnv.headers.fnCallNum.value;
169
210
  try {
170
- this.startCall(fnCallNum, path, req);
211
+ this.startCall(reqEnv);
171
212
  return () => this.sendCallCancellation(fnCallNum);
172
213
  }
173
214
  catch (err) {
@@ -176,7 +217,7 @@ class ClientsSideImpl {
176
217
  }
177
218
  }
178
219
  registerClientDrop(o, srvRef) {
179
- const clientRef = weakref_1.makeWeakRefFor(o);
220
+ const clientRef = (0, weakref_1.makeWeakRefFor)(o);
180
221
  this.weakRefs.add(clientRef);
181
222
  clientRef.addCallback(this.makeClientDropCB(clientRef, srvRef));
182
223
  this.srvRefs.set(o, srvRef);
@@ -199,19 +240,15 @@ class ClientsSideImpl {
199
240
  return srvRef;
200
241
  }
201
242
  else {
202
- throw connector_1.makeIPCException({ 'objectNotFound': true });
243
+ throw (0, connector_1.makeIPCException)({ 'objectNotFound': true });
203
244
  }
204
245
  }
205
246
  listObj(path) {
206
- if (this.isStopped) {
207
- throw connector_1.makeIPCException({ 'ipcNotConnected': true });
208
- }
247
+ this.throwIfStopped();
209
248
  return this.syncReqToListObj(path);
210
249
  }
211
250
  listObjAsync(path) {
212
- if (this.isStopped) {
213
- throw connector_1.makeIPCException({ 'ipcNotConnected': true });
214
- }
251
+ this.throwIfStopped();
215
252
  return this.asyncReqToListObj(path);
216
253
  }
217
254
  }
@@ -41,22 +41,22 @@ class ServicesSideImpl {
41
41
  }
42
42
  sendCallError(fnCallNum, err) {
43
43
  this.sendMsg({
44
- headers: { fnCallNum: protobuf_msg_1.toVal(fnCallNum), msgType: 'error' },
45
- body: protobuf_msg_1.toVal(protobuf_msg_1.errBodyType.pack(protobuf_msg_1.errToMsg(err)))
44
+ headers: { fnCallNum: (0, protobuf_msg_1.toVal)(fnCallNum), msgType: 'error' },
45
+ body: (0, protobuf_msg_1.toVal)(protobuf_msg_1.errBodyType.pack((0, protobuf_msg_1.errToMsg)(err)))
46
46
  });
47
47
  }
48
48
  sendCallReply(fnCallNum, last, body) {
49
49
  this.sendMsg({
50
50
  headers: {
51
- fnCallNum: protobuf_msg_1.toVal(fnCallNum),
51
+ fnCallNum: (0, protobuf_msg_1.toVal)(fnCallNum),
52
52
  msgType: (last ? 'end' : 'interim')
53
53
  },
54
- body: protobuf_msg_1.toOptVal(body)
54
+ body: (0, protobuf_msg_1.toOptVal)(body)
55
55
  });
56
56
  }
57
57
  processCallStart(fnCallNum, path, body) {
58
58
  if (this.fnCallProcs.has(fnCallNum)) {
59
- this.sendCallError(fnCallNum, connector_1.makeIPCException({ duplicateFnCallNum: true }));
59
+ this.sendCallError(fnCallNum, (0, connector_1.makeIPCException)({ duplicateFnCallNum: true }));
60
60
  return;
61
61
  }
62
62
  try {
@@ -113,7 +113,7 @@ class ServicesSideImpl {
113
113
  this.exposedObjs.drop(path[0]);
114
114
  }
115
115
  else {
116
- throw connector_1.makeIPCException({ invalidPath: true, path });
116
+ throw (0, connector_1.makeIPCException)({ invalidPath: true, path });
117
117
  }
118
118
  }
119
119
  processListObj(fnCallNum, path) {
@@ -124,7 +124,7 @@ class ServicesSideImpl {
124
124
  this.sendCallReply(fnCallNum, true, buf);
125
125
  }
126
126
  else {
127
- const exc = connector_1.makeIPCException({ 'objectNotFound': true });
127
+ const exc = (0, connector_1.makeIPCException)({ 'objectNotFound': true });
128
128
  this.sendCallError(fnCallNum, exc);
129
129
  }
130
130
  }
@@ -151,7 +151,7 @@ class ExposedObjs {
151
151
  exposeDroppableService(objType, exp, original) {
152
152
  let id;
153
153
  do {
154
- id = random_node_1.stringOfB64CharsSync(20);
154
+ id = (0, random_node_1.stringOfB64CharsSync)(20);
155
155
  } while (this.objs.has(id));
156
156
  this.objs.set(id, { exp, original });
157
157
  return { objType, path: [id] };
@@ -162,7 +162,7 @@ class ExposedObjs {
162
162
  return o.original;
163
163
  }
164
164
  else {
165
- throw connector_1.makeIPCException({ 'objectNotFound': true });
165
+ throw (0, connector_1.makeIPCException)({ 'objectNotFound': true });
166
166
  }
167
167
  }
168
168
  exposeW3NService(exp) {
@@ -199,7 +199,7 @@ class ExposedObjs {
199
199
  return fn;
200
200
  }
201
201
  else {
202
- throw connector_1.makeIPCException({ callFnNotFound: true, path });
202
+ throw (0, connector_1.makeIPCException)({ callFnNotFound: true, path });
203
203
  }
204
204
  }
205
205
  dropAll() {
@@ -104,8 +104,8 @@ class ObjectsConnector {
104
104
  processIncomingMsg(msg) {
105
105
  var _a, _b, _c, _d, _e, _f, _g;
106
106
  const { msgType, path, fnCallNum: cNum } = msg.headers;
107
- const fnCallNum = protobuf_msg_1.valOfOptInt(cNum);
108
- const body = protobuf_msg_1.valOfOpt(msg.body);
107
+ const fnCallNum = (0, protobuf_msg_1.valOfOptInt)(cNum);
108
+ const body = (0, protobuf_msg_1.valOfOpt)(msg.body);
109
109
  try {
110
110
  if (typeof fnCallNum === 'number') {
111
111
  if (msgType === 'start') {
@@ -149,8 +149,8 @@ class ObjectsConnector {
149
149
  return;
150
150
  }
151
151
  const msg = {
152
- headers: { fnCallNum: protobuf_msg_1.toVal(fnCallNum), msgType: 'error' },
153
- body: protobuf_msg_1.toVal(protobuf_msg_1.errBodyType.pack(protobuf_msg_1.errToMsg(err)))
152
+ headers: { fnCallNum: (0, protobuf_msg_1.toVal)(fnCallNum), msgType: 'error' },
153
+ body: (0, protobuf_msg_1.toVal)(protobuf_msg_1.errBodyType.pack((0, protobuf_msg_1.errToMsg)(err)))
154
154
  };
155
155
  this.msgSink.next(msg);
156
156
  }
@@ -8,20 +8,27 @@ declare type WritableFile = web3n.files.WritableFile;
8
8
  declare type WritableFileVersionedAPI = web3n.files.WritableFileVersionedAPI;
9
9
  declare type File = web3n.files.File;
10
10
  declare type Stats = web3n.files.Stats;
11
+ declare type SyncStatus = web3n.files.SyncStatus;
11
12
  declare type XAttrsChanges = web3n.files.XAttrsChanges;
12
13
  declare type FileEvent = web3n.files.FileEvent;
14
+ declare type RemoteEvent = web3n.files.RemoteEvent;
15
+ declare type OptionsToAdopteRemote = web3n.files.OptionsToAdopteRemote;
16
+ declare type OptionsToUploadLocal = web3n.files.OptionsToUploadLocal;
13
17
  export declare function makeFileCaller(caller: Caller, fileMsg: FileMsg): File;
14
18
  export declare function exposeFileService(file: File, expServices: ExposedServices): FileMsg;
15
- export declare const fileMsgType: ProtoType<FileMsg>;
16
- export declare function packStats(s: Stats): Buffer;
17
- export declare function unpackStats(buf: Buffer | void): Stats;
18
19
  export interface FileMsg {
19
20
  writable: boolean;
20
21
  isVersioned: boolean;
22
+ isSynced: boolean;
21
23
  name: string;
22
24
  isNew: boolean;
23
25
  impl: ObjectReference<'FileImpl'>;
24
26
  }
27
+ export declare const fileMsgType: ProtoType<FileMsg>;
28
+ export declare function packStats(s: Stats): Buffer;
29
+ export declare function unpackStats(buf: Buffer | void): Stats;
30
+ export declare function packSyncStatus(s: SyncStatus): Buffer;
31
+ export declare function unpackSyncStatus(buf: Buffer | void): SyncStatus;
25
32
  export declare function packXAttrValue(val: any): EnvelopeBody;
26
33
  export declare function unpackXAttrValue(buf: EnvelopeBody): any;
27
34
  export declare namespace readBytes {
@@ -32,8 +39,8 @@ export declare namespace readBytes {
32
39
  }
33
40
  export declare function packJSON(json: any): EnvelopeBody;
34
41
  export declare function unpackJSON(buf: EnvelopeBody): any;
35
- export declare function packFileEvent(e: FileEvent): Buffer;
36
- export declare function unpackFileEvent(buf: EnvelopeBody): FileEvent;
42
+ export declare function packFileEvent(e: FileEvent | RemoteEvent): Buffer;
43
+ export declare function unpackFileEvent(buf: EnvelopeBody): FileEvent | RemoteEvent;
37
44
  export declare namespace vGetXAttr {
38
45
  interface Reply {
39
46
  version: number;
@@ -97,16 +104,21 @@ export declare namespace vGetByteSource {
97
104
  function wrapService(fn: ReadonlyFileVersionedAPI['getByteSource'], expServices: ExposedServices): ExposedFn;
98
105
  function makeCaller(caller: Caller, objPath: string[]): ReadonlyFileVersionedAPI['getByteSource'];
99
106
  }
107
+ export interface XAttrMsg {
108
+ xaName: string;
109
+ str?: Value<string>;
110
+ json?: Value<string>;
111
+ bytes?: Value<Buffer>;
112
+ }
113
+ export declare function xattrToMsg(xaName: string, val: any): XAttrMsg;
114
+ export declare function xattrFromMsg(msg: XAttrMsg): {
115
+ name: string;
116
+ value: any;
117
+ };
100
118
  export declare namespace updateXAttrs {
101
- interface Attr {
102
- xaName: string;
103
- str?: Value<string>;
104
- json?: Value<string>;
105
- bytes?: Value<Buffer>;
106
- }
107
119
  interface Request {
108
120
  changes: {
109
- set: Attr[];
121
+ set: XAttrMsg[];
110
122
  remove: string[];
111
123
  };
112
124
  }
@@ -126,4 +138,28 @@ export declare namespace vGetByteSink {
126
138
  function wrapService(fn: WritableFileVersionedAPI['getByteSink'], expServices: ExposedServices): ExposedFn;
127
139
  function makeCaller(caller: Caller, objPath: string[]): WritableFileVersionedAPI['getByteSink'];
128
140
  }
141
+ export interface OptionsToUploadLocalMsg {
142
+ localVersion?: Value<number>;
143
+ uploadVersion?: Value<number>;
144
+ }
145
+ export declare function optionsToUploadLocalToMsg(opts?: OptionsToUploadLocal): OptionsToUploadLocalMsg | undefined;
146
+ export declare function optionsToUploadLocalFromMsg(opts?: OptionsToUploadLocalMsg): OptionsToUploadLocal | undefined;
147
+ export interface OptionsToAdopteRemoteMsg {
148
+ dropLocalVer?: Value<boolean>;
149
+ remoteVersion?: Value<number>;
150
+ }
151
+ export declare function remoteAdoptionOptsToMsg(opts: OptionsToAdopteRemote | undefined): OptionsToAdopteRemoteMsg | undefined;
152
+ export declare function remoteAdoptionOptsFromMsg(msg: OptionsToAdopteRemoteMsg | undefined): OptionsToAdopteRemote | undefined;
153
+ export declare namespace vListVersions {
154
+ function packReply(v: {
155
+ current?: number;
156
+ archived?: number[];
157
+ }): Buffer;
158
+ function unpackReply(b: Buffer): {
159
+ current?: number;
160
+ archived?: number[];
161
+ };
162
+ function wrapService(fn: ReadonlyFileVersionedAPI['listVersions']): ExposedFn;
163
+ function makeCaller(caller: Caller, objPath: string[]): ReadonlyFileVersionedAPI['listVersions'];
164
+ }
129
165
  export {};