@travetto/email-compiler 5.0.17 → 5.0.19

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 (3) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +10 -10
  3. package/src/util.ts +7 -5
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 ArcSine Technologies
3
+ Copyright (c) 2020 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/email-compiler",
3
- "version": "5.0.17",
3
+ "version": "5.0.19",
4
4
  "description": "Email compiling module",
5
5
  "keywords": [
6
6
  "email",
@@ -26,20 +26,20 @@
26
26
  "directory": "module/email-compiler"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/config": "^5.0.12",
30
- "@travetto/di": "^5.0.12",
31
- "@travetto/email": "^5.0.12",
32
- "@travetto/image": "^5.0.16",
33
- "@travetto/runtime": "^5.0.12",
34
- "@travetto/worker": "^5.0.14",
29
+ "@travetto/config": "^5.0.14",
30
+ "@travetto/di": "^5.0.14",
31
+ "@travetto/email": "^5.0.14",
32
+ "@travetto/image": "^5.0.18",
33
+ "@travetto/runtime": "^5.0.14",
34
+ "@travetto/worker": "^5.0.16",
35
35
  "@types/inline-css": "^3.0.3",
36
36
  "html-entities": "^2.5.2",
37
37
  "inline-css": "^4.0.2",
38
- "purgecss": "^6.0.0",
39
- "sass": "^1.80.4"
38
+ "purgecss": "^7.0.2",
39
+ "sass": "^1.83.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@travetto/cli": "^5.0.15"
42
+ "@travetto/cli": "^5.0.17"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@travetto/cli": {
package/src/util.ts CHANGED
@@ -11,13 +11,15 @@ type Tokenized = {
11
11
  finalize: (onToken: (token: string) => string) => string;
12
12
  };
13
13
 
14
+ const SUPPORT_SRC = /(support|src)\//;
15
+
14
16
  /**
15
17
  * Email compile tools
16
18
  */
17
19
  export class EmailCompileUtil {
18
20
  static #HTML_CSS_IMAGE_URLS = [
19
- /(?<pre><img[^>]src=\s*["'])(?<src>[^"{}]+)/g,
20
- /(?<pre>background(?:-image)?:\s*url[(]['"]?)(?<src>[^"'){}]+)/g
21
+ /(?<pre><img[^>]src=\s{0,10}["'])(?<src>[^"{}]{1,1000})/g,
22
+ /(?<pre>background(?:-image)?:\s{0,10}url[(]['"]?)(?<src>[^"'){}]{1,1000})/g
21
23
  ];
22
24
 
23
25
  static #EXT = /[.]email[.]tsx$/;
@@ -33,7 +35,7 @@ export class EmailCompileUtil {
33
35
  * Generate singular output path given a file
34
36
  */
35
37
  static buildOutputPath(file: string, suffix: string, prefix?: string): string {
36
- const res = file.replace(/.*(support|src)\//, '').replace(this.#EXT, suffix);
38
+ const res = (SUPPORT_SRC.test(file) ? file.split(SUPPORT_SRC)[1] : file).replace(this.#EXT, suffix);
37
39
  return prefix ? path.join(prefix, res) : res;
38
40
  }
39
41
 
@@ -68,7 +70,7 @@ export class EmailCompileUtil {
68
70
  text = text.replace(all, `${pre}${token}`);
69
71
  }
70
72
  }
71
- const finalize = (onToken: (token: string) => string): string => text.replace(/@@[^@]+@@/g, t => onToken(t));
73
+ const finalize = (onToken: (token: string) => string): string => text.replace(/@@[^@]{1,100}@@/g, t => onToken(t));
72
74
 
73
75
  return { text, tokens, finalize };
74
76
  }
@@ -161,7 +163,7 @@ export class EmailCompileUtil {
161
163
  static handleHtmlEdgeCases(html: string): string {
162
164
  return html
163
165
  .replace(/\n{3,100}/msg, '\n\n')
164
- .replace(/<(meta|img|link|hr|br)[^>]*>/g, a => a.replace('>', '/>')) // Fix self closing
166
+ .replace(/<(meta|img|link|hr|br)[^>]{0,200}>/g, a => a.replace(/>/g, '/>')) // Fix self closing
165
167
  .replace(/&apos;/g, '&#39;') // Fix apostrophes, as outlook hates them
166
168
  .replace(/(background(?:-color)?:\s*)([#0-9a-f]{6,8})([^>.#,]+)>/ig,
167
169
  (all, p, col, rest) => `${p}${col}${rest} bgcolor="${col}">`) // Inline bg-color