@maizzle/framework 5.0.0-beta.23 → 5.0.0-beta.25
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 +8 -8
- package/src/generators/render.js +7 -7
- package/src/posthtml/index.js +2 -2
- package/src/server/index.js +5 -5
- package/src/server/routes/index.js +1 -1
- package/src/server/views/index.html +25 -0
- package/src/transformers/inline.js +7 -2
- package/src/transformers/markdown.js +14 -5
- package/src/transformers/prettify.js +2 -1
- package/src/transformers/template.js +9 -9
- package/types/build.d.ts +0 -6
- package/types/config.d.ts +9 -4
- package/types/index.d.ts +4 -3
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.25",
|
|
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",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"html-emails"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@csstools/css-calc": "^
|
|
51
|
+
"@csstools/css-calc": "^2.0.1",
|
|
52
52
|
"@maizzle/cli": "next",
|
|
53
|
-
"cheerio": "1.0.0
|
|
53
|
+
"cheerio": "^1.0.0",
|
|
54
54
|
"chokidar": "^3.6.0",
|
|
55
55
|
"cli-table3": "^0.6.5",
|
|
56
56
|
"color-shorthand-hex-to-six-digit": "^5.0.16",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"html-crush": "^6.0.18",
|
|
63
63
|
"is-url-superb": "^6.1.0",
|
|
64
64
|
"istextorbinary": "^9.5.0",
|
|
65
|
-
"juice": "^
|
|
65
|
+
"juice": "^11.0.0",
|
|
66
66
|
"lodash-es": "^4.17.21",
|
|
67
67
|
"morphdom": "^2.7.4",
|
|
68
|
-
"ora": "^8.0
|
|
68
|
+
"ora": "^8.1.0",
|
|
69
69
|
"pathe": "^1.1.2",
|
|
70
70
|
"postcss": "^8.4.39",
|
|
71
|
-
"postcss-custom-properties": "^
|
|
71
|
+
"postcss-custom-properties": "^14.0.1",
|
|
72
72
|
"postcss-import": "^16.1.0",
|
|
73
73
|
"postcss-safe-parser": "^7.0.0",
|
|
74
74
|
"posthtml": "^0.16.6",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"pretty": "^2.0.0",
|
|
91
91
|
"string-remove-widows": "^4.0.22",
|
|
92
92
|
"string-strip-html": "^13.4.8",
|
|
93
|
-
"tailwindcss": "^3.4.
|
|
93
|
+
"tailwindcss": "^3.4.10",
|
|
94
94
|
"ws": "^8.17.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
@@ -102,6 +102,6 @@
|
|
|
102
102
|
"vitest": "^2.0.1"
|
|
103
103
|
},
|
|
104
104
|
"engines": {
|
|
105
|
-
"node": ">=18.
|
|
105
|
+
"node": ">=18.20"
|
|
106
106
|
}
|
|
107
107
|
}
|
package/src/generators/render.js
CHANGED
|
@@ -70,7 +70,9 @@ export async function render(html = '', config = {}) {
|
|
|
70
70
|
})) ?? content
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Compile PostHTML
|
|
75
|
+
*/
|
|
74
76
|
const compiled = await compilePostHTML(content, templateConfig)
|
|
75
77
|
|
|
76
78
|
/**
|
|
@@ -86,11 +88,10 @@ export async function render(html = '', config = {}) {
|
|
|
86
88
|
compiled.html = await templateConfig.afterRender(({
|
|
87
89
|
html: compiled.html,
|
|
88
90
|
matter: matterData,
|
|
89
|
-
config:
|
|
91
|
+
config: compiled.config,
|
|
90
92
|
})) ?? compiled.html
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
// Run Transformers
|
|
94
95
|
/**
|
|
95
96
|
* Run Transformers
|
|
96
97
|
*
|
|
@@ -101,10 +102,9 @@ export async function render(html = '', config = {}) {
|
|
|
101
102
|
* @returns {string} - The transformed HTML
|
|
102
103
|
*/
|
|
103
104
|
if (templateConfig.useTransformers !== false) {
|
|
104
|
-
compiled.html = await useTransformers(compiled.html,
|
|
105
|
+
compiled.html = await useTransformers(compiled.html, compiled.config).then(({ html }) => html)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
// Run `afterTransformers` event
|
|
108
108
|
/**
|
|
109
109
|
* Run `afterTransformers` event
|
|
110
110
|
*
|
|
@@ -118,12 +118,12 @@ export async function render(html = '', config = {}) {
|
|
|
118
118
|
compiled.html = await templateConfig.afterTransformers(({
|
|
119
119
|
html: compiled.html,
|
|
120
120
|
matter: matterData,
|
|
121
|
-
config:
|
|
121
|
+
config: compiled.config,
|
|
122
122
|
})) ?? compiled.html
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
return {
|
|
126
|
-
config:
|
|
126
|
+
config: compiled.config,
|
|
127
127
|
html: compiled.html,
|
|
128
128
|
}
|
|
129
129
|
}
|
package/src/posthtml/index.js
CHANGED
|
@@ -41,7 +41,7 @@ export async function process(html = '', config = {}) {
|
|
|
41
41
|
const componentsUserOptions = get(config, 'components', {})
|
|
42
42
|
|
|
43
43
|
const expressionsOptions = merge(
|
|
44
|
-
get(config, '
|
|
44
|
+
get(config, 'expressions', get(config, 'posthtml.expressions', {})),
|
|
45
45
|
get(componentsUserOptions, 'expressions', {}),
|
|
46
46
|
)
|
|
47
47
|
|
|
@@ -94,7 +94,7 @@ export async function process(html = '', config = {}) {
|
|
|
94
94
|
])
|
|
95
95
|
.process(html, posthtmlOptions)
|
|
96
96
|
.then(result => ({
|
|
97
|
-
config,
|
|
97
|
+
config: merge(config, { page: config }),
|
|
98
98
|
html: result.html,
|
|
99
99
|
}))
|
|
100
100
|
.catch(error => {
|
package/src/server/index.js
CHANGED
|
@@ -63,7 +63,7 @@ async function renderUpdatedFile(file, config) {
|
|
|
63
63
|
|
|
64
64
|
// beforeCreate event
|
|
65
65
|
if (typeof config.beforeCreate === 'function') {
|
|
66
|
-
await config.beforeCreate(config)
|
|
66
|
+
await config.beforeCreate({ config })
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// Read the file
|
|
@@ -128,7 +128,7 @@ export default async (config = {}) => {
|
|
|
128
128
|
* Initialize WebSocket server
|
|
129
129
|
* Used to send messages between the server and the browser
|
|
130
130
|
*/
|
|
131
|
-
initWebSockets(wss, {
|
|
131
|
+
initWebSockets(wss, { shouldScroll, useHmr })
|
|
132
132
|
|
|
133
133
|
// Register routes
|
|
134
134
|
templatePaths = await getUpdatedRoutes(app, config)
|
|
@@ -164,11 +164,11 @@ export default async (config = {}) => {
|
|
|
164
164
|
app.get(routePattern, async (req, res, next) => {
|
|
165
165
|
// Run beforeCreate event
|
|
166
166
|
if (typeof config.beforeCreate === 'function') {
|
|
167
|
-
config.beforeCreate(config)
|
|
167
|
+
await config.beforeCreate({ config })
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
try {
|
|
171
|
-
const filePath = templatePaths.find(t => t.endsWith(req.url.slice(1)))
|
|
171
|
+
const filePath = templatePaths.find(t => t.endsWith(decodeURI(req.url.slice(1))))
|
|
172
172
|
|
|
173
173
|
// Set the file being viewed
|
|
174
174
|
viewing = filePath
|
|
@@ -288,7 +288,7 @@ export default async (config = {}) => {
|
|
|
288
288
|
|
|
289
289
|
// Run beforeCreate event
|
|
290
290
|
if (typeof config.beforeCreate === 'function') {
|
|
291
|
-
await config.beforeCreate(config)
|
|
291
|
+
await config.beforeCreate({ config })
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
// Read the file
|
|
@@ -79,6 +79,11 @@
|
|
|
79
79
|
border-left: 1px solid #64748B;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
li.folder.nested > strong {
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
display: block;
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
li.folder.root {
|
|
83
88
|
padding-top: 3rem;
|
|
84
89
|
border: none;
|
|
@@ -92,6 +97,15 @@
|
|
|
92
97
|
line-height: 2.25rem;
|
|
93
98
|
}
|
|
94
99
|
|
|
100
|
+
li.file.nested.collapsed {
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
li.file.nested.collapsed + .folder.nested {
|
|
105
|
+
padding-top: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
95
109
|
li.file.nested a {
|
|
96
110
|
padding-bottom: 0.75rem;
|
|
97
111
|
margin-left: -1.5rem;
|
|
@@ -143,5 +157,16 @@
|
|
|
143
157
|
</ul>
|
|
144
158
|
|
|
145
159
|
<svg fill="none" stroke="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 993 483" class="insignia"><mask id="a" style="mask-type:alpha;" maskUnits="userSpaceOnUse" x="0" y="0" width="993" height="483"><path fill="#D9D9D9" d="M0 0h993v483H0z"></path></mask><g mask="url(#a)" stroke="#e2e8f0" stroke-miterlimit="10"><path d="M954.124 81.816c0-45.163-39.678-81.774-88.624-81.774-48.945 0-88.624 36.611-88.624 81.774v436.13c0 45.163 39.679 81.775 88.624 81.775 48.946 0 88.624-36.612 88.624-81.775V81.816ZM583.379 81.816c0-45.163-39.678-81.774-88.624-81.774-48.945 0-88.624 36.611-88.624 81.774v436.13c0 45.163 39.679 81.775 88.624 81.775 48.946 0 88.624-36.612 88.624-81.775V81.816Z"></path><path d="M935.39 132.185c30.161-35.57 23.362-86.965-15.187-114.795S825.954-4.165 795.794 31.404L425.713 467.848c-30.161 35.57-23.361 86.965 15.187 114.795 38.549 27.829 94.249 21.555 124.41-14.014l370.08-436.444ZM564.288 132.196c30.161-35.569 23.362-86.964-15.187-114.794S454.852-4.154 424.692 31.416L54.611 467.86c-30.16 35.569-23.361 86.965 15.187 114.794 38.549 27.83 94.249 21.556 124.41-14.013l370.08-436.445Z"></path></g></svg>
|
|
160
|
+
<script>
|
|
161
|
+
document.querySelectorAll('.folder.nested').forEach(folder => {
|
|
162
|
+
folder.addEventListener('click', function() {
|
|
163
|
+
let nextElement = this.nextElementSibling;
|
|
164
|
+
while (nextElement && nextElement.classList.contains('file') && nextElement.classList.contains('nested')) {
|
|
165
|
+
nextElement.classList.toggle('collapsed');
|
|
166
|
+
nextElement = nextElement.nextElementSibling;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
</script>
|
|
146
171
|
</body>
|
|
147
172
|
</html>
|
|
@@ -2,11 +2,11 @@ import juice from 'juice'
|
|
|
2
2
|
import postcss from 'postcss'
|
|
3
3
|
import get from 'lodash-es/get.js'
|
|
4
4
|
import has from 'lodash-es/has.js'
|
|
5
|
+
import * as cheerio from 'cheerio/slim'
|
|
5
6
|
import remove from 'lodash-es/remove.js'
|
|
6
7
|
import { render } from 'posthtml-render'
|
|
7
8
|
import { calc } from '@csstools/css-calc'
|
|
8
9
|
import isEmpty from 'lodash-es/isEmpty.js'
|
|
9
|
-
import * as cheerio from 'cheerio/lib/slim'
|
|
10
10
|
import safeParser from 'postcss-safe-parser'
|
|
11
11
|
import isObject from 'lodash-es/isObject.js'
|
|
12
12
|
import { parser as parse } from 'posthtml-parser'
|
|
@@ -47,7 +47,12 @@ export async function inline(html = '', options = {}) {
|
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const $ = cheerio.load(html, {
|
|
50
|
+
const $ = cheerio.load(html, {
|
|
51
|
+
xml: {
|
|
52
|
+
decodeEntities: false,
|
|
53
|
+
xmlMode: false,
|
|
54
|
+
}
|
|
55
|
+
})
|
|
51
56
|
|
|
52
57
|
// Add a `data-embed` attribute to style tags that have the embed attribute
|
|
53
58
|
$('style[embed]').each((i, el) => {
|
|
@@ -3,17 +3,26 @@ import { defu as merge } from 'defu'
|
|
|
3
3
|
import md from 'posthtml-markdownit'
|
|
4
4
|
import posthtmlConfig from '../posthtml/defaultConfig.js'
|
|
5
5
|
|
|
6
|
-
export async function markdown(
|
|
6
|
+
export async function markdown(input = '', options = {}, posthtmlOptions = {}) {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
|
|
8
|
+
* If no input is provided, return an empty string.
|
|
9
|
+
*/
|
|
10
|
+
if (!input) {
|
|
11
|
+
return ''
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Automatically wrap in <md> tag, unless manual mode is enabled.
|
|
16
|
+
*
|
|
17
|
+
* With manual mode, user must wrap the input in a <md> tag.
|
|
18
|
+
*
|
|
10
19
|
* https://github.com/posthtml/posthtml-markdownit#usage
|
|
11
20
|
*/
|
|
12
|
-
|
|
21
|
+
input = options.manual ? input : `<md>${input}</md>`
|
|
13
22
|
|
|
14
23
|
return posthtml([
|
|
15
24
|
md(options)
|
|
16
25
|
])
|
|
17
|
-
.process(
|
|
26
|
+
.process(input, merge(posthtmlOptions, posthtmlConfig))
|
|
18
27
|
.then(result => result.html)
|
|
19
28
|
}
|
|
@@ -2,6 +2,7 @@ import pretty from 'pretty'
|
|
|
2
2
|
import posthtml from 'posthtml'
|
|
3
3
|
import { defu as merge } from 'defu'
|
|
4
4
|
import { render } from 'posthtml-render'
|
|
5
|
+
import { parser as parse } from 'posthtml-parser'
|
|
5
6
|
import posthtmlConfig from '../posthtml/defaultConfig.js'
|
|
6
7
|
|
|
7
8
|
const posthtmlPlugin = (options = {}) => tree => {
|
|
@@ -14,7 +15,7 @@ const posthtmlPlugin = (options = {}) => tree => {
|
|
|
14
15
|
|
|
15
16
|
const config = merge(options, defaultConfig)
|
|
16
17
|
|
|
17
|
-
return pretty(render(tree), config)
|
|
18
|
+
return parse(pretty(render(tree), config), posthtmlConfig)
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export default posthtmlPlugin
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const posthtmlPlugin = (
|
|
1
|
+
const posthtmlPlugin = () => tree => {
|
|
2
2
|
const process = node => {
|
|
3
3
|
// Return the original node if it doesn't have a tag
|
|
4
4
|
if (!node.tag) {
|
|
5
5
|
return node
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
node.attrs
|
|
8
|
+
if (node.tag === 'template') {
|
|
9
|
+
// Preserve <template> tags marked as such
|
|
10
|
+
if ('attrs' in node && 'preserve' in node.attrs) {
|
|
11
|
+
node.attrs.preserve = false
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
return node
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
if (node.tag === 'template') {
|
|
16
|
+
// Remove the <template> tag
|
|
17
17
|
node.tag = false
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,6 +21,6 @@ const posthtmlPlugin = (() => tree => {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return tree.walk(process)
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
|
|
26
26
|
export default posthtmlPlugin
|
package/types/build.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SpinnerName } from 'cli-spinners';
|
|
2
|
-
import type { PostHTMLExpressions } from 'posthtml-expressions';
|
|
3
2
|
|
|
4
3
|
export default interface BuildConfig {
|
|
5
4
|
/**
|
|
@@ -18,11 +17,6 @@ export default interface BuildConfig {
|
|
|
18
17
|
*/
|
|
19
18
|
content?: string[];
|
|
20
19
|
|
|
21
|
-
/**
|
|
22
|
-
Configure [posthtml-expressions](https://github.com/posthtml/posthtml-expressions) options.
|
|
23
|
-
*/
|
|
24
|
-
expressions?: PostHTMLExpressions;
|
|
25
|
-
|
|
26
20
|
/**
|
|
27
21
|
* Define the output path for compiled Templates, and what file extension they should use.
|
|
28
22
|
*
|
package/types/config.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ import type { CoreBeautifyOptions } from 'js-beautify';
|
|
|
13
13
|
import type { BaseURLConfig } from 'posthtml-base-url';
|
|
14
14
|
import type URLParametersConfig from './urlParameters';
|
|
15
15
|
import type { PostHTMLFetchConfig } from 'posthtml-fetch';
|
|
16
|
-
import type { PostHTMLComponents } from 'posthtml-component';
|
|
17
|
-
|
|
18
16
|
import type { Config as TailwindConfig } from 'tailwindcss';
|
|
17
|
+
import type { PostHTMLComponents } from 'posthtml-component';
|
|
18
|
+
import type { PostHTMLExpressions } from 'posthtml-expressions';
|
|
19
19
|
|
|
20
20
|
export default interface Config {
|
|
21
21
|
/**
|
|
@@ -170,6 +170,11 @@ export default interface Config {
|
|
|
170
170
|
tailwind?: TailwindConfig;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
Configure [posthtml-expressions](https://github.com/posthtml/posthtml-expressions) options.
|
|
175
|
+
*/
|
|
176
|
+
expressions?: PostHTMLExpressions;
|
|
177
|
+
|
|
173
178
|
/**
|
|
174
179
|
* Configure the [`<fetch>`](https://maizzle.com/docs/tags#fetch) tag.
|
|
175
180
|
*/
|
|
@@ -370,11 +375,11 @@ export default interface Config {
|
|
|
370
375
|
hmr?: boolean;
|
|
371
376
|
|
|
372
377
|
/**
|
|
373
|
-
* Enable synchronized scrolling across
|
|
378
|
+
* Enable synchronized scrolling across browser tabs.
|
|
374
379
|
*
|
|
375
380
|
* @default false
|
|
376
381
|
*/
|
|
377
|
-
|
|
382
|
+
scrollSync?: boolean;
|
|
378
383
|
|
|
379
384
|
/**
|
|
380
385
|
* Paths to watch for changes.
|
package/types/index.d.ts
CHANGED
|
@@ -37,10 +37,11 @@ declare namespace MaizzleFramework {
|
|
|
37
37
|
*
|
|
38
38
|
* @param {string} input The Markdown string to compile.
|
|
39
39
|
* @param {MarkdownConfig} [options] A configuration object for the Markdown compiler.
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
40
|
+
* @param {PostHTMLConfig} [posthtmlOptions] A configuration object for PostHTML.
|
|
41
|
+
* @returns {Promise<string>} The compiled HTML string.
|
|
42
|
+
* @see https://maizzle.com/docs/markdown#api
|
|
42
43
|
*/
|
|
43
|
-
function markdown(input: string, options?: MarkdownConfig): string
|
|
44
|
+
function markdown(input: string, options?: MarkdownConfig, posthtmlOptions?: PostHTMLConfig): Promise<string>;
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Prevent widow words inside a tag by adding a ` ` between its last two words.
|