You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.**Resolve** (using §3) the `stateKey` and `initialValue` arguments **at build‑time.**
16
-
-`stateKey` must be a _local_, static string.
17
-
-`initialValue` follows the same rule.
16
+
-`stateKey` must be a _local_, static string.
17
+
-`initialValue` follows the same rule.
18
18
19
19
3.**Globally scan all project files** for **variant tokens that match any discovered `stateKey`**-regardless of where hooks are declared. `(scanner.cts) ➡️ scanVariantTokens`
|**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>`|
77
-
|**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>>`|
74
+
| Stage | Scope & algorithm | Output |
75
+
| --- | --- | --- |
76
+
|**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>`|
77
+
|**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>>`|
78
78
79
79
The pipeline now ensures tokens are captured globally-regardless of hook declarations in each file.
80
80
@@ -88,12 +88,12 @@ Everything funnels through **`literalFromNode`**. Think of it as a deterministic
|**`resolveTemplateLiteral`**| Ensures every `${expr}` resolves via `literalFromNode`.|
120
+
| Helper | Purpose |
121
+
| --- | --- |
122
+
|**`resolveTemplateLiteral`**| Ensures every `${expr}` resolves via `literalFromNode`. |
123
123
|**`resolveLocalConstIdentifier`**| Maps an `Identifier` ➡️ its `const` initializer _iff_ initializer is a local static string/template. Imported bindings rejected explicitly. |
124
-
|**`resolveMemberExpression`**| Static walk of `obj.prop`, `obj['prop']`, `obj?.prop`, arrays, numeric indexes, optional‑chaining… Throws if unresolved.|
125
-
|**`literalFromNode`**| Router calling above; memoised (`WeakMap`) per AST node.|
124
+
|**`resolveMemberExpression`**| Static walk of `obj.prop`, `obj['prop']`, `obj?.prop`, arrays, numeric indexes, optional‑chaining… Throws if unresolved. |
125
+
|**`literalFromNode`**| Router calling above; memoised (`WeakMap`) per AST node. |
126
126
127
127
Resolvers throw contextual errors via **`throwCodeFrame`** (`@babel/code-frame`).
128
128
129
129
---
130
130
131
131
## 4. Validation rules
132
132
133
-
| Position in`useUI`| Allowed value | Example error|
0 commit comments