@maizzle/framework 6.0.0-rc.17 → 6.0.0-rc.19

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 (349) hide show
  1. package/bin/maizzle.mjs +1 -1
  2. package/dist/build.d.ts +6 -5
  3. package/dist/build.d.ts.map +1 -1
  4. package/dist/{build.mjs → build.js} +23 -15
  5. package/dist/build.js.map +1 -0
  6. package/dist/components/Body.vue +10 -0
  7. package/dist/components/Button.vue +86 -49
  8. package/dist/components/Column.vue +10 -0
  9. package/dist/components/Container.vue +35 -7
  10. package/dist/components/Hr.vue +33 -0
  11. package/dist/components/Html.vue +29 -1
  12. package/dist/components/Layout.vue +27 -12
  13. package/dist/components/MarkdownLayout.vue +39 -0
  14. package/dist/components/NotPlaintext.vue +14 -0
  15. package/dist/components/{Vml.vue → OutlookBg.vue} +1 -1
  16. package/dist/components/Overlap.vue +10 -0
  17. package/dist/components/Plaintext.vue +14 -0
  18. package/dist/components/Preheader.vue +3 -8
  19. package/dist/components/QrCode.vue +157 -0
  20. package/dist/components/Row.vue +10 -0
  21. package/dist/components/Section.vue +10 -0
  22. package/dist/components/Spacer.vue +28 -27
  23. package/dist/components/{utils.mjs → utils.js} +2 -2
  24. package/dist/components/utils.js.map +1 -0
  25. package/dist/composables/{defineConfig.mjs → defineConfig.js} +4 -5
  26. package/dist/composables/defineConfig.js.map +1 -0
  27. package/dist/composables/{renderContext.mjs → renderContext.js} +2 -2
  28. package/dist/composables/renderContext.js.map +1 -0
  29. package/dist/composables/useBaseUrl.d.ts +19 -0
  30. package/dist/composables/useBaseUrl.d.ts.map +1 -0
  31. package/dist/composables/useBaseUrl.js +26 -0
  32. package/dist/composables/useBaseUrl.js.map +1 -0
  33. package/dist/composables/{useConfig.mjs → useConfig.js} +2 -3
  34. package/dist/composables/useConfig.js.map +1 -0
  35. package/dist/composables/{useDoctype.mjs → useDoctype.js} +3 -4
  36. package/dist/composables/useDoctype.js.map +1 -0
  37. package/dist/composables/{useEvent.mjs → useEvent.js} +3 -4
  38. package/dist/composables/useEvent.js.map +1 -0
  39. package/dist/composables/{useFont.mjs → useFont.js} +3 -4
  40. package/dist/composables/useFont.js.map +1 -0
  41. package/dist/composables/{useOutlookFallback.mjs → useOutlookFallback.js} +2 -3
  42. package/dist/composables/useOutlookFallback.js.map +1 -0
  43. package/dist/composables/usePlaintext.d.ts +2 -0
  44. package/dist/composables/usePlaintext.d.ts.map +1 -1
  45. package/dist/composables/{usePlaintext.mjs → usePlaintext.js} +4 -4
  46. package/dist/composables/usePlaintext.js.map +1 -0
  47. package/dist/composables/{usePreheader.mjs → usePreheader.js} +3 -4
  48. package/dist/composables/usePreheader.js.map +1 -0
  49. package/dist/composables/useTransformers.d.ts +34 -0
  50. package/dist/composables/useTransformers.d.ts.map +1 -0
  51. package/dist/composables/useTransformers.js +48 -0
  52. package/dist/composables/useTransformers.js.map +1 -0
  53. package/dist/composables/useUrlQuery.d.ts +19 -0
  54. package/dist/composables/useUrlQuery.d.ts.map +1 -0
  55. package/dist/composables/useUrlQuery.js +26 -0
  56. package/dist/composables/useUrlQuery.js.map +1 -0
  57. package/dist/config/{defaults.mjs → defaults.js} +9 -3
  58. package/dist/config/defaults.js.map +1 -0
  59. package/dist/config/{index.mjs → index.js} +4 -5
  60. package/dist/config/index.js.map +1 -0
  61. package/dist/events/index.d.ts +8 -2
  62. package/dist/events/index.d.ts.map +1 -1
  63. package/dist/events/{index.mjs → index.js} +21 -5
  64. package/dist/events/index.js.map +1 -0
  65. package/dist/index.d.ts +12 -9
  66. package/dist/index.js +36 -0
  67. package/dist/{plaintext.mjs → plaintext.js} +4 -5
  68. package/dist/plaintext.js.map +1 -0
  69. package/dist/{plugin.mjs → plugin.js} +6 -7
  70. package/dist/plugin.js.map +1 -0
  71. package/dist/plugins/postcss/{mergeMediaQueries.mjs → mergeMediaQueries.js} +2 -3
  72. package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -0
  73. package/dist/plugins/postcss/{pruneVars.mjs → pruneVars.js} +2 -2
  74. package/dist/plugins/postcss/pruneVars.js.map +1 -0
  75. package/dist/plugins/postcss/{quoteFontFamilies.mjs → quoteFontFamilies.js} +2 -2
  76. package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -0
  77. package/dist/plugins/postcss/{removeDeclarations.mjs → removeDeclarations.js} +2 -2
  78. package/dist/plugins/postcss/removeDeclarations.js.map +1 -0
  79. package/dist/plugins/postcss/{resolveMaizzleImports.mjs → resolveMaizzleImports.js} +2 -3
  80. package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -0
  81. package/dist/plugins/postcss/{resolveProps.mjs → resolveProps.js} +2 -2
  82. package/dist/plugins/postcss/resolveProps.js.map +1 -0
  83. package/dist/plugins/postcss/{tailwindCleanup.mjs → tailwindCleanup.js} +2 -2
  84. package/dist/plugins/postcss/tailwindCleanup.js.map +1 -0
  85. package/dist/{prepare.mjs → prepare.js} +5 -6
  86. package/dist/prepare.js.map +1 -0
  87. package/dist/render/active.d.ts +8 -0
  88. package/dist/render/active.d.ts.map +1 -0
  89. package/dist/render/active.js +12 -0
  90. package/dist/render/active.js.map +1 -0
  91. package/dist/render/createRenderer.d.ts.map +1 -1
  92. package/dist/render/{createRenderer.mjs → createRenderer.js} +24 -19
  93. package/dist/render/createRenderer.js.map +1 -0
  94. package/dist/render/index.d.ts.map +1 -1
  95. package/dist/render/{index.mjs → index.js} +18 -11
  96. package/dist/render/index.js.map +1 -0
  97. package/dist/render/{injectFonts.mjs → injectFonts.js} +3 -4
  98. package/dist/render/injectFonts.js.map +1 -0
  99. package/dist/render/plugins/{codeBlockExtract.mjs → codeBlockExtract.js} +2 -2
  100. package/dist/render/plugins/codeBlockExtract.js.map +1 -0
  101. package/dist/render/plugins/{markdownExtract.mjs → markdownExtract.js} +2 -3
  102. package/dist/render/plugins/markdownExtract.js.map +1 -0
  103. package/dist/render/plugins/{rawExtract.mjs → rawExtract.js} +2 -2
  104. package/dist/render/plugins/rawExtract.js.map +1 -0
  105. package/dist/render/plugins/{rowSourceLocation.mjs → rowSourceLocation.js} +2 -2
  106. package/dist/render/plugins/rowSourceLocation.js.map +1 -0
  107. package/dist/serve.d.ts +2 -0
  108. package/dist/serve.d.ts.map +1 -1
  109. package/dist/{serve.mjs → serve.js} +20 -15
  110. package/dist/serve.js.map +1 -0
  111. package/dist/server/{compatibility.mjs → compatibility.js} +5 -6
  112. package/dist/server/compatibility.js.map +1 -0
  113. package/dist/server/{email.mjs → email.js} +2 -3
  114. package/dist/server/email.js.map +1 -0
  115. package/dist/server/{linter.mjs → linter.js} +3 -4
  116. package/dist/server/linter.js.map +1 -0
  117. package/dist/server/{sfc-utils.mjs → sfc-utils.js} +2 -3
  118. package/dist/server/sfc-utils.js.map +1 -0
  119. package/dist/server/ui/App.vue +18 -0
  120. package/dist/server/ui/components/ui/command/Command.vue +4 -1
  121. package/dist/tests/render/_helpers.d.ts +6 -0
  122. package/dist/tests/render/_helpers.d.ts.map +1 -0
  123. package/dist/tests/render/_helpers.js +16 -0
  124. package/dist/tests/render/_helpers.js.map +1 -0
  125. package/dist/transformers/{addAttributes.mjs → addAttributes.js} +6 -7
  126. package/dist/transformers/addAttributes.js.map +1 -0
  127. package/dist/transformers/attributeToStyle.d.ts +27 -14
  128. package/dist/transformers/attributeToStyle.d.ts.map +1 -1
  129. package/dist/transformers/attributeToStyle.js +94 -0
  130. package/dist/transformers/attributeToStyle.js.map +1 -0
  131. package/dist/transformers/base.d.ts +66 -3
  132. package/dist/transformers/base.d.ts.map +1 -1
  133. package/dist/transformers/{base.mjs → base.js} +56 -30
  134. package/dist/transformers/base.js.map +1 -0
  135. package/dist/transformers/{columnWidth.mjs → columnWidth.js} +4 -5
  136. package/dist/transformers/columnWidth.js.map +1 -0
  137. package/dist/transformers/entities.d.ts +31 -2
  138. package/dist/transformers/entities.d.ts.map +1 -1
  139. package/dist/transformers/entities.js +73 -0
  140. package/dist/transformers/entities.js.map +1 -0
  141. package/dist/transformers/filters/{defaults.mjs → defaults.js} +2 -2
  142. package/dist/transformers/filters/defaults.js.map +1 -0
  143. package/dist/transformers/filters/index.d.ts +31 -10
  144. package/dist/transformers/filters/index.d.ts.map +1 -1
  145. package/dist/transformers/filters/index.js +89 -0
  146. package/dist/transformers/filters/index.js.map +1 -0
  147. package/dist/transformers/format.d.ts +14 -7
  148. package/dist/transformers/format.d.ts.map +1 -1
  149. package/dist/transformers/format.js +30 -0
  150. package/dist/transformers/format.js.map +1 -0
  151. package/dist/transformers/index.js +133 -0
  152. package/dist/transformers/index.js.map +1 -0
  153. package/dist/transformers/inlineCss.d.ts +84 -0
  154. package/dist/transformers/inlineCss.d.ts.map +1 -0
  155. package/dist/transformers/{inlineCSS.mjs → inlineCss.js} +28 -18
  156. package/dist/transformers/inlineCss.js.map +1 -0
  157. package/dist/transformers/inlineLink.d.ts +26 -5
  158. package/dist/transformers/inlineLink.d.ts.map +1 -1
  159. package/dist/transformers/{inlineLink.mjs → inlineLink.js} +34 -10
  160. package/dist/transformers/inlineLink.js.map +1 -0
  161. package/dist/transformers/minify.d.ts +13 -9
  162. package/dist/transformers/minify.d.ts.map +1 -1
  163. package/dist/transformers/minify.js +25 -0
  164. package/dist/transformers/minify.js.map +1 -0
  165. package/dist/transformers/msoPlaceholders.d.ts +28 -0
  166. package/dist/transformers/msoPlaceholders.d.ts.map +1 -0
  167. package/dist/transformers/msoPlaceholders.js +88 -0
  168. package/dist/transformers/msoPlaceholders.js.map +1 -0
  169. package/dist/transformers/purgeCss.d.ts +43 -0
  170. package/dist/transformers/purgeCss.d.ts.map +1 -0
  171. package/dist/transformers/{purgeCSS.mjs → purgeCss.js} +36 -29
  172. package/dist/transformers/purgeCss.js.map +1 -0
  173. package/dist/transformers/removeAttributes.d.ts +43 -20
  174. package/dist/transformers/removeAttributes.d.ts.map +1 -1
  175. package/dist/transformers/removeAttributes.js +70 -0
  176. package/dist/transformers/removeAttributes.js.map +1 -0
  177. package/dist/transformers/{replaceStrings.mjs → replaceStrings.js} +2 -2
  178. package/dist/transformers/replaceStrings.js.map +1 -0
  179. package/dist/transformers/{safeClassNames.mjs → safeClassNames.js} +4 -5
  180. package/dist/transformers/safeClassNames.js.map +1 -0
  181. package/dist/transformers/shorthandCss.d.ts +47 -0
  182. package/dist/transformers/shorthandCss.d.ts.map +1 -0
  183. package/dist/transformers/shorthandCss.js +61 -0
  184. package/dist/transformers/shorthandCss.js.map +1 -0
  185. package/dist/transformers/sixHex.d.ts +16 -7
  186. package/dist/transformers/sixHex.d.ts.map +1 -1
  187. package/dist/transformers/sixHex.js +42 -0
  188. package/dist/transformers/sixHex.js.map +1 -0
  189. package/dist/transformers/{tailwindComponent.mjs → tailwindComponent.js} +5 -6
  190. package/dist/transformers/tailwindComponent.js.map +1 -0
  191. package/dist/transformers/{tailwindcss.mjs → tailwindcss.js} +6 -7
  192. package/dist/transformers/tailwindcss.js.map +1 -0
  193. package/dist/transformers/urlQuery.d.ts +26 -14
  194. package/dist/transformers/urlQuery.d.ts.map +1 -1
  195. package/dist/transformers/urlQuery.js +77 -0
  196. package/dist/transformers/urlQuery.js.map +1 -0
  197. package/dist/types/config.d.ts +108 -15
  198. package/dist/types/config.d.ts.map +1 -1
  199. package/dist/types/config.js +1 -0
  200. package/dist/types/index.d.ts +2 -2
  201. package/dist/types/index.js +1 -0
  202. package/dist/utils/ast/index.js +4 -0
  203. package/dist/utils/ast/{parser.mjs → parser.js} +2 -3
  204. package/dist/utils/ast/parser.js.map +1 -0
  205. package/dist/utils/ast/{serializer.mjs → serializer.js} +3 -4
  206. package/dist/utils/ast/serializer.js.map +1 -0
  207. package/dist/utils/ast/{walker.mjs → walker.js} +2 -2
  208. package/dist/utils/ast/walker.js.map +1 -0
  209. package/dist/utils/{compileTailwindCss.mjs → compileTailwindCss.js} +8 -9
  210. package/dist/utils/compileTailwindCss.js.map +1 -0
  211. package/dist/utils/{decodeStyleEntities.mjs → decodeStyleEntities.js} +2 -2
  212. package/dist/utils/decodeStyleEntities.js.map +1 -0
  213. package/dist/utils/{detect.mjs → detect.js} +2 -3
  214. package/dist/utils/detect.js.map +1 -0
  215. package/dist/utils/output-markers.d.ts +29 -0
  216. package/dist/utils/output-markers.d.ts.map +1 -0
  217. package/dist/utils/output-markers.js +68 -0
  218. package/dist/utils/output-markers.js.map +1 -0
  219. package/dist/utils/{url.mjs → url.js} +2 -3
  220. package/dist/utils/url.js.map +1 -0
  221. package/node_modules/@clack/core/CHANGELOG.md +8 -0
  222. package/node_modules/@clack/core/dist/index.d.mts +18 -4
  223. package/node_modules/@clack/core/dist/index.mjs +16 -10
  224. package/node_modules/@clack/core/dist/index.mjs.map +1 -1
  225. package/node_modules/@clack/core/package.json +5 -2
  226. package/node_modules/@clack/prompts/CHANGELOG.md +15 -0
  227. package/node_modules/@clack/prompts/README.md +107 -2
  228. package/node_modules/@clack/prompts/dist/index.d.mts +16 -11
  229. package/node_modules/@clack/prompts/dist/index.mjs +114 -107
  230. package/node_modules/@clack/prompts/dist/index.mjs.map +1 -1
  231. package/node_modules/@clack/prompts/package.json +7 -4
  232. package/node_modules/fast-string-truncated-width/dist/index.js +36 -96
  233. package/node_modules/fast-string-truncated-width/dist/types.d.ts +0 -3
  234. package/node_modules/fast-string-truncated-width/dist/utils.d.ts +3 -3
  235. package/node_modules/fast-string-truncated-width/dist/utils.js +14 -9
  236. package/node_modules/fast-string-truncated-width/package.json +1 -1
  237. package/node_modules/fast-string-truncated-width/readme.md +2 -3
  238. package/node_modules/fast-string-width/package.json +2 -2
  239. package/node_modules/fast-string-width/readme.md +0 -3
  240. package/node_modules/fast-wrap-ansi/lib/main.js +4 -1
  241. package/node_modules/fast-wrap-ansi/lib/main.js.map +1 -1
  242. package/node_modules/fast-wrap-ansi/package.json +2 -2
  243. package/node_modules/maizzle/README.md +24 -0
  244. package/node_modules/maizzle/dist/commands/make/component.mjs +1 -1
  245. package/node_modules/maizzle/dist/commands/make/config.mjs +1 -1
  246. package/node_modules/maizzle/dist/commands/make/layout.mjs +3 -3
  247. package/node_modules/maizzle/dist/commands/make/scaffold.mjs +1 -1
  248. package/node_modules/maizzle/dist/commands/make/stubs/Layout.vue +146 -0
  249. package/node_modules/maizzle/dist/commands/make/stubs/component.vue +2 -4
  250. package/node_modules/maizzle/dist/commands/make/stubs/config.ts +1 -5
  251. package/node_modules/maizzle/dist/commands/make/template.mjs +1 -1
  252. package/node_modules/maizzle/dist/commands/new.mjs +29 -24
  253. package/node_modules/maizzle/dist/index.mjs +28 -8
  254. package/node_modules/maizzle/package.json +1 -1
  255. package/node_modules/tinyexec/README.md +1 -1
  256. package/node_modules/tinyexec/dist/main.d.mts +6 -6
  257. package/node_modules/tinyexec/dist/main.mjs +126 -134
  258. package/node_modules/tinyexec/package.json +9 -9
  259. package/package.json +4 -4
  260. package/dist/build.mjs.map +0 -1
  261. package/dist/components/Divider.vue +0 -133
  262. package/dist/components/utils.mjs.map +0 -1
  263. package/dist/composables/defineConfig.mjs.map +0 -1
  264. package/dist/composables/renderContext.mjs.map +0 -1
  265. package/dist/composables/useConfig.mjs.map +0 -1
  266. package/dist/composables/useDoctype.mjs.map +0 -1
  267. package/dist/composables/useEvent.mjs.map +0 -1
  268. package/dist/composables/useFont.mjs.map +0 -1
  269. package/dist/composables/useOutlookFallback.mjs.map +0 -1
  270. package/dist/composables/usePlaintext.mjs.map +0 -1
  271. package/dist/composables/usePreheader.mjs.map +0 -1
  272. package/dist/config/defaults.mjs.map +0 -1
  273. package/dist/config/index.mjs.map +0 -1
  274. package/dist/events/index.mjs.map +0 -1
  275. package/dist/index.mjs +0 -34
  276. package/dist/plaintext.mjs.map +0 -1
  277. package/dist/plugin.mjs.map +0 -1
  278. package/dist/plugins/postcss/mergeMediaQueries.mjs.map +0 -1
  279. package/dist/plugins/postcss/pruneVars.mjs.map +0 -1
  280. package/dist/plugins/postcss/quoteFontFamilies.mjs.map +0 -1
  281. package/dist/plugins/postcss/removeDeclarations.mjs.map +0 -1
  282. package/dist/plugins/postcss/resolveMaizzleImports.mjs.map +0 -1
  283. package/dist/plugins/postcss/resolveProps.mjs.map +0 -1
  284. package/dist/plugins/postcss/tailwindCleanup.mjs.map +0 -1
  285. package/dist/prepare.mjs.map +0 -1
  286. package/dist/render/createRenderer.mjs.map +0 -1
  287. package/dist/render/index.mjs.map +0 -1
  288. package/dist/render/injectFonts.mjs.map +0 -1
  289. package/dist/render/plugins/codeBlockExtract.mjs.map +0 -1
  290. package/dist/render/plugins/markdownExtract.mjs.map +0 -1
  291. package/dist/render/plugins/rawExtract.mjs.map +0 -1
  292. package/dist/render/plugins/rowSourceLocation.mjs.map +0 -1
  293. package/dist/serve.mjs.map +0 -1
  294. package/dist/server/compatibility.mjs.map +0 -1
  295. package/dist/server/email.mjs.map +0 -1
  296. package/dist/server/linter.mjs.map +0 -1
  297. package/dist/server/sfc-utils.mjs.map +0 -1
  298. package/dist/transformers/addAttributes.mjs.map +0 -1
  299. package/dist/transformers/attributeToStyle.mjs +0 -80
  300. package/dist/transformers/attributeToStyle.mjs.map +0 -1
  301. package/dist/transformers/base.mjs.map +0 -1
  302. package/dist/transformers/columnWidth.mjs.map +0 -1
  303. package/dist/transformers/entities.mjs +0 -41
  304. package/dist/transformers/entities.mjs.map +0 -1
  305. package/dist/transformers/filters/defaults.mjs.map +0 -1
  306. package/dist/transformers/filters/index.mjs +0 -67
  307. package/dist/transformers/filters/index.mjs.map +0 -1
  308. package/dist/transformers/format.mjs +0 -26
  309. package/dist/transformers/format.mjs.map +0 -1
  310. package/dist/transformers/index.mjs +0 -87
  311. package/dist/transformers/index.mjs.map +0 -1
  312. package/dist/transformers/inlineCSS.d.ts +0 -17
  313. package/dist/transformers/inlineCSS.d.ts.map +0 -1
  314. package/dist/transformers/inlineCSS.mjs.map +0 -1
  315. package/dist/transformers/inlineLink.mjs.map +0 -1
  316. package/dist/transformers/minify.mjs +0 -24
  317. package/dist/transformers/minify.mjs.map +0 -1
  318. package/dist/transformers/msoWidthFromClass.d.ts +0 -19
  319. package/dist/transformers/msoWidthFromClass.d.ts.map +0 -1
  320. package/dist/transformers/msoWidthFromClass.mjs +0 -61
  321. package/dist/transformers/msoWidthFromClass.mjs.map +0 -1
  322. package/dist/transformers/purgeCSS.d.ts +0 -23
  323. package/dist/transformers/purgeCSS.d.ts.map +0 -1
  324. package/dist/transformers/purgeCSS.mjs.map +0 -1
  325. package/dist/transformers/removeAttributes.mjs +0 -63
  326. package/dist/transformers/removeAttributes.mjs.map +0 -1
  327. package/dist/transformers/replaceStrings.mjs.map +0 -1
  328. package/dist/transformers/safeClassNames.mjs.map +0 -1
  329. package/dist/transformers/shorthandCSS.d.ts +0 -24
  330. package/dist/transformers/shorthandCSS.d.ts.map +0 -1
  331. package/dist/transformers/shorthandCSS.mjs +0 -48
  332. package/dist/transformers/shorthandCSS.mjs.map +0 -1
  333. package/dist/transformers/sixHex.mjs +0 -30
  334. package/dist/transformers/sixHex.mjs.map +0 -1
  335. package/dist/transformers/tailwindComponent.mjs.map +0 -1
  336. package/dist/transformers/tailwindcss.mjs.map +0 -1
  337. package/dist/transformers/urlQuery.mjs +0 -65
  338. package/dist/transformers/urlQuery.mjs.map +0 -1
  339. package/dist/types/config.mjs +0 -1
  340. package/dist/types/index.mjs +0 -1
  341. package/dist/utils/ast/index.mjs +0 -5
  342. package/dist/utils/ast/parser.mjs.map +0 -1
  343. package/dist/utils/ast/serializer.mjs.map +0 -1
  344. package/dist/utils/ast/walker.mjs.map +0 -1
  345. package/dist/utils/compileTailwindCss.mjs.map +0 -1
  346. package/dist/utils/decodeStyleEntities.mjs.map +0 -1
  347. package/dist/utils/detect.mjs.map +0 -1
  348. package/dist/utils/url.mjs.map +0 -1
  349. package/node_modules/maizzle/dist/commands/make/stubs/layout.vue +0 -39
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","names":["merge"],"sources":["../../src/transformers/entities.ts"],"sourcesContent":["import { defu as merge } from 'defu'\nimport type { ChildNode } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\nimport type { EntitiesConfig } from '../types/index.ts'\n\nconst DEFAULT_ENTITIES: Record<string, string> = {\n '\\u200D': '&zwj;',\n '\\u200C': '&zwnj;',\n '\\u00A0': '&nbsp;',\n '\\u00AD': '&shy;',\n '\\u200B': '&#8203;',\n '\\u2007': '&#8199;',\n '\\u034F': '&#847;',\n '\\u2003': '&emsp;',\n '\\u2028': '&LineSeparator;',\n '\\u2029': '&ParagraphSeparator;',\n '\\u00B7': '&middot;',\n '\\u2013': '&ndash;',\n '\\u2014': '&mdash;',\n '\\u2018': '&lsquo;',\n '\\u2019': '&rsquo;',\n '\\u201C': '&ldquo;',\n '\\u201D': '&rdquo;',\n '\\u00AB': '&laquo;',\n '\\u00BB': '&raquo;',\n '\\u2022': '&bull;',\n '\\u2039': '&lsaquo;',\n '\\u203A': '&rsaquo;'\n}\n\n/**\n * Replace literal Unicode characters in text nodes with their HTML entity\n * equivalents (zero-width joiners, non-breaking spaces, smart quotes,\n * dashes, etc.) for better email-client rendering.\n *\n * @param html HTML string to transform.\n * @param custom Extra entries merged on top of the built-in entity map, or\n * `false` to disable the transform. Defaults to `true`\n * (built-ins only).\n * @returns The transformed HTML string.\n *\n * @example\n * import { entities } from '@maizzle/framework'\n *\n * // Defaults only\n * entities('hello world') // → 'hello&nbsp;world'\n *\n * // Add a custom mapping\n * entities('© Maizzle', { '©': '&copy;' })\n *\n * // Disable the transform\n * entities('hello world', false)\n */\nexport function entities(html: string, custom: EntitiesConfig = true): string {\n return serialize(entitiesDom(parse(html), custom))\n}\n\n/**\n * DOM-form of {@link entities} used by the internal transformer pipeline.\n * Takes a parsed DOM, returns a parsed DOM — avoids redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport function entitiesDom(dom: ChildNode[], custom: EntitiesConfig = true): ChildNode[] {\n if (!custom) return dom\n\n const map = typeof custom === 'object'\n ? merge(custom as Record<string, string>, DEFAULT_ENTITIES)\n : DEFAULT_ENTITIES\n\n walk(dom, (node) => {\n if (node.type === 'text') {\n for (const [char, entity] of Object.entries(map)) {\n node.data = node.data.split(char).join(entity)\n }\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;AAKA,MAAM,mBAA2C;CAC/C,KAAU;CACV,KAAU;CACV,QAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,UAAU;CACV,UAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACX;;;;;;;;;;;;;;;;;;;;;;;;AAyBD,SAAgB,SAAS,MAAc,SAAyB,MAAc;CAC5E,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,OAAO,CAAC;;;;;;;AAQpD,SAAgB,YAAY,KAAkB,SAAyB,MAAmB;CACxF,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,MAAM,OAAO,WAAW,WAC1BA,OAAM,QAAkC,iBAAiB,GACzD;CAEJ,KAAK,MAAM,SAAS;EAClB,IAAI,KAAK,SAAS,QAChB,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,IAAI,EAC9C,KAAK,OAAO,KAAK,KAAK,MAAM,KAAK,CAAC,KAAK,OAAO;GAGlD;CAEF,OAAO"}
@@ -72,7 +72,7 @@ const defaults = {
72
72
  "url-decode": (str) => decodeURIComponent(str.replace(/\+/g, " ")),
73
73
  "url-encode": (str) => encodeURIComponent(str)
74
74
  };
75
-
76
75
  //#endregion
77
76
  export { defaults };
78
- //# sourceMappingURL=defaults.mjs.map
77
+
78
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":[],"sources":["../../../src/transformers/filters/defaults.ts"],"sourcesContent":["export type FilterFunction = (str: string, value: string) => string\n\nconst escapeMap: Record<string, string> = {\n '\"': '&#34;',\n '&': '&amp;',\n \"'\": '&#39;',\n '<': '&lt;',\n '>': '&gt;',\n}\n\nconst escapeRegex = /[\"&'<>]/g\n\nfunction escapeHtml(str: string): string {\n return str.replace(escapeRegex, ch => escapeMap[ch])\n}\n\nexport const defaults: Record<string, FilterFunction> = {\n append: (str, value) => str + value,\n prepend: (str, value) => value + str,\n uppercase: str => str.toUpperCase(),\n lowercase: str => str.toLowerCase(),\n capitalize: str => str.charAt(0).toUpperCase() + str.slice(1),\n ceil: str => String(Math.ceil(Number.parseFloat(str))),\n floor: str => String(Math.floor(Number.parseFloat(str))),\n round: str => String(Math.round(Number.parseFloat(str))),\n escape: str => escapeHtml(str),\n 'escape-once': str => {\n const decoded = str\n .replace(/&amp;/g, '&')\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&#34;/g, '\"')\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&apos;/g, \"'\")\n\n return escapeHtml(decoded)\n },\n lstrip: str => str.trimStart(),\n rstrip: str => str.trimEnd(),\n trim: str => str.trim(),\n minus: (str, value) => String(Number.parseFloat(str) - Number.parseFloat(value)),\n plus: (str, value) => String(Number.parseFloat(str) + Number.parseFloat(value)),\n multiply: (str, value) => String(Number.parseFloat(str) * Number.parseFloat(value)),\n times: (str, value) => String(Number.parseFloat(str) * Number.parseFloat(value)),\n 'divide-by': (str, value) => String(Number.parseFloat(str) / Number.parseFloat(value)),\n divide: (str, value) => String(Number.parseFloat(str) / Number.parseFloat(value)),\n modulo: (str, value) => String(Number.parseFloat(str) % Number.parseFloat(value)),\n 'newline-to-br': str => str.replace(/\\n/g, '<br>'),\n 'strip-newlines': str => str.replace(/\\n/g, ''),\n remove: (str, value) => str.split(value).join(''),\n 'remove-first': (str, value) => {\n const i = str.indexOf(value)\n return i === -1 ? str : str.slice(0, i) + str.slice(i + value.length)\n },\n replace: (str, value) => {\n const [search = '', replacement = ''] = value.split('|')\n return str.split(search).join(replacement)\n },\n 'replace-first': (str, value) => {\n const [search = '', replacement = ''] = value.split('|')\n const i = str.indexOf(search)\n return i === -1 ? str : str.slice(0, i) + replacement + str.slice(i + search.length)\n },\n size: str => String(str.length),\n slice: (str, value) => {\n const args = value.split(',').map(s => Number.parseInt(s.trim(), 10))\n return str.slice(args[0], args[1])\n },\n truncate: (str, value) => {\n const commaIndex = value.indexOf(',')\n const length = Number.parseInt(commaIndex === -1 ? value : value.slice(0, commaIndex), 10)\n const ellipsis = commaIndex === -1 ? '...' : value.slice(commaIndex + 1)\n\n if (str.length <= length) return str\n\n return str.slice(0, length) + ellipsis\n },\n 'truncate-words': (str, value) => {\n const commaIndex = value.indexOf(',')\n const count = Number.parseInt(commaIndex === -1 ? value : value.slice(0, commaIndex), 10)\n const ellipsis = commaIndex === -1 ? '...' : value.slice(commaIndex + 1)\n const words = str.split(/\\s+/).filter(Boolean)\n\n if (words.length <= count) return str\n\n return words.slice(0, count).join(' ') + ellipsis\n },\n 'url-decode': str => decodeURIComponent(str.replace(/\\+/g, ' ')),\n 'url-encode': str => encodeURIComponent(str),\n}\n"],"mappings":";AAEA,MAAM,YAAoC;CACxC,MAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN;AAED,MAAM,cAAc;AAEpB,SAAS,WAAW,KAAqB;CACvC,OAAO,IAAI,QAAQ,cAAa,OAAM,UAAU,IAAI;;AAGtD,MAAa,WAA2C;CACtD,SAAS,KAAK,UAAU,MAAM;CAC9B,UAAU,KAAK,UAAU,QAAQ;CACjC,YAAW,QAAO,IAAI,aAAa;CACnC,YAAW,QAAO,IAAI,aAAa;CACnC,aAAY,QAAO,IAAI,OAAO,EAAE,CAAC,aAAa,GAAG,IAAI,MAAM,EAAE;CAC7D,OAAM,QAAO,OAAO,KAAK,KAAK,OAAO,WAAW,IAAI,CAAC,CAAC;CACtD,QAAO,QAAO,OAAO,KAAK,MAAM,OAAO,WAAW,IAAI,CAAC,CAAC;CACxD,QAAO,QAAO,OAAO,KAAK,MAAM,OAAO,WAAW,IAAI,CAAC,CAAC;CACxD,SAAQ,QAAO,WAAW,IAAI;CAC9B,gBAAe,QAA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AO,mBAAmB,IAAI;CAC7C"}
@@ -4,19 +4,40 @@ import { ChildNode } from "domhandler";
4
4
  //#region src/transformers/filters/index.d.ts
5
5
  type FiltersConfig = false | Record<string, (str: string, value: string) => string>;
6
6
  /**
7
- * Filters transformer.
7
+ * Apply transformation functions to the content of elements that have
8
+ * matching filter attributes. Multiple filters on the same element are
9
+ * executed in the order the attributes are defined.
8
10
  *
9
- * Applies transformation functions to the content of elements that
10
- * have matching filter attributes. Multiple filters on the same element
11
- * are executed in the order the attributes are defined.
11
+ * Default filters include string manipulation (`uppercase`, `lowercase`,
12
+ * `trim`, etc.), math operations (`plus`, `minus`, `multiply`, etc.),
13
+ * and more.
12
14
  *
13
- * Default filters include string manipulation (uppercase, lowercase, trim, etc.),
14
- * math operations (plus, minus, multiply, etc.), and more.
15
+ * @param html HTML string to transform.
16
+ * @param custom Custom filters to merge with the defaults. Pass `false`
17
+ * to disable all filters (including the defaults).
18
+ * @returns The transformed HTML string.
15
19
  *
16
- * Custom filters can be added via config, and will be merged with defaults.
17
- * Set config to `false` to disable all filters.
20
+ * @example
21
+ * import { filters } from '@maizzle/framework'
22
+ *
23
+ * // Defaults only
24
+ * const out = filters('<p uppercase>foo</p>') // → '<p>FOO</p>'
25
+ *
26
+ * // Add a custom filter
27
+ * filters('<p suffix=" world">hello</p>', {
28
+ * suffix: (s, v) => s + v,
29
+ * })
30
+ *
31
+ * // Disable all filters
32
+ * filters('<p uppercase>foo</p>', false)
33
+ */
34
+ declare function filters(html: string, custom?: FiltersConfig): string;
35
+ /**
36
+ * DOM-form of {@link filters} used by the internal transformer pipeline.
37
+ * Takes a parsed DOM, returns a parsed DOM — avoids redundant
38
+ * serialize/parse round-trips when chained with other transformers.
18
39
  */
