@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
@@ -4,11 +4,32 @@ import { ChildNode } from "domhandler";
4
4
  /**
5
5
  * Inline `<link rel="stylesheet">` tags as `<style>` tags.
6
6
  *
7
- * - Local file paths are always inlined (resolved relative to the template)
8
- * - Remote URLs (http/https) are only inlined if the `inline` attribute is present
9
- * - Runs before the tailwindcss transformer so CSS is compiled normally
7
+ * - Local file paths are inlined when `filePath` is provided (resolved
8
+ * relative to it).
9
+ * - Remote URLs (`http://` / `https://`) are only inlined when the link
10
+ * carries an `inline` attribute, e.g. `<link rel="stylesheet" inline href="…">`.
11
+ *
12
+ * @param html HTML string to transform.
13
+ * @param filePath Path of the source file the HTML came from, used as the
14
+ * base for resolving relative `href` values. Required for
15
+ * local-file inlining; remote `inline` links work without it.
16
+ * @returns The transformed HTML string.
17
+ *
18
+ * @example
19
+ * import { inlineLink } from '@maizzle/framework'
20
+ *
21
+ * const out = await inlineLink(
22
+ * '<link rel="stylesheet" href="./styles.css">',
23
+ * '/path/to/template.html',
24
+ * )
25
+ */
26
+ declare function inlineLink(html: string, filePath?: string): Promise<string>;
27
+ /**
28
+ * DOM-form of {@link inlineLink} used by the internal transformer pipeline.
29
+ * Takes a parsed DOM, returns a parsed DOM — avoids redundant
30
+ * serialize/parse round-trips when chained with other transformers.
10
31
  */
11
- declare function inlineLink(dom: ChildNode[], filePath?: string): Promise<ChildNode[]>;
32
+ declare function inlineLinkDom(dom: ChildNode[], filePath?: string): Promise<ChildNode[]>;
12
33
  //#endregion
13
- export { inlineLink };
34
+ export { inlineLink, inlineLinkDom };
14
35
  //# sourceMappingURL=inlineLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inlineLink.d.ts","names":[],"sources":["../../src/transformers/inlineLink.ts"],"mappings":";;;;;AAYA;;;;;iBAAsB,UAAA,CAAW,GAAA,EAAK,SAAA,IAAa,QAAA,YAAoB,OAAA,CAAQ,SAAA"}
1
+ {"version":3,"file":"inlineLink.d.ts","names":[],"sources":["../../src/transformers/inlineLink.ts"],"mappings":";;;;;AA2BA;;;;;;;;;AASA;;;;;;;;;;;iBATsB,UAAA,CAAW,IAAA,UAAc,QAAA,YAAoB,OAAA;;;;;;iBAS7C,aAAA,CAAc,GAAA,EAAK,SAAA,IAAa,QAAA,YAAoB,OAAA,CAAQ,SAAA"}
@@ -1,17 +1,41 @@
1
- import { walk } from "../utils/ast/walker.mjs";
2
- 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";
3
5
  import { readFileSync } from "node:fs";
4
6
  import { dirname, resolve } from "node:path";
5
-
6
7
  //#region src/transformers/inlineLink.ts
7
8
  /**
8
9
  * Inline `<link rel="stylesheet">` tags as `<style>` tags.
9
10
  *
10
- * - Local file paths are always inlined (resolved relative to the template)
11
- * - Remote URLs (http/https) are only inlined if the `inline` attribute is present
12
- * - Runs before the tailwindcss transformer so CSS is compiled normally
11
+ * - Local file paths are inlined when `filePath` is provided (resolved
12
+ * relative to it).
13
+ * - Remote URLs (`http://` / `https://`) are only inlined when the link
14
+ * carries an `inline` attribute, e.g. `<link rel="stylesheet" inline href="…">`.
15
+ *
16
+ * @param html HTML string to transform.
17
+ * @param filePath Path of the source file the HTML came from, used as the
18
+ * base for resolving relative `href` values. Required for
19
+ * local-file inlining; remote `inline` links work without it.
20
+ * @returns The transformed HTML string.
21
+ *
22
+ * @example
23
+ * import { inlineLink } from '@maizzle/framework'
24
+ *
25
+ * const out = await inlineLink(
26
+ * '<link rel="stylesheet" href="./styles.css">',
27
+ * '/path/to/template.html',
28
+ * )
13
29
  */
