@maizzle/framework 5.0.0-beta.16 → 5.0.0-beta.18

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": "@maizzle/framework",
3
- "version": "5.0.0-beta.16",
3
+ "version": "5.0.0-beta.18",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -60,8 +60,6 @@ export async function render(html = '', config = {}) {
60
60
  * @param {string} options.html - The HTML to be transformed
61
61
  * @param {Object} options.matter - The front matter data
62
62
  * @param {Object} options.config - The current template config
63
- * @param {function} options.posthtml - The PostHTML compiler
64
- * @param {Object} options.transform - The transformers object
65
63
  * @returns {string} - The transformed HTML, or the original one if nothing was returned
66
64
  */
67
65
  if (typeof templateConfig.beforeRender === 'function') {
@@ -69,7 +67,6 @@ export async function render(html = '', config = {}) {
69
67
  html: content,
70
68
  matter: matterData,
71
69
  config: templateConfig,
72
- posthtml: compilePostHTML,
73
70
  })) ?? content
74
71
  }
75
72
 
@@ -83,8 +80,6 @@ export async function render(html = '', config = {}) {
83
80
  * @param {string} options.html - The HTML to be transformed
84
81
  * @param {Object} options.matter - The front matter data
85
82
  * @param {Object} options.config - The current template config
86
- * @param {function} options.posthtml - The PostHTML compiler
87
- * @param {Object} options.transform - The transformers object
88
83
  * @returns {string} - The transformed HTML, or the original one if nothing was returned
89
84
  */
90
85
  if (typeof templateConfig.afterRender === 'function') {
@@ -92,7 +87,6 @@ export async function render(html = '', config = {}) {
92
87
  html: compiled.html,
93
88
  matter: matterData,
94
89
  config: templateConfig,
95
- posthtml: compilePostHTML,
96
90
  })) ?? compiled.html
97
91
  }
98
92
 
@@ -118,8 +112,6 @@ export async function render(html = '', config = {}) {
118
112
  * @param {string} options.html - The HTML to be transformed
119
113
  * @param {Object} options.matter - The front matter data
120
114
  * @param {Object} options.config - The current template config
121
- * @param {function} options.posthtml - The PostHTML compiler
122
- * @param {Object} options.transform - The transformers object
123
115
  * @returns {string} - The transformed HTML, or the original one if nothing was returned
124
116
  */
125
117
  if (typeof templateConfig.afterTransformers === 'function') {
@@ -127,7 +119,6 @@ export async function render(html = '', config = {}) {
127
119
  html: compiled.html,
128
120
  matter: matterData,
129
121
  config: templateConfig,
130
- posthtml: compilePostHTML,
131
122
  })) ?? compiled.html
132
123
  }
133
124
 
@@ -63,7 +63,7 @@ export async function process(html = '', config = {}) {
63
63
  },
64
64
  ),
65
65
  },
66
- get(config, 'build.fetch', {})
66
+ get(config, 'fetch', {})
67
67
  )
68
68
  )
69
69
 
@@ -87,6 +87,8 @@ export async function process(html = '', config = {}) {
87
87
  ),
88
88
  expandLinkTag,
89
89
  postcssPlugin,
90
+ envTags(config.env),
91
+ envAttributes(config.env),
90
92
  ...get(config, 'posthtml.plugins.after', get(config, 'posthtml.plugins', []))
91
93
  ])
92
94
  .process(html, posthtmlOptions)
@@ -178,21 +178,6 @@ export async function run(html = '', config = {}) {
178
178
  posthtmlPlugins.push(
179
179
  baseUrl(get(config, 'baseURL', get(config, 'baseUrl', {})))
180
180
  )
181
- } else {
182
- /**
183
- * Set baseURL to `build.static.destination` if it's not already set.
184
- */
185
- const destination = get(config, 'build.static.destination', '')
186
- if (destination && !config._dev) {
187
- posthtmlPlugins.push(
188
- baseUrl({
189
- url: destination,
190
- allTags: true,
191
- styleTag: true,
192
- inlineCss: true,
193
- })
194
- )
195
- }
196
181
  }
197
182
 
