arn-rawmime 0.1.3 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arn-rawmime",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "A lightweight, dependency-free raw MIME email builder with DKIM support.",
5
5
  "author": "ARNDESK",
6
6
  "type": "module",
@@ -40,6 +40,11 @@ export class MimeMessage {
40
40
  */
41
41
  setBoundaryStyle(style: "google" | "outlook" | "apple-mail"): void;
42
42
 
43
+ /**
44
+ * Sets whether to preserve the exact insertion order of MIME parts.
45
+ */
46
+ setPreserveOrder(flag?: boolean): void;
47
+
43
48
  /**
44
49
  * Sets the Date header using a specific Time Zone or a random US Time Zone.
45
50
  * @param options Configuration object.
@@ -60,7 +65,6 @@ export class MimeMessage {
60
65
  data: string | Buffer;
61
66
  encoding?: "quoted-printable" | "base64" | "7bit" | "8bit";
62
67
  charset?: "UTF-8" | "ISO-8859-1" | "US-ASCII" | (string & {});
63
- autoMinify?: boolean;
64
68
  }): void;
65
69
 
66
70
  /**
@@ -30,6 +30,11 @@ class MimeMessage {
30
30
  this.processingPromises = [];
31
31
  this.removedHeaders = new Set();
32
32
  this.boundaryStyle = "google";
33
+ this.preserveOrder = false;
34
+ }
35
+
36
+ setPreserveOrder(flag = true) {
37
+ this.preserveOrder = !!flag;
33
38
  }
34
39
 
35
40
  setBoundaryStyle(style) {
@@ -475,12 +480,8 @@ class MimeMessage {
475
480
  }
476
481
 
477
482
  // Default encoding is now 'quoted-printable'
478
- addText({ data, encoding = "quoted-printable", charset = "UTF-8", autoMinify = false }) {
479
- let finalData = data;
480
- if (autoMinify && typeof finalData === "string") {
481
- finalData = finalData.replace(/\s+/g, " ").trim();
482
- }
483
- this._addBodyPart(finalData, "text/plain", encoding, charset);
483
+ addText({ data, encoding = "quoted-printable", charset = "UTF-8" }) {
484
+ this._addBodyPart(data, "text/plain", encoding, charset);
484
485
  }
485
486
 
486
487
  /**
@@ -652,7 +653,9 @@ class MimeMessage {
652
653
  console.warn(`[MimeMessage] Warning: Multiple text/html parts added (${htmls.length}). Most email clients will only display the last text/html part.`);
653
654
  }
654
655
 
655
- this.bodyParts = [...texts, ...htmls];
656
+ if (!this.preserveOrder) {
657
+ this.bodyParts = [...texts, ...htmls];
658
+ }
656
659
 
657
660
  let body = "";
658
661
  const numAttachments = this.attachments.length;