@travetto/email-compiler 6.0.0 → 7.0.0-rc.0

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": "6.0.0",
3
+ "version": "7.0.0-rc.0",
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": "^6.0.0",
30
- "@travetto/di": "^6.0.0",
31
- "@travetto/email": "^6.0.0",
32
- "@travetto/image": "^6.0.0",
33
- "@travetto/runtime": "^6.0.0",
34
- "@travetto/worker": "^6.0.0",
35
- "@types/inline-css": "^3.0.3",
29
+ "@travetto/config": "^7.0.0-rc.0",
30
+ "@travetto/di": "^7.0.0-rc.0",
31
+ "@travetto/email": "^7.0.0-rc.0",
32
+ "@travetto/image": "^7.0.0-rc.0",
33
+ "@travetto/runtime": "^7.0.0-rc.0",
34
+ "@travetto/worker": "^7.0.0-rc.0",
35
+ "@types/inline-css": "^3.0.4",
36
36
  "html-entities": "^2.6.0",
37
37
  "inline-css": "^4.0.3",
38
38
  "purgecss": "^7.0.2",
39
- "sass": "^1.87.0"
39
+ "sass": "^1.94.2"
40
40
  },
41
41
  "peerDependencies": {
42
- "@travetto/cli": "^6.0.0"
42
+ "@travetto/cli": "^7.0.0-rc.0"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@travetto/cli": {
package/src/util.ts CHANGED
@@ -13,29 +13,30 @@ type Tokenized = {
13
13
 
14
14
  const SUPPORT_SRC = /(?:support|src)\//;
15
15
 
16
+ const HTML_CSS_IMAGE_URLS = [
17
+ /(?<pre><img[^>]src=\s{0,10}["'])(?<src>[^"{}]{1,1000})/g,
18
+ /(?<pre>background(?:-image)?:\s{0,10}url[(]['"]?)(?<src>[^"'){}]{1,1000})/g
19
+ ];
20
+
21
+ const EXT = /[.]email[.]tsx$/;
22
+
16
23
  /**
17
24
  * Email compile tools
18
25
  */
19
26
  export class EmailCompileUtil {
20
- static #HTML_CSS_IMAGE_URLS = [
21
- /(?<pre><img[^>]src=\s{0,10}["'])(?<src>[^"{}]{1,1000})/g,
22
- /(?<pre>background(?:-image)?:\s{0,10}url[(]['"]?)(?<src>[^"'){}]{1,1000})/g
23
- ];
24
-
25
- static #EXT = /[.]email[.]tsx$/;
26
27
 
27
28
  /**
28
29
  * Is file a template?
29
30
  */
30
31
  static isTemplateFile(file: string): boolean {
31
- return this.#EXT.test(file);
32
+ return EXT.test(file);
32
33
  }
33
34
 
34
35
  /**
35
36
  * Generate singular output path given a file
36
37
  */
37
38
  static buildOutputPath(file: string, suffix: string, prefix?: string): string {
38
- const res = (SUPPORT_SRC.test(file) ? file.split(SUPPORT_SRC)[1] : file).replace(this.#EXT, suffix);
39
+ const res = (SUPPORT_SRC.test(file) ? file.split(SUPPORT_SRC)[1] : file).replace(EXT, suffix);
39
40
  return prefix ? path.join(prefix, res) : res;
40
41
  }
41
42
 
@@ -133,7 +134,7 @@ export class EmailCompileUtil {
133
134
  * Inline image sources
134
135
  */
135
136
  static async inlineImages(html: string, opts: EmailTemplateResource): Promise<string> {
136
- const { tokens, finalize } = await this.tokenizeResources(html, this.#HTML_CSS_IMAGE_URLS);
137
+ const { tokens, finalize } = await this.tokenizeResources(html, HTML_CSS_IMAGE_URLS);
137
138
  const pendingImages: [token: string, ext: string, stream: Buffer | Promise<Buffer>][] = [];
138
139
 
139
140
  for (const [token, src] of tokens) {
@@ -1,6 +1,7 @@
1
1
  import { MailService, EmailOptions, MailTransport } from '@travetto/email';
2
- import { DependencyRegistry, Injectable } from '@travetto/di';
2
+ import { DependencyRegistryIndex, Injectable } from '@travetto/di';
3
3
  import { toConcrete } from '@travetto/runtime';
4
+ import { Registry } from '@travetto/registry';
4
5
 
5
6
  import { EditorConfig } from './config.ts';
6
7
 
@@ -15,20 +16,24 @@ export class EditorSendService {
15
16
  async service(): Promise<MailService> {
16
17
  const MailTransportTarget = toConcrete<MailTransport>();
17
18
 
18
- const transports = DependencyRegistry.getCandidateTypes(MailTransportTarget);
19
+ const transports = DependencyRegistryIndex.getCandidates(MailTransportTarget);
19
20
 
20
21
  if (!transports.length) {
21
22
  try {
22
23
  const { NodemailerTransport } = await import('@travetto/email-nodemailer');
23
24
  const senderConfig = await EditorConfig.get('sender');
24
25
  const cls = class { };
25
- DependencyRegistry.registerFactory({
26
- fn: () => new NodemailerTransport(senderConfig),
27
- target: MailTransportTarget,
28
- src: cls,
29
- id: 'nodemailer',
26
+ DependencyRegistryIndex.getForRegister(cls).register({
27
+ candidates: {
28
+ factory: {
29
+ candidateType: MailTransportTarget,
30
+ factory: () => new NodemailerTransport(senderConfig),
31
+ class: cls,
32
+ method: 'factory',
33
+ }
34
+ }
30
35
  });
31
- DependencyRegistry.install(cls, { curr: cls, type: 'added' });
36
+ Registry.process([{ type: 'added', curr: cls }]);
32
37
 
33
38
  this.ethereal = !!senderConfig.host?.includes('ethereal.email');
34
39
  } catch {
@@ -36,7 +41,7 @@ export class EditorSendService {
36
41
  throw new Error('A mail transport is currently needed to support sending emails. Please install @travetto/email-nodemailer or any other compatible transport');
37
42
  }
38
43
  }
39
- return await DependencyRegistry.getInstance(MailService);
44
+ return await DependencyRegistryIndex.getInstance(MailService);
40
45
  }
41
46
 
42
47
  /**
@@ -1,4 +1,4 @@
1
- import { RootRegistry } from '@travetto/registry';
1
+ import { Registry } from '@travetto/registry';
2
2
  import { CliCommandShape, CliCommand, cliTpl } from '@travetto/cli';
3
3
  import { Env, Runtime } from '@travetto/runtime';
4
4
 
@@ -20,7 +20,7 @@ export class EmailCompileCommand implements CliCommandShape {
20
20
  }
21
21
 
22
22
  async main(): Promise<void> {
23
- await RootRegistry.init();
23
+ await Registry.init();
24
24
 
25
25
  // Let the engine template
26
26
  const all = await EmailCompiler.compileAll();
@@ -1,7 +1,7 @@
1
1
  import { Env } from '@travetto/runtime';
2
2
  import { CliCommand, CliUtil } from '@travetto/cli';
3
- import { RootRegistry } from '@travetto/registry';
4
- import { DependencyRegistry } from '@travetto/di';
3
+ import { Registry } from '@travetto/registry';
4
+ import { DependencyRegistryIndex } from '@travetto/di';
5
5
 
6
6
  import { EditorService } from './bin/editor.ts';
7
7
 
@@ -19,8 +19,8 @@ export class EmailEditorCommand {
19
19
  return;
20
20
  }
21
21
 
22
- await RootRegistry.init();
23
- const service = await DependencyRegistry.getInstance(EditorService);
22
+ await Registry.init();
23
+ const service = await DependencyRegistryIndex.getInstance(EditorService);
24
24
  await service.listen();
25
25
  }
26
26
  }
@@ -1,8 +1,8 @@
1
1
  import path from 'node:path';
2
2
 
3
- import { RootRegistry } from '@travetto/registry';
3
+ import { Registry } from '@travetto/registry';
4
4
  import { CliCommandShape, CliCommand } from '@travetto/cli';
5
- import { DependencyRegistry } from '@travetto/di';
5
+ import { DependencyRegistryIndex } from '@travetto/di';
6
6
  import { Env } from '@travetto/runtime';
7
7
 
8
8
  import { EditorService } from './bin/editor.ts';
@@ -19,8 +19,8 @@ export class EmailTestCommand implements CliCommandShape {
19
19
 
20
20
  async main(file: string, to: string): Promise<void> {
21
21
  file = path.resolve(file);
22
- await RootRegistry.init();
23
- const editor = await DependencyRegistry.getInstance(EditorService);
22
+ await Registry.init();
23
+ const editor = await DependencyRegistryIndex.getInstance(EditorService);
24
24
  await editor.sendFile(file, to);
25
25
  }
26
26
  }