@travetto/email-compiler 3.4.0-rc.7 → 3.4.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": "3.4.0-rc.7",
3
+ "version": "3.4.0",
4
4
  "description": "Email compiling module",
5
5
  "keywords": [
6
6
  "email",
@@ -26,12 +26,12 @@
26
26
  "directory": "module/email-compiler"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/base": "^3.4.0-rc.7",
30
- "@travetto/config": "^3.4.0-rc.7",
31
- "@travetto/di": "^3.4.0-rc.7",
32
- "@travetto/email": "^3.4.0-rc.7",
33
- "@travetto/image": "^3.4.0-rc.7",
34
- "@travetto/worker": "^3.4.0-rc.7",
29
+ "@travetto/base": "^3.4.0",
30
+ "@travetto/config": "^3.4.0",
31
+ "@travetto/di": "^3.4.0",
32
+ "@travetto/email": "^3.4.0",
33
+ "@travetto/image": "^3.4.0",
34
+ "@travetto/worker": "^3.4.0",
35
35
  "@types/inline-css": "^3.0.2",
36
36
  "html-entities": "^2.4.0",
37
37
  "inline-css": "^4.0.2",
@@ -39,7 +39,7 @@
39
39
  "sass": "^1.69.5"
40
40
  },
41
41
  "peerDependencies": {
42
- "@travetto/cli": "^3.4.0-rc.9"
42
+ "@travetto/cli": "^3.4.0"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@travetto/cli": {
package/src/compiler.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs/promises';
2
2
 
3
- import { CompilerClient, FileResourceProvider, TypedObject } from '@travetto/base';
3
+ import { CompilerClient, TypedObject } from '@travetto/base';
4
4
  import { EmailCompileSource, EmailCompiled, EmailCompileContext, MailUtil } from '@travetto/email';
5
5
  import { RootIndex, path } from '@travetto/manifest';
6
6
  import { ManualAsyncIterator as Queue } from '@travetto/worker';
@@ -118,9 +118,15 @@ export class EmailCompiler {
118
118
  * Watch compilation
119
119
  */
120
120
  static async * watchCompile(): AsyncIterable<string> {
121
- const all = FileResourceProvider.resolveSearchPaths(
122
- this.findAllTemplates().map(x => `${RootIndex.getEntry(x)!.module}#resources`)
123
- );
121
+ const all = this.findAllTemplates()
122
+ .map(x => RootIndex.resolveModulePath(`${RootIndex.getEntry(x)!.module}#resources`))
123
+ .reduce<{ set: Set<string>, arr: string[] }>((a, v) => {
124
+ if (!a.set.has(v)) {
125
+ a.set.add(v);
126
+ a.arr.push(v);
127
+ }
128
+ return a;
129
+ }, { set: new Set(), arr: [] }).arr;
124
130
 
125
131
  const ctrl = new AbortController();
126
132
  const stream = new Queue<WatchEvent>([], ctrl.signal);
package/src/util.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import util from 'util';
2
2
  import { Readable } from 'stream';
3
3
 
4
- import { FileResourceProvider, StreamUtil } from '@travetto/base';
4
+ import { ResourceLoader, StreamUtil } from '@travetto/base';
5
5
  import {
6
6
  EmailTemplateImageConfig, EmailTemplateStyleConfig,
7
7
  EmailCompiled, EmailCompileContext
@@ -137,7 +137,7 @@ export class EmailCompileUtil {
137
137
  static async inlineImages(html: string, opts: EmailTemplateImageConfig): Promise<string> {
138
138
  const { tokens, finalize } = await this.tokenizeResources(html, this.#HTML_CSS_IMAGE_URLS);
139
139
  const pendingImages: [token: string, ext: string, stream: Readable | Promise<Readable>][] = [];
140
- const resource = new FileResourceProvider({ includeCommon: true, paths: opts.search ?? [] });
140
+ const resource = new ResourceLoader(opts.search);
141
141
 
142
142
  for (const [token, src] of tokens) {
143
143
  const ext = path.extname(src);
@@ -183,7 +183,7 @@ export class EmailCompileUtil {
183
183
  styles.push(opts.global);
184
184
  }
185
185
 
186
- const resource = new FileResourceProvider({ includeCommon: true, paths: opts.search ?? [] });
186
+ const resource = new ResourceLoader(opts.search);
187
187
  const main = await resource.read('/email/main.scss').then(d => d, () => '');
188
188
 
189
189
  if (main) {
@@ -1,6 +1,6 @@
1
1
  import { RootRegistry } from '@travetto/registry';
2
2
  import { CliCommandShape, CliCommand, cliTpl } from '@travetto/cli';
3
- import { Env, GlobalEnvConfig } from '@travetto/base';
3
+ import { Env, EnvInit } from '@travetto/base';
4
4
 
5
5
  import { EmailCompiler } from '../src/compiler';
6
6
 
@@ -13,16 +13,12 @@ export class EmailCompileCommand implements CliCommandShape {
13
13
  /** Compile in watch mode */
14
14
  watch?: boolean;
15
15
 
16
- envInit(): GlobalEnvConfig {
17
- return {
18
- debug: false,
19
- dynamic: this.watch,
20
- };
16
+ envInit(): EnvInit {
17
+ Env.addToList('TRV_PROFILES', 'email-dev');
18
+ return { debug: false, dynamic: this.watch };
21
19
  }
22
20
 
23
21
  async main(): Promise<void> {
24
- Env.addToList('TRV_PROFILES', 'email-dev');
25
-
26
22
  await RootRegistry.init();
27
23
 
28
24
  // Let the engine template
@@ -1,4 +1,4 @@
1
- import { Env, GlobalEnvConfig } from '@travetto/base';
1
+ import { Env, EnvInit } from '@travetto/base';
2
2
  import { CliCommand, CliUtil } from '@travetto/cli';
3
3
  import { RootRegistry } from '@travetto/registry';
4
4
 
@@ -9,11 +9,9 @@ import { EmailCompilationManager } from './bin/manager';
9
9
  @CliCommand()
10
10
  export class EmailEditorCommand {
11
11
 
12
- envInit(): GlobalEnvConfig {
13
- return {
14
- envName: 'dev',
15
- dynamic: true
16
- };
12
+ envInit(): EnvInit {
13
+ Env.addToList('TRV_PROFILES', 'email-dev');
14
+ return { envName: 'dev', dynamic: true };
17
15
  }
18
16
 
19
17
  async main(): Promise<void> {
@@ -21,8 +19,6 @@ export class EmailEditorCommand {
21
19
  return;
22
20
  }
23
21
 
24
- Env.addToList('TRV_PROFILES', 'email-dev');
25
-
26
22
  await RootRegistry.init();
27
23
  await new EditorState(await EmailCompilationManager.createInstance()).init();
28
24
  }
@@ -1,7 +1,7 @@
1
1
  import { path } from '@travetto/manifest';
2
2
  import { RootRegistry } from '@travetto/registry';
3
3
  import { CliCommandShape, CliCommand } from '@travetto/cli';
4
- import { Env, GlobalEnvConfig } from '@travetto/base';
4
+ import { Env, EnvInit } from '@travetto/base';
5
5
 
6
6
  import { EmailCompilationManager } from './bin/manager';
7
7
  import { EditorConfig } from './bin/config';
@@ -15,13 +15,12 @@ import { EmailCompiler } from '../src/compiler';
15
15
  @CliCommand()
16
16
  export class EmailTestCommand implements CliCommandShape {
17
17
 
18
- envInit(): GlobalEnvConfig {
18
+ envInit(): EnvInit {
19
+ Env.addToList('TRV_PROFILES', 'email-dev');
19
20
  return { envName: 'dev' };
20
21
  }
21
22
 
22
23
  async main(file: string, to: string): Promise<void> {
23
- Env.addToList('TRV_PROFILES', 'email-dev');
24
-
25
24
  file = path.resolve(file);
26
25
  await RootRegistry.init();
27
26
  await EmailCompiler.compile(file, true);