retouche-dev 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Damien Schneider
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/PROMPT.md ADDED
@@ -0,0 +1,89 @@
1
+ Set up Retouche in this React app. Retouche is a dev-only overlay: it puts a dot on every element where a call site overrides the typography of a design-system component (`<Text className="text-lg font-bold">`, `<Badge className={styles.loud}>`, `<Heading style={{ fontSize: 40 }}>`). It also dots every nested corner that doesn't follow the curve of the container it sits in. Clicking a dot shows which properties the override changes, what it replaced, and the code behind it. Retouche does not judge: the developer decides, override by override, whether to fix the call site or allow it. Its panel can also highlight renders: each component flashes as it renders, with a running count, the panel lists every component that rendered, and it shows what changed on a component's last render. That needs no setup beyond the steps below.
2
+
3
+ Work through these steps in order. Stop and tell me if a precondition fails instead of working around it.
4
+
5
+ ## 1. Check the stack
6
+
7
+ - React 19 or later is required. React 18 or another UI framework: stop and tell me.
8
+ - Supported dev servers: Vite, frameworks built on it included, or Next.js 16 with the App Router on Turbopack, its default. Anything else, a Next app on the Pages Router alone and a Next dev script with `--webpack` included: stop and tell me.
9
+ - In a monorepo, work in the app that runs the dev server. If several apps could be meant, ask which.
10
+ - Any styling approach works: Tailwind, CSS Modules, plain CSS or Sass classes, CSS-in-JS that emits class names, inline `style`. Note which ones this app uses.
11
+ - Retouche reads the `className` and `style` a call site passes, including the CSS custom properties the design system's stylesheets read into typography (`style={{ "--button-font-size": "14px" }}`, `[--button-font-size:14px]`). If call sites change typography mostly through other props (`sx`, the `css` prop, style props such as `fontSize="lg"`), stop and tell me: those are not read.
12
+
13
+ ## 2. Install
14
+
15
+ Add Retouche as a dev dependency with the project's own package manager:
16
+
17
+ ```
18
+ {{RETOUCHE_PACKAGE}}
19
+ ```
20
+
21
+ For example `bun add -d {{RETOUCHE_PACKAGE}}`, `pnpm add -D {{RETOUCHE_PACKAGE}}` or `npm install -D {{RETOUCHE_PACKAGE}}`.
22
+
23
+ ## 3. Find the design system
24
+
25
+ The design system is the set of components the app builds its screens from. It can be a local folder (`components/ui`), a workspace package, a package installed from npm, or several of these; local components that wrap library ones belong to it.
26
+
27
+ Find where it decides typography, whatever the styling approach:
28
+
29
+ - Tailwind: utilities in the component definitions (cva variants, a `cn(...)` base string) and the theme (`@theme` in CSS or `tailwind.config`).
30
+ - CSS Modules, plain CSS, Sass: the stylesheets the components import, and the rules in them that set typography, whether they target classes or the components' data attributes (`[data-slot="title"]`).
31
+ - CSS-in-JS (styled-components, Emotion, Panda, vanilla-extract…): the styled definitions and the theme tokens they read.
32
+ - Tokens: CSS custom properties or a theme object that names sizes, weights and families.
33
+
34
+ Then list the components to watch. A design-system component belongs on the list when either holds:
35
+
36
+ - It styles its own text: its definition sets any of these properties, by class, variant, stylesheet or CSS that targets it: {{PROPERTIES}}. Typically `Text`, `Heading`, `Button`, `Badge`, `Label`, `Link`.
37
+ - It renders a component on the list and passes it classes or styles: a `MarkdownH2` that renders `<Heading className="text-2xl">`, a `SidebarTrigger` that renders `<Button>`. Retouche trusts what a listed component renders, so a component like this left off the list shows its own JSX as an override wherever it appears. Unexported helpers inside the design system count too.
38
+
39
+ Leave out the ones that do neither, such as providers and layout primitives (`Stack`, `Box`, `Grid`): Retouche checks typography, not spacing. For a design system installed as a package, start from the components the app imports from it and read the package's files in `node_modules` to sort them.
40
+
41
+ Write each name as React sees it: the component's `displayName` when it sets one, otherwise its function name. That is `CardTitle` rather than `Card.Title`, and never the file name. A component without a name of its own (an anonymous function inside `forwardRef` or `memo`, or a minified package) cannot be watched: leave it out and name it in your report. Names are matched across the whole page, so a component from another library with the same name is watched too: name any you notice in your report.
42
+
43
+ Nothing else needs describing. At a call site, Retouche reads Tailwind utilities by name and any other class through the page's own stylesheets, the theme's custom tokens included: `text-caption` counts as a size because the CSS Tailwind generates for it sets `font-size`. Inline `style` is read by property. Stylesheets served from another origin cannot be read.
44
+
45
+ ## 4. Write `retouche.config.ts`
46
+
47
+ Copy `node_modules/retouche-dev/templates/retouche.config.ts` to the project root, next to `package.json`, and tailor it:
48
+
49
+ - `components`: the list from step 3.
50
+ - `allow`: leave it out. The developer reviews each override in the overlay, and when one is intended the overlay copies the exact entry to add. Only add an entry now when the design system's own code or docs say a component is meant to take that override, and name the source in your report.
51
+
52
+ An `allow` entry is `{ component?: "Text", classes?: ["text-muted-*"], properties?: ["text-color"], corners?: true }`: `classes` are globs on the class name (variants such as `md:` or `hover:` are ignored), `properties` lets any override of those properties through, class or inline style, `corners: true` keeps the component's nested corners as they are, and without `component` the entry applies to every watched component. An override is let through when it matches either list.
53
+
54
+ ## 5. Wire it up
55
+
56
+ **Vite**
57
+
58
+ - `vite.config.ts`: add `retouche()` from `retouche-dev/vite` to `plugins`.
59
+ - The client entry (`src/main.tsx`): make `import "retouche-dev/instrument";` the very first import, before React. A framework that generates its client entry takes a custom one written as its docs show: TanStack Start's `src/client.tsx`, React Router's `app/entry.client.tsx` (`npx react-router reveal entry.client`).
60
+ - Render `<Retouche config={config} />` from `retouche-dev` next to the app root, with `config` imported from `retouche.config.ts`. A framework that renders the whole document takes it inside the root route's `<body>`: TanStack Start's `__root.tsx`, the `Layout` in React Router's `app/root.tsx`.
61
+ - An app with several entries, one per HTML page or window, needs both in every entry whose screens should be checked.
62
+
63
+ **Next.js (App Router)**
64
+
65
+ - Create `app/api/retouche/[...path]/route.ts`, under `src/app/` when the app uses `src/`, containing `export { GET, POST } from "retouche-dev/next";`.
66
+ - Create or extend `instrumentation-client.ts` at the project root, or in `src/` when the app uses one, with `import "retouche-dev/instrument";` as its first line.
67
+ - Render `<Retouche config={config} />` from `retouche-dev` inside the root layout's `<body>`, with `config` imported from `retouche.config.ts`.
68
+
69
+ `<Retouche>` renders nothing in production builds, `retouche-dev/instrument` installs nothing there, and the route answers nothing outside development, so no environment guards are needed.
70
+
71
+ ## 6. Check the dev setup
72
+
73
+ The overlay talks to its dev route at `/api/retouche` on the app's own origin: the code behind each override, the config entries it writes and voice sessions all go through it. Read the app's config for anything that stands between the two, and change it for development only:
74
+
75
+ - **Hostname.** The route answers on `localhost`, `*.localhost`, `127.0.0.1` and `[::1]`. If the developer opens the dev server under another name (a domain mapped in `/etc/hosts`, a LAN address, a container or tunnel host: look at `server.host` and `server.allowedHosts` in the Vite config, `allowedDevOrigins` in the Next config, the dev script and the README), add each name, comma-separated, to `RETOUCHE_HOSTS` in the app's `.env.local`, or to the `allowedHosts` option when the whole team uses it: `retouche({ allowedHosts: [...] })`, or for Next.js a route file reading `export const { GET, POST } = createRoute({ allowedHosts: [...] });` with `createRoute` from `retouche-dev/next`.
76
+ - **Next.js `basePath`.** The overlay calls `/api/retouche` from the site's root, so with a `basePath` set: stop and tell me.
77
+ - **Requests in front of the route.** A Next.js `proxy.ts` or `middleware.ts` whose matcher covers `/api/retouche` and that can redirect, rewrite or reject it (auth, locale prefixes, rate limits): exclude `/api/retouche` from its matcher. Vite runs Retouche's middleware before its own `server.proxy`, so a proxied `/api` is fine; when the app's own server sits in front of Vite (Vite in middleware mode under Express, Hono, Fastify…), it must hand `/api/retouche` to `vite.middlewares` before its own routes.
78
+ - **Security headers in development.** A `Content-Security-Policy` or `Permissions-Policy` sent in development (headers in the Next config, `proxy.ts` or `middleware.ts`, a `<meta http-equiv>` tag, Vite's `server.headers`, the app's own server) must let the overlay run. Its styles are `<style>` elements: `style-src 'unsafe-inline'`, and since browsers ignore `'unsafe-inline'` next to a nonce or hash, leave those out of `style-src` in development. Screenshots are `blob:` and `data:` images (`img-src`). Listening through a speech-to-text key loads an audio worklet from a `blob:` URL (`script-src`). Voice sessions need the microphone (`microphone=(self)`). Leave production headers as they are.
79
+ - **Editor.** Code opens in VS Code unless `RETOUCHE_EDITOR` names another: `cursor`, `webstorm`, `windsurf` or `zed`. When you know the developer works in one of those, set it in the app's `.env.local`.
80
+ - Before writing to `.env.local`, check that git ignores it, and add it to `.gitignore` when it doesn't.
81
+ - **Voice sessions** (Session on the bar) turn what the developer says while pointing at the page into feedback through their own Claude Code, Codex or Mastra Code CLI, whichever is installed and signed in; Retouche runs it in the background. Sessions are saved in the user's data folder, outside the repo. A Groq, Mistral or OpenAI speech-to-text key is added from the voice start screen, or picked up from `GROQ_API_KEY`, `MISTRAL_API_KEY` or `OPENAI_API_KEY` in the environment or the app's `.env` files, and kept outside the repo. Other writers, ACP agents or OpenAI-compatible endpoints, and any other transcriber go in the `voice` option of `retouche()` or `createRoute()`, typed in the package; add them only when the developer asks, and never write a key into a file. None is required for the rest of Retouche.
82
+
83
+ ## 7. Verify
84
+
85
+ - Run the project's typecheck, or `tsc --noEmit` when it has none.
86
+ - Start the dev server and open the app. Dots should appear on overridden elements, and the Retouche bar should show a count rather than "Config error".
87
+ - Open a few overrides in the panel. Their code should show under Call site and Component; when the panel asks to add the route instead, the browser does not reach `/api/retouche`: go back to step 6. Each call site should be a line written where the app uses the design system. When it sits inside the design system itself, the component whose code it is belongs on the list from step 3: add it and look again rather than allowing the override.
88
+ - Open the browser console: nothing should report a blocked Retouche request, style, image or worklet.
89
+ - Report back: where the design system lives and the styling approaches found, the components watched, the ones left out and why, any `allow` entries and where they come from, how many overrides the first page shows, what you changed in the dev setup and why (hostnames, matchers, development headers, editor), and which of Claude Code, Codex and Mastra Code voice sessions can use.
package/README.md CHANGED
@@ -1,3 +1,27 @@
1
- # Temporary Holding Version
1
+ # Retouche
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A dev overlay for React apps. It puts a dot on every element whose call site overrides your design system's typography, and on every nested corner that doesn't fit the corner it sits in. Click a dot to see the call site, the component it overrides, and a before/after diff measured in the browser.
4
+
5
+ It also highlights renders, takes notes for your coding agent, and turns what you say while pointing at the page into feedback cards. Production builds render nothing and install nothing.
6
+
7
+ ## Setup
8
+
9
+ Give this prompt to Claude Code, Codex, Cursor or any coding agent working in your app:
10
+
11
+ ```text
12
+ Set up Retouche in this React app by following https://retouche.dev/setup.md
13
+ ```
14
+
15
+ Or install it yourself:
16
+
17
+ ```bash
18
+ npm install -D retouche-dev
19
+ ```
20
+
21
+ Requires React 19, with Vite (TanStack Start and React Router included) or Next.js 16 (App Router on Turbopack). Manual setup, configuration and docs are on [GitHub](https://github.com/damien-schneider/retouche#manual-setup).
22
+
23
+ The package is named `retouche-dev` because `retouche` belongs to another project. Its CLI is `retouche`.
24
+
25
+ ## License
26
+
27
+ MIT. Bundled third-party code is listed in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
@@ -0,0 +1,19 @@
1
+ # Third-party notices
2
+
3
+ `retouche-dev` bundles code from the packages below into `dist`. Each is under the MIT License, reproduced once at the end.
4
+
5
+ | Package | Version | Copyright | Source |
6
+ | --- | --- | --- | --- |
7
+ | `@zumer/snapdom` | 3.8.3 | Copyright (c) 2025 ZumerLab | https://github.com/zumerlab/snapdom |
8
+ | `bippy` | 0.7.3 | Copyright 2024-present Aiden Bai | https://github.com/aidenybai/bippy |
9
+ | `sugar-high` | 2.7.0 | Copyright (c) Jiachi Liu (huozhi) | https://github.com/huozhi/sugar-high |
10
+
11
+ `sugar-high` ships no license file; its `package.json` declares MIT.
12
+
13
+ ## MIT License
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,269 @@
1
+ // src/rules/class-token.ts
2
+ const WHITESPACE = /\s+/;
3
+ const ARBITRARY_PROPERTY = /^\[(?<property>-{0,2}[a-z][\w-]*):/i;
4
+ const OPENERS = "[(";
5
+ const CLOSERS = "])";
6
+ function splitTopLevel(raw, separator) {
7
+ const parts = [];
8
+ let depth = 0;
9
+ let start = 0;
10
+ for (let index = 0; index < raw.length; index += 1) {
11
+ const char = raw.charAt(index);
12
+ if (OPENERS.includes(char)) depth += 1;
13
+ else if (CLOSERS.includes(char)) depth = Math.max(0, depth - 1);
14
+ else if (char === separator && depth === 0) {
15
+ parts.push(raw.slice(start, index));
16
+ start = index + 1;
17
+ }
18
+ }
19
+ parts.push(raw.slice(start));
20
+ return parts;
21
+ }
22
+ function parseClassToken(raw) {
23
+ const parts = splitTopLevel(raw, ":");
24
+ const last = parts.at(-1) ?? "";
25
+ const hasLeadingBang = last.startsWith("!");
26
+ const hasTrailingBang = last.endsWith("!") && last.length > 1;
27
+ const utility = last.slice(hasLeadingBang ? 1 : 0, hasTrailingBang ? -1 : void 0);
28
+ return {
29
+ important: hasLeadingBang || hasTrailingBang,
30
+ raw,
31
+ utility,
32
+ variants: parts.slice(0, -1)
33
+ };
34
+ }
35
+ function splitValueModifier(value) {
36
+ const [base = "", modifier] = splitTopLevel(value, "/");
37
+ return {
38
+ base,
39
+ modifier: modifier ?? null
40
+ };
41
+ }
42
+ function arbitraryProperty(utility) {
43
+ return ARBITRARY_PROPERTY.exec(utility)?.groups?.property ?? null;
44
+ }
45
+ function classTokens(className) {
46
+ return className.split(WHITESPACE).filter(Boolean);
47
+ }
48
+ // src/rules/style-groups.ts
49
+ const PROPERTY_GROUPS = new Map(Object.entries({
50
+ "-moz-osx-font-smoothing": ["font-smoothing"],
51
+ "-webkit-font-smoothing": ["font-smoothing"],
52
+ "-webkit-text-fill-color": ["text-color"],
53
+ background: ["background"],
54
+ "background-color": ["background"],
55
+ "background-image": ["background"],
56
+ "box-shadow": ["shadow"],
57
+ color: ["text-color"],
58
+ font: [
59
+ "font-style",
60
+ "font-weight",
61
+ "font-size",
62
+ "line-height",
63
+ "font-family"
64
+ ],
65
+ "font-family": ["font-family"],
66
+ "font-size": ["font-size"],
67
+ "font-style": ["font-style"],
68
+ "font-variant": ["font-variant-numeric"],
69
+ "font-variant-numeric": ["font-variant-numeric"],
70
+ "font-weight": ["font-weight"],
71
+ "letter-spacing": ["letter-spacing"],
72
+ "line-height": ["line-height"],
73
+ opacity: ["opacity"],
74
+ outline: ["ring"],
75
+ "outline-color": ["ring"],
76
+ "outline-width": ["ring"],
77
+ "text-decoration": ["text-decoration"],
78
+ "text-decoration-color": ["text-decoration"],
79
+ "text-decoration-line": ["text-decoration"],
80
+ "text-decoration-style": ["text-decoration"],
81
+ "text-decoration-thickness": ["text-decoration"],
82
+ "text-shadow": ["shadow"],
83
+ "text-transform": ["text-transform"],
84
+ "text-underline-offset": ["text-decoration"],
85
+ "text-underline-position": ["text-decoration"]
86
+ }));
87
+ const BORDER_RADIUS = /^border(?:-[a-z]+)*-radius$/;
88
+ const BORDER_COLOR = /^border(?:-[a-z]+)*-color$/;
89
+ const CAPITAL = /[A-Z]/g;
90
+ const VENDOR = /^(?:webkit|moz|ms)-/;
91
+ function cssProperty(key) {
92
+ const kebab = key.replaceAll(CAPITAL, (letter) => `-${letter.toLowerCase()}`);
93
+ return VENDOR.test(kebab) ? `-${kebab}` : kebab;
94
+ }
95
+ function boxGroup(property) {
96
+ if (property.startsWith("padding")) return "padding";
97
+ if (property.startsWith("margin")) return "margin";
98
+ if (BORDER_RADIUS.test(property)) return "radius";
99
+ if (BORDER_COLOR.test(property)) return "border-color";
100
+ return property.startsWith("border") ? "border" : null;
101
+ }
102
+ function isCustomProperty(key) {
103
+ return key.startsWith("--");
104
+ }
105
+ function propertyGroupsOf(key) {
106
+ if (isCustomProperty(key)) return [];
107
+ const property = cssProperty(key);
108
+ const known = PROPERTY_GROUPS.get(property);
109
+ if (known !== void 0) return known;
110
+ const box = boxGroup(property);
111
+ return box === null ? [] : [box];
112
+ }
113
+ // src/rules/class-groups.ts
114
+ const WATCHED_GROUPS = [
115
+ "font-size",
116
+ "font-weight",
117
+ "font-family",
118
+ "line-height",
119
+ "letter-spacing",
120
+ "font-style",
121
+ "text-transform",
122
+ "text-decoration",
123
+ "font-variant-numeric",
124
+ "font-smoothing",
125
+ "text-color"
126
+ ];
127
+ [...WATCHED_GROUPS];
128
+ const WATCHED = new Set(WATCHED_GROUPS);
129
+ function isWatchedGroup(group) {
130
+ return WATCHED.has(group);
131
+ }
132
+ const FONT_SIZES = /* @__PURE__ */ new Set([
133
+ "xs",
134
+ "sm",
135
+ "base",
136
+ "lg",
137
+ "xl",
138
+ "2xl",
139
+ "3xl",
140
+ "4xl",
141
+ "5xl",
142
+ "6xl",
143
+ "7xl",
144
+ "8xl",
145
+ "9xl"
146
+ ]);
147
+ const FONT_WEIGHTS = /* @__PURE__ */ new Set([
148
+ "thin",
149
+ "extralight",
150
+ "light",
151
+ "normal",
152
+ "medium",
153
+ "semibold",
154
+ "bold",
155
+ "extrabold",
156
+ "black"
157
+ ]);
158
+ const TEXT_LAYOUT = /* @__PURE__ */ new Set([
159
+ "left",
160
+ "center",
161
+ "right",
162
+ "justify",
163
+ "start",
164
+ "end",
165
+ "wrap",
166
+ "nowrap",
167
+ "balance",
168
+ "pretty",
169
+ "ellipsis",
170
+ "clip"
171
+ ]);
172
+ const BORDER_STYLES = /* @__PURE__ */ new Set([
173
+ "solid",
174
+ "dashed",
175
+ "dotted",
176
+ "double",
177
+ "hidden",
178
+ "none"
179
+ ]);
180
+ const TABLE_BORDERS = /* @__PURE__ */ new Set(["collapse", "separate"]);
181
+ const BOX_DECORATION = /* @__PURE__ */ new Set(["decoration-clone", "decoration-slice"]);
182
+ const KEYWORD_GROUPS = new Map(Object.entries({
183
+ antialiased: "font-smoothing",
184
+ border: "border",
185
+ capitalize: "text-transform",
186
+ "diagonal-fractions": "font-variant-numeric",
187
+ italic: "font-style",
188
+ "line-through": "text-decoration",
189
+ "lining-nums": "font-variant-numeric",
190
+ lowercase: "text-transform",
191
+ "no-underline": "text-decoration",
192
+ "normal-case": "text-transform",
193
+ "normal-nums": "font-variant-numeric",
194
+ "not-italic": "font-style",
195
+ "oldstyle-nums": "font-variant-numeric",
196
+ ordinal: "font-variant-numeric",
197
+ outline: "ring",
198
+ overline: "text-decoration",
199
+ "proportional-nums": "font-variant-numeric",
200
+ ring: "ring",
201
+ rounded: "radius",
202
+ shadow: "shadow",
203
+ "slashed-zero": "font-variant-numeric",
204
+ "stacked-fractions": "font-variant-numeric",
205
+ "subpixel-antialiased": "font-smoothing",
206
+ "tabular-nums": "font-variant-numeric",
207
+ underline: "text-decoration",
208
+ uppercase: "text-transform"
209
+ }));
210
+ const PREFIX_GROUPS = [
211
+ ["leading-", "line-height"],
212
+ ["tracking-", "letter-spacing"],
213
+ ["decoration-", "text-decoration"],
214
+ ["underline-offset-", "text-decoration"],
215
+ ["placeholder-", "text-color"],
216
+ ["text-shadow", "shadow"],
217
+ ["bg-", "background"],
218
+ ["rounded-", "radius"],
219
+ ["shadow-", "shadow"],
220
+ ["inset-shadow", "shadow"],
221
+ ["drop-shadow", "shadow"],
222
+ ["ring-", "ring"],
223
+ ["inset-ring", "ring"],
224
+ ["outline-", "ring"],
225
+ ["opacity-", "opacity"]
226
+ ];
227
+ const ARBITRARY_SIZE = /^(?:\[(?:(?:length|size|percentage|absolute-size|relative-size):|-?\.?\d|(?:clamp|calc|min|max)\(|(?:xx?-small|small|medium|large|x{1,3}-large|larger|smaller)\])|\((?:length|size|percentage):)/;
228
+ const ARBITRARY_WEIGHT = /^(?:\[(?:number:|weight:|-?\.?\d|(?:var|calc|min|max|clamp)\()|\((?!family-name:|generic-name:))/;
229
+ const UNWATCHED_FONT = /^(?:stretch|features)-/;
230
+ const BORDER_WIDTH = /^(?:\d+$|\[(?:length:|-?\.?\d)|\(length:)/;
231
+ const BORDER_SIDE = /^[xytrblse](?:-|$)/;
232
+ const PADDING = /^p[xytrblse]?-/;
233
+ const MARGIN = /^m[xytrblse]?-/;
234
+ function textGroups(value, declared) {
235
+ if (TEXT_LAYOUT.has(value)) return [];
236
+ const { base, modifier } = splitValueModifier(value);
237
+ if (FONT_SIZES.has(base) || ARBITRARY_SIZE.test(base)) return modifier === null ? ["font-size"] : ["font-size", "line-height"];
238
+ return declared ? [...declared] : ["text-color"];
239
+ }
240
+ function fontGroups(value, declared) {
241
+ if (FONT_WEIGHTS.has(value) || ARBITRARY_WEIGHT.test(value)) return ["font-weight"];
242
+ if (UNWATCHED_FONT.test(value)) return [];
243
+ return declared ? [...declared] : ["font-family"];
244
+ }
245
+ function borderGroups(value) {
246
+ if (TABLE_BORDERS.has(value) || value.startsWith("spacing")) return [];
247
+ const side = BORDER_SIDE.exec(value)?.[0] ?? "";
248
+ const rest = value.slice(side.length);
249
+ return rest === "" || BORDER_STYLES.has(rest) || BORDER_WIDTH.test(rest) ? ["border"] : ["border-color"];
250
+ }
251
+ function spacingGroups(utility) {
252
+ if (PADDING.test(utility)) return ["padding"];
253
+ return MARGIN.test(utility) ? ["margin"] : [];
254
+ }
255
+ function classGroupsOf(utility, declared) {
256
+ const name = utility.startsWith("-") ? utility.slice(1) : utility;
257
+ const property = arbitraryProperty(name);
258
+ if (property !== null) return [...propertyGroupsOf(property)];
259
+ if (BOX_DECORATION.has(name)) return [];
260
+ const keyword = KEYWORD_GROUPS.get(name);
261
+ if (keyword !== void 0) return [keyword];
262
+ const prefixed = PREFIX_GROUPS.find(([prefix]) => name.startsWith(prefix));
263
+ if (prefixed) return [prefixed[1]];
264
+ if (name.startsWith("text-")) return textGroups(name.slice(5), declared);
265
+ if (name.startsWith("font-")) return fontGroups(name.slice(5), declared);
266
+ if (name.startsWith("border-")) return borderGroups(name.slice(7));
267
+ return spacingGroups(name);
268
+ }
269
+ export { propertyGroupsOf as a, parseClassToken as c, isCustomProperty as i, classGroupsOf as n, arbitraryProperty as o, isWatchedGroup as r, classTokens as s, WATCHED_GROUPS as t };
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {}