@bobfrankston/iflow-direct 0.1.9 → 0.1.10

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/gmail.d.ts CHANGED
@@ -10,6 +10,8 @@ export interface GmailOAuthConfig {
10
10
  verbose?: boolean;
11
11
  rejectUnauthorized?: boolean;
12
12
  inactivityTimeout?: number;
13
+ fetchChunkSize?: number;
14
+ fetchChunkSizeMax?: number;
13
15
  }
14
16
  /**
15
17
  * Check if email address is Gmail
@@ -37,5 +39,7 @@ export declare function createAutoImapConfig(config: {
37
39
  verbose?: boolean;
38
40
  rejectUnauthorized?: boolean;
39
41
  inactivityTimeout?: number;
42
+ fetchChunkSize?: number;
43
+ fetchChunkSizeMax?: number;
40
44
  }): ImapClientConfig;
41
45
  //# sourceMappingURL=gmail.d.ts.map
package/gmail.js CHANGED
@@ -34,6 +34,8 @@ export function createGmailConfig(config) {
34
34
  verbose: config.verbose,
35
35
  rejectUnauthorized: config.rejectUnauthorized,
36
36
  inactivityTimeout: config.inactivityTimeout,
37
+ fetchChunkSize: config.fetchChunkSize,
38
+ fetchChunkSizeMax: config.fetchChunkSizeMax,
37
39
  };
38
40
  }
39
41
  /**
@@ -52,6 +54,8 @@ export function createAutoImapConfig(config) {
52
54
  verbose: config.verbose,
53
55
  rejectUnauthorized: config.rejectUnauthorized,
54
56
  inactivityTimeout: config.inactivityTimeout,
57
+ fetchChunkSize: config.fetchChunkSize,
58
+ fetchChunkSizeMax: config.fetchChunkSizeMax,
55
59
  });
56
60
  }
57
61
  else {
@@ -63,6 +67,8 @@ export function createAutoImapConfig(config) {
63
67
  verbose: config.verbose,
64
68
  rejectUnauthorized: config.rejectUnauthorized,
65
69
  inactivityTimeout: config.inactivityTimeout,
70
+ fetchChunkSize: config.fetchChunkSize,
71
+ fetchChunkSizeMax: config.fetchChunkSizeMax,
66
72
  };
67
73
  }
68
74
  }
package/imap-native.d.ts CHANGED
@@ -121,9 +121,11 @@ export declare class NativeImapClient {
121
121
  * 60s accommodates Gmail which is slow on SEARCH for large folders.
122
122
  * Overridable via ImapClientConfig.inactivityTimeout — slow Dovecot servers need 180s+. */
123
123
  private inactivityTimeout;
124
- /** Fetch chunk sizes — start small for quick first paint, ramp up for throughput */
125
- private static INITIAL_CHUNK_SIZE;
126
- private static MAX_CHUNK_SIZE;
124
+ /** Fetch chunk sizes — start small for quick first paint, ramp up for throughput.
125
+ * Default 25 initial → 500 max. Overridable via ImapClientConfig.fetchChunkSize /
126
+ * fetchChunkSizeMax. Slow servers benefit from smaller chunks (fewer timeouts). */
127
+ private fetchChunkSize;
128
+ private fetchChunkSizeMax;
127
129
  /** Active command timer — reset by handleData on every data arrival */
128
130
  private commandTimer;
129
131
  private sendCommand;
package/imap-native.js CHANGED
@@ -29,6 +29,8 @@ export class NativeImapClient {
29
29
  this.transport = transportFactory();
30
30
  this.verbose = config.verbose || false;
31
31
  this.inactivityTimeout = config.inactivityTimeout ?? 60000;
32
+ this.fetchChunkSize = config.fetchChunkSize ?? 25;
33
+ this.fetchChunkSizeMax = config.fetchChunkSizeMax ?? 500;
32
34
  }
33
35
  get connected() { return this._connected; }
34
36
  // ── Connection ──
