core-3nweb-client-lib 0.42.1 → 0.42.3

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 (23) hide show
  1. package/build/core/asmail/inbox/inbox-events.d.ts +3 -2
  2. package/build/core/asmail/inbox/inbox-events.js +23 -18
  3. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  4. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  5. package/package.json +1 -1
  6. package/{test-data-1-1759636324169 → test-data-1-1759691784470}/util/logs/2025-10-05.log.txt +4 -4
  7. package/{test-data-10-1759636364594 → test-data-10-1759691821007}/util/logs/2025-10-05.log.txt +4 -4
  8. package/{test-data-11-1759636364595 → test-data-11-1759691821008}/util/logs/2025-10-05.log.txt +4 -4
  9. package/{test-data-12-1759636368628 → test-data-12-1759691824688}/util/logs/2025-10-05.log.txt +4 -4
  10. package/{test-data-13-1759636369614 → test-data-13-1759691825525}/util/logs/2025-10-05.log.txt +8 -8
  11. package/test-data-2-1759691784473/util/logs/2025-10-05.log.txt +14 -0
  12. package/{test-data-3-1759636329651 → test-data-3-1759691789049}/util/logs/2025-10-05.log.txt +8 -8
  13. package/{test-data-4-1759636335955 → test-data-4-1759691794994}/util/logs/2025-10-05.log.txt +8 -8
  14. package/test-data-5-1759691804247/util/logs/2025-10-05.log.txt +14 -0
  15. package/test-data-6-1759691806167/util/logs/2025-10-05.log.txt +14 -0
  16. package/test-data-7-1759691808152/util/logs/2025-10-05.log.txt +14 -0
  17. package/test-data-8-1759691816773/util/logs/2025-10-05.log.txt +14 -0
  18. package/{test-data-9-1759636360774 → test-data-9-1759691817611}/util/logs/2025-10-05.log.txt +8 -8
  19. package/test-data-2-1759636324173/util/logs/2025-10-05.log.txt +0 -14
  20. package/test-data-5-1759636345925/util/logs/2025-10-05.log.txt +0 -14
  21. package/test-data-6-1759636347983/util/logs/2025-10-05.log.txt +0 -14
  22. package/test-data-7-1759636350156/util/logs/2025-10-05.log.txt +0 -14
  23. package/test-data-8-1759636359769/util/logs/2025-10-05.log.txt +0 -14
