@maizzle/framework 5.0.0-beta.14 → 5.0.0-beta.16
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 +14 -12
- package/src/posthtml/index.js +19 -1
- package/src/server/index.js +106 -67
- package/types/build.d.ts +3 -3
- package/types/config.d.ts +10 -10
- package/types/css/purge.d.ts +1 -1
- package/types/posthtml.d.ts +3 -3
- package/types/components.d.ts +0 -195
- package/types/expressions.d.ts +0 -100
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maizzle/framework",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.16",
|
|
4
4
|
"description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -72,23 +72,25 @@
|
|
|
72
72
|
"postcss-import": "^16.1.0",
|
|
73
73
|
"postcss-safe-parser": "^7.0.0",
|
|
74
74
|
"posthtml": "^0.16.6",
|
|
75
|
-
"posthtml-attrs-parser": "^1.1.
|
|
75
|
+
"posthtml-attrs-parser": "^1.1.1",
|
|
76
76
|
"posthtml-base-url": "^3.1.4",
|
|
77
|
-
"posthtml-component": "^
|
|
78
|
-
"posthtml-content": "^2.0
|
|
79
|
-
"posthtml-
|
|
80
|
-
"posthtml-
|
|
81
|
-
"posthtml-
|
|
77
|
+
"posthtml-component": "^2.0.0",
|
|
78
|
+
"posthtml-content": "^2.1.0",
|
|
79
|
+
"posthtml-expressions": "^1.11.4",
|
|
80
|
+
"posthtml-extra-attributes": "^3.1.0",
|
|
81
|
+
"posthtml-fetch": "^4.0.0",
|
|
82
|
+
"posthtml-markdownit": "^3.1.0",
|
|
83
|
+
"posthtml-mso": "^3.1.0",
|
|
82
84
|
"posthtml-parser": "^0.12.0",
|
|
83
|
-
"posthtml-postcss": "^1.0.
|
|
84
|
-
"posthtml-postcss-merge-longhand": "^3.1.
|
|
85
|
+
"posthtml-postcss": "^1.0.2",
|
|
86
|
+
"posthtml-postcss-merge-longhand": "^3.1.2",
|
|
85
87
|
"posthtml-render": "^3.0.0",
|
|
86
|
-
"posthtml-safe-class-names": "^4.0
|
|
87
|
-
"posthtml-url-parameters": "^3.
|
|
88
|
+
"posthtml-safe-class-names": "^4.1.0",
|
|
89
|
+
"posthtml-url-parameters": "^3.1.0",
|
|
88
90
|
"pretty": "^2.0.0",
|
|
89
91
|
"string-remove-widows": "^4.0.22",
|
|
90
92
|
"string-strip-html": "^13.4.8",
|
|
91
|
-
"tailwindcss": "^3.4.
|
|
93
|
+
"tailwindcss": "^3.4.7",
|
|
92
94
|
"ws": "^8.17.0"
|
|
93
95
|
},
|
|
94
96
|
"devDependencies": {
|
package/src/posthtml/index.js
CHANGED
|
@@ -3,12 +3,13 @@ import { defu as merge } from 'defu'
|
|
|
3
3
|
|
|
4
4
|
// PostHTML
|
|
5
5
|
import posthtml from 'posthtml'
|
|
6
|
+
import posthtmlFetch from 'posthtml-fetch'
|
|
7
|
+
import envTags from './plugins/envTags.js'
|
|
6
8
|
import components from 'posthtml-component'
|
|
7
9
|
import posthtmlPostcss from 'posthtml-postcss'
|
|
8
10
|
import defaultPosthtmlConfig from './defaultConfig.js'
|
|
9
11
|
import expandLinkTag from './plugins/expandLinkTag.js'
|
|
10
12
|
import envAttributes from './plugins/envAttributes.js'
|
|
11
|
-
import envTags from './plugins/envTags.js'
|
|
12
13
|
|
|
13
14
|
// PostCSS
|
|
14
15
|
import tailwindcss from 'tailwindcss'
|
|
@@ -50,12 +51,29 @@ export async function process(html = '', config = {}) {
|
|
|
50
51
|
{ page: config },
|
|
51
52
|
)
|
|
52
53
|
|
|
54
|
+
const fetchPlugin = posthtmlFetch(
|
|
55
|
+
merge(
|
|
56
|
+
{
|
|
57
|
+
expressions: merge(
|
|
58
|
+
locals,
|
|
59
|
+
expressionsOptions,
|
|
60
|
+
{
|
|
61
|
+
missingLocal: '{local}',
|
|
62
|
+
strictMode: false,
|
|
63
|
+
},
|
|
64
|
+
),
|
|
65
|
+
},
|
|
66
|
+
get(config, 'build.fetch', {})
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
|
|
53
70
|
return posthtml([
|
|
54
71
|
...get(config, 'posthtml.plugins.before', []),
|
|
55
72
|
envTags(config.env),
|
|
56
73
|
envAttributes(config.env),
|
|
57
74
|
expandLinkTag,
|
|
58
75
|
postcssPlugin,
|
|
76
|
+
fetchPlugin,
|
|
59
77
|
components(
|
|
60
78
|
merge(
|
|
61
79
|
{
|
package/src/server/index.js
CHANGED
|
@@ -40,6 +40,71 @@ app.use(hmrRoute)
|
|
|
40
40
|
|
|
41
41
|
let viewing = ''
|
|
42
42
|
const spinner = ora()
|
|
43
|
+
let templatePaths = []
|
|
44
|
+
|
|
45
|
+
function getTemplateFolders(config) {
|
|
46
|
+
return Array.isArray(get(config, 'build.content'))
|
|
47
|
+
? config.build.content
|
|
48
|
+
: [config.build.content]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function getTemplatePaths(templateFolders) {
|
|
52
|
+
return await fg.glob([...new Set(templateFolders)])
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function getUpdatedRoutes(app, config) {
|
|
56
|
+
return getTemplatePaths(getTemplateFolders(config))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function renderUpdatedFile(file, config) {
|
|
60
|
+
try {
|
|
61
|
+
const startTime = Date.now()
|
|
62
|
+
spinner.start('Building...')
|
|
63
|
+
|
|
64
|
+
// beforeCreate event
|
|
65
|
+
if (typeof config.beforeCreate === 'function') {
|
|
66
|
+
await config.beforeCreate(config)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Read the file
|
|
70
|
+
const fileContent = await fs.readFile(file, 'utf8')
|
|
71
|
+
|
|
72
|
+
// Set a `dev` flag on the config
|
|
73
|
+
config._dev = true
|
|
74
|
+
|
|
75
|
+
// Render the file with PostHTML
|
|
76
|
+
let { html } = await render(fileContent, config)
|
|
77
|
+
|
|
78
|
+
// Update console message
|
|
79
|
+
const shouldReportFileSize = get(config, 'server.reportFileSize', false)
|
|
80
|
+
|
|
81
|
+
spinner.succeed(
|
|
82
|
+
`Done in ${formatTime(Date.now() - startTime)}`
|
|
83
|
+
+ `${pico.gray(` [${path.relative(cwd(), file)}]`)}`
|
|
84
|
+
+ `${shouldReportFileSize ? ' · ' + getColorizedFileSize(html) : ''}`
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Inject HMR script
|
|
89
|
+
*/
|
|
90
|
+
html = injectScript(html, '<script src="/hmr.js"></script>')
|
|
91
|
+
|
|
92
|
+
// Notify connected websocket clients about the change
|
|
93
|
+
wss.clients.forEach(client => {
|
|
94
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
95
|
+
client.send(JSON.stringify({
|
|
96
|
+
type: 'change',
|
|
97
|
+
content: html,
|
|
98
|
+
scrollSync: get(config, 'server.scrollSync', false),
|
|
99
|
+
hmr: get(config, 'server.hmr', true),
|
|
100
|
+
}))
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
} catch (error) {
|
|
104
|
+
spinner.fail('Failed to render template.')
|
|
105
|
+
throw error
|
|
106
|
+
}
|
|
107
|
+
}
|
|
43
108
|
|
|
44
109
|
export default async (config = {}) => {
|
|
45
110
|
// Read the Maizzle config file
|
|
@@ -63,16 +128,18 @@ export default async (config = {}) => {
|
|
|
63
128
|
*/
|
|
64
129
|
initWebSockets(wss, { scrollSync: shouldScroll, hmr: useHmr })
|
|
65
130
|
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
? config.build.content
|
|
69
|
-
: [config.build.content]
|
|
131
|
+
// Register routes
|
|
132
|
+
templatePaths = await getUpdatedRoutes(app, config)
|
|
70
133
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Store template paths on the request object
|
|
136
|
+
*
|
|
137
|
+
* We use it in the index view to list all templates.
|
|
138
|
+
* */
|
|
74
139
|
app.request.templatePaths = templatePaths
|
|
75
140
|
|
|
141
|
+
// await updateRoutes(app, config)
|
|
142
|
+
|
|
76
143
|
/**
|
|
77
144
|
* Create route pattern
|
|
78
145
|
* Only allow files with the following extensions
|
|
@@ -84,7 +151,7 @@ export default async (config = {}) => {
|
|
|
84
151
|
)
|
|
85
152
|
].join('|')
|
|
86
153
|
|
|
87
|
-
const routePattern = Array.isArray(
|
|
154
|
+
const routePattern = Array.isArray(getTemplateFolders(config))
|
|
88
155
|
? `*/:file.(${extensions})`
|
|
89
156
|
: `:file.(${extensions})`
|
|
90
157
|
|
|
@@ -127,7 +194,7 @@ export default async (config = {}) => {
|
|
|
127
194
|
})
|
|
128
195
|
|
|
129
196
|
// Error-handling middleware
|
|
130
|
-
app.use(async (error, req, res, next) => {
|
|
197
|
+
app.use(async (error, req, res, next) => {
|
|
131
198
|
console.error(error)
|
|
132
199
|
|
|
133
200
|
const view = await fs.readFile(path.join(__dirname, 'views', 'error.html'), 'utf8')
|
|
@@ -145,60 +212,32 @@ export default async (config = {}) => {
|
|
|
145
212
|
*
|
|
146
213
|
* Watches for changes in the configured Templates and Components paths
|
|
147
214
|
*/
|
|
215
|
+
let isWatcherReady = false
|
|
148
216
|
chokidar
|
|
149
|
-
.watch([...templatePaths, ...get(config, 'components.folders', defaultComponentsConfig.folders)
|
|
217
|
+
.watch([...templatePaths, ...get(config, 'components.folders', defaultComponentsConfig.folders)])
|
|
150
218
|
.on('change', async () => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return
|
|
219
|
+
if (viewing) {
|
|
220
|
+
await renderUpdatedFile(viewing, config)
|
|
154
221
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
// Update console message
|
|
175
|
-
const shouldReportFileSize = get(config, 'server.reportFileSize', false)
|
|
176
|
-
|
|
177
|
-
spinner.succeed(
|
|
178
|
-
`Done in ${formatTime(Date.now() - startTime)}`
|
|
179
|
-
+ `${pico.gray(` [${path.relative(cwd(), viewing)}]`)}`
|
|
180
|
-
+ `${ shouldReportFileSize ? ' · ' + getColorizedFileSize(html) : ''}`
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Inject HMR script
|
|
185
|
-
*/
|
|
186
|
-
html = injectScript(html, '<script src="/hmr.js"></script>')
|
|
187
|
-
|
|
188
|
-
// Notify connected websocket clients about the change
|
|
189
|
-
wss.clients.forEach(client => {
|
|
190
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
191
|
-
client.send(JSON.stringify({
|
|
192
|
-
type: 'change',
|
|
193
|
-
content: html,
|
|
194
|
-
scrollSync: get(config, 'server.scrollSync', false),
|
|
195
|
-
hmr: get(config, 'server.hmr', true),
|
|
196
|
-
}))
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
} catch (error) {
|
|
200
|
-
spinner.fail('Failed to render template.')
|
|
201
|
-
throw error
|
|
222
|
+
})
|
|
223
|
+
.on('ready', () => {
|
|
224
|
+
/**
|
|
225
|
+
* `add` fires immediately when the watcher is created,
|
|
226
|
+
* so we use this trick to detect new files added
|
|
227
|
+
* after it has started.
|
|
228
|
+
*/
|
|
229
|
+
isWatcherReady = true
|
|
230
|
+
})
|
|
231
|
+
.on('add', async () => {
|
|
232
|
+
if (isWatcherReady) {
|
|
233
|
+
templatePaths = await getUpdatedRoutes(app, config)
|
|
234
|
+
app.request.templatePaths = templatePaths
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
.on('unlink', async () => {
|
|
238
|
+
if (isWatcherReady) {
|
|
239
|
+
templatePaths = await getUpdatedRoutes(app, config)
|
|
240
|
+
app.request.templatePaths = templatePaths
|
|
202
241
|
}
|
|
203
242
|
})
|
|
204
243
|
|
|
@@ -255,7 +294,7 @@ export default async (config = {}) => {
|
|
|
255
294
|
spinner.succeed(
|
|
256
295
|
`Done in ${formatTime(Date.now() - startTime)}`
|
|
257
296
|
+ `${pico.gray(` [${path.relative(cwd(), filePath)}]`)}`
|
|
258
|
-
+ `${
|
|
297
|
+
+ `${shouldReportFileSize ? ' · ' + getColorizedFileSize(html) : ''}`
|
|
259
298
|
)
|
|
260
299
|
|
|
261
300
|
/**
|
|
@@ -302,12 +341,12 @@ export default async (config = {}) => {
|
|
|
302
341
|
'**/*/',
|
|
303
342
|
...get(config, 'build.static.source', [])
|
|
304
343
|
], {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
344
|
+
onlyFiles: false,
|
|
345
|
+
ignore: [
|
|
346
|
+
'node_modules',
|
|
347
|
+
get(config, 'build.output.path', 'build_*'),
|
|
348
|
+
]
|
|
349
|
+
})
|
|
311
350
|
|
|
312
351
|
srcFoldersList.forEach(folder => {
|
|
313
352
|
app.use(express.static(path.join(config.cwd, folder)))
|
package/types/build.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SpinnerName } from 'cli-spinners';
|
|
2
|
-
import type
|
|
2
|
+
import type { PostHTMLExpressions } from 'posthtml-expressions';
|
|
3
3
|
|
|
4
4
|
export default interface BuildConfig {
|
|
5
5
|
/**
|
|
@@ -19,9 +19,9 @@ export default interface BuildConfig {
|
|
|
19
19
|
content?: string[];
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
Configure expressions.
|
|
22
|
+
Configure [posthtml-expressions](https://github.com/posthtml/posthtml-expressions) options.
|
|
23
23
|
*/
|
|
24
|
-
expressions?:
|
|
24
|
+
expressions?: PostHTMLExpressions;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Define the output path for compiled Templates, and what file extension they should use.
|
package/types/config.d.ts
CHANGED
|
@@ -8,11 +8,11 @@ import type PurgeCSSConfig from './css/purge';
|
|
|
8
8
|
import type PlaintextConfig from './plaintext';
|
|
9
9
|
import type CSSInlineConfig from './css/inline';
|
|
10
10
|
import type { SpinnerName } from 'cli-spinners';
|
|
11
|
-
import type ComponentsConfig from './components';
|
|
12
11
|
import type WidowWordsConfig from './widowWords';
|
|
13
12
|
import type { CoreBeautifyOptions } from 'js-beautify';
|
|
14
13
|
import type { BaseURLConfig } from 'posthtml-base-url';
|
|
15
14
|
import type URLParametersConfig from './urlParameters';
|
|
15
|
+
import type { PostHTMLComponents } from 'posthtml-component';
|
|
16
16
|
|
|
17
17
|
import type { Config as TailwindConfig } from 'tailwindcss';
|
|
18
18
|
|
|
@@ -62,7 +62,7 @@ export default interface Config {
|
|
|
62
62
|
/**
|
|
63
63
|
* Configure build settings.
|
|
64
64
|
*/
|
|
65
|
-
build
|
|
65
|
+
build?: BuildConfig;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
Define a string that will be prepended to sources and hrefs in your HTML and CSS.
|
|
@@ -93,12 +93,12 @@ export default interface Config {
|
|
|
93
93
|
/**
|
|
94
94
|
* Configure components.
|
|
95
95
|
*/
|
|
96
|
-
components?:
|
|
96
|
+
components?: PostHTMLComponents;
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Configure how CSS is handled.
|
|
100
100
|
*/
|
|
101
|
-
css
|
|
101
|
+
css?: {
|
|
102
102
|
/**
|
|
103
103
|
* Configure CSS inlining.
|
|
104
104
|
*/
|
|
@@ -184,7 +184,7 @@ export default interface Config {
|
|
|
184
184
|
* }
|
|
185
185
|
* ```
|
|
186
186
|
*/
|
|
187
|
-
filters
|
|
187
|
+
filters?: boolean | Record<string, (str: string) => string>;
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
190
|
* Define variables outside of the `page` object.
|
|
@@ -473,7 +473,7 @@ export default interface Config {
|
|
|
473
473
|
* }
|
|
474
474
|
* ```
|
|
475
475
|
*/
|
|
476
|
-
beforeCreate
|
|
476
|
+
beforeCreate?: Events['beforeCreate'];
|
|
477
477
|
|
|
478
478
|
/**
|
|
479
479
|
* Runs after the Template's config has been computed, but just before it is compiled.
|
|
@@ -492,7 +492,7 @@ export default interface Config {
|
|
|
492
492
|
* }
|
|
493
493
|
* ```
|
|
494
494
|
*/
|
|
495
|
-
beforeRender
|
|
495
|
+
beforeRender?: Events['beforeRender'];
|
|
496
496
|
|
|
497
497
|
/**
|
|
498
498
|
* Runs after the Template has been compiled, but before any Transformers have been applied.
|
|
@@ -511,7 +511,7 @@ export default interface Config {
|
|
|
511
511
|
* }
|
|
512
512
|
* ```
|
|
513
513
|
*/
|
|
514
|
-
afterRender
|
|
514
|
+
afterRender?: Events['afterRender'];
|
|
515
515
|
|
|
516
516
|
/**
|
|
517
517
|
* Runs after all Transformers have been applied, just before the final HTML is returned.
|
|
@@ -530,7 +530,7 @@ export default interface Config {
|
|
|
530
530
|
* }
|
|
531
531
|
* ```
|
|
532
532
|
*/
|
|
533
|
-
afterTransformers
|
|
533
|
+
afterTransformers?: Events['afterTransformers'];
|
|
534
534
|
|
|
535
535
|
/**
|
|
536
536
|
* Runs after all Templates have been compiled and output to disk.
|
|
@@ -547,7 +547,7 @@ export default interface Config {
|
|
|
547
547
|
* }
|
|
548
548
|
* ```
|
|
549
549
|
*/
|
|
550
|
-
afterBuild
|
|
550
|
+
afterBuild?: Events['afterBuild'];
|
|
551
551
|
|
|
552
552
|
[key: string]: any;
|
|
553
553
|
}
|
package/types/css/purge.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export default interface PurgeCSSConfig {
|
|
|
102
102
|
* }
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
doNotRemoveHTMLCommentsWhoseOpeningTagContains
|
|
105
|
+
doNotRemoveHTMLCommentsWhoseOpeningTagContains?: Opts['doNotRemoveHTMLCommentsWhoseOpeningTagContains'];
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* Rename all classes and IDs in both your `<style>` tags and your body HTML elements,
|
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/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
|
-
}
|