Skip to content

Commit 44ce652

Browse files
committed
fix: tailwind variants generate without useUI hook
in file
1 parent caf7f4a commit 44ce652

File tree

13 files changed

+84
-154
lines changed

13 files changed

+84
-154
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Release
22

33
on:
4-
workflow_dispatch: # manual "Run workflow"
4+
workflow_dispatch: # manual "Run workflow"
55

66
permissions:
77
contents: write
@@ -39,8 +39,8 @@ jobs:
3939
id: release
4040
with:
4141
token: ${{ secrets.GITHUB_TOKEN }}
42-
config-file: .release-please-config.json # your config
43-
manifest-file: .release-please-manifest.json # version manifest
42+
config-file: .release-please-config.json # your config
43+
manifest-file: .release-please-manifest.json # version manifest
4444

4545
# 4 ▸ Only continue if at least one package was released
4646
- uses: actions/setup-node@v4

AGENTS.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Use these tips when working with the codebase or generating examples.
77

88
## How React Zero-UI works
99

10-
1. `useUI()` writes to `document.body.dataset` using keys you specify.
10+
1. `useUI()` writes to `document.body.dataset` using keys you specify.
1111

1212
```tsx
1313
const [staleValue, setValue] = useUI<'open' | 'closed'>('sidebar', 'closed');
@@ -61,11 +61,13 @@ const [, setTheme] = useUI<'light' | 'dark'>('theme', 'light');
6161
```tsx
6262
const [, setTheme] = useUI<'light' | 'dark'>('theme', 'light');
6363
// Simply pass a ref to the element
64-
<div ref={setTheme.ref} className="theme-light:bg-white theme-dark:bg-black" />
65-
64+
<div
65+
ref={setTheme.ref}
66+
className="theme-light:bg-white theme-dark:bg-black"
67+
/>;
6668
```
6769

68-
Now the data-* will flip on that element, and the styles will be scoped to that element, or its children.
70+
Now the data-\* will flip on that element, and the styles will be scoped to that element, or its children.
6971

7072
---
7173

docs/assets/internal.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Internal docs
22

3-
Below is a **"mental model"** of the Zero‑UI variant extractor—distilled so that *another* human (or LLM) can reason about, extend, or safely refactor the code‑base.
3+
Below is a **"mental model"** of the Zero‑UI variant extractor—distilled so that _another_ human (or LLM) can reason about, extend, or safely refactor the code‑base.
44

55
---
66

@@ -13,13 +13,12 @@ Below is a **"mental model"** of the Zero‑UI variant extractor—distilled so
1313
```
1414

1515
2. **Resolve** (using §3) the `stateKey` and `initialValue` arguments **at build‑time.**
16-
17-
* `stateKey` must be a *local*, static string.
18-
* `initialValue` follows the same rule.
16+
- `stateKey` must be a _local_, static string.
17+
- `initialValue` follows the same rule.
1918

2019
3. **Globally scan all project files** for **variant tokens that match any discovered `stateKey`**—regardless of where hooks are declared. `(scanner.cts) → scanVariantTokens`
2120

22-
*Examples*
21+
_Examples_
2322

