@maizzle/framework 5.0.0-beta.2 → 5.0.0-beta.21
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 +24 -21
- package/src/commands/build.js +138 -70
- package/src/generators/plaintext.js +13 -14
- package/src/generators/render.js +8 -7
- package/src/posthtml/index.js +34 -5
- package/src/posthtml/plugins/envAttributes.js +32 -0
- package/src/posthtml/plugins/envTags.js +33 -0
- package/src/server/index.js +155 -92
- package/src/server/views/404.html +59 -0
- package/src/transformers/addAttributes.js +1 -1
- package/src/transformers/comb.js +1 -1
- package/src/transformers/core.js +12 -0
- package/src/transformers/index.js +32 -40
- package/src/transformers/inline.js +7 -5
- package/src/transformers/minify.js +2 -1
- package/src/transformers/replaceStrings.js +6 -2
- package/src/transformers/template.js +26 -0
- package/src/utils/string.js +79 -0
- package/types/build.d.ts +59 -24
- package/types/config.d.ts +54 -48
- package/types/css/purge.d.ts +1 -1
- package/types/events.d.ts +153 -5
- package/types/posthtml.d.ts +3 -3
- package/types/urlParameters.d.ts +1 -1
- package/types/components.d.ts +0 -195
- package/types/expressions.d.ts +0 -100
package/types/events.d.ts
CHANGED
|
@@ -1,5 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type Config from "./config";
|
|
2
|
+
|
|
3
|
+
export default interface Events {
|
|
4
|
+
/**
|
|
5
|
+
* Runs after the Environment config has been computed, but before Templates are processed.
|
|
6
|
+
* Exposes the `config` object so you can further customize it.
|
|
7
|
+
*
|
|
8
|
+
* @default undefined
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* export default {
|
|
13
|
+
* beforeCreate: async ({config}) => {
|
|
14
|
+
* // do something with `config`
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
beforeCreate?: (params: {
|
|
20
|
+
/**
|
|
21
|
+
* The computed Maizzle config object.
|
|
22
|
+
*/
|
|
23
|
+
config: Config
|
|
24
|
+
}) => void | Promise<void>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Runs after the Template's config has been computed, but just before it is compiled.
|
|
28
|
+
*
|
|
29
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
30
|
+
*
|
|
31
|
+
* @default undefined
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```
|
|
35
|
+
* export default {
|
|
36
|
+
* beforeRender: async ({html, matter, config, posthtml}) => {
|
|
37
|
+
* // do something...
|
|
38
|
+
* return html;
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
beforeRender?: (params: {
|
|
44
|
+
/**
|
|
45
|
+
* The Template's HTML string.
|
|
46
|
+
*/
|
|
47
|
+
html: string;
|
|
48
|
+
/**
|
|
49
|
+
* The Template's Front Matter data.
|
|
50
|
+
*/
|
|
51
|
+
matter: { [key: string]: string };
|
|
52
|
+
/**
|
|
53
|
+
* The Template's computed config.
|
|
54
|
+
*
|
|
55
|
+
* This is the Environment config merged with the Template's Front Matter.
|
|
56
|
+
*/
|
|
57
|
+
config: Config;
|
|
58
|
+
}) => string | Promise<string>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Runs after the Template has been compiled, but before any Transformers have been applied.
|
|
62
|
+
*
|
|
63
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
64
|
+
*
|
|
65
|
+
* @default undefined
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```
|
|
69
|
+
* export default {
|
|
70
|
+
* afterRender: async async ({html, matter, config, posthtml}) => {
|
|
71
|
+
* // do something...
|
|
72
|
+
* return html;
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
afterRender?: (params: {
|
|
78
|
+
/**
|
|
79
|
+
* The Template's HTML string.
|
|
80
|
+
*/
|
|
81
|
+
html: string;
|
|
82
|
+
/**
|
|
83
|
+
* The Template's Front Matter data.
|
|
84
|
+
*/
|
|
85
|
+
matter: { [key: string]: string };
|
|
86
|
+
/**
|
|
87
|
+
* The Template's computed config.
|
|
88
|
+
*
|
|
89
|
+
* This is the Environment config merged with the Template's Front Matter.
|
|
90
|
+
*/
|
|
91
|
+
config: Config;
|
|
92
|
+
}) => string | Promise<string>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Runs after all Transformers have been applied, just before the final HTML is returned.
|
|
96
|
+
*
|
|
97
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
98
|
+
*
|
|
99
|
+
* @default undefined
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```
|
|
103
|
+
* export default {
|
|
104
|
+
* afterTransformers: async ({html, matter, config, posthtml}) => {
|
|
105
|
+
* // do something...
|
|
106
|
+
* return html;
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
afterTransformers?: (params: {
|
|
112
|
+
/**
|
|
113
|
+
* The Template's HTML string.
|
|
114
|
+
*/
|
|
115
|
+
html: string;
|
|
116
|
+
/**
|
|
117
|
+
* The Template's Front Matter data.
|
|
118
|
+
*/
|
|
119
|
+
matter: { [key: string]: string };
|
|
120
|
+
/**
|
|
121
|
+
* The Template's computed config.
|
|
122
|
+
*
|
|
123
|
+
* This is the Environment config merged with the Template's Front Matter.
|
|
124
|
+
*/
|
|
125
|
+
config: Config;
|
|
126
|
+
}) => string | Promise<string>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Runs after all Templates have been compiled and output to disk.
|
|
130
|
+
* `files` will contain the paths to all the files inside the `build.output.path` directory.
|
|
131
|
+
*
|
|
132
|
+
* @default undefined
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```
|
|
136
|
+
* export default {
|
|
137
|
+
* afterBuild: async ({config, files}) => {
|
|
138
|
+
* // do something...
|
|
139
|
+
* }
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
afterBuild?: (params: {
|
|
144
|
+
/**
|
|
145
|
+
* The computed Maizzle config object.
|
|
146
|
+
*/
|
|
147
|
+
config: Config;
|
|
148
|
+
/**
|
|
149
|
+
* An array of paths to all the files inside the `build.output.path` directory.
|
|
150
|
+
*/
|
|
151
|
+
files: string[];
|
|
152
|
+
}) => string | Promise<string>;
|
|
153
|
+
}
|
package/types/posthtml.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Directive } from 'posthtml-parser';
|
|
2
|
-
import type
|
|
2
|
+
import type { PostHTMLExpressions } from 'posthtml-expressions';
|
|
3
3
|
|
|
4
4
|
export interface PostHTMLOptions {
|
|
5
5
|
/**
|
|
@@ -128,9 +128,9 @@ export interface PostHTMLOptions {
|
|
|
128
128
|
|
|
129
129
|
export default interface PostHTMLConfig {
|
|
130
130
|
/**
|
|
131
|
-
Configure expressions.
|
|
131
|
+
Configure [posthtml-expressions](https://github.com/posthtml/posthtml-expressions) options.
|
|
132
132
|
*/
|
|
133
|
-
expressions?:
|
|
133
|
+
expressions?: PostHTMLExpressions;
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
Configure PostHTML options.
|
package/types/urlParameters.d.ts
CHANGED
package/types/components.d.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import type ExpressionsConfig from './expressions';
|
|
2
|
-
import type { Options as PostHTMLParserOptions } from 'posthtml-parser';
|
|
3
|
-
|
|
4
|
-
interface AnyObject {
|
|
5
|
-
[key: string]: string | AnyObject;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default interface ComponentsConfig {
|
|
9
|
-
/**
|
|
10
|
-
* Root path where to look for folders containing component files.
|
|
11
|
-
*
|
|
12
|
-
* @default './'
|
|
13
|
-
*/
|
|
14
|
-
root?: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Paths where to look for component files. Must be relative to `root`.
|
|
18
|
-
*
|
|
19
|
-
* @default ['src/components', 'src/layouts', 'src/templates']
|
|
20
|
-
*/
|
|
21
|
-
folders?: string[];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Prefix to use for component tags.
|
|
25
|
-
*
|
|
26
|
-
* @default 'x-'
|
|
27
|
-
*/
|
|
28
|
-
tagPrefix?: string;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Tag name to be used in HTML when using a component.
|
|
32
|
-
*
|
|
33
|
-
* @default 'component'
|
|
34
|
-
*/
|
|
35
|
-
tag?: string;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Attribute name to be used when referencing a component via its path.
|
|
39
|
-
*
|
|
40
|
-
* @default 'src'
|
|
41
|
-
*/
|
|
42
|
-
attribute?: string;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* File extension that component files must use.
|
|
46
|
-
* Any other files will be ignored and not be made available as components.
|
|
47
|
-
*
|
|
48
|
-
* @default 'html'
|
|
49
|
-
*/
|
|
50
|
-
fileExtension?: string;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Name of the tag that will be replaced with the content that is passed to the component.
|
|
54
|
-
*
|
|
55
|
-
* @default 'yield'
|
|
56
|
-
*/
|
|
57
|
-
yield?: string;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Name of the slot tag, where the content will be injected.
|
|
61
|
-
*
|
|
62
|
-
* @default 'slot'
|
|
63
|
-
*/
|
|
64
|
-
slot?: string;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Name of the fill tag, where the content to be injected is defined.
|
|
68
|
-
*
|
|
69
|
-
* @default 'fill'
|
|
70
|
-
*/
|
|
71
|
-
fill?: string;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* String to use as a separator between the slot tag and its name.
|
|
75
|
-
*
|
|
76
|
-
* @default ':'
|
|
77
|
-
*/
|
|
78
|
-
slotSeparator?: string;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Tag name for pushing content to a stack.
|
|
82
|
-
*
|
|
83
|
-
* @default 'push'
|
|
84
|
-
*/
|
|
85
|
-
push?: string;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Tag name for popping (rendering) content from a stack.
|
|
89
|
-
*
|
|
90
|
-
* @default 'stack'
|
|
91
|
-
*/
|
|
92
|
-
stack?: string;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Name of the props attribute to use in the `<script>` tag of a component.
|
|
96
|
-
*
|
|
97
|
-
* @default 'props'
|
|
98
|
-
*/
|
|
99
|
-
propsScriptAttribute?: string;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Name of the object that will be used to store the props of a component.
|
|
103
|
-
*
|
|
104
|
-
* @default 'props'
|
|
105
|
-
*/
|
|
106
|
-
propsContext?: string;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Name of the attribute that will be used to pass props to a component as JSON.
|
|
110
|
-
*
|
|
111
|
-
* @default 'locals'
|
|
112
|
-
*/
|
|
113
|
-
propsAttribute?: string;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Name of the key to use when retrieving props passed to a slot via `$slots.slotName.props`.
|
|
117
|
-
*
|
|
118
|
-
* @default 'props'
|
|
119
|
-
*/
|
|
120
|
-
propsSlot?: string;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Configure [`posthtml-parser`](https://github.com/posthtml/posthtml-parser).
|
|
124
|
-
*
|
|
125
|
-
* @default
|
|
126
|
-
* {
|
|
127
|
-
* recognizeNoValueAttribute: true,
|
|
128
|
-
* recognizeSelfClosing: true
|
|
129
|
-
* }
|
|
130
|
-
*/
|
|
131
|
-
parserOptions?: PostHTMLParserOptions;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Configure [`posthtml-expressions`](https://github.com/posthtml/posthtml-expressions).
|
|
135
|
-
*
|
|
136
|
-
* @default
|
|
137
|
-
* {
|
|
138
|
-
* strictMode: false,
|
|
139
|
-
* missingLocal: '{local}',
|
|
140
|
-
* locals: {
|
|
141
|
-
* page: config, // the computed Maizzle config object
|
|
142
|
-
* }
|
|
143
|
-
* }
|
|
144
|
-
*/
|
|
145
|
-
expressions?: ExpressionsConfig;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* PostHTML plugins to apply to each parsed component.
|
|
149
|
-
*
|
|
150
|
-
* @default []
|
|
151
|
-
*/
|
|
152
|
-
plugins?: Array<() => void>;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Extra rules for the PostHTML plugin that is used by components to parse attributes.
|
|
156
|
-
*
|
|
157
|
-
* @default {}
|
|
158
|
-
*/
|
|
159
|
-
attrsParserRules?: Record<string, AnyObject>;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* In strict mode, an error will be thrown if a component cannot be rendered.
|
|
163
|
-
*
|
|
164
|
-
* @default true
|
|
165
|
-
*/
|
|
166
|
-
strict?: boolean;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Utility methods to be passed to `<script props>` in a component.
|
|
170
|
-
*
|
|
171
|
-
* @default {merge: _.mergeWith, template: _.template}
|
|
172
|
-
*/
|
|
173
|
-
utilities?: Record<string, unknown>;
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Define additional attributes that should be preserved for specific HTML elements.
|
|
177
|
-
*
|
|
178
|
-
* @default {}
|
|
179
|
-
*/
|
|
180
|
-
elementAttributes?: Record<string, void>;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Attributes that should be preserved on all elements in components.
|
|
184
|
-
*
|
|
185
|
-
* @default ['data-*']
|
|
186
|
-
*/
|
|
187
|
-
safelistAttributes?: string[];
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Attributes that should be removed from all elements in components.
|
|
191
|
-
*
|
|
192
|
-
* @default []
|
|
193
|
-
*/
|
|
194
|
-
blacklistAttributes?: string[];
|
|
195
|
-
}
|
package/types/expressions.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
export default interface ExpressionsConfig {
|
|
2
|
-
/**
|
|
3
|
-
Define the starting and ending delimiters used for expressions.
|
|
4
|
-
|
|
5
|
-
@default ['{{', '}}']
|
|
6
|
-
*/
|
|
7
|
-
delimiters?: string[];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
Define the starting and ending delimiters used for unescaped expressions.
|
|
11
|
-
|
|
12
|
-
@default ['{{{', '}}}']
|
|
13
|
-
*/
|
|
14
|
-
unescapeDelimiters?: string[];
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
Object containing data that will be available under the `page` object.
|
|
18
|
-
|
|
19
|
-
@default {}
|
|
20
|
-
*/
|
|
21
|
-
locals?: Record<string, unknown>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
Attribute name for `<script>` tags that contain locals.
|
|
25
|
-
|
|
26
|
-
@default 'locals'
|
|
27
|
-
*/
|
|
28
|
-
localsAttr?: string;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
Whether to remove `<script>` tags that contain locals.
|
|
32
|
-
|
|
33
|
-
@default false
|
|
34
|
-
*/
|
|
35
|
-
removeScriptLocals?: boolean;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
Tag names to be used for if/else statements.
|
|
39
|
-
|
|
40
|
-
@default ['if', 'elseif', 'else']
|
|
41
|
-
*/
|
|
42
|
-
conditionalTags?: string[];
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
Tag names to be used for switch statements.
|
|
46
|
-
|
|
47
|
-
@default ['switch', 'case', 'default']
|
|
48
|
-
*/
|
|
49
|
-
switchTags?: string[];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
Tag names to be used for loops.
|
|
53
|
-
|
|
54
|
-
@default ['each', 'for']
|
|
55
|
-
*/
|
|
56
|
-
loopTags?: string[];
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
Tag names to be used for scopes.
|
|
60
|
-
|
|
61
|
-
@default ['scope']
|
|
62
|
-
*/
|
|
63
|
-
scopeTags?: string[];
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
Name of tag inside of which expression parsing is disabled.
|
|
67
|
-
|
|
68
|
-
@default 'raw'
|
|
69
|
-
*/
|
|
70
|
-
ignoredTag?: string;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
Enabling strict mode will throw an error if an expression cannot be evaluated.
|
|
74
|
-
|
|
75
|
-
@default false
|
|
76
|
-
*/
|
|
77
|
-
strictMode?: boolean;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
What to render when referencing a value that is not defined in `locals`.
|
|
81
|
-
|
|
82
|
-
By default, the string 'undefined' will be output.
|
|
83
|
-
|
|
84
|
-
@default undefined
|
|
85
|
-
|
|
86
|
-
@example
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
// Output empty string if value is not defined
|
|
90
|
-
missingLocal: ''
|
|
91
|
-
|
|
92
|
-
// Output original reference if value is not defined
|
|
93
|
-
missingLocal: '{local}'
|
|
94
|
-
|
|
95
|
-
// Output custom string if value is not defined
|
|
96
|
-
missingLocal: 'ERR_NO_VALUE: {local}'
|
|
97
|
-
```
|
|
98
|
-
*/
|
|
99
|
-
missingLocal?: string;
|
|
100
|
-
}
|