core-3nweb-client-lib 0.42.1 → 0.42.2

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 +28 -16
  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-1759677394615}/util/logs/2025-10-05.log.txt +4 -4
  7. package/{test-data-10-1759636364594 → test-data-10-1759677431029}/util/logs/2025-10-05.log.txt +4 -4
  8. package/{test-data-11-1759636364595 → test-data-11-1759677431029}/util/logs/2025-10-05.log.txt +4 -4
  9. package/{test-data-12-1759636368628 → test-data-12-1759677434728}/util/logs/2025-10-05.log.txt +4 -4
  10. package/{test-data-13-1759636369614 → test-data-13-1759677435553}/util/logs/2025-10-05.log.txt +8 -8
  11. package/test-data-2-1759677394617/util/logs/2025-10-05.log.txt +14 -0
  12. package/{test-data-3-1759636329651 → test-data-3-1759677399141}/util/logs/2025-10-05.log.txt +8 -8
  13. package/{test-data-4-1759636335955 → test-data-4-1759677405076}/util/logs/2025-10-05.log.txt +8 -8
  14. package/test-data-5-1759677414316/util/logs/2025-10-05.log.txt +14 -0
  15. package/test-data-6-1759677416229/util/logs/2025-10-05.log.txt +14 -0
  16. package/test-data-7-1759677418207/util/logs/2025-10-05.log.txt +14 -0
  17. package/test-data-8-1759677426790/util/logs/2025-10-05.log.txt +14 -0
  18. package/{test-data-9-1759636360774 → test-data-9-1759677427624}/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,12 +77,16 @@ 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 {
@@ -86,7 +94,7 @@ class InboxEvents {
86
94
  }
87
95
  catch (err) {
88
96
  // XXX we need to skip, if it is a connectivity error here
89
- await this.rmMsg(msgId);
97
+ // await this.rmMsg(msgId);
90
98
  await this.logError(err, `Cannot get message ${msgId}, and removing it as a result`);
91
99
  }
92
100
  }
@@ -130,8 +138,8 @@ class InboxEvents {
130
138
  suspendNetworkActivity() {
131
139
  this.networkActive = false;
132
140
  if (this.isListening) {
133
- if (!this.listMsgsFrom) {
134
- this.listMsgsFrom = Date.now();
141
+ if (!this.disconnectedAt) {
142
+ this.disconnectedAt = Date.now();
135
143
  }
136
144
  this.stopListening();
137
145
  }
@@ -140,30 +148,34 @@ class InboxEvents {
140
148
  this.networkActive = true;
141
149
  if (!this.isListening) {
142
150
  this.startListening();
143
- this.startListingOfDisconnectedPeriod();
144
151
  }
145
152
  }
146
- async startListingOfDisconnectedPeriod() {
147
- if (!this.listMsgsFrom) {
153
+ async listMsgsFromDisconnectedPeriod() {
154
+ // DEBUG log
155
+ await this.logError(null, `entering listMsgsFromDisconnectedPeriod at ${Date.now()}, this.disconnectedAt is ${this.disconnectedAt}`);
156
+ if (!this.disconnectedAt) {
148
157
  return;
149
158
  }
150
- const fromTS = this.listMsgsFrom + 2 * 60 * 1000;
159
+ const fromTS = this.disconnectedAt - BUFFER_MILLIS_FOR_LISTING;
160
+ // DEBUG log
161
+ await this.logError(null, `starting listMsgsFromDisconnectedPeriod process with fromTS ${fromTS}`);
151
162
  let msgInfos = (await this.listMsgs(fromTS))
152
163
  .filter(info => (fromTS <= info.deliveryTS))
153
164
  .sort((a, b) => (a.deliveryTS - b.deliveryTS));
165
+ // DEBUG log
166
+ await this.logError(null, ` ... filtered list has ${msgInfos.length} number of items`);
154
167
  for (const info of msgInfos) {
155
168
  const msg = await this.getMessage(info.msgId);
169
+ // DEBUG log
170
+ await this.logError(null, ` ... msg ${msg === null || msg === void 0 ? void 0 : msg.msgId} found`);
156
171
  if (msg) {
157
172
  this.newMsgs.next(msg);
158
173
  }
159
174
  else if (!this.networkActive) {
160
175
  return;
161
176
  }
162
- else {
163
- // XXX
164
- }
165
177
  }
166
- this.listMsgsFrom = undefined;
178
+ this.disconnectedAt = undefined;
167
179
  }
168
180
  }
169
181
  exports.InboxEvents = InboxEvents;