mancha 0.24.0 → 0.24.2

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 +26 -7
  2. package/dist/browser.d.ts +451 -2
  3. package/dist/browser.js +32 -1
  4. package/dist/cli.js +3 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/css_gen_utils.d.ts +8 -915
  7. package/dist/css_gen_utils.js +382 -641
  8. package/dist/css_gen_utils.js.map +1 -1
  9. package/dist/mancha.js +25 -36
  10. package/dist/plugins.js +11 -1
  11. package/dist/plugins.js.map +1 -1
  12. package/dist/store.d.ts +8 -1
  13. package/dist/store.js +10 -3
  14. package/dist/store.js.map +1 -1
  15. package/dist/trusted_attributes.d.ts +0 -3
  16. package/dist/trusted_attributes.js +1 -3
  17. package/dist/trusted_attributes.js.map +1 -1
  18. package/docs/01_syntax.md +2 -0
  19. package/docs/03_reactivity.md +20 -3
  20. package/docs/05_css.md +270 -275
  21. package/docs/06_ssr.md +3 -2
  22. package/docs/07_typescript.md +5 -5
  23. package/docs/10_security.md +204 -0
  24. package/package.json +20 -7
  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-C8heJ6BZ.d.ts +0 -452
  53. package/dist/mancha.js.map +0 -1
  54. package/dist/renderer-B4AORGUN.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 -622
  76. package/tsconfig.json +0 -37
  77. package/tsdown.config.ts +0 -32
  78. package/tsec_exemptions.json +0 -9
