Skip to content

Feat/scoped variables - #611

Open
dlebedynskyi wants to merge 11 commits into
uni-stack:mainfrom
dlebedynskyi:feat/scoped-variables
Open

Feat/scoped variables#611
dlebedynskyi wants to merge 11 commits into
uni-stack:mainfrom
dlebedynskyi:feat/scoped-variables

Conversation

@dlebedynskyi

@dlebedynskyi dlebedynskyi commented Jul 22, 2026

Copy link
Copy Markdown

What

Adds <ScopedVariables> — a React Context provider that overrides CSS variables for a subtree on both web and native, the per-subtree analogue of Uniwind.updateCSSVariables (which is global-per-theme) but limited to a React tree, instead of global.

<ScopedVariables variables={{ '--color-primary': '#e11d48', '--gap': 16 }}>
  <Text className="text-(--color-primary)" />
</ScopedVariables>
  • Overrides apply only inside the subtree; nested providers merge { ...inherited, ...own }, nearest wins.
  • Keys must start with -- (dev-mode error, invalid keys dropped); values string | number, normalized by the same helper as the global API.
  • Reads back via useCSSVariable('--name'); composes with ScopedTheme / LayoutDirection.
  • Opt-in cacheKey (native only) folds a caller-supplied stable key into the native style cache; without it the subtree bypasses the cache for correctness. No-op on web.
  • Web sets the variables as inline custom properties on the display:contents wrapper so the real DOM cascade resolves them.

Context

Addresses uni-stack/uniwind#546.

Prior art

In NativeWind var serve similar purpose. Opted to have a separate explicit component, following ScopedTheme example:

import { vars } from 'nativewind'

 <View style={vars({ '--color-primary': '#e11d48' })}>
   <Text className="text-primary" />   {/* reads the scoped value */}
 </View>

Plain web - this is literally what web portion of PR does:

<div style="--color-primary: #e11d48; display:contents">
   <span style="color: var(--color-primary)">scoped</span>
 </div>

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added ScopedVariables to override CSS custom properties for a component subtree.
    • Supports nested scopes with nearest provider winning.
    • Integrated with useCSSVariable on both native and web.
  • Bug Fixes

    • Improved scoped-style caching to prevent stale results when scoped variables change.
    • Corrected scoped value handling (for example, numeric values on web resolve consistently).
  • Tests

    • Added/updated native and web test coverage for scoping, validation, nesting, and caching.

Dima Lebedynskyi added 4 commits July 22, 2026 13:08
Demonstrate per-subtree CSS variable overrides in the expo example app:
theme default, scoped override, nested inheritance (nearest wins), and the
opt-in cacheKey. Adds --color-primary/--color-surface/--gap theme defaults so
the unscoped baseline renders intentionally.
On web, Uniwind passes classes through RNW unchanged, so real elements
resolve `var(--name)` from the live CSS cascade. The wrapper only applied
its variables to the hidden dummyParent used for JS reads, so scoped
overrides never reached descendants — styling stayed at the theme default
while useCSSVariable readouts (which use the dummyParent path) looked
correct. Set the variables as inline custom properties on the
display:contents wrapper so they cascade to children (numbers -> px).

Add web regression tests asserting the wrapper carries the overrides
inline, nested wrappers only declare their own overrides, and invalid
keys are dropped. Rework the expo-example demo with origin pills
(default/set here/inherited), swatches, and a gap strip so the
override/inherit story is legible.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a cross-platform ScopedVariables provider with nested merging, validation, native and web style resolution, cache-key integration, hook updates, public exports, documentation, and native/web test coverage.

Changes

ScopedVariables feature