@@ -24,9 +24,10 @@ export declare class InboxEvents {
24
24
  private listeningProc;
25
25
  private readonly makeServerEvents;
26
26
  private networkActive;
27
- private listMsgsFrom;
27
+ private disconnectedAt;
28
28
  constructor(msgReceiver: MailRecipient, getMsg: (msgId: string) => Promise<IncomingMessage>, listMsgs: (fromTS: number) => Promise<MsgInfo[]>, rmMsg: (msgId: string) => Promise<void>, logError: LogError);
29
29
  private startListening;
30
+ private sleepAndRestart;
30
31
  private getMessage;
31
32
  subscribe<T>(event: InboxEventType, observer: Observer<T>): () => void;
32
33
  close(): void;
@@ -35,6 +36,6 @@ export declare class InboxEvents {
35
36
  private stopListening;
36
37
  suspendNetworkActivity(): void;
37
38
  resumeNetworkActivity(): void;
38
- private startListingOfDisconnectedPeriod;
39
+ private listMsgsFromDisconnectedPeriod;
39
40
  }
40
41
  export {};
@@ -24,6 +24,7 @@ const operators_1 = require("rxjs/operators");
24
24
  const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
25
25
  const sleep_1 = require("../../../lib-common/processes/sleep");
26
26
  const SERVER_EVENTS_RESTART_WAIT_SECS = 5;
27
+ const BUFFER_MILLIS_FOR_LISTING = 2 * 60 * 1000;
27
28
  /**
28
29
  * Instance of this class handles event subscription from UI side. It observes
29
30
  * inbox server events, handles them, and generates respective events for UI
@@ -44,7 +45,7 @@ class InboxEvents {
44
45
  this.newMsg$ = this.newMsgs.asObservable().pipe((0, operators_1.share)());
45
46
  this.listeningProc = undefined;
46
47
  this.networkActive = true;
47
- this.listMsgsFrom = undefined;
48
+ this.disconnectedAt = undefined;
48
49
  this.makeServerEvents = () => new server_events_1.ServerEvents(() => msgReceiver.openEventSource(this.logError));
49
50
  this.startListening();
50
51
  Object.seal(this);
@@ -53,11 +54,14 @@ class InboxEvents {
53
54
  if (this.listeningProc || !this.networkActive) {
54
55
  return;
55
56
  }
56
- function clearListeningProc() {
57
+ const clearListeningProc = () => {
57
58
  if (this.listeningProc === sub) {
58
59
  this.listeningProc = undefined;
59
60
  }
60
- }
61
+ if (!this.disconnectedAt) {
62
+ this.disconnectedAt = Date.now();
63
+ }
64
+ };
61
65
  const sub = this.makeServerEvents()
62
66
  .observe(retrieval_1.msgRecievedCompletely.EVENT_NAME)
63
67
  .pipe((0, operators_1.mergeMap)(async (ev) => this.getMessage(ev.msgId), 5))
@@ -73,21 +77,26 @@ class InboxEvents {
73
77
  error: async (exc) => {
74
78
  clearListeningProc();
75
79
  if (this.shouldRestartAfterErr(exc)) {
76
- await (0, sleep_1.sleep)(SERVER_EVENTS_RESTART_WAIT_SECS);
77
- this.startListening();
80
+ this.sleepAndRestart();
78
81
  }
79
82
  }
80
83
  });
81
84
  this.listeningProc = sub;
85
+ this.listMsgsFromDisconnectedPeriod();
86
+ }
87
+ async sleepAndRestart() {
88
+ await (0, sleep_1.sleep)(SERVER_EVENTS_RESTART_WAIT_SECS);
89
+ this.startListening();
82
90
  }
83
91
  async getMessage(msgId) {
84
92
  try {
85
93
  return await this.getMsg(msgId);
86
94
  }
87
95
  catch (err) {
88
- // XXX we need to skip, if it is a connectivity error here
89
- await this.rmMsg(msgId);
90
- await this.logError(err, `Cannot get message ${msgId}, and removing it as a result`);
96
+ // XXX we need to skip, if it is a connectivity error here;
97
+ // should we remove on non-connectivity error
98
+ // await this.rmMsg(msgId).catch(noop);
99
+ await this.logError(err, `Cannot get message ${msgId}`);
91
100
  }
92
101
  }
93
102
  subscribe(event, observer) {
@@ -130,8 +139,8 @@ class InboxEvents {
130
139
  suspendNetworkActivity() {
131
140
  this.networkActive = false;
132
141
  if (this.isListening) {
133
- if (!this.listMsgsFrom) {
134
- this.listMsgsFrom = Date.now();
142
+ if (!this.disconnectedAt) {
143
+ this.disconnectedAt = Date.now();
135
144
  }
136
145
  this.stopListening();
137
146
  }
@@ -140,14 +149,13 @@ class InboxEvents {
140
149
  this.networkActive = true;
141
150
  if (!this.isListening) {
142
151
  this.startListening();
143
- this.startListingOfDisconnectedPeriod();
144
152
  }
145
153
  }
146
- async startListingOfDisconnectedPeriod() {
147
- if (!this.listMsgsFrom) {
154
+ async listMsgsFromDisconnectedPeriod() {
155
+ if (!this.disconnectedAt) {
148
156
  return;
149
157
  }
150
- const fromTS = this.listMsgsFrom + 2 * 60 * 1000;
158
+ const fromTS = this.disconnectedAt - BUFFER_MILLIS_FOR_LISTING;
151
159
  let msgInfos = (await this.listMsgs(fromTS))
152
160
  .filter(info => (fromTS <= info.deliveryTS))
153
161
  .sort((a, b) => (a.deliveryTS - b.deliveryTS));
@@ -159,11 +167,8 @@ class InboxEvents {
159
167
  else if (!this.networkActive) {
160
168
  return;
161
169
  }
162
- else {
163
- // XXX
164
- }
165
170
  }
166
- this.listMsgsFrom = undefined;
171
+ this.disconnectedAt = undefined;
167
172
  }
168
173
  }
169
174
  exports.InboxEvents = InboxEvents;