@csszyx/mcp-server 0.10.9 → 0.10.11
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.
- package/llms-full.txt +88 -0
- package/package.json +4 -4
package/llms-full.txt
CHANGED
|
@@ -643,6 +643,94 @@ Strategy for static analysis vs runtime generation.
|
|
|
643
643
|
- ✅ `sz({ color: isErr ? 'red-500' : 'green-500' })` (Zero Runtime)
|
|
644
644
|
- ⚠️ `sz({ color:`red-${shade}`})` (Runtime injection overhead)
|
|
645
645
|
|
|
646
|
+
## TypeScript: `sz` on custom components
|
|
647
|
+
|
|
648
|
+
The JSX augmentation (`@csszyx/types/jsx`) adds `sz` to **host elements only**
|
|
649
|
+
(`<div>`, `<span>`, … via React `HTMLAttributes` / `SVGAttributes`). A custom
|
|
650
|
+
component has its own props type, so `sz` is **not auto-typed** there.
|
|
651
|
+
|
|
652
|
+
Two independent layers:
|
|
653
|
+
|
|
654
|
+
- **Compile** — the transform lowers `sz` → `className` on ANY element, custom
|
|
655
|
+
included: `<Card sz={{ p: 4 }} />` → `<Card className="p-4" />`. So it works at
|
|
656
|
+
runtime as long as the component forwards `className` down to a host element.
|
|
657
|
+
- **Type** — only auto-typed when the component's props derive from host attributes.
|
|
658
|
+
|
|
659
|
+
| Component props type | `sz` typed? |
|
|
660
|
+
| :--------------------------------------------------------- | :------------------ |
|
|
661
|
+
| `{ title: string }` (fresh type) | ❌ TS error |
|
|
662
|
+
| `ComponentProps<'div'>` / `extends HTMLAttributes<T>` | ✅ inherited |
|
|
663
|
+
| `{ title: string } & Pick<ComponentProps<'div'>, 'sz'>` | ✅ just `sz` |
|
|
664
|
+
|
|
665
|
+
Add `sz` to a fresh props type by picking it (no import needed) or declaring it:
|
|
666
|
+
|
|
667
|
+
```tsx
|
|
668
|
+
import type { ComponentProps } from 'react';
|
|
669
|
+
type Props = { title: string } & Pick<ComponentProps<'div'>, 'sz'>;
|
|
670
|
+
// equivalent: import type { SzPropValue } from '@csszyx/types'; then `sz?: SzPropValue`
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
Pick is for CONCRETE tags only. On a generic component (`E extends ElementType`),
|
|
674
|
+
`Pick<ComponentProps<E>, 'sz'>` distributes over union members without the
|
|
675
|
+
augmentation and resolves order-dependently (sz can flip optional→required when an
|
|
676
|
+
unrelated file changes). Generic wrappers declare the prop directly — `sz?: SzInput`
|
|
677
|
+
(from `csszyx`) — which is stable and also accepts szv factory output
|
|
678
|
+
(`sz={someSzv({ v })}`; `SzPropValue` rejects it, `SzInput` is the forwarding type).
|
|
679
|
+
|
|
680
|
+
The augmentation must be in scope (a `/// <reference types="@csszyx/types/jsx" />`
|
|
681
|
+
or the project's `csszyx-env.d.ts`), otherwise `sz` is not a key of
|
|
682
|
+
`ComponentProps<'div'>` and `Pick` fails.
|
|
683
|
+
|
|
684
|
+
## Styling parts of a compound component
|
|
685
|
+
|
|
686
|
+
No special API. `sz` compiles to `className` on ANY element — host tags, custom
|
|
687
|
+
components, and dotted names (`Card.Header`) — and each is safelisted + mangled like
|
|
688
|
+
a normal `sz`. So style a compound component's parts by giving each part its own `sz`:
|
|
689
|
+
|
|
690
|
+
```tsx
|
|
691
|
+
<Card sz={{ p: 4 }}>
|
|
692
|
+
<Card.Header sz={{ bg: 'gray-100', font: 'bold' }}>Title</Card.Header>
|
|
693
|
+
<Card.Body sz={{ text: 'sm' }}>Body</Card.Body>
|
|
694
|
+
</Card>
|
|
695
|
+
// → each part compiled to className at build time; all classes safelisted.
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
Build it as a plain React compound component; each part forwards `sz` (already
|
|
699
|
+
rewritten to `className` by the transform) onto a host element. Type each part with
|
|
700
|
+
`ComponentProps<'div'>` (or the relevant tag) to get `sz` + `className` for free.
|
|
701
|
+
Merge a part's own defaults with the consumer's override via `szcn` (mangle-aware,
|
|
702
|
+
last-wins) — the RECOMMENDED pattern for slot defaults. Multi-property prefixes
|
|
703
|
+
(`text`, `bg`, `border`, `font`, `flex`, `divide`, `ring`, `outline`) are
|
|
704
|
+
value-classified into property groups: same property → later wins
|
|
705
|
+
(`szcn('text-base','text-sm')` → `text-sm`); different properties co-exist
|
|
706
|
+
(`text-red-500` never removes `text-sm`); unclassifiable values are always kept
|
|
707
|
+
(fail-safe). Custom `@theme` tokens join their groups automatically when the CSS
|
|
708
|
+
is scanned (`build.scanCss`); classes written in plain CSS register via
|
|
709
|
+
`registerSzcnGroups({ colors: [...], textSizes: [...] })` from `@csszyx/runtime`.
|
|
710
|
+
|
|
711
|
+
## `szs` — slot map for a component's internal parts
|
|
712
|
+
|
|
713
|
+
For parts a component renders ITSELF (no consumer content), `szs` maps slot names
|
|
714
|
+
to sz values. The transform compiles each VALUE to its class string (key kept),
|
|
715
|
+
safelisting + mangling like `sz`; the component forwards `props.szs?.<slot>` into
|
|
716
|
+
the matching child's `className`.
|
|
717
|
+
|
|
718
|
+
```tsx
|
|
719
|
+
type CardProps = { szs?: Szs<'header' | 'icon'> }; // Szs from @csszyx/types
|
|
720
|
+
<Card szs={{ header: { bg: 'gray-100' }, icon: { color: 'red-500' } }} />
|
|
721
|
+
// → <Card szs={{ header: "bg-gray-100", icon: "text-red-500" }} />
|
|
722
|
+
// component: <header className={szsClass(props.szs?.header)} />
|
|
723
|
+
// szsClass (from @csszyx/runtime) narrows the compiled slot to string | undefined —
|
|
724
|
+
// slots TYPE as sz values but ARE class strings after the transform; the helper
|
|
725
|
+
// is also fail-safe (uncompiled slot -> undefined, never "[object Object]").
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
Rules: custom components only (host element → dev warn, unchanged). Slot values
|
|
729
|
+
must be STATIC — a pure object literal (nested variants OK) or a raw class string;
|
|
730
|
+
identifiers/conditionals/spreads leave the attribute unchanged with a dev warning.
|
|
731
|
+
Keys are identifiers. `sz` styles the element itself; `szs` styles its internal
|
|
732
|
+
parts — a component can take both.
|
|
733
|
+
|
|
646
734
|
|
|
647
735
|
# Backgrounds
|
|
648
736
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/mcp-server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.11",
|
|
4
4
|
"description": "Model Context Protocol (MCP) server for csszyx — enables AI agents to understand and generate sz props",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
32
32
|
"zod": "^3.23.8",
|
|
33
|
-
"@csszyx/
|
|
34
|
-
"@csszyx/
|
|
35
|
-
"@csszyx/
|
|
33
|
+
"@csszyx/cli": "0.10.11",
|
|
34
|
+
"@csszyx/compiler": "0.10.11",
|
|
35
|
+
"@csszyx/unplugin": "0.10.11"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^6.0.3",
|