19
- declare function filters(dom: ChildNode[], config?: FiltersConfig): ChildNode[];
40
+ declare function filtersDom(dom: ChildNode[], custom?: FiltersConfig): ChildNode[];
20
41
  //#endregion
21
- export { type FilterFunction, FiltersConfig, filters };
42
+ export { type FilterFunction, FiltersConfig, filters, filtersDom };
22
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/transformers/filters/index.ts"],"mappings":";;;;KAMY,aAAA,WAAwB,MAAA,UAAgB,GAAA,UAAa,KAAA;;AAAjE;;;;;;;;;AA4BA;;;iBAAgB,OAAA,CAAQ,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,aAAA,GAAqB,SAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/transformers/filters/index.ts"],"mappings":";;;;KAMY,aAAA,WAAwB,MAAA,UAAgB,GAAA,UAAa,KAAA;;AAAjE;;;;;;;;;AA2CA;;;;;;;;;AASA;;;;;;;;;iBATgB,OAAA,CAAQ,IAAA,UAAc,MAAA,GAAQ,aAAA;;;;;;iBAS9B,UAAA,CAAW,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,aAAA,GAAqB,SAAA"}
@@ -0,0 +1,89 @@
1
+ import { parse } from "../../utils/ast/parser.js";
2
+ import { serialize } from "../../utils/ast/serializer.js";
3
+ import "../../utils/ast/index.js";
4
+ import { defaults } from "./defaults.js";
5
+ import { Text } from "domhandler";
6
+ //#region src/transformers/filters/index.ts
7
+ /**
8
+ * Process children before parents so nested filter elements work correctly.
9
+ */
10
+ function walkBottomUp(nodes, callback) {
11
+ for (const node of nodes.slice()) {
12
+ if ("children" in node && node.children?.length) walkBottomUp(node.children, callback);
13
+ callback(node);
14
+ }
15
+ }
16
+ /**
17
+ * Apply transformation functions to the content of elements that have
18
+ * matching filter attributes. Multiple filters on the same element are
19
+ * executed in the order the attributes are defined.
20
+ *
21
+ * Default filters include string manipulation (`uppercase`, `lowercase`,
22
+ * `trim`, etc.), math operations (`plus`, `minus`, `multiply`, etc.),
23
+ * and more.
24
+ *
25
+ * @param html HTML string to transform.
26
+ * @param custom Custom filters to merge with the defaults. Pass `false`
27
+ * to disable all filters (including the defaults).
28
+ * @returns The transformed HTML string.
29
+ *
30
+ * @example
31
+ * import { filters } from '@maizzle/framework'
32
+ *
33
+ * // Defaults only
34
+ * const out = filters('<p uppercase>foo</p>') // → '<p>FOO</p>'
35
+ *
36
+ * // Add a custom filter
37
+ * filters('<p suffix=" world">hello</p>', {
38
+ * suffix: (s, v) => s + v,
39
+ * })
40
+ *
41
+ * // Disable all filters
42
+ * filters('<p uppercase>foo</p>', false)
43
+ */
44
+ function filters(html, custom = {}) {
45
+ return serialize(filtersDom(parse(html), custom));
46
+ }
47
+ /**
48
+ * DOM-form of {@link filters} used by the internal transformer pipeline.
49
+ * Takes a parsed DOM, returns a parsed DOM — avoids redundant
50
+ * serialize/parse round-trips when chained with other transformers.
51
+ */
52
+ function filtersDom(dom, custom = {}) {
53
+ if (custom === false) return dom;
54
+ const allFilters = {
55
+ ...defaults,
56
+ ...custom
57
+ };
58
+ const filterNames = new Set(Object.keys(allFilters));
59
+ walkBottomUp(dom, (node) => {
60
+ const el = node;
61
+ if (!el.attribs) return;
62
+ const matched = [];
63
+ for (const attr of Object.keys(el.attribs)) if (filterNames.has(attr)) matched.push({
64
+ name: attr,
65
+ value: el.attribs[attr]
66
+ });
67
+ if (matched.length === 0) return;
68
+ let content = serialize(el.children);
69
+ for (const { name, value } of matched) {
70
+ content = allFilters[name](content, value);
71
+ delete el.attribs[name];
72
+ }
73
+ if (content === "") el.children = [];
74
+ else if (/<[a-z/!]/i.test(content)) {
75
+ const newChildren = parse(content);
76
+ for (const child of newChildren) child.parent = el;
77
+ el.children = newChildren;
78
+ } else {
79
+ const textNode = new Text(content);
80
+ textNode.parent = el;
81
+ el.children = [textNode];
82
+ }
83
+ });
84
+ return dom;
85
+ }
86
+ //#endregion
87
+ export { filters, filtersDom };
88
+
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/transformers/filters/index.ts"],"sourcesContent":["import { Text } from 'domhandler'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize } from '../../utils/ast/index.ts'\nimport { defaults } from './defaults.ts'\n\nexport type { FilterFunction } from './defaults.ts'\nexport type FiltersConfig = false | Record<string, (str: string, value: string) => string>\n\n/**\n * Process children before parents so nested filter elements work correctly.\n */\nfunction walkBottomUp(nodes: ChildNode[], callback: (node: ChildNode) => void): void {\n for (const node of nodes.slice()) {\n if ('children' in node && node.children?.length) {\n walkBottomUp(node.children as ChildNode[], callback)\n }\n\n callback(node)\n }\n}\n\n/**\n * Apply transformation functions to the content of elements that have\n * matching filter attributes. Multiple filters on the same element are\n * executed in the order the attributes are defined.\n *\n * Default filters include string manipulation (`uppercase`, `lowercase`,\n * `trim`, etc.), math operations (`plus`, `minus`, `multiply`, etc.),\n * and more.\n *\n * @param html HTML string to transform.\n * @param custom Custom filters to merge with the defaults. Pass `false`\n * to disable all filters (including the defaults).\n * @returns The transformed HTML string.\n *\n * @example\n * import { filters } from '@maizzle/framework'\n *\n * // Defaults only\n * const out = filters('<p uppercase>foo</p>') // → '<p>FOO</p>'\n *\n * // Add a custom filter\n * filters('<p suffix=\" world\">hello</p>', {\n * suffix: (s, v) => s + v,\n * })\n *\n * // Disable all filters\n * filters('<p uppercase>foo</p>', false)\n */\nexport function filters(html: string, custom: FiltersConfig = {}): string {\n return serialize(filtersDom(parse(html), custom))\n}\n\n/**\n * DOM-form of {@link filters} used by the internal transformer pipeline.\n * Takes a parsed DOM, returns a parsed DOM — avoids redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport function filtersDom(dom: ChildNode[], custom: FiltersConfig = {}): ChildNode[] {\n if (custom === false) return dom\n\n const allFilters = { ...defaults, ...custom }\n const filterNames = new Set(Object.keys(allFilters))\n\n walkBottomUp(dom, (node) => {\n const el = node as Element\n\n if (!el.attribs) return\n\n // Collect matching filter attributes in source order\n const matched: Array<{ name: string; value: string }> = []\n\n for (const attr of Object.keys(el.attribs)) {\n if (filterNames.has(attr)) {\n matched.push({ name: attr, value: el.attribs[attr] })\n }\n }\n\n if (matched.length === 0) return\n\n // Serialize children to get innerHTML\n let content = serialize(el.children as ChildNode[])\n\n // Apply each filter in attribute order\n for (const { name, value } of matched) {\n content = allFilters[name](content, value)\n delete el.attribs[name]\n }\n\n // Replace children with the filtered content\n if (content === '') {\n el.children = []\n } else if (/<[a-z/!]/i.test(content)) {\n // Result contains HTML elements — parse back to DOM\n const newChildren = parse(content)\n\n for (const child of newChildren) {\n child.parent = el as any\n }\n\n el.children = newChildren as ChildNode[]\n } else {\n // Text-only result — create a text node directly to preserve entity strings\n const textNode = new Text(content)\n textNode.parent = el as any\n el.children = [textNode]\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;;;;AAWA,SAAS,aAAa,OAAoB,UAA2C;CACnF,KAAK,MAAM,QAAQ,MAAM,OAAO,EAAE;EAChC,IAAI,cAAc,QAAQ,KAAK,UAAU,QACvC,aAAa,KAAK,UAAyB,SAAS;EAGtD,SAAS,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgClB,SAAgB,QAAQ,MAAc,SAAwB,EAAE,EAAU;CACxE,OAAO,UAAU,WAAW,MAAM,KAAK,EAAE,OAAO,CAAC;;;;;;;AAQnD,SAAgB,WAAW,KAAkB,SAAwB,EAAE,EAAe;CACpF,IAAI,WAAW,OAAO,OAAO;CAE7B,MAAM,aAAa;EAAE,GAAG;EAAU,GAAG;EAAQ;CAC7C,MAAM,cAAc,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC;CAEpD,aAAa,MAAM,SAAS;EAC1B,MAAM,KAAK;EAEX,IAAI,CAAC,GAAG,SAAS;EAGjB,MAAM,UAAkD,EAAE;EAE1D,KAAK,MAAM,QAAQ,OAAO,KAAK,GAAG,QAAQ,EACxC,IAAI,YAAY,IAAI,KAAK,EACvB,QAAQ,KAAK;GAAE,MAAM;GAAM,OAAO,GAAG,QAAQ;GAAO,CAAC;EAIzD,IAAI,QAAQ,WAAW,GAAG;EAG1B,IAAI,UAAU,UAAU,GAAG,SAAwB;EAGnD,KAAK,MAAM,EAAE,MAAM,WAAW,SAAS;GACrC,UAAU,WAAW,MAAM,SAAS,MAAM;GAC1C,OAAO,GAAG,QAAQ;;EAIpB,IAAI,YAAY,IACd,GAAG,WAAW,EAAE;OACX,IAAI,YAAY,KAAK,QAAQ,EAAE;GAEpC,MAAM,cAAc,MAAM,QAAQ;GAElC,KAAK,MAAM,SAAS,aAClB,MAAM,SAAS;GAGjB,GAAG,WAAW;SACT;GAEL,MAAM,WAAW,IAAI,KAAK,QAAQ;GAClC,SAAS,SAAS;GAClB,GAAG,WAAW,CAAC,SAAS;;GAE1B;CAEF,OAAO"}
@@ -1,15 +1,22 @@
1
- import { MaizzleConfig } from "../types/config.js";
1
+ import { FormatOptions, FormatOptions as FormatOptions$1 } from "oxfmt";
2
2
 
3
3
  //#region src/transformers/format.d.ts
4
4
  /**
5
- * Format transformer.
5
+ * Pretty-print an HTML string with `oxfmt`. Maizzle defaults
6
+ * (`printWidth: 320`, `htmlWhitespaceSensitivity: 'ignore'`,
7
+ * `embeddedLanguageFormatting: 'off'`) are merged underneath any options
8
+ * you pass.
6
9
  *
7
- * Formats the HTML string using `oxfmt`. Accepts all oxfmt `FormatOptions`.
10
+ * @param html HTML string to format.
11
+ * @param options [oxfmt `FormatOptions`](https://github.com/oxc-project/oxfmt).
12
+ * @returns The formatted HTML string.
8
13
  *
9
- * Enable by setting `html.format: true` (or passing options).
10
- * User options are merged on top of the defaults.
14
+ * @example
15
+ * import { format } from '@maizzle/framework'
16
+ *
17
+ * const pretty = await format(html, { useTabs: true, tabWidth: 4 })
11
18
  */
