@travetto/email-compiler 3.3.0 → 3.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/email-compiler",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "Email compiling module",
5
5
  "keywords": [
6
6
  "email",
package/src/util.ts CHANGED
@@ -20,8 +20,8 @@ type Tokenized = {
20
20
  */
21
21
  export class EmailCompileUtil {
22
22
  static #HTML_CSS_IMAGE_URLS = [
23
- /(?<pre><img[^>]src=\s*["'])(?<src>[^"]+)/g,
24
- /(?<pre>background(?:-image)?:\s*url[(]['"]?)(?<src>[^"')]+)/g
23
+ /(?<pre><img[^>]src=\s*["'])(?<src>[^"{}]+)/g,
24
+ /(?<pre>background(?:-image)?:\s*url[(]['"]?)(?<src>[^"'){}]+)/g
25
25
  ];
26
26
 
27
27
  static #EXT = /[.]email[.]tsx$/;
@@ -148,7 +148,7 @@ export class EmailCompileUtil {
148
148
 
149
149
  const imageMap = new Map(await Promise.all(pendingImages.map(async ([token, ext, stream]) => {
150
150
  const data = await StreamUtil.streamToBuffer(await stream);
151
- return [token, `data:image/${ext};base64,${data.toString('base64')}`] as const;
151
+ return [token, `data:image/${ext.replace('.', '')};base64,${data.toString('base64')}`] as const;
152
152
  })));
153
153
 
154
154
  return finalize(token => imageMap.get(token)!);
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs/promises';
2
2
 
3
- import { RootIndex, path } from '@travetto/manifest';
3
+ import { IndexedModule, RootIndex, path } from '@travetto/manifest';
4
4
  import { YamlUtil } from '@travetto/yaml';
5
5
 
6
6
  interface ConfigType {
@@ -39,13 +39,18 @@ export class $EditorConfig {
39
39
  },
40
40
  };
41
41
 
42
+ #getEmailConfig(mod: IndexedModule): string {
43
+ return this.#configFile[mod.name] ??= path.resolve(mod.sourcePath, 'resources/email/dev.yml');
44
+ }
45
+
42
46
  /**
43
47
  *
44
48
  */
45
49
  async get(file: string): Promise<ConfigType> {
46
50
  try {
47
- const mod = RootIndex.getModuleFromSource(file)!.name;
48
- const content = await fs.readFile(this.#configFile[mod], 'utf8');
51
+ const mod = RootIndex.getModuleFromSource(file)!;
52
+ const resolved = this.#getEmailConfig(mod);
53
+ const content = await fs.readFile(resolved, 'utf8');
49
54
  return YamlUtil.parse<ConfigType>(content);
50
55
  } catch {
51
56
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
@@ -70,7 +75,7 @@ export class $EditorConfig {
70
75
  async ensureConfig(file: string): Promise<string> {
71
76
  console.log('Ensuring config', file);
72
77
  const mod = RootIndex.getModuleFromSource(file)!;
73
- const resolved = this.#configFile[mod.name] ??= path.resolve(mod.sourcePath, 'resources/email/dev.yml');
78
+ const resolved = this.#getEmailConfig(mod);
74
79
  if (!(await fs.stat(resolved).catch(() => { }))) {
75
80
  await fs.mkdir(path.dirname(resolved), { recursive: true });
76
81
  await fs.writeFile(resolved, this.getDefaultConfig(), { encoding: 'utf8' });