@maizzle/framework 4.8.8 → 5.0.0-beta.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.
Files changed (80) hide show
  1. package/bin/maizzle +3 -1
  2. package/package.json +64 -55
  3. package/src/commands/build.js +244 -19
  4. package/src/commands/serve.js +2 -197
  5. package/src/generators/plaintext.js +192 -91
  6. package/src/generators/render.js +128 -0
  7. package/src/index.js +45 -13
  8. package/src/{generators/posthtml → posthtml}/defaultComponentsConfig.js +6 -4
  9. package/src/{generators/posthtml → posthtml}/defaultConfig.js +1 -1
  10. package/src/posthtml/index.js +74 -0
  11. package/src/posthtml/plugins/expandLinkTag.js +36 -0
  12. package/src/server/client.js +181 -0
  13. package/src/server/index.js +383 -0
  14. package/src/server/routes/hmr.js +24 -0
  15. package/src/server/routes/index.js +38 -0
  16. package/src/server/views/error.html +83 -0
  17. package/src/server/views/index.html +24 -0
  18. package/src/server/websockets.js +27 -0
  19. package/src/transformers/addAttributes.js +30 -0
  20. package/src/transformers/attributeToStyle.js +30 -36
  21. package/src/transformers/baseUrl.js +56 -27
  22. package/src/transformers/comb.js +51 -0
  23. package/src/transformers/core.js +20 -0
  24. package/src/transformers/filters/defaultFilters.js +90 -71
  25. package/src/transformers/filters/index.js +14 -78
  26. package/src/transformers/index.js +268 -63
  27. package/src/transformers/inline.js +240 -0
  28. package/src/transformers/markdown.js +13 -14
  29. package/src/transformers/minify.js +21 -16
  30. package/src/transformers/posthtmlMso.js +13 -8
  31. package/src/transformers/prettify.js +16 -15
  32. package/src/transformers/preventWidows.js +32 -28
  33. package/src/transformers/removeAttributes.js +19 -19
  34. package/src/transformers/replaceStrings.js +30 -9
  35. package/src/transformers/safeClassNames.js +24 -24
  36. package/src/transformers/shorthandCss.js +22 -0
  37. package/src/transformers/sixHex.js +17 -17
  38. package/src/transformers/urlParameters.js +18 -16
  39. package/src/transformers/useAttributeSizes.js +65 -0
  40. package/src/utils/getConfigByFilePath.js +124 -0
  41. package/src/utils/node.js +68 -0
  42. package/src/utils/string.js +117 -0
  43. package/types/build.d.ts +117 -57
  44. package/types/components.d.ts +130 -112
  45. package/types/config.d.ts +454 -242
  46. package/types/css/inline.d.ts +234 -0
  47. package/types/css/purge.d.ts +125 -0
  48. package/types/events.d.ts +5 -105
  49. package/types/index.d.ts +148 -116
  50. package/types/markdown.d.ts +20 -18
  51. package/types/minify.d.ts +122 -120
  52. package/types/plaintext.d.ts +46 -52
  53. package/types/posthtml.d.ts +103 -136
  54. package/types/render.d.ts +0 -117
  55. package/types/urlParameters.d.ts +21 -20
  56. package/types/widowWords.d.ts +9 -7
  57. package/src/functions/plaintext.js +0 -5
  58. package/src/functions/render.js +0 -5
  59. package/src/generators/config.js +0 -52
  60. package/src/generators/output/index.js +0 -4
  61. package/src/generators/output/to-disk.js +0 -254
  62. package/src/generators/output/to-string.js +0 -73
  63. package/src/generators/postcss.js +0 -23
  64. package/src/generators/posthtml/index.js +0 -75
  65. package/src/generators/tailwindcss.js +0 -157
  66. package/src/transformers/extraAttributes.js +0 -33
  67. package/src/transformers/inlineCss.js +0 -42
  68. package/src/transformers/removeInlineBackgroundColor.js +0 -57
  69. package/src/transformers/removeInlineSizes.js +0 -45
  70. package/src/transformers/removeInlinedSelectors.js +0 -100
  71. package/src/transformers/removeUnusedCss.js +0 -48
  72. package/src/transformers/shorthandInlineCSS.js +0 -26
  73. package/src/utils/helpers.js +0 -13
  74. package/types/baseUrl.d.ts +0 -79
  75. package/types/fetch.d.ts +0 -143
  76. package/types/inlineCss.d.ts +0 -207
  77. package/types/layouts.d.ts +0 -39
  78. package/types/removeUnusedCss.d.ts +0 -115
  79. package/types/tailwind.d.ts +0 -22
  80. package/types/templates.d.ts +0 -181
