@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
@@ -1,207 +0,0 @@
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
- }
@@ -1,39 +0,0 @@
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
- }
@@ -1,115 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
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
- }
@@ -1,181 +0,0 @@
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
- }