14
- async function inlineLink(dom, filePath) {
30
+ async function inlineLink(html, filePath) {
31
+ return serialize(await inlineLinkDom(parse(html), filePath));
32
+ }
33
+ /**
34
+ * DOM-form of {@link inlineLink} used by the internal transformer pipeline.
35
+ * Takes a parsed DOM, returns a parsed DOM — avoids redundant
36
+ * serialize/parse round-trips when chained with other transformers.
37
+ */
38
+ async function inlineLinkDom(dom, filePath) {
15
39
  const links = [];
16
40
  walk(dom, (node) => {
17
41
  if (node.name !== "link") return;
@@ -70,7 +94,7 @@ async function inlineLink(dom, filePath) {
70
94
  }
71
95
  return dom;
72
96
  }
73
-
74
97
  //#endregion
75
- export { inlineLink };
76
- //# sourceMappingURL=inlineLink.mjs.map
98
+ export { inlineLink, inlineLinkDom };
99
+
100
+ //# sourceMappingURL=inlineLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineLink.js","names":[],"sources":["../../src/transformers/inlineLink.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\n\n/**\n * Inline `<link rel=\"stylesheet\">` tags as `<style>` tags.\n *\n * - Local file paths are inlined when `filePath` is provided (resolved\n * relative to it).\n * - Remote URLs (`http://` / `https://`) are only inlined when the link\n * carries an `inline` attribute, e.g. `<link rel=\"stylesheet\" inline href=\"…\">`.\n *\n * @param html HTML string to transform.\n * @param filePath Path of the source file the HTML came from, used as the\n * base for resolving relative `href` values. Required for\n * local-file inlining; remote `inline` links work without it.\n * @returns The transformed HTML string.\n *\n * @example\n * import { inlineLink } from '@maizzle/framework'\n *\n * const out = await inlineLink(\n * '<link rel=\"stylesheet\" href=\"./styles.css\">',\n * '/path/to/template.html',\n * )\n */\nexport async function inlineLink(html: string, filePath?: string): Promise<string> {\n return serialize(await inlineLinkDom(parse(html), filePath))\n}\n\n/**\n * DOM-form of {@link inlineLink} 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 async function inlineLinkDom(dom: ChildNode[], filePath?: string): Promise<ChildNode[]> {\n const links: { node: Element; parent: ChildNode; index: number }[] = []\n\n walk(dom, (node) => {\n if ((node as Element).name !== 'link') return\n\n const el = node as Element\n const attrs = el.attribs || {}\n\n if (attrs.rel !== 'stylesheet' || !attrs.href) return\n\n const parent = el.parent as ChildNode\n\n if (parent && 'children' in parent) {\n const index = (parent.children as ChildNode[]).indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent, index })\n }\n } else {\n // Top-level node\n const index = dom.indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent: null as any, index })\n }\n }\n })\n\n for (const { node, parent, index } of links) {\n const href = node.attribs.href\n const isRemote = href.startsWith('http://') || href.startsWith('https://')\n\n let css: string | undefined\n\n if (isRemote) {\n if (!('inline' in node.attribs)) continue\n\n try {\n const response = await fetch(href)\n css = await response.text()\n } catch {\n continue\n }\n } else {\n if (!filePath) continue\n\n try {\n const absolutePath = resolve(dirname(filePath), href)\n css = readFileSync(absolutePath, 'utf8')\n } catch {\n continue\n }\n }\n\n const styleNode = {\n type: 'tag',\n name: 'style',\n attribs: {},\n children: [{\n type: 'text',\n data: css,\n parent: null as any,\n }],\n parent: parent || null,\n } as any\n\n // Set parent reference on the text child\n styleNode.children[0].parent = styleNode\n\n const siblings = parent && 'children' in parent\n ? parent.children as ChildNode[]\n : dom\n\n siblings.splice(index, 1, styleNode)\n }\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,eAAsB,WAAW,MAAc,UAAoC;CACjF,OAAO,UAAU,MAAM,cAAc,MAAM,KAAK,EAAE,SAAS,CAAC;;;;;;;AAQ9D,eAAsB,cAAc,KAAkB,UAAyC;CAC7F,MAAM,QAA+D,EAAE;CAEvE,KAAK,MAAM,SAAS;EAClB,IAAK,KAAiB,SAAS,QAAQ;EAEvC,MAAM,KAAK;EACX,MAAM,QAAQ,GAAG,WAAW,EAAE;EAE9B,IAAI,MAAM,QAAQ,gBAAgB,CAAC,MAAM,MAAM;EAE/C,MAAM,SAAS,GAAG;EAElB,IAAI,UAAU,cAAc,QAAQ;GAClC,MAAM,QAAS,OAAO,SAAyB,QAAQ,GAAG;GAC1D,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI;IAAQ;IAAO,CAAC;SAEpC;GAEL,MAAM,QAAQ,IAAI,QAAQ,GAAG;GAC7B,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI,QAAQ;IAAa;IAAO,CAAC;;GAGxD;CAEF,KAAK,MAAM,EAAE,MAAM,QAAQ,WAAW,OAAO;EAC3C,MAAM,OAAO,KAAK,QAAQ;EAC1B,MAAM,WAAW,KAAK,WAAW,UAAU,IAAI,KAAK,WAAW,WAAW;EAE1E,IAAI;EAEJ,IAAI,UAAU;GACZ,IAAI,EAAE,YAAY,KAAK,UAAU;GAEjC,IAAI;IAEF,MAAM,OAAM,MADW,MAAM,KAAK,EACb,MAAM;WACrB;IACN;;SAEG;GACL,IAAI,CAAC,UAAU;GAEf,IAAI;IAEF,MAAM,aADe,QAAQ,QAAQ,SAAS,EAAE,KACjB,EAAE,OAAO;WAClC;IACN;;;EAIJ,MAAM,YAAY;GAChB,MAAM;GACN,MAAM;GACN,SAAS,EAAE;GACX,UAAU,CAAC;IACT,MAAM;IACN,MAAM;IACN,QAAQ;IACT,CAAC;GACF,QAAQ,UAAU;GACnB;EAGD,UAAU,SAAS,GAAG,SAAS;EAM/B,CAJiB,UAAU,cAAc,SACrC,OAAO,WACP,KAEK,OAAO,OAAO,GAAG,UAAU;;CAGtC,OAAO"}
@@ -1,17 +1,21 @@
1
- import { MaizzleConfig } from "../types/config.js";
1
+ import { Opts, Opts as MinifyOptions } from "html-crush";
2
2
 
3
3
  //#region src/transformers/minify.d.ts
4
4
  /**
5
- * Minify transformer.
5
+ * Minify an HTML string using `html-crush`. Maizzle's only default that
6
+ * differs from html-crush's own defaults is `removeLineBreaks: true`.
6
7
  *
7
- * Minifies HTML using the `html-crush` package.
8
- * Enabled by setting `minify: true` (or passing options object).
9
- * User options are merged on top of the defaults.
8
+ * @param html HTML string to minify.
9
+ * @param options [html-crush options](https://codsen.com/os/html-crush) merged
10
+ * on top of the Maizzle defaults.
11
+ * @returns The minified HTML string.
10
12
  *
11
- * The only Maizzle default that differs from html-crush's own defaults
12
- * is `removeLineBreaks: true`.
13
+ * @example
14
+ * import { minify } from '@maizzle/framework'
15
+ *
16
+ * const tight = minify('<p> hello </p>', { removeIndentations: true })
13
17
  */
14
- declare function minify(html: string, config?: MaizzleConfig): string;
18
+ declare function minify(html: string, options?: Partial<Opts>): string;
15
19
  //#endregion
16
- export { minify };
20
+ export { type MinifyOptions, minify };
17
21
  //# sourceMappingURL=minify.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"minify.d.ts","names":[],"sources":["../../src/transformers/minify.ts"],"mappings":";;;;;AAmBA;;;;;;;;iBAAgB,MAAA,CAAO,IAAA,UAAc,MAAA,GAAQ,aAAA"}
1
+ {"version":3,"file":"minify.d.ts","names":[],"sources":["../../src/transformers/minify.ts"],"mappings":";;;;AAwBA;;;;;;;;;;;;;iBAAgB,MAAA,CAAO,IAAA,UAAc,OAAA,GAAS,OAAA,CAAQ,IAAA"}
@@ -0,0 +1,25 @@
1
+ import { defu as defu$1 } from "defu";
2
+ import { crush } from "html-crush";
3
+ //#region src/transformers/minify.ts
4
+ const DEFAULT_OPTIONS = { removeLineBreaks: true };
5
+ /**
6
+ * Minify an HTML string using `html-crush`. Maizzle's only default that
7
+ * differs from html-crush's own defaults is `removeLineBreaks: true`.
8
+ *
9
+ * @param html HTML string to minify.
10
+ * @param options [html-crush options](https://codsen.com/os/html-crush) merged
11
+ * on top of the Maizzle defaults.
12
+ * @returns The minified HTML string.
13
+ *
14
+ * @example
15
+ * import { minify } from '@maizzle/framework'
16
+ *
17
+ * const tight = minify('<p> hello </p>', { removeIndentations: true })
18
+ */
19
+ function minify(html, options = {}) {
20
+ return crush(html, defu$1(options, DEFAULT_OPTIONS)).result;
21
+ }
22
+ //#endregion
23
+ export { minify };
24
+
25
+ //# sourceMappingURL=minify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minify.js","names":["merge"],"sources":["../../src/transformers/minify.ts"],"sourcesContent":["import { crush } from 'html-crush'\nimport { defu as merge } from 'defu'\nimport type { Opts as HtmlCrushOptions } from 'html-crush'\n\nexport type { Opts as MinifyOptions } from 'html-crush'\n\nconst DEFAULT_OPTIONS: Partial<HtmlCrushOptions> = {\n removeLineBreaks: true,\n}\n\n/**\n * Minify an HTML string using `html-crush`. Maizzle's only default that\n * differs from html-crush's own defaults is `removeLineBreaks: true`.\n *\n * @param html HTML string to minify.\n * @param options [html-crush options](https://codsen.com/os/html-crush) merged\n * on top of the Maizzle defaults.\n * @returns The minified HTML string.\n *\n * @example\n * import { minify } from '@maizzle/framework'\n *\n * const tight = minify('<p> hello </p>', { removeIndentations: true })\n */\nexport function minify(html: string, options: Partial<HtmlCrushOptions> = {}): string {\n const merged = merge(options, DEFAULT_OPTIONS) as Partial<HtmlCrushOptions>\n return crush(html, merged).result\n}\n"],"mappings":";;;AAMA,MAAM,kBAA6C,EACjD,kBAAkB,MACnB;;;;;;;;;;;;;;;AAgBD,SAAgB,OAAO,MAAc,UAAqC,EAAE,EAAU;CAEpF,OAAO,MAAM,MADEA,OAAM,SAAS,gBACL,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { ChildNode } from "domhandler";
2
+
3
+ //#region src/transformers/msoPlaceholders.d.ts
4
+ /**
5
+ * Resolve all `__MAIZZLE_MSO*__` placeholders inside MSO conditional comments
6
+ * by reading inlined style + `data-*` markers on the paired elements.
7
+ *
8
+ * Two placeholder families:
9
+ *
10
+ * MSOW (`__MAIZZLE_MSOW_{id}__`) — emitted by `<Container>` and `<Section>`.
11
+ * Source element is marked with `data-maizzle-msow-id`. Reads inlined
12
+ * `max-width:` (falls back to `width:`) and normalizes to px. Falls
13
+ * back to `data-maizzle-msow-fallback` (default `600px`) when the
14
+ * value can't be parsed.
15
+ *
16
+ * MSOTDSTYLE (`__MAIZZLE_MSOTDSTYLE_{id}__`) — emitted by `<Container>`'s
17
+ * MSO `<td>`. Source element is marked with `data-maizzle-mso-td-id`.
18
+ * Copies every `padding*` declaration from inlined style and appends
19
+ * the `data-maizzle-mso-style` value (the user's `msoStyle` prop).
20
+ * Empty input resolves to '' so the placeholder collapses cleanly.
21
+ *
22
+ * Single collect-walk + single substitute-walk: the same Container div
23
+ * carries both marker kinds, so one element visit fills both maps.
24
+ */
25
+ declare function msoPlaceholders(dom: ChildNode[]): ChildNode[];
26
+ //#endregion
27
+ export { msoPlaceholders };
28
+ //# sourceMappingURL=msoPlaceholders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msoPlaceholders.d.ts","names":[],"sources":["../../src/transformers/msoPlaceholders.ts"],"mappings":";;;;;AA4CA;;;;;;;;;;;;;;;;;;;iBAAgB,eAAA,CAAgB,GAAA,EAAK,SAAA,KAAc,SAAA"}
@@ -0,0 +1,88 @@
1
+ import { walk } from "../utils/ast/walker.js";
2
+ import "../utils/ast/index.js";
3
+ //#region src/transformers/msoPlaceholders.ts
4
+ const RE_MAX_WIDTH = /(?:^|;\s*)max-width:\s*([^;]+)/i;
5
+ const RE_WIDTH = /(?:^|;\s*)width:\s*([^;]+)/i;
6
+ const RE_PERCENT = /^[\d.]+%$/;
7
+ const PADDING_DECL_RE = /(?:^|;)\s*(padding(?:-[a-z-]+)?\s*:\s*[^;]+)/gi;
8
+ function resolveWidth(value) {
9
+ const trimmed = value.trim();
10
+ if (RE_PERCENT.test(trimmed)) return trimmed;
11
+ const m = trimmed.match(/^([\d.]+)(px|rem|em|pt)?$/i);
12
+ if (!m) return null;
13
+ const n = parseFloat(m[1]);
14
+ switch ((m[2] || "px").toLowerCase()) {
15
+ case "px": return `${Math.round(n)}px`;
16
+ case "rem":
17
+ case "em": return `${Math.round(n * 16)}px`;
18
+ case "pt": return `${Math.round(n * 1.333)}px`;
19
+ default: return null;
20
+ }
21
+ }
22
+ /**
23
+ * Resolve all `__MAIZZLE_MSO*__` placeholders inside MSO conditional comments
24
+ * by reading inlined style + `data-*` markers on the paired elements.
25
+ *
26
+ * Two placeholder families:
27
+ *
28
+ * MSOW (`__MAIZZLE_MSOW_{id}__`) — emitted by `<Container>` and `<Section>`.
29
+ * Source element is marked with `data-maizzle-msow-id`. Reads inlined
30
+ * `max-width:` (falls back to `width:`) and normalizes to px. Falls
31
+ * back to `data-maizzle-msow-fallback` (default `600px`) when the
32
+ * value can't be parsed.
33
+ *
34
+ * MSOTDSTYLE (`__MAIZZLE_MSOTDSTYLE_{id}__`) — emitted by `<Container>`'s
35
+ * MSO `<td>`. Source element is marked with `data-maizzle-mso-td-id`.
36
+ * Copies every `padding*` declaration from inlined style and appends
37
+ * the `data-maizzle-mso-style` value (the user's `msoStyle` prop).
38
+ * Empty input resolves to '' so the placeholder collapses cleanly.
39
+ *
40
+ * Single collect-walk + single substitute-walk: the same Container div
41
+ * carries both marker kinds, so one element visit fills both maps.
42
+ */
43
+ function msoPlaceholders(dom) {
44
+ const widths = /* @__PURE__ */ new Map();
45
+ const tdStyles = /* @__PURE__ */ new Map();
46
+ walk(dom, (node) => {
47
+ const a = node.attribs;
48
+ if (!a) return;
49
+ const msowId = a["data-maizzle-msow-id"];
50
+ const tdId = a["data-maizzle-mso-td-id"];
51
+ if (!msowId && !tdId) return;
52
+ const style = a.style ?? "";
53
+ if (msowId) {
54
+ delete a["data-maizzle-msow-id"];
55
+ const fallback = a["data-maizzle-msow-fallback"] ?? "600px";
56
+ delete a["data-maizzle-msow-fallback"];
57
+ const raw = style.match(RE_MAX_WIDTH)?.[1] ?? style.match(RE_WIDTH)?.[1];
58
+ const resolved = raw ? resolveWidth(raw) : null;
59
+ widths.set(msowId, resolved ?? fallback);
60
+ }
61
+ if (tdId) {
62
+ delete a["data-maizzle-mso-td-id"];
63
+ const msoStyle = (a["data-maizzle-mso-style"] ?? "").trim().replace(/;\s*$/, "");
64
+ delete a["data-maizzle-mso-style"];
65
+ const parts = [];
66
+ if (style) for (const m of style.matchAll(PADDING_DECL_RE)) parts.push(m[1].trim());
67
+ if (msoStyle) parts.push(msoStyle);
68
+ tdStyles.set(tdId, parts.length ? ` style="${parts.join("; ")}"` : "");
69
+ }
70
+ });
71
+ if (widths.size === 0 && tdStyles.size === 0) return dom;
72
+ walk(dom, (node) => {
73
+ if (node.type !== "comment") return;
74
+ let data = node.data;
75
+ if (!data) return;
76
+ const hasMsow = widths.size > 0 && data.includes("__MAIZZLE_MSOW_");
77
+ const hasTd = tdStyles.size > 0 && data.includes("__MAIZZLE_MSOTDSTYLE_");
78
+ if (!hasMsow && !hasTd) return;
79
+ if (hasMsow) for (const [id, val] of widths) data = data.replaceAll(`__MAIZZLE_MSOW_${id}__`, val);
80
+ if (hasTd) for (const [id, val] of tdStyles) data = data.replaceAll(`__MAIZZLE_MSOTDSTYLE_${id}__`, val);
81
+ node.data = data;
82
+ });
83
+ return dom;
84
+ }
85
+ //#endregion
86
+ export { msoPlaceholders };
87
+
88
+ //# sourceMappingURL=msoPlaceholders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msoPlaceholders.js","names":["el"],"sources":["../../src/transformers/msoPlaceholders.ts"],"sourcesContent":["import { walk } from '../utils/ast/index.ts'\nimport type { ChildNode, Element } from 'domhandler'\n\nconst RE_MAX_WIDTH = /(?:^|;\\s*)max-width:\\s*([^;]+)/i\nconst RE_WIDTH = /(?:^|;\\s*)width:\\s*([^;]+)/i\nconst RE_PERCENT = /^[\\d.]+%$/\nconst PADDING_DECL_RE = /(?:^|;)\\s*(padding(?:-[a-z-]+)?\\s*:\\s*[^;]+)/gi\n\nfunction resolveWidth(value: string): string | null {\n const trimmed = value.trim()\n if (RE_PERCENT.test(trimmed)) return trimmed\n const m = trimmed.match(/^([\\d.]+)(px|rem|em|pt)?$/i)\n if (!m) return null\n const n = parseFloat(m[1])\n switch ((m[2] || 'px').toLowerCase()) {\n case 'px': return `${Math.round(n)}px`\n case 'rem':\n case 'em': return `${Math.round(n * 16)}px`\n case 'pt': return `${Math.round(n * 1.333)}px`\n default: return null\n }\n}\n\n/**\n * Resolve all `__MAIZZLE_MSO*__` placeholders inside MSO conditional comments\n * by reading inlined style + `data-*` markers on the paired elements.\n *\n * Two placeholder families:\n *\n * MSOW (`__MAIZZLE_MSOW_{id}__`) — emitted by `<Container>` and `<Section>`.\n * Source element is marked with `data-maizzle-msow-id`. Reads inlined\n * `max-width:` (falls back to `width:`) and normalizes to px. Falls\n * back to `data-maizzle-msow-fallback` (default `600px`) when the\n * value can't be parsed.\n *\n * MSOTDSTYLE (`__MAIZZLE_MSOTDSTYLE_{id}__`) — emitted by `<Container>`'s\n * MSO `<td>`. Source element is marked with `data-maizzle-mso-td-id`.\n * Copies every `padding*` declaration from inlined style and appends\n * the `data-maizzle-mso-style` value (the user's `msoStyle` prop).\n * Empty input resolves to '' so the placeholder collapses cleanly.\n *\n * Single collect-walk + single substitute-walk: the same Container div\n * carries both marker kinds, so one element visit fills both maps.\n */\nexport function msoPlaceholders(dom: ChildNode[]): ChildNode[] {\n const widths = new Map<string, string>()\n const tdStyles = new Map<string, string>()\n\n walk(dom, (node) => {\n const el = node as Element\n const a = el.attribs\n if (!a) return\n\n const msowId = a['data-maizzle-msow-id']\n const tdId = a['data-maizzle-mso-td-id']\n if (!msowId && !tdId) return\n\n const style = a.style ?? ''\n\n if (msowId) {\n delete a['data-maizzle-msow-id']\n const fallback = a['data-maizzle-msow-fallback'] ?? '600px'\n delete a['data-maizzle-msow-fallback']\n const raw = style.match(RE_MAX_WIDTH)?.[1] ?? style.match(RE_WIDTH)?.[1]\n const resolved = raw ? resolveWidth(raw) : null\n widths.set(msowId, resolved ?? fallback)\n }\n\n if (tdId) {\n delete a['data-maizzle-mso-td-id']\n const msoStyle = (a['data-maizzle-mso-style'] ?? '').trim().replace(/;\\s*$/, '')\n delete a['data-maizzle-mso-style']\n\n const parts: string[] = []\n if (style) {\n for (const m of style.matchAll(PADDING_DECL_RE)) {\n parts.push(m[1].trim())\n }\n }\n if (msoStyle) parts.push(msoStyle)\n\n tdStyles.set(tdId, parts.length ? ` style=\"${parts.join('; ')}\"` : '')\n }\n })\n\n if (widths.size === 0 && tdStyles.size === 0) return dom\n\n walk(dom, (node) => {\n if (node.type !== 'comment') return\n let data = (node as any).data as string\n if (!data) return\n const hasMsow = widths.size > 0 && data.includes('__MAIZZLE_MSOW_')\n const hasTd = tdStyles.size > 0 && data.includes('__MAIZZLE_MSOTDSTYLE_')\n if (!hasMsow && !hasTd) return\n\n if (hasMsow) {\n for (const [id, val] of widths) {\n data = data.replaceAll(`__MAIZZLE_MSOW_${id}__`, val)\n }\n }\n if (hasTd) {\n for (const [id, val] of tdStyles) {\n data = data.replaceAll(`__MAIZZLE_MSOTDSTYLE_${id}__`, val)\n }\n }\n ;(node as any).data = data\n })\n\n return dom\n}\n"],"mappings":";;;AAGA,MAAM,eAAe;AACrB,MAAM,WAAW;AACjB,MAAM,aAAa;AACnB,MAAM,kBAAkB;AAExB,SAAS,aAAa,OAA8B;CAClD,MAAM,UAAU,MAAM,MAAM;CAC5B,IAAI,WAAW,KAAK,QAAQ,EAAE,OAAO;CACrC,MAAM,IAAI,QAAQ,MAAM,6BAA6B;CACrD,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,IAAI,WAAW,EAAE,GAAG;CAC1B,SAAS,EAAE,MAAM,MAAM,aAAa,EAApC;EACE,KAAK,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;EACnC,KAAK;EACL,KAAK,MAAM,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,CAAC;EACxC,KAAK,MAAM,OAAO,GAAG,KAAK,MAAM,IAAI,MAAM,CAAC;EAC3C,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBpB,SAAgB,gBAAgB,KAA+B;CAC7D,MAAM,yBAAS,IAAI,KAAqB;CACxC,MAAM,2BAAW,IAAI,KAAqB;CAE1C,KAAK,MAAM,SAAS;EAElB,MAAM,IAAIA,KAAG;EACb,IAAI,CAAC,GAAG;EAER,MAAM,SAAS,EAAE;EACjB,MAAM,OAAO,EAAE;EACf,IAAI,CAAC,UAAU,CAAC,MAAM;EAEtB,MAAM,QAAQ,EAAE,SAAS;EAEzB,IAAI,QAAQ;GACV,OAAO,EAAE;GACT,MAAM,WAAW,EAAE,iCAAiC;GACpD,OAAO,EAAE;GACT,MAAM,MAAM,MAAM,MAAM,aAAa,GAAG,MAAM,MAAM,MAAM,SAAS,GAAG;GACtE,MAAM,WAAW,MAAM,aAAa,IAAI,GAAG;GAC3C,OAAO,IAAI,QAAQ,YAAY,SAAS;;EAG1C,IAAI,MAAM;GACR,OAAO,EAAE;GACT,MAAM,YAAY,EAAE,6BAA6B,IAAI,MAAM,CAAC,QAAQ,SAAS,GAAG;GAChF,OAAO,EAAE;GAET,MAAM,QAAkB,EAAE;GAC1B,IAAI,OACF,KAAK,MAAM,KAAK,MAAM,SAAS,gBAAgB,EAC7C,MAAM,KAAK,EAAE,GAAG,MAAM,CAAC;GAG3B,IAAI,UAAU,MAAM,KAAK,SAAS;GAElC,SAAS,IAAI,MAAM,MAAM,SAAS,WAAW,MAAM,KAAK,KAAK,CAAC,KAAK,GAAG;;GAExE;CAEF,IAAI,OAAO,SAAS,KAAK,SAAS,SAAS,GAAG,OAAO;CAErD,KAAK,MAAM,SAAS;EAClB,IAAI,KAAK,SAAS,WAAW;EAC7B,IAAI,OAAQ,KAAa;EACzB,IAAI,CAAC,MAAM;EACX,MAAM,UAAU,OAAO,OAAO,KAAK,KAAK,SAAS,kBAAkB;EACnE,MAAM,QAAQ,SAAS,OAAO,KAAK,KAAK,SAAS,wBAAwB;EACzE,IAAI,CAAC,WAAW,CAAC,OAAO;EAExB,IAAI,SACF,KAAK,MAAM,CAAC,IAAI,QAAQ,QACtB,OAAO,KAAK,WAAW,kBAAkB,GAAG,KAAK,IAAI;EAGzD,IAAI,OACF,KAAK,MAAM,CAAC,IAAI,QAAQ,UACtB,OAAO,KAAK,WAAW,wBAAwB,GAAG,KAAK,IAAI;EAG9D,KAAc,OAAO;GACtB;CAEF,OAAO"}
@@ -0,0 +1,43 @@
1
+ import { ChildNode } from "domhandler";
2
+ import { Opts } from "email-comb";
3
+
4
+ //#region src/transformers/purgeCss.d.ts
5
+ /**
6
+ * Options for the `purgeCss` transformer.
7
+ */
8
+ interface PurgeCssOptions extends Partial<Omit<Opts, 'whitelist'>> {
9
+ /**
10
+ * Selectors to preserve regardless of whether they're matched in the
11
+ * markup. Appended to Maizzle's built-in safelist (Gmail, Apple Mail,
12
+ * Outlook.com hooks, etc). Mapped to email-comb's `whitelist` option.
13
+ */
14
+ safelist?: string[];
15
+ }
16
+ /**
17
+ * Remove unused CSS from an HTML string.
18
+ *
19
+ * Uses `email-comb` together with a DOM-aware deep-purge step to strip
20
+ * CSS selectors and class/id references that are not matched anywhere
21
+ * in the document body.
22
+ *
23
+ * @param html HTML string to transform.
24
+ * @param options Email-comb options plus a Maizzle `safelist`.
25
+ * @returns The transformed HTML string.
26
+ *
27
+ * @example
28
+ * import { purgeCss } from '@maizzle/framework'
29
+ *
30
+ * const out = purgeCss('<style>.a{}.b{}</style><p class="a">x</p>', {
31
+ * safelist: ['.keep'],
32
+ * })
33
+ */
34
+ declare function purgeCss(html: string, options?: PurgeCssOptions): string;
35
+ /**
36
+ * DOM-form of {@link purgeCss} used by the internal transformer
37
+ * pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant
38
+ * serialize/parse round-trips when chained with other transformers.
39
+ */
40
+ declare function purgeCssDom(dom: ChildNode[], options?: PurgeCssOptions): ChildNode[];
41
+ //#endregion
42
+ export { PurgeCssOptions, purgeCss, purgeCssDom };
43
+ //# sourceMappingURL=purgeCss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purgeCss.d.ts","names":[],"sources":["../../src/transformers/purgeCss.ts"],"mappings":";;;;;;AAqCA;UAAiB,eAAA,SAAwB,OAAA,CAAQ,IAAA,CAAK,IAAA;;;;;;EAMpD,QAAA;AAAA;;;;;;AAqBF;;;;;;;;;AASA;;;;iBATgB,QAAA,CAAS,IAAA,UAAc,OAAA,GAAS,eAAA;;;;;;iBAShC,WAAA,CAAY,GAAA,EAAK,SAAA,IAAa,OAAA,GAAS,eAAA,GAAuB,SAAA"}
@@ -1,13 +1,12 @@
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";
5
- import { defu } from "defu";
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
+ import { defu as defu$1 } from "defu";
6
6
  import safeParser from "postcss-safe-parser";
7
7
  import { selectAll } from "css-select";
8
8
  import { comb } from "email-comb";
9
-
10
- //#region src/transformers/purgeCSS.ts
9
+ //#region src/transformers/purgeCss.ts
11
10
  const DEFAULT_SAFELIST = [
12
11
  "*body*",
13
12
  ".gmail*",
@@ -36,27 +35,35 @@ const DEFAULT_OPTIONS = {
36
35
  whitelist: [...DEFAULT_SAFELIST]
37
36
  };
38
37
  /**
39
- * Remove unused CSS transformer.
38
+ * Remove unused CSS from an HTML string.
39
+ *
40
+ * Uses `email-comb` together with a DOM-aware deep-purge step to strip
41
+ * CSS selectors and class/id references that are not matched anywhere
42
+ * in the document body.
40
43
  *
41
- * Uses `email-comb` to strip CSS selectors and corresponding class/id
42
- * references that are not matched anywhere in the HTML body.
44
+ * @param html HTML string to transform.
45
+ * @param options Email-comb options plus a Maizzle `safelist`.
46
+ * @returns The transformed HTML string.
43
47
  *
44
- * Enable by setting `css.purge: true` (or passing options).
45
- * The user-supplied options are merged on top of the defaults, so
46
- * `safelist` values are **appended** to the built-in safelist rather
47
- * than replacing it.
48
+ * @example
49
+ * import { purgeCss } from '@maizzle/framework'
48
50
  *
49
- * Accepts `ChildNode[]` as input, serializes internally before passing
50
- * to email-comb (which requires a raw HTML string), then parses the
51
- * result back to `ChildNode[]` so it fits in the DOM pipeline.
51
+ * const out = purgeCss('<style>.a{}.b{}</style><p class="a">x</p>', {
52
+ * safelist: ['.keep'],
53
+ * })
52
54
  */
53
- function purgeCSS(dom, config = {}) {
54
- const option = config.purge;
55
- if (!option) return dom;
56
- const userOptions = typeof option === "object" ? option : {};
57
- const userSafelist = Array.isArray(userOptions.safelist) ? userOptions.safelist : [];
58
- const { safelist: _discard, ...restUserOptions } = userOptions;
59
- const options = defu({
55
+ function purgeCss(html, options = {}) {
56
+ return serialize(purgeCssDom(parse(html), options));
57
+ }
58
+ /**
59
+ * DOM-form of {@link purgeCss} used by the internal transformer
60
+ * pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant
61
+ * serialize/parse round-trips when chained with other transformers.
62
+ */
63
+ function purgeCssDom(dom, options = {}) {
64
+ const userSafelist = Array.isArray(options.safelist) ? options.safelist : [];
65
+ const { safelist: _discard, ...restUserOptions } = options;
66
+ const combOptions = defu$1({
60
67
  ...restUserOptions,
61
68
  whitelist: [...DEFAULT_SAFELIST, ...userSafelist]
62
69
  }, DEFAULT_OPTIONS);
@@ -89,8 +96,8 @@ function purgeCSS(dom, config = {}) {
89
96
  });
90
97
  textNode.data = `${token}{}`;
91
98
  });
92
- if (extraWhitelist.length) options.whitelist = [...options.whitelist ?? [], ...extraWhitelist];
93
- const { result } = comb(serialize(dom), options);
99
+ if (extraWhitelist.length) combOptions.whitelist = [...combOptions.whitelist ?? [], ...extraWhitelist];
100
+ const { result } = comb(serialize(dom), combOptions);
94
101
  /**
95
102
  * Comb returns a fresh string, so we work off the post-parse tree:
96
103
  * find each embed style tag whose body still starts with the stub
@@ -168,7 +175,7 @@ function deepPurge(dom, safelist) {
168
175
  });
169
176
  return dom;
170
177
  }
171
-
172
178
  //#endregion
173
- export { purgeCSS };
174
- //# sourceMappingURL=purgeCSS.mjs.map
179
+ export { purgeCss, purgeCssDom };
180
+
181
+ //# sourceMappingURL=purgeCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purgeCss.js","names":["merge"],"sources":["../../src/transformers/purgeCss.ts"],"sourcesContent":["import { comb } from 'email-comb'\nimport { defu as merge } from 'defu'\nimport safeParser from 'postcss-safe-parser'\nimport { selectAll } from 'css-select'\nimport type { ChildNode, Element } from 'domhandler'\nimport type { Opts as CombOptions } from 'email-comb'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\n\nconst DEFAULT_SAFELIST: string[] = [\n '*body*', // Gmail\n '.gmail*', // Gmail\n '.apple*', // Apple Mail\n '.ios*', // Mail on iOS\n '.ox-*', // Open-Xchange\n '.outlook*', // Outlook.com\n '[data-ogs*', // Outlook.com\n '.bloop_container', // Airmail\n '.Singleton', // Apple Mail 10\n '.unused', // Notes 8\n '.moz-text-html', // Thunderbird\n '.mail-detail-content', // Comcast, Libero webmail\n '*edo*', // Edison (all)\n '#*', // Freenet uses #msgBody\n '.lang*', // Fenced code blocks\n]\n\nconst DEFAULT_OPTIONS = {\n backend: [\n { heads: '{{', tails: '}}' },\n { heads: '{%', tails: '%}' },\n ],\n whitelist: [...DEFAULT_SAFELIST],\n}\n\n/**\n * Options for the `purgeCss` transformer.\n */\nexport interface PurgeCssOptions extends Partial<Omit<CombOptions, 'whitelist'>> {\n /**\n * Selectors to preserve regardless of whether they're matched in the\n * markup. Appended to Maizzle's built-in safelist (Gmail, Apple Mail,\n * Outlook.com hooks, etc). Mapped to email-comb's `whitelist` option.\n */\n safelist?: string[]\n}\n\n/**\n * Remove unused CSS from an HTML string.\n *\n * Uses `email-comb` together with a DOM-aware deep-purge step to strip\n * CSS selectors and class/id references that are not matched anywhere\n * in the document body.\n *\n * @param html HTML string to transform.\n * @param options Email-comb options plus a Maizzle `safelist`.\n * @returns The transformed HTML string.\n *\n * @example\n * import { purgeCss } from '@maizzle/framework'\n *\n * const out = purgeCss('<style>.a{}.b{}</style><p class=\"a\">x</p>', {\n * safelist: ['.keep'],\n * })\n */\nexport function purgeCss(html: string, options: PurgeCssOptions = {}): string {\n return serialize(purgeCssDom(parse(html), options))\n}\n\n/**\n * DOM-form of {@link purgeCss} used by the internal transformer\n * pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport function purgeCssDom(dom: ChildNode[], options: PurgeCssOptions = {}): ChildNode[] {\n const userSafelist = Array.isArray(options.safelist) ? options.safelist : []\n\n const { safelist: _discard, ...restUserOptions } = options\n\n // Merge user options on top of defaults.\n // defu merges objects deeply; for arrays it appends user values.\n // We want the user safelist appended to the default safelist,\n // so we build whitelist manually.\n const combOptions = merge(\n { ...restUserOptions, whitelist: [...DEFAULT_SAFELIST, ...userSafelist] },\n DEFAULT_OPTIONS,\n )\n\n // Deep purge first: DOM-aware selector removal using PostCSS + css-select.\n // Runs before email-comb so that email-comb can clean up orphaned classes\n // in HTML attributes left behind by removed CSS rules.\n const safelist = [...DEFAULT_SAFELIST, ...userSafelist]\n dom = deepPurge(dom, safelist)\n\n /**\n * Shield embed style tags from email-comb. Comb has no skip option,\n * so it strips CSS comments and drops class refs it can't match\n * against visible CSS. Swap each embed tag's body for a unique\n * stub rule (`.maizzle-keep-N{}`) so comb keeps the tag, then\n * whitelist that stub plus every selector from the original\n * CSS so comb leaves matching refs alone elsewhere — and\n * finally restore the original CSS once comb has run.\n */\n const stash: { token: string; original: string; textNode: any }[] = []\n const extraWhitelist: string[] = []\n walk(dom, (node) => {\n const el = node as Element\n if (el.name !== 'style' || !el.attribs) return\n if (!('embed' in el.attribs) && !('data-embed' in el.attribs)) return\n const textNode = el.children?.find((c: any) => c.type === 'text') as any\n if (!textNode?.data) return\n const idx = stash.length\n const token = `.maizzle-keep-${idx}`\n extraWhitelist.push(token)\n for (const m of textNode.data.matchAll(/(?<![\\w-])[.#][a-zA-Z_][\\w-]*/g)) {\n extraWhitelist.push(m[0])\n }\n stash.push({ token, original: textNode.data, textNode })\n textNode.data = `${token}{}`\n })\n\n if (extraWhitelist.length) {\n combOptions.whitelist = [...(combOptions.whitelist as string[] ?? []), ...extraWhitelist]\n }\n\n const { result } = comb(serialize(dom), combOptions)\n\n /**\n * Comb returns a fresh string, so we work off the post-parse tree:\n * find each embed style tag whose body still starts with the stub\n * token we planted earlier and swap the original CSS back in.\n */\n let purgedDom = parse(result)\n\n if (stash.length) {\n walk(purgedDom, (node) => {\n const el = node as Element\n if (el.name !== 'style' || !el.attribs) return\n if (!('embed' in el.attribs) && !('data-embed' in el.attribs)) return\n const textNode = el.children?.find((c: any) => c.type === 'text') as any\n if (!textNode?.data) return\n const trimmed = textNode.data.trim()\n const match = stash.find(s => trimmed === `${s.token}{}` || trimmed.startsWith(`${s.token}{`))\n if (match) textNode.data = match.original\n })\n }\n\n // Clean up data-embed/embed attributes — no longer needed after purging\n walk(purgedDom, (node) => {\n const el = node as Element\n if (el.name === 'style' && el.attribs) {\n delete el.attribs['data-embed']\n delete el.attribs.embed\n }\n })\n\n return purgedDom\n}\n\n/**\n * Deep purge: uses PostCSS to parse CSS in non-embedded style tags,\n * then checks each selector against the DOM with css-select.\n * Removes rules where no selector matches any element.\n */\nfunction isSafelisted(selector: string, safelist: string[]): boolean {\n return safelist.some((pattern) => {\n if (pattern.startsWith('*') && pattern.endsWith('*')) {\n return selector.includes(pattern.slice(1, -1))\n }\n if (pattern.endsWith('*')) {\n return selector.startsWith(pattern.slice(0, -1))\n }\n if (pattern.startsWith('*')) {\n return selector.endsWith(pattern.slice(1))\n }\n return selector === pattern\n })\n}\n\nfunction deepPurge(dom: ChildNode[], safelist: string[]): ChildNode[] {\n walk(dom, (node) => {\n const el = node as Element\n\n if (el.name !== 'style' || !el.attribs) return\n if ('data-embed' in el.attribs || 'embed' in el.attribs) return\n\n const textNode = el.children?.find((c: any) => c.type === 'text') as any\n if (!textNode?.data?.trim()) return\n\n const root = safeParser(textNode.data)\n\n root.walkRules((rule) => {\n // Skip rules inside @media or other at-rules — those may target\n // states we can't match statically (hover, responsive, etc.)\n if (rule.parent?.type === 'atrule') return\n\n const selectors = rule.selectors ?? [rule.selector]\n const matched = selectors.filter((sel) => {\n // Keep safelisted selectors\n if (isSafelisted(sel, safelist)) return true\n\n // Skip pseudo-classes/elements that can't be matched statically.\n // Functional pseudos like :not(), :is(), :where(), :has() are\n // matchable by css-select, so we only skip dynamic/state ones.\n if (/::[\\w-]/.test(sel)) return true\n if (/(?<!:):(?!not\\b|is\\b|where\\b|has\\b)[\\w-]/.test(sel.replace(/\\\\./g, ''))) return true\n\n try {\n return selectAll(sel, dom).length > 0\n } catch {\n // If css-select can't parse the selector, keep it\n return true\n }\n })\n\n if (matched.length === 0) {\n rule.remove()\n } else if (matched.length < selectors.length) {\n rule.selectors = matched\n }\n })\n\n // Remove empty at-rules\n root.walkAtRules((atRule) => {\n if (atRule.nodes?.length === 0) {\n atRule.remove()\n }\n })\n\n const purgedCss = root.toString()\n\n if (purgedCss.trim()) {\n textNode.data = purgedCss\n } else {\n // Remove the style tag entirely if empty\n const parent = el.parent\n if (parent && 'children' in parent) {\n const idx = parent.children.indexOf(el as any)\n if (idx !== -1) parent.children.splice(idx, 1)\n }\n }\n })\n\n return dom\n}\n"],"mappings":"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"}
@@ -1,31 +1,54 @@
1
- import { AttributesConfig } from "../types/config.js";
2
1
  import { ChildNode } from "domhandler";
3
2
 
4
3
  //#region src/transformers/removeAttributes.d.ts
5
4
  /**
6
- * Remove attributes transformer.
5
+ * Single attribute-removal rule.
6
+ */
7
+ interface RemoveAttributeRule {
8
+ /** Attribute name to match. */
9
+ name: string;
10
+ /**
11
+ * Match condition for the attribute's value:
12
+ * - `string` — remove when the value matches exactly.
13
+ * - `RegExp` — remove when the value matches the regex.
14
+ * - `boolean` / omitted — remove when the value is empty.
15
+ */
16
+ value?: string | RegExp | boolean;
17
+ }
18
+ /**
19
+ * Entry passed to {@link removeAttributes}. A bare string targets the named
20
+ * attribute and removes it when its value is empty.
21
+ */
22
+ type RemoveAttributeOption = string | RemoveAttributeRule;
23
+ /**
24
+ * Remove HTML attributes from elements.
7
25
  *
8
- * Removes specified HTML attributes from elements.
26
+ * Empty `style` and `class` attributes are always stripped, regardless of
27
+ * what you pass. Your entries are appended to those defaults.
9
28
  *
10
- * By default, removes empty `style` and `class` attributes.
29
+ * - `'data-src'` remove when the value is empty.
30
+ * - `{ name: 'id', value: 'test' }` — remove when the value matches exactly.
31
+ * - `{ name: 'data-id', value: /\d/ }` — remove when the value matches the regex.
11
32
  *
12
- * Supports:
13
- * - String: removes attribute when empty (boolean or empty string)
14
- * - Object with name and value: removes when attribute matches exactly
15
- * - Object with name and RegExp value: removes when attribute value matches regex
33
+ * @param html HTML string to transform.
34
+ * @param attributes Additional attribute-removal rules to apply on top of the defaults.
35
+ * @returns The transformed HTML string.
16
36
  *
17
- * Configured via `remove` array:
18
- * ```js
19
- * {
20
- * remove: [
21
- * 'data-src', // Remove empty data-src attributes
22
- * { name: 'id', value: 'test' }, // Remove id="test" exactly
23
- * { name: 'data-id', value: /\d/ } // Remove data-id when value contains digits
24
- * ]
25
- * }
26
- * ```
37
+ * @example
38
+ * import { removeAttributes } from '@maizzle/framework'
39
+ *
40
+ * const out = removeAttributes('<p style="" data-x="">x</p>', [
41
+ * 'data-x',
42
+ * { name: 'role', value: 'none' },
43
+ * ])
44
+ */
45
+ declare function removeAttributes(html: string, attributes?: RemoveAttributeOption[]): string;
46
+ /**
47
+ * DOM-form of {@link removeAttributes} used by the internal transformer
48
+ * pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant
49
+ * serialize/parse round-trips when chained with other transformers.
27
50
  */
28
- declare function removeAttributes(dom: ChildNode[], config?: AttributesConfig): ChildNode[];
51
+ declare function removeAttributesDom(dom: ChildNode[], attributes?: RemoveAttributeOption[]): ChildNode[];
29
52
  //#endregion
30
- export { removeAttributes };
53
+ export { RemoveAttributeOption, RemoveAttributeRule, removeAttributes, removeAttributesDom };
31
54
  //# sourceMappingURL=removeAttributes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"removeAttributes.d.ts","names":[],"sources":["../../src/transformers/removeAttributes.ts"],"mappings":";;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;iBAAgB,gBAAA,CAAiB,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,gBAAA,GAAwB,SAAA"}
1
+ {"version":3,"file":"removeAttributes.d.ts","names":[],"sources":["../../src/transformers/removeAttributes.ts"],"mappings":";;;;;AAMA;UAAiB,mBAAA;;EAEf,IAAA;EAAA;;;;;AAcF;EAPE,KAAA,YAAiB,MAAA;AAAA;;;AA+BnB;;KAxBY,qBAAA,YAAiC,mBAAA;;;;;;;AAiC7C;;;;;;;;;;;;;;;;iBATgB,gBAAA,CAAiB,IAAA,UAAc,UAAA,GAAY,qBAAA;;;;;;iBAS3C,mBAAA,CAAoB,GAAA,EAAK,SAAA,IAAa,UAAA,GAAY,qBAAA,KAA+B,SAAA"}