@maizzle/framework 4.7.4 → 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.
@@ -0,0 +1,187 @@
1
+ import type {AttributeToStyleSupportedAttributes} from './inlineCss';
2
+ import type BaseURLConfig from './baseURL';
3
+ import type Config from './config';
4
+ import type {CoreBeautifyOptions} from 'js-beautify';
5
+ import type InlineCSSConfig from './inlineCss';
6
+ import type {Options as MarkdownItOptions} from 'markdown-it';
7
+ import type MinifyConfig from './minify';
8
+ import type PlaintextConfig from './plaintext';
9
+ import type RenderOptions from './render';
10
+ import type {RenderOutput} from './render';
11
+ import type RemoveUnusedCSSConfig from './removeUnusedCss';
12
+ import type URLParametersConfig from './urlParameters';
13
+ import type WidowWordsConfig from './widowWords';
14
+
15
+ declare namespace MaizzleFramework {
16
+ /**
17
+ Compile an HTML string with Maizzle.
18
+
19
+ @param {string} html The HTML string to render.
20
+ @param {RenderOptions} [options] Options to pass to the renderer.
21
+ */
22
+ function render(html: string, options?: RenderOptions): Promise<RenderOutput>;
23
+
24
+ /**
25
+ Normalize escaped character class names like `\:` or `\/` by replacing them with email-safe alternatives.
26
+
27
+ @param {string} html The HTML string to render.
28
+ @param {object} replacements Customize replacements strategy.
29
+ */
30
+ function safeClassNames(html: string, replacements: Record<string, string>): string;
31
+
32
+ /**
33
+ Compile Markdown to HTML.
34
+
35
+ @param {string} input String to compile with Markdown.
36
+ @param {Options} [options] markdown-it options.
37
+ */
38
+ function markdown(input: string, options?: MarkdownItOptions): string;
39
+
40
+ /**
41
+ Prevent widow words inside a tag by adding a `&nbsp;` between its last two words.
42
+
43
+ @param {string} html The HTML string to render.
44
+ @param {WidowWordsConfig} [options] Options to pass to the transformer.
45
+ */
46
+ function preventWidows(html: string, options?: WidowWordsConfig): string;
47
+
48
+ /**
49
+ Duplicate HTML attributes to inline CSS.
50
+
51
+ @param {string} html The HTML string to render.
52
+ @param {AttributeToStyleSupportedAttributes} [options] Options to pass to the transformer.
53
+ */
54
+ function attributeToStyle(
55
+ html: string,
56
+ options?: AttributeToStyleSupportedAttributes[]
57
+ ): string;
58
+
59
+ /**
60
+ Inline CSS styles from `<style>` tags found in `<head>`.
61
+
62
+ @param {string} html The HTML string to render.
63
+ @param {InlineCSSConfig} [options] Options to pass to the transformer.
64
+ */
65
+ function inlineCSS(html: string, options?: InlineCSSConfig): string;
66
+
67
+ /**
68
+ Rewrite longhand CSS inside style attributes with shorthand syntax.
69
+ Only works with margin, padding and border, and only when all sides are specified.
70
+
71
+ @param {string} html The HTML string to render.
72
+ */
73
+ function shorthandCSS(html: string): string;
74
+
75
+ /**
76
+ Remove unused CSS from `<style>` tags and HTML elements.
77
+
78
+ @param {string} html The HTML string to use.
79
+ @param {RemoveUnusedCSSConfig} [options] Options to pass to the transformer.
80
+ */
81
+ function removeUnusedCSS(html: string, options?: RemoveUnusedCSSConfig): string;
82
+
83
+ /**
84
+ Automatically remove HTML attributes.
85
+ @param {string} html The HTML string to use.
86
+ @param options Either an array of attribute names, or an array of objects with `name` and `value` properties.
87
+ */
88
+ function removeAttributes(
89
+ html: string,
90
+ options?:
91
+ | string[]
92
+ | Array<{
93
+ name: string;
94
+ value: string | RegExp;
95
+ }>
96
+ ): string;
97
+
98
+ /**
99
+ Add attributes to elements in your HTML.
100
+
101
+ @param {string} html The HTML string to use.
102
+ @param {object} options Attributes to add.
103
+ */
104
+ function addAttributes(html: string, options?: Record<string, unknown>): string;
105
+
106
+ /**
107
+ Pretty print HTML code so that it's nicely indented and more human-readable.
108
+ @param {string} html The HTML string to prettify.
109
+ @param {CoreBeautifyOptions} [options] Options to pass to the prettifier.
110
+ */
111
+ function prettify(html: string, options?: CoreBeautifyOptions): string;
112
+
113
+ /**
114
+ Prepend a string to sources and hrefs in an HTML string.
115
+
116
+ @param {string} html The HTML string to use.
117
+ @param {BaseURLConfig} [options] Options to pass to the transformer.
118
+ */
119
+ function applyBaseURL(html: string, options?: string | BaseURLConfig): string;
120
+
121
+ /**
122
+ Append parameters to URLs in an HTML string.
123
+ @param {string} html The HTML string to use.
124
+ @param {URLParametersConfig} [options] Options to pass to the transformer.
125
+ */
126
+ function addURLParameters(html: string, options?: URLParametersConfig): string;
127
+
128
+ /**
129
+ Ensure that all your HEX colors inside `bgcolor` and `color` attributes are defined with six digits.
130
+
131
+ @param {string} html The HTML string to use.
132
+ */
133
+ function ensureSixHex(html: string): string;
134
+
135
+ /**
136
+ Minify a string of HTML code.
137
+
138
+ @param {string} html The HTML string to minify.
139
+ @param {MinifyConfig} [options] Options to pass to the minifier.
140
+ */
141
+ function minify(html: string, options?: MinifyConfig): string;
142
+
143
+ /**
144
+ Batch-replace strings in an HTML string.
145
+
146
+ @param {string} html The HTML string to use.
147
+ @param {object} replacements Strings to find and replace.
148
+ */
149
+ function replaceStrings(html: string, replacements?: Record<string, string>): string;
150
+
151
+ /**
152
+ Generate a plaintext version of an HTML string.
153
+
154
+ @param {string} html The HTML string to use.
155
+ @param {PlaintextConfig} [options] Options to pass to the plaintext generator.
156
+ */
157
+ function plaintext(html: string, options?: PlaintextConfig): Promise<{
158
+ html: string;
159
+ plaintext: string;
160
+ destination: string;
161
+ }>;
162
+
163
+ export {
164
+ Config,
165
+ RenderOptions,
166
+ // Functions
167
+ addAttributes,
168
+ addURLParameters,
169
+ applyBaseURL,
170
+ attributeToStyle,
171
+ ensureSixHex,
172
+ inlineCSS,
173
+ markdown,
174
+ minify,
175
+ plaintext,
176
+ preventWidows,
177
+ prettify,
178
+ removeAttributes,
179
+ removeUnusedCSS,
180
+ render,
181
+ replaceStrings,
182
+ safeClassNames,
183
+ shorthandCSS
184
+ };
185
+ }
186
+
187
+ export = MaizzleFramework;
@@ -0,0 +1,207 @@
1
+ export type AttributeToStyleSupportedAttributes =
2
+ | 'width'
3
+ | 'height'
4
+ | 'bgcolor'
5
+ | 'background'
6
+ | 'align'
7
+ | 'valign';
8
+
9
+ export default interface InlineCSSConfig {
10
+ /**
11
+ Which CSS properties should be duplicated as what HTML attributes.
12
+
13
+ @default {}
14
+
15
+ @example
16
+ ```
17
+ module.exports = {
18
+ build: {
19
+ inlineCSS: {
20
+ styleToAttribute: {
21
+ 'background-color': 'bgcolor',
22
+ }
23
+ }
24
+ }
25
+ }
26
+ ```
27
+ */
28
+ styleToAttribute?: Record<string, string>;
29
+
30
+ /**
31
+ Duplicate HTML attributes to inline CSS.
32
+
33
+ @default false
34
+
35
+ @example
36
+ ```
37
+ module.exports = {
38
+ build: {
39
+ inlineCSS: {
40
+ attributeToStyle: ['width', 'bgcolor', 'background']
41
+ }
42
+ }
43
+ }
44
+ ```
45
+ */
46
+ attributeToStyle?: boolean | AttributeToStyleSupportedAttributes[];
47
+
48
+ /**
49
+ HTML elements that will receive `width` attributes based on inline CSS width.
50
+
51
+ @default []
52
+
53
+ @example
54
+ ```
55
+ module.exports = {
56
+ build: {
57
+ inlineCSS: {
58
+ applyWidthAttributes: ['td', 'th']
59
+ }
60
+ }
61
+ }
62
+ ```
63
+ */
64
+ applyWidthAttributes?: string[];
65
+
66
+ /**
67
+ HTML elements that will receive `height` attributes based on inline CSS height.
68
+
69
+ @default []
70
+
71
+ @example
72
+ ```
73
+ module.exports = {
74
+ build: {
75
+ inlineCSS: {
76
+ applyHeightAttributes: ['td', 'th']
77
+ }
78
+ }
79
+ }
80
+ ```
81
+ */
82
+ applyHeightAttributes?: string[];
83
+
84
+ /**
85
+ List of elements that should only use `width` and `height`. Their inline CSS `width` and `height` will be removed.
86
+
87
+ @example
88
+ ```
89
+ module.exports = {
90
+ inlineCSS: {
91
+ keepOnlyAttributeSizes: {
92
+ width: ['img', 'video'],
93
+ height: ['img', 'video']
94
+ }
95
+ }
96
+ }
97
+ ```
98
+ */
99
+ keepOnlyAttributeSizes?: {
100
+ /**
101
+ List of elements that should only use the `width` HTML attribute (inline CSS width will be removed).
102
+
103
+ @default []
104
+
105
+ @example
106
+ ```
107
+ module.exports = {
108
+ inlineCSS: {
109
+ keepOnlyAttributeSizes: {
110
+ width: ['img', 'video'],
111
+ }
112
+ }
113
+ }
114
+ ```
115
+ */
116
+ width?: string[];
117
+ /**
118
+ List of elements that should only use the `height` HTML attribute (inline CSS height will be removed).
119
+
120
+ @default []
121
+
122
+ @example
123
+ ```
124
+ module.exports = {
125
+ inlineCSS: {
126
+ keepOnlyAttributeSizes: {
127
+ height: ['img', 'video']
128
+ }
129
+ }
130
+ }
131
+ ```
132
+ */
133
+ height?: string[];
134
+ };
135
+
136
+ /**
137
+ Remove inlined `background-color` CSS on elements containing a `bgcolor` HTML attribute.
138
+
139
+ @default false
140
+
141
+ @example
142
+ ```
143
+ module.exports = {
144
+ inlineCSS: {
145
+ preferBgColorAttribute: ['td'] // default: ['body', 'marquee', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr']
146
+ }
147
+ }
148
+ ```
149
+ */
150
+ preferBgColorAttribute?: boolean | string[];
151
+
152
+ /**
153
+ Array of CSS property names that should be excluded from the CSS inlining process. `--tw-shadow` is excluded by default.
154
+
155
+ @default []
156
+
157
+ @example
158
+ ```
159
+ module.exports = {
160
+ inlineCSS: {
161
+ excludedProperties: ['padding', 'padding-left']
162
+ }
163
+ }
164
+ ```
165
+ */
166
+ excludedProperties?: string[];
167
+
168
+ /**
169
+ An object where each value has a `start` and `end` to specify fenced code blocks that should be ignored during CSS inlining.
170
+
171
+ @default {EJS: {}, HBS: {}}
172
+
173
+ @example
174
+ ```
175
+ module.exports = {
176
+ EJS: { start: '<%', end: '%>' },
177
+ HBS: { start: '{{', end: '}}' },
178
+ }
179
+ ```
180
+ */
181
+ codeBlocks?: {
182
+ EJS?: Record<string, string>;
183
+ HBS?: Record<string, string>;
184
+ };
185
+
186
+ /**
187
+ Provide your own CSS to be inlined. Must be vanilla or pre-compiled CSS.
188
+
189
+ Existing `<style>` in your HTML tags will be ignored and their contents won't be inlined.
190
+
191
+ @default undefined
192
+
193
+ @example
194
+ ```
195
+ module.exports = {
196
+ inlineCSS: {
197
+ customCSS: `
198
+ .custom-class {
199
+ color: red;
200
+ }
201
+ `
202
+ }
203
+ }
204
+ ```
205
+ */
206
+ customCSS?: string;
207
+ }
@@ -0,0 +1,39 @@
1
+ export default interface LayoutsConfig {
2
+ /**
3
+ Encoding to be used when reading a layout file from disk.
4
+
5
+ @default 'utf8'
6
+ */
7
+ encoding?: string;
8
+
9
+ /**
10
+ Name of the slot tag, where the content will be injected.
11
+ This is typically used in a Layout file, to define the place where to inject a Template.
12
+
13
+ @default 'block'
14
+ */
15
+ slotTagName?: string;
16
+
17
+ /**
18
+ Name of the fill tag, inside of which content that will be injected is defined.
19
+ This is typically used in a Template file, to extend a Layout.
20
+
21
+ @default 'block'
22
+ */
23
+ fillTagName?: string;
24
+
25
+ /**
26
+ Path to the layouts folder, relative to the project root.
27
+
28
+ @default 'src/layouts'
29
+ */
30
+ root?: string;
31
+
32
+ /**
33
+ Tag name to be used in HTML when extending a layout.
34
+
35
+ @default 'extends'
36
+ */
37
+ tagName?: string;
38
+
39
+ }
@@ -0,0 +1,31 @@
1
+ import type {Options as MarkdownItOptions} from 'markdown-it';
2
+
3
+ export default interface MarkdownConfig {
4
+ /**
5
+ Path relative to which markdown files are imported.
6
+
7
+ @default './'
8
+ */
9
+ root?: string;
10
+
11
+ /**
12
+ Encoding for imported Markdown files.
13
+
14
+ @default 'utf8'
15
+ */
16
+ encoding?: string;
17
+
18
+ /**
19
+ Options to pass to the `markdown-it` library.
20
+
21
+ @default {}
22
+ */
23
+ markdownit?: MarkdownItOptions;
24
+
25
+ /**
26
+ Plugins for the `markdown-it` library.
27
+
28
+ @default []
29
+ */
30
+ plugins?: any[];
31
+ }
@@ -0,0 +1,136 @@
1
+ export default interface MinifyConfig {
2
+ /**
3
+ Maximum line length. Works only when `removeLineBreaks` is `true`.
4
+
5
+ @default 500
6
+ */
7
+ lineLengthLimit?: number;
8
+
9
+ /**
10
+ Remove all line breaks from HTML when minifying.
11
+
12
+ @default true
13
+ */
14
+ removeLineBreaks?: boolean;
15
+
16
+ /**
17
+ Remove code indentation when minifying HTML.
18
+
19
+ @default true
20
+ */
21
+ removeIndentations?: boolean;
22
+
23
+ /**
24
+ Remove `<!-- HTML comments -->` when minifying HTML.
25
+
26
+ `0` - don't remove any HTML comments
27
+
28
+ `1` - remove all comments except Outlook conditional comments
29
+
30
+ `2` - remove all comments, including Outlook conditional comments
31
+
32
+ @default false
33
+ */
34
+ removeHTMLComments?: boolean | number;
35
+
36
+ /**
37
+ Remove CSS comments when minifying HTML.
38
+
39
+ @default true
40
+ */
41
+ removeCSSComments?: boolean;
42
+
43
+ /**
44
+ When any of given strings are encountered and `removeLineBreaks` is true, current line will be terminated.
45
+
46
+ @default
47
+ [
48
+ '</td',
49
+ '<html',
50
+ '</html',
51
+ '<head',
52
+ '</head',
53
+ '<meta',
54
+ '<link',
55
+ '<table',
56
+ '<script',
57
+ '</script',
58
+ '<!DOCTYPE',
59
+ '<style',
60
+ '</style',
61
+ '<title',
62
+ '<body',
63
+ '@media',
64
+ '</body',
65
+ '<!--[if',
66
+ '<!--<![endif',
67
+ '<![endif]'
68
+ ]
69
+ */
70
+ breakToTheLeftOf?: string[] | boolean | null;
71
+
72
+ /**
73
+ Some inline tags can accidentally introduce extra text.
74
+ The minifier will take extra precaution when minifying around these tags.
75
+
76
+ @default
77
+ [
78
+ 'a',
79
+ 'abbr',
80
+ 'acronym',
81
+ 'audio',
82
+ 'b',
83
+ 'bdi',
84
+ 'bdo',
85
+ 'big',
86
+ 'br',
87
+ 'button',
88
+ 'canvas',
89
+ 'cite',
90
+ 'code',
91
+ 'data',
92
+ 'datalist',
93
+ 'del',
94
+ 'dfn',
95
+ 'em',
96
+ 'embed',
97
+ 'i',
98
+ 'iframe',
99
+ 'img',
100
+ 'input',
101
+ 'ins',
102
+ 'kbd',
103
+ 'label',
104
+ 'map',
105
+ 'mark',
106
+ 'meter',
107
+ 'noscript',
108
+ 'object',
109
+ 'output',
110
+ 'picture',
111
+ 'progress',
112
+ 'q',
113
+ 'ruby',
114
+ 's',
115
+ 'samp',
116
+ 'script',
117
+ 'select',
118
+ 'slot',
119
+ 'small',
120
+ 'span',
121
+ 'strong',
122
+ 'sub',
123
+ 'sup',
124
+ 'svg',
125
+ 'template',
126
+ 'textarea',
127
+ 'time',
128
+ 'u',
129
+ 'tt',
130
+ 'var',
131
+ 'video',
132
+ 'wbr'
133
+ ]
134
+ */
135
+ mindTheInlineTags?: string[] | boolean | null;
136
+ }
@@ -0,0 +1,62 @@
1
+ import type {Opts as PlaintextOptions} from 'string-strip-html';
2
+
3
+ export default interface PlaintextConfig extends PlaintextOptions {
4
+ /**
5
+ Configure where plaintext files should be output.
6
+
7
+ @example
8
+ ```
9
+ module.exports = {
10
+ build: {
11
+ plaintext: {
12
+ destination: {
13
+ path: 'dist/brand/plaintext',
14
+ extension: 'rtxt'
15
+ }
16
+ }
17
+ }
18
+ }
19
+ ```
20
+ */
21
+ destination?: {
22
+ /**
23
+ Directory where Maizzle should output compiled Plaintext files.
24
+
25
+ @default 'build_{env}'
26
+
27
+ @example
28
+ ```
29
+ module.exports = {
30
+ build: {
31
+ plaintext: {
32
+ destination: {
33
+ path: 'dist/brand/plaintext'
34
+ }
35
+ }
36
+ }
37
+ }
38
+ ```
39
+ */
40
+ path?: string;
41
+
42
+ /**
43
+ File extension to be used for compiled Plaintext files.
44
+
45
+ @default 'txt'
46
+
47
+ @example
48
+ ```
49
+ module.exports = {
50
+ build: {
51
+ plaintext: {
52
+ destination: {
53
+ extension: 'rtxt'
54
+ }
55
+ }
56
+ }
57
+ }
58
+ ```
59
+ */
60
+ extension: string;
61
+ };
62
+ }