Repository navigation
feat!: React contracts; target-support diagnostic; pruning-off warning - #430
Merged
Merged
Conversation
A React component can declare typed obligations on its renders with the same rule shape as Effect UI. A required attribute becomes a required prop; a conditional rule applies by variant value, counting the variant's default, and by tag; a state can discharge an obligation. Contracts are inherited through .extend() and kept inside composed families. Rule attrs are set at run time. The rule types move to @animus-ui/core so the two bindings share them. AnimusWithAll, AnimusComponent, AnimusWrappedComponent and the AnimusExtended classes gain a trailing contracts type parameter. Composed families keep union props of their slots. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
animus.style.unsupported-feature reports a property, at-rule or value function that a target browser lacks, located at the property, from a table generated out of web-features by css-support.ts. It does not fire for a feature Lightning CSS lowers, inside @supports, or when the project sets no targets. Under strict it fails the build. animus.usage.pruning-off names the computed member read that turned option and state pruning off for the whole build. The showcase had five such reads; written with .at() and a lookup function it now prunes, and its stylesheet drops from 258,938 to 254,141 bytes. Verified at this commit: vp run verify:full (55 of 55 tasks); both generators pass --check. The parity baselines are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Two changes, one commit each, on top of #429.
.contract()on React chainsA React component can declare typed obligations on whoever renders it, with the same rule shape as Effect UI.
<Link>withouthreffails withProperty 'href' is missing.aria-labeloraria-labelledbyonly whenkindisiconOnly;aria-label={undefined}does not discharge it.decorativein place ofalt)..extend()and kept inside composed families. A rule'sattrsare set at run time.@animus-ui/core, so the two bindings share them. Effect UI's fixtures pass unchanged. The extractor already recognised the step; a chain with a contract emits the same CSS as one without.packages/react/types/published/contract.tsx: 11 negative assertions, each failing on both compilers in both modes when its directive is removed.Limit: rendering with no props at all against a state-discharge rule (
<Picture />) fails without naming the missing attribute.Target-support diagnostic; pruning-off warning
animus.style.unsupported-featurereports a property, at-rule or value function that at least one target browser lacks, located at the property, withfeatureandreasonfields. The data is a table generated fromweb-featuresbypackages/extract/scripts/css-support.ts(--write/--check): 578 properties, 24 at-rules, about 117 functions, 9 KB gzipped.@supports, or when the project sets no targets (browserslist defaults do not count).packages/_integration/__tests__/target-support.test.ts.animus.usage.pruning-off(warn) names the computed member read that turned option and state pruning off for the whole build, and how many options ship because of it. Before, the only trace was one line under verbose..at()and a lookup function it now prunes 17 of 234 options, and its stylesheet drops from 258,938 to 254,141 bytes.Known weakness:
web-featurescounts a partial implementation as unsupported, sooutlineis reported for Safari before 16.4. A follow-up will take first-shipped versions instead.Not covered: keyword-level support, selectors and pseudo-classes, and at-rules outside component styles (
@property,@position-try,@keyframes,@font-face).Release notes
.contract(rule)on React and.extend()chains.ContractRequirement,ContractRuleandContractRuleEntryare exported from@animus-ui/coreand@animus-ui/react.AnimusWithAll,AnimusComponent,AnimusWrappedComponentand theAnimusExtended*classes gain a trailing contracts type parameter. Composed families keep union props of their slots.diagnostics: { 'animus.style.unsupported-feature': 'warn' }or'off'to relax it.animus.usage.pruning-off.Verification
vp run verify:fullpasses at8f934f3f: 55 of 55 tasks. Both generators pass--check. The parity baselines are unchanged.verify:benchwas not run: every row reports INVALID untilscripts/bench/accepted-differences.jsonrecords the output differences noted on feat!: structured diagnostics, tighter types, CI hardening #427 and feat!: faster style-object types; sound pruning of unused options #429.🤖 Generated with Claude Code