@maizzle/framework 4.7.5 → 4.8.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.
@@ -0,0 +1,195 @@
1
+ import type PostHTMLFetchConfig from './fetch';
2
+ import type ExpressionsConfig from './expressions';
3
+
4
+ export interface PostHTMLOptions {
5
+ /**
6
+ Configure the PostHTML parser to process custom directives.
7
+
8
+ @default []
9
+ */
10
+ directives?: any[];
11
+
12
+ /**
13
+ Enable `xmlMode` if you're using Maizzle to output XML content, and not actual HTML.
14
+
15
+ @default false
16
+ */
17
+ xmlMode?: boolean;
18
+
19
+ /**
20
+ Decode entities in the HTML.
21
+
22
+ @default false
23
+ */
24
+ decodeEntities?: boolean;
25
+
26
+ /**
27
+ Output all tags in lowercase. Works only when `xmlMode` is disabled.
28
+
29
+ @default false
30
+ */
31
+ lowerCaseTags?: boolean;
32
+
33
+ /**
34
+ Output all attribute names in lowercase.
35
+
36
+ @default false
37
+ */
38
+ lowerCaseAttributeNames?: boolean;
39
+
40
+ /**
41
+ Recognize CDATA sections as text even if the `xmlMode` option is disabled.
42
+
43
+ @default false
44
+ */
45
+ recognizeCDATA?: boolean;
46
+
47
+ /**
48
+ Recognize self-closing tags.
49
+ Disabling this will cause rendering to stop at the first self-closing custom (non-HTML) tag.
50
+
51
+ @default true
52
+ */
53
+ recognizeSelfClosing?: boolean;
54
+
55
+ /**
56
+ If enabled, AST nodes will have a location property containing the `start` and `end` line and column position of the node.
57
+
58
+ @default false
59
+ */
60
+ sourceLocations?: boolean;
61
+
62
+ /**
63
+ Whether attributes with no values should render exactly as they were written, without `=""` appended.
64
+
65
+ @default true
66
+ */
67
+ recognizeNoValueAttribute?: boolean;
68
+
69
+ /**
70
+ Tell PostHTML to treat custom tags as self-closing.
71
+
72
+ @default []
73
+ */
74
+ singleTags?: string[] | RegExp[];
75
+
76
+ /**
77
+ Define the closing format for single tags.
78
+
79
+ @default 'default'
80
+ */
81
+ closingSingleTag?: 'tag' | 'slash';
82
+
83
+ /**
84
+ Whether to quote all attribute values.
85
+
86
+ @default true
87
+ */
88
+ quoteAllAttributes?: boolean;
89
+
90
+ /**
91
+ Replaces quotes in attribute values with `&quote;`.
92
+
93
+ @default true
94
+ */
95
+ replaceQuote?: boolean;
96
+
97
+ /**
98
+ Specify the style of quote around the attribute values.
99
+
100
+ @default 2
101
+
102
+ @example
103
+
104
+ `0` - Quote style is based on attribute values (an alternative for `replaceQuote` option)
105
+
106
+ ```
107
+ <img src="example.jpg" onload='testFunc("test")'>
108
+ ```
109
+
110
+ @example
111
+
112
+ `1` - Attribute values are wrapped in single quotes
113
+
114
+ ```
115
+ <img src='example.jpg' onload='testFunc("test")'>
116
+ ```
117
+
118
+ @example
119
+
120
+ `2` - Attribute values are wrapped in double quotes
121
+
122
+ ```
123
+ <img src="example.jpg" onload="testFunc("test")">
124
+ ```
125
+ */
126
+ quoteStyle?: 0 | 1 | 2;
127
+ }
128
+
129
+ export default interface PostHTMLConfig {
130
+ /**
131
+ Configure expressions.
132
+ */
133
+ expressions?: ExpressionsConfig;
134
+
135
+ /**
136
+ Configure PostHTML options.
137
+ */
138
+ options?: PostHTMLOptions;
139
+
140
+ /**
141
+ Additional PostHTML plugins that you would like to use.
142
+
143
+ These will run last, after components.
144
+
145
+ @default []
146
+
147
+ @example
148
+ ```
149
+ const spaceless = require('posthtml-spaceless')
150
+ module.exports = {
151
+ build: {
152
+ posthtml: {
153
+ plugins: [
154
+ spaceless()
155
+ ]
156
+ }
157
+ }
158
+ }
159
+ ```
160
+ */
161
+ plugins?: any[];
162
+
163
+ /**
164
+ Configure the `posthtml-mso` plugin.
165
+ */
166
+ outlook?: {
167
+ /**
168
+ The tag name to use for Outlook conditional comments.
169
+
170
+ @default 'outlook'
171
+
172
+ @example
173
+ ```
174
+ module.exports = {
175
+ build: {
176
+ posthtml: {
177
+ outlook: {
178
+ tag: 'mso'
179
+ }
180
+ }
181
+ }
182
+ }
183
+ // You now write <mso>...</mso> instead of <outlook>...</outlook>
184
+ ```
185
+ */
186
+ tag?: string;
187
+ };
188
+
189
+ /**
190
+ Configure the `<fetch>` tag behavior.
191
+
192
+ @default {}
193
+ */
194
+ fetch?: PostHTMLFetchConfig;
195
+ }
@@ -0,0 +1,115 @@
1
+ export default interface RemoveUnusedCSSConfig {
2
+ /**
3
+ Classes or IDs that you don't want removed.
4
+
5
+ @default []
6
+
7
+ @example
8
+ ```
9
+ module.exports = {
10
+ removeUnusedCSS: {
11
+ whitelist: ['.some-class', '.Mso*', '#*'],
12
+ }
13
+ }
14
+ ```
15
+ */
16
+ whitelist?: string[];
17
+
18
+ /**
19
+ Start and end delimiters for computed classes that you don't want removed.
20
+
21
+ @default [{heads: '{{', tails: '}}'}, {heads: '{%', tails: '%}'}]
22
+
23
+ @example
24
+ ```
25
+ module.exports = {
26
+ removeUnusedCSS: {
27
+ backend: [
28
+ { heads: '[[', tails: ']]' },
29
+ ]
30
+ }
31
+ }
32
+ ```
33
+ */
34
+ backend?: Array<Record<string, string>>;
35
+
36
+ /**
37
+ Whether to remove `<!-- HTML comments -->`.
38
+
39
+ @default true
40
+
41
+ @example
42
+ ```
43
+ module.exports = {
44
+ removeUnusedCSS: {
45
+ removeHTMLComments: false
46
+ }
47
+ }
48
+ ```
49
+ */
50
+ removeHTMLComments?: boolean;
51
+
52
+ /**
53
+ Whether to remove `/* CSS comments *\/`.
54
+
55
+ @default true
56
+
57
+ @example
58
+ ```
59
+ module.exports = {
60
+ removeUnusedCSS: {
61
+ removeCSSComments: false
62
+ }
63
+ }
64
+ ```
65
+ */
66
+ removeCSSComments?: boolean;
67
+
68
+ /**
69
+ Whether to remove classes that have been inlined.
70
+
71
+ @default undefined
72
+
73
+ @example
74
+ ```
75
+ module.exports = {
76
+ removeUnusedCSS: {
77
+ removeInlinedSelectors: false,
78
+ }
79
+ }
80
+ ```
81
+ */
82
+ removeInlinedSelectors?: boolean;
83
+
84
+ /**
85
+ List of strings representing start of a conditional comment that should not be removed.
86
+
87
+ @default ['[if', '[endif']
88
+
89
+ @example
90
+ ```
91
+ module.exports = {
92
+ removeUnusedCSS: {
93
+ doNotRemoveHTMLCommentsWhoseOpeningTagContains: ['[if', '[endif']
94
+ }
95
+ }
96
+ ```
97
+ */
98
+ doNotRemoveHTMLCommentsWhoseOpeningTagContains: string[];
99
+
100
+ /**
101
+ Rename all classes and IDs in both your `<style>` tags and your body HTML elements, to be as few characters as possible.
102
+
103
+ @default false
104
+
105
+ @example
106
+ ```
107
+ module.exports = {
108
+ removeUnusedCSS: {
109
+ uglify: true
110
+ }
111
+ }
112
+ ```
113
+ */
114
+ uglify?: boolean;
115
+ }
@@ -0,0 +1,130 @@
1
+ import {
2
+ beforeRenderType,
3
+ afterRenderType,
4
+ afterTransformersType
5
+ } from './events';
6
+ import type Config from './config';
7
+ import type TailwindConfig from './tailwind';
8
+
9
+ export type RenderOutput = {
10
+ /**
11
+ The rendered HTML.
12
+ */
13
+ html: string;
14
+
15
+ /**
16
+ The Maizzle configuration object.
17
+ */
18
+ config: Config;
19
+ };
20
+
21
+ export default interface RenderOptions {
22
+ /**
23
+ A Maizzle configuration object.
24
+
25
+ @default {}
26
+
27
+ @example
28
+ ```
29
+ const Maizzle = require('@maizzle/framework');
30
+
31
+ Maizzle
32
+ .render(`html string`, {
33
+ maizzle: {
34
+ inlineCSS: true,
35
+ }
36
+ })
37
+ .then(({html, config}) => console.log(html, config))
38
+ ```
39
+ */
40
+ maizzle: Config;
41
+
42
+ /**
43
+ Tailwind CSS configuration object.
44
+
45
+ @default {}
46
+
47
+ @example
48
+ ```
49
+ const Maizzle = require('@maizzle/framework');
50
+
51
+ Maizzle
52
+ .render(`html string`, {
53
+ tailwind: {
54
+ config: './tailwind-custom.config.js',
55
+ },
56
+ })
57
+ .then(({html, config}) => console.log(html, config))
58
+ ```
59
+ */
60
+ tailwind?: TailwindConfig;
61
+
62
+ /**
63
+ A function that runs after the Template's config has been computed, but just before it is compiled.
64
+
65
+ It exposes the Template's config, as well as the HTML.
66
+
67
+ @default undefined
68
+
69
+ @example
70
+ ```
71
+ const Maizzle = require('@maizzle/framework');
72
+
73
+ Maizzle
74
+ .render(`html string`, {
75
+ beforeRender: (html, config) => {
76
+ // do something with html and config
77
+ return html;
78
+ },
79
+ })
80
+ .then(({html, config}) => console.log(html, config))
81
+ ```
82
+ */
83
+ beforeRender?: beforeRenderType;
84
+
85
+ /**
86
+ A function that runs after the Template has been compiled, but before any Transformers have been applied.
87
+
88
+ Exposes the rendered html string and the Templates' config.
89
+
90
+ @default undefined
91
+
92
+ @example
93
+ ```
94
+ const Maizzle = require('@maizzle/framework');
95
+
96
+ Maizzle
97
+ .render(`html string`, {
98
+ afterRender: (html, config) => {
99
+ // do something with html and config
100
+ return html;
101
+ },
102
+ })
103
+ .then(({html, config}) => console.log(html, config))
104
+ ```
105
+ */
106
+ afterRender?: afterRenderType;
107
+
108
+ /**
109
+ A function that runs after all Transformers have been applied, just before the final HTML is returned.
110
+
111
+ It exposes the Template's config, as well as the HTML.
112
+
113
+ @default undefined
114
+
115
+ @example
116
+ ```
117
+ const Maizzle = require('@maizzle/framework');
118
+
119
+ Maizzle
120
+ .render(`html string`, {
121
+ afterTransformers: (html, config) => {
122
+ // do something with html and config
123
+ return html;
124
+ },
125
+ })
126
+ .then(({html, config}) => console.log(html, config))
127
+ ```
128
+ */
129
+ afterTransformers?: afterTransformersType;
130
+ }
@@ -0,0 +1,22 @@
1
+ export default interface TailwindConfig {
2
+ /**
3
+ Path to the Tailwind config file.
4
+
5
+ @default 'tailwind.config.js'
6
+ */
7
+ config?: string;
8
+
9
+ /**
10
+ Path to your main CSS file, that will be compiled with Tailwind CSS.
11
+
12
+ @default 'src/css/tailwind.css'
13
+ */
14
+ css?: string;
15
+
16
+ /**
17
+ Pre-compiled CSS. Skip Tailwind CSS processing by providing your own CSS string.
18
+
19
+ @default ''
20
+ */
21
+ compiled?: string;
22
+ }
@@ -0,0 +1,181 @@
1
+ import type Config from './config';
2
+ import type PlaintextConfig from './plaintext';
3
+
4
+ export default interface TemplatesConfig {
5
+ /**
6
+ Directory where Maizzle should look for Templates to compile.
7
+
8
+ @default 'src/templates'
9
+
10
+ @example
11
+ ```
12
+ module.exports = {
13
+ build: {
14
+ templates: {
15
+ source: 'src/templates'
16
+ }
17
+ }
18
+ }
19
+ ```
20
+ */
21
+ source?:
22
+ | string
23
+ | Array<string | TemplatesConfig>
24
+ | ((config: Config) => string | string[]);
25
+
26
+ /**
27
+ Define what file extensions your Templates use.
28
+ Maizzle will only compile files from your `source` directory that have these extensions.
29
+
30
+ @default 'html'
31
+
32
+ @example
33
+ ```
34
+ module.exports = {
35
+ build: {
36
+ templates: {
37
+ filetypes: ['html', 'blade.php']
38
+ }
39
+ }
40
+ }
41
+ ```
42
+ */
43
+ filetypes?: string | string[];
44
+
45
+ /**
46
+ Define the output path for compiled Templates, and what file extension they should use.
47
+
48
+ @example
49
+ ```
50
+ module.exports = {
51
+ build: {
52
+ templates: {
53
+ destination: {
54
+ path: 'build_production',
55
+ extension: 'html'
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+ */
62
+ destination?: {
63
+ /**
64
+ Directory where Maizzle should output compiled Templates.
65
+
66
+ @default 'build_{env}'
67
+ */
68
+ path?: string;
69
+ /**
70
+ File extension to be used for compiled Templates.
71
+
72
+ @default 'html'
73
+ */
74
+ extension: string;
75
+ };
76
+
77
+ /**
78
+ * Source and destination directories for your asset files.
79
+ *
80
+ * @example
81
+ * ```
82
+ * module.exports = {
83
+ * build: {
84
+ * templates: {
85
+ * assets: {
86
+ * source: 'src/images',
87
+ * destination: 'images'
88
+ * }
89
+ * }
90
+ * }
91
+ * }
92
+ * ```
93
+ */
94
+ assets?: {
95
+ /**
96
+ * Directory where Maizzle should look for asset files.
97
+ *
98
+ * @default ''
99
+ */
100
+ source?: string;
101
+ /**
102
+ * Directory where asset files should be copied to.
103
+ *
104
+ * @default 'assets'
105
+ */
106
+ destination?: string;
107
+ } | {
108
+ /**
109
+ * An array of objects specifying source and destination directories for asset files.
110
+ */
111
+ assets: Array<{
112
+ /**
113
+ * Directory where Maizzle should look for asset files.
114
+ */
115
+ source: string;
116
+ /**
117
+ * Directory where asset files should be copied to.
118
+ */
119
+ destination: string;
120
+ }>;
121
+ };
122
+
123
+ /**
124
+ Configure plaintext generation.
125
+
126
+ @example
127
+ ```
128
+ module.exports = {
129
+ build: {
130
+ plaintext: {
131
+ skipHtmlDecoding: true,
132
+ destination: {
133
+ path: 'dist/brand/plaintext',
134
+ extension: 'rtxt'
135
+ }
136
+ }
137
+ }
138
+ }
139
+ ```
140
+ */
141
+ plaintext?: boolean | PlaintextConfig;
142
+
143
+ /**
144
+ Paths to files or directories from your `source` that should _not_ be copied over to the build destination.
145
+
146
+ @default ['']
147
+
148
+ @example
149
+ ```
150
+ module.exports = {
151
+ build: {
152
+ templates: {
153
+ source: 'src/templates',
154
+ omit: ['1.html', 'archive/4.html'],
155
+ }
156
+ }
157
+ }
158
+ ```
159
+ */
160
+ omit?: string[];
161
+
162
+ /**
163
+ Paths to files relative to your `source` directory that should not be parsed.
164
+ They will be copied over to the build destination as-is.
165
+
166
+ @default ['']
167
+
168
+ @example
169
+ ```
170
+ module.exports = {
171
+ build: {
172
+ templates: {
173
+ source: 'src/templates',
174
+ skip: ['1.html', 'archive/3.html'],
175
+ }
176
+ }
177
+ }
178
+ ```
179
+ */
180
+ skip?: string | string[];
181
+ }
@@ -0,0 +1,39 @@
1
+ import type {StringifyOptions} from 'query-string';
2
+
3
+ export default interface URLParametersConfig {
4
+ [key: string]: any;
5
+
6
+ _options?: {
7
+ /**
8
+ Array of tag names to process. Only URLs inside `href` attributes of tags in this array will be processed.
9
+
10
+ @default ['a']
11
+
12
+ @example
13
+ ```
14
+ module.exports = {
15
+ urlParameters: {
16
+ _options: {
17
+ tags: ['a[href*="example.com"]'],
18
+ },
19
+ utm_source: 'maizzle',
20
+ }
21
+ }
22
+ ```
23
+ */
24
+ tags?: string[];
25
+
26
+ /**
27
+ By default, query parameters are appended only to valid URLs.
28
+ Disable strict mode to append parameters to any string.
29
+
30
+ @default true
31
+ */
32
+ strict?: boolean;
33
+
34
+ /**
35
+ Options to pass to the `query-string` library.
36
+ */
37
+ qs?: StringifyOptions;
38
+ };
39
+ }