postal-mime 2.1.0 → 2.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.1](https://github.com/postalsys/postal-mime/compare/v2.1.0...v2.1.1) (2024-02-26)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **types:** Updated types for PostalMime ([bc90f6d](https://github.com/postalsys/postal-mime/commit/bc90f6d5b7d3e2475cece77bb094caf421dead97))
9
+
3
10
  ## [2.1.0](https://github.com/postalsys/postal-mime/compare/v2.0.2...v2.1.0) (2024-02-22)
4
11
 
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postal-mime",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Email parser for browser environments",
5
5
  "main": "./src/postal-mime.js",
6
6
  "exports": {
@@ -27,10 +27,11 @@
27
27
  "author": "Andris Reinman",
28
28
  "license": "MIT-0",
29
29
  "devDependencies": {
30
+ "@types/node": "20.11.20",
30
31
  "cross-blob": "3.0.2",
31
- "eslint": "8.56.0",
32
+ "cross-env": "7.0.3",
33
+ "eslint": "8.57.0",
32
34
  "eslint-cli": "1.1.1",
33
- "iframe-resizer": "4.3.9",
34
- "cross-env": "7.0.3"
35
+ "iframe-resizer": "4.3.9"
35
36
  }
36
37
  }
package/postal-mime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type RawEmail = string | ArrayBuffer | Blob | Buffer;
1
+ export type RawEmail = string | ArrayBuffer | Uint8Array | Blob | Buffer | ReadableStream;
2
2
 
3
3
  export type Header = Record<string, string>;
4
4
 
@@ -13,7 +13,7 @@ export type Attachment = {
13
13
  disposition: "attachment" | "inline" | null;
14
14
  related?: boolean;
15
15
  contentId?: string;
16
- content: ArrayBuffer;
16
+ content: Uint8Array;
17
17
  };
18
18
 
19
19
  export type Email = {
@@ -317,30 +317,31 @@ export default class PostalMime {
317
317
  }
318
318
  this.started = true;
319
319
 
320
- // check if the input is a readable stream and resolve it into an ArrayBuffer
320
+ // Check if the input is a readable stream and resolve it into an ArrayBuffer
321
321
  if (buf && typeof buf.getReader === 'function') {
322
322
  buf = await this.resolveStream(buf);
323
323
  }
324
324
 
325
- // should it thrown on empty value instead?
325
+ // Should it throw for an empty value instead of defaulting to an empty ArrayBuffer?
326
326
  buf = buf || ArrayBuffer(0);
327
327
 
328
+ // Cast string input to Uint8Array
328
329
  if (typeof buf === 'string') {
329
- // cast string input to ArrayBuffer
330
330
  buf = textEncoder.encode(buf);
331
331
  }
332
332
 
333
+ // Cast Blob to ArrayBuffer
333
334
  if (buf instanceof Blob || Object.prototype.toString.call(buf) === '[object Blob]') {
334
- // can't process blob directly, cast to ArrayBuffer
335
335
  buf = await blobToArrayBuffer(buf);
336
336
  }
337
337
 
338
+ // Cast Node.js Buffer object or Uint8Array into ArrayBuffer
338
339
  if (buf.buffer instanceof ArrayBuffer) {
339
- // Node.js Buffer object or Uint8Array
340
340
  buf = new Uint8Array(buf).buffer;
341
341
  }
342
342
 
343
343
  this.buf = buf;
344
+
344
345
  this.av = new Uint8Array(buf);
345
346
  this.readPos = 0;
346
347