@@ -0,0 +1,234 @@
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
+ * export default {
18
+ * css: {
19
+ * inline: {
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
+ * export default {
38
+ * css: {
39
+ * inline: {
40
+ * attributeToStyle: ['width', 'bgcolor', 'background']
41
+ * }
42
+ * }
43
+ * }
44
+ * ```
45
+ */
46
+ attributeToStyle?: boolean | AttributeToStyleSupportedAttributes[];
47
+
48
+ /**
49
+ * Use any CSS pixel widths to create `width` attributes on elements set in `widthElements`.
50
+ *
51
+ * @default true
52
+ *
53
+ * @example
54
+ * ```
55
+ * export default {
56
+ * css: {
57
+ * inline: {
58
+ * applyWidthAttributes: true,
59
+ * }
60
+ * }
61
+ * }
62
+ * ```
63
+ */
64
+ applyWidthAttributes?: boolean;
65
+
66
+ /**
67
+ * Use any CSS pixel widths to create `height` attributes on elements set in `heightElements`.
68
+ *
69
+ * @default true
70
+ *
71
+ * @example
72
+ * ```
73
+ * export default {
74
+ * css: {
75
+ * inline: {
76
+ * applyHeightAttributes: true,
77
+ * }
78
+ * }
79
+ * }
80
+ * ```
81
+ */
82
+ applyHeightAttributes?: boolean;
83
+
84
+ /**
85
+ * Prefer HTML `width` and `height` attributes over inline CSS.
86
+ * The inline CSS `width` and `height` will be removed.
87
+ *
88
+ * @example
89
+ * ```
90
+ * export default {
91
+ * css: {
92
+ * inline: {
93
+ * useAttributeSizes: true
94
+ * }
95
+ * }
96
+ * }
97
+ * ```
98
+ */
99
+ useAttributeSizes?: boolean;
100
+
101
+ /**
102
+ * Array of CSS property names that should be excluded from the CSS inlining process.
103
+ *
104
+ * @default []
105
+ *
106
+ * @example
107
+ * ```
108
+ * export default {
109
+ * css: {
110
+ * inline: {
111
+ * excludedProperties: ['padding', 'padding-left']
112
+ * }
113
+ * }
114
+ * }
115
+ * ```
116
+ */
117
+ excludedProperties?: string[];
118
+
119
+ /**
120
+ * Fenced code blocks that should be ignored during CSS inlining.
121
+ *
122
+ * @default
123
+ * {
124
+ * EJS: { start: '<%', end: '%>' },
125
+ * HBS: { start: '{{', end: '}}' }
126
+ * }
127
+ *
128
+ * @example
129
+ * ```
130
+ * export default {
131
+ * css: {
132
+ * inline: {
133
+ * codeBlocks: {
134
+ * EJS: { start: '<%', end: '%>' },
135
+ * HBS: { start: '{{', end: '}}' },
136
+ * }
137
+ * }
138
+ * }
139
+ * }
140
+ * ```
141
+ */
142
+ codeBlocks?: Record<string, { start: string; end: string }>;
143
+
144
+ /**
145
+ * Provide your own CSS to be inlined. Must be vanilla or pre-compiled CSS.
146
+ *
147
+ * Existing `<style>` in your HTML tags will be ignored and their contents won't be inlined.
148
+ *
149
+ * @default false
150
+ *
151
+ * @example
152
+ * ```
153
+ * export default {
154
+ * css: {
155
+ * inline: {
156
+ * customCSS: `.custom-class { color: red }`
157
+ * }
158
+ * }
159
+ * }
160
+ * ```
161
+ */
162
+ customCSS?: string | false;
163
+
164
+ /**
165
+ * Resolve CSS variables and replace them with their values.
166
+ *
167
+ * @default true
168
+ *
169
+ * @example
170
+ * ```
171
+ * export default {
172
+ * css: {
173
+ * inline: {
174
+ * resolveVariables: true
175
+ * }
176
+ * }
177
+ * }
178
+ * ```
179
+ */
180
+ resolveVariables?: boolean;
181
+
182
+ /**
183
+ * Remove inlined CSS selectors from the `<style>` tag.
184
+ *
185
+ * @default true
186
+ *
187
+ * @example
188
+ * ```
189
+ * export default {
190
+ * css: {
191
+ * inline: {
192
+ * removeInlinedSelectors: true
193
+ * }
194
+ * }
195
+ * ```
196
+ */
197
+ removeInlinedSelectors?: boolean;
198
+
199
+ /**
200
+ * Resolve calc() expressions in CSS to their computed values.
201
+ *
202
+ * @default true
203
+ *
204
+ * @example
205
+ * ```
206
+ * export default {
207
+ * css: {
208
+ * inline: {
209
+ * resolveCalc: true
210
+ * }
211
+ * }
212
+ * }
213
+ * ```
214
+ */
215
+ resolveCalc?: boolean;
216
+
217
+ /**
218
+ * Prefer unitless CSS values
219
+ *
220
+ * @default true
221
+ *
222
+ * @example
223
+ * ```
224
+ * export default {
225
+ * css: {
226
+ * inline: {
227
+ * preferUnitless: true
228
+ * }
229
+ * }
230
+ * }
231
+ * ```
232
+ */
233
+ preferUnitlessValues?: boolean;
234
+ }
@@ -0,0 +1,125 @@
1
+ import type { Opts } from 'email-comb';
2
+
3
+ export default interface PurgeCSSConfig {
4
+ /**
5
+ * Classes or IDs that you don't want removed.
6
+ *
7
+ * @default []
8
+ *
9
+ * @example
10
+ * ```
11
+ * export default {
12
+ * css: {
13
+ * purge: {
14
+ * whitelist: ['.some-class', '.Mso*', '#*'],
15
+ * }
16
+ * }
17
+ * }
18
+ * ```
19
+ */
20
+ whitelist?: Opts['whitelist'];
21
+
22
+ /**
23
+ * Start and end delimiters for computed classes that you don't want removed.
24
+ *
25
+ * @default
26
+ * [
27
+ * {
28
+ * heads: '{{',
29
+ * tails: '}}',
30
+ * },
31
+ * {
32
+ * heads: '{%',
33
+ * tails: '%}',
34
+ * }
35
+ * ]
36
+ *
37
+ * @example
38
+ * ```
39
+ * export default {
40
+ * css: {
41
+ * purge: {
42
+ * backend: [
43
+ * { heads: '[[', tails: ']]' },
44
+ * ]
45
+ * }
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ backend?: Opts['backend'];
51
+
52
+ /**
53
+ * Whether to remove `<!-- HTML comments -->`.
54
+ *
55
+ * @default true
56
+ *
57
+ * @example
58
+ * ```
59
+ * export default {
60
+ * css: {
61
+ * purge: {
62
+ * removeHTMLComments: false,
63
+ * }
64
+ * }
65
+ * }
66
+ * ```
67
+ */
68
+ removeHTMLComments?: Opts['removeHTMLComments'];
69
+
70
+ /**
71
+ * Whether to remove `/* CSS comments *\/`.
72
+ *
73
+ * @default true
74
+ *
75
+ * @example
76
+ * ```
77
+ * export default {
78
+ * css: {
79
+ * purge: {
80
+ * removeCSSComments: false,
81
+ * }
82
+ * }
83
+ * }
84
+ * ```
85
+ */
86
+ removeCSSComments?: Opts['removeCSSComments'];
87
+
88
+ /**
89
+ * List of strings representing start of a conditional comment that should not be removed.
90
+ *
91
+ * @default
92
+ * ['[if', '[endif']
93
+ *
94
+ * @example
95
+ * ```
96
+ * export default {
97
+ * css: {
98
+ * purge: {
99
+ * doNotRemoveHTMLCommentsWhoseOpeningTagContains: ['[if', '[endif'],
100
+ * }
101
+ * }
102
+ * }
103
+ * ```
104
+ */
105
+ doNotRemoveHTMLCommentsWhoseOpeningTagContains: Opts['doNotRemoveHTMLCommentsWhoseOpeningTagContains'];
106
+
107
+ /**
108
+ * Rename all classes and IDs in both your `<style>` tags and your body HTML elements,
109
+ * to be as few characters as possible.
110
+ *
111
+ * @default false
112
+ *
113
+ * @example
114
+ * ```
115
+ * export default {
116
+ * css: {
117
+ * purge: {
118
+ * uglify: true,
119
+ * }
120
+ * }
121
+ * }
122
+ * ```
123
+ */
124
+ uglify?: Opts['uglify'];
125
+ }
package/types/events.d.ts CHANGED
@@ -1,105 +1,5 @@
1
- export type beforeCreateType = (config: any) => Promise<void>;
2
- export type beforeRenderType = (html: string, config: any) => Promise<string>;
3
- export type afterRenderType = (html: string, config: any) => Promise<string>;
4
- export type afterTransformersType = (html: string, config: any) => Promise<string>;
5
- export type afterBuildType = (files: any[], config: any) => Promise<void>;
6
-
7
- export default interface EventsConfig {
8
- /**
9
- Runs after the Environment config has been computed, but before Templates are processed.
10
- Exposes the `config` object so you can further customize it.
11
-
12
- @default undefined
13
-
14
- @example
15
- ```
16
- module.exports = {
17
- events: {
18
- beforeCreate: async (config) => {
19
- // do something with `config`
20
- }
21
- }
22
- }
23
- ```
24
- */
25
- beforeCreate: beforeCreateType;
26
-
27
- /**
28
- Runs after the Template's config has been computed, but just before it is compiled.
29
- It exposes the Template's config, as well as the HTML. Must return the `html` string.
30
-
31
- @default undefined
32
-
33
- @example
34
- ```
35
- module.exports = {
36
- events: {
37
- beforeRender: async (html, config) => {
38
- // do something with html and config
39
- return html;
40
- }
41
- }
42
- }
43
- ```
44
- */
45
- beforeRender: beforeRenderType;
46
-
47
- /**
48
- Runs after the Template has been compiled, but before any Transformers have been applied.
49
- Exposes the rendered `html` string and the `config`. Must return the `html` string.
50
-
51
- @default undefined
52
-
53
- @example
54
- ```
55
- module.exports = {
56
- events: {
57
- afterRender: async (html, config) => {
58
- // do something with html and config
59
- return html;
60
- }
61
- }
62
- }
63
- ```
64
- */
65
- afterRender: afterRenderType;
66
-
67
- /**
68
- Runs after all Transformers have been applied, just before the final HTML is returned.
69
- Exposes the rendered `html` string and the `config`. Must return the `html` string.
70
-
71
- @default undefined
72
-
73
- @example
74
- ```
75
- module.exports = {
76
- events: {
77
- afterTransformers: async (html, config) => {
78
- // do something with html and config
79
- return html;
80
- }
81
- }
82
- }
83
- ```
84
- */
85
- afterTransformers: afterTransformersType;
86
-
87
- /**
88
- Runs after all Templates have been compiled and output to disk.
89
- The files parameter will contain the paths to all the files inside the `build.templates.destination.path` directory.
90
-
91
- @default undefined
92
-
93
- @example
94
- ```
95
- module.exports = {
96
- events: {
97
- afterBuild: async (files, config) => {
98
- // do something with files or config
99
- }
100
- }
101
- }
102
- ```
103
- */
104
- afterBuild: afterBuildType;
105
- }
1
+ export type beforeCreateType = (config: object) => Promise<void>;
2
+ export type beforeRenderType = (html: string, config: object, render: (html: string, config: object) => Promise<string>) => Promise<string>;
3
+ export type afterRenderType = ({ html, config }: { html: string, config: object }) => Promise<string>;
4
+ export type afterTransformersType = ({ html, config, render }: { html: string, config: object, render: (html: string, config: object) => Promise<string> }) => Promise<string>;
5
+ export type afterBuildType = ({ files, config, render }: { files: string[], config: object, render: (html: string, config: object) => Promise<string> }) => Promise<void>;