@@ -1,622 +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 += "## CSS Reset\n\n";
39
- md +=
40
- 'The reset provides a comprehensive set of defaults, widely based on Tailwind CSS Preflight. It ships with the utility classes: adding `css="utils"` to your script tag, or calling `injectCss(["utils"])`, injects both.\n\n';
41
- md += "### Key Features\n";
42
- md += "- **Typography**: Default sans-serif font stack, consistent line-height\n";
43
- md +=
44
- "- **Form Elements**: Inherit font styles and color from their container, with margin and padding zeroed; buttons also get a transparent background and `cursor: pointer`\n";
45
- md += "- **Dialog**: Default backdrop styling\n";
46
- md += "- **Resets**: Removes default margins/paddings from most block elements\n\n";
47
- md += "### Layout Effects\n\n";
48
- md +=
49
- "The reset applies to **all of your markup**, not only to elements carrying utility classes, so plain HTML lays out differently once it is injected. The rules with layout, rather than merely typographic, consequences are:\n\n";
50
- md +=
51
- "- `img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}` — media is no longer inline. `text-align:center` on a parent stops centering it, the inline baseline gap below images disappears, and images no longer flow alongside adjacent text.\n";
52
- md +=
53
- '- `img,video{max-width:100%;height:auto}` — media never overflows its container. `height:auto` also overrides the HTML `height` attribute, so `<img width="300" height="100">` renders at the file\'s own aspect ratio instead of the requested one. Inside a flex row the same clamp lets an image shrink below its intrinsic size.\n';
54
- md +=
55
- "- `*,::before,::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}` — padding and border no longer add to an element's width. Default borders are also stripped, including those set through presentational HTML attributes, so `fieldset`, `iframe`, `img`, and `table` render without one until a border utility is applied. `hr` is the exception: the reset gives it back a 1px top border so horizontal rules stay visible.\n";
56
- md +=
57
- "- `body{margin:0;…}` and `blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}` — the page loses its default gutter and headings, paragraphs, and other blocks no longer space themselves apart, so plain prose collapses into a single run of text until spacing utilities are applied.\n";
58
- md +=
59
- "- `ol,ul,menu{list-style:none;margin:0;padding:0}` — bullets, numbers, and list indentation are gone; restore them with the `list-*` and padding utilities.\n";
60
- md +=
61
- "- `button,input,optgroup,select,textarea{…;margin:0;padding:0}` — form controls lose their native margin and padding on top of inheriting the surrounding font and color, so inputs and text areas render flush against their content and need padding utilities to look clickable.\n";
62
- md +=
63
- "- `button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button;background-color:transparent;background-image:none;cursor:pointer}` — buttons lose their native chrome entirely and must be styled explicitly.\n";
64
- md +=
65
- "- `:disabled{cursor:default;pointer-events:none;opacity:0.75}` — beyond dimming, `pointer-events:none` is a behavioral change: disabled controls stop receiving hover, tooltip, and click handling. Tailwind Preflight only sets `cursor:default` here; the `pointer-events` and `opacity` declarations are mancha additions.\n\n";
66
- md +=
67
- "Opt out per element with utilities, e.g. to stop a flex item from being shrunk by its siblings. The class belongs on the flex item itself — on a nested image it does nothing, because only direct children of the flex container are flex items:\n\n";
68
- md += "```html\n";
69
- md += '<div class="flex">\n';
70
- md += ' <div class="flex-none">\n';
71
- md += ' <img src="logo.svg" />\n';
72
- md += " </div>\n";
73
- md += "</div>\n";
74
- md += "```\n\n";
75
- md +=
76
- "The wrapper then keeps its content width, so the image is not shrunk. `flex-none` on the image itself is not enough even when the image is the direct flex child, because `max-width:100%` clamps it regardless of how flex sizes it. That clamp applies everywhere, not just in flex rows: an image in a container narrower than itself is scaled down to fit. Undo it with the arbitrary value `max-w-[none]` — there is no `max-w-none` utility.\n\n";
77
-
78
- md += "## Utility CSS\n\n";
79
- md +=
80
- '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';
81
- md += "This automatically includes:\n";
82
- md +=
83
- "- **CSS Reset**: box-sizing, typography, form and media defaults applied to all of your markup — see [CSS Reset](#css-reset), in particular the layout effects on images, lists, and form controls\n";
84
- md += "- **Base utility classes**: spacing, sizing, colors, layout, typography, and more\n";
85
- md +=
86
- "- **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";
87
-
88
- md += "### Media Breakpoints\n\n";
89
- md += "| Prefix | Min Width |\n";
90
- md += "| --- | --- |\n";
91
- for (const [bp, width] of Object.entries(MEDIA_BREAKPOINTS)) {
92
- md += `| \`${bp}:\` | \`${width}px\` |\n`;
93
- }
94
- md += "\n";
95
-
96
- md += "### Orientation\n\n";
97
- md +=
98
- "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";
99
- md += "```html\n";
100
- md += "<!-- Stack vertically in portrait, side-by-side in landscape. -->\n";
101
- md += '<div class="flex flex-col landscape:flex-row">\n';
102
- md += ' <div class="board">...</div>\n';
103
- md += ' <div class="moves-panel portrait:hidden">...</div>\n';
104
- md += "</div>\n";
105
- md += "```\n\n";
106
-
107
- md += "### Pseudo States\n\n";
108
- md += "The following pseudo states are supported for all utilities:\n";
109
- md += "- `hover:`\n";
110
- md += "- `focus:`\n";
111
- md += "- `disabled:`\n\n";
112
-
113
- md += "### Dark Mode\n\n";
114
- md += `Use the \`dark:\` prefix to apply styles when the user's system prefers dark mode (\`prefers-color-scheme: dark\`):\n\n`;
115
- md += "```html\n";
116
- md += '<div class="bg-white text-gray-900 dark:bg-gray-900 dark:text-white">\n';
117
- md += " This adapts to the user's color scheme preference.\n";
118
- md += "</div>\n";
119
- md += "```\n\n";
120
- md += `The \`dark:\` prefix can be used with any utility class, including colors, spacing, and custom bracket values:\n\n`;
121
- md += "```html\n";
122
- md += '<div class="bg-[#fff] dark:bg-[#1a1a1a] p-4 dark:border-gray-700">\n';
123
- md += "```\n\n";
124
- 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`;
125
-
126
- md += "### Spacing (Margin & Padding)\n\n";
127
- md += "Spacing utilities use a 0.25rem (4px) unit by default.\n\n";
128
- md += "| Prefix | Property | Values |\n";
129
- md += "| --- | --- | --- |\n";
130
- for (const [prop, prefix] of Object.entries(PROPS_SPACING)) {
131
- md += `| \`${prefix}-\` | \`${prop}\` | \`0\`, \`0.25rem\` - \`128rem\` (and negative versions) |\n`;
132
- md += `| \`${prefix}x-\` | \`${prop}-left/right\` | Same as above |\n`;
133
- md += `| \`${prefix}y-\` | \`${prop}-top/bottom\` | Same as above |\n`;
134
- md += `| \`${prefix}t-\` | \`${prop}-top\` | Same as above |\n`;
135
- md += `| \`${prefix}b-\` | \`${prop}-bottom\` | Same as above |\n`;
136
- md += `| \`${prefix}l-\` | \`${prop}-left\` | Same as above |\n`;
137
- md += `| \`${prefix}r-\` | \`${prop}-right\` | Same as above |\n`;
138
- }
139
- md += "\n";
140
-
141
- md += "### Sizing (Width & Height)\n\n";
142
- md += "| Prefix | Property | Values |\n";
143
- md += "| --- | --- | --- |\n";
144
- for (const [prop, prefix] of Object.entries(PROPS_SIZING)) {
145
- md += `| \`${prefix}-\` | \`${prop}\` | \`0\`, \`full\` (100%), \`screen\` (100vw/vh), \`auto\`, \`px\`, \`0.25rem\` - \`128rem\` |\n`;
146
- md += `| \`${prefix}-sm/md/lg/xl\` | \`${prop}\` | Match media breakpoints (e.g. \`w-sm\`, \`max-w-lg\`) |\n`;
147
- md += `| \`${prefix}-dvw/dvh/svw/svh/lvw/lvh\` | \`${prop}\` | Viewport-relative units |\n`;
148
- md += `| \`${prefix}-fit/min/max\` | \`${prop}\` | \`fit-content\`, \`min-content\`, \`max-content\` |\n`;
149
- }
150
- for (const [prop, prefix] of Object.entries(PROPS_SIZING_MINMAX)) {
151
- md += `| \`${prefix}-\` | \`${prop}\` | Same as sizing |\n`;
152
- }
153
- md +=
154
- "| `size-` | `width` & `height` | `auto`, `px`, `full`, `dvw`, `dvh`, `svw`, `svh`, `lvw`, `lvh`, `min`, `max`, `fit` |\n";
155
- md += "\n";
156
-
157
- md += "### Colors\n\n";
158
- md += "Supported prefixes: `text-`, `bg-`, `border-`, `fill-`.\n\n";
159
- md += "| Color | Shades |\n";
160
- md += "| --- | --- |\n";
161
- md += "| `white`, `black`, `transparent` | N/A |\n";
162
- for (const [color, _shades] of Object.entries(PROPS_COLORS)) {
163
- md += `| \`${color}\` | \`50\`, \`100\`, \`200\`, \`300\`, \`400\`, \`500\`, \`600\`, \`700\`, \`800\`, \`900\` |\n`;
164
- }
165
- md += "\n";
166
- md += `You can also control the opacity of any color utility by appending \`/{opacity}\` (${COLOR_OPACITY_MODIFIERS.join(", ")}):\n`;
167
- md += "- `bg-black/50`\n";
168
- md += "- `text-red-500/20`\n";
169
- md += "- `border-blue-600/100`\n";
170
- md += "\n";
171
-
172
- md += "### Borders & Corners\n\n";
173
- md += "| Utility | Description |\n";
174
- md += "| --- | --- |\n";
175
- const borderProps = ["border", "rounded"];
176
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
177
- if (borderProps.some((p) => klass.startsWith(p))) {
178
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
179
- }
180
- }
181
- // Document dynamic border widths
182
- md +=
183
- "| `border-{0-15}` | Border width in pixels (e.g., `border-0`, `border-1`, ..., `border-15`) |\n";
184
- md += "| `border-x-{0-15}` | Horizontal border width in pixels |\n";
185
- md += "| `border-y-{0-15}` | Vertical border width in pixels |\n";
186
- md += "| `border-{t,b,l,r}-{0-15}` | Individual side border width in pixels |\n";
187
- md += "\n";
188
-
189
- md += "### Shadows & Effects\n\n";
190
- md += "| Utility | Description |\n";
191
- md += "| --- | --- |\n";
192
- const effectProps = ["shadow", "ring", "mix-blend-"];
193
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
194
- if (effectProps.some((p) => klass.startsWith(p))) {
195
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
196
- }
197
- }
198
- // Document opacity
199
- md += "| `opacity-0` | Fully transparent |\n";
200
- md += `| \`opacity-{${PERCENTS.join(",")}}\` | Opacity values (multiples of 5) |\n`;
201
- md += "\n";
202
-
203
- md += "### Outline\n\n";
204
- md += "| Utility | Description |\n";
205
- md += "| --- | --- |\n";
206
- const outlineProps = ["outline"];
207
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
208
- if (outlineProps.some((p) => klass.startsWith(p))) {
209
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
210
- }
211
- }
212
- md += "\n";
213
-
214
- md += "### Aspect Ratio\n\n";
215
- md += "| Utility | Description |\n";
216
- md += "| --- | --- |\n";
217
- const aspectProps = ["aspect-"];
218
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
219
- if (aspectProps.some((p) => klass.startsWith(p))) {
220
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
221
- }
222
- }
223
- md += "\n";
224
-
225
- md += "### Backdrop Filters\n\n";
226
- md += "| Utility | Description |\n";
227
- md += "| --- | --- |\n";
228
- const backdropProps = ["backdrop-"];
229
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
230
- if (backdropProps.some((p) => klass.startsWith(p))) {
231
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
232
- }
233
- }
234
- md += "\n";
235
-
236
- md += "### Transitions & Animations\n\n";
237
- md += "| Utility | Description |\n";
238
- md += "| --- | --- |\n";
239
- const animProps = ["transition", "animate-"];
240
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
241
- if (animProps.some((p) => klass.startsWith(p))) {
242
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
243
- }
244
- }
245
- // Document durations
246
- md += `| \`duration-{${DURATIONS.join(",")}}\` | Transition duration in milliseconds |\n`;
247
- md += "\n";
248
-
249
- md += "### Interactivity\n\n";
250
- md += "| Utility | Description |\n";
251
- md += "| --- | --- |\n";
252
- const interProps = ["cursor-", "select-", "pointer-events-", "resize", "user-select"];
253
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
254
- if (interProps.some((p) => klass.startsWith(p))) {
255
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
256
- }
257
- }
258
- md += "\n";
259
-
260
- md += "### Typography\n\n";
261
- md += "| Utility | Description |\n";
262
- md += "| --- | --- |\n";
263
- const typoProps = [
264
- "font-",
265
- "text-",
266
- "italic",
267
- "not-italic",
268
- "leading-",
269
- "tracking-",
270
- "uppercase",
271
- "lowercase",
272
- "capitalize",
273
- "truncate",
274
- "whitespace-",
275
- "decoration-",
276
- "underline",
277
- "line-through",
278
- ];
279
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
280
- if (typoProps.some((p) => klass.startsWith(p)) && !handledBySize(klass)) {
281
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
282
- }
283
- }
284
- md += "\n";
285
-
286
- md += "### Flexbox & Layout\n\n";
287
- md += "| Utility | Description |\n";
288
- md += "| --- | --- |\n";
289
- const flexProps = [
290
- "flex",
291
- "justify-",
292
- "items-",
293
- "self-",
294
- "content-",
295
- "grow",
296
- "shrink",
297
- "gap-",
298
- "order-",
299
- "grid-",
300
- ];
301
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
302
- if (flexProps.some((p) => klass.startsWith(p))) {
303
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
304
- }
305
- }
306
- // Document gap utilities
307
- md += "| `gap-0` | No gap |\n";
308
- md += "| `gap-{1-512}` | Gap in rem units (0.25rem increments) |\n";
309
- md += "| `gap-{1-512}px` | Gap in pixels |\n";
310
- md += "| `gap-x-{1-512}` | Horizontal gap in rem units |\n";
311
- md += "| `gap-y-{1-512}` | Vertical gap in rem units |\n";
312
- md += "| `gap-x-{1-512}px` | Horizontal gap in pixels |\n";
313
- md += "| `gap-y-{1-512}px` | Vertical gap in pixels |\n";
314
- md += "| `space-x-{0-512}` | Horizontal spacing between children (rem) |\n";
315
- md += "| `space-y-{0-512}` | Vertical spacing between children (rem) |\n";
316
- md += "| `space-x-{0-512}px` | Horizontal spacing between children (px) |\n";
317
- md += "| `space-y-{0-512}px` | Vertical spacing between children (px) |\n";
318
- // Document divide utilities
319
- md += "| `divide-x` | Add 1px vertical border between horizontal children |\n";
320
- md += "| `divide-y` | Add 1px horizontal border between vertical children |\n";
321
- md += "| `divide-x-{0,2,4,8}` | Vertical border width between horizontal children |\n";
322
- md += "| `divide-y-{0,2,4,8}` | Horizontal border width between vertical children |\n";
323
- md += "| `divide-solid` | Solid border style for dividers |\n";
324
- md += "| `divide-dashed` | Dashed border style for dividers |\n";
325
- md += "| `divide-dotted` | Dotted border style for dividers |\n";
326
- md += "| `divide-none` | Remove divider borders |\n";
327
- md += "\n";
328
-
329
- md += "### Grid Layout\n\n";
330
- md += "| Utility | Description |\n";
331
- md += "| --- | --- |\n";
332
-
333
- // Static grid properties from PROPS_CUSTOM if any (like 'grid')
334
- const gridProps = ["grid"];
335
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
336
- if (gridProps.some((p) => klass === p)) {
337
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
338
- }
339
- }
340
-
341
- md += "| `grid-cols-{1-12}` | `grid-template-columns: repeat(n, minmax(0, 1fr))` |\n";
342
- md += "| `grid-cols-none` | `grid-template-columns: none` |\n";
343
- md += "| `col-span-{1-12}` | `grid-column: span n / span n` |\n";
344
- md += "| `col-span-full` | `grid-column: 1 / -1` |\n";
345
- md += "| `col-start-{1-13}` | `grid-column-start: n` |\n";
346
- md += "| `col-end-{1-13}` | `grid-column-end: n` |\n";
347
- md += "| `col-start/end-auto` | `grid-column-start/end: auto` |\n";
348
- md += "| `grid-rows-{1-12}` | `grid-template-rows: repeat(n, minmax(0, 1fr))` |\n";
349
- md += "| `grid-rows-none` | `grid-template-rows: none` |\n";
350
- md += "| `row-span-{1-12}` | `grid-row: span n / span n` |\n";
351
- md += "| `row-span-full` | `grid-row: 1 / -1` |\n";
352
- md += "| `row-start-{1-13}` | `grid-row-start: n` |\n";
353
- md += "| `row-end-{1-13}` | `grid-row-end: n` |\n";
354
- md += "| `row-start/end-auto` | `grid-row-start/end: auto` |\n";
355
- md += "\n";
356
-
357
- md += "### Position & Inset\n\n";
358
- md += "| Utility | Description |\n";
359
- md += "| --- | --- |\n";
360
- const posProps = ["relative", "absolute", "fixed", "sticky", "inset-", "object-"];
361
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
362
- if (posProps.some((p) => klass.startsWith(p))) {
363
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
364
- }
365
- }
366
- // Document position values
367
- md +=
368
- "| `top-{0-512}`, `bottom-{0-512}`, `left-{0-512}`, `right-{0-512}` | Position in rem units (0.25rem increments) |\n";
369
- md +=
370
- "| `top-{0-512}px`, `bottom-{0-512}px`, `left-{0-512}px`, `right-{0-512}px` | Position in pixels |\n";
371
- md +=
372
- "| `top-{1-100}%`, `bottom-{1-100}%`, `left-{1-100}%`, `right-{1-100}%` | Position in percentages |\n";
373
- md += "| `top-auto`, `bottom-auto`, `left-auto`, `right-auto` | Auto positioning |\n";
374
- // Document z-index
375
- md += `| \`z-{${PERCENTS.join(",")}}\` | Z-index values |\n`;
376
- md += "\n";
377
-
378
- md += "### Display & Visibility\n\n";
379
- md += "| Utility | Description |\n";
380
- md += "| --- | --- |\n";
381
- const displayProps = [
382
- "block",
383
- "inline",
384
- "hidden",
385
- "contents",
386
- "visible",
387
- "invisible",
388
- "collapse",
389
- ];
390
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
391
- if (displayProps.some((p) => klass === p)) {
392
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
393
- }
394
- }
395
- md += "\n";
396
-
397
- md += "### Overflow & Scrolling\n\n";
398
- md += "| Utility | Description |\n";
399
- md += "| --- | --- |\n";
400
- const overflowProps = ["overflow-", "overscroll-"];
401
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
402
- if (overflowProps.some((p) => klass.startsWith(p))) {
403
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
404
- }
405
- }
406
- md += "\n";
407
-
408
- md += "### Backgrounds\n\n";
409
- md += "| Utility | Description |\n";
410
- md += "| --- | --- |\n";
411
- const bgProps = [
412
- "bg-auto",
413
- "bg-cover",
414
- "bg-contain",
415
- "bg-center",
416
- "bg-top",
417
- "bg-bottom",
418
- "bg-left",
419
- "bg-right",
420
- "bg-left-top",
421
- "bg-left-bottom",
422
- "bg-right-top",
423
- "bg-right-bottom",
424
- "bg-no-repeat",
425
- "bg-fixed",
426
- "bg-local",
427
- "bg-scroll",
428
- ];
429
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
430
- if (bgProps.some((p) => klass === p)) {
431
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
432
- }
433
- }
434
- md += "\n";
435
-
436
- md += "### Lists\n\n";
437
- md += "| Utility | Description |\n";
438
- md += "| --- | --- |\n";
439
- const listProps = ["list-"];
440
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
441
- if (listProps.some((p) => klass.startsWith(p))) {
442
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
443
- }
444
- }
445
- md += "\n";
446
-
447
- md += "### Vertical Alignment\n\n";
448
- md += "| Utility | Description |\n";
449
- md += "| --- | --- |\n";
450
- const alignProps = ["align-"];
451
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
452
- if (alignProps.some((p) => klass.startsWith(p))) {
453
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
454
- }
455
- }
456
- md += "\n";
457
-
458
- md += "### Viewport Sizing\n\n";
459
- md += "| Utility | Description |\n";
460
- md += "| --- | --- |\n";
461
- const viewportProps = [
462
- "min-h-screen",
463
- "max-h-screen",
464
- "min-w-screen",
465
- "h-dvh",
466
- "h-svh",
467
- "h-lvh",
468
- "w-dvw",
469
- "w-svw",
470
- "w-lvw",
471
- "min-h-dvh",
472
- "min-h-svh",
473
- "min-h-lvh",
474
- ];
475
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
476
- if (viewportProps.some((p) => klass === p)) {
477
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
478
- }
479
- }
480
- md += "\n";
481
-
482
- md += "### Accessibility\n\n";
483
- md += "| Utility | Description |\n";
484
- md += "| --- | --- |\n";
485
- const a11yProps = ["sr-only", "not-sr-only"];
486
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
487
- if (a11yProps.some((p) => klass === p)) {
488
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
489
- }
490
- }
491
- md += "\n";
492
-
493
- md += "### Other Utilities\n\n";
494
- md += "| Utility | Description |\n";
495
- md += "| --- | --- |\n";
496
- const allHandledPrefixes = [
497
- ...typoProps,
498
- ...flexProps,
499
- ...posProps,
500
- ...borderProps,
501
- ...effectProps,
502
- ...animProps,
503
- ...interProps,
504
- ...displayProps,
505
- ...overflowProps,
506
- ...bgProps,
507
- ...listProps,
508
- ...alignProps,
509
- ...a11yProps,
510
- ...viewportProps,
511
- ...outlineProps,
512
- ...aspectProps,
513
- ...backdropProps,
514
- "w-",
515
- "h-",
516
- "min-w-",
517
- "min-h-",
518
- "max-w-",
519
- "max-h-",
520
- "bg-",
521
- "border-",
522
- "opacity-",
523
- "cursor-",
524
- "size-",
525
- "top-",
526
- "bottom-",
527
- "left-",
528
- "right-",
529
- "z-",
530
- "duration-",
531
- "gap-",
532
- "space-",
533
- "divide-",
534
- "grid-",
535
- "col-",
536
- ];
537
- for (const [klass, props] of Object.entries(PROPS_CUSTOM)) {
538
- if (!allHandledPrefixes.some((p) => klass.startsWith(p) || klass === p)) {
539
- md += `| \`${klass}\` | \`${JSON.stringify(props)}\` |\n`;
540
- }
541
- }
542
- // Document text sizes
543
- md += "| `text-{0-99}px` | Font size in pixels (e.g., `text-12px`, `text-16px`) |\n";
544
- md += "| `text-{0-24.75}rem` | Font size in rem units (0.25rem increments) |\n";
545
- md += "\n";
546
-
547
- md += "## Custom Values\n\n";
548
- 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`;
549
- md += "### Syntax\n\n";
550
- md += "```html\n";
551
- md += '<div class="w-[133px] mt-[2rem] max-w-[900px]">\n';
552
- md += "```\n\n";
553
- md += "### Supported Properties\n\n";
554
- md += "| Prefix | CSS Property |\n";
555
- md += "|--------|--------------|\n";
556
- md += "| `w-` | width |\n";
557
- md += "| `h-` | height |\n";
558
- md += "| `min-w-`, `min-h-` | min-width, min-height |\n";
559
- md += "| `max-w-`, `max-h-` | max-width, max-height |\n";
560
- md += "| `m-`, `mt-`, `mr-`, `mb-`, `ml-` | margin |\n";
561
- md += "| `mx-`, `my-` | margin-inline, margin-block |\n";
562
- md += "| `p-`, `pt-`, `pr-`, `pb-`, `pl-` | padding |\n";
563
- md += "| `px-`, `py-` | padding-inline, padding-block |\n";
564
- md += "| `top`, `right`, `bottom`, `left` | positioning |\n";
565
- md += "| `gap-`, `gap-x-`, `gap-y-` | gap |\n";
566
- md += "| `text-` | font-size |\n";
567
- md += "| `z-` | z-index |\n";
568
- md += "| `bg-` | background-color |\n";
569
- md += "| `border-` | border-color |\n";
570
- md += "\n";
571
- md += "### Variants\n\n";
572
- md += "Custom values support pseudo-states, responsive breakpoints, and dark mode:\n\n";
573
- md += "```html\n";
574
- md += '<div class="hover:w-[200px] md:max-w-[900px] dark:bg-[#333]">\n';
575
- md += "```\n\n";
576
- md += "### Limitations\n\n";
577
- md += "**Static classes only**: Custom values work with the `class` attribute, not `:class`:\n\n";
578
- md += "```html\n";
579
- md += "<!-- ✓ Works -->\n";
580
- md += '<div class="w-[133px]">\n\n';
581
- md += "<!-- ✗ Not supported - use inline styles instead -->\n";
582
- md += `<div :class="'w-[133px]'">\n`;
583
- md += `<div :attr:style="'width: ' + dynamicWidth">\n`;
584
- md += "```\n\n";
585
- md +=
586
- "**Browser only**: Custom values require the CSSStyleSheet API and are not available in Worker or SSR environments.\n\n";
587
- md += "### When to Use\n\n";
588
- md += "**Prefer the design scale** for consistency. Use custom values for:\n";
589
- md += "- Matching external constraints (third-party widgets, embeds)\n";
590
- md += "- One-off pixel-perfect adjustments\n";
591
- md += "- Rapid prototyping (replace with scale values later)\n\n";
592
- md += "### Dynamic Content\n\n";
593
- md +=
594
- "Content rendered by Mancha is scanned automatically. Markup produced by anything else (raw `innerHTML`, a third-party widget) is not, so scan it yourself with `scanAndInject(root)`:\n\n";
595
- md += "```js\n";
596
- md += 'import { scanAndInject } from "mancha/browser";\n\n';
597
- md += "widget.mount(container); // Third-party code writes into the container.\n";
598
- md += "scanAndInject(container);\n";
599
- md += "```\n\n";
600
- md +=
601
- "Re-scanning an already-scanned tree is safe: each rule is injected once, and rules are re-injected if the stylesheet element is removed from the document.\n\n";
602
- md += "Two limitations:\n\n";
603
- md +=
604
- "- **ESM only**: `scanAndInject` is exported from the module build, not from the global bundle loaded via a `<script>` tag.\n";
605
- md +=
606
- "- **No shadow DOM**: `querySelectorAll` does not pierce a shadow root, so scanning a host element finds nothing inside it. Scanning the shadow root itself does inject rules, but they land in the main document's stylesheet, where shadow-boundary scoping stops them from applying. Style shadow content with its own stylesheet instead.\n\n";
607
-
608
- md += "--- \n\n*Generated automatically from `src/css_gen_utils.ts`*\n";
609
-
610
- return md;
611
- }
612
-
613
- // Generate CSS and calculate stats
614
- const css = rules();
615
- const ruleCount = (css.match(/\{[^}]+\}/g) || []).length;
616
- const sizeBytes = css.length;
617
- const sizeKB = (sizeBytes / 1024).toFixed(1);
618
- const sizeMB = (sizeBytes / 1024 / 1024).toFixed(2);
619
-
620
- fs.writeFileSync(DOCS_PATH, generateMarkdown());
621
- console.log(`Documentation generated at ${DOCS_PATH}`);
622
- 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
- ]);