Unify CSS-to-RN compiler and runtime pipeline#5
Draft
cray0000 wants to merge 32 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR unifies the CSS-to-React-Native style pipeline into a new
@cssxjs/css-to-rnworkspace package and wires CSSX, loaders, Babel output, and runtime entrypoints through it. The goal is to replace the separate forked CSS-to-RN transform libraries and the old CSSX runtime with one maintainable compiler/runtime package.Key changes:
packages/css-to-rn, a TypeScript ESM package owning CSS parsing, selector IR, value resolution, property transforms, style resolution, caching, and React runtime tracking.css/styltemplates, with interpolation values reusing one cache slot per compiled call shape.useRuntimeCss(),useCssxLayer(), andcssx().var()resolution, partial shorthand substitution, dynamic dependency tracking, bounded cache behavior, deep inline-style hashing, media/dimension tracking, webmatchMediainvalidation, and React NativeDimensionsintegration.@nx-js/observer-util, including Suspense/aborted-render cleanup tests.CssxProvider styleandthemefor subtree-scoped provider CSS, global utility classes, scoped:root/:root.<theme>variables, OS dark-mode auto selection, and component tag overrides.cssxjs/themes/tailwindandcssxjs/themes/shadcn.@custom-media, CSS media range evaluation for width/height comparisons, built-in@media (--theme-*)aliases, and provider-awareuseMedia().themed(tagName, Component), includingTag,Tag.class,Tag:part(name),Tag::part(name),Tag:hover, andTag:activematching.useCssVariable(),useCssVariableRaw(),getCssVariable(), andgetCssVariableRaw()for subscribed and global JS access to resolved CSS variables.useCssColor()andgetCssColor()for provider-aware JS color bridges, including token lookup andcolor-mix()style mixing.u()helper and build diagnostics for deprecated CSSuunits.variablesanddefaultVariablesproxy methods:.assign(),.set(), and.clear().var()inside inline style props and tracks the variables used by those inline props.oklch(),oklab(), andcolor-mix()through pinned@colordx/core@5.4.3so modern color CSS works on RN.calc()in CSS value resolution for color-channel math while still rejecting mixed layout calc such ascalc(100% - 16px).color-mix(in srgb, color, transparent)with premultiplied alpha so transparent theme colors preserve the source RGB.themed()preserves wrapped component props, andcssx()accepts loader-produced opaque sheet records at the type boundary.:hover/:activealiases,filter,background-image/gradient support, limitedbackgroundshorthand, animations/transitions/keyframes, and Reanimated v4-compatible animation style output.distoutput; package builds still emitdistfor published/default exports.runtime/*-teamplayimport paths as compatibility wrappers only.packages/runtimepackage from the active graph.architecture.md,AGENTS.md,plan.md, public docs, README credits, and CI smoke checks for the new architecture.Architect Review Follow-up
After a multi-agent architecture/performance/test-coverage review, this PR now also:
useCssxLayer(false)hook order stable when toggled to a real sheet:rootcustom property values{ sheet, values }layersvar()values in box-shadow/filter/text-shadow/transform/background:rootinterpolationRelated PRs
StartupjsProvider styleandthemeinto CSSX so framework users can pass provider CSS and theme selection through the StartupJS root provider.startupjsUiTheme.cssx.css, CSS variable primitives, and direct component tag/part overrides.Validation
cd packages/css-to-rn && npm testyarn testyarn docs-buildgit diff --checknode scripts/check-startupjs-ui-exports.mjs,yarn install --immutable --mode=skip-build, targeted eslint, and direct CSS-template compile smoke overpackages/plusstartupjsUiTheme.cssx.css.NODE_OPTIONS="-C cssx-ts" npm testincore/startupjs, plus the normal pre-commit hook with eslint andnpx startupjs check.Review Focus
This is a large architectural PR. Please scrutinize:
:root/:root.<theme>variable scoping and precedence relative to runtime/default variables.@media (--theme-*)behavior.@custom-media, range media evaluation, anduseMedia()subscriptions.themed()render-local tracking model.useCssVariable()/useCssColor()exact subscriptions and Suspense/aborted-render safety.matchMediasubscriptions, React Native dimensions, and listener cleanup.var(), shorthand fragments, modern colors, gradients/backgrounds, transforms, animations, transitions, and invalid generated CSS.styleName,css,styl, and part workflows.