198
183
  /**
@@ -15,9 +15,11 @@ const posthtmlPlugin = (replacements = {}) => tree => {
15
15
  render(tree).replace(patterns, matched => {
16
16
  for (const [regex, replacement] of regexes) {
17
17
  if (regex.test(matched)) {
18
- return replacement
18
+ return matched.replace(regex, replacement)
19
19
  }
20
20
  }
21
+
22
+ return matched
21
23
  }),
22
24
  defaultPostHTMLConfig
23
25
  )
package/types/config.d.ts CHANGED
@@ -12,6 +12,7 @@ import type WidowWordsConfig from './widowWords';
12
12
  import type { CoreBeautifyOptions } from 'js-beautify';
13
13
  import type { BaseURLConfig } from 'posthtml-base-url';
14
14
  import type URLParametersConfig from './urlParameters';
15
+ import type { PostHTMLFetchConfig } from 'posthtml-fetch';
15
16
  import type { PostHTMLComponents } from 'posthtml-component';
16
17
 
17
18
  import type { Config as TailwindConfig } from 'tailwindcss';
@@ -169,6 +170,11 @@ export default interface Config {
169
170
  tailwind?: TailwindConfig;
170
171
  }
171
172
 
173
+ /**
174
+ * Configure the [`<fetch>`](https://maizzle.com/docs/tags#fetch) tag.
175
+ */
176
+ fetch?: PostHTMLFetchConfig;
177
+
172
178
  /**
173
179
  * Transform text inside elements marked with custom attributes.
174
180
  * Filters work only on elements that contain only text.
package/types/events.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import type Config from "./config";
2
2
 
3
- type PostHTMLType = (html: string, config: Config) => { html: string; config: Config };
4
-
5
3
  export default interface Events {
6
4
  /**
7
5
  * Runs after the Environment config has been computed, but before Templates are processed.
@@ -18,7 +16,12 @@ export default interface Events {
18
16
  * }
19
17
  * ```
20
18
  */
21
- beforeCreate?: (params: { config: Config }) => void | Promise<void>;
19
+ beforeCreate?: (params: {
20
+ /**
21
+ * The computed Maizzle config object.
22
+ */
23
+ config: Config
24
+ }) => void | Promise<void>;
22
25
 
23
26
  /**
24
27
  * Runs after the Template's config has been computed, but just before it is compiled.
@@ -43,20 +46,15 @@ export default interface Events {
43
46
  */
44
47
  html: string;
45
48
  /**
46
- * The Template's Front Matter.
49
+ * The Template's Front Matter data.
47
50
  */
48
51
  matter: { [key: string]: string };
49
52
  /**
50
53
  * The Template's computed config.
51
- */
52
- config: Config;
53
- /**
54
- * A function to process an HTML string with PostHTML.
55
54
  *
56
- * @param {string} html The HTML string to process.
57
- * @param {Config} config The Maizzle config object.
55
+ * This is the Environment config merged with the Template's Front Matter.
58
56
  */
59
- posthtml: PostHTMLType;
57
+ config: Config;
60
58
  }) => string | Promise<string>;
61
59
 
62
60
  /**
@@ -82,20 +80,15 @@ export default interface Events {
82
80
  */
83
81
  html: string;
84
82
  /**
85
- * The Template's Front Matter.
83
+ * The Template's Front Matter data.
86
84
  */
87
85
  matter: { [key: string]: string };
88
86
  /**
89
87
  * The Template's computed config.
88
+ *
89
+ * This is the Environment config merged with the Template's Front Matter.
90
90
  */
91
91
  config: Config;
92
- /**
93
- * A function to process an HTML string with PostHTML.
94
- *
95
- * @param {string} html The HTML string to process.
96
- * @param {Config} config The Maizzle config object.
97
- */
98
- posthtml: PostHTMLType;
99
92
  }) => string | Promise<string>;
100
93
 
101
94
  /**
@@ -121,20 +114,15 @@ export default interface Events {
121
114
  */
122
115
  html: string;
123
116
  /**
124
- * The Template's Front Matter.
117
+ * The Template's Front Matter data.
125
118
  */
126
119
  matter: { [key: string]: string };
127
120
  /**
128
121
  * The Template's computed config.
122
+ *
123
+ * This is the Environment config merged with the Template's Front Matter.
129
124
  */
130
125
  config: Config;
131
- /**
132
- * A function to process an HTML string with PostHTML.
133
- *
134
- * @param {string} html The HTML string to process.
135
- * @param {Config} config The Maizzle config object.
136
- */
137
- posthtml: PostHTMLType;
138
126
  }) => string | Promise<string>;
139
127
 
140
128
  /**
@@ -146,7 +134,7 @@ export default interface Events {
146
134
  * @example
147
135
  * ```
148
136
  * export default {
149
- * afterBuild: async ({files, config}) => {
137
+ * afterBuild: async ({config, files}) => {
150
138
  * // do something...
151
139
  * }
152
140
  * }
@@ -154,12 +142,12 @@ export default interface Events {
154
142
  */
155
143
  afterBuild?: (params: {
156
144
  /**
157
- * An array of paths to all the files inside the `build.output.path` directory.
145
+ * The computed Maizzle config object.
158
146
  */
159
- files: string[];
147
+ config: Config;
160
148
  /**
161
- * The Maizzle config object.
149
+ * An array of paths to all the files inside the `build.output.path` directory.
162
150
  */
163
- config: Config;
151
+ files: string[];
164
152
  }) => string | Promise<string>;
165
153
  }