2423
```html
2524
<!-- stateKey‑true:bg-black → value = "true" -->
@@ -45,9 +44,9 @@ source files ─► ├─► Map<key,Set<value>>
4544

4645
```ts
4746
type VariantData = {
48-
key: string; // 'stateKey'
49-
values: string[]; // ['light', 'dark', …] (unique & sorted)
50-
initialValue: string; // from 2nd arg of useUI()
47+
key: string; // 'stateKey'
48+
values: string[]; // ['light', 'dark', …] (unique & sorted)
49+
initialValue: string; // from 2nd arg of useUI()
5150
};
5251
```
5352

@@ -66,18 +65,18 @@ source files ─► ├─► Map<key,Set<value>>
6665

6766
## 2. Pipeline overview (AST + global token scan)
6867

69-
| Stage | Scope & algorithm | Output |
70-
| --- | --- | --- |
71-
| **A - collectUseUIHooks** | Single AST traversal per file.<br>• Validate `useUI()` shapes.<br>• Resolve **stateKey** & **initialValue** with **`literalFromNode`** (§3).<br>• Builds global set of all state keys. | `HookMeta[]` = `{ stateKey, initialValue }[]`, global `Set<stateKey>` |
72-
| **B - global scanVariantTokens** | Single global regex scan pass over all files (same glob & delimiters Tailwind uses).<br>Matches tokens for **every stateKey discovered in Stage A**. | `Map<stateKey, Set<value>>` |
68+
| Stage | Scope & algorithm | Output |
69+
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
70+
| **A - collectUseUIHooks** | Single AST traversal per file.<br>• Validate `useUI()` shapes.<br>• Resolve **stateKey** & **initialValue** with **`literalFromNode`** (§3).<br>• Builds global set of all state keys. | `HookMeta[]` = `{ stateKey, initialValue }[]`, global `Set<stateKey>` |
71+
| **B - global scanVariantTokens** | Single global regex scan pass over all files (same glob & delimiters Tailwind uses).<br>Matches tokens for **every stateKey discovered in Stage A**. | `Map<stateKey, Set<value>>` |
7372

7473
The pipeline now ensures tokens are captured globally—regardless of hook declarations in each file.
7574

7675
---
7776

7877
## 3. The literal‑resolution micro‑framework
7978

80-
Everything funnels through **`literalFromNode`**. Think of it as a deterministic *static evaluator* restricted to a very small grammar.
79+
Everything funnels through **`literalFromNode`**. Think of it as a deterministic _static evaluator_ restricted to a very small grammar.
8180

8281
### 3.1 Supported input forms (stateKey & initialValue)
8382

@@ -112,11 +111,11 @@ Everything funnels through **`literalFromNode`**. Think of it as a deterministic
112111
113112
### 3.2 Resolvers
114113
115-
| Helper | Purpose |
116-
| -- | -- |
117-
| **`resolveTemplateLiteral`** | Ensures every `${expr}` resolves via `literalFromNode`. |
118-
| **`resolveLocalConstIdentifier`** | Maps an `Identifier` → its `const` initializer *iff* initializer is a local static string/template. Imported bindings rejected explicitly. |
119-
| **`resolveMemberExpression`** | Static walk of `obj.prop`, `obj['prop']`, `obj?.prop`, arrays, numeric indexes, optional‑chaining… Throws if unresolved. |
114+
| Helper | Purpose |
115+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
116+
| **`resolveTemplateLiteral`** | Ensures every `${expr}` resolves via `literalFromNode`. |
117+
| **`resolveLocalConstIdentifier`** | Maps an `Identifier` → its `const` initializer _iff_ initializer is a local static string/template. Imported bindings rejected explicitly. |
118+
| **`resolveMemberExpression`** | Static walk of `obj.prop`, `obj['prop']`, `obj?.prop`, arrays, numeric indexes, optional‑chaining… Throws if unresolved. |
120119
| **`literalFromNode`** | Router calling above; memoised (`WeakMap`) per AST node. |
121120
122121
Resolvers throw contextual errors via **`throwCodeFrame`** (`@babel/code-frame`).
@@ -125,27 +124,27 @@ Resolvers throw contextual errors via **`throwCodeFrame`** (`@babel/code-frame`)
125124
126125
## 4. Validation rules
127126
128-
| Position in `useUI` | Allowed value | Example error |
129-
| --- | --- | --- |
130-
| **stateKey (arg 0)** | Local static string | `State key cannot be resolved at build‑time.` |
131-
| **initialValue (arg 1)** | Same rule as above. | `Initial value cannot be resolved …` |
127+
| Position in `useUI` | Allowed value | Example error |
128+
| ------------------------ | ------------------- | --------------------------------------------- |
129+
| **stateKey (arg 0)** | Local static string | `State key cannot be resolved at build‑time.` |
130+
| **initialValue (arg 1)** | Same rule as above. | `Initial value cannot be resolved …` |
132131
133132
Imported bindings must be re‑cast locally.
134133
135134
---
136135
137136
## 5. Performance notes
138137
139-
* **Global LRU file‑cache** avoids re‑parsing unchanged files (`mtime:size`).
140-
* **Parallel parsing** (`os.cpus().length-1` concurrent tasks).
141-
* **Regex-based global token scanning** (fast Tailwind‑style parsing).
138+
- **Global LRU file‑cache** avoids re‑parsing unchanged files (`mtime:size`).
139+
- **Parallel parsing** (`os.cpus().length-1` concurrent tasks).
140+
- **Regex-based global token scanning** (fast Tailwind‑style parsing).
142141
143142
---
144143
145144
## 6. Unsupported cases
146145
147-
* Runtime constructs (`import.meta`, dynamic imports).
148-
* Cross‑file constants.
149-
* Non‑string values (numbers, booleans).
150-
* Private class fields.
151-
* No analysis of setter functions (runtime-only).
146+
- Runtime constructs (`import.meta`, dynamic imports).
147+
- Cross‑file constants.
148+
- Non‑string values (numbers, booleans).
149+
- Private class fields.
150+
- No analysis of setter functions (runtime-only).

examples/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
"tailwindcss": "^4.1.10",
3333
"typescript": "^5"
3434
}
35-
}
35+
}

examples/demo/src/app/globals.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
0px 2px 2px -1.5px rgba(0, 0, 0, 0.32), 0px 4.4px 4.4px -2.25px rgba(0, 0, 0, 0.3), 0px 9.8px 9.8px -3px rgba(0, 0, 0, 0.25),
77
0px 25px 25px -3.75px rgba(0, 0, 0, 0.11), 0px -5px 5px -3.75px rgba(0, 0, 0, 0.11);
88
}
9-
div.relative.py-10{
10-
padding: 0;
9+
div.relative.py-10 {
10+
padding: 0;
1111

12-
.min-h-\[750px\]{
12+
.min-h-\[750px\] {
1313
min-height: auto;
1414
margin: 80px auto;
1515
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
"tsx": "^4.20.3",
4646
"typescript": "^5.8.3"
4747
}
48-
}
48+
}

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
"tailwindcss": "^4.0.0",
2222
"@tailwindcss/postcss": "^4.1.8"
2323
}
24-
}
24+
}

0 commit comments

Comments
 (0)