@maizzle/framework 6.0.0-rc.21 → 6.0.0-rc.23

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 (242) hide show
  1. package/dist/build.d.ts.map +1 -1
  2. package/dist/build.js +11 -0
  3. package/dist/build.js.map +1 -1
  4. package/dist/components/Body.vue +1 -1
  5. package/dist/components/CodeBlock.vue +1 -1
  6. package/dist/components/CodeInline.vue +72 -2
  7. package/dist/components/Column.vue +2 -1
  8. package/dist/components/Container.vue +1 -11
  9. package/dist/components/Heading.vue +1 -1
  10. package/dist/components/Img.vue +252 -7
  11. package/dist/components/Link.vue +1 -1
  12. package/dist/components/Preheader.vue +35 -5
  13. package/dist/components/Section.vue +9 -14
  14. package/dist/components/Tailwind.vue +4 -2
  15. package/dist/components/Text.vue +2 -2
  16. package/dist/components/Vml.vue +354 -0
  17. package/dist/components/utils.d.ts.map +1 -1
  18. package/dist/components/utils.js.map +1 -1
  19. package/dist/composables/defineConfig.d.ts +3 -4
  20. package/dist/composables/defineConfig.d.ts.map +1 -1
  21. package/dist/composables/defineConfig.js +3 -4
  22. package/dist/composables/defineConfig.js.map +1 -1
  23. package/dist/composables/renderContext.d.ts +0 -1
  24. package/dist/composables/renderContext.d.ts.map +1 -1
  25. package/dist/composables/renderContext.js.map +1 -1
  26. package/dist/composables/useBaseUrl.d.ts.map +1 -1
  27. package/dist/composables/useBaseUrl.js.map +1 -1
  28. package/dist/composables/useConfig.d.ts.map +1 -1
  29. package/dist/composables/useConfig.js.map +1 -1
  30. package/dist/composables/useCurrentTemplate.d.ts.map +1 -1
  31. package/dist/composables/useCurrentTemplate.js +10 -3
  32. package/dist/composables/useCurrentTemplate.js.map +1 -1
  33. package/dist/composables/useDoctype.d.ts.map +1 -1
  34. package/dist/composables/useDoctype.js.map +1 -1
  35. package/dist/composables/useEvent.js.map +1 -1
  36. package/dist/composables/useFont.d.ts.map +1 -1
  37. package/dist/composables/useFont.js.map +1 -1
  38. package/dist/composables/useOutlookFallback.d.ts.map +1 -1
  39. package/dist/composables/useOutlookFallback.js.map +1 -1
  40. package/dist/composables/usePlaintext.d.ts.map +1 -1
  41. package/dist/composables/usePlaintext.js.map +1 -1
  42. package/dist/composables/usePreheader.d.ts +6 -5
  43. package/dist/composables/usePreheader.d.ts.map +1 -1
  44. package/dist/composables/usePreheader.js +3 -3
  45. package/dist/composables/usePreheader.js.map +1 -1
  46. package/dist/composables/useTransformers.d.ts +1 -1
  47. package/dist/composables/useTransformers.d.ts.map +1 -1
  48. package/dist/composables/useTransformers.js +1 -1
  49. package/dist/composables/useTransformers.js.map +1 -1
  50. package/dist/composables/useUrlQuery.d.ts.map +1 -1
  51. package/dist/composables/useUrlQuery.js.map +1 -1
  52. package/dist/config/defaults.d.ts.map +1 -1
  53. package/dist/config/defaults.js.map +1 -1
  54. package/dist/config/index.js +12 -0
  55. package/dist/config/index.js.map +1 -1
  56. package/dist/events/index.d.ts +5 -0
  57. package/dist/events/index.d.ts.map +1 -1
  58. package/dist/events/index.js +5 -0
  59. package/dist/events/index.js.map +1 -1
  60. package/dist/index.d.ts +2 -2
  61. package/dist/index.js +2 -2
  62. package/dist/plaintext.d.ts.map +1 -1
  63. package/dist/plaintext.js.map +1 -1
  64. package/dist/plugin.js.map +1 -1
  65. package/dist/plugins/postcss/mergeMediaQueries.d.ts.map +1 -1
  66. package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -1
  67. package/dist/plugins/postcss/pruneVars.d.ts.map +1 -1
  68. package/dist/plugins/postcss/pruneVars.js.map +1 -1
  69. package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -1
  70. package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -1
  71. package/dist/plugins/postcss/removeDeclarations.d.ts.map +1 -1
  72. package/dist/plugins/postcss/removeDeclarations.js.map +1 -1
  73. package/dist/plugins/postcss/resolveMaizzleImports.d.ts.map +1 -1
  74. package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -1
  75. package/dist/plugins/postcss/resolveProps.d.ts.map +1 -1
  76. package/dist/plugins/postcss/resolveProps.js +14 -0
  77. package/dist/plugins/postcss/resolveProps.js.map +1 -1
  78. package/dist/plugins/postcss/tailwindCleanup.d.ts.map +1 -1
  79. package/dist/plugins/postcss/tailwindCleanup.js.map +1 -1
  80. package/dist/prepare.d.ts.map +1 -1
  81. package/dist/prepare.js.map +1 -1
  82. package/dist/render/active.d.ts.map +1 -1
  83. package/dist/render/active.js.map +1 -1
  84. package/dist/render/createRenderer.d.ts.map +1 -1
  85. package/dist/render/createRenderer.js +91 -3
  86. package/dist/render/createRenderer.js.map +1 -1
  87. package/dist/render/index.d.ts.map +1 -1
  88. package/dist/render/index.js +6 -0
  89. package/dist/render/index.js.map +1 -1
  90. package/dist/render/injectFonts.js.map +1 -1
  91. package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -1
  92. package/dist/render/plugins/codeBlockExtract.js +4 -0
  93. package/dist/render/plugins/codeBlockExtract.js.map +1 -1
  94. package/dist/render/plugins/markdownExtract.d.ts.map +1 -1
  95. package/dist/render/plugins/markdownExtract.js.map +1 -1
  96. package/dist/render/plugins/rawExtract.d.ts.map +1 -1
  97. package/dist/render/plugins/rawExtract.js.map +1 -1
  98. package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -1
  99. package/dist/render/plugins/rowSourceLocation.js.map +1 -1
  100. package/dist/serve.d.ts.map +1 -1
  101. package/dist/serve.js +48 -15
  102. package/dist/serve.js.map +1 -1
  103. package/dist/server/compatibility.d.ts.map +1 -1
  104. package/dist/server/compatibility.js +48 -0
  105. package/dist/server/compatibility.js.map +1 -1
  106. package/dist/server/email.js.map +1 -1
  107. package/dist/server/linter.js +6 -0
  108. package/dist/server/linter.js.map +1 -1
  109. package/dist/server/sfc-utils.d.ts.map +1 -1
  110. package/dist/server/sfc-utils.js.map +1 -1
  111. package/dist/server/ui/App.vue +17 -16
  112. package/dist/server/ui/components/Markdown.vue +17 -0
  113. package/dist/server/ui/components/SidebarClose.vue +1 -1
  114. package/dist/server/ui/components/ui/checkbox/Checkbox.vue +1 -1
  115. package/dist/server/ui/components/ui/command/CommandInput.vue +2 -2
  116. package/dist/server/ui/components/ui/dialog/DialogContent.vue +1 -1
  117. package/dist/server/ui/components/ui/dialog/DialogScrollContent.vue +1 -1
  118. package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
  119. package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +1 -1
  120. package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  121. package/dist/server/ui/components/ui/sheet/SheetContent.vue +1 -1
  122. package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +1 -1
  123. package/dist/server/ui/components/ui/tags-input/TagsInputItemDelete.vue +1 -1
  124. package/dist/server/ui/lib/emulated-dark-mode.ts +25 -10
  125. package/dist/server/ui/pages/Home.vue +1 -1
  126. package/dist/server/ui/pages/Preview.vue +32 -18
  127. package/dist/tests/render/_helpers.js.map +1 -1
  128. package/dist/transformers/addAttributes.d.ts +18 -8
  129. package/dist/transformers/addAttributes.d.ts.map +1 -1
  130. package/dist/transformers/addAttributes.js +22 -8
  131. package/dist/transformers/addAttributes.js.map +1 -1
  132. package/dist/transformers/attributeToStyle.d.ts.map +1 -1
  133. package/dist/transformers/attributeToStyle.js.map +1 -1
  134. package/dist/transformers/base.d.ts.map +1 -1
  135. package/dist/transformers/base.js +4 -0
  136. package/dist/transformers/base.js.map +1 -1
  137. package/dist/transformers/columnWidth.d.ts.map +1 -1
  138. package/dist/transformers/columnWidth.js +136 -150
  139. package/dist/transformers/columnWidth.js.map +1 -1
  140. package/dist/transformers/entities.d.ts.map +1 -1
  141. package/dist/transformers/entities.js +1 -0
  142. package/dist/transformers/entities.js.map +1 -1
  143. package/dist/transformers/filters/defaults.d.ts.map +1 -1
  144. package/dist/transformers/filters/defaults.js.map +1 -1
  145. package/dist/transformers/filters/index.d.ts.map +1 -1
  146. package/dist/transformers/filters/index.js.map +1 -1
  147. package/dist/transformers/format.d.ts.map +1 -1
  148. package/dist/transformers/format.js.map +1 -1
  149. package/dist/transformers/index.d.ts.map +1 -1
  150. package/dist/transformers/index.js +33 -5
  151. package/dist/transformers/index.js.map +1 -1
  152. package/dist/transformers/inlineCss.d.ts.map +1 -1
  153. package/dist/transformers/inlineCss.js +27 -9
  154. package/dist/transformers/inlineCss.js.map +1 -1
  155. package/dist/transformers/inlineLink.d.ts.map +1 -1
  156. package/dist/transformers/inlineLink.js.map +1 -1
  157. package/dist/transformers/minify.d.ts.map +1 -1
  158. package/dist/transformers/minify.js.map +1 -1
  159. package/dist/transformers/minifyCodeInline.d.ts +29 -0
  160. package/dist/transformers/minifyCodeInline.d.ts.map +1 -0
  161. package/dist/transformers/minifyCodeInline.js +36 -0
  162. package/dist/transformers/minifyCodeInline.js.map +1 -0
  163. package/dist/transformers/msoPlaceholders.d.ts +10 -5
  164. package/dist/transformers/msoPlaceholders.d.ts.map +1 -1
  165. package/dist/transformers/msoPlaceholders.js +38 -7
  166. package/dist/transformers/msoPlaceholders.js.map +1 -1
  167. package/dist/transformers/purgeCss.d.ts.map +1 -1
  168. package/dist/transformers/purgeCss.js +29 -3
  169. package/dist/transformers/purgeCss.js.map +1 -1
  170. package/dist/transformers/removeAttributes.d.ts.map +1 -1
  171. package/dist/transformers/removeAttributes.js.map +1 -1
  172. package/dist/transformers/replaceStrings.d.ts.map +1 -1
  173. package/dist/transformers/replaceStrings.js.map +1 -1
  174. package/dist/transformers/safeSelectors.d.ts +37 -0
  175. package/dist/transformers/safeSelectors.d.ts.map +1 -0
  176. package/dist/transformers/{safeClassNames.js → safeSelectors.js} +37 -6
  177. package/dist/transformers/safeSelectors.js.map +1 -0
  178. package/dist/transformers/shorthandCss.d.ts.map +1 -1
  179. package/dist/transformers/shorthandCss.js +38 -7
  180. package/dist/transformers/shorthandCss.js.map +1 -1
  181. package/dist/transformers/sixHex.d.ts.map +1 -1
  182. package/dist/transformers/sixHex.js.map +1 -1
  183. package/dist/transformers/tailwindComponent.js +9 -0
  184. package/dist/transformers/tailwindComponent.js.map +1 -1
  185. package/dist/transformers/tailwindcss.d.ts.map +1 -1
  186. package/dist/transformers/tailwindcss.js +22 -0
  187. package/dist/transformers/tailwindcss.js.map +1 -1
  188. package/dist/transformers/urlQuery.d.ts.map +1 -1
  189. package/dist/transformers/urlQuery.js.map +1 -1
  190. package/dist/types/config.d.ts +6 -10
  191. package/dist/types/config.d.ts.map +1 -1
  192. package/dist/types/index.d.ts +1 -1
  193. package/dist/utils/ast/parser.d.ts.map +1 -1
  194. package/dist/utils/ast/parser.js.map +1 -1
  195. package/dist/utils/ast/serializer.d.ts.map +1 -1
  196. package/dist/utils/ast/serializer.js +27 -17
  197. package/dist/utils/ast/serializer.js.map +1 -1
  198. package/dist/utils/ast/walker.d.ts.map +1 -1
  199. package/dist/utils/ast/walker.js.map +1 -1
  200. package/dist/utils/compileTailwindCss.d.ts.map +1 -1
  201. package/dist/utils/compileTailwindCss.js.map +1 -1
  202. package/dist/utils/componentSources.d.ts.map +1 -1
  203. package/dist/utils/componentSources.js.map +1 -1
  204. package/dist/utils/cssBox.d.ts +42 -0
  205. package/dist/utils/cssBox.d.ts.map +1 -0
  206. package/dist/utils/cssBox.js +156 -0
  207. package/dist/utils/cssBox.js.map +1 -0
  208. package/dist/utils/decodeStyleEntities.d.ts.map +1 -1
  209. package/dist/utils/decodeStyleEntities.js.map +1 -1
  210. package/dist/utils/detect.d.ts.map +1 -1
  211. package/dist/utils/detect.js.map +1 -1
  212. package/dist/utils/output-markers.d.ts.map +1 -1
  213. package/dist/utils/output-markers.js.map +1 -1
  214. package/dist/utils/url.d.ts.map +1 -1
  215. package/dist/utils/url.js.map +1 -1
  216. package/dist/utils/watchPaths.js.map +1 -1
  217. package/node_modules/@clack/core/CHANGELOG.md +6 -0
  218. package/node_modules/@clack/core/dist/index.d.mts +1 -1
  219. package/node_modules/@clack/core/dist/index.mjs +8 -8
  220. package/node_modules/@clack/core/dist/index.mjs.map +1 -1
  221. package/node_modules/@clack/core/package.json +1 -1
  222. package/node_modules/@clack/prompts/CHANGELOG.md +13 -0
  223. package/node_modules/@clack/prompts/README.md +2 -2
  224. package/node_modules/@clack/prompts/dist/index.d.mts +98 -0
  225. package/node_modules/@clack/prompts/dist/index.mjs +122 -121
  226. package/node_modules/@clack/prompts/dist/index.mjs.map +1 -1
  227. package/node_modules/@clack/prompts/package.json +2 -2
  228. package/node_modules/fast-wrap-ansi/lib/main.js +0 -1
  229. package/node_modules/fast-wrap-ansi/package.json +10 -10
  230. package/node_modules/maizzle/dist/commands/make/config.mjs +7 -6
  231. package/node_modules/maizzle/dist/commands/new.mjs +15 -84
  232. package/node_modules/maizzle/package.json +2 -2
  233. package/node_modules/tinyexec/README.md +8 -0
  234. package/node_modules/tinyexec/dist/main.d.mts +16 -1
  235. package/node_modules/tinyexec/dist/main.mjs +163 -457
  236. package/node_modules/tinyexec/package.json +12 -14
  237. package/package.json +3 -4
  238. package/dist/transformers/safeClassNames.d.ts +0 -22
  239. package/dist/transformers/safeClassNames.d.ts.map +0 -1
  240. package/dist/transformers/safeClassNames.js.map +0 -1
  241. package/node_modules/fast-wrap-ansi/lib/main.js.map +0 -1
  242. package/node_modules/tinyexec/dist/LICENSES.txt +0 -83
@@ -1,10 +1,10 @@
1
1
  import { walk } from "../utils/ast/walker.js";
2
2
  import "../utils/ast/index.js";
3
+ import { horizontalBorderPx, horizontalPaddingPx, lengthToPx } from "../utils/cssBox.js";
3
4
  import postcss from "postcss";
4
5
  import safeParser from "postcss-safe-parser";
5
6
  //#region src/transformers/columnWidth.ts
6
7
  const RE_PERCENT = /^[\d.]+%$/;
7
- const NO_BORDER_STYLES = new Set(["none", "hidden"]);
8
8
  /**
9
9
  * Stringify decls into a `; `-joined inline-style attribute. PostCSS raws
10
10
  * preserve the original source spacing, which mixes poorly with
@@ -55,18 +55,6 @@ function resolveLength(value) {
55
55
  default: return null;
56
56
  }
57
57
  }
58
- function lengthToPx(value) {
59
- const m = value.trim().match(/^([\d.]+)(px|rem|em|pt)?$/i);
60
- if (!m) return null;
61
- const n = parseFloat(m[1]);
62
- switch ((m[2] || "px").toLowerCase()) {
63
- case "px": return n;
64
- case "rem":
65
- case "em": return n * 16;
66
- case "pt": return n * 1.333;
67
- default: return null;
68
- }
69
- }
70
58
  function divideLength(value, divisor) {
71
59
  const m = value.match(/^([\d.]+)(px|%)$/);
72
60
  if (!m || divisor < 1) return null;
@@ -92,139 +80,6 @@ function minPxLength(a, b) {
92
80
  if (!am || !bm) return a;
93
81
  return parseFloat(am[1]) < parseFloat(bm[1]) ? a : b;
94
82
  }
95
- /**
96
- * Expand a 1-4 token CSS shorthand (T R B L) into a left/right pair:
97
- * 1: all sides
98
- * 2: TB RL
99
- * 3: T RL B
100
- * 4: T R B L
101
- */
102
- function shorthandSides(value) {
103
- const parts = value.trim().split(/\s+/);
104
- switch (parts.length) {
105
- case 1: return {
106
- left: parts[0],
107
- right: parts[0]
108
- };
109
- case 2:
110
- case 3: return {
111
- left: parts[1],
112
- right: parts[1]
113
- };
114
- case 4: return {
115
- left: parts[3],
116
- right: parts[1]
117
- };
118
- default: return {};
119
- }
120
- }
121
- /**
122
- * Read horizontal padding (left + right) px from a parsed style root.
123
- * Percentages are skipped — they'd need a known container width.
124
- */
125
- function horizontalPaddingPx(root) {
126
- let left = null;
127
- let right = null;
128
- root.walkDecls((d) => {
129
- switch (d.prop) {
130
- case "padding": {
131
- const { left: l, right: r } = shorthandSides(d.value);
132
- if (l) left = lengthToPx(l);
133
- if (r) right = lengthToPx(r);
134
- break;
135
- }
136
- case "padding-left":
137
- left = lengthToPx(d.value);
138
- break;
139
- case "padding-right":
140
- right = lengthToPx(d.value);
141
- break;
142
- }
143
- });
144
- return (left ?? 0) + (right ?? 0);
145
- }
146
- /**
147
- * Extract a px length from a CSS border shorthand (e.g. `1px solid red` → 1).
148
- * Returns null when the value indicates no border — `none` or `hidden`.
149
- * Defaults to 3px (CSS `medium`) when a visible style is set but
150
- * no explicit width token is present in the shorthand value.
151
- */
152
- function shorthandBorderWidthPx(value) {
153
- const tokens = value.trim().split(/\s+/);
154
- if (tokens.some((t) => NO_BORDER_STYLES.has(t.toLowerCase()))) return null;
155
- for (const t of tokens) {
156
- const px = lengthToPx(t);
157
- if (px != null) return px;
158
- }
159
- return 3;
160
- }
161
- /**
162
- * Read horizontal border widths (left + right) px from a parsed style root.
163
- * Per-side `border-style: none|hidden` overrides count as zero
164
- * contribution. Returns total px or 0 when nothing resolves.
165
- */
166
- function horizontalBorderPx(root) {
167
- let left = null;
168
- let right = null;
169
- let leftNone = false;
170
- let rightNone = false;
171
- root.walkDecls((d) => {
172
- switch (d.prop) {
173
- case "border": {
174
- const w = shorthandBorderWidthPx(d.value);
175
- if (w == null) leftNone = rightNone = true;
176
- else {
177
- left = right = w;
178
- leftNone = rightNone = false;
179
- }
180
- break;
181
- }
182
- case "border-width": {
183
- const { left: l, right: r } = shorthandSides(d.value);
184
- if (l) left = lengthToPx(l) ?? left;
185
- if (r) right = lengthToPx(r) ?? right;
186
- break;
187
- }
188
- case "border-style": {
189
- const { left: l, right: r } = shorthandSides(d.value);
190
- if (l && NO_BORDER_STYLES.has(l.toLowerCase())) leftNone = true;
191
- if (r && NO_BORDER_STYLES.has(r.toLowerCase())) rightNone = true;
192
- break;
193
- }
194
- case "border-left": {
195
- const w = shorthandBorderWidthPx(d.value);
196
- if (w == null) leftNone = true;
197
- else {
198
- left = w;
199
- leftNone = false;
200
- }
201
- break;
202
- }
203
- case "border-right": {
204
- const w = shorthandBorderWidthPx(d.value);
205
- if (w == null) rightNone = true;
206
- else {
207
- right = w;
208
- rightNone = false;
209
- }
210
- break;
211
- }
212
- case "border-left-width":
213
- left = lengthToPx(d.value) ?? left;
214
- break;
215
- case "border-right-width":
216
- right = lengthToPx(d.value) ?? right;
217
- break;
218
- case "border-left-style":
219
- if (NO_BORDER_STYLES.has(d.value.trim().toLowerCase())) leftNone = true;
220
- break;
221
- case "border-right-style":
222
- if (NO_BORDER_STYLES.has(d.value.trim().toLowerCase())) rightNone = true;
223
- break;
224
- }
225
- });
226
- return (leftNone ? 0 : left ?? 0) + (rightNone ? 0 : right ?? 0);
227
- }
228
83
  function depth(node) {
229
84
  let d = 0;
230
85
  let cur = node.parent;
@@ -359,7 +214,75 @@ function columnWidth(dom) {
359
214
  * last-wins and bloat the style — so we skip emitting it.
360
215
  */
361
216
  const userHasMaxWidth = /* @__PURE__ */ new Set();
217
+ /**
218
+ * Horizontal padding+border (px) of each column whose width was auto-
219
+ * derived from count-based math. The column's own border/padding eats
220
+ * its content box under content-box sizing, so the emitted `width:`
221
+ * must be the slice MINUS this inset; otherwise two bordered cols
222
+ * sum past the container and wrap. Only populated for auto paths
223
+ * — user-explicit `width:`/`min-width:`/`max-width:`-wins paths
224
+ * leave the value alone so the user's number stays the user's.
225
+ */
226
+ const autoColumnInsets = /* @__PURE__ */ new Map();
227
+ /**
228
+ * Extra inline-style decls that get stamped onto each column's MSO `<td>`
229
+ * via its COLTDX placeholder. Carries `background-color` (so Word
230
+ * paints the cell behind any padding area or whitespace, not just
231
+ * the div) and hoisted `padding*` decls (when no border is present
232
+ * — without one Word silently drops div padding, with one a td
233
+ * copy would double-pad). The div keeps both for modern clients
234
+ * since the MSO td is conditional-comment-only.
235
+ */
236
+ const tdExtras = /* @__PURE__ */ new Map();
237
+ /**
238
+ * MSO td width override for hoisted columns. With padding on the td and
239
+ * CSS content-box sizing for table cells, td_outer = width + 2*pad,
240
+ * so we set td width to the slot MINUS 2*horizontal-padding to keep
241
+ * the cell at its outer slot. Skipped when the slot is a %.
242
+ */
243
+ const hoistedTdWidths = /* @__PURE__ */ new Map();
362
244
  for (const { id, count } of columns) widthFallbacks.set(id, `${Math.round(100 / Math.max(count, 1))}%`);
245
+ const groupInfos = /* @__PURE__ */ new Map();
246
+ for (const c of columns) {
247
+ if (c.self) continue;
248
+ const ownRoot = parseElStyle(c.el);
249
+ const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot);
250
+ let cls = {
251
+ kind: "auto",
252
+ pxOuter: 0,
253
+ pctOuter: 0
254
+ };
255
+ const userVal = findUserMinWidth(ownRoot) ?? firstDeclValue(ownRoot, "width");
256
+ if (userVal) {
257
+ const resolved = resolveLength(userVal);
258
+ if (resolved?.endsWith("px")) {
259
+ const px = lengthToPx(resolved);
260
+ if (px != null) cls = {
261
+ kind: "explicit",
262
+ pxOuter: px + ownInset,
263
+ pctOuter: 0
264
+ };
265
+ } else if (resolved?.endsWith("%")) cls = {
266
+ kind: "explicit",
267
+ pxOuter: ownInset,
268
+ pctOuter: parseFloat(resolved)
269
+ };
270
+ }
271
+ const parent = c.el.parent;
272
+ if (!parent) continue;
273
+ let info = groupInfos.get(parent);
274
+ if (!info) {
275
+ info = {
276
+ explicitPxOuterSum: 0,
277
+ explicitPctOuterSum: 0,
278
+ autoCount: 0
279
+ };
280
+ groupInfos.set(parent, info);
281
+ }
282
+ info.explicitPxOuterSum += cls.pxOuter;
283
+ info.explicitPctOuterSum += cls.pctOuter;
284
+ if (cls.kind === "auto") info.autoCount++;
285
+ }
363
286
  for (const { el, id, count, self } of columns) {
364
287
  const ownRoot = parseElStyle(el);
365
288
  let sourceWidth = null;
@@ -401,7 +324,24 @@ function columnWidth(dom) {
401
324
  }
402
325
  }
403
326
  const adjusted = sourceWidth ? subtractInsetPx(sourceWidth, accumulatedInsetPx) : null;
404
- const countBased = adjusted ? divideLength(adjusted, count) : null;
327
+ let countBased = adjusted ? divideLength(adjusted, count) : null;
328
+ /**
329
+ * Sibling-aware redistribution kicks in only when the auto col has at
330
+ * least one explicit-width sibling and the source is in px (can't
331
+ * mix px subtraction with a % source). When that's true, the auto
332
+ * col's share becomes `(source − sum_explicit_px − pct% of source)
333
+ * / autoCount`, replacing the naive `source/totalCount`.
334
+ */
335
+ if (!self && adjusted?.endsWith("px") && countBased && el.parent) {
336
+ const group = groupInfos.get(el.parent);
337
+ if (group && group.autoCount > 0 && (group.explicitPxOuterSum > 0 || group.explicitPctOuterSum > 0)) {
338
+ const adjPx = lengthToPx(adjusted);
339
+ if (adjPx != null) {
340
+ const remaining = adjPx - group.explicitPxOuterSum - adjPx * group.explicitPctOuterSum / 100;
341
+ countBased = `${Math.max(0, Math.floor(remaining * 100 / group.autoCount) / 100)}px`;
342
+ }
343
+ }
344
+ }
405
345
  /**
406
346
  * Four user-override paths, decided by which CSS property the user
407
347
  * actually wrote:
@@ -456,12 +396,49 @@ function columnWidth(dom) {
456
396
  widthResolutions.set(id, cappedMin);
457
397
  el.attribs["data-maizzle-cw"] = cappedMin;
458
398
  userHasMaxWidth.add(id);
399
+ if (cappedMin === countBased) {
400
+ const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot);
401
+ if (ownInset > 0) autoColumnInsets.set(id, ownInset);
402
+ }
459
403
  continue;
460
404
  }
461
405
  }
462
406
  if (countBased) {
463
407
  widthResolutions.set(id, countBased);
464
408
  el.attribs["data-maizzle-cw"] = countBased;
409
+ const ownPaddingPx = horizontalPaddingPx(ownRoot);
410
+ const ownBorderPx = horizontalBorderPx(ownRoot);
411
+ const ownInset = ownPaddingPx + ownBorderPx;
412
+ if (ownInset > 0) autoColumnInsets.set(id, ownInset);
413
+ /**
414
+ * Build the MSO td's "extras" string — decls that need to live on
415
+ * the td in addition to width + vertical-align. Two contributors:
416
+ *
417
+ * - `background-color` (always, when present) — Word renders the
418
+ * div bg inside the cell, but anything outside the div (the
419
+ * td's padding area when hoisted, or any whitespace gap)
420
+ * would show the parent's bg instead of the column's. Painting
421
+ * the td matches the user's intent.
422
+ *
423
+ * - `padding*` (hoisted only when no horizontal border) — Word
424
+ * drops div padding without a stabilizing border, so the td
425
+ * has to carry it. With a border, Word renders div padding
426
+ * and a td copy would double-pad. Skip when the slot is `%`:
427
+ * td width math can't subtract px padding from a percentage.
428
+ */
429
+ const extras = [];
430
+ let bgColor;
431
+ ownRoot.walkDecls("background-color", (d) => {
432
+ bgColor = d.value;
433
+ });
434
+ if (bgColor) extras.push(`background-color: ${bgColor}`);
435
+ if (ownPaddingPx > 0 && ownBorderPx === 0 && countBased.endsWith("px")) {
436
+ ownRoot.walkDecls((d) => {
437
+ if (/^padding(-|$)/.test(d.prop)) extras.push(`${d.prop}: ${d.value}`);
438
+ });
439
+ hoistedTdWidths.set(id, subtractInsetPx(countBased, ownPaddingPx));
440
+ }
441
+ if (extras.length) tdExtras.set(id, extras.join("; "));
465
442
  }
466
443
  }
467
444
  const heightResolutions = /* @__PURE__ */ new Map();
@@ -473,8 +450,15 @@ function columnWidth(dom) {
473
450
  walk(dom, (node) => {
474
451
  if (node.type === "comment") {
475
452
  const data = node.data;
476
- if (!data || !data.includes("__MAIZZLE_COLW_") && !data.includes("__MAIZZLE_OH_")) return;
477
- node.data = data.replace(/__MAIZZLE_COLW_([^_]+)__/g, (_m, mid) => widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? "100%").replace(/__MAIZZLE_OH_([^_]+)__/g, (_m, hid) => heightResolutions.get(hid) ?? "100%");
453
+ if (!data) return;
454
+ const hasCW = data.includes("__MAIZZLE_COLW_");
455
+ const hasOH = data.includes("__MAIZZLE_OH_");
456
+ const hasTDX = data.includes("__MAIZZLE_COLTDX_");
457
+ if (!hasCW && !hasOH && !hasTDX) return;
458
+ node.data = data.replace(/__MAIZZLE_COLW_([^_]+)__/g, (_m, mid) => hoistedTdWidths.get(mid) ?? widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? "100%").replace(/;\s*__MAIZZLE_COLTDX_([^_]+)__/g, (_m, mid) => {
459
+ const pad = tdExtras.get(mid);
460
+ return pad ? `; ${pad}` : "";
461
+ }).replace(/__MAIZZLE_OH_([^_]+)__/g, (_m, hid) => heightResolutions.get(hid) ?? "100%");
478
462
  return;
479
463
  }
480
464
  const el = node;
@@ -513,7 +497,9 @@ function columnWidth(dom) {
513
497
  d.remove();
514
498
  return;
515
499
  }
516
- const resolved = widthResolutions.get(mid);
500
+ let resolved = widthResolutions.get(mid);
501
+ const inset = autoColumnInsets.get(mid);
502
+ if (inset) resolved = subtractInsetPx(resolved, inset);
517
503
  const repl = [postcss.decl({
518
504
  prop: "width",
519
505
  value: resolved
@@ -1 +1 @@
1
- {"version":3,"file":"columnWidth.js","names":[],"sources":["../../src/transformers/columnWidth.ts"],"sourcesContent":["import postcss, { type Root, type Declaration } from 'postcss'\nimport safeParser from 'postcss-safe-parser'\nimport { walk } from '../utils/ast/index.ts'\nimport type { ChildNode, Element, ParentNode } from 'domhandler'\n\nconst RE_PERCENT = /^[\\d.]+%$/\nconst NO_BORDER_STYLES = new Set(['none', 'hidden'])\n\n/**\n * Stringify decls into a `; `-joined inline-style attribute. PostCSS raws\n * preserve the original source spacing, which mixes poorly with\n * the fresh decls we inject — plain join keeps output uniform.\n */\nfunction serializeStyle(root: Root): string {\n const parts: string[] = []\n root.walkDecls((d) => {\n parts.push(`${d.prop}: ${d.value}${d.important ? ' !important' : ''}`)\n })\n return parts.join('; ')\n}\n\nfunction firstDeclValue(root: Root, prop: string): string | undefined {\n let found: string | undefined\n root.walkDecls(prop, (d) => {\n found = d.value\n return false\n })\n return found\n}\n\n/**\n * Find the user-set `min-width:` value on a column. Juice keeps both ours\n * and the one inlined from a class like `min-w-1/3` — we skip any\n * min-width whose value still contains our placeholder token,\n * returning the first remaining user value, or null.\n */\nfunction findUserMinWidth(root: Root): string | null {\n let userVal: string | null = null\n root.walkDecls('min-width', (d) => {\n if (!d.value.includes('__MAIZZLE_COLW_')) {\n userVal = d.value\n return false\n }\n })\n return userVal\n}\n\nfunction resolveLength(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\nfunction lengthToPx(value: string): number | null {\n const m = value.trim().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 n\n case 'rem':\n case 'em': return n * 16\n case 'pt': return n * 1.333\n default: return null\n }\n}\n\nfunction divideLength(value: string, divisor: number): string | null {\n const m = value.match(/^([\\d.]+)(px|%)$/)\n if (!m || divisor < 1) return null\n const n = parseFloat(m[1])\n return `${parseFloat((n / divisor).toFixed(2))}${m[2]}`\n}\n\nfunction subtractInsetPx(width: string, insetPx: number): string {\n if (insetPx <= 0) return width\n const m = width.match(/^([\\d.]+)(px|%)$/)\n if (!m) return width\n // Don't subtract px from percentage widths — units don't match.\n if (m[2] === '%') return width\n const n = parseFloat(m[1]) - insetPx\n return `${Math.max(0, Math.round(n))}px`\n}\n\n/**\n * Return the smaller of two px lengths. Clamps our count-based min-width\n * down to the user's `max-width:` so the cap is never silently\n * violated when our computed min would exceed the user's max.\n */\nfunction minPxLength(a: string, b: string): string {\n const am = a.match(/^([\\d.]+)px$/)\n const bm = b.match(/^([\\d.]+)px$/)\n if (!am || !bm) return a\n return parseFloat(am[1]) < parseFloat(bm[1]) ? a : b\n}\n\n/**\n * Expand a 1-4 token CSS shorthand (T R B L) into a left/right pair:\n * 1: all sides\n * 2: TB RL\n * 3: T RL B\n * 4: T R B L\n */\nfunction shorthandSides(value: string): { left?: string; right?: string } {\n const parts = value.trim().split(/\\s+/)\n switch (parts.length) {\n case 1: return { left: parts[0], right: parts[0] }\n case 2:\n case 3: return { left: parts[1], right: parts[1] }\n case 4: return { left: parts[3], right: parts[1] }\n default: return {}\n }\n}\n\n/**\n * Read horizontal padding (left + right) px from a parsed style root.\n * Percentages are skipped — they'd need a known container width.\n */\nfunction horizontalPaddingPx(root: Root): number {\n let left: number | null = null\n let right: number | null = null\n\n // Shorthand applies first; longhand overrides per side.\n root.walkDecls((d) => {\n switch (d.prop) {\n case 'padding': {\n const { left: l, right: r } = shorthandSides(d.value)\n if (l) left = lengthToPx(l)\n if (r) right = lengthToPx(r)\n break\n }\n case 'padding-left':\n left = lengthToPx(d.value)\n break\n case 'padding-right':\n right = lengthToPx(d.value)\n break\n }\n })\n\n return (left ?? 0) + (right ?? 0)\n}\n\n/**\n * Extract a px length from a CSS border shorthand (e.g. `1px solid red` → 1).\n * Returns null when the value indicates no border — `none` or `hidden`.\n * Defaults to 3px (CSS `medium`) when a visible style is set but\n * no explicit width token is present in the shorthand value.\n */\nfunction shorthandBorderWidthPx(value: string): number | null {\n const tokens = value.trim().split(/\\s+/)\n if (tokens.some((t) => NO_BORDER_STYLES.has(t.toLowerCase()))) return null\n for (const t of tokens) {\n const px = lengthToPx(t)\n if (px != null) return px\n }\n // Visible style, no explicit width → CSS default `medium` = 3px.\n return 3\n}\n\n/**\n * Read horizontal border widths (left + right) px from a parsed style root.\n * Per-side `border-style: none|hidden` overrides count as zero\n * contribution. Returns total px or 0 when nothing resolves.\n */\nfunction horizontalBorderPx(root: Root): number {\n let left: number | null = null\n let right: number | null = null\n let leftNone = false\n let rightNone = false\n\n root.walkDecls((d) => {\n switch (d.prop) {\n case 'border': {\n const w = shorthandBorderWidthPx(d.value)\n if (w == null) {\n leftNone = rightNone = true\n }\n else {\n left = right = w\n leftNone = rightNone = false\n }\n break\n }\n case 'border-width': {\n const { left: l, right: r } = shorthandSides(d.value)\n if (l) left = lengthToPx(l) ?? left\n if (r) right = lengthToPx(r) ?? right\n break\n }\n case 'border-style': {\n const { left: l, right: r } = shorthandSides(d.value)\n if (l && NO_BORDER_STYLES.has(l.toLowerCase())) leftNone = true\n if (r && NO_BORDER_STYLES.has(r.toLowerCase())) rightNone = true\n break\n }\n case 'border-left': {\n const w = shorthandBorderWidthPx(d.value)\n if (w == null) leftNone = true\n else { left = w; leftNone = false }\n break\n }\n case 'border-right': {\n const w = shorthandBorderWidthPx(d.value)\n if (w == null) rightNone = true\n else { right = w; rightNone = false }\n break\n }\n case 'border-left-width':\n left = lengthToPx(d.value) ?? left\n break\n case 'border-right-width':\n right = lengthToPx(d.value) ?? right\n break\n case 'border-left-style':\n if (NO_BORDER_STYLES.has(d.value.trim().toLowerCase())) leftNone = true\n break\n case 'border-right-style':\n if (NO_BORDER_STYLES.has(d.value.trim().toLowerCase())) rightNone = true\n break\n }\n })\n\n return (leftNone ? 0 : (left ?? 0)) + (rightNone ? 0 : (right ?? 0))\n}\n\nfunction depth(node: ChildNode): number {\n let d = 0\n let cur: ParentNode | null = node.parent\n while (cur) {\n d++\n cur = (cur as any).parent ?? null\n }\n return d\n}\n\nfunction readWidthFromRoot(root: Root): string | null {\n const raw = firstDeclValue(root, 'max-width')\n ?? firstDeclValue(root, 'width')\n ?? firstDeclValue(root, 'min-width')\n return raw ? resolveLength(raw) : null\n}\n\nfunction readHeightFromRoot(root: Root): string | null {\n const raw = firstDeclValue(root, 'max-height')\n ?? firstDeclValue(root, 'height')\n ?? firstDeclValue(root, 'min-height')\n return raw ? resolveLength(raw) : null\n}\n\nfunction readWidthSource(el: Element, root: Root | null): string | null {\n const explicit = el.attribs?.['data-maizzle-cw']\n if (explicit) {\n const r = resolveLength(explicit)\n if (r) return r\n }\n return root ? readWidthFromRoot(root) : null\n}\n\n/**\n * Convert a user-supplied length to absolute px against the column's source\n * width (post-inset). Percentages multiply against the source while\n * absolute units pass through `resolveLength`. Returns null when\n * the value or source can't be expressed in px.\n */\nfunction userValueToPx(rawValue: string, sourcePx: string | null): string | null {\n const trimmed = rawValue.trim()\n\n const absMatch = trimmed.match(/^([\\d.]+)(px|rem|em|pt)$/i)\n if (absMatch) return resolveLength(trimmed)\n\n const pctMatch = trimmed.match(/^([\\d.]+)%$/)\n if (!pctMatch || !sourcePx) return null\n const sourceMatch = sourcePx.match(/^([\\d.]+)px$/)\n if (!sourceMatch) return null\n const pct = parseFloat(pctMatch[1])\n const src = parseFloat(sourceMatch[1])\n return `${Math.round((pct / 100) * src)}px`\n}\n\n/**\n * Resolve `__MAIZZLE_COLW_{id}__` and `__MAIZZLE_OH_{id}__` placeholders.\n *\n * COLW (column width) — emitted by `<Column>` and `<Overlap>`. Walks up to\n * the nearest ancestor marked `data-maizzle-cw` (Container, Section,\n * Row, or another Column already resolved) and divides the source\n * width by `data-maizzle-cw-count`. With `data-maizzle-cw-self`,\n * reads from the element's own inlined max/width/min-width\n * instead — used by `<Overlap>` with its own width class.\n *\n * OH (overlap height) — emitted by `<Overlap>`. Reads max-height, height,\n * or min-height from the element's own inlined style.\n *\n * Resolution rules:\n * - Style placeholders for `min-width`: replaced when resolvable, otherwise\n * the entire `min-width` declaration is stripped.\n * - Other style placeholders (Overlap td `width`, etc.): replaced when\n * resolvable, otherwise replaced with the count-based fallback or `100%`.\n * - Comment placeholders: same fallback chain.\n *\n * Resolved column widths are written back to `data-maizzle-cw` so nested\n * rows cascade. All `data-maizzle-cw*` and `data-maizzle-oh-*` are\n * stripped at the end of the second walk pass.\n */\nexport function columnWidth(dom: ChildNode[]): ChildNode[] {\n /**\n * Cache parsed style ASTs for this columnWidth invocation. The walk-up\n * loop visits the same Section/Container once per column of a Row,\n * so without caching each column re-parses every ancestor's style.\n * Cache is function-local — no cross-build leak via the WeakMap.\n */\n const styleCache = new WeakMap<Element, Root>()\n const parseElStyle = (el: Element): Root => {\n const cached = styleCache.get(el)\n if (cached) return cached\n const style = el.attribs?.style ?? ''\n const root = style ? safeParser(style) : postcss.root()\n styleCache.set(el, root)\n return root\n }\n\n const columns: { el: Element; id: string; count: number; d: number; self: boolean }[] = []\n const heightTargets: { el: Element; id: string }[] = []\n\n walk(dom, (node) => {\n const el = node as Element\n if (!el.attribs) return\n\n const id = el.attribs['data-maizzle-cw-id']\n if (id) {\n const count = parseInt(el.attribs['data-maizzle-cw-count'] || '1', 10)\n const self = 'data-maizzle-cw-self' in el.attribs\n columns.push({ el, id, count, d: depth(node), self })\n }\n\n const ohId = el.attribs['data-maizzle-oh-id']\n if (ohId) heightTargets.push({ el, id: ohId })\n })\n\n columns.sort((a, b) => a.d - b.d)\n\n const widthResolutions = new Map<string, string>()\n const widthFallbacks = new Map<string, string>()\n /**\n * Column ids whose absolute user `width:` was promoted to `min-width:`\n * — the original `width:` declaration must be stripped from the\n * column's style (otherwise it'd compete with the min-width).\n */\n const stripWidth = new Set<string>()\n /**\n * Column ids where the user wrote a percentage `width:` (e.g. `w-1/2`) —\n * explicit opt-out of px-based stacking. Keep the user's `width: X%`\n * and drop our `min-width:` placeholder so the column stays at\n * that percentage of its parent forever and never stacks.\n */\n const dropMinWidth = new Set<string>()\n /**\n * Column ids where the user wrote their own `min-width:` (via `min-w-1/3`).\n * Juice inlines theirs after ours, so two `min-width:` decls land in\n * the style — we strip the user's after using its value as the\n * column's resolution, leaving our placeholder as last word.\n */\n const stripUserMinWidth = new Set<string>()\n /**\n * Column ids where the user already supplied a `max-width:` of their own.\n * Our default `max-width: 100%` would just be shadowed by it via\n * last-wins and bloat the style — so we skip emitting it.\n */\n const userHasMaxWidth = new Set<string>()\n\n for (const { id, count } of columns) {\n widthFallbacks.set(id, `${Math.round(100 / Math.max(count, 1))}%`)\n }\n\n for (const { el, id, count, self } of columns) {\n const ownRoot = parseElStyle(el)\n\n let sourceWidth: string | null = null\n let accumulatedInsetPx = 0\n\n if (self) {\n sourceWidth = readWidthFromRoot(ownRoot)\n accumulatedInsetPx = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot)\n }\n else {\n /**\n * Walk up through every ancestor with attribs, accumulating horizontal\n * padding+border along the way (including the source). Stop at the\n * first `data-maizzle-cw` ancestor whose width is resolvable.\n * Markers without a resolvable width (Row emitted empty after\n * Tailwind dropped a bogus class) shouldn't shadow a real\n * width on a higher ancestor like `<Container>`.\n *\n * With CSS content-box this is technically generous toward the\n * source's own padding/border, but matches user expectations\n * when they put `px-9` or `border-2` on a wrapper.\n */\n let cur: ParentNode | null = el.parent\n while (cur) {\n const parentEl = cur as Element\n if (parentEl.attribs) {\n let pRoot: Root | null = null\n if (parentEl.attribs.style) {\n pRoot = parseElStyle(parentEl)\n accumulatedInsetPx += horizontalPaddingPx(pRoot) + horizontalBorderPx(pRoot)\n }\n if ('data-maizzle-cw' in parentEl.attribs) {\n const w = readWidthSource(parentEl, pRoot)\n if (w) {\n sourceWidth = w\n break\n }\n }\n }\n cur = (cur as any).parent ?? null\n }\n }\n\n const adjusted = sourceWidth ? subtractInsetPx(sourceWidth, accumulatedInsetPx) : null\n const countBased = adjusted ? divideLength(adjusted, count) : null\n\n /**\n * Four user-override paths, decided by which CSS property the user\n * actually wrote:\n *\n * - `min-width: X` → user's value wins. Convert to px against\n * the source (if %), use as the column's\n * resolution, and strip the user's min-width\n * declaration so our placeholder substitution\n * remains the last `min-width:` in style.\n * - `width: X%` → opt-out of px stacking. Keep `width:` in\n * style, drop our `min-width:` placeholder.\n * Cols stay at X% of parent forever, never stack.\n * - `width: Xpx` (or rem/em/pt) → fixed pixel column. Promote to\n * `min-width:`, strip the original `width:` so\n * it doesn't compete.\n * - `max-width: X` → CSS cap. Keep the `max-width:` declaration;\n * clamp our count-based min-width *down* to\n * the user's max-width when our min would\n * otherwise violate it.\n */\n const userMinRaw = findUserMinWidth(ownRoot)\n const widthRaw = firstDeclValue(ownRoot, 'width')\n const maxRaw = firstDeclValue(ownRoot, 'max-width')\n\n if (userMinRaw) {\n const minPx = userValueToPx(userMinRaw, adjusted) ?? resolveLength(userMinRaw)\n if (minPx) {\n widthResolutions.set(id, minPx)\n el.attribs['data-maizzle-cw'] = minPx\n stripUserMinWidth.add(id)\n continue\n }\n }\n\n if (widthRaw) {\n const widthVal = resolveLength(widthRaw)\n if (widthVal?.endsWith('%')) {\n widthResolutions.set(id, widthVal)\n el.attribs['data-maizzle-cw'] = widthVal\n dropMinWidth.add(id)\n continue\n }\n if (widthVal) {\n widthResolutions.set(id, widthVal)\n el.attribs['data-maizzle-cw'] = widthVal\n stripWidth.add(id)\n continue\n }\n }\n\n if (maxRaw && countBased) {\n const maxPx = userValueToPx(maxRaw, adjusted)\n if (maxPx) {\n const cappedMin = countBased.endsWith('px')\n ? minPxLength(countBased, maxPx)\n : maxPx\n widthResolutions.set(id, cappedMin)\n el.attribs['data-maizzle-cw'] = cappedMin\n userHasMaxWidth.add(id)\n continue\n }\n }\n\n if (countBased) {\n widthResolutions.set(id, countBased)\n el.attribs['data-maizzle-cw'] = countBased\n }\n }\n\n const heightResolutions = new Map<string, string>()\n for (const { el, id } of heightTargets) {\n if (!el.attribs?.style) continue\n const h = readHeightFromRoot(parseElStyle(el))\n if (h) heightResolutions.set(id, h)\n }\n\n walk(dom, (node) => {\n if (node.type === 'comment') {\n const data = (node as any).data as string\n if (!data || (!data.includes('__MAIZZLE_COLW_') && !data.includes('__MAIZZLE_OH_'))) return\n ;(node as any).data = data\n .replace(/__MAIZZLE_COLW_([^_]+)__/g,\n (_m, mid) => widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? '100%')\n .replace(/__MAIZZLE_OH_([^_]+)__/g,\n (_m, hid) => heightResolutions.get(hid) ?? '100%')\n return\n }\n\n const el = node as Element\n if (!el.attribs) return\n\n const style = el.attribs.style\n if (style && (style.includes('__MAIZZLE_COLW_') || style.includes('__MAIZZLE_OH_'))) {\n const root = parseElStyle(el)\n const cwId = el.attribs['data-maizzle-cw-id']\n\n /**\n * Strip user dups BEFORE substitution — last-wins CSS would\n * otherwise shadow our resolved values in the output.\n */\n if (cwId && stripUserMinWidth.has(cwId)) {\n root.walkDecls('min-width', (d) => {\n if (!d.value.includes('__MAIZZLE_COLW_')) d.remove()\n })\n }\n if (cwId && stripWidth.has(cwId)) {\n root.walkDecls('width', (d) => { d.remove() })\n }\n\n /**\n * Substitute the column's `min-width:` placeholder with `width: <res>;\n * max-width: 100%`. Width gives the same stacking trigger as\n * min-width — inline-block wraps when children sum > parent\n * — and the `max-width: 100%` clamp keeps the column from\n * overflowing the viewport once it drops to its own row on\n * mobile. Skip the clamp when the user supplied their own.\n *\n * Other placeholders (Overlap td `width`, comment markers,\n * OH height) get a plain value substitution.\n */\n root.walkDecls((d) => {\n if (d.prop === 'min-width') {\n const m = d.value.match(/^__MAIZZLE_COLW_([^_]+)__$/)\n if (m) {\n const mid = m[1]\n if (dropMinWidth.has(mid) || !widthResolutions.has(mid)) {\n d.remove()\n return\n }\n const resolved = widthResolutions.get(mid)!\n const repl: Declaration[] = [postcss.decl({ prop: 'width', value: resolved })]\n if (!userHasMaxWidth.has(mid)) {\n repl.push(postcss.decl({ prop: 'max-width', value: '100%' }))\n }\n d.replaceWith(...repl)\n return\n }\n }\n if (d.value.includes('__MAIZZLE_COLW_') || d.value.includes('__MAIZZLE_OH_')) {\n d.value = d.value\n .replace(/__MAIZZLE_COLW_([^_]+)__/g,\n (_m, mid) => widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? '100%')\n .replace(/__MAIZZLE_OH_([^_]+)__/g,\n (_m, hid) => heightResolutions.get(hid) ?? '100%')\n }\n })\n\n const out = serializeStyle(root)\n if (out) el.attribs.style = out\n else delete el.attribs.style\n }\n\n delete el.attribs['data-maizzle-cw']\n delete el.attribs['data-maizzle-cw-id']\n delete el.attribs['data-maizzle-cw-count']\n delete el.attribs['data-maizzle-cw-self']\n delete el.attribs['data-maizzle-oh-id']\n })\n\n return dom\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAa;AACnB,MAAM,mBAAmB,IAAI,IAAI,CAAC,QAAQ,SAAS,CAAC;;;;;;AAOpD,SAAS,eAAe,MAAoB;CAC1C,MAAM,QAAkB,EAAE;CAC1B,KAAK,WAAW,MAAM;EACpB,MAAM,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,QAAQ,EAAE,YAAY,gBAAgB,KAAK;GACtE;CACF,OAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,eAAe,MAAY,MAAkC;CACpE,IAAI;CACJ,KAAK,UAAU,OAAO,MAAM;EAC1B,QAAQ,EAAE;EACV,OAAO;GACP;CACF,OAAO;;;;;;;;AAST,SAAS,iBAAiB,MAA2B;C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"file":"columnWidth.js","names":[],"sources":["../../src/transformers/columnWidth.ts"],"sourcesContent":["import postcss, { type Root, type Declaration } from 'postcss'\nimport safeParser from 'postcss-safe-parser'\nimport { walk } from '../utils/ast/index.ts'\nimport { horizontalBorderPx, horizontalPaddingPx, lengthToPx } from '../utils/cssBox.ts'\nimport type { ChildNode, Element, ParentNode } from 'domhandler'\n\nconst RE_PERCENT = /^[\\d.]+%$/\n\n/**\n * Stringify decls into a `; `-joined inline-style attribute. PostCSS raws\n * preserve the original source spacing, which mixes poorly with\n * the fresh decls we inject — plain join keeps output uniform.\n */\nfunction serializeStyle(root: Root): string {\n const parts: string[] = []\n root.walkDecls((d) => {\n parts.push(`${d.prop}: ${d.value}${d.important ? ' !important' : ''}`)\n })\n return parts.join('; ')\n}\n\nfunction firstDeclValue(root: Root, prop: string): string | undefined {\n let found: string | undefined\n root.walkDecls(prop, (d) => {\n found = d.value\n return false\n })\n return found\n}\n\n/**\n * Find the user-set `min-width:` value on a column. Juice keeps both ours\n * and the one inlined from a class like `min-w-1/3` — we skip any\n * min-width whose value still contains our placeholder token,\n * returning the first remaining user value, or null.\n */\nfunction findUserMinWidth(root: Root): string | null {\n let userVal: string | null = null\n root.walkDecls('min-width', (d) => {\n if (!d.value.includes('__MAIZZLE_COLW_')) {\n userVal = d.value\n return false\n }\n })\n return userVal\n}\n\nfunction resolveLength(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\nfunction divideLength(value: string, divisor: number): string | null {\n const m = value.match(/^([\\d.]+)(px|%)$/)\n if (!m || divisor < 1) return null\n const n = parseFloat(m[1])\n return `${parseFloat((n / divisor).toFixed(2))}${m[2]}`\n}\n\nfunction subtractInsetPx(width: string, insetPx: number): string {\n if (insetPx <= 0) return width\n const m = width.match(/^([\\d.]+)(px|%)$/)\n if (!m) return width\n // Don't subtract px from percentage widths — units don't match.\n if (m[2] === '%') return width\n const n = parseFloat(m[1]) - insetPx\n return `${Math.max(0, Math.round(n))}px`\n}\n\n/**\n * Return the smaller of two px lengths. Clamps our count-based min-width\n * down to the user's `max-width:` so the cap is never silently\n * violated when our computed min would exceed the user's max.\n */\nfunction minPxLength(a: string, b: string): string {\n const am = a.match(/^([\\d.]+)px$/)\n const bm = b.match(/^([\\d.]+)px$/)\n if (!am || !bm) return a\n return parseFloat(am[1]) < parseFloat(bm[1]) ? a : b\n}\n\nfunction depth(node: ChildNode): number {\n let d = 0\n let cur: ParentNode | null = node.parent\n while (cur) {\n d++\n cur = (cur as any).parent ?? null\n }\n return d\n}\n\nfunction readWidthFromRoot(root: Root): string | null {\n const raw = firstDeclValue(root, 'max-width')\n ?? firstDeclValue(root, 'width')\n ?? firstDeclValue(root, 'min-width')\n return raw ? resolveLength(raw) : null\n}\n\nfunction readHeightFromRoot(root: Root): string | null {\n const raw = firstDeclValue(root, 'max-height')\n ?? firstDeclValue(root, 'height')\n ?? firstDeclValue(root, 'min-height')\n return raw ? resolveLength(raw) : null\n}\n\nfunction readWidthSource(el: Element, root: Root | null): string | null {\n const explicit = el.attribs?.['data-maizzle-cw']\n if (explicit) {\n const r = resolveLength(explicit)\n if (r) return r\n }\n return root ? readWidthFromRoot(root) : null\n}\n\n/**\n * Convert a user-supplied length to absolute px against the column's source\n * width (post-inset). Percentages multiply against the source while\n * absolute units pass through `resolveLength`. Returns null when\n * the value or source can't be expressed in px.\n */\nfunction userValueToPx(rawValue: string, sourcePx: string | null): string | null {\n const trimmed = rawValue.trim()\n\n const absMatch = trimmed.match(/^([\\d.]+)(px|rem|em|pt)$/i)\n if (absMatch) return resolveLength(trimmed)\n\n const pctMatch = trimmed.match(/^([\\d.]+)%$/)\n if (!pctMatch || !sourcePx) return null\n const sourceMatch = sourcePx.match(/^([\\d.]+)px$/)\n if (!sourceMatch) return null\n const pct = parseFloat(pctMatch[1])\n const src = parseFloat(sourceMatch[1])\n return `${Math.round((pct / 100) * src)}px`\n}\n\n/**\n * Resolve `__MAIZZLE_COLW_{id}__` and `__MAIZZLE_OH_{id}__` placeholders.\n *\n * COLW (column width) — emitted by `<Column>` and `<Overlap>`. Walks up to\n * the nearest ancestor marked `data-maizzle-cw` (Container, Section,\n * Row, or another Column already resolved) and divides the source\n * width by `data-maizzle-cw-count`. With `data-maizzle-cw-self`,\n * reads from the element's own inlined max/width/min-width\n * instead — used by `<Overlap>` with its own width class.\n *\n * OH (overlap height) — emitted by `<Overlap>`. Reads max-height, height,\n * or min-height from the element's own inlined style.\n *\n * Resolution rules:\n * - Style placeholders for `min-width`: replaced when resolvable, otherwise\n * the entire `min-width` declaration is stripped.\n * - Other style placeholders (Overlap td `width`, etc.): replaced when\n * resolvable, otherwise replaced with the count-based fallback or `100%`.\n * - Comment placeholders: same fallback chain.\n *\n * Resolved column widths are written back to `data-maizzle-cw` so nested\n * rows cascade. All `data-maizzle-cw*` and `data-maizzle-oh-*` are\n * stripped at the end of the second walk pass.\n */\nexport function columnWidth(dom: ChildNode[]): ChildNode[] {\n /**\n * Cache parsed style ASTs for this columnWidth invocation. The walk-up\n * loop visits the same Section/Container once per column of a Row,\n * so without caching each column re-parses every ancestor's style.\n * Cache is function-local — no cross-build leak via the WeakMap.\n */\n const styleCache = new WeakMap<Element, Root>()\n const parseElStyle = (el: Element): Root => {\n const cached = styleCache.get(el)\n if (cached) return cached\n const style = el.attribs?.style ?? ''\n const root = style ? safeParser(style) : postcss.root()\n styleCache.set(el, root)\n return root\n }\n\n const columns: { el: Element; id: string; count: number; d: number; self: boolean }[] = []\n const heightTargets: { el: Element; id: string }[] = []\n\n walk(dom, (node) => {\n const el = node as Element\n if (!el.attribs) return\n\n const id = el.attribs['data-maizzle-cw-id']\n if (id) {\n const count = parseInt(el.attribs['data-maizzle-cw-count'] || '1', 10)\n const self = 'data-maizzle-cw-self' in el.attribs\n columns.push({ el, id, count, d: depth(node), self })\n }\n\n const ohId = el.attribs['data-maizzle-oh-id']\n if (ohId) heightTargets.push({ el, id: ohId })\n })\n\n columns.sort((a, b) => a.d - b.d)\n\n const widthResolutions = new Map<string, string>()\n const widthFallbacks = new Map<string, string>()\n /**\n * Column ids whose absolute user `width:` was promoted to `min-width:`\n * — the original `width:` declaration must be stripped from the\n * column's style (otherwise it'd compete with the min-width).\n */\n const stripWidth = new Set<string>()\n /**\n * Column ids where the user wrote a percentage `width:` (e.g. `w-1/2`) —\n * explicit opt-out of px-based stacking. Keep the user's `width: X%`\n * and drop our `min-width:` placeholder so the column stays at\n * that percentage of its parent forever and never stacks.\n */\n const dropMinWidth = new Set<string>()\n /**\n * Column ids where the user wrote their own `min-width:` (via `min-w-1/3`).\n * Juice inlines theirs after ours, so two `min-width:` decls land in\n * the style — we strip the user's after using its value as the\n * column's resolution, leaving our placeholder as last word.\n */\n const stripUserMinWidth = new Set<string>()\n /**\n * Column ids where the user already supplied a `max-width:` of their own.\n * Our default `max-width: 100%` would just be shadowed by it via\n * last-wins and bloat the style — so we skip emitting it.\n */\n const userHasMaxWidth = new Set<string>()\n /**\n * Horizontal padding+border (px) of each column whose width was auto-\n * derived from count-based math. The column's own border/padding eats\n * its content box under content-box sizing, so the emitted `width:`\n * must be the slice MINUS this inset; otherwise two bordered cols\n * sum past the container and wrap. Only populated for auto paths\n * — user-explicit `width:`/`min-width:`/`max-width:`-wins paths\n * leave the value alone so the user's number stays the user's.\n */\n const autoColumnInsets = new Map<string, number>()\n /**\n * Extra inline-style decls that get stamped onto each column's MSO `<td>`\n * via its COLTDX placeholder. Carries `background-color` (so Word\n * paints the cell behind any padding area or whitespace, not just\n * the div) and hoisted `padding*` decls (when no border is present\n * — without one Word silently drops div padding, with one a td\n * copy would double-pad). The div keeps both for modern clients\n * since the MSO td is conditional-comment-only.\n */\n const tdExtras = new Map<string, string>()\n /**\n * MSO td width override for hoisted columns. With padding on the td and\n * CSS content-box sizing for table cells, td_outer = width + 2*pad,\n * so we set td width to the slot MINUS 2*horizontal-padding to keep\n * the cell at its outer slot. Skipped when the slot is a %.\n */\n const hoistedTdWidths = new Map<string, string>()\n\n for (const { id, count } of columns) {\n widthFallbacks.set(id, `${Math.round(100 / Math.max(count, 1))}%`)\n }\n\n /**\n * Sibling-aware redistribution.\n *\n * Without this, every auto column slices its source `/ totalCount`,\n * ignoring siblings that already declared a fixed `w-5` (20px) or\n * `w-1/3` (%). Three auto cols next to a `w-5` would each take\n * `source/3` and overflow the row by 20px.\n *\n * Pre-pass: classify each col against its inlined style.\n * - explicit-px: `width:` or `min-width:` resolving to px. The col\n * occupies (px value + own horizontal padding +\n * own horizontal border) of the source.\n * - explicit-pct: `width:` or `min-width:` resolving to %. The col\n * occupies (pct * source / 100 + own inset).\n * - auto: everything else. Shares the remainder with other\n * auto siblings.\n *\n * Group cols by their immediate `el.parent` (the Row div). For each\n * group, sum the explicit contributions and count the autos. The\n * countBased path below uses these to redistribute leftover space\n * instead of dividing the raw source by total count.\n *\n * `data-maizzle-cw-self` cols (Overlap) are excluded — they own their\n * source independently and don't share a parent's slot with cols.\n */\n interface ColClassification {\n kind: 'auto' | 'explicit'\n pxOuter: number\n pctOuter: number\n }\n interface GroupInfo {\n explicitPxOuterSum: number\n explicitPctOuterSum: number\n autoCount: number\n }\n const groupInfos = new Map<ParentNode, GroupInfo>()\n\n for (const c of columns) {\n if (c.self) continue\n const ownRoot = parseElStyle(c.el)\n const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot)\n\n let cls: ColClassification = { kind: 'auto', pxOuter: 0, pctOuter: 0 }\n const userVal = findUserMinWidth(ownRoot) ?? firstDeclValue(ownRoot, 'width')\n if (userVal) {\n const resolved = resolveLength(userVal)\n if (resolved?.endsWith('px')) {\n const px = lengthToPx(resolved)\n if (px != null) cls = { kind: 'explicit', pxOuter: px + ownInset, pctOuter: 0 }\n }\n else if (resolved?.endsWith('%')) {\n cls = { kind: 'explicit', pxOuter: ownInset, pctOuter: parseFloat(resolved) }\n }\n }\n\n const parent = c.el.parent as ParentNode | null\n if (!parent) continue\n let info = groupInfos.get(parent)\n if (!info) {\n info = { explicitPxOuterSum: 0, explicitPctOuterSum: 0, autoCount: 0 }\n groupInfos.set(parent, info)\n }\n info.explicitPxOuterSum += cls.pxOuter\n info.explicitPctOuterSum += cls.pctOuter\n if (cls.kind === 'auto') info.autoCount++\n }\n\n for (const { el, id, count, self } of columns) {\n const ownRoot = parseElStyle(el)\n\n let sourceWidth: string | null = null\n let accumulatedInsetPx = 0\n\n if (self) {\n sourceWidth = readWidthFromRoot(ownRoot)\n accumulatedInsetPx = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot)\n }\n else {\n /**\n * Walk up through every ancestor with attribs, accumulating horizontal\n * padding+border along the way (including the source). Stop at the\n * first `data-maizzle-cw` ancestor whose width is resolvable.\n * Markers without a resolvable width (Row emitted empty after\n * Tailwind dropped a bogus class) shouldn't shadow a real\n * width on a higher ancestor like `<Container>`.\n *\n * With CSS content-box this is technically generous toward the\n * source's own padding/border, but matches user expectations\n * when they put `px-9` or `border-2` on a wrapper.\n */\n let cur: ParentNode | null = el.parent\n while (cur) {\n const parentEl = cur as Element\n if (parentEl.attribs) {\n let pRoot: Root | null = null\n if (parentEl.attribs.style) {\n pRoot = parseElStyle(parentEl)\n accumulatedInsetPx += horizontalPaddingPx(pRoot) + horizontalBorderPx(pRoot)\n }\n if ('data-maizzle-cw' in parentEl.attribs) {\n const w = readWidthSource(parentEl, pRoot)\n if (w) {\n sourceWidth = w\n break\n }\n }\n }\n cur = (cur as any).parent ?? null\n }\n }\n\n const adjusted = sourceWidth ? subtractInsetPx(sourceWidth, accumulatedInsetPx) : null\n let countBased = adjusted ? divideLength(adjusted, count) : null\n\n /**\n * Sibling-aware redistribution kicks in only when the auto col has at\n * least one explicit-width sibling and the source is in px (can't\n * mix px subtraction with a % source). When that's true, the auto\n * col's share becomes `(source − sum_explicit_px − pct% of source)\n * / autoCount`, replacing the naive `source/totalCount`.\n */\n if (!self && adjusted?.endsWith('px') && countBased && el.parent) {\n const group = groupInfos.get(el.parent as ParentNode)\n if (group && group.autoCount > 0\n && (group.explicitPxOuterSum > 0 || group.explicitPctOuterSum > 0)) {\n const adjPx = lengthToPx(adjusted)\n if (adjPx != null) {\n const remaining = adjPx - group.explicitPxOuterSum - (adjPx * group.explicitPctOuterSum / 100)\n /**\n * Floor-to-2-decimals on the per-auto share. Two reasons:\n *\n * 1. Matches `divideLength`'s precision so the auto path and\n * group-aware path emit consistent units.\n * 2. Rounding up (e.g. 536/3 = 178.6̄ → round to 179) pushes\n * the sum past the slot — 3×179 + 2×20 = 577 > 576 →\n * inline-block wraps and the row stacks. Flooring at 2\n * decimals keeps the sum ≤ slot with at most ~0.0(autoCount)\n * px unused, which is sub-pixel and invisible.\n */\n const share = Math.max(0, Math.floor((remaining * 100) / group.autoCount) / 100)\n countBased = `${share}px`\n }\n }\n }\n\n /**\n * Four user-override paths, decided by which CSS property the user\n * actually wrote:\n *\n * - `min-width: X` → user's value wins. Convert to px against\n * the source (if %), use as the column's\n * resolution, and strip the user's min-width\n * declaration so our placeholder substitution\n * remains the last `min-width:` in style.\n * - `width: X%` → opt-out of px stacking. Keep `width:` in\n * style, drop our `min-width:` placeholder.\n * Cols stay at X% of parent forever, never stack.\n * - `width: Xpx` (or rem/em/pt) → fixed pixel column. Promote to\n * `min-width:`, strip the original `width:` so\n * it doesn't compete.\n * - `max-width: X` → CSS cap. Keep the `max-width:` declaration;\n * clamp our count-based min-width *down* to\n * the user's max-width when our min would\n * otherwise violate it.\n */\n const userMinRaw = findUserMinWidth(ownRoot)\n const widthRaw = firstDeclValue(ownRoot, 'width')\n const maxRaw = firstDeclValue(ownRoot, 'max-width')\n\n if (userMinRaw) {\n const minPx = userValueToPx(userMinRaw, adjusted) ?? resolveLength(userMinRaw)\n if (minPx) {\n widthResolutions.set(id, minPx)\n el.attribs['data-maizzle-cw'] = minPx\n stripUserMinWidth.add(id)\n continue\n }\n }\n\n if (widthRaw) {\n const widthVal = resolveLength(widthRaw)\n if (widthVal?.endsWith('%')) {\n widthResolutions.set(id, widthVal)\n el.attribs['data-maizzle-cw'] = widthVal\n dropMinWidth.add(id)\n continue\n }\n if (widthVal) {\n widthResolutions.set(id, widthVal)\n el.attribs['data-maizzle-cw'] = widthVal\n stripWidth.add(id)\n continue\n }\n }\n\n if (maxRaw && countBased) {\n const maxPx = userValueToPx(maxRaw, adjusted)\n if (maxPx) {\n const cappedMin = countBased.endsWith('px')\n ? minPxLength(countBased, maxPx)\n : maxPx\n widthResolutions.set(id, cappedMin)\n el.attribs['data-maizzle-cw'] = cappedMin\n userHasMaxWidth.add(id)\n if (cappedMin === countBased) {\n const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot)\n if (ownInset > 0) autoColumnInsets.set(id, ownInset)\n }\n continue\n }\n }\n\n if (countBased) {\n widthResolutions.set(id, countBased)\n el.attribs['data-maizzle-cw'] = countBased\n const ownPaddingPx = horizontalPaddingPx(ownRoot)\n const ownBorderPx = horizontalBorderPx(ownRoot)\n const ownInset = ownPaddingPx + ownBorderPx\n if (ownInset > 0) autoColumnInsets.set(id, ownInset)\n\n /**\n * Build the MSO td's \"extras\" string — decls that need to live on\n * the td in addition to width + vertical-align. Two contributors:\n *\n * - `background-color` (always, when present) — Word renders the\n * div bg inside the cell, but anything outside the div (the\n * td's padding area when hoisted, or any whitespace gap)\n * would show the parent's bg instead of the column's. Painting\n * the td matches the user's intent.\n *\n * - `padding*` (hoisted only when no horizontal border) — Word\n * drops div padding without a stabilizing border, so the td\n * has to carry it. With a border, Word renders div padding\n * and a td copy would double-pad. Skip when the slot is `%`:\n * td width math can't subtract px padding from a percentage.\n */\n const extras: string[] = []\n let bgColor: string | undefined\n ownRoot.walkDecls('background-color', (d) => { bgColor = d.value })\n if (bgColor) extras.push(`background-color: ${bgColor}`)\n\n if (ownPaddingPx > 0 && ownBorderPx === 0 && countBased.endsWith('px')) {\n ownRoot.walkDecls((d) => {\n if (/^padding(-|$)/.test(d.prop)) extras.push(`${d.prop}: ${d.value}`)\n })\n hoistedTdWidths.set(id, subtractInsetPx(countBased, ownPaddingPx))\n }\n\n if (extras.length) tdExtras.set(id, extras.join('; '))\n }\n }\n\n const heightResolutions = new Map<string, string>()\n for (const { el, id } of heightTargets) {\n if (!el.attribs?.style) continue\n const h = readHeightFromRoot(parseElStyle(el))\n if (h) heightResolutions.set(id, h)\n }\n\n walk(dom, (node) => {\n if (node.type === 'comment') {\n const data = (node as any).data as string\n if (!data) return\n const hasCW = data.includes('__MAIZZLE_COLW_')\n const hasOH = data.includes('__MAIZZLE_OH_')\n const hasTDX = data.includes('__MAIZZLE_COLTDX_')\n if (!hasCW && !hasOH && !hasTDX) return\n ;(node as any).data = data\n .replace(/__MAIZZLE_COLW_([^_]+)__/g,\n (_m, mid) => hoistedTdWidths.get(mid) ?? widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? '100%')\n .replace(/;\\s*__MAIZZLE_COLTDX_([^_]+)__/g,\n (_m, mid) => {\n const pad = tdExtras.get(mid)\n return pad ? `; ${pad}` : ''\n })\n .replace(/__MAIZZLE_OH_([^_]+)__/g,\n (_m, hid) => heightResolutions.get(hid) ?? '100%')\n return\n }\n\n const el = node as Element\n if (!el.attribs) return\n\n const style = el.attribs.style\n if (style && (style.includes('__MAIZZLE_COLW_') || style.includes('__MAIZZLE_OH_'))) {\n const root = parseElStyle(el)\n const cwId = el.attribs['data-maizzle-cw-id']\n\n /**\n * Strip user dups BEFORE substitution — last-wins CSS would\n * otherwise shadow our resolved values in the output.\n */\n if (cwId && stripUserMinWidth.has(cwId)) {\n root.walkDecls('min-width', (d) => {\n if (!d.value.includes('__MAIZZLE_COLW_')) d.remove()\n })\n }\n if (cwId && stripWidth.has(cwId)) {\n root.walkDecls('width', (d) => { d.remove() })\n }\n\n /**\n * Substitute the column's `min-width:` placeholder with `width: <res>;\n * max-width: 100%`. Width gives the same stacking trigger as\n * min-width — inline-block wraps when children sum > parent\n * — and the `max-width: 100%` clamp keeps the column from\n * overflowing the viewport once it drops to its own row on\n * mobile. Skip the clamp when the user supplied their own.\n *\n * Other placeholders (Overlap td `width`, comment markers,\n * OH height) get a plain value substitution.\n */\n root.walkDecls((d) => {\n if (d.prop === 'min-width') {\n const m = d.value.match(/^__MAIZZLE_COLW_([^_]+)__$/)\n if (m) {\n const mid = m[1]\n if (dropMinWidth.has(mid) || !widthResolutions.has(mid)) {\n d.remove()\n return\n }\n let resolved = widthResolutions.get(mid)!\n const inset = autoColumnInsets.get(mid)\n if (inset) resolved = subtractInsetPx(resolved, inset)\n const repl: Declaration[] = [postcss.decl({ prop: 'width', value: resolved })]\n if (!userHasMaxWidth.has(mid)) {\n repl.push(postcss.decl({ prop: 'max-width', value: '100%' }))\n }\n d.replaceWith(...repl)\n return\n }\n }\n if (d.value.includes('__MAIZZLE_COLW_') || d.value.includes('__MAIZZLE_OH_')) {\n d.value = d.value\n .replace(/__MAIZZLE_COLW_([^_]+)__/g,\n (_m, mid) => widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? '100%')\n .replace(/__MAIZZLE_OH_([^_]+)__/g,\n (_m, hid) => heightResolutions.get(hid) ?? '100%')\n }\n })\n\n const out = serializeStyle(root)\n if (out) el.attribs.style = out\n else delete el.attribs.style\n }\n\n delete el.attribs['data-maizzle-cw']\n delete el.attribs['data-maizzle-cw-id']\n delete el.attribs['data-maizzle-cw-count']\n delete el.attribs['data-maizzle-cw-self']\n delete el.attribs['data-maizzle-oh-id']\n })\n\n return dom\n}\n"],"mappings":";;;;;;AAMA,MAAM,aAAa;;;;;;AAOnB,SAAS,eAAe,MAAoB;CAC1C,MAAM,QAAkB,CAAC;CACzB,KAAK,WAAW,MAAM;EACpB,MAAM,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,QAAQ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,IAAI,GAAG,KAAK,MAAM;GAEzD,CAAC;GAED,MAAM,MAAM,eAAe,IAAI;GAC/B,IAAI,KAAK,GAAG,QAAQ,QAAQ;QACvB,OAAO,GAAG,QAAQ;EACzB;EAEA,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;CACpB,CAAC;CAED,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","names":[],"sources":["../../src/transformers/entities.ts"],"mappings":";;;;;;;AAqDA;;;;;;;;;AASA;;;;;;;;;;;iBATgB,QAAA,CAAS,IAAA,UAAc,MAAA,GAAQ,cAAA;;;;;;iBAS/B,WAAA,CAAY,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,cAAA,GAAwB,SAAA"}
1
+ {"version":3,"file":"entities.d.ts","names":[],"sources":["../../src/transformers/entities.ts"],"mappings":";;;;;;;AAsDA;;;;;;;;AAAoE;AASpE;;;;;;;;;;;iBATgB,QAAA,CAAS,IAAA,UAAc,MAAA,GAAQ,cAAqB;;;AASmB;;;iBAAvE,WAAA,CAAY,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,cAAA,GAAwB,SAAA"}
@@ -11,6 +11,7 @@ const DEFAULT_ENTITIES = {
11
11
  "­": "&shy;",
12
12
  "​": "&#8203;",
13
13
  " ": "&#8199;",
14
+ "": "&#65279;",
14
15
  "͏": "&#847;",
15
16
  " ": "&emsp;",
16
17
  "\u2028": "&LineSeparator;",
@@ -1 +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"}
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 '\\uFEFF': '&#65279;',\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,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;AACZ;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,SAAS,MAAc,SAAyB,MAAc;CAC5E,OAAO,UAAU,YAAY,MAAM,IAAI,GAAG,MAAM,CAAC;AACnD;;;;;;AAOA,SAAgB,YAAY,KAAkB,SAAyB,MAAmB;CACxF,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,MAAM,OAAO,WAAW,WAC1BA,OAAM,QAAkC,gBAAgB,IACxD;CAEJ,KAAK,MAAM,SAAS;EAClB,IAAI,KAAK,SAAS,QAChB,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,GAAG,GAC7C,KAAK,OAAO,KAAK,KAAK,MAAM,IAAI,EAAE,KAAK,MAAM;CAGnD,CAAC;CAED,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","names":[],"sources":["../../../src/transformers/filters/defaults.ts"],"mappings":";KAAY,cAAA,IAAkB,GAAA,UAAa,KAAA;AAAA,cAgB9B,QAAA,EAAU,MAAA,SAAe,cAAA"}
1
+ {"version":3,"file":"defaults.d.ts","names":[],"sources":["../../../src/transformers/filters/defaults.ts"],"mappings":";KAAY,cAAA,IAAkB,GAAA,UAAa,KAAa;AAAA,cAgB3C,QAAA,EAAU,MAAM,SAAS,cAAA"}
@@ -1 +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,QAAO;EAUpB,OAAO,WATS,IACb,QAAQ,UAAU,IAAI,CACtB,QAAQ,SAAS,IAAI,CACrB,QAAQ,SAAS,IAAI,CACrB,QAAQ,UAAU,KAAI,CACtB,QAAQ,WAAW,KAAI,CACvB,QAAQ,UAAU,IAAI,CACtB,QAAQ,WAAW,IAEG,CA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AAO,MAAM,KAAK,MAAM,IAAI,MAAM,GAAG,EAAE,GAAG,cAAc,IAAI,MAAM,IAAI,OAAO,OAAO;;CAEtF,OAAM,QAAO,OAAO,IAAI,OAAO;CAC/B,QAAQ,KAAK,UAAU;EACrB,MAAM,OAAO,MAAM,MAAM,IAAI,CAAC,KAAI,MAAK,OAAO,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC;EACrE,OAAO,IAAI,MAAM,KAAK,IAAI,KAAK,GAAG;;CAEpC,WAAW,KAAK,UAAU;EACxB,MAAM,aAAa,MAAM,QAAQ,IAAI;EACrC,MAAM,SAAS,OAAO,SAAS,eAAe,KAAK,QAAQ,MAAM,MAAM,GAAG,WAAW,EAAE,GAAG;EAC1F,MAAM,WAAW,eAAe,KAAK,QAAQ,MAAM,MAAM,aAAa,EAAE;EAExE,IAAI,IAAI,UAAU,QAAQ,OAAO;EAEjC,OAAO,IAAI,MAAM,GAAG,OAAO,GAAG;;CAEhC,mBAAmB,KAAK,UAAU;EAChC,MAAM,aAAa,MAAM,QAAQ,IAAI;EACrC,MAAM,QAAQ,OAAO,SAAS,eAAe,KAAK,QAAQ,MAAM,MAAM,GAAG,WAAW,EAAE,GAAG;EACzF,MAAM,WAAW,eAAe,KAAK,QAAQ,MAAM,MAAM,aAAa,EAAE;EACxE,MAAM,QAAQ,IAAI,MAAM,MAAM,CAAC,OAAO,QAAQ;EAE9C,IAAI,MAAM,UAAU,OAAO,OAAO;EAElC,OAAO,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,IAAI,GAAG;;CAE3C,eAAc,QAAO,mBAAmB,IAAI,QAAQ,OAAO,IAAI,CAAC;CAChE,eAAc,QAAO,mBAAmB,IAAI;CAC7C"}
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;AACP;AAEA,MAAM,cAAc;AAEpB,SAAS,WAAW,KAAqB;CACvC,OAAO,IAAI,QAAQ,cAAa,OAAM,UAAU,GAAG;AACrD;AAEA,MAAa,WAA2C;CACtD,SAAS,KAAK,UAAU,MAAM;CAC9B,UAAU,KAAK,UAAU,QAAQ;CACjC,YAAW,QAAO,IAAI,YAAY;CAClC,YAAW,QAAO,IAAI,YAAY;CAClC,aAAY,QAAO,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;CAC5D,OAAM,QAAO,OAAO,KAAK,KAAK,OAAO,WAAW,GAAG,CAAC,CAAC;CACrD,QAAO,QAAO,OAAO,KAAK,MAAM,OAAO,WAAW,GAAG,CAAC,CAAC;CACvD,QAAO,QAAO,OAAO,KAAK,MAAM,OAAO,WAAW,GAAG,CAAC,CA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C3C;CACA,eAAc,QAAO,mBAAmB,IAAI,QAAQ,OAAO,GAAG,CAAC;CAC/D,eAAc,QAAO,mBAAmB,GAAG;AAC7C"}
@@ -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;;;;;;;;;AA2CA;;;;;;;;;AASA;;;;;;;;;iBATgB,OAAA,CAAQ,IAAA,UAAc,MAAA,GAAQ,aAAA;;;;;;iBAS9B,UAAA,CAAW,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,MAAM,UAAU,GAAA,UAAa,KAAA;;AAAjE;;;;;;;;AAA8E;AA2C9E;;;;;;;;AAAgE;AAShE;;;;;;;;;iBATgB,OAAA,CAAQ,IAAA,UAAc,MAAA,GAAQ,aAAkB;;;;;AASmB;iBAAnE,UAAA,CAAW,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,aAAA,GAAqB,SAAA"}
@@ -1 +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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SAAS;;GAE1B;CAEF,OAAO"}
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,MAAM,GAAG;EAChC,IAAI,cAAc,QAAQ,KAAK,UAAU,QACvC,aAAa,KAAK,UAAyB,QAAQ;EAGrD,SAAS,IAAI;CACf;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,MAAc,SAAwB,CAAC,GAAW;CACxE,OAAO,UAAU,WAAW,MAAM,IAAI,GAAG,MAAM,CAAC;AAClD;;;;;;AAOA,SAAgB,WAAW,KAAkB,SAAwB,CAAC,GAAgB;CACpF,IAAI,WAAW,OAAO,OAAO;CAE7B,MAAM,aAAa;EAAE,GAAG;EAAU,GAAG;CAAO;CAC5C,MAAM,cAAc,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC;CAEnD,aAAa,MAAM,SAAS;EAC1B,MAAM,KAAK;EAEX,IAAI,CAAC,GAAG,SAAS;EAGjB,MAAM,UAAkD,CAAC;EAEzD,KAAK,MAAM,QAAQ,OAAO,KAAK,GAAG,OAAO,GACvC,IAAI,YAAY,IAAI,IAAI,GACtB,QAAQ,KAAK;GAAE,MAAM;GAAM,OAAO,GAAG,QAAQ;EAAM,CAAC;EAIxD,IAAI,QAAQ,WAAW,GAAG;EAG1B,IAAI,UAAU,UAAU,GAAG,QAAuB;EAGlD,KAAK,MAAM,EAAE,MAAM,WAAW,SAAS;GACrC,UAAU,WAAW,MAAM,SAAS,KAAK;GACzC,OAAO,GAAG,QAAQ;EACpB;EAGA,IAAI,YAAY,IACd,GAAG,WAAW,CAAC;OACV,IAAI,YAAY,KAAK,OAAO,GAAG;GAEpC,MAAM,cAAc,MAAM,OAAO;GAEjC,KAAK,MAAM,SAAS,aAClB,MAAM,SAAS;GAGjB,GAAG,WAAW;EAChB,OAAO;GAEL,MAAM,WAAW,IAAI,KAAK,OAAO;GACjC,SAAS,SAAS;GAClB,GAAG,WAAW,CAAC,QAAQ;EACzB;CACF,CAAC;CAED,OAAO;AACT"}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"format.d.ts","names":[],"sources":["../../src/transformers/format.ts"],"mappings":";;;;AA2BA;;;;;;;;;AAAgF;;;;;iBAA1D,MAAA,CAAO,IAAA,UAAc,OAAA,GAAS,eAAA,GAAqB,OAAO"}
@@ -1 +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"}
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;AAC9B;;;;;;;;;;;;;;;;AAiBA,eAAsB,OAAO,MAAc,UAAyB,CAAC,GAAoB;CAGvF,QAAO,MADcA,SAAM,cAAc,MAD1BC,OAAM,SAAS,eACsB,CAAC,GACvC;AAChB"}