@@ -296,14 +298,14 @@ export class NativeImapClient {
296
298
  return [];
297
299
  uids.reverse(); // Newest first
298
300
  console.log(` [fetch] ${uids.length} UIDs since ${sinceUid} (newest first)`);
299
- if (uids.length <= NativeImapClient.INITIAL_CHUNK_SIZE) {
301
+ if (uids.length <= this.fetchChunkSize) {
300
302
  const msgs = await this.fetchMessages(uids.join(","), options);
301
303
  if (onChunk)
302
304
  onChunk(msgs);
303
305
  return msgs;
304
306
  }
305
307
  const allMessages = [];
306
- let chunkSize = NativeImapClient.INITIAL_CHUNK_SIZE;
308
+ let chunkSize = this.fetchChunkSize;
307
309
  for (let i = 0; i < uids.length; i += chunkSize) {
308
310
  const chunk = uids.slice(i, i + chunkSize);
309
311
  const msgs = await this.fetchMessages(chunk.join(","), options);
@@ -311,8 +313,8 @@ export class NativeImapClient {
311
313
  console.log(` [fetch] ${allMessages.length}/${uids.length} (chunk of ${chunk.length})`);
312
314
  if (onChunk)
313
315
  onChunk(msgs);
314
- if (chunkSize < NativeImapClient.MAX_CHUNK_SIZE)
315
- chunkSize = Math.min(chunkSize * 4, NativeImapClient.MAX_CHUNK_SIZE);
316
+ if (chunkSize < this.fetchChunkSizeMax)
317
+ chunkSize = Math.min(chunkSize * 4, this.fetchChunkSizeMax);
316
318
  }
317
319
  return allMessages;
318
320
  }
@@ -329,7 +331,7 @@ export class NativeImapClient {
329
331
  uids.reverse();
330
332
  console.log(` [fetch] ${uids.length} UIDs to fetch (newest first)`);
331
333
  const allMessages = [];
332
- let chunkSize = NativeImapClient.INITIAL_CHUNK_SIZE;
334
+ let chunkSize = this.fetchChunkSize;
333
335
  for (let i = 0; i < uids.length; i += chunkSize) {
334
336
  const chunk = uids.slice(i, i + chunkSize);
335
337
  const msgs = await this.fetchMessages(chunk.join(","), options);
@@ -337,8 +339,8 @@ export class NativeImapClient {
337
339
  console.log(` [fetch] ${allMessages.length}/${uids.length} (chunk of ${chunk.length})`);
338
340
  if (onChunk)
339
341
  onChunk(msgs);
340
- if (chunkSize < NativeImapClient.MAX_CHUNK_SIZE)
341
- chunkSize = Math.min(chunkSize * 4, NativeImapClient.MAX_CHUNK_SIZE);
342
+ if (chunkSize < this.fetchChunkSizeMax)
343
+ chunkSize = Math.min(chunkSize * 4, this.fetchChunkSizeMax);
342
344
  }
343
345
  return allMessages;
344
346
  }
@@ -461,9 +463,11 @@ export class NativeImapClient {
461
463
  * 60s accommodates Gmail which is slow on SEARCH for large folders.
462
464
  * Overridable via ImapClientConfig.inactivityTimeout — slow Dovecot servers need 180s+. */
463
465
  inactivityTimeout;
464
- /** Fetch chunk sizes — start small for quick first paint, ramp up for throughput */
465
- static INITIAL_CHUNK_SIZE = 25;
466
- static MAX_CHUNK_SIZE = 500;
466
+ /** Fetch chunk sizes — start small for quick first paint, ramp up for throughput.
467
+ * Default 25 initial → 500 max. Overridable via ImapClientConfig.fetchChunkSize /
468
+ * fetchChunkSizeMax. Slow servers benefit from smaller chunks (fewer timeouts). */
469
+ fetchChunkSize;
470
+ fetchChunkSizeMax;
467
471
  /** Active command timer — reset by handleData on every data arrival */
468
472
  commandTimer = null;
469
473
  sendCommand(tag, command) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/iflow-direct",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Direct IMAP client — transport-agnostic, no Node.js dependencies, browser-ready",
5
5
  "main": "index.js",
6
6
  "types": "index.ts",
package/types.d.ts CHANGED
@@ -11,5 +11,7 @@ export interface ImapClientConfig {
11
11
  verbose?: boolean;
12
12
  rejectUnauthorized?: boolean;
13
13
  inactivityTimeout?: number;
14
+ fetchChunkSize?: number;
15
+ fetchChunkSizeMax?: number;
14
16
  }
15
17
  //# sourceMappingURL=types.d.ts.map