Layer / File(s) Summary
Provider contract and context wiring
packages/uniwind/src/components/ScopedVariables/*, packages/uniwind/src/core/context.ts, packages/uniwind/src/core/types.ts, packages/uniwind/src/index.ts, CONTEXT.md
Adds the ScopedVariables API, validates -- keys, merges nested values with nearest-provider precedence, derives deterministic cache keys, and exposes scoped context to descendants.
Native variable resolution and caching
packages/uniwind/src/core/native/*, packages/uniwind/src/hooks/useCSSVariable/*, packages/uniwind/tests/native/*
Normalizes native scoped values, overlays them on theme variables, incorporates scoped identity into style caching, updates hook resolution, and tests inheritance, theme interaction, reactivity, validation, and cache behavior.
Web cascade and computed-style reads
packages/uniwind/src/core/web/*, packages/uniwind/src/core/config/*, packages/uniwind/tests/web/*, packages/uniwind/tests/e2e/*
Uses a display: contents wrapper and temporary dummyParent CSS properties for scoped web reads, converts numeric values to pixels, cleans up applied properties, and updates related configuration and tests.
Context compatibility fixtures
packages/uniwind/tests/consts.ts
Updates the shared context mock to include variables and remove the obsolete top-level cache-key field.

Pre-commit output mode

Layer / File(s) Summary
Stream pre-commit output
.husky/pre-commit
Runs the pre-commit task with streamed UI output.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Component
  participant ScopedVariables
  participant UniwindContext
  participant Runtime
  participant useCSSVariable
  Component->>ScopedVariables: provide variables
  ScopedVariables->>UniwindContext: merge scoped values and cache key
  UniwindContext->>Runtime: resolve scoped styles
  Runtime->>useCSSVariable: evaluate variable overlay
  useCSSVariable-->>Component: return scoped value
Loading

Possibly related PRs

  • uni-stack/uniwind#393: Extends the same UniwindContext and web style-resolution plumbing used for scoped theme behavior.
  • uni-stack/uniwind#521: Modifies the shared CSS-variable resolution path and useCSSVariable integration.
  • uni-stack/uniwind#577: Updates adjacent subtree-scoping and dummyParent handling in the web runtime.

Suggested reviewers: brentlok

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly points to the new scoped variables feature and matches the main change in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR introduces ScopedVariables, a React context provider that overrides CSS custom properties for a component subtree without touching global theme state — the per-tree counterpart to Uniwind.updateCSSVariables. It ships implementations for both native (prototype-chain overlay onto theme vars, WeakMap-cached var getters, merged cache key) and web (inline display:contents wrapper + temporary dummyParent application for JS reads), along with useCSSVariable improvements and a rename of formatColor.tswebUtils.ts.

  • Core mechanism: buildScopedVariablesContext merges ancestor and own variables (nearest-wins), computes a __uniwindVariablesCacheKey via JSON.stringify of sorted entries, and stores it inside the context's variables object; the native cache key and getScopedVars WeakMap cache both key off this for correctness and performance.
  • Cleanup correctness: applyScopedVariables and getWebVariable now wrap all DOM reads in try/finally, guaranteeing dummyParent is never left with stale scoped properties after an exception.
  • Test gap: the last test in scoped-variables.test.tsx (web) passes a variablesCacheKey: null top-level field that does not exist in UniwindContextType, which will fail bun run check:typescript.

Confidence Score: 4/5

The feature implementation is solid; the one concrete defect is a stale variablesCacheKey field in the web test that would break TypeScript compilation before tests can run.

The variablesCacheKey: null excess property passed to getWebVariable in the last web test does not exist in UniwindContextType. This is a leftover from an earlier design where the cache key lived as a top-level context field instead of inside variables.__uniwindVariablesCacheKey. TypeScript's excess-property check will reject it, so bun run check:typescript fails before any test executes. Everything else — the prototype-chain overlay on native, the try/finally disposal on web, the sorted-entry cache key, and the isMountRef mount optimisation — looks correct.

Files Needing Attention: packages/uniwind/tests/web/components/scoped-variables.test.tsx — the getWebVariable test on lines 140 and 145 passes a variablesCacheKey field that does not exist in the context type.

Important Files Changed

Filename Overview
packages/uniwind/src/components/ScopedVariables/utils.ts Shared merge/validate logic; invalid keys are always filtered (not just in DEV), cache key computed over sorted entries after stripping the sentinel, merging correctly preserves ancestor vars with nearest-wins semantics.
packages/uniwind/src/core/web/getWebStyles.ts Scoped variables applied/disposed around DOM reads with try/finally. Minor issue: applyScopedVariables iterates __uniwindVariablesCacheKey alongside real CSS vars, causing harmless but impure setProperty calls.
packages/uniwind/src/core/native/store.ts Cache key extended with __uniwindVariablesCacheKey; scoped vars overlaid via prototype chain onto theme vars, preventing mutation of global state.
packages/uniwind/src/core/native/native-utils.ts Extracts createVarGetter and adds getScopedVars with a WeakMap cache keyed on the variables reference; normalisation logic (culori color → hex) reused from config.
packages/uniwind/tests/web/components/scoped-variables.test.tsx Comprehensive coverage of web scoping, nesting, and disposal, but the last test passes variablesCacheKey: null — an excess property not in UniwindContextType — which will fail TypeScript compilation.
packages/uniwind/tests/native/components/scoped-variables.test.tsx Well-structured native tests covering override scope, nesting, numeric pass-through, color normalization, composition with ScopedTheme, cache key derivation, and stale-cache prevention.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["ScopedVariables variables={...}"] --> B["buildScopedVariablesContext"]
    B --> C["validateVariables (drops non -- keys)"]
    C --> D["merge: ...parent.variables, ...own"]
    D --> E["delete __uniwindVariablesCacheKey\nJSON.stringify(sorted entries)\nset __uniwindVariablesCacheKey"]
    E --> F["UniwindContext.Provider (updated variables)"]
    F --> G{Platform}
    G -->|Web| H["div display:contents with inline --vars\nchildren"]
    G -->|Native| I["Children with updated context"]
    H --> J["useCSSVariable / getWebStyles"]
    I --> K["useCSSVariable / UniwindStore.getStyles"]
    J --> L["applyScopedVariables setProperty on dummyParent\ntry { read } finally { dispose }"]
    K --> M["Object.create(themeVars) + getScopedVars\nprototype-chained overlay"]
    L --> N["parseCSSValue(computed)"]
    M --> O["vars[name](vars)"]
Loading

Reviews (6): Last reviewed commit: "Merge branch 'main' into feat/scoped-var..." | Re-trigger Greptile

Comment thread packages/uniwind/src/components/ScopedVariables/utils.ts Outdated
Comment thread packages/uniwind/src/core/web/getWebStyles.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/uniwind/src/components/ScopedVariables/utils.ts (1)

24-40: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Invalid-key filtering is dev-only; downstream consumers diverge in production.

validateVariables skips filtering entirely when !__DEV__ (Line 25-27), but ScopedVariables.tsx's inline-style loop always filters non--- keys regardless of environment. In a production build this means an invalid key stays in the exposed context.variables (read by getVariableValue.native.ts and applyScopedVariables in getWebStyles.ts) while never appearing as an actual inline custom property — a silent, hard-to-diagnose inconsistency between the two paths. Consider always filtering and only gating the Logger.error call behind __DEV__.

♻️ Proposed fix
 const validateVariables = (variables: CSSVariables) => {
-    if (!__DEV__) {
-        return variables
-    }
-
     return Object.fromEntries(
         Object.entries(variables).filter(([name]) => {
             if (!name.startsWith('--')) {
-                Logger.error(`CSS variable name must start with "--", instead got: ${name}`)
+                if (__DEV__) {
+                    Logger.error(`CSS variable name must start with "--", instead got: ${name}`)
+                }
 
                 return false
             }
 
             return true
         }),
     )
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/uniwind/src/components/ScopedVariables/utils.ts` around lines 24 -
40, Update validateVariables so it always removes variable names that do not
start with "--", regardless of __DEV__. Restrict only the Logger.error call to
development builds, preserving the filtered result for production consumers such
as context.variables and inline-style processing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/expo-example/ScopedVariablesDemo.tsx`:
- Around line 124-131: Update the cached subtree example in ScopedVariablesDemo,
specifically the ScopedVariables declaration with cacheKey="demo-amber", to
reuse the exact --color-primary and --gap values from section 2 while leaving
only the cacheKey difference. Keep the surrounding heading and AccentCard usage
unchanged.

In `@packages/uniwind/tests/native/components/scoped-variables.test.tsx`:
- Around line 163-182: Remove the unused `@ts-expect-error` directive from the
ScopedVariables test; the variables object already satisfies
ScopedVariablesProps and should remain unchanged so the test continues
validating the runtime warning and valid --gap styling.

In `@packages/uniwind/tests/web/components/scoped-variables.test.tsx`:
- Around line 8-31: Extend the scoped custom-property test around Probe and
ScopedVariables to update the provider’s variables prop after the initial
render, then assert that the subscribed useCSSVariable result rerenders with the
new DOM-cascaded value. Preserve the existing outside fallback assertion and
verify the inside consumer reflects both the initial and updated values.
- Around line 106-109: Remove the unused `@ts-expect-error` directive from the
invalid-keys test when rendering ScopedVariables. Keep the variables object
unchanged so the runtime filtering of the valid CSSVariables prop continues to
be tested.

---

Nitpick comments:
In `@packages/uniwind/src/components/ScopedVariables/utils.ts`:
- Around line 24-40: Update validateVariables so it always removes variable
names that do not start with "--", regardless of __DEV__. Restrict only the
Logger.error call to development builds, preserving the filtered result for
production consumers such as context.variables and inline-style processing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bcd8a38c-205e-43b8-9fea-e785e0254907

📥 Commits

Reviewing files that changed from the base of the PR and between 6cce440 and 232702e.

📒 Files selected for processing (22)
  • CONTEXT.md
  • apps/expo-example/App.tsx
  • apps/expo-example/ScopedVariablesDemo.tsx
  • apps/expo-example/global.css
  • packages/uniwind/src/components/ScopedVariables/ScopedVariables.native.tsx
  • packages/uniwind/src/components/ScopedVariables/ScopedVariables.tsx
  • packages/uniwind/src/components/ScopedVariables/index.ts
  • packages/uniwind/src/components/ScopedVariables/utils.ts
  • packages/uniwind/src/core/config/config.common.ts
  • packages/uniwind/src/core/config/config.native.ts
  • packages/uniwind/src/core/config/config.ts
  • packages/uniwind/src/core/context.ts
  • packages/uniwind/src/core/native/native-utils.ts
  • packages/uniwind/src/core/native/store.ts
  • packages/uniwind/src/core/web/getWebStyles.ts
  • packages/uniwind/src/hooks/useCSSVariable/getVariableValue.native.ts
  • packages/uniwind/src/index.ts
  • packages/uniwind/tests/consts.ts
  • packages/uniwind/tests/e2e/getWebStyles.test.ts
  • packages/uniwind/tests/native/components/scoped-variables.test.tsx
  • packages/uniwind/tests/type-test/theme.ts
  • packages/uniwind/tests/web/components/scoped-variables.test.tsx

Comment thread apps/expo-example/ScopedVariablesDemo.tsx Outdated
Comment thread packages/uniwind/tests/native/components/scoped-variables.test.tsx
Comment thread packages/uniwind/tests/web/components/scoped-variables.test.tsx
Comment thread packages/uniwind/tests/web/components/scoped-variables.test.tsx
- useCSSVariable: recompute on context change, not only on global
  Theme/Variables events — an updated <ScopedVariables> variables prop
  (or a nearer provider) now surfaces the new value. Adds web + native
  regression tests for a prop update.
- utils: always drop non-`--` keys (not just in dev), gating only the
  Logger.error behind __DEV__, so invalid keys can't reach the web read
  helper and corrupt a resolved inheritable property in production.
- getWebStyles/getWebVariable: wrap the scoped-variable read in
  try/finally so the temporary custom properties are always cleared,
  even if a DOM read throws.
- Document the variables prop stability contract (define outside render
  or useMemo) in JSDoc.
- Remove two unused @ts-expect-error directives in tests.
- Reword the demo's cacheKey section so it no longer claims parity with
  section 2.

@Brentlok Brentlok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR, I've done initial review for things that I've catched immediately, but I didn't dig any deeper into the logic yet. Since it's a huge PR and touches many core functionalities would you be okay, if I push some of my changes directly into this PR, it would be much faster in some cases than writing a detailed comments?

Comment thread apps/expo-example/ScopedVariablesDemo.tsx Outdated
Comment thread packages/uniwind/src/components/ScopedVariables/ScopedVariables.native.tsx Outdated
Comment thread packages/uniwind/src/components/ScopedVariables/utils.ts Outdated
Comment thread packages/uniwind/src/core/web/getWebStyles.ts Outdated
Comment thread packages/uniwind/src/hooks/useCSSVariable/useCSSVariable.ts Outdated
Comment thread packages/uniwind/tests/type-test/theme.ts Outdated

@Brentlok Brentlok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's too much long, multi line comments everywhere, it's not common in this repo

@dlebedynskyi

dlebedynskyi commented Jul 23, 2026

Copy link
Copy Markdown
Author

@Brentlok

if I push some of my changes directly into this PR, it would be much faster in some cases than writing a detailed comments?

please go ahead.

There's too much long, multi line comments everywhere, it's not common in this repo
Can you to what are you referring to here?



- Derive the native style cache key from the merged variables map instead
  of a user-supplied cacheKey prop; removes the cache-bypass path and the
  stale-key footgun
- Drop the display: contents View wrapper on native, render the bare
  provider like ScopedTheme.native
- Remove the expo-example demo (playground only, covered by tests)
- useCSSVariable: skip the mount-time recompute, useState already
  resolved the initial value
- Extract toWebValue (number -> px) web util, reuse in config,
  getWebStyles and the web wrapper
- Remove the ScopedVariables prop type test
- Trim long comments to match repo style

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/uniwind/src/components/ScopedVariables/utils.ts`:
- Around line 32-35: Update the variablesCacheKey serialization in the
mergedVariables cache-key construction to use an unambiguous encoding that
cannot collide when variable keys or values contain delimiters such as
semicolons or colons. Preserve deterministic ordering of entries so equivalent
variable maps produce the same key, and keep the resulting key compatible with
its use by UniwindStore.getStyles.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cd7d602a-9e01-4195-b622-fe5160ee43d9

📥 Commits

Reviewing files that changed from the base of the PR and between c34ed83 and d21795e.

📒 Files selected for processing (13)
  • CONTEXT.md
  • packages/uniwind/src/components/ScopedVariables/ScopedVariables.native.tsx
  • packages/uniwind/src/components/ScopedVariables/ScopedVariables.tsx
  • packages/uniwind/src/components/ScopedVariables/utils.ts
  • packages/uniwind/src/core/config/config.ts
  • packages/uniwind/src/core/native/native-utils.ts
  • packages/uniwind/src/core/native/store.ts
  • packages/uniwind/src/core/web/getWebStyles.ts
  • packages/uniwind/src/core/web/index.ts
  • packages/uniwind/src/core/web/webUtils.ts
  • packages/uniwind/src/hooks/useCSSVariable/useCSSVariable.ts
  • packages/uniwind/tests/native/components/scoped-variables.test.tsx
  • packages/uniwind/tests/web/components/scoped-variables.test.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/uniwind/src/core/native/native-utils.ts
  • packages/uniwind/src/core/config/config.ts
  • packages/uniwind/src/core/web/getWebStyles.ts

Comment thread packages/uniwind/src/components/ScopedVariables/utils.ts Outdated
@dlebedynskyi

Copy link
Copy Markdown
Author

@Brentlok
I've done a pass on your comments. Please take a look. Feel free to update PR as needed.

Dima Lebedynskyi and others added 4 commits July 23, 2026 10:11
The key:value; concatenation had no escaping, so values containing
separators could collide ({'--a': '1;--b:2'} vs {'--a': '1', '--b': '2'})
and serve wrong cached styles.
@Brentlok

Copy link
Copy Markdown
Contributor

@dlebedynskyi I've pushed some minor changes, I need to do some more testing as this is quite a big feature, but overall great contribution!

@Brentlok

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/uniwind/src/components/ScopedVariables/utils.ts (1)

4-6: 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

Preserve the optional native no-cache path.

buildScopedVariablesContext always sets variables.__uniwindVariablesCacheKey, and native getStyles uses that value in its cache key. As a result, every ScopedVariables subtree becomes cacheable even without an explicit cache key. Carry an optional key through the context and let native styles opt out of caching when it is absent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/uniwind/src/components/ScopedVariables/utils.ts` around lines 4 - 6,
Update ScopedVariablesProps and buildScopedVariablesContext to carry an optional
cache key instead of always assigning variables.__uniwindVariablesCacheKey.
Ensure native getStyles uses the key when provided but preserves the no-cache
path when it is absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/uniwind/src/components/ScopedVariables/utils.ts`:
- Around line 4-6: Update ScopedVariablesProps and buildScopedVariablesContext
to carry an optional cache key instead of always assigning
variables.__uniwindVariablesCacheKey. Ensure native getStyles uses the key when
provided but preserves the no-cache path when it is absent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a48f6b06-3ac7-4bea-a1d6-119243b948d8

📥 Commits

Reviewing files that changed from the base of the PR and between 367cadc and e4358bb.

📒 Files selected for processing (19)
  • .husky/pre-commit
  • packages/uniwind/src/components/ScopedVariables/ScopedVariables.tsx
  • packages/uniwind/src/components/ScopedVariables/utils.ts
  • packages/uniwind/src/components/web/useUniwindAccent.ts
  • packages/uniwind/src/core/config/config.common.ts
  • packages/uniwind/src/core/config/config.ts
  • packages/uniwind/src/core/context.ts
  • packages/uniwind/src/core/native/native-utils.ts
  • packages/uniwind/src/core/native/store.ts
  • packages/uniwind/src/core/types.ts
  • packages/uniwind/src/core/web/getWebStyles.ts
  • packages/uniwind/src/core/web/index.ts
  • packages/uniwind/src/core/web/parseCSSValue.ts
  • packages/uniwind/src/core/web/webUtils.ts
  • packages/uniwind/src/hooks/useCSSVariable/getVariableValue.native.ts
  • packages/uniwind/src/hooks/useCSSVariable/useCSSVariable.ts
  • packages/uniwind/tests/consts.ts
  • packages/uniwind/tests/e2e/getWebStyles.test.ts
  • packages/uniwind/tests/native/components/scoped-variables.test.tsx
💤 Files with no reviewable changes (3)
  • packages/uniwind/src/core/web/parseCSSValue.ts
  • packages/uniwind/tests/consts.ts
  • packages/uniwind/src/core/web/index.ts

@dlebedynskyi dlebedynskyi left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked over changes. All make sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants