mancha 0.23.1 → 0.24.1

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 (78) hide show
  1. package/README.md +25 -7
  2. package/dist/browser.d.ts +454 -3
  3. package/dist/browser.js +32 -1
  4. package/dist/css_custom.d.ts +1 -1
  5. package/dist/css_custom.js +44 -11
  6. package/dist/css_custom.js.map +1 -1
  7. package/dist/css_gen_utils.d.ts +8 -915
  8. package/dist/css_gen_utils.js +382 -641
  9. package/dist/css_gen_utils.js.map +1 -1
  10. package/dist/mancha.js +25 -36
  11. package/dist/plugins.js +11 -1
  12. package/dist/plugins.js.map +1 -1
  13. package/dist/renderer.js +5 -1
  14. package/dist/renderer.js.map +1 -1
  15. package/dist/store.d.ts +38 -2
  16. package/dist/store.js +215 -35
  17. package/dist/store.js.map +1 -1
  18. package/dist/trusted_attributes.d.ts +0 -3
  19. package/dist/trusted_attributes.js +1 -3
  20. package/dist/trusted_attributes.js.map +1 -1
  21. package/docs/02_initialization.md +2 -2
  22. package/docs/03_reactivity.md +26 -3
  23. package/docs/05_css.md +314 -282
  24. package/package.json +19 -4
  25. package/.biomeignore +0 -3
  26. package/.github/workflows/ci.yml +0 -109
  27. package/.vscode/extensions.json +0 -3
  28. package/.vscode/launch.json +0 -34
  29. package/biome.json +0 -46
  30. package/dist/browser.js.map +0 -1
  31. package/dist/expressions/ast.test.d.ts +0 -1
  32. package/dist/expressions/ast.test.js +0 -147
  33. package/dist/expressions/ast.test.js.map +0 -1
  34. package/dist/expressions/ast_factory.test.d.ts +0 -1
  35. package/dist/expressions/ast_factory.test.js +0 -94
  36. package/dist/expressions/ast_factory.test.js.map +0 -1
  37. package/dist/expressions/constants.test.d.ts +0 -1
  38. package/dist/expressions/constants.test.js +0 -84
  39. package/dist/expressions/constants.test.js.map +0 -1
  40. package/dist/expressions/eval.test.d.ts +0 -1
  41. package/dist/expressions/eval.test.js +0 -215
  42. package/dist/expressions/eval.test.js.map +0 -1
  43. package/dist/expressions/expressions.test.d.ts +0 -6
  44. package/dist/expressions/expressions.test.js +0 -7
  45. package/dist/expressions/expressions.test.js.map +0 -1
  46. package/dist/expressions/parser.test.d.ts +0 -1
  47. package/dist/expressions/parser.test.js +0 -174
  48. package/dist/expressions/parser.test.js.map +0 -1
  49. package/dist/expressions/tokenizer.test.d.ts +0 -1
  50. package/dist/expressions/tokenizer.test.js +0 -124
  51. package/dist/expressions/tokenizer.test.js.map +0 -1
  52. package/dist/interfaces-DhL-_vL-.d.ts +0 -423
  53. package/dist/mancha.js.map +0 -1
  54. package/dist/renderer-1jqgJa7K.js +0 -43
  55. package/dist/safe_browser.d.ts +0 -16
  56. package/dist/safe_browser.js +0 -1
  57. package/dist/safe_browser.js.map +0 -1
  58. package/dist/test_types/api.d.ts +0 -11
  59. package/dist/test_types/api.js +0 -3
  60. package/dist/test_types/api.js.map +0 -1
  61. package/dist/test_types/nested/child.d.ts +0 -12
  62. package/dist/test_types/nested/child.js +0 -2
  63. package/dist/test_types/nested/child.js.map +0 -1
  64. package/dist/test_types/product.d.ts +0 -11
  65. package/dist/test_types/product.js +0 -3
  66. package/dist/test_types/product.js.map +0 -1
  67. package/dist/test_types/user.d.ts +0 -10
  68. package/dist/test_types/user.js +0 -3
  69. package/dist/test_types/user.js.map +0 -1
  70. package/dist/test_utils.d.ts +0 -20
  71. package/dist/test_utils.js +0 -94
  72. package/dist/test_utils.js.map +0 -1
  73. package/global.d.ts +0 -4
  74. package/gulpfile.ts +0 -47
  75. package/scripts/generate-css-docs.ts +0 -582
  76. package/tsconfig.json +0 -37
  77. package/tsdown.config.ts +0 -32
  78. package/tsec_exemptions.json +0 -9