12
- declare function format(html: string, config?: MaizzleConfig): Promise<string>;
19
+ declare function format(html: string, options?: FormatOptions$1): Promise<string>;
13
20
  //#endregion
14
- export { format };
21
+ export { type FormatOptions, format };
15
22
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","names":[],"sources":["../../src/transformers/format.ts"],"mappings":";;;;;AAmBA;;;;;;iBAAsB,MAAA,CAAO,IAAA,UAAc,MAAA,GAAQ,aAAA,GAAqB,OAAA"}
1
+ {"version":3,"file":"format.d.ts","names":[],"sources":["../../src/transformers/format.ts"],"mappings":";;;;AA2BA;;;;;;;;;;;;;;iBAAsB,MAAA,CAAO,IAAA,UAAc,OAAA,GAAS,eAAA,GAAqB,OAAA"}
@@ -0,0 +1,30 @@
1
+ import { defu as defu$1 } from "defu";
2
+ import { format as format$1 } from "oxfmt";
3
+ //#region src/transformers/format.ts
4
+ const DEFAULT_OPTIONS = {
5
+ printWidth: 320,
6
+ htmlWhitespaceSensitivity: "ignore",
7
+ embeddedLanguageFormatting: "off"
8
+ };
9
+ /**
10
+ * Pretty-print an HTML string with `oxfmt`. Maizzle defaults
11
+ * (`printWidth: 320`, `htmlWhitespaceSensitivity: 'ignore'`,
12
+ * `embeddedLanguageFormatting: 'off'`) are merged underneath any options
13
+ * you pass.
14
+ *
15
+ * @param html HTML string to format.
16
+ * @param options [oxfmt `FormatOptions`](https://github.com/oxc-project/oxfmt).
17
+ * @returns The formatted HTML string.
18
+ *
19
+ * @example
20
+ * import { format } from '@maizzle/framework'
21
+ *
22
+ * const pretty = await format(html, { useTabs: true, tabWidth: 4 })
23
+ */
24
+ async function format(html, options = {}) {
25
+ return (await format$1("input.html", html, defu$1(options, DEFAULT_OPTIONS))).code;
26
+ }
27
+ //#endregion
28
+ export { format };
29
+
30
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","names":["oxfmt","merge"],"sources":["../../src/transformers/format.ts"],"sourcesContent":["import { format as oxfmt } from 'oxfmt'\nimport { defu as merge } from 'defu'\nimport type { FormatOptions } from 'oxfmt'\n\nexport type { FormatOptions } from 'oxfmt'\n\nconst DEFAULT_OPTIONS: FormatOptions = {\n printWidth: 320,\n htmlWhitespaceSensitivity: 'ignore',\n embeddedLanguageFormatting: 'off',\n}\n\n/**\n * Pretty-print an HTML string with `oxfmt`. Maizzle defaults\n * (`printWidth: 320`, `htmlWhitespaceSensitivity: 'ignore'`,\n * `embeddedLanguageFormatting: 'off'`) are merged underneath any options\n * you pass.\n *\n * @param html HTML string to format.\n * @param options [oxfmt `FormatOptions`](https://github.com/oxc-project/oxfmt).\n * @returns The formatted HTML string.\n *\n * @example\n * import { format } from '@maizzle/framework'\n *\n * const pretty = await format(html, { useTabs: true, tabWidth: 4 })\n */\nexport async function format(html: string, options: FormatOptions = {}): Promise<string> {\n const merged = merge(options, DEFAULT_OPTIONS)\n const result = await oxfmt('input.html', html, merged)\n return result.code\n}\n"],"mappings":";;;AAMA,MAAM,kBAAiC;CACrC,YAAY;CACZ,2BAA2B;CAC3B,4BAA4B;CAC7B;;;;;;;;;;;;;;;;AAiBD,eAAsB,OAAO,MAAc,UAAyB,EAAE,EAAmB;CAGvF,QAAO,MADcA,SAAM,cAAc,MAD1BC,OAAM,SAAS,gBACuB,CAAC,EACxC"}
@@ -0,0 +1,133 @@
1
+ import { parse } from "../utils/ast/parser.js";
2
+ import { serialize } from "../utils/ast/serializer.js";
3
+ import "../utils/ast/index.js";
4
+ import { inlineLinkDom } from "./inlineLink.js";
5
+ import { tailwindComponent } from "./tailwindComponent.js";
6
+ import { tailwindcss } from "./tailwindcss.js";
7
+ import { safeClassNames } from "./safeClassNames.js";
8
+ import { attributeToStyleDom } from "./attributeToStyle.js";
9
+ import { inlineCssDom } from "./inlineCss.js";
10
+ import { msoPlaceholders } from "./msoPlaceholders.js";
11
+ import { columnWidth } from "./columnWidth.js";
12
+ import { removeAttributesDom } from "./removeAttributes.js";
13
+ import { shorthandCssDom } from "./shorthandCss.js";
14
+ import { sixHexDom } from "./sixHex.js";
15
+ import { addAttributes } from "./addAttributes.js";
16
+ import { filtersDom } from "./filters/index.js";
17
+ import { baseDom } from "./base.js";
18
+ import { entitiesDom } from "./entities.js";
19
+ import { urlQueryDom } from "./urlQuery.js";
20
+ import { purgeCssDom } from "./purgeCss.js";
21
+ import { replaceStrings } from "./replaceStrings.js";
22
+ import { format } from "./format.js";
23
+ import { minify } from "./minify.js";
24
+ //#region src/transformers/index.ts
25
+ /**
26
+ * Run all Maizzle transformers on the rendered HTML.
27
+ *
28
+ * The HTML is parsed into a DOM once at the start and passed through all
29
+ * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers
30
+ * complete, the DOM is serialized back to a string exactly once.
31
+ *
32
+ * String-only transformers (those that rely on external tools that require a
33
+ * raw HTML string) then run on the serialized output.
34
+ *
35
+ * Transformers run in a specific order:
36
+ * 0. Inline link stylesheets — replace `<link rel="stylesheet">` with `<style>` tags
37
+ * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)
38
+ * 2. Safe class names
39
+ * 3. Attribute to style
40
+ * 4. CSS inliner
41
+ * 5. Remove attributes
42
+ * 6. Shorthand CSS
43
+ * 7. Six-digit HEX
44
+ * 8. Add attributes
45
+ * 9. Filters
46
+ * 10. Base URL
47
+ * 11. URL query
48
+ * 12. Purge CSS (serializes/parses internally around email-comb)
49
+ * 13. Entities
50
+ * + Vue-generated comments stripped here (on serialized string)
51
+ * 14. Replace strings
52
+ * 15. Prettify
53
+ * 16. Minify
54
+ */
55
+ async function runTransformers(html, config, filePath, doctype, tailwindBlocks) {
56
+ const toggles = typeof config.useTransformers === "object" ? config.useTransformers : null;
57
+ const enabled = (key) => toggles?.[key] !== false;
58
+ let effective = config;
59
+ if (toggles) {
60
+ const cssOver = {};
61
+ const htmlOver = {};
62
+ if (toggles.inlineCss === true) cssOver.inline = true;
63
+ if (toggles.purgeCss === true) cssOver.purge = true;
64
+ if (toggles.safeClassNames === true) cssOver.safe = true;
65
+ if (toggles.shorthandCss === true) cssOver.shorthand = true;
66
+ if (toggles.sixHex === true) cssOver.sixHex = true;
67
+ if (toggles.prettify === true) htmlOver.format = true;
68
+ if (toggles.minify === true) htmlOver.minify = true;
69
+ if (toggles.entities === true) htmlOver.decodeEntities = true;
70
+ if (Object.keys(cssOver).length || Object.keys(htmlOver).length) effective = {
71
+ ...config,
72
+ css: {
73
+ ...config.css,
74
+ ...cssOver
75
+ },
76
+ html: {
77
+ ...config.html,
78
+ ...htmlOver
79
+ }
80
+ };
81
+ }
82
+ let dom = parse(html);
83
+ dom = await inlineLinkDom(dom, filePath);
84
+ if (tailwindBlocks?.length) dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath);
85
+ dom = await tailwindcss(dom, effective, filePath);
86
+ if (enabled("safeClassNames")) dom = safeClassNames(dom, effective.css);
87
+ if (enabled("attributeToStyle") && typeof effective.css?.inline === "object" && effective.css.inline.attributeToStyle) dom = attributeToStyleDom(dom, effective.css.inline.attributeToStyle);
88
+ if (enabled("inlineCss") && effective.css?.inline) {
89
+ const inlineOptions = typeof effective.css.inline === "object" ? effective.css.inline : {};
90
+ dom = inlineCssDom(dom, inlineOptions);
91
+ }
92
+ dom = msoPlaceholders(dom);
93
+ dom = columnWidth(dom);
94
+ if (enabled("removeAttributes")) {
95
+ const removeRules = effective.html?.attributes?.remove;
96
+ dom = removeAttributesDom(dom, Array.isArray(removeRules) ? removeRules : []);
97
+ }
98
+ if (enabled("shorthandCss") && effective.css?.shorthand) {
99
+ const shorthandOptions = typeof effective.css.shorthand === "object" ? effective.css.shorthand : {};
100
+ dom = shorthandCssDom(dom, shorthandOptions);
101
+ }
102
+ if (enabled("sixHex") && effective.css?.sixHex !== false) dom = sixHexDom(dom);
103
+ if (enabled("addAttributes")) dom = addAttributes(dom, effective.html?.attributes);
104
+ if (enabled("filters")) dom = filtersDom(dom, effective.filters);
105
+ if (enabled("baseURL") && effective.url?.base) dom = baseDom(dom, effective.url.base);
106
+ if (enabled("urlQuery") && effective.url?.query && Object.keys(effective.url.query).length > 0) {
107
+ const { _options: queryOptions, ...queryParams } = effective.url.query;
108
+ dom = urlQueryDom(dom, queryParams, queryOptions ?? {});
109
+ }
110
+ if (enabled("purgeCss") && effective.css?.purge) {
111
+ const purgeOptions = typeof effective.css.purge === "object" ? effective.css.purge : {};
112
+ dom = purgeCssDom(dom, purgeOptions);
113
+ }
114
+ if (enabled("entities")) dom = entitiesDom(dom, effective.html?.decodeEntities);
115
+ const isXhtml = doctype ? /xhtml/i.test(doctype) : false;
116
+ let result = serialize(dom, { selfClosingTags: isXhtml });
117
+ if (enabled("replaceStrings")) result = replaceStrings(result, effective);
118
+ const minifyWillRun = enabled("minify") && !!effective.html?.minify;
119
+ if (enabled("prettify") && !minifyWillRun && effective.html?.format) {
120
+ const formatOptions = typeof effective.html.format === "object" ? effective.html.format : {};
121
+ result = await format(result, formatOptions);
122
+ }
123
+ if (enabled("minify") && effective.html?.minify) {
124
+ const minifyOptions = typeof effective.html.minify === "object" ? effective.html.minify : {};
125
+ result = minify(result, minifyOptions);
126
+ }
127
+ if (!isXhtml) result = result.replace(/<!--\[if [^\]]*\]>[\s\S]*?<!\[endif\]-->|( \/>)/g, (match, selfClose) => selfClose ? ">" : match);
128
+ return result;
129
+ }
130
+ //#endregion
131
+ export { runTransformers };
132
+
133
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLinkDom } from './inlineLink.ts'\nimport { tailwindComponent } from './tailwindComponent.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeClassNames } from './safeClassNames.ts'\nimport { attributeToStyleDom } from './attributeToStyle.ts'\nimport { inlineCssDom } from './inlineCss.ts'\nimport { msoPlaceholders } from './msoPlaceholders.ts'\nimport { columnWidth } from './columnWidth.ts'\nimport { removeAttributesDom } from './removeAttributes.ts'\nimport { shorthandCssDom } from './shorthandCss.ts'\nimport { sixHexDom } from './sixHex.ts'\nimport { addAttributes } from './addAttributes.ts'\nimport { filtersDom } from './filters/index.ts'\nimport { baseDom } from './base.ts'\nimport { entitiesDom } from './entities.ts'\nimport { urlQueryDom } from './urlQuery.ts'\nimport { purgeCssDom } from './purgeCss.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Six-digit HEX\n * 8. Add attributes\n * 9. Filters\n * 10. Base URL\n * 11. URL query\n * 12. Purge CSS (serializes/parses internally around email-comb)\n * 13. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 14. Replace strings\n * 15. Prettify\n * 16. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n doctype?: string,\n tailwindBlocks?: TailwindBlock[],\n): Promise<string> {\n // Per-transformer skip map — only honored when useTransformers is an object.\n // Whole-pipeline opt-out (`useTransformers === false`) is handled upstream\n // in build.ts / render so we never reach this function in that case.\n //\n // A toggle set to `true` *force-enables* its transformer for this run by\n // layering on the matching config slice (e.g. `prettify: true` sets\n // `html.format = true`). This only applies to transformers whose\n // enable flag is a plain boolean — data-driven ones (filters,\n // baseURL, urlQuery, etc.) need actual config values, so a\n // bare `true` for those is a no-op.\n const toggles = typeof config.useTransformers === 'object' ? config.useTransformers : null\n const enabled = (key: keyof NonNullable<typeof toggles>) => toggles?.[key] !== false\n\n let effective = config\n if (toggles) {\n const cssOver: Record<string, unknown> = {}\n const htmlOver: Record<string, unknown> = {}\n if (toggles.inlineCss === true) cssOver.inline = true\n if (toggles.purgeCss === true) cssOver.purge = true\n if (toggles.safeClassNames === true) cssOver.safe = true\n if (toggles.shorthandCss === true) cssOver.shorthand = true\n if (toggles.sixHex === true) cssOver.sixHex = true\n if (toggles.prettify === true) htmlOver.format = true\n if (toggles.minify === true) htmlOver.minify = true\n if (toggles.entities === true) htmlOver.decodeEntities = true\n\n if (Object.keys(cssOver).length || Object.keys(htmlOver).length) {\n effective = {\n ...config,\n css: { ...config.css, ...cssOver },\n html: { ...config.html, ...htmlOver },\n }\n }\n }\n\n // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLinkDom(dom, filePath)\n\n // 0.5. <Tailwind> component — compile per-block scoped CSS, inject into <head>\n if (tailwindBlocks?.length) {\n dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath)\n }\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, effective, filePath)\n\n // 2. Safe class names\n if (enabled('safeClassNames')) dom = safeClassNames(dom, effective.css)\n\n // 3. Attribute to style\n if (enabled('attributeToStyle') && typeof effective.css?.inline === 'object' && effective.css.inline.attributeToStyle) {\n dom = attributeToStyleDom(dom, effective.css.inline.attributeToStyle)\n }\n\n // 4. CSS inliner (serializes/parses internally around juice)\n if (enabled('inlineCss') && effective.css?.inline) {\n const inlineOptions = typeof effective.css.inline === 'object' ? effective.css.inline : {}\n dom = inlineCssDom(dom, inlineOptions)\n }\n\n // 4.5. Resolve MSO placeholders (table width + td style) from inlined CSS\n dom = msoPlaceholders(dom)\n\n // 4.6. Resolve Column min-width placeholders from nearest sized ancestor\n dom = columnWidth(dom)\n\n // 5. Remove attributes\n if (enabled('removeAttributes')) {\n const removeRules = effective.html?.attributes?.remove\n dom = removeAttributesDom(dom, Array.isArray(removeRules) ? removeRules : [])\n }\n\n // 6. Shorthand CSS\n if (enabled('shorthandCss') && effective.css?.shorthand) {\n const shorthandOptions = typeof effective.css.shorthand === 'object' ? effective.css.shorthand : {}\n dom = shorthandCssDom(dom, shorthandOptions)\n }\n\n // 7. Six-digit HEX\n if (enabled('sixHex') && effective.css?.sixHex !== false) dom = sixHexDom(dom)\n\n // 8. Add attributes\n if (enabled('addAttributes')) dom = addAttributes(dom, effective.html?.attributes)\n\n // 9. Filters\n if (enabled('filters')) dom = filtersDom(dom, effective.filters)\n\n // 10. Base URL (serializes/parses internally for VML/MSO regex passes)\n if (enabled('baseURL') && effective.url?.base) dom = baseDom(dom, effective.url.base)\n\n // 11. URL query\n if (enabled('urlQuery') && effective.url?.query && Object.keys(effective.url.query).length > 0) {\n const { _options: queryOptions, ...queryParams } = effective.url.query as Record<string, unknown>\n dom = urlQueryDom(dom, queryParams, (queryOptions ?? {}) as import('../types/config.ts').UrlQueryOptions)\n }\n\n // 12. Remove unused CSS (serializes/parses internally around email-comb)\n if (enabled('purgeCss') && effective.css?.purge) {\n const purgeOptions = typeof effective.css.purge === 'object' ? effective.css.purge : {}\n dom = purgeCssDom(dom, purgeOptions)\n }\n\n // 13. Entities\n if (enabled('entities')) dom = entitiesDom(dom, effective.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n const isXhtml = doctype ? /xhtml/i.test(doctype) : false\n let result = serialize(dom, { selfClosingTags: isXhtml })\n\n // 14. Replace strings\n if (enabled('replaceStrings')) result = replaceStrings(result, effective)\n\n // 15. Format — skipped when `minify` is enabled\n const minifyWillRun = enabled('minify') && !!effective.html?.minify\n if (enabled('prettify') && !minifyWillRun && effective.html?.format) {\n const formatOptions = typeof effective.html.format === 'object' ? effective.html.format : {}\n result = await format(result, formatOptions)\n }\n\n // 16. Minify\n if (enabled('minify') && effective.html?.minify) {\n const minifyOptions = typeof effective.html.minify === 'object' ? effective.html.minify : {}\n result = minify(result, minifyOptions)\n }\n\n // Strip self-closing slashes for HTML5 doctypes, but preserve content\n // inside MSO conditional comments (which are XML-ish and case/syntax sensitive).\n if (!isXhtml) {\n result = result.replace(\n /<!--\\[if [^\\]]*\\]>[\\s\\S]*?<!\\[endif\\]-->|( \\/>)/g,\n (match, selfClose) =>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a;;CAItC,IAAI,QAAQ,WAAW,EAAE,MAAM,YAAY,KAAK,UAAU,MAAM,eAAe;CAG/E,MAAM,UAAU,UAAU,SAAS,KAAK,QAAQ,GAAG;CACnD,IAAI,SAAS,UAAU,KAAK,EAAE,iBAAiB,SAAS,CAAC;CAGzD,IAAI,QAAQ,iBAAiB,EAAE,SAAS,eAAe,QAAQ,UAAU;CAGzE,MAAM,gBAAgB,QAAQ,SAAS,IAAI,CAAC,CAAC,UAAU,MAAM;CAC7D,IAAI,QAAQ,WAAW,IAAI,CAAC,iBAAiB,UAAU,MAAM,QAAQ;EACnE,MAAM,gBAAgB,OAAO,UAAU,KAAK,WAAW,WAAW,UAAU,KAAK,SAAS,EAAE;EAC5F,SAAS,MAAM,OAAO,QAAQ,cAAc;;CAI9C,IAAI,QAAQ,SAAS,IAAI,UAAU,MAAM,QAAQ;EAC/C,MAAM,gBAAgB,OAAO,UAAU,KAAK,WAAW,WAAW,UAAU,KAAK,SAAS,EAAE;EAC5F,SAAS,OAAO,QAAQ,cAAc;;CAKxC,IAAI,CAAC,SACH,SAAS,OAAO,QACd,qDACC,OAAO,cAAc,YAAY,MAAM,MACzC;CAGH,OAAO"}
@@ -0,0 +1,84 @@
1
+ import { ChildNode } from "domhandler";
2
+ import { Options } from "juice";
3
+
4
+ //#region src/transformers/inlineCss.d.ts
5
+ /**
6
+ * Options for the `inlineCss` transformer. Accepts every Juice option plus a
7
+ * handful of Maizzle-specific extras.
8
+ */
9
+ interface InlineCssOptions extends Options {
10
+ /**
11
+ * Convert `0px`, `0em` etc. to `0` in inline styles.
12
+ *
13
+ * @default true
14
+ */
15
+ preferUnitlessValues?: boolean;
16
+ /**
17
+ * CSS selectors to preserve in `<style>` tags, even after inlining.
18
+ * Mapped to Juice's `preservedSelectors` option.
19
+ *
20
+ * @default []
21
+ */
22
+ safelist?: string[];
23
+ /**
24
+ * Additional CSS string to inline alongside `<style>` tag contents.
25
+ * Mapped to Juice's `extraCss` option.
26
+ */
27
+ customCSS?: string;
28
+ /**
29
+ * Duplicate CSS properties to HTML attributes.
30
+ * Mapped to Juice's static `styleToAttribute` property.
31
+ */
32
+ styleToAttribute?: Record<string, string>;
33
+ /**
34
+ * CSS properties to exclude from inlining.
35
+ * Mapped to Juice's static `excludedProperties` property.
36
+ */
37
+ excludedProperties?: string[];
38
+ /**
39
+ * Elements that can receive `width` HTML attributes.
40
+ * Mapped to Juice's static `widthElements` property.
41
+ *
42
+ * @default ['img', 'video']
43
+ */
44
+ widthElements?: string[];
45
+ /**
46
+ * Elements that can receive `height` HTML attributes.
47
+ * Mapped to Juice's static `heightElements` property.
48
+ *
49
+ * @default ['img', 'video']
50
+ */
51
+ heightElements?: string[];
52
+ /**
53
+ * Template language code blocks to preserve during inlining.
54
+ * Mapped to Juice's static `codeBlocks` property.
55
+ */
56
+ codeBlocks?: Record<string, {
57
+ start: string;
58
+ end: string;
59
+ }>;
60
+ }
61
+ /**
62
+ * Inline CSS from `<style>` tags into `style` attributes on matching elements.
63
+ *
64
+ * @param html HTML string to transform.
65
+ * @param options Juice options plus Maizzle-specific extras.
66
+ * @returns The transformed HTML string.
67
+ *
68
+ * @example
69
+ * import { inlineCss } from '@maizzle/framework'
70
+ *
71
+ * const out = inlineCss('<style>.red{color:red}</style><p class="red">x</p>', {
72
+ * removeStyleTags: true,
73
+ * })
74
+ */
75
+ declare function inlineCss(html: string, options?: InlineCssOptions): string;
76
+ /**
77
+ * DOM-form of {@link inlineCss} used by the internal transformer pipeline.
78
+ * Takes a parsed DOM, returns a parsed DOM — avoids the redundant
79
+ * serialize/parse round-trips when chained with other transformers.
80
+ */
81
+ declare function inlineCssDom(dom: ChildNode[], options?: InlineCssOptions): ChildNode[];
82
+ //#endregion
83
+ export { InlineCssOptions, inlineCss, inlineCssDom };
84
+ //# sourceMappingURL=inlineCss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineCss.d.ts","names":[],"sources":["../../src/transformers/inlineCss.ts"],"mappings":";;;;;;AASA;;UAAiB,gBAAA,SAAyB,OAAA;EAuBrB;;;;;EAjBnB,oBAAA;EAAA;;;;;;EAOA,QAAA;EA6BA;;;;EAxBA,SAAA;EA6BgD;;AAiBlD;;EAzCE,gBAAA,GAAmB,MAAA;EAyCiD;;;;EApCpE,kBAAA;EAoCoE;AAStE;;;;;EAtCE,aAAA;EAsCuF;;;;;;EA/BvF,cAAA;EA+BuF;;;;EA1BvF,UAAA,GAAa,MAAA;IAAiB,KAAA;IAAe,GAAA;EAAA;AAAA;;;;;;;;;;;;;;;iBAiB/B,SAAA,CAAU,IAAA,UAAc,OAAA,GAAS,gBAAA;;;;;;iBASjC,YAAA,CAAa,GAAA,EAAK,SAAA,IAAa,OAAA,GAAS,gBAAA,GAAwB,SAAA"}
@@ -1,23 +1,33 @@
1
- import { parse } from "../utils/ast/parser.mjs";
2
- import { walk } from "../utils/ast/walker.mjs";
3
- import { serialize } from "../utils/ast/serializer.mjs";
4
- import "../utils/ast/index.mjs";
1
+ import { parse } from "../utils/ast/parser.js";
2
+ import { walk } from "../utils/ast/walker.js";
3
+ import { serialize } from "../utils/ast/serializer.js";
4
+ import "../utils/ast/index.js";
5
5
  import juice from "juice";
6
-
7
- //#region src/transformers/inlineCSS.ts
6
+ //#region src/transformers/inlineCss.ts
8
7
  /**
9
- * Inline CSS transformer.
8
+ * Inline CSS from `<style>` tags into `style` attributes on matching elements.
9
+ *
10
+ * @param html HTML string to transform.
11
+ * @param options Juice options plus Maizzle-specific extras.
12
+ * @returns The transformed HTML string.
10
13
  *
11
- * Inlines CSS from `<style>` tags into inline style attributes on HTML elements.
12
- * This is important for email client compatibility (especially Outlook on Windows).
14
+ * @example
15
+ * import { inlineCss } from '@maizzle/framework'
13
16
  *
14
- * Enabled when `css.inline` is set to `true` or an object with options.
15
- * All Juice options are supported and passed through directly.
17
+ * const out = inlineCss('<style>.red{color:red}</style><p class="red">x</p>', {
18
+ * removeStyleTags: true,
19
+ * })
16
20
  */
17
- function inlineCSS(dom, config = {}) {
18
- const inline = config.inline;
19
- if (!inline) return dom;
20
- const { preferUnitlessValues = true, safelist, customCSS = "", styleToAttribute, excludedProperties, widthElements, heightElements, codeBlocks, ...juicePassthrough } = typeof inline === "object" ? inline : {};
21
+ function inlineCss(html, options = {}) {
22
+ return serialize(inlineCssDom(parse(html), options));
23
+ }
24
+ /**
25
+ * DOM-form of {@link inlineCss} used by the internal transformer pipeline.
26
+ * Takes a parsed DOM, returns a parsed DOM — avoids the redundant
27
+ * serialize/parse round-trips when chained with other transformers.
28
+ */
29
+ function inlineCssDom(dom, options = {}) {
30
+ const { preferUnitlessValues = true, safelist, customCSS = "", styleToAttribute, excludedProperties, widthElements, heightElements, codeBlocks, ...juicePassthrough } = options;
21
31
  juice.styleToAttribute = styleToAttribute ?? {};
22
32
  juice.excludedProperties = ["--tw-shadow", ...excludedProperties ?? []];
23
33
  juice.widthElements = (widthElements ?? ["img", "video"]).map((i) => i.toUpperCase());
@@ -75,7 +85,7 @@ function inlineCSS(dom, config = {}) {
75
85
  });
76
86
  return result;
77
87
  }
78
-
79
88
  //#endregion
80
- export { inlineCSS };
81
- //# sourceMappingURL=inlineCSS.mjs.map
89
+ export { inlineCss, inlineCssDom };
90
+
91
+ //# sourceMappingURL=inlineCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineCss.js","names":[],"sources":["../../src/transformers/inlineCss.ts"],"sourcesContent":["import juice from 'juice'\nimport { walk, parse, serialize } from '../utils/ast/index.ts'\nimport type { ChildNode, Element } from 'domhandler'\nimport type { Options as JuiceOptions } from 'juice'\n\n/**\n * Options for the `inlineCss` transformer. Accepts every Juice option plus a\n * handful of Maizzle-specific extras.\n */\nexport interface InlineCssOptions extends JuiceOptions {\n /**\n * Convert `0px`, `0em` etc. to `0` in inline styles.\n *\n * @default true\n */\n preferUnitlessValues?: boolean\n /**\n * CSS selectors to preserve in `<style>` tags, even after inlining.\n * Mapped to Juice's `preservedSelectors` option.\n *\n * @default []\n */\n safelist?: string[]\n /**\n * Additional CSS string to inline alongside `<style>` tag contents.\n * Mapped to Juice's `extraCss` option.\n */\n customCSS?: string\n /**\n * Duplicate CSS properties to HTML attributes.\n * Mapped to Juice's static `styleToAttribute` property.\n */\n styleToAttribute?: Record<string, string>\n /**\n * CSS properties to exclude from inlining.\n * Mapped to Juice's static `excludedProperties` property.\n */\n excludedProperties?: string[]\n /**\n * Elements that can receive `width` HTML attributes.\n * Mapped to Juice's static `widthElements` property.\n *\n * @default ['img', 'video']\n */\n widthElements?: string[]\n /**\n * Elements that can receive `height` HTML attributes.\n * Mapped to Juice's static `heightElements` property.\n *\n * @default ['img', 'video']\n */\n heightElements?: string[]\n /**\n * Template language code blocks to preserve during inlining.\n * Mapped to Juice's static `codeBlocks` property.\n */\n codeBlocks?: Record<string, { start: string; end: string }>\n}\n\n/**\n * Inline CSS from `<style>` tags into `style` attributes on matching elements.\n *\n * @param html HTML string to transform.\n * @param options Juice options plus Maizzle-specific extras.\n * @returns The transformed HTML string.\n *\n * @example\n * import { inlineCss } from '@maizzle/framework'\n *\n * const out = inlineCss('<style>.red{color:red}</style><p class=\"red\">x</p>', {\n * removeStyleTags: true,\n * })\n */\nexport function inlineCss(html: string, options: InlineCssOptions = {}): string {\n return serialize(inlineCssDom(parse(html), options))\n}\n\n/**\n * DOM-form of {@link inlineCss} used by the internal transformer pipeline.\n * Takes a parsed DOM, returns a parsed DOM — avoids the redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport function inlineCssDom(dom: ChildNode[], options: InlineCssOptions = {}): ChildNode[] {\n const {\n preferUnitlessValues = true,\n safelist,\n customCSS = '',\n styleToAttribute,\n excludedProperties,\n widthElements,\n heightElements,\n codeBlocks,\n ...juicePassthrough\n } = options\n\n // Configure Juice static properties\n juice.styleToAttribute = styleToAttribute ?? {}\n juice.excludedProperties = ['--tw-shadow', ...(excludedProperties ?? [])]\n juice.widthElements = (widthElements ?? ['img', 'video']).map(i => i.toUpperCase()) as unknown as HTMLElement[]\n juice.heightElements = (heightElements ?? ['img', 'video']).map(i => i.toUpperCase()) as unknown as HTMLElement[]\n\n // Add custom code blocks\n if (codeBlocks && typeof codeBlocks === 'object') {\n Object.entries(codeBlocks).forEach(([key, value]) => {\n if (value.start && value.end) {\n juice.codeBlocks[key] = value\n }\n })\n }\n\n // Handle style tags with embed attributes.\n // We add a marker attribute that persists through the pipeline,\n // then restore data-embed from it after Juice runs.\n walk(dom, (node) => {\n const el = node as Element\n if (el.name === 'style' && el.attribs) {\n // Sync data-embed ↔ embed. Use `in` so presence-only attrs\n // (<style embed> → attribs.embed === '') still count.\n if ('embed' in el.attribs && !('data-embed' in el.attribs)) {\n el.attribs['data-embed'] = ''\n }\n if ('data-embed' in el.attribs && !('embed' in el.attribs)) {\n el.attribs.embed = ''\n }\n\n // Add marker that persists through the pipeline\n if ('data-embed' in el.attribs) {\n el.attribs['data-maizzle-embed'] = ''\n }\n }\n })\n\n // Serialize for juice (juice requires a string)\n const serialized = serialize(dom)\n\n let inlinedHtml: string\n\n try {\n const juiceOptions: JuiceOptions = {\n removeStyleTags: juicePassthrough.removeStyleTags ?? false,\n removeInlinedSelectors: juicePassthrough.removeInlinedSelectors ?? true,\n applyWidthAttributes: juicePassthrough.applyWidthAttributes ?? true,\n applyHeightAttributes: juicePassthrough.applyHeightAttributes ?? true,\n preservedSelectors: safelist ?? [],\n ...customCSS ? { extraCss: customCSS } : {},\n inlineDuplicateProperties: juicePassthrough.inlineDuplicateProperties ?? true,\n ...juicePassthrough,\n }\n\n inlinedHtml = juice(serialized, juiceOptions)\n } catch {\n // If Juice fails, return the dom unchanged\n return dom\n }\n\n // Post-process for preferUnitlessValues\n const result = parse(inlinedHtml)\n\n walk(result, (node) => {\n const el = node as Element\n if (el.attribs?.style) {\n // Normalize style formatting: ensure spaces after : and ;\n let style = el.attribs.style\n .replace(/:\\s*/g, ': ')\n .replace(/;\\s*/g, '; ')\n .trimEnd()\n\n // Ensure trailing semicolon\n if (!style.endsWith(';')) {\n style += ';'\n }\n\n if (preferUnitlessValues) {\n style = style.replace(\n /\\b0(px|rem|em|%|vh|vw|vmin|vmax|in|cm|mm|pt|pc|ex|ch)\\b/g,\n '0'\n )\n }\n\n el.attribs.style = style\n }\n })\n\n /**\n * Restore `embed` from our marker so the purge step can detect\n * these tags and skip them. Drop `data-embed` (juice's name)\n * since it's redundant once `embed` is back, and let purge\n * strip `embed` itself at the end of its run.\n */\n walk(result, (node) => {\n const el = node as Element\n if (el.name === 'style' && el.attribs && 'data-maizzle-embed' in el.attribs) {\n el.attribs.embed = ''\n delete el.attribs['data-embed']\n delete el.attribs['data-maizzle-embed']\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,UAAU,MAAc,UAA4B,EAAE,EAAU;CAC9E,OAAO,UAAU,aAAa,MAAM,KAAK,EAAE,QAAQ,CAAC;;;;;;;AAQtD,SAAgB,aAAa,KAAkB,UAA4B,EAAE,EAAe;CAC1F,MAAM,EACJ,uBAAuB,MACvB,UACA,YAAY,IACZ,kBACA,oBACA,eACA,gBACA,YACA,GAAG,qBACD;CAGJ,MAAM,mBAAmB,oBAAoB,EAAE;CAC/C,MAAM,qBAAqB,CAAC,eAAe,GAAI,sBAAsB,EAAE,CAAE;CACzE,MAAM,iBAAiB,iBAAiB,CAAC,OAAO,QAAQ,EAAE,KAAI,MAAK,EAAE,aAAa,CAAC;CACnF,MAAM,kBAAkB,kBAAkB,CAAC,OAAO,QAAQ,EAAE,KAAI,MAAK,EAAE,aAAa,CAAC;CAGrF,IAAI,cAAc,OAAO,eAAe,UACtC,OAAO,QAAQ,WAAW,CAAC,SAAS,CAAC,KAAK,WAAW;EACnD,IAAI,MAAM,SAAS,MAAM,KACvB,MAAM,WAAW,OAAO;GAE1B;CAMJ,KAAK,MAAM,SAAS;EAClB,MAAM,KAAK;EACX,IAAI,GAAG,SAAS,WAAW,GAAG,SAAS;GAGrC,IAAI,WAAW,GAAG,WAAW,EAAE,gBAAgB,GAAG,UAChD,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