@maizzle/framework 4.7.5 → 4.7.6

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,10 +1,10 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "4.7.5",
3
+ "version": "4.7.6",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "main": "src/index.js",
7
- "types": "src/index.d.ts",
7
+ "types": "types/index.d.ts",
8
8
  "bin": {
9
9
  "maizzle": "bin/maizzle"
10
10
  },
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "files": [
40
40
  "src/**/*",
41
+ "types/**/*",
41
42
  "bin/*"
42
43
  ],
43
44
  "dependencies": {
@@ -78,6 +79,7 @@
78
79
  "tailwindcss": "^3.2.7"
79
80
  },
80
81
  "devDependencies": {
82
+ "@types/browser-sync": "^2.29.0",
81
83
  "@types/js-beautify": "^1.14.0",
82
84
  "@types/markdown-it": "^13.0.0",
83
85
  "ava": "^5.2.0",
@@ -0,0 +1,79 @@
1
+ export default interface BaseURLConfig {
2
+ /**
3
+ The URL to prepend.
4
+
5
+ @default undefined
6
+ */
7
+ url: string;
8
+
9
+ /**
10
+ Tags to apply the `url` to. When using this option, the `url` will only be prepended to the specified tags.
11
+
12
+ Maizzle uses a [custom set of tags](https://github.com/posthtml/posthtml-base-url/blob/main/lib/index.js#L6-L60) by default.
13
+
14
+ @example
15
+
16
+ Prepend `url` to all 'source'-like attribute values on image tags, like `src` and `srcset`:
17
+
18
+ ```
19
+ module.exports = {
20
+ baseURL: {
21
+ url: 'https://cdn.example.com/',
22
+ tags: ['img'],
23
+ },
24
+ }
25
+ ```
26
+
27
+ With more granular control:
28
+
29
+ ```
30
+ module.exports = {
31
+ baseURL: {
32
+ url: 'https://cdn.example.com/',
33
+ tags: {
34
+ img: {
35
+ src: true, // use the value of `url` above
36
+ srcset: 'https://bar.com/',
37
+ },
38
+ },
39
+ },
40
+ }
41
+ ```
42
+ */
43
+ tags?: string[] | Record<string, unknown>;
44
+
45
+ /**
46
+ Key-value pairs of attributes and the string to prepend to their existing value.
47
+
48
+ @default {}
49
+
50
+ @example
51
+
52
+ Prepend `https://example.com/` to all `data-url` attribute values:
53
+
54
+ ```
55
+ module.exports = {
56
+ baseURL: {
57
+ attributes: {
58
+ 'data-url': 'https://example.com/',
59
+ },
60
+ },
61
+ }
62
+ ```
63
+ */
64
+ attributes?: Record<string, unknown>;
65
+
66
+ /**
67
+ Whether the string defined in `url` should be prepended to `url()` values in CSS `<style>` tags.
68
+
69
+ @default true
70
+ */
71
+ styleTag?: boolean;
72
+
73
+ /**
74
+ Whether the string defined in `url` should be prepended to `url()` values in inline CSS.
75
+
76
+ @default true
77
+ */
78
+ inlineCss?: boolean;
79
+ }
@@ -0,0 +1,74 @@
1
+ import type LayoutsConfig from './layouts';
2
+ import type PostHTMLConfig from './posthtml';
3
+ import type TailwindConfig from './tailwind';
4
+ import type TemplatesConfig from './templates';
5
+ import type ComponentsConfig from './components';
6
+ import type {Options as BrowserSyncConfig} from 'browser-sync';
7
+
8
+ export default interface BuildConfig {
9
+ /**
10
+ Templates configuration.
11
+ */
12
+ templates: TemplatesConfig;
13
+
14
+ /**
15
+ Tailwind CSS configuration.
16
+ */
17
+ tailwind?: TailwindConfig;
18
+
19
+ /**
20
+ [DEPRECATED] Layouts configuration.
21
+ */
22
+ layouts?: LayoutsConfig;
23
+
24
+ /**
25
+ Components configuration.
26
+ */
27
+ components?: ComponentsConfig;
28
+
29
+ /**
30
+ PostHTML configuration.
31
+ */
32
+ posthtml?: PostHTMLConfig;
33
+
34
+ /**
35
+ Configure PostCSS
36
+ */
37
+ postcss?: {
38
+ /**
39
+ Additional PostCSS plugins that you would like to use.
40
+
41
+ @default []
42
+
43
+ @example
44
+ ```
45
+ const examplePlugin = require('postcss-example-plugin')
46
+ module.exports = {
47
+ build: {
48
+ postcss: {
49
+ plugins: [
50
+ examplePlugin()
51
+ ]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+ */
57
+ plugins?: any[];
58
+ };
59
+
60
+ /**
61
+ Browsersync configuration.
62
+
63
+ When you run the `maizzle serve` command, Maizzle uses [Browsersync](https://browsersync.io/)
64
+ to start a local development server and open a directory listing of your emails in your default browser.
65
+ */
66
+ browsersync?: BrowserSyncConfig;
67
+
68
+ /**
69
+ Configure how build errors are handled when developing with the Maizzle CLI.
70
+
71
+ @default undefined
72
+ */
73
+ fail?: 'silent' | 'verbose';
74
+ }
@@ -0,0 +1,177 @@
1
+ export default interface ComponentsConfig {
2
+ /**
3
+ Root path where to look for folders containing component files.
4
+
5
+ @default './'
6
+ */
7
+ root?: string;
8
+
9
+ /**
10
+ Paths where to look for component files. Must be relative to `root`.
11
+
12
+ @default ['src/components', 'src/layouts', 'src/templates']
13
+ */
14
+ folders?: string[];
15
+
16
+ /**
17
+ Prefix to use for component tags.
18
+
19
+ @default 'x-'
20
+ */
21
+ tagPrefix?: string;
22
+
23
+ /**
24
+ Tag name to be used in HTML when using a component.
25
+
26
+ @default 'component'
27
+ */
28
+ tag?: string;
29
+
30
+ /**
31
+ Attribute name to be used when referencing a component via its path.
32
+
33
+ @default 'src'
34
+ */
35
+ attribute?: string;
36
+
37
+ /**
38
+ File extension that component files must use.
39
+ Any other files will be ignored and not be made available as components.
40
+
41
+ @default 'html'
42
+ */
43
+ fileExtension?: string;
44
+
45
+ /**
46
+ Name of the tag that will be replaced with the content that is passed to the component.
47
+
48
+ @default 'content'
49
+ */
50
+ yield?: string;
51
+
52
+ /**
53
+ Name of the slot tag, where the content will be injected.
54
+
55
+ @default 'slot'
56
+ */
57
+ slot?: string;
58
+
59
+ /**
60
+ Name of the fill tag, where the content to be injected is defined.
61
+
62
+ @default 'fill'
63
+ */
64
+ fill?: string;
65
+
66
+ /**
67
+ String to use as a separator between the slot tag and its name.
68
+
69
+ @default ':'
70
+ */
71
+ slotSeparator?: string;
72
+
73
+ /**
74
+ Tag name for pushing content to a stack.
75
+
76
+ @default 'push'
77
+ */
78
+ push?: string;
79
+
80
+ /**
81
+ Tag name for popping (rendering) content from a stack.
82
+
83
+ @default 'stack'
84
+ */
85
+ stack?: string;
86
+
87
+ /**
88
+ Name of the props attribute to use in the `<script>` tag of a component.
89
+
90
+ @default 'props'
91
+ */
92
+ propsScriptAttribute?: string;
93
+
94
+ /**
95
+ Name of the object that will be used to store the props of a component.
96
+
97
+ @default 'props'
98
+ */
99
+ propsContext?: string;
100
+
101
+ /**
102
+ Name of the attribute that will be used to pass props to a component as JSON.
103
+
104
+ @default 'locals'
105
+ */
106
+ propsAttribute?: string;
107
+
108
+ /**
109
+ Name of the key to use when retrieving props passed to a slot via `$slots.slotName.props`.
110
+
111
+ @default 'props'
112
+ */
113
+ propsSlot?: string;
114
+
115
+ /**
116
+ Configure [`posthtml-parser`](https://github.com/posthtml/posthtml-parser).
117
+
118
+ @default {recognizeSelfClosing:true}
119
+ */
120
+ parserOptions?: Record<string, any>;
121
+
122
+ /**
123
+ Configure [`posthtml-expressions`](https://github.com/posthtml/posthtml-expressions).
124
+
125
+ @default {} // custom object
126
+ */
127
+ expressions?: Record<any, any>;
128
+
129
+ /**
130
+ PostHTML plugins to apply to each parsed component.
131
+
132
+ @default []
133
+ */
134
+ plugins?: any[];
135
+
136
+ /**
137
+ Extra rules for the PostHTML plugin that is used by components to parse attributes.
138
+
139
+ @default {}
140
+ */
141
+ attrsParserRules?: Record<any, any>;
142
+
143
+ /**
144
+ In strict mode, an error will be thrown if a component cannot be rendered.
145
+
146
+ @default true
147
+ */
148
+ strict?: boolean;
149
+
150
+ /**
151
+ Utility methods to be passed to `<script props>` in a component.
152
+
153
+ @default {merge: _.mergeWith, template: _.template}
154
+ */
155
+ utilities?: Record<string, unknown>;
156
+
157
+ /**
158
+ Define additional attributes that should be preserved for specific HTML elements.
159
+
160
+ @default {}
161
+ */
162
+ elementAttributes?: Record<string, void>;
163
+
164
+ /**
165
+ Attributes that should be preserved on all elements in components.
166
+
167
+ @default ['data-*']
168
+ */
169
+ safelistAttributes?: string[];
170
+
171
+ /**
172
+ Attributes that should be removed from all elements in components.
173
+
174
+ @default []
175
+ */
176
+ blacklistAttributes?: string[];
177
+ }
@@ -0,0 +1,341 @@
1
+ import type BuildConfig from './build';
2
+ import type InlineCSSConfig from './inlineCss';
3
+ import type RemoveUnusedCSSConfig from './removeUnusedCss';
4
+ import type WidowWordsConfig from './widowWords';
5
+ import type BaseURLConfig from './baseURL';
6
+ import type URLParametersConfig from './urlParameters';
7
+ import type {CoreBeautifyOptions} from 'js-beautify';
8
+ import type MinifyConfig from './minify';
9
+ import type MarkdownConfig from './markdown';
10
+ import type EventsConfig from './events';
11
+
12
+ export default interface Config {
13
+ [key: string]: any;
14
+
15
+ /**
16
+ Configure build settings.
17
+
18
+ @example
19
+ ```
20
+ module.exports = {
21
+ build: {
22
+ templates: TemplatesConfig,
23
+ tailwind: TailwindConfig,
24
+ layouts: LayoutsConfig,
25
+ components: ComponentsConfig,
26
+ posthtml: PostHTMLConfig,
27
+ browsersync: BrowserSyncConfig,
28
+ fail: 'silent' // or 'verbose'
29
+ }
30
+ }
31
+ ```
32
+ */
33
+ build: BuildConfig;
34
+
35
+ /**
36
+ Toggle the use of Transformers.
37
+
38
+ @default true
39
+
40
+ @example
41
+ ```
42
+ module.exports = {
43
+ applyTransformers: false,
44
+ }
45
+ ```
46
+ */
47
+ applyTransformers?: boolean;
48
+
49
+ /**
50
+ Configure CSS inlining.
51
+
52
+ To enable it with defaults, simply set it to `true`.
53
+ @example
54
+ ```js
55
+ module.exports = {
56
+ inlineCSS: true,
57
+ }
58
+ ```
59
+ */
60
+ inlineCSS?: boolean | InlineCSSConfig;
61
+
62
+ /**
63
+ Configure unused CSS purging.
64
+
65
+ To enable it with defaults, simply set it to `true`.
66
+ @example
67
+ ```
68
+ module.exports = {
69
+ removeUnusedCSS: true,
70
+ }
71
+ ```
72
+ */
73
+ removeUnusedCSS?: boolean | RemoveUnusedCSSConfig;
74
+
75
+ /**
76
+ Automatically remove HTML attributes.
77
+
78
+ By default, empty `style` and `class` attributes are removed.
79
+
80
+ @default ['style', 'class']
81
+
82
+ @example
83
+ ```
84
+ module.exports = {
85
+ removeAttributes: ['data-src']
86
+ }
87
+ ```
88
+ */
89
+ removeAttributes?:
90
+ | string[]
91
+ | Array<{
92
+ name: string;
93
+ value: string | RegExp;
94
+ }>;
95
+
96
+ /**
97
+ Prevent widow words inside a tag by adding a `&nbsp;` between its last two words.
98
+
99
+ @example
100
+ ```
101
+ module.exports = {
102
+ widowWords: true,
103
+ }
104
+ ```
105
+ */
106
+ widowWords?: WidowWordsConfig;
107
+
108
+ /**
109
+ [Add attributes](https://maizzle.com/docs/transformers/add-attributes) to elements in your HTML.
110
+
111
+ @default
112
+ {
113
+ table: {
114
+ cellpadding: 0,
115
+ cellspacing: 0,
116
+ role: 'none'
117
+ },
118
+ img: {
119
+ alt: ''
120
+ },
121
+ }
122
+ */
123
+ extraAttributes?: boolean | Record<string, unknown>;
124
+
125
+ /**
126
+ Normalize escaped character class names like `\:` or `\/` by replacing them with email-safe alternatives.
127
+
128
+ @example
129
+ ```
130
+ module.exports = {
131
+ safeClassNames: {
132
+ ':': '__',
133
+ '!': 'i-',
134
+ }
135
+ }
136
+ ```
137
+ */
138
+ safeClassNames?: boolean | Record<string, string>;
139
+
140
+ /**
141
+ Rewrite longhand CSS inside style attributes with shorthand syntax.
142
+ Only works with margin, padding and border, and only when all sides are specified.
143
+
144
+ @default []
145
+
146
+ @example
147
+ ```
148
+ module.exports = {
149
+ shorthandCSS: true, // or ['td', 'div'] to only apply to those tags
150
+ }
151
+ ```
152
+ */
153
+ shorthandCSS?: boolean | string[];
154
+
155
+ /**
156
+ Define a string that will be prepended to sources and hrefs in your HTML and CSS.
157
+
158
+ @example
159
+
160
+ Prepend to all sources and hrefs:
161
+
162
+ ```
163
+ module.exports = {
164
+ baseURL: 'https://cdn.example.com/'
165
+ }
166
+ ```
167
+
168
+ Prepend only to `src` attributes on image tags:
169
+
170
+ ```
171
+ module.exports = {
172
+ baseURL: {
173
+ url: 'https://cdn.example.com/',
174
+ tags: ['img'],
175
+ },
176
+ }
177
+ ```
178
+ */
179
+ baseURL?: string | BaseURLConfig;
180
+
181
+ /**
182
+ Transform text inside elements marked with custom attributes.
183
+
184
+ Filters work only on elements that contain only text.
185
+
186
+ @default {}
187
+
188
+ @example
189
+ ```
190
+ module.exports = {
191
+ filters: {
192
+ uppercase: str => str.toUpperCase()
193
+ }
194
+ }
195
+ ```
196
+ */
197
+ filters: Record<string, unknown>;
198
+
199
+ /**
200
+ Define variables outside of the `page` object.
201
+
202
+ @default {}
203
+
204
+ @example
205
+ ```
206
+ module.exports = {
207
+ locals: {
208
+ company: {
209
+ name: 'Spacely Space Sprockets, Inc.'
210
+ }
211
+ }
212
+ }
213
+ ```
214
+
215
+ `company` can be then used like this:
216
+
217
+ ```
218
+ <p>{{ company.name }}</p>
219
+ ```
220
+ */
221
+ locals?: Record<string, unknown>;
222
+
223
+ /**
224
+ Configure custom parameters to append to URLs.
225
+
226
+ @example
227
+ ```
228
+ module.exports = {
229
+ urlParameters: {
230
+ _options: {
231
+ tags: ['a'],
232
+ qs: {}, // options for the `query-string` library
233
+ },
234
+ utm_source: 'maizzle',
235
+ utm_campaign: 'Campaign Name',
236
+ utm_medium: 'email',
237
+ custom_parameter: 'foo',
238
+ '1stOfApril': 'bar',
239
+ }
240
+ }
241
+ ```
242
+ */
243
+ urlParameters?: URLParametersConfig;
244
+
245
+ /**
246
+ Ensure that all your HEX colors inside `bgcolor` and `color` attributes are defined with six digits.
247
+
248
+ @default true
249
+
250
+ @example
251
+ ```
252
+ module.exports = {
253
+ sixHex: false,
254
+ }
255
+ ```
256
+ */
257
+ sixHex?: boolean;
258
+
259
+ /**
260
+ [Pretty print](https://maizzle.com/docs/transformers/prettify) your HTML email code so that it's nicely indented and more human-readable.
261
+
262
+ @default undefined
263
+
264
+ @example
265
+ ```
266
+ module.exports = {
267
+ prettify: true,
268
+ }
269
+ ```
270
+ */
271
+ prettify?: boolean | CoreBeautifyOptions;
272
+
273
+ /**
274
+ Minify the compiled HTML email code.
275
+
276
+ @default false
277
+
278
+ @example
279
+ ```
280
+ module.exports = {
281
+ minify: true,
282
+ }
283
+ ```
284
+ */
285
+ minify?: boolean | MinifyConfig;
286
+
287
+ /**
288
+ Configure the Markdown parser.
289
+
290
+ @example
291
+
292
+ ```
293
+ module.exports = {
294
+ markdown: {
295
+ root: './', // A path relative to which markdown files are imported
296
+ encoding: 'utf8', // Encoding for imported Markdown files
297
+ markdownit: {}, // Options passed to markdown-it
298
+ plugins: [], // Plugins for markdown-it
299
+ }
300
+ }
301
+ ```
302
+ */
303
+ markdown?: MarkdownConfig;
304
+
305
+ /**
306
+ Batch-replace strings in your HTML.
307
+
308
+ @default {}
309
+
310
+ @example
311
+ ```
312
+ module.exports = {
313
+ replaceStrings: {
314
+ 'replace this exact string': 'with this one',
315
+ '\\s?data-src=""': '', // remove empty data-src="" attributes
316
+ }
317
+ }
318
+ ```
319
+ */
320
+ replaceStrings?: Record<string, string>;
321
+
322
+ /**
323
+ When compiling your email templates, Maizzle goes through a series of steps like generating a Template config, rendering, or applying Transformers.
324
+ You can hook into the build process and manipulate it by using functions that run before or after some of these steps.
325
+
326
+ @default {}
327
+
328
+ @example
329
+ ```
330
+ module.exports = {
331
+ events: {
332
+ beforeRender: async (html, config) => {
333
+ // do something with html and config
334
+ return html;
335
+ },
336
+ }
337
+ }
338
+ ```
339
+ */
340
+ events?: EventsConfig;
341
+ }