@@ -1,582 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import rules, {
4
- COLOR_OPACITY_MODIFIERS,
5
- DURATIONS,
6
- MEDIA_BREAKPOINTS,
7
- PERCENTS,
8
- PROPS_COLORS,
9
- PROPS_CUSTOM,
10
- PROPS_SIZING,
11
- PROPS_SIZING_MINMAX,
12
- PROPS_SPACING,
13
- } from "../src/css_gen_utils.js";
14
-
15
- const DOCS_PATH = path.join(process.cwd(), "docs", "05_css.md");
16
-
17
- function handledBySize(klass: string) {
18
- return klass.startsWith("text-") && (klass.endsWith("px") || klass.endsWith("rem"));
19
- }
20
-
21
- function generateMarkdown() {
22
- let md = "# CSS Documentation\n\n";
23
-
24
- md +=
25
- "Mancha provides a set of CSS utilities and minimal styles to help you build your application.\n\n";
26
-
27
- md += "## Minimal CSS\n\n";
28
- md +=
29
- 'The minimal CSS rules provide a clean, readable default style for standard HTML elements. You can inject them using `injectCss(["minimal"])` or by adding `css="minimal"` to your script tag.\n\n';
30
- md += "### Reset & Defaults\n";
31
- md += "- **Max Width**: 70ch (centered)\n";
32
- md += "- **Padding**: 2em 1em\n";
33
- md += "- **Line Height**: 1.75\n";
34
- md += "- **Font Family**: sans-serif\n";
35
- md += "- **H1-H6 Margin**: 1em 0 0.5em\n";
36
- md += "- **P, UL, OL Margin Bottom**: 1em\n\n";
37
-
38
- md += "## Basic CSS\n\n";
39
- md +=
40
- 'The basic CSS rules provide a more comprehensive reset and set of defaults, widely based on Tailwind CSS Preflight. You can inject them using `injectCss(["basic"])` or by adding `css="basic"` to your script tag.\n\n';
41
- md += "### Key Features\n";
42
- md += "- **Box Sizing**: `border-box` globally\n";
43
- md += "- **Typography**: Default sans-serif font stack, consistent line-height\n";
44
- md +=
45
- "- **Form Elements**: Inherit font styles, transparent backgrounds, `cursor: pointer` for buttons\n";
46
- md += "- **Media**: Images/videos max-width 100%\n";
47
- md += "- **Dialog**: Default backdrop styling\n";
48
- md += "- **Resets**: Removes default margins/paddings from most block elements\n\n";
49
-
50
- md += "## Utility CSS\n\n";
51
- md +=
52
- 'The utility CSS rules are inspired by Tailwind CSS. You can inject them using `injectCss(["utils"])` or by adding `css="utils"` to your script tag.\n\n';
53
- md += "This automatically includes:\n";
54
- md +=
55
- "- **CSS Reset** (Tailwind Preflight): box-sizing, typography, form resets, media defaults\n";
56
- md += "- **Base utility classes**: spacing, sizing, colors, layout, typography, and more\n";
57
- md +=
58
- "- **On-demand scanning**: responsive variants, orientation variants, pseudo-state variants, color opacity, custom bracket values, and dark mode are generated on-the-fly for only the classes actually used in your markup\n\n";
59
-
60
- md += "### Media Breakpoints\n\n";
61
- md += "| Prefix | Min Width |\n";
62
- md += "| --- | --- |\n";
63
- for (const [bp, width] of Object.entries(MEDIA_BREAKPOINTS)) {
64
- md += `| \`${bp}:\` | \`${width}px\` |\n`;
65
- }
66
- md += "\n";
67
-
68
- md += "### Orientation\n\n";
69
- md +=
70
- "Use the `landscape:` and `portrait:` prefixes to apply styles based on screen orientation (`@media (orientation: …)`) rather than width, so layouts respond to device rotation without picking an arbitrary breakpoint:\n\n";
71
- md += "```html\n";
72
- md += "<!-- Stack vertically in portrait, side-by-side in landscape. -->\n";
73
- md += '<div class="flex flex-col landscape:flex-row">\n';
74
- md += ' <div class="board">...</div>\n';
75
- md += ' <div class="moves-panel portrait:hidden">...</div>\n';
76
- md += "</div>\n";
77
- md += "```\n\n";
78
-
79
- md += "### Pseudo States\n\n";
80
- md += "The following pseudo states are supported for all utilities:\n";
81
- md += "- `hover:`\n";
82
- md += "- `focus:`\n";
83
- md += "- `disabled:`\n\n";
84
-
85
- md += "### Dark Mode\n\n";
86
- md += `Use the \`dark:\` prefix to apply styles when the user's system prefers dark mode (\`prefers-color-scheme: dark\`):\n\n`;
87
- md += "```html\n";
88
- md += '<div class="bg-white text-gray-900 dark:bg-gray-900 dark:text-white">\n';
89
- md += " This adapts to the user's color scheme preference.\n";
90
- md += "</div>\n";
91
- md += "```\n\n";
92
- md += `The \`dark:\` prefix can be used with any utility class, including colors, spacing, and custom bracket values:\n\n`;
93
- md += "```html\n";
94
- md += '<div class="bg-[#fff] dark:bg-[#1a1a1a] p-4 dark:border-gray-700">\n';
95
- md += "```\n\n";
96
- md += `> **Note:** Responsive variants (\`sm:\`, \`md:\`, etc.), orientation variants (\`landscape:\`, \`portrait:\`), pseudo-state variants (\`hover:\`, \`focus:\`, \`disabled:\`), color opacity (\`/N\`), dark mode (\`dark:\`), and custom bracket values are all generated on-demand. Only the classes actually present in your markup are injected, keeping the CSS bundle small.\n\n`;
97
-
98
- md += "### Spacing (Margin & Padding)\n\n";
99
- md += "Spacing utilities use a 0.25rem (4px) unit by default.\n\n";
100
- md += "| Prefix | Property | Values |\n";
101
- md += "| --- | --- | --- |\n";
102
- for (const [prop, prefix] of Object.entries(PROPS_SPACING)) {
103
- md += `| \`${prefix}-\` | \`${prop}\` | \`0\`, \`0.25rem\` - \`128rem\` (and negative versions) |\n`;
104
- md += `| \`${prefix}x-\` | \`${prop}-left/right\` | Same as above |\n`;
105
- md += `| \`${prefix}y-\` | \`${prop}-top/bottom\` | Same as above |\n`;
106
- md += `| \`${prefix}t-\` | \`${prop}-top\` | Same as above |\n`;
107
- md += `| \`${prefix}b-\` | \`${prop}-bottom\` | Same as above |\n`;
108
- md += `| \`${prefix}l-\` | \`${prop}-left\` | Same as above |\n`;
109
- md += `| \`${prefix}r-\` | \`${prop}-right\` | Same as above |\n`;
110
- }
111
- md += "\n";
112
-
113
- md += "### Sizing (Width & Height)\n\n";
114
- md += "| Prefix | Property | Values |\n";
115
- md += "| --- | --- | --- |\n";
116
- for (const [prop, prefix] of Object.entries(PROPS_SIZING)) {
117
- md += `| \`${prefix}-\` | \`${prop}\` | \`0\`, \`full\` (100%), \`screen\` (100vw/vh), \`auto\`, \`px\`, \`0.25rem\` - \`128rem\` |\n`;
118
- md += `| \`${prefix}-sm/md/lg/xl\` | \`${prop}\` | Match media breakpoints (e.g. \`w-sm\`, \`max-w-lg\`) |\n`;
119
- md += `| \`${prefix}-dvw/dvh/svw/svh/lvw/lvh\` | \`${prop}\` | Viewport-relative units |\n`;
120
- md += `| \`${prefix}-fit/min/max\` | \`${prop}\` | \`fit-content\`, \`min-content\`, \`max-content\` |\n`;
121
- }
122
- for (const [prop, prefix] of Object.entries(PROPS_SIZING_MINMAX)) {
123
- md += `| \`${prefix}-\` | \`${prop}\` | Same as sizing |\n`;
124
- }
125
- md +=
126
- "| `size-` | `width` & `height` | `auto`, `px`, `full`, `dvw`, `dvh`, `svw`, `svh`, `lvw`, `lvh`, `min`, `max`, `fit` |\n";
127
- md += "\n";
128
-
129
- md += "### Colors\n\n";
130
- md += "Supported prefixes: `text-`, `bg-`, `border-`, `fill-`.\n\n";
131
- md += "| Color | Shades |\n";
132
- md += "| --- | --- |\n";
133
- md += "| `white`, `black`, `transparent` | N/A |\n";
134
- for (const [color, _shades] of Object.entries(PROPS_COLORS)) {
135
- md += `| \`${color}\` | \`50\`, \`100\`, \`200\`, \`300\`, \`400\`, \`500\`, \`600\`, \`700\`, \`800\`, \`900\` |\n`;
136
- }
137
- md += "\n";
138
- md += `You can also control the opacity of any color utility by appending \`/{opacity}\` (${COLOR_OPACITY_MODIFIERS.join(", ")}):\n`;
139
- md += "- `bg-black/50`\n";
140
- md += "- `text-red-500/20`\n";
141
- md += "- `border-blue-600/100`\n";
142
- md += "\n";
143
-
144
- md += "### Borders & Corners\n\n";
145
- md += "| Utility | Description |\n";
146
- md += "| --- | --- |\n";
147
- const borderProps = ["border", "rounded"];
148
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
149
- if (borderProps.some((p) => klass.startsWith(p))) {
150
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
151
- }
152
- }
153
- // Document dynamic border widths
154
- md +=
155
- "| `border-{0-15}` | Border width in pixels (e.g., `border-0`, `border-1`, ..., `border-15`) |\n";
156
- md += "| `border-x-{0-15}` | Horizontal border width in pixels |\n";
157
- md += "| `border-y-{0-15}` | Vertical border width in pixels |\n";
158
- md += "| `border-{t,b,l,r}-{0-15}` | Individual side border width in pixels |\n";
159
- md += "\n";
160
-
161
- md += "### Shadows & Effects\n\n";
162
- md += "| Utility | Description |\n";
163
- md += "| --- | --- |\n";
164
- const effectProps = ["shadow", "ring", "mix-blend-"];
165
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
166
- if (effectProps.some((p) => klass.startsWith(p))) {
167
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
168
- }
169
- }
170
- // Document opacity
171
- md += "| `opacity-0` | Fully transparent |\n";
172
- md += `| \`opacity-{${PERCENTS.join(",")}}\` | Opacity values (multiples of 5) |\n`;
173
- md += "\n";
174
-
175
- md += "### Outline\n\n";
176
- md += "| Utility | Description |\n";
177
- md += "| --- | --- |\n";
178
- const outlineProps = ["outline"];
179
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
180
- if (outlineProps.some((p) => klass.startsWith(p))) {
181
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
182
- }
183
- }
184
- md += "\n";
185
-
186
- md += "### Aspect Ratio\n\n";
187
- md += "| Utility | Description |\n";
188
- md += "| --- | --- |\n";
189
- const aspectProps = ["aspect-"];
190
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
191
- if (aspectProps.some((p) => klass.startsWith(p))) {
192
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
193
- }
194
- }
195
- md += "\n";
196
-
197
- md += "### Backdrop Filters\n\n";
198
- md += "| Utility | Description |\n";
199
- md += "| --- | --- |\n";
200
- const backdropProps = ["backdrop-"];
201
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
202
- if (backdropProps.some((p) => klass.startsWith(p))) {
203
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
204
- }
205
- }
206
- md += "\n";
207
-
208
- md += "### Transitions & Animations\n\n";
209
- md += "| Utility | Description |\n";
210
- md += "| --- | --- |\n";
211
- const animProps = ["transition", "animate-"];
212
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
213
- if (animProps.some((p) => klass.startsWith(p))) {
214
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
215
- }
216
- }
217
- // Document durations
218
- md += `| \`duration-{${DURATIONS.join(",")}}\` | Transition duration in milliseconds |\n`;
219
- md += "\n";
220
-
221
- md += "### Interactivity\n\n";
222
- md += "| Utility | Description |\n";
223
- md += "| --- | --- |\n";
224
- const interProps = ["cursor-", "select-", "pointer-events-", "resize", "user-select"];
225
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
226
- if (interProps.some((p) => klass.startsWith(p))) {
227
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
228
- }
229
- }
230
- md += "\n";
231
-
232
- md += "### Typography\n\n";
233
- md += "| Utility | Description |\n";
234
- md += "| --- | --- |\n";
235
- const typoProps = [
236
- "font-",
237
- "text-",
238
- "italic",
239
- "not-italic",
240
- "leading-",
241
- "tracking-",
242
- "uppercase",
243
- "lowercase",
244
- "capitalize",
245
- "truncate",
246
- "whitespace-",
247
- "decoration-",
248
- "underline",
249
- "line-through",
250
- ];
251
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
252
- if (typoProps.some((p) => klass.startsWith(p)) && !handledBySize(klass)) {
253
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
254
- }
255
- }
256
- md += "\n";
257
-
258
- md += "### Flexbox & Layout\n\n";
259
- md += "| Utility | Description |\n";
260
- md += "| --- | --- |\n";
261
- const flexProps = [
262
- "flex",
263
- "justify-",
264
- "items-",
265
- "self-",
266
- "content-",
267
- "grow",
268
- "shrink",
269
- "gap-",
270
- "order-",
271
- "grid-",
272
- ];
273
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
274
- if (flexProps.some((p) => klass.startsWith(p))) {
275
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
276
- }
277
- }
278
- // Document gap utilities
279
- md += "| `gap-0` | No gap |\n";
280
- md += "| `gap-{1-512}` | Gap in rem units (0.25rem increments) |\n";
281
- md += "| `gap-{1-512}px` | Gap in pixels |\n";
282
- md += "| `gap-x-{1-512}` | Horizontal gap in rem units |\n";
283
- md += "| `gap-y-{1-512}` | Vertical gap in rem units |\n";
284
- md += "| `gap-x-{1-512}px` | Horizontal gap in pixels |\n";
285
- md += "| `gap-y-{1-512}px` | Vertical gap in pixels |\n";
286
- md += "| `space-x-{0-512}` | Horizontal spacing between children (rem) |\n";
287
- md += "| `space-y-{0-512}` | Vertical spacing between children (rem) |\n";
288
- md += "| `space-x-{0-512}px` | Horizontal spacing between children (px) |\n";
289
- md += "| `space-y-{0-512}px` | Vertical spacing between children (px) |\n";
290
- // Document divide utilities
291
- md += "| `divide-x` | Add 1px vertical border between horizontal children |\n";
292
- md += "| `divide-y` | Add 1px horizontal border between vertical children |\n";
293
- md += "| `divide-x-{0,2,4,8}` | Vertical border width between horizontal children |\n";
294
- md += "| `divide-y-{0,2,4,8}` | Horizontal border width between vertical children |\n";
295
- md += "| `divide-solid` | Solid border style for dividers |\n";
296
- md += "| `divide-dashed` | Dashed border style for dividers |\n";
297
- md += "| `divide-dotted` | Dotted border style for dividers |\n";
298
- md += "| `divide-none` | Remove divider borders |\n";
299
- md += "\n";
300
-
301
- md += "### Grid Layout\n\n";
302
- md += "| Utility | Description |\n";
303
- md += "| --- | --- |\n";
304
-
305
- // Static grid properties from PROPS_CUSTOM if any (like 'grid')
306
- const gridProps = ["grid"];
307
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
308
- if (gridProps.some((p) => klass === p)) {
309
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
310
- }
311
- }
312
-
313
- md += "| `grid-cols-{1-12}` | `grid-template-columns: repeat(n, minmax(0, 1fr))` |\n";
314
- md += "| `grid-cols-none` | `grid-template-columns: none` |\n";
315
- md += "| `col-span-{1-12}` | `grid-column: span n / span n` |\n";
316
- md += "| `col-span-full` | `grid-column: 1 / -1` |\n";
317
- md += "| `col-start-{1-13}` | `grid-column-start: n` |\n";
318
- md += "| `col-end-{1-13}` | `grid-column-end: n` |\n";
319
- md += "| `col-start/end-auto` | `grid-column-start/end: auto` |\n";
320
- md += "| `grid-rows-{1-12}` | `grid-template-rows: repeat(n, minmax(0, 1fr))` |\n";
321
- md += "| `grid-rows-none` | `grid-template-rows: none` |\n";
322
- md += "| `row-span-{1-12}` | `grid-row: span n / span n` |\n";
323
- md += "| `row-span-full` | `grid-row: 1 / -1` |\n";
324
- md += "| `row-start-{1-13}` | `grid-row-start: n` |\n";
325
- md += "| `row-end-{1-13}` | `grid-row-end: n` |\n";
326
- md += "| `row-start/end-auto` | `grid-row-start/end: auto` |\n";
327
- md += "\n";
328
-
329
- md += "### Position & Inset\n\n";
330
- md += "| Utility | Description |\n";
331
- md += "| --- | --- |\n";
332
- const posProps = ["relative", "absolute", "fixed", "sticky", "inset-", "object-"];
333
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
334
- if (posProps.some((p) => klass.startsWith(p))) {
335
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
336
- }
337
- }
338
- // Document position values
339
- md +=
340
- "| `top-{0-512}`, `bottom-{0-512}`, `left-{0-512}`, `right-{0-512}` | Position in rem units (0.25rem increments) |\n";
341
- md +=
342
- "| `top-{0-512}px`, `bottom-{0-512}px`, `left-{0-512}px`, `right-{0-512}px` | Position in pixels |\n";
343
- md +=
344
- "| `top-{1-100}%`, `bottom-{1-100}%`, `left-{1-100}%`, `right-{1-100}%` | Position in percentages |\n";
345
- md += "| `top-auto`, `bottom-auto`, `left-auto`, `right-auto` | Auto positioning |\n";
346
- // Document z-index
347
- md += `| \`z-{${PERCENTS.join(",")}}\` | Z-index values |\n`;
348
- md += "\n";
349
-
350
- md += "### Display & Visibility\n\n";
351
- md += "| Utility | Description |\n";
352
- md += "| --- | --- |\n";
353
- const displayProps = [
354
- "block",
355
- "inline",
356
- "hidden",
357
- "contents",
358
- "visible",
359
- "invisible",
360
- "collapse",
361
- ];
362
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
363
- if (displayProps.some((p) => klass === p)) {
364
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
365
- }
366
- }
367
- md += "\n";
368
-
369
- md += "### Overflow & Scrolling\n\n";
370
- md += "| Utility | Description |\n";
371
- md += "| --- | --- |\n";
372
- const overflowProps = ["overflow-", "overscroll-"];
373
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
374
- if (overflowProps.some((p) => klass.startsWith(p))) {
375
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
376
- }
377
- }
378
- md += "\n";
379
-
380
- md += "### Backgrounds\n\n";
381
- md += "| Utility | Description |\n";
382
- md += "| --- | --- |\n";
383
- const bgProps = [
384
- "bg-auto",
385
- "bg-cover",
386
- "bg-contain",
387
- "bg-center",
388
- "bg-top",
389
- "bg-bottom",
390
- "bg-left",
391
- "bg-right",
392
- "bg-left-top",
393
- "bg-left-bottom",
394
- "bg-right-top",
395
- "bg-right-bottom",
396
- "bg-no-repeat",
397
- "bg-fixed",
398
- "bg-local",
399
- "bg-scroll",
400
- ];
401
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
402
- if (bgProps.some((p) => klass === p)) {
403
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
404
- }
405
- }
406
- md += "\n";
407
-
408
- md += "### Lists\n\n";
409
- md += "| Utility | Description |\n";
410
- md += "| --- | --- |\n";
411
- const listProps = ["list-"];
412
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
413
- if (listProps.some((p) => klass.startsWith(p))) {
414
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
415
- }
416
- }
417
- md += "\n";
418
-
419
- md += "### Vertical Alignment\n\n";
420
- md += "| Utility | Description |\n";
421
- md += "| --- | --- |\n";
422
- const alignProps = ["align-"];
423
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
424
- if (alignProps.some((p) => klass.startsWith(p))) {
425
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
426
- }
427
- }
428
- md += "\n";
429
-
430
- md += "### Viewport Sizing\n\n";
431
- md += "| Utility | Description |\n";
432
- md += "| --- | --- |\n";
433
- const viewportProps = [
434
- "min-h-screen",
435
- "max-h-screen",
436
- "min-w-screen",
437
- "h-dvh",
438
- "h-svh",
439
- "h-lvh",
440
- "w-dvw",
441
- "w-svw",
442
- "w-lvw",
443
- "min-h-dvh",
444
- "min-h-svh",
445
- "min-h-lvh",
446
- ];
447
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
448
- if (viewportProps.some((p) => klass === p)) {
449
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
450
- }
451
- }
452
- md += "\n";
453
-
454
- md += "### Accessibility\n\n";
455
- md += "| Utility | Description |\n";
456
- md += "| --- | --- |\n";
457
- const a11yProps = ["sr-only", "not-sr-only"];
458
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
459
- if (a11yProps.some((p) => klass === p)) {
460
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
461
- }
462
- }
463
- md += "\n";
464
-
465
- md += "### Other Utilities\n\n";
466
- md += "| Utility | Description |\n";
467
- md += "| --- | --- |\n";
468
- const allHandledPrefixes = [
469
- ...typoProps,
470
- ...flexProps,
471
- ...posProps,
472
- ...borderProps,
473
- ...effectProps,
474
- ...animProps,
475
- ...interProps,
476
- ...displayProps,
477
- ...overflowProps,
478
- ...bgProps,
479
- ...listProps,
480
- ...alignProps,
481
- ...a11yProps,
482
- ...viewportProps,
483
- ...outlineProps,
484
- ...aspectProps,
485
- ...backdropProps,
486
- "w-",
487
- "h-",
488
- "min-w-",
489
- "min-h-",
490
- "max-w-",
491
- "max-h-",
492
- "bg-",
493
- "border-",
494
- "opacity-",
495
- "cursor-",
496
- "size-",
497
- "top-",
498
- "bottom-",
499
- "left-",
500
- "right-",
501
- "z-",
502
- "duration-",
503
- "gap-",
504
- "space-",
505
- "divide-",
506
- "grid-",
507
- "col-",
508
- ];
509
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
510
- if (!allHandledPrefixes.some((p) => klass.startsWith(p) || klass === p)) {
511
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
512
- }
513
- }
514
- // Document text sizes
515
- md += "| `text-{0-99}px` | Font size in pixels (e.g., `text-12px`, `text-16px`) |\n";
516
- md += "| `text-{0-24.75}rem` | Font size in rem units (0.25rem increments) |\n";
517
- md += "\n";
518
-
519
- md += "## Custom Values\n\n";
520
- md += `When you need a value outside the design scale, use bracket notation as an escape hatch. Custom values are automatically supported when using \`css="utils"\` — no extra configuration needed.\n\n`;
521
- md += "### Syntax\n\n";
522
- md += "```html\n";
523
- md += '<div class="w-[133px] mt-[2rem] max-w-[900px]">\n';
524
- md += "```\n\n";
525
- md += "### Supported Properties\n\n";
526
- md += "| Prefix | CSS Property |\n";
527
- md += "|--------|--------------|\n";
528
- md += "| `w-` | width |\n";
529
- md += "| `h-` | height |\n";
530
- md += "| `min-w-`, `min-h-` | min-width, min-height |\n";
531
- md += "| `max-w-`, `max-h-` | max-width, max-height |\n";
532
- md += "| `m-`, `mt-`, `mr-`, `mb-`, `ml-` | margin |\n";
533
- md += "| `mx-`, `my-` | margin-inline, margin-block |\n";
534
- md += "| `p-`, `pt-`, `pr-`, `pb-`, `pl-` | padding |\n";
535
- md += "| `px-`, `py-` | padding-inline, padding-block |\n";
536
- md += "| `top`, `right`, `bottom`, `left` | positioning |\n";
537
- md += "| `gap-`, `gap-x-`, `gap-y-` | gap |\n";
538
- md += "| `text-` | font-size |\n";
539
- md += "| `z-` | z-index |\n";
540
- md += "| `bg-` | background-color |\n";
541
- md += "| `border-` | border-color |\n";
542
- md += "\n";
543
- md += "### Variants\n\n";
544
- md += "Custom values support pseudo-states, responsive breakpoints, and dark mode:\n\n";
545
- md += "```html\n";
546
- md += '<div class="hover:w-[200px] md:max-w-[900px] dark:bg-[#333]">\n';
547
- md += "```\n\n";
548
- md += "### Limitations\n\n";
549
- md += "**Static classes only**: Custom values work with the `class` attribute, not `:class`:\n\n";
550
- md += "```html\n";
551
- md += "<!-- ✓ Works -->\n";
552
- md += '<div class="w-[133px]">\n\n';
553
- md += "<!-- ✗ Not supported - use inline styles instead -->\n";
554
- md += `<div :class="'w-[133px]'">\n`;
555
- md += `<div :attr:style="'width: ' + dynamicWidth">\n`;
556
- md += "```\n\n";
557
- md +=
558
- "**Browser only**: Custom values require the CSSStyleSheet API and are not available in Worker or SSR environments.\n\n";
559
- md += "### When to Use\n\n";
560
- md += "**Prefer the design scale** for consistency. Use custom values for:\n";
561
- md += "- Matching external constraints (third-party widgets, embeds)\n";
562
- md += "- One-off pixel-perfect adjustments\n";
563
- md += "- Rapid prototyping (replace with scale values later)\n\n";
564
- md += "### Dynamic Content\n\n";
565
- md +=
566
- 'For content added after initial load, call `injectCss(["custom"])` again to scan and inject new on-demand values.\n\n';
567
-
568
- md += "--- \n\n*Generated automatically from `src/css_gen_utils.ts`*\n";
569
-
570
- return md;
571
- }
572
-
573
- // Generate CSS and calculate stats
574
- const css = rules();
575
- const ruleCount = (css.match(/\{[^}]+\}/g) || []).length;
576
- const sizeBytes = css.length;
577
- const sizeKB = (sizeBytes / 1024).toFixed(1);
578
- const sizeMB = (sizeBytes / 1024 / 1024).toFixed(2);
579
-
580
- fs.writeFileSync(DOCS_PATH, generateMarkdown());
581
- console.log(`Documentation generated at ${DOCS_PATH}`);
582
- console.log(`CSS Stats: ${ruleCount.toLocaleString()} rules, ${sizeKB} KB (${sizeMB} MB)`);
package/tsconfig.json DELETED
@@ -1,37 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "strict": true,
9
- "sourceMap": true,
10
- "declaration": true,
11
- "noImplicitAny": true,
12
- "skipLibCheck": true,
13
- "stripInternal": true,
14
- "esModuleInterop": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "baseUrl": ".",
17
- "paths": {
18
- "mancha": ["./src/index.ts"],
19
- "mancha/*": ["./src/*.ts"]
20
- },
21
- "plugins": [
22
- {
23
- "name": "tsec",
24
- "exemptionConfig": "./tsec_exemptions.json"
25
- }
26
- ]
27
- },
28
- "include": ["src/**/*", "global.d.ts"],
29
- "exclude": [
30
- "scripts",
31
- "examples",
32
- "gulpfile.ts",
33
- "webpack.config.ts",
34
- "webpack.config.esmodule.ts",
35
- "dist"
36
- ]
37
- }
package/tsdown.config.ts DELETED
@@ -1,32 +0,0 @@
1
- import { defineConfig } from "tsdown";
2
-
3
- export default defineConfig([
4
- {
5
- entry: {
6
- mancha: "src/mancha.ts",
7
- },
8
- format: "iife",
9
- clean: false,
10
- target: "es2022",
11
- platform: "browser",
12
- minify: true,
13
- unbundle: false,
14
- skipNodeModulesBundle: false,
15
- noExternal: [/.*/],
16
- globalName: "Mancha",
17
- },
18
- {
19
- entry: {
20
- browser: "src/browser.ts",
21
- safe_browser: "src/safe_browser.ts",
22
- },
23
- format: "esm",
24
- clean: false,
25
- dts: true,
26
- target: "es2022",
27
- platform: "browser",
28
- minify: true,
29
- unbundle: false,
30
- skipNodeModulesBundle: false,
31
- },
32
- ]);
@@ -1,9 +0,0 @@
1
- {
2
- "ban-domparser-parsefromstring": [
3
- "src/browser.ts",
4
- "src/dome.test.ts",
5
- "src/worker.test.ts",
6
- "src/test_utils.ts"
7
- ],
8
- "ban-range-createcontextualfragment": ["src/browser.ts"]
9
- }