diff --git a/AGENTS.md b/AGENTS.md index e6f39687..c9053bfe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -118,6 +118,7 @@ Before pushing a change to `packages/extract/**` or to a plugin (`packages/vite- | the CSS vocabulary: `@webref/css`, `web-features` or `csstype` (`css-keywords.ts --write` also regenerates `packages/core/src/types/specification-properties.ts`) | `node packages/extract/scripts/css-keywords.ts --write`, then the `packages/core/src/**` and `extractor/src/**` rows | | `ANIMUS_LAYERS` in `packages/extract/pipeline/assemble-stylesheet.ts` (`node packages/extract/scripts/layer-order.ts --write` regenerates `layer_order.json`) | the `extractor/src/**` row | | `packages/extract/scripts/node-builtins.ts` (`--write`, under Node 24, regenerates `node_builtins.json`; rerun it when the pinned Node major changes) | `node packages/extract/scripts/node-builtins.ts --check`, then the `extractor/src/**` row | +| `packages/extract/scripts/css-support.ts`, or a `web-features` or `@webref/css` update (`node packages/extract/scripts/css-support.ts --write` regenerates `packages/extract/pipeline/css-support-table.ts`) | `node packages/extract/scripts/css-support.ts --check`, then the `packages/extract/pipeline/**` row | | `packages/extract/crates/system-loader/**` | the `extractor/src/**` row | | `packages/extract/crates/extractor/Cargo.toml` | `vp run verify:clippy && vp run verify:hygiene:rust && vp run verify:unit:rust` | | `packages/extract/pipeline/**` | `vp run verify:compile && vp run verify:unit:ts && vp run verify:canary && vp run build:ts && vp run verify:types && vp run verify:integration` | diff --git a/packages/_integration/__tests__/target-support.test.ts b/packages/_integration/__tests__/target-support.test.ts new file mode 100644 index 00000000..6d0c903c --- /dev/null +++ b/packages/_integration/__tests__/target-support.test.ts @@ -0,0 +1,53 @@ +import { + unsupportedFeatures, + withoutLoweredFeatures, +} from '@animus-ui/extract/pipeline'; +import { expect, test } from 'vitest'; + +import { analyzeProject } from './run-pipeline'; + +import type { + LightningTargets, + ManifestDiagnostic, +} from '@animus-ui/extract/pipeline'; + +const path = 'fixtures/target-support.tsx'; +const source = `import { ds } from './setup'; +export const Tip = ds + .styles({ + anchorName: '--tip', + '@supports (position-anchor: --tip)': { positionAnchor: '--tip' }, + }) + .asElement('div'); +export const App = () => ; +`; + +function reported(targets: LightningTargets): ManifestDiagnostic[] { + const manifest = JSON.parse( + analyzeProject(JSON.stringify([{ path, source }]), { + analysisContextJson: JSON.stringify({ + unsupportedFeatures: Object.fromEntries(unsupportedFeatures(targets)), + }), + }) + ) as { diagnostics: ManifestDiagnostic[] }; + return withoutLoweredFeatures(manifest.diagnostics, { + targets, + features: {}, + }).filter((d) => d.code === 'animus.style.unsupported-feature'); +} + +test('a property the targets lack is reported at the property, unless the targets support it or it sits inside a matching @supports', () => { + const lacking = reported({ safari: (16 << 16) | (4 << 8) }); + expect(lacking).toHaveLength(1); + expect(lacking[0]).toMatchObject({ + file: path, + component: 'Tip', + property: 'anchor-name', + reason: 'unsupported-property', + line: 4, + column: 17, + }); + expect(lacking[0]!.message).toContain('safari 16.4'); + + expect(reported({ chrome: 130 << 16 })).toEqual([]); +}); diff --git a/packages/core/src/binding.ts b/packages/core/src/binding.ts index 6bd23871..170c54af 100644 --- a/packages/core/src/binding.ts +++ b/packages/core/src/binding.ts @@ -16,6 +16,12 @@ export type { StripIndex, VariantProps, } from './types/class-props.js'; +export type { + ContractTagMatches, + ContractValues, + ExactContractRule, + VariantOptionMap, +} from './types/contract.js'; export type { AdmittedNames, StylingNames, diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 8062545a..52df7fa4 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -115,6 +115,11 @@ export type { BuilderClassProps, BuilderClassResolver, } from './types/class-props.js'; +export type { + ContractRequirement, + ContractRule, + ContractRuleEntry, +} from './types/contract.js'; export { type Assign, type AssignValueIfUnmergable, diff --git a/packages/core/src/types/contract.ts b/packages/core/src/types/contract.ts new file mode 100644 index 00000000..79dbed9d --- /dev/null +++ b/packages/core/src/types/contract.ts @@ -0,0 +1,67 @@ +import type { StripIndex } from './class-props'; +import type { VariantKeyOf } from './config'; + +export interface ContractRequirement { + readonly attrs?: readonly string[]; + readonly anyAttr?: readonly string[]; +} + +export interface ContractRule< + VMap = Readonly>, + StateKeys extends string = string, +> { + readonly when?: { + readonly [K in keyof VMap & string]?: VMap[K] | readonly VMap[K][]; + }; + readonly whenTag?: string | readonly string[]; + readonly attrs?: Readonly>; + readonly require?: ContractRequirement; + readonly dischargedByState?: readonly StateKeys[]; +} + +export interface ContractRuleEntry { + readonly when?: Readonly< + Record + >; + readonly whenTag?: string | readonly string[]; + readonly attrs?: Readonly>; + readonly require?: ContractRequirement; + readonly dischargedByState?: readonly string[]; +} + +type NoExtraKeys = { + readonly [K in Exclude]: never; +}; + +export type ExactContractRule = Rule & + NoExtraKeys & + (Rule extends { readonly require: infer Requirement } + ? { readonly require: NoExtraKeys } + : unknown) & + (Rule extends { readonly when: infer When } + ? { readonly when: NoExtraKeys } + : unknown); + +export type VariantOptionMap = { + [K in keyof StripIndex]: StripIndex[K] extends { + variants: infer Options; + } + ? VariantKeyOf + : never; +}; + +export type ContractValues = T extends readonly (infer Item extends string)[] + ? Item + : T extends string + ? T + : never; + +export type ContractTagMatches = [ + WhenTag, +] extends [undefined] + ? true + : string extends BoundTag + ? true + : [Extract>] extends [never] + ? false + : true; diff --git a/packages/effect-ui/src/types.ts b/packages/effect-ui/src/types.ts index 70e4ea3e..b3f23a01 100644 --- a/packages/effect-ui/src/types.ts +++ b/packages/effect-ui/src/types.ts @@ -8,6 +8,9 @@ import type { CreateViewTransitionsFactory, ClassResolver, CompoundEntry, + ContractRequirement, + ContractRule, + ContractRuleEntry, CSSPropMap, CSSProps, CustomPropConfig, @@ -32,10 +35,14 @@ import type { VariantKeyOf, } from '@animus-ui/core'; import type { + ContractTagMatches, + ContractValues, + ExactContractRule, StylingNames, SystemPicks, UnadmittedName, UnadmittedStates, + VariantOptionMap, } from '@animus-ui/core/binding'; import type { ClassResolverConfig } from '@animus-ui/core/runtime'; @@ -106,14 +113,6 @@ export type RequiredVariantKeys = Extract< string >; -export type VariantOptionMap = { - [K in keyof StripIndex]: StripIndex[K] extends { - variants: infer Options; - } - ? VariantKeyOf - : never; -}; - type InitialVariantState = { [K in keyof StripIndex]: DefaultVariantValue[K]>; }; @@ -144,71 +143,14 @@ type CustomValueMap> = { >; }; -export interface ContractRequirement { - readonly attrs?: readonly string[]; - readonly anyAttr?: readonly string[]; -} - -export interface ContractRule< - VMap = Readonly>, - StateKeys extends string = string, -> { - readonly when?: { - readonly [K in keyof VMap & string]?: VMap[K] | readonly VMap[K][]; - }; - readonly whenTag?: string | readonly string[]; - readonly attrs?: Readonly>; - readonly require?: ContractRequirement; - readonly dischargedByState?: readonly StateKeys[]; -} - -type NoExtraKeys = { - readonly [K in Exclude]: never; -}; - -type ExactContractRule = Rule & - NoExtraKeys & - (Rule extends { readonly require: infer Requirement } - ? { readonly require: NoExtraKeys } - : unknown) & - (Rule extends { readonly when: infer When } - ? { readonly when: NoExtraKeys } - : unknown); - -export interface ContractRuleEntry { - readonly when?: Readonly< - Record - >; - readonly whenTag?: string | readonly string[]; - readonly attrs?: Readonly>; - readonly require?: ContractRequirement; - readonly dischargedByState?: readonly string[]; -} - interface ObligationUnit { readonly attrs: string; readonly states: string; } -type ToUnion = T extends readonly (infer Item extends string)[] - ? Item - : T extends string - ? T - : never; - -type TagMatches = [WhenTag] extends [ - undefined, -] - ? true - : string extends BoundTag - ? true - : [Extract>] extends [never] - ? false - : true; - type WhenEntriesMatch = { [K in keyof When & string]: K extends keyof CurrentV - ? [Extract>] extends [never] + ? [Extract>] extends [never] ? false : true : false; @@ -256,7 +198,7 @@ type ActiveObligations< ? never : C[number] extends infer Rule ? Rule extends ContractRuleEntry - ? TagMatches> extends true + ? ContractTagMatches> extends true ? VariantMatches> extends true ? RuleObligations : never @@ -1457,6 +1399,10 @@ export interface EffectUiSystemBuilder< export type { ClassResolverConfig, CompoundEntry, + ContractRequirement, + ContractRule, + ContractRuleEntry, ResponsiveProp, ThemedCSSPropMap, + VariantOptionMap, }; diff --git a/packages/extract/crates/extractor/src/analyze_css.rs b/packages/extract/crates/extractor/src/analyze_css.rs index f6f7cdd6..1e9d1dab 100644 --- a/packages/extract/crates/extractor/src/analyze_css.rs +++ b/packages/extract/crates/extractor/src/analyze_css.rs @@ -179,6 +179,13 @@ pub struct AnalysisContext { pub font_preloads: Option>, pub prop_order: bool, pub exclude: Option>, + pub unsupported_features: BTreeMap, +} + +#[derive(Debug, Default, Clone, serde::Deserialize)] +pub struct UnsupportedFeature { + pub feature: String, + pub targets: Vec, } pub(crate) fn is_system_module(path: &str, inputs: &CssInputs) -> bool { @@ -487,6 +494,10 @@ pub struct CssDiagnostic { #[serde(skip_serializing_if = "Option::is_none")] pub value: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub feature: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub emitted: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub reason: Option<&'static str>, #[serde(skip)] pub(crate) offset: Option, @@ -624,6 +635,7 @@ const MISSING_MODULE_REACH: &str = "animus.load.missing-module-reach"; const WIDE_MODULE_LOAD_LIMIT: usize = 20; const IDENTITY_UNCERTAIN: &str = "animus.usage.identity-uncertain"; const IDENTITY_UNCERTAIN_TAG: &str = "animus.usage.identity-uncertain-tag"; +const PRUNING_OFF: &str = "animus.usage.pruning-off"; const CLASS_NAME_WHITESPACE: &str = "animus.chain.class-name-whitespace"; const STYLING_NAME_COLLISION: &str = "animus.chain.styling-name-collision"; const UNEXTRACTABLE_CHAIN: &str = "animus.chain.unextractable"; @@ -643,6 +655,7 @@ pub(crate) const STATIC_CSS_UNKNOWN_NAME: &str = "animus.static-css.unknown-name pub(crate) const STATIC_CSS_INVALID_SHAPE: &str = "animus.static-css.invalid-shape"; const INVALID_OPACITY_MODIFIER: &str = "animus.style.invalid-opacity-modifier"; +const UNSUPPORTED_FEATURE: &str = "animus.style.unsupported-feature"; pub(crate) const DIAGNOSTIC_CODES: &[(&str, &str)] = &[ (crate::eval::SELECTOR_UNSUPPORTED_SUBJECT, "error"), @@ -680,6 +693,7 @@ pub(crate) const DIAGNOSTIC_CODES: &[(&str, &str)] = &[ (MISSING_MODULE_REACH, "warn"), (IDENTITY_UNCERTAIN, "warn"), (IDENTITY_UNCERTAIN_TAG, "info"), + (PRUNING_OFF, "warn"), (UNEXTRACTABLE_CHAIN, "warn"), (SKIPPED_VALUE, "warn"), (FIRST_THAT_WORKS_UNEXTRACTED, "warn"), @@ -709,6 +723,7 @@ pub(crate) const DIAGNOSTIC_CODES: &[(&str, &str)] = &[ (crate::theme::FONT_PRELOAD_INVALID, "error"), (CLASS_NAME_WHITESPACE, "warn"), (INVALID_OPACITY_MODIFIER, "warn"), + (UNSUPPORTED_FEATURE, "error"), (UNSUPPORTED_OBJECT_MEMBER, "error"), (NAMESPACE_ROOT_THROUGH_BARREL, "error"), (RUNTIME_BUILDER_REFERENCE, "error"), @@ -750,6 +765,8 @@ pub(crate) fn diagnostic( dropped: None, property: None, value: None, + feature: None, + emitted: None, reason: None, offset: None, site: None, @@ -3480,6 +3497,170 @@ fn warn_invalid_opacity_modifiers( } } +fn value_functions(value: &str) -> Vec { + let mut names = Vec::new(); + let mut quote: Option = None; + let mut start: Option = None; + for (at, c) in value.char_indices() { + if let Some(open) = quote { + if c == open { + quote = None; + } + continue; + } + match c { + '"' | '\'' => { + quote = Some(c); + start = None; + } + '(' => { + if let Some(from) = start.take() { + names.push(value[from..at].to_ascii_lowercase()); + } + } + c if c.is_ascii_alphanumeric() || c == '-' || c == '_' => { + if start.is_none() && !c.is_ascii_digit() { + start = Some(at); + } + } + _ => start = None, + } + } + names +} + +fn at_rule_of(condition: &crate::theme::Condition) -> Option<(&'static str, &str)> { + use crate::theme::Condition; + match condition { + Condition::Breakpoint(_) | Condition::Supports(_) => None, + Condition::Media(prelude) => Some(("media", prelude)), + Condition::Container(prelude) => Some(("container", prelude)), + Condition::Scope(prelude) => Some(("scope", prelude)), + Condition::StartingStyle(prelude) => Some(("starting-style", prelude)), + } +} + +fn authored_key(property: &str) -> String { + let mut key = String::with_capacity(property.len()); + let mut upper = false; + for c in property.chars() { + if c == '-' && !key.is_empty() { + upper = true; + } else if upper { + key.push(c.to_ascii_uppercase()); + upper = false; + } else { + key.push(c); + } + } + key +} + +type Origin = Option<(String, Option)>; + +struct FeatureScan<'a> { + features: &'a BTreeMap, + file: &'a str, + component: &'a str, + seen: FxHashSet<(String, String)>, + found: Vec, +} + +impl FeatureScan<'_> { + fn finding(&mut self, key: String, emitted: String, named: impl FnOnce() -> String) -> Option { + let feature = self.features.get(&key)?; + if !self.seen.insert((key.clone(), emitted.clone())) { + return None; + } + let message = format!( + "{} ({}) is not supported by {} among this build's targets, and Lightning CSS does not lower it for \ + them — guard it with @supports, or raise the targets", + named(), + feature.feature, + feature.targets.join(", ") + ); + let mut record = diagnostic(self.file, self.component, "warn", message, Some(UNSUPPORTED_FEATURE)); + record.feature = Some(key); + record.emitted = Some(emitted); + Some(record) + } + + fn declarations(&mut self, declarations: &[CssDeclaration], origin: &Origin) { + for declaration in declarations { + let property = declaration.property.as_str(); + if property.starts_with("--") { + continue; + } + let emitted = format!("{property}:{}", declaration.value); + let seek = |written: Written| Seek { key: Some(authored_key(property)), written, breakpoint: None, origin: origin.clone() }; + if let Some(record) = self.finding(format!("property:{property}"), emitted.clone(), || format!("'{property}'")) { + self.found.push( + record.concerning(property).written(&declaration.value).because("unsupported-property").seeking(seek(Written::Any)), + ); + } + for function in value_functions(&declaration.value) { + let named = || format!("{function}() in '{property}'"); + if let Some(record) = self.finding(format!("function:{function}"), emitted.clone(), named) { + self.found.push( + record + .concerning(property) + .written(&declaration.value) + .because("unsupported-function") + .seeking(seek(Written::Contains(format!("{function}(")))), + ); + } + } + } + } + + fn styles(&mut self, styles: &ResolvedStyles, origin: &Origin) { + self.declarations(&styles.declarations, origin); + for (_, declarations, _) in &styles.pseudo_selectors { + self.declarations(declarations, origin); + } + for group in &styles.conditioned { + if group.conditions.iter().any(|condition| matches!(condition, crate::theme::Condition::Supports(_))) { + continue; + } + for (name, prelude) in group.conditions.iter().filter_map(at_rule_of) { + if let Some(record) = self.finding(format!("at-rule:{name}"), prelude.to_string(), || format!("@{name}")) { + self.found.push(record.written(prelude).because("unsupported-at-rule").seeking(Seek { + key: Some(prelude.to_string()), + written: Written::Any, + breakpoint: None, + origin: origin.clone(), + })); + } + } + self.declarations(&group.declarations, origin); + } + } +} + +fn unsupported_feature_diagnostics( + css: &ComponentCss, + features: &BTreeMap, + file: &str, + component: &str, +) -> Vec { + let mut scan = FeatureScan { features, file, component, seen: FxHashSet::default(), found: Vec::new() }; + if let Some(base) = css.base.as_ref() { + scan.styles(base, &None); + } + for variant in &css.variants { + for (option, styles) in &variant.options { + scan.styles(styles, &Some((variant.prop.clone(), Some(option.clone())))); + } + } + for styles in &css.compounds { + scan.styles(styles, &None); + } + for (_, styles) in &css.states { + scan.styles(styles, &None); + } + scan.found +} + fn shed_unresolved_aliases( css: &mut ComponentCss, scale_check: &ScaleCheck<'_>, @@ -5418,6 +5599,45 @@ fn identity_uncertainty_diagnostics( .collect() } +fn pruning_off_diagnostics(gaps: &[SlotOpening], options: usize, states: usize) -> Vec { + gaps.iter() + .map(|gap| { + let rule = gap.detail.as_deref().unwrap_or(gap.rule); + let (what, remedy) = match rule { + "prototype-use" => ( + "a computed member read whose key analysis cannot bound lets its value go, and the key could be '__proto__' or 'constructor'", + "read it with a numeric key (an index, or arithmetic such as i + 1), a string literal, or a method such as .at() or Map.get()", + ), + "prototype-let-go" => ("a built-in prototype is let go", "keep built-in prototypes out of values other code can reach"), + "string-code" => ("code built from a string may run (eval, Function or a constructor called by name)", "remove the dynamic code"), + "writer-let-go" => ("a reflection writer such as Object.assign or Reflect.set is let go", "call it where it is read"), + "prop-key-store" => ( + "a store writes a key that names an Animus prop or option into an object analysis cannot follow", + "write that key into an object literal analysis can see", + ), + _ => ("the file may patch a built-in prototype", "remove the construct the location names"), + }; + let file = gap.file.as_deref().unwrap_or("usage"); + let record = diagnostic( + file, + "pruning", + "warn", + format!( + "off for this build: {what} ({rule}), so analysis cannot prove that no prop is inherited from a \ + patched prototype, and every variant option and state ships ({}, {}) — {remedy}", + count_of(options, "variant option"), + count_of(states, "state"), + ), + Some(PRUNING_OFF), + ); + match gap.at { + Some(at) => record.at(at), + None => record, + } + }) + .collect() +} + fn first_site_of(ff: &FileFacts, name: &str) -> Option<(bool, Option, u32)> { ff.usage_for_analysis().iter().find_map(|fact| match fact { UsageFact::Element { tag: TagFact::Ident(tag) | TagFact::Member(tag), span, origin, written_as_call, .. } @@ -8467,6 +8687,14 @@ fn run_with_system_floor( external: is_external_file(file_path, &inputs.external_dirs), }; let binding = &chain.descriptor.binding; + if !inputs.analysis_context.unsupported_features.is_empty() { + diagnostics.extend(unsupported_feature_diagnostics( + own_css.as_ref().unwrap_or(&component_css), + &inputs.analysis_context.unsupported_features, + file_path, + binding, + )); + } let mut merged_in = Vec::new(); let sink = if own_css.is_some() { &mut merged_in } else { &mut diagnostics }; shed_unresolved_aliases(&mut component_css, &scale_check, file_path, binding, sink); @@ -9699,6 +9927,11 @@ fn run_with_system_floor( Some(SlotOpening { at: Some(*at), ..SlotOpening::rule("patches-intrinsics").in_file(file).detail("prop-key-store") }) })); let props_patched = !patch_gaps.is_empty(); + if props_patched && !inputs.dev_mode { + let options = evaluated.values().map(|(css, ..)| css.variants.iter().map(|variant| variant.options.len()).sum::()).sum(); + let states = evaluated.values().map(|(css, ..)| css.states.len()).sum(); + diagnostics.extend(pruning_off_diagnostics(&patch_gaps, options, states)); + } let opened_ids: Vec<&String> = if props_patched { evaluated.keys().collect() } else { escaped_ids.iter().collect() }; let mut opened_usage = UsageScanResult::default(); for component_id in opened_ids { diff --git a/packages/extract/crates/extractor/src/value_site.rs b/packages/extract/crates/extractor/src/value_site.rs index 36ed9dfa..ef9f6eac 100644 --- a/packages/extract/crates/extractor/src/value_site.rs +++ b/packages/extract/crates/extractor/src/value_site.rs @@ -60,6 +60,15 @@ fn same_value(found: &Value, wanted: &Value) -> bool { impl ValueSite { pub(crate) fn find(&self, source: &str) -> Option { + self.find_keyed(source).or_else(|| match (&self.seek.key, &self.seek.written) { + (Some(_), Written::Contains(_)) => { + Self { seek: Seek { key: None, ..self.seek.clone() }, stages: self.stages.clone() }.find_keyed(source) + } + _ => None, + }) + } + + fn find_keyed(&self, source: &str) -> Option { self.stages.iter().find_map(|stage| { let span = if stage.method == "compound" { stage.second_arg_span? } else { stage.arg_span }; self.in_stage(&stage.method, source, span) diff --git a/packages/extract/pipeline/css-support-table.ts b/packages/extract/pipeline/css-support-table.ts new file mode 100644 index 00000000..13c086d0 --- /dev/null +++ b/packages/extract/pipeline/css-support-table.ts @@ -0,0 +1,988 @@ +export const CSS_SUPPORT = { + browsers: [ + 'chrome', + 'chrome_android', + 'edge', + 'firefox', + 'firefox_android', + 'safari', + 'safari_ios', + ], + features: [ + 'abs-sign=abs() and sign()', + 'accent-color=accent-color', + 'alignment-baseline=alignment-baseline', + 'all=all', + 'alpha=alpha()', + 'anchor-positioning=Anchor positioning', + 'animation-composition=animation-composition', + 'animations-css=Animations (CSS)', + 'appearance=appearance', + 'aspect-ratio=aspect-ratio', + 'attr-contents=attr() (content only)', + 'backdrop-filter=backdrop-filter', + 'background=background', + 'background-attachment=background-attachment', + 'background-blend-mode=background-blend-mode', + 'background-clip=background-clip', + 'background-color=background-color', + 'background-image=background-image', + 'background-origin=background-origin', + 'background-position=background-position', + 'background-repeat=background-repeat', + 'background-size=background-size', + 'baseline-shift=baseline-shift', + 'baseline-source=baseline-source', + 'border-image=Border images', + 'border-radius=border-radius', + 'border-shape=border-shape', + 'borders=Borders', + 'box-decoration-break=box-decoration-break', + 'box-shadow=box-shadow', + 'box-sizing=box-sizing', + 'calc=calc()', + 'calc-size=calc-size()', + 'caret-color=caret-color', + 'caret-shape=caret-shape', + 'cascade-layers=Cascade layers', + 'charset=@charset', + 'clip=clip', + 'clip-path=clip-path', + 'color=Color', + 'color-adjust=color-adjust', + 'color-function=color()', + 'color-mix=color-mix()', + 'color-scheme=color-scheme', + 'column-fill=column-fill', + 'column-span=column-span', + 'column-wrap=column-wrap', + 'conic-gradients=Conic gradients', + 'contain=contain', + 'contain-intrinsic-size=contain-intrinsic-size', + 'container-queries=Container queries (size)', + 'content=Content', + 'content-visibility=content-visibility', + 'contrast-color=contrast-color()', + 'corner-shape=corner-shape', + 'counter-set=counter-set', + 'counter-style=@counter-style', + 'counters=Counters (CSS)', + 'cross-document-view-transitions=Cross-document view transitions', + 'cross-fade=cross-fade()', + 'cubic-bezier-easing=cubic-bezier() easing', + 'cursor=Cursor styles', + 'custom-media-queries=Custom media queries', + 'custom-properties=Custom properties', + 'display=Display', + 'dominant-baseline=dominant-baseline', + 'dynamic-range-limit=dynamic-range-limit', + 'element=element()', + 'exp-functions=Exponential functions (CSS)', + 'field-sizing=field-sizing', + 'filter=filter', + 'filter-function=filter()', + 'flexbox=Flexbox', + 'float-clear=float and clear', + 'font-face=@font-face', + 'font-family=font-family', + 'font-feature-settings=font-feature-settings', + 'font-kerning=font-kerning', + 'font-language-override=font-language-override', + 'font-optical-sizing=font-optical-sizing', + 'font-palette=font-palette', + 'font-shorthand=Font shorthand', + 'font-size=font-size', + 'font-size-adjust=font-size-adjust', + 'font-stretch=font-stretch', + 'font-style=font-style', + 'font-synthesis=font-synthesis', + 'font-synthesis-position=font-synthesis-position', + 'font-synthesis-small-caps=font-synthesis-small-caps', + 'font-synthesis-style=font-synthesis-style', + 'font-synthesis-weight=font-synthesis-weight', + 'font-variant=font-variant', + 'font-variant-alternates=font-variant-alternates', + 'font-variant-caps=font-variant-caps', + 'font-variant-east-asian=font-variant-east-asian', + 'font-variant-emoji=font-variant-emoji', + 'font-variant-ligatures=font-variant-ligatures', + 'font-variant-numeric=font-variant-numeric', + 'font-variant-position=font-variant-position', + 'font-variation-settings=font-variation-settings', + 'font-weight=font-weight', + 'font-width=font-width', + 'forced-colors=Forced colors', + 'frame-sizing=Responsive iframes', + 'function=@function', + 'gap-decorations=Gap decorations', + 'glyph-orientation-vertical=glyph-orientation-vertical', + 'gradients=Gradients', + 'grid=Grid', + 'grid-lanes=Grid lanes', + 'hanging-punctuation=Hanging punctuation', + 'hsl=HSL', + 'hwb=HWB', + 'hyphenate-character=Hyphenate character', + 'hyphenate-limit-chars=Hyphenate limit chars', + 'hyphenate-limit-lines=hyphenate-limit-lines', + 'hyphens=Hyphenation', + 'if=if()', + 'image-orientation=image-orientation', + 'image-rendering=image-rendering', + 'image-set=image-set()', + 'ime-mode=ime-mode', + 'import=@import', + 'individual-transforms=Individual transform properties', + 'initial-letter=initial-letter', + 'interactivity=interactivity', + 'interest-invokers=Interest invokers', + 'interpolate-size=interpolate-size', + 'isolation=isolation', + 'lab=Lab and LCH', + 'layout-direction-override=Layout direction override', + 'letter-spacing=letter-spacing', + 'light-dark=light-dark()', + 'line-break=line-break', + 'line-clamp=line-clamp', + 'line-height=line-height', + 'link-parameters=Link parameters', + 'list-style=List style', + 'logical-properties=Logical properties', + 'margin=margin', + 'margin-trim=margin-trim', + 'mask-border=mask-border', + 'mask-type=mask-type', + 'masks=Masks', + 'mathml=MathML', + 'media-queries=Media queries', + 'min-max-clamp=min(), max(), and clamp()', + 'min-max-width-height=Min and max width and height', + 'mix-blend-mode=mix-blend-mode', + 'mixin=@mixin', + 'motion-path=Motion path', + 'multi-column=Multi-column layout', + 'namespace=@namespace', + 'object-fit=object-fit', + 'object-position=object-position', + 'object-view-box=object-view-box', + 'oklab=Oklab and OkLCh', + 'opacity=opacity', + 'opacity-svg=Opacity (SVG)', + 'outline=outline', + 'outlines=Outlines', + 'overflow-anchor=overflow-anchor', + 'overflow-clip-margin=overflow-clip-margin', + 'overflow-shorthand=overflow', + 'overflow-wrap=overflow-wrap', + 'overlay=overlay', + 'overscroll-behavior=overscroll-behavior', + 'padding=padding', + 'page-break-aliases=Page break aliases', + 'page-breaks=Page breaks', + 'page-setup=Page setup', + 'paint=paint()', + 'paint-order=paint-order', + 'path-shape=path()', + 'physical-properties=Physical properties', + 'pointer-events=pointer-events', + 'position=Position', + 'print-color-adjust=print-color-adjust', + 'progress-function=progress()', + 'quotes=Quotes', + 'random-function=random()', + 'random-item=random-item()', + 'reading-flow=reading-flow', + 'rect-xywh=rect() and xywh()', + 'registered-custom-properties=Registered custom properties', + 'resize=resize (CSS property)', + 'rgb=RGB', + 'round-mod-rem=round(), mod(), and rem()', + 'ruby-align=ruby-align', + 'ruby-overhang=ruby-overhang', + 'ruby-position=ruby-position', + 'safe-area-inset=Safe area inset environment variables', + 'scope=@scope', + 'scroll-axis-lock=scroll-axis-lock', + 'scroll-behavior=scroll-behavior', + 'scroll-driven-animations=Scroll-driven animations', + 'scroll-initial-target=scroll-initial-target', + 'scroll-markers=Scroll markers', + 'scroll-snap=Scroll snap', + 'scroll-target-group=scroll-target-group', + 'scroll-triggered-animations=Scroll-triggered animations', + 'scrollbar-color=scrollbar-color', + 'scrollbar-gutter=scrollbar-gutter', + 'scrollbar-width=scrollbar-width', + 'shape-function=shape()', + 'shape-outside=shape-outside', + 'shapes=shapes', + 'sibling-count=sibling-count() and sibling-index()', + 'speak=speak', + 'speak-as=speak-as', + 'starting-style=@starting-style', + 'steps-easing=steps() easing', + 'supports=@supports', + 'svg=SVG', + 'svg-filters=SVG filters', + 'tab-size=tab-size', + 'table=Tables', + 'text-align=text-align', + 'text-align-last=text-align-last', + 'text-autospace=text-autospace', + 'text-box=text-box', + 'text-combine-upright=text-combine-upright', + 'text-decoration=text-decoration', + 'text-decoration-inset=text-decoration-inset', + 'text-decoration-skip-ink=text-decoration-skip-ink', + 'text-decoration-skip-spaces=text-decoration-skip-spaces', + 'text-emphasis=text-emphasis', + 'text-fit=text-fit', + 'text-indent=text-indent', + 'text-justify=text-justify', + 'text-orientation=text-orientation', + 'text-overflow=Text overflow', + 'text-shadow=text-shadow', + 'text-size-adjust=text-size-adjust', + 'text-spacing-trim=text-spacing-trim', + 'text-stroke-fill=Text stroke and fill (compatibility prefixes)', + 'text-transform=text-transform', + 'text-underline-offset=text-underline-offset', + 'text-underline-position=text-underline-position', + 'text-wrap=text-wrap', + 'touch-action=touch-action', + 'transform-box=transform-box', + 'transforms2d=2D transforms', + 'transforms3d=3D transforms', + 'transition-behavior=transition-behavior', + 'transitions=Transitions (CSS)', + 'trig-functions=Trigonometric functions (CSS)', + 'user-select=user-select', + 'vertical-align=vertical-align', + 'view-transition-class=view-transition-class', + 'view-transitions=View transitions', + 'view-transitions-element-scoped=Element-scoped view transitions', + 'visibility=visibility', + 'white-space=white-space', + 'white-space-collapse=white-space-collapse', + 'white-space-trim=white-space-trim', + 'widows-orphans=Widows and orphans', + 'width-height=Width and height', + 'will-change=will-change', + 'window-drag=window-drag', + 'word-break=word-break', + 'word-spacing=word-spacing', + 'wrap-inside=wrap-inside', + 'writing-mode=writing-mode', + 'z-index=z-index', + 'zoom=zoom', + ], + properties: [ + '-webkit-text-fill-color text-stroke-fill 1 18 12 49 49 3 2', + '-webkit-text-stroke text-stroke-fill 4 18 15 49 49 3 2', + '-webkit-text-stroke-color text-stroke-fill 1 18 15 49 49 3 2', + '-webkit-text-stroke-width text-stroke-fill 1 18 15 49 49 3 2', + 'accent-color accent-color 93 - 93 92 92 26.2 26.2', + 'align-content flexbox 29 29 12 28 28 9 9', + 'align-items flexbox 29 29 12 20 20 9 9', + 'align-self flexbox 29 29 12 20 20 9 9', + 'alignment-baseline alignment-baseline 1 18 79 149 149 5.1 5', + 'all all 37 37 79 27 27 9.1 9.3', + 'anchor-name anchor-positioning 125 125 125 147 147 26 26', + 'anchor-scope anchor-positioning 131 131 131 147 147 26 26', + 'animation animations-css 43 43 12 16 16 9 9', + 'animation-composition animation-composition 112 112 112 115 115 16 16', + 'animation-delay animations-css 43 43 12 16 16 9 9', + 'animation-direction animations-css 43 43 12 16 16 9 9', + 'animation-duration animations-css 43 43 12 16 16 9 9', + 'animation-fill-mode animations-css 43 43 12 16 16 9 9', + 'animation-iteration-count animations-css 43 43 12 16 16 9 9', + 'animation-name animations-css 43 43 12 16 16 9 9', + 'animation-play-state animations-css 43 43 12 16 16 9 9', + 'animation-range scroll-driven-animations 115 115 115 159 159 26 26', + 'animation-range-end scroll-driven-animations 115 115 115 159 159 26 26', + 'animation-range-start scroll-driven-animations 115 115 115 159 159 26 26', + 'animation-timeline scroll-driven-animations 115 115 115 159 159 26 26', + 'animation-timing-function animations-css 43 43 12 16 16 9 9', + 'animation-trigger scroll-triggered-animations 146 146 146 - - - -', + 'appearance appearance 84 84 84 80 80 15.4 15.4', + 'aspect-ratio aspect-ratio 88 88 88 89 89 15 15', + 'backdrop-filter backdrop-filter 76 76 79 103 103 18 18', + 'backface-visibility transforms3d 36 36 12 16 16 15.4 15.4', + 'background background 1 18 12 1 4 1 1', + 'background-attachment background-attachment 1 18 12 1 4 1 3.2', + 'background-blend-mode background-blend-mode 35 35 79 30 30 8 8', + 'background-clip background-clip 1 18 12 4 4 5 5', + 'background-color background-color 1 18 12 1 4 1 1', + 'background-image background-image 1 18 12 1 4 1 1', + 'background-origin background-origin 1 18 12 4 4 3 1', + 'background-position background-position 1 18 12 1 4 1 1', + 'background-position-x background-position 1 18 12 49 49 1 1', + 'background-position-y background-position 1 18 12 49 49 1 1', + 'background-repeat background-repeat 1 18 12 1 4 1 1', + 'background-size background-size 3 18 12 4 4 5 4.2', + 'baseline-shift baseline-shift 1 18 79 149 149 4 3.2', + 'baseline-source baseline-source 111 111 111 115 115 - -', + 'block-size logical-properties 57 57 79 41 41 12.1 12.2', + 'border borders 1 18 12 1 4 1 1', + 'border-block logical-properties 87 87 87 66 66 14.1 14.5', + 'border-block-color logical-properties 87 87 87 66 66 14.1 14.5', + 'border-block-end logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-end-color logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-end-style logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-end-width logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-start logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-start-color logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-start-style logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-start-width logical-properties 69 69 79 41 41 12.1 12.2', + 'border-block-style logical-properties 87 87 87 66 66 14.1 14.5', + 'border-block-width logical-properties 87 87 87 66 66 14.1 14.5', + 'border-bottom borders 1 18 12 1 4 1 1', + 'border-bottom-color borders 1 18 12 1 4 1 1', + 'border-bottom-left-radius border-radius 4 18 12 4 4 5 4.2', + 'border-bottom-right-radius border-radius 4 18 12 4 4 5 4.2', + 'border-bottom-style borders 1 18 12 1 4 1 1', + 'border-bottom-width borders 1 18 12 1 4 1 1', + 'border-collapse table 1 18 12 1 4 1.1 1', + 'border-color borders 1 18 12 1 4 1 1', + 'border-end-end-radius logical-properties 89 89 89 66 66 15 15', + 'border-end-start-radius logical-properties 89 89 89 66 66 15 15', + 'border-image border-image 16 18 12 15 15 6 6', + 'border-image-outset border-image 15 18 12 15 15 6 6', + 'border-image-repeat border-image 15 18 12 15 15 6 9.3', + 'border-image-slice border-image 15 18 12 15 15 6 6', + 'border-image-source border-image 15 18 12 15 15 6 6', + 'border-image-width border-image 16 18 12 13 14 6 6', + 'border-inline logical-properties 87 87 87 66 66 14.1 14.5', + 'border-inline-color logical-properties 87 87 87 66 66 14.1 14.5', + 'border-inline-end logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-end-color logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-end-style logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-end-width logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-start logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-start-color logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-start-style logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-start-width logical-properties 69 69 79 41 41 12.1 12.2', + 'border-inline-style logical-properties 87 87 87 66 66 14.1 14.5', + 'border-inline-width logical-properties 87 87 87 66 66 14.1 14.5', + 'border-left borders 1 18 12 1 4 1 1', + 'border-left-color borders 1 18 12 1 4 1 1', + 'border-left-style borders 1 18 12 1 14 1 1', + 'border-left-width borders 1 18 12 1 4 1 1', + 'border-radius border-radius 4 18 12 4 4 5 4.2', + 'border-right borders 1 18 12 1 4 1 1', + 'border-right-color borders 1 18 12 1 4 1 1', + 'border-right-style borders 1 18 12 1 14 1 1', + 'border-right-width borders 1 18 12 1 4 1 1', + 'border-shape border-shape 147 147 147 - - - -', + 'border-spacing table 1 18 12 1 4 1 1', + 'border-start-end-radius logical-properties 89 89 89 66 66 15 15', + 'border-start-start-radius logical-properties 89 89 89 66 66 15 15', + 'border-style borders 1 18 12 1 4 1 1', + 'border-top borders 1 18 12 1 4 1 1', + 'border-top-color borders 1 18 12 1 4 1 1', + 'border-top-left-radius border-radius 4 18 12 4 4 5 4.2', + 'border-top-right-radius border-radius 4 18 12 4 4 5 4.2', + 'border-top-style borders 1 18 12 1 4 1 1', + 'border-top-width borders 1 18 12 1 4 1 1', + 'border-width borders 1 18 12 1 4 1 3', + 'bottom physical-properties 1 18 12 1 4 1 1', + 'box-decoration-break box-decoration-break 130 130 130 32 32 - -', + 'box-shadow box-shadow 10 18 12 4 4 5.1 5', + 'box-sizing box-sizing 10 18 12 29 29 5.1 6', + 'break-after page-breaks 50 50 12 65 65 10 10', + 'break-before page-breaks 50 50 12 65 65 10 10', + 'break-inside page-breaks 50 50 12 65 65 10 10', + 'caption-side table 1 18 12 1 4 1 1', + 'caret-color caret-color 57 57 79 53 53 11.1 11.3', + 'caret-shape caret-shape 144 144 144 - - - -', + 'clear float-clear 1 18 12 1 4 1 1', + 'clip clip 1 18 12 1 4 1 1', + 'clip-path clip-path 55 55 79 3.5 4 9.1 9.3', + 'clip-rule svg 15 18 79 3.5 4 5 4.2', + 'color color 1 18 12 1 4 1 1', + 'color-adjust color-adjust - - - 48 48 15.4 15.4', + 'color-interpolation svg 1 18 79 3 4 4 3.2', + 'color-interpolation-filters svg-filters 1 18 79 3 4 3 2', + 'color-scheme color-scheme 81 81 81 96 96 13 13', + 'column-count multi-column 50 50 12 52 52 9 9', + 'column-fill column-fill 50 50 12 52 52 9 9', + 'column-gap multi-column 1 18 12 1.5 4 3 2', + 'column-height column-wrap 145 145 145 - - - -', + 'column-rule multi-column 50 50 12 52 52 9 9', + 'column-rule-break gap-decorations 149 149 149 - - - -', + 'column-rule-color multi-column 50 50 12 52 52 9 9', + 'column-rule-inset gap-decorations 149 149 149 - - - -', + 'column-rule-inset-cap gap-decorations 149 149 149 - - - -', + 'column-rule-inset-cap-end gap-decorations 149 149 149 - - - -', + 'column-rule-inset-cap-start gap-decorations 149 149 149 - - - -', + 'column-rule-inset-end gap-decorations 149 149 149 - - - -', + 'column-rule-inset-junction gap-decorations 149 149 149 - - - -', + 'column-rule-inset-junction-end gap-decorations 149 149 149 - - - -', + 'column-rule-inset-junction-start gap-decorations 149 149 149 - - - -', + 'column-rule-inset-start gap-decorations 149 149 149 - - - -', + 'column-rule-style multi-column 50 50 12 52 52 9 9', + 'column-rule-visibility-items gap-decorations 149 149 149 - - - -', + 'column-rule-width multi-column 50 50 12 52 52 9 9', + 'column-span column-span 50 50 12 71 79 9 9', + 'column-width multi-column 50 50 12 50 50 9 9', + 'column-wrap column-wrap 145 145 145 - - - -', + 'columns multi-column 50 50 12 52 52 9 9', + 'contain contain 52 52 79 69 79 15.4 15.4', + 'contain-intrinsic-block-size contain-intrinsic-size 95 95 95 107 107 17 17', + 'contain-intrinsic-height contain-intrinsic-size 95 95 95 107 107 17 17', + 'contain-intrinsic-inline-size contain-intrinsic-size 95 95 95 107 107 17 17', + 'contain-intrinsic-size contain-intrinsic-size 83 83 83 107 107 17 17', + 'contain-intrinsic-width contain-intrinsic-size 95 95 95 107 107 17 17', + 'container container-queries 105 105 105 110 110 16 16', + 'container-name container-queries 105 105 105 110 110 16 16', + 'container-type container-queries 105 105 105 110 110 16 16', + 'content content 1 18 12 1 4 1 1', + 'content-visibility content-visibility 85 85 85 125 125 18 18', + 'corner-block-end-shape corner-shape 139 139 139 - - - -', + 'corner-block-start-shape corner-shape 139 139 139 - - - -', + 'corner-bottom-left-shape corner-shape 139 139 139 - - - -', + 'corner-bottom-right-shape corner-shape 139 139 139 - - - -', + 'corner-bottom-shape corner-shape 139 139 139 - - - -', + 'corner-end-end-shape corner-shape 139 139 139 - - - -', + 'corner-end-start-shape corner-shape 139 139 139 - - - -', + 'corner-inline-end-shape corner-shape 139 139 139 - - - -', + 'corner-inline-start-shape corner-shape 139 139 139 - - - -', + 'corner-left-shape corner-shape 139 139 139 - - - -', + 'corner-right-shape corner-shape 139 139 139 - - - -', + 'corner-shape corner-shape 139 139 139 - - - -', + 'corner-start-end-shape corner-shape 139 139 139 - - - -', + 'corner-start-start-shape corner-shape 139 139 139 - - - -', + 'corner-top-left-shape corner-shape 139 139 139 - - - -', + 'corner-top-right-shape corner-shape 139 139 139 - - - -', + 'corner-top-shape corner-shape 139 139 139 - - - -', + 'counter-increment counters 2 18 12 1 25 3 1', + 'counter-reset counters 2 18 12 1 25 3 1', + 'counter-set counter-set 85 85 85 68 68 17.2 17.2', + 'cursor cursor 1 18 12 1 95 1.2 13.4', + 'custom-property custom-properties 49 49 15 31 31 9.1 9.3', + 'cx svg 43 43 79 69 79 9 9', + 'cy svg 43 43 79 69 79 9 9', + 'd svg 52 52 79 97 97 - -', + 'direction layout-direction-override 2 18 12 1 4 1 1', + 'display display 1 18 12 1 4 1 1', + 'dominant-baseline dominant-baseline 1 18 79 1 4 4 3.2', + 'dynamic-range-limit dynamic-range-limit 136 136 136 - - 26 26', + 'empty-cells table 1 18 12 1 4 1.2 1', + 'field-sizing field-sizing 123 123 123 152 152 26.2 26.2', + 'fill svg 1 18 15 3 4 4 3.2', + 'fill-opacity opacity-svg 1 18 15 1 4 4 3.2', + 'fill-rule svg 1 18 15 3 4 4 3.2', + 'filter filter 53 53 12 35 35 9.1 9.3', + 'fit-tolerance grid-lanes - - - - - 27.2 27.2', + 'flex flexbox 29 29 12 22 22 9 9', + 'flex-basis flexbox 29 29 12 22 22 9 9', + 'flex-direction flexbox 29 29 12 22 22 9 9', + 'flex-flow flexbox 29 29 12 28 28 9 9', + 'flex-grow flexbox 29 29 12 20 20 9 9', + 'flex-shrink flexbox 29 29 12 20 20 9 9', + 'flex-wrap flexbox 29 29 12 28 28 9 9', + 'float float-clear 1 18 12 1 4 1 1', + 'flood-color svg-filters 5 18 12 3 4 6 6', + 'flood-opacity svg-filters 5 18 12 3 4 6 6', + 'font font-shorthand 1 18 12 1 4 1 1', + 'font-family font-family 1 18 12 1 4 1 1', + 'font-feature-settings font-feature-settings 48 48 12 34 34 9.1 9.3', + 'font-kerning font-kerning 33 33 79 32 32 9 9', + 'font-language-override font-language-override 143 143 143 34 34 - -', + 'font-optical-sizing font-optical-sizing 79 79 17 62 62 13.1 13.4', + 'font-palette font-palette 101 101 101 107 107 15.4 15.4', + 'font-size font-size 1 18 12 1 4 1 1', + 'font-size-adjust font-size-adjust 127 127 127 3 4 16.4 16.4', + 'font-stretch font-stretch 60 60 12 9 9 11 11', + 'font-style font-style 1 18 12 1 4 1 1', + 'font-synthesis font-synthesis 97 97 97 34 34 9 9', + 'font-synthesis-position font-synthesis-position - - - 118 118 - -', + 'font-synthesis-small-caps font-synthesis-small-caps 97 97 97 111 111 16.4 16.4', + 'font-synthesis-style font-synthesis-style 97 97 97 111 111 16.4 16.4', + 'font-synthesis-weight font-synthesis-weight 97 97 97 111 111 16.4 16.4', + 'font-variant font-variant 1 18 12 1 4 1 1', + 'font-variant-alternates font-variant-alternates 111 111 111 34 34 9.1 9.3', + 'font-variant-caps font-variant-caps 52 52 79 34 34 9.1 9.3', + 'font-variant-east-asian font-variant-east-asian 63 63 79 34 34 9.1 9.3', + 'font-variant-emoji font-variant-emoji 131 131 131 141 141 - -', + 'font-variant-ligatures font-variant-ligatures 34 34 79 34 34 9.1 9.3', + 'font-variant-numeric font-variant-numeric 52 52 79 34 34 9.1 9.3', + 'font-variant-position font-variant-position 117 117 117 34 34 9.1 9.3', + 'font-variation-settings font-variation-settings 62 62 17 62 62 11 11', + 'font-weight font-weight 2 18 12 1 4 1 1', + 'font-width font-width - - - 155 155 18.4 18.4', + 'forced-color-adjust forced-colors 89 89 79 113 113 - -', + 'frame-sizing frame-sizing 154 154 154 - - - -', + 'gap grid 57 57 16 52 52 10.1 10.3', + 'glyph-orientation-vertical glyph-orientation-vertical - - - - - 4 3.2', + 'grid grid 57 57 16 52 52 10.1 10.3', + 'grid-area grid 57 57 16 52 52 10.1 10.3', + 'grid-auto-columns grid 57 57 16 70 79 10.1 10.3', + 'grid-auto-flow grid 57 57 16 52 52 10.1 10.3', + 'grid-auto-rows grid 57 57 16 70 79 10.1 10.3', + 'grid-column grid 57 57 16 52 52 10.1 10.3', + 'grid-column-end grid 57 57 16 52 52 10.1 10.3', + 'grid-column-start grid 57 57 16 52 52 10.1 10.3', + 'grid-row grid 57 57 16 52 52 10.1 10.3', + 'grid-row-end grid 57 57 16 52 52 10.1 10.3', + 'grid-row-start grid 57 57 16 52 52 10.1 10.3', + 'grid-template grid 57 57 16 52 52 10.1 10.3', + 'grid-template-areas grid 57 57 16 52 52 10.1 10.3', + 'grid-template-columns grid 57 57 16 52 52 10.1 10.3', + 'grid-template-rows grid 57 57 16 52 52 10.1 10.3', + 'hanging-punctuation hanging-punctuation - - - - - 26.5 26.5', + 'height width-height 1 18 12 1 4 1 1', + 'hyphenate-character hyphenate-character 106 106 106 98 98 17 17', + 'hyphenate-limit-chars hyphenate-limit-chars 109 109 109 137 137 - -', + 'hyphenate-limit-lines hyphenate-limit-lines - - - - - - -', + 'hyphens hyphens 55 55 79 43 43 17 17', + 'image-orientation image-orientation 81 81 81 26 26 13.1 13.4', + 'image-rendering image-rendering 13 18 79 3.6 4 6 6', + 'ime-mode ime-mode - - - 3 4 - -', + 'initial-letter initial-letter 110 110 110 - - - -', + 'inline-size logical-properties 57 57 79 41 41 12.1 12.2', + 'inset logical-properties 87 87 87 66 66 14.1 14.5', + 'inset-block logical-properties 87 87 87 63 63 14.1 14.5', + 'inset-block-end logical-properties 87 87 87 63 63 14.1 14.5', + 'inset-block-start logical-properties 87 87 87 63 63 14.1 14.5', + 'inset-inline logical-properties 87 87 87 63 63 14.1 14.5', + 'inset-inline-end logical-properties 87 87 87 63 63 14.1 14.5', + 'inset-inline-start logical-properties 87 87 87 63 63 14.1 14.5', + 'interactivity interactivity 135 135 135 - - - -', + 'interest-delay interest-invokers 142 142 142 - - - -', + 'interest-delay-end interest-invokers 142 142 142 - - - -', + 'interest-delay-start interest-invokers 142 142 142 - - - -', + 'interpolate-size interpolate-size 129 129 129 - - - -', + 'isolation isolation 41 41 79 36 36 8 8', + 'justify-content flexbox 29 29 12 20 20 9 9', + 'justify-items flexbox 52 52 12 20 20 9 9', + 'justify-self grid 57 57 16 45 45 10.1 10.3', + 'left physical-properties 1 18 12 1 4 1 1', + 'letter-spacing letter-spacing 1 18 12 1 4 1 1', + 'lighting-color svg-filters 5 18 12 3 4 6 6', + 'line-break line-break 58 58 14 69 79 11 11', + 'line-clamp line-clamp - - - - - - -', + 'line-height line-height 1 18 12 1 4 1 1', + 'link-parameters link-parameters - - - - - - -', + 'list-style list-style 1 18 12 1 4 1 1', + 'list-style-image list-style 1 18 12 1 4 1 1', + 'list-style-position list-style 1 18 12 1 4 1 1', + 'list-style-type list-style 1 18 12 1 4 1 1', + 'margin margin 1 18 12 1 4 1 1', + 'margin-block logical-properties 87 87 87 66 66 14.1 14.5', + 'margin-block-end logical-properties 69 69 79 41 41 12.1 12.2', + 'margin-block-start logical-properties 69 69 79 41 41 12.1 12.2', + 'margin-bottom margin 1 18 12 1 4 1 1', + 'margin-inline logical-properties 87 87 87 66 66 14.1 14.5', + 'margin-inline-end logical-properties 69 69 79 41 41 12.1 12.2', + 'margin-inline-start logical-properties 69 69 79 41 41 12.1 12.2', + 'margin-left margin 1 18 12 1 4 1 1', + 'margin-right margin 1 18 12 1 4 1 1', + 'margin-top margin 1 18 12 1 4 1 1', + 'margin-trim margin-trim 155 155 155 - - 16.4 16.4', + 'marker svg 1 18 15 3 4 4 3.2', + 'marker-end svg 1 18 15 3 4 4 3.2', + 'marker-mid svg 1 18 15 3 4 4 3.2', + 'marker-start svg 1 18 15 3 4 4 3.2', + 'mask masks 120 120 120 53 53 15.4 15.4', + 'mask-border mask-border - - - - - 17.2 17.2', + 'mask-border-outset mask-border - - - - - 17.2 17.2', + 'mask-border-repeat mask-border - - - - - 17.2 17.2', + 'mask-border-slice mask-border - - - - - 17.2 17.2', + 'mask-border-source mask-border - - - - - 17.2 17.2', + 'mask-border-width mask-border - - - - - 17.2 17.2', + 'mask-clip masks 120 120 120 53 53 15.4 15.4', + 'mask-composite masks 120 120 120 53 53 15.4 15.4', + 'mask-image masks 120 120 120 53 53 15.4 15.4', + 'mask-mode masks 120 120 120 53 53 - -', + 'mask-origin masks 120 120 120 53 53 15.4 15.4', + 'mask-position masks 120 120 120 53 53 15.4 15.4', + 'mask-repeat masks 120 120 120 53 53 15.4 15.4', + 'mask-size masks 120 120 120 53 53 15.4 15.4', + 'mask-type mask-type 24 25 79 35 35 7 7', + 'math-depth mathml 109 109 109 117 117 26.4 26.4', + 'math-shift mathml 109 109 109 146 146 26.2 26.2', + 'math-style mathml 109 109 109 117 117 14.1 14.5', + 'max-block-size logical-properties 57 57 79 41 41 12.1 12.2', + 'max-height min-max-width-height 1 18 12 1 4 1.3 1', + 'max-inline-size logical-properties 57 57 79 41 41 12.1 12.2', + 'max-width min-max-width-height 1 18 12 1 4 1 1', + 'min-block-size logical-properties 57 57 79 41 41 12.1 12.2', + 'min-height min-max-width-height 1 18 12 3 4 1.3 1', + 'min-inline-size logical-properties 57 57 79 41 41 12.1 12.2', + 'min-width min-max-width-height 1 18 12 1 4 1 1', + 'mix-blend-mode mix-blend-mode 41 41 79 32 32 8 8', + 'object-fit object-fit 32 32 79 36 36 10 10', + 'object-position object-position 32 32 79 36 36 10 10', + 'object-view-box object-view-box 104 104 104 - - - -', + 'offset motion-path 55 55 79 72 79 16 16', + 'offset-anchor motion-path 116 116 116 72 79 16 16', + 'offset-distance motion-path 55 55 79 72 79 16 16', + 'offset-path motion-path 55 55 79 72 79 15.4 15.4', + 'offset-position motion-path 116 116 116 122 122 16 16', + 'offset-rotate motion-path 56 56 79 72 79 16 16', + 'opacity opacity 1 18 12 1 4 2 1', + 'order flexbox 29 29 12 20 20 9 9', + 'orphans widows-orphans 25 25 12 - - 1.3 1', + 'outline outline 94 94 94 88 88 16.4 16.4', + 'outline-color outlines 1 18 12 1.5 4 1.2 1', + 'outline-offset outlines 1 18 15 1.5 4 1.2 1', + 'outline-style outlines 1 18 12 1.5 4 1.2 1', + 'outline-width outlines 1 18 12 1.5 4 1.2 1', + 'overflow overflow-shorthand 1 18 12 1 4 1 1', + 'overflow-anchor overflow-anchor 56 56 79 66 66 27 27', + 'overflow-block logical-properties 135 135 135 69 79 26 26', + 'overflow-clip-margin overflow-clip-margin - - - 102 102 - -', + 'overflow-inline logical-properties 135 135 135 69 79 26 26', + 'overflow-wrap overflow-wrap 23 25 18 49 49 7 7', + 'overflow-x overflow-shorthand 1 18 12 3.5 4 3 1', + 'overflow-y overflow-shorthand 1 18 12 3.5 4 3 1', + 'overlay overlay 117 117 117 - - - -', + 'overscroll-behavior overscroll-behavior 144 144 18 150 150 - -', + 'overscroll-behavior-block overscroll-behavior 144 144 144 150 150 - -', + 'overscroll-behavior-inline overscroll-behavior 144 144 144 150 150 - -', + 'overscroll-behavior-x overscroll-behavior 144 144 18 150 150 - -', + 'overscroll-behavior-y overscroll-behavior 144 144 18 150 150 - -', + 'padding padding 1 18 12 1 4 1 1', + 'padding-block logical-properties 87 87 87 66 66 14.1 14.5', + 'padding-block-end logical-properties 69 69 79 41 41 12.1 12.2', + 'padding-block-start logical-properties 69 69 79 41 41 12.1 12.2', + 'padding-bottom padding 1 18 12 1 4 1 1', + 'padding-inline logical-properties 87 87 87 66 66 14.1 14.5', + 'padding-inline-end logical-properties 69 69 79 41 41 12.1 12.2', + 'padding-inline-start logical-properties 69 69 79 41 41 12.1 12.2', + 'padding-left padding 1 18 12 1 4 1 1', + 'padding-right padding 1 18 12 1 4 1 1', + 'padding-top padding 1 18 12 1 4 1 1', + 'page page-setup 85 85 85 110 110 1 1', + 'page-break-after page-break-aliases 1 18 12 1 4 1.2 1', + 'page-break-before page-break-aliases 1 18 12 1 4 1.2 1', + 'page-break-inside page-break-aliases 1 18 12 19 19 1.3 1', + 'paint-order paint-order 123 123 123 60 60 11 11', + 'perspective transforms3d 36 36 12 16 16 9 9', + 'perspective-origin transforms3d 36 36 12 16 16 9 9', + 'place-content flexbox 59 59 79 45 45 9 9', + 'place-items flexbox 59 59 79 45 45 11 11', + 'place-self flexbox 59 59 79 45 45 11 11', + 'pointer-events pointer-events 1 18 12 1.5 4 4 3.2', + 'position position 1 18 12 1 4 1 1', + 'position-anchor anchor-positioning 151 151 151 151 151 27 27', + 'position-area anchor-positioning 129 129 129 147 147 26 26', + 'position-try anchor-positioning 125 125 125 147 147 26 26', + 'position-try-fallbacks anchor-positioning 128 128 128 147 147 26 26', + 'position-try-order anchor-positioning 125 125 125 148 148 26 26', + 'position-visibility anchor-positioning 125 125 125 147 147 26.2 26.2', + 'print-color-adjust print-color-adjust 136 136 136 97 97 15.4 15.4', + 'quotes quotes 11 18 12 1.5 4 9 9', + 'r svg 43 43 79 69 79 9 9', + 'reading-flow reading-flow 137 137 137 - - - -', + 'reading-order reading-flow 137 137 137 - - - -', + 'resize resize 1 18 79 4 - 3 -', + 'right physical-properties 1 18 12 1 4 1 1', + 'rotate individual-transforms 104 104 104 72 79 14.1 14.5', + 'row-gap grid 47 47 16 52 52 10.1 10.3', + 'row-rule gap-decorations 149 149 149 - - - -', + 'row-rule-break gap-decorations 149 149 149 - - - -', + 'row-rule-color gap-decorations 149 149 149 - - - -', + 'row-rule-inset gap-decorations 149 149 149 - - - -', + 'row-rule-inset-cap gap-decorations 149 149 149 - - - -', + 'row-rule-inset-cap-end gap-decorations 149 149 149 - - - -', + 'row-rule-inset-cap-start gap-decorations 149 149 149 - - - -', + 'row-rule-inset-end gap-decorations 149 149 149 - - - -', + 'row-rule-inset-junction gap-decorations 149 149 149 - - - -', + 'row-rule-inset-junction-end gap-decorations 149 149 149 - - - -', + 'row-rule-inset-junction-start gap-decorations 149 149 149 - - - -', + 'row-rule-inset-start gap-decorations 149 149 149 - - - -', + 'row-rule-style gap-decorations 149 149 149 - - - -', + 'row-rule-visibility-items gap-decorations 149 149 149 - - - -', + 'row-rule-width gap-decorations 149 149 149 - - - -', + 'ruby-align ruby-align 128 128 128 38 38 18.2 18.2', + 'ruby-overhang ruby-overhang 151 151 151 - - 18.2 18.2', + 'ruby-position ruby-position 84 84 84 38 38 18.2 18.2', + 'rule gap-decorations 149 149 149 - - - -', + 'rule-break gap-decorations 149 149 149 - - - -', + 'rule-color gap-decorations 149 149 149 - - - -', + 'rule-inset gap-decorations 149 149 149 - - - -', + 'rule-inset-cap gap-decorations 149 149 149 - - - -', + 'rule-inset-end gap-decorations 149 149 149 - - - -', + 'rule-inset-junction gap-decorations 149 149 149 - - - -', + 'rule-inset-start gap-decorations 149 149 149 - - - -', + 'rule-overlap gap-decorations 149 149 149 - - - -', + 'rule-style gap-decorations 149 149 149 - - - -', + 'rule-visibility-items gap-decorations 149 149 149 - - - -', + 'rule-width gap-decorations 149 149 149 - - - -', + 'rx svg 43 43 79 69 79 17.4 17.4', + 'ry svg 43 43 79 69 79 17.4 17.4', + 'scale individual-transforms 104 104 104 72 79 14.1 14.5', + 'scroll-axis-lock scroll-axis-lock 153 153 153 - - - -', + 'scroll-behavior scroll-behavior 61 61 79 36 36 15.4 15.4', + 'scroll-initial-target scroll-initial-target 133 133 133 - - - -', + 'scroll-margin scroll-snap 69 69 79 90 90 14.1 14.5', + 'scroll-margin-block scroll-snap 69 69 79 68 68 15 15', + 'scroll-margin-block-end scroll-snap 69 69 79 68 68 15 15', + 'scroll-margin-block-start scroll-snap 69 69 79 68 68 15 15', + 'scroll-margin-bottom scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-margin-inline scroll-snap 69 69 79 68 68 15 15', + 'scroll-margin-inline-end scroll-snap 69 69 79 68 68 15 15', + 'scroll-margin-inline-start scroll-snap 69 69 79 68 68 15 15', + 'scroll-margin-left scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-margin-right scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-margin-top scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-marker-group scroll-markers 135 135 135 - - - -', + 'scroll-padding scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-padding-block scroll-snap 69 69 79 68 68 15 15', + 'scroll-padding-block-end scroll-snap 69 69 79 68 68 15 15', + 'scroll-padding-block-start scroll-snap 69 69 79 68 68 15 15', + 'scroll-padding-bottom scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-padding-inline scroll-snap 69 69 79 68 68 15 15', + 'scroll-padding-inline-end scroll-snap 69 69 79 68 68 15 15', + 'scroll-padding-inline-start scroll-snap 69 69 79 68 68 15 15', + 'scroll-padding-left scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-padding-right scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-padding-top scroll-snap 69 69 79 68 68 14.1 14.5', + 'scroll-snap-align scroll-snap 69 69 79 68 68 11 11', + 'scroll-snap-stop scroll-snap 75 75 79 103 103 15 15', + 'scroll-snap-type scroll-snap 69 69 79 99 39 11 11', + 'scroll-target-group scroll-target-group 140 140 140 - - - -', + 'scroll-timeline scroll-driven-animations 115 115 115 159 159 26 26', + 'scroll-timeline-axis scroll-driven-animations 115 115 115 159 159 26 26', + 'scroll-timeline-name scroll-driven-animations 115 115 115 159 159 26 26', + 'scrollbar-color scrollbar-color 121 121 121 64 64 26.2 26.2', + 'scrollbar-gutter scrollbar-gutter 94 94 94 97 97 18.2 18.2', + 'scrollbar-width scrollbar-width 121 121 121 64 64 18.2 18.2', + 'shape-image-threshold shape-outside 37 37 79 62 62 10.1 10.3', + 'shape-margin shape-outside 37 37 79 62 62 10.1 10.3', + 'shape-outside shape-outside 37 37 79 62 62 10.1 10.3', + 'shape-rendering svg 1 18 79 3 4 4 3.2', + 'speak speak - - - - - - -', + 'speak-as speak-as - - - - - 11.1 11.3', + 'stop-color svg 1 18 15 3 4 4 3.2', + 'stop-opacity svg 1 18 15 3 4 4 3.2', + 'stroke svg 1 18 15 1.5 4 4 3.2', + 'stroke-color svg - - - - - 11.1 11.3', + 'stroke-dasharray svg 1 18 15 1.5 4 4 3.2', + 'stroke-dashoffset svg 1 18 15 1.5 4 4 3.2', + 'stroke-linecap svg 1 18 15 1.5 4 4 3.2', + 'stroke-linejoin svg 1 18 15 1.5 4 4 3.2', + 'stroke-miterlimit svg 1 18 15 1.5 4 4 3.2', + 'stroke-opacity opacity-svg 1 18 15 1.5 4 4 3.2', + 'stroke-width svg 1 18 15 1.5 4 4 3.2', + 'tab-size tab-size 21 25 79 91 91 7 7', + 'table-layout table 14 18 12 1 4 1 3', + 'text-align text-align 1 18 12 1 4 1 1', + 'text-align-last text-align-last 47 47 12 49 49 16 16', + 'text-anchor svg 1 18 14 3 4 4 3.2', + 'text-autospace text-autospace 140 140 140 145 145 18.4 18.4', + 'text-box text-box 133 133 133 154 154 18.2 18.2', + 'text-box-edge text-box 133 133 133 154 154 18.2 18.2', + 'text-box-trim text-box 133 133 133 154 154 18.2 18.2', + 'text-combine-upright text-combine-upright 48 48 79 48 48 15.4 15.4', + 'text-decoration text-decoration 1 18 12 1 4 1 1', + 'text-decoration-color text-decoration 57 57 79 36 36 12.1 12.2', + 'text-decoration-inset text-decoration-inset 157 157 157 146 146 - -', + 'text-decoration-line text-decoration 57 57 79 36 36 12.1 12.2', + 'text-decoration-skip-ink text-decoration-skip-ink 64 64 79 70 79 15.4 15.4', + 'text-decoration-skip-spaces text-decoration-skip-spaces 155 - - - - - -', + 'text-decoration-style text-decoration 57 57 79 36 36 12.1 12.2', + 'text-decoration-thickness text-decoration 89 89 89 70 79 12.1 12.2', + 'text-emphasis text-emphasis 99 99 99 46 46 7 7', + 'text-emphasis-color text-emphasis 99 99 99 46 46 7 7', + 'text-emphasis-position text-emphasis 99 99 99 46 46 7 7', + 'text-emphasis-style text-emphasis 99 99 99 46 46 7 7', + 'text-fit text-fit 150 150 150 - - - -', + 'text-indent text-indent 1 18 12 1 4 1 1', + 'text-justify text-justify 145 145 145 55 55 - -', + 'text-orientation text-orientation 48 48 79 41 41 14 14', + 'text-overflow text-overflow 1 18 12 7 7 1.3 1', + 'text-rendering svg 4 18 79 1 46 5 4.2', + 'text-shadow text-shadow 2 18 12 3.5 4 1.1 1', + 'text-size-adjust text-size-adjust 54 54 79 - - - -', + 'text-spacing-trim text-spacing-trim 123 123 123 - - - -', + 'text-transform text-transform 1 18 12 1 4 1 1', + 'text-underline-offset text-underline-offset 87 87 87 70 79 12.1 12.2', + 'text-underline-position text-underline-position 33 33 12 74 79 12.1 12.2', + 'text-wrap text-wrap 114 114 114 121 121 17.4 17.4', + 'text-wrap-mode text-wrap 130 130 130 124 124 17.4 17.4', + 'text-wrap-style text-wrap 130 130 130 124 124 17.5 17.5', + 'timeline-scope scroll-driven-animations 116 116 116 159 159 26 26', + 'timeline-trigger scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-activation-range scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-activation-range-end scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-activation-range-start scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-active-range scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-active-range-end scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-active-range-start scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-name scroll-triggered-animations 146 146 146 - - - -', + 'timeline-trigger-source scroll-triggered-animations 146 146 146 - - - -', + 'top physical-properties 1 18 12 1 4 1 1', + 'touch-action touch-action 36 36 12 52 52 13 9.3', + 'transform transforms2d 36 36 12 16 16 9 9', + 'transform-box transform-box 64 64 79 55 55 11 11', + 'transform-origin transforms2d 36 36 12 16 16 9 9', + 'transform-style transforms3d 36 36 12 16 16 9 9', + 'transition transitions 26 26 12 16 16 9 9', + 'transition-behavior transition-behavior 117 117 117 - - 17.4 17.4', + 'transition-delay transitions 26 26 12 16 16 9 9', + 'transition-duration transitions 26 26 12 16 16 9 9', + 'transition-property transitions 26 26 12 16 16 9 9', + 'transition-timing-function transitions 26 26 12 16 16 9 9', + 'translate individual-transforms 104 104 104 72 79 14.1 14.5', + 'trigger-scope scroll-triggered-animations 146 146 146 - - - -', + 'unicode-bidi layout-direction-override 2 18 12 1 4 1.3 1', + 'user-select user-select 54 54 79 69 79 - -', + 'vector-effect svg 6 18 79 15 15 5.1 5', + 'vertical-align vertical-align 1 18 12 1 4 1 1', + 'view-timeline scroll-driven-animations 115 115 115 159 159 26 26', + 'view-timeline-axis scroll-driven-animations 115 115 115 159 159 26 26', + 'view-timeline-inset scroll-driven-animations 115 115 115 159 159 26 26', + 'view-timeline-name scroll-driven-animations 115 115 115 159 159 26 26', + 'view-transition-class view-transition-class 125 125 125 144 144 18.2 18.2', + 'view-transition-name view-transitions 111 111 111 144 144 18 18', + 'view-transition-scope view-transitions-element-scoped 147 147 147 - - - -', + 'visibility visibility 1 18 12 1 4 1 1', + 'white-space white-space 1 18 12 1 4 1 1', + 'white-space-collapse white-space-collapse 114 114 114 124 124 17.4 17.4', + 'white-space-trim white-space-trim - - - - - - -', + 'widows widows-orphans 25 25 12 - - 1.3 1', + 'width width-height 1 18 12 1 4 1 1', + 'will-change will-change 36 36 79 36 36 9.1 9.3', + 'window-drag window-drag 152 - 152 - - - -', + 'word-break word-break 1 18 12 15 15 3 2', + 'word-spacing word-spacing 1 18 12 1 4 1 1', + 'wrap-inside wrap-inside - - - - - - -', + 'writing-mode writing-mode 48 48 12 41 41 10.1 10.3', + 'x svg 42 42 79 69 79 9 9', + 'y svg 42 42 79 69 79 9 9', + 'z-index z-index 1 18 12 1 4 1 1', + 'zoom zoom 1 18 12 126 126 3.1 3', + ], + atRules: [ + 'apply mixin - - - - - - -', + 'charset charset 2 18 12 1.5 4 4 4', + 'container container-queries 105 105 105 110 110 16 16', + 'contents mixin - - - - - - -', + 'counter-style counter-style 91 91 91 33 33 17 17', + 'custom-media custom-media-queries - - - - - - -', + 'font-face font-face 1 18 12 3.5 4 3.1 2', + 'font-feature-values font-variant-alternates 111 111 111 34 34 9.1 9.3', + 'font-palette-values font-palette 101 101 101 107 107 15.4 15.4', + 'function function 139 139 139 - - - -', + 'import import 1 18 12 1 4 1 1', + 'keyframes animations-css 43 43 12 16 16 9 9', + 'layer cascade-layers 99 99 99 97 97 15.4 15.4', + 'media media-queries 1 18 12 1 4 3 1', + 'mixin mixin - - - - - - -', + 'namespace namespace 1 18 12 1 4 1 1', + 'page page-setup 2 18 12 19 19 18.2 18.2', + 'position-try anchor-positioning 125 125 125 147 147 26 26', + 'private mixin - - - - - - -', + 'property registered-custom-properties 85 85 85 128 128 16.4 16.4', + 'scope scope 118 118 118 146 146 26.4 26.4', + 'starting-style starting-style 117 117 117 129 129 17.5 17.5', + 'supports supports 28 28 12 22 22 9 9', + 'view-transition cross-document-view-transitions 126 126 126 - - 18.2 18.2', + ], + functions: [ + 'abs abs-sign 138 138 138 118 118 15.4 15.4', + 'acos trig-functions 111 111 111 108 108 15.4 15.4', + 'alpha alpha 152 152 152 155 155 27 27', + 'anchor anchor-positioning 125 125 125 147 147 26 26', + 'asin trig-functions 111 111 111 108 108 15.4 15.4', + 'atan trig-functions 111 111 111 108 108 15.4 15.4', + 'atan2 trig-functions 111 111 111 108 108 15.4 15.4', + 'attr attr-contents 2 18 12 1 4 3.1 2', + 'blur filter 18 53 12 35 35 6 6', + 'brightness filter 18 53 12 35 35 6 6', + 'calc calc 26 28 12 16 16 7 7', + 'calc-size calc-size 129 129 129 - - - -', + 'circle shapes 37 37 79 54 54 10.1 10.3', + 'clamp min-max-clamp 79 79 79 75 79 13.1 13.4', + 'color color-function 111 111 111 113 113 15 15', + 'color-mix color-mix 111 111 111 113 113 16.2 16.2', + 'conic-gradient conic-gradients 69 69 79 83 83 12.1 12.2', + 'contrast filter 18 53 12 35 35 6 6', + 'contrast-color contrast-color 147 147 147 146 146 26 26', + 'cos trig-functions 111 111 111 108 108 15.4 15.4', + 'counters counters 1 18 12 1.5 4 3 1', + 'cross-fade cross-fade - - - - - 10 9.3', + 'cubic-bezier cubic-bezier-easing 16 18 12 4 4 6 6', + 'drop-shadow filter 18 53 12 35 35 6 6', + 'dynamic-range-limit-mix dynamic-range-limit 136 136 136 - - - -', + 'element element - - - - - - -', + 'ellipse shapes 37 37 79 54 54 10.1 10.3', + 'env safe-area-inset 69 69 79 65 65 11.1 11.3', + 'exp exp-functions 120 120 120 118 118 15.4 15.4', + 'filter filter-function - - - - - 9.1 9.3', + 'grayscale filter 18 53 12 35 35 6 6', + 'hsl hsl 1 18 12 1 4 3.1 2', + 'hsla hsl 1 18 12 1 4 3.1 2', + 'hue-rotate filter 18 53 12 35 35 6 6', + 'hwb hwb 101 101 101 96 96 15 15', + 'hypot exp-functions 120 120 120 118 118 15.4 15.4', + 'if if 137 137 137 - - - -', + 'image-set image-set 113 113 113 89 89 17 17', + 'inset shapes 37 37 79 54 54 10.1 10.3', + 'invert filter 18 53 12 35 35 6 6', + 'lab lab 111 111 111 113 113 15 15', + 'lch lab 111 111 111 113 113 15 15', + 'light-dark light-dark 123 123 123 120 120 17.5 17.5', + 'linear-gradient gradients 26 26 12 16 16 7 7', + 'log exp-functions 120 120 120 118 118 15.4 15.4', + 'matrix transforms2d 1 18 12 3.5 4 3.1 3.2', + 'matrix3d transforms3d 12 18 12 10 10 4 3.2', + 'max min-max-clamp 79 79 79 75 79 11.1 11.3', + 'min min-max-clamp 79 79 79 75 79 11.1 11.3', + 'mod round-mod-rem 125 125 125 118 118 15.4 15.4', + 'oklab oklab 111 111 111 113 113 15.4 15.4', + 'oklch oklab 111 111 111 113 113 15.4 15.4', + 'opacity filter 18 53 12 35 35 6 6', + 'paint paint 65 65 79 - - - -', + 'path path-shape 52 52 79 72 79 13.1 13', + 'perspective transforms3d 12 18 12 10 10 4 3.2', + 'polygon shapes 37 37 79 54 54 10.1 10.3', + 'pow exp-functions 120 120 120 118 118 15.4 15.4', + 'progress progress-function 138 138 138 155 155 26 26', + 'radial-gradient gradients 26 26 12 16 16 7 7', + 'random random-function 156 156 156 161 161 26.2 26.2', + 'random-item random-item - - - - - - -', + 'ray motion-path 116 116 116 122 122 16 16', + 'rect clip 1 18 12 1 4 1.3 1', + 'rem round-mod-rem 125 125 125 118 118 15.4 15.4', + 'repeating-conic-gradient conic-gradients 69 69 79 83 83 12.1 12.2', + 'repeating-linear-gradient gradients 26 26 12 16 16 7 7', + 'repeating-radial-gradient gradients 26 26 12 16 16 7 7', + 'rgb rgb 1 18 12 1 4 1 1', + 'rotate transforms2d 1 18 12 3.5 4 3.1 3.2', + 'rotate3d transforms3d 12 18 12 10 10 4 3.2', + 'rotatex transforms3d 12 18 12 10 10 4 3.2', + 'rotatey transforms3d 12 18 12 10 10 4 3.2', + 'rotatez transforms3d 12 18 12 10 10 4 3.2', + 'round round-mod-rem 125 125 125 118 118 15.4 15.4', + 'saturate filter 18 53 12 35 35 6 6', + 'scale transforms2d 1 18 12 3.5 4 3.1 3.2', + 'scale3d transforms3d 12 18 12 10 10 4 3.2', + 'scalex transforms2d 1 18 12 3.5 4 3.1 3.2', + 'scaley transforms2d 1 18 12 3.5 4 3.1 3.2', + 'scalez transforms3d 12 18 12 10 10 4 3.2', + 'sepia filter 18 53 12 35 35 6 6', + 'shape shape-function 135 135 135 148 148 18.4 18.4', + 'sibling-count sibling-count 138 138 138 154 154 26.2 26.2', + 'sibling-index sibling-count 138 138 138 154 154 26.2 26.2', + 'sign abs-sign 138 138 138 118 118 15.4 15.4', + 'sin trig-functions 111 111 111 108 108 15.4 15.4', + 'skew transforms2d 1 18 12 3.5 4 3.1 3.2', + 'skewx transforms2d 1 18 12 3.5 4 3.1 3.2', + 'skewy transforms2d 1 18 12 3.5 4 3.1 3.2', + 'sqrt exp-functions 120 120 120 118 118 15.4 15.4', + 'steps steps-easing 8 18 12 4 4 5.1 5', + 'superellipse corner-shape 139 139 139 - - - -', + 'tan trig-functions 111 111 111 108 108 15.4 15.4', + 'translate transforms2d 1 18 12 3.5 4 3.1 3.2', + 'translate3d transforms3d 12 18 12 10 10 4 3.2', + 'translatex transforms2d 1 18 12 3.5 4 3.1 3.2', + 'translatey transforms2d 1 18 12 3.5 4 3.1 3.2', + 'translatez transforms3d 12 18 12 10 10 4 3.2', + 'var custom-properties 49 49 15 31 31 9.1 9.3', + 'xywh rect-xywh 119 119 119 122 122 17.2 17.2', + ], +} as const; diff --git a/packages/extract/pipeline/index.ts b/packages/extract/pipeline/index.ts index fdc1197d..68a7ed52 100644 --- a/packages/extract/pipeline/index.ts +++ b/packages/extract/pipeline/index.ts @@ -223,6 +223,8 @@ export { postProcessCss, resolveLightningTargets, } from './post-process-css'; +export { unsupportedFeatures, withoutLoweredFeatures } from './target-support'; +export type { UnsupportedFeature } from './target-support'; export type { AnalysisOptions, EmitterConfig, diff --git a/packages/extract/pipeline/manifest-diagnostics.ts b/packages/extract/pipeline/manifest-diagnostics.ts index 59af0d2e..5616dce3 100644 --- a/packages/extract/pipeline/manifest-diagnostics.ts +++ b/packages/extract/pipeline/manifest-diagnostics.ts @@ -17,6 +17,8 @@ export type ManifestDiagnostic = { dropped?: string; property?: string; value?: string; + feature?: string; + emitted?: string; reason?: ManifestDiagnosticReason; }; @@ -25,7 +27,10 @@ export type ManifestDiagnosticReason = | 'inherited' | 'token-shaped' | 'unknown-identifier' - | 'unowned-token'; + | 'unowned-token' + | 'unsupported-property' + | 'unsupported-function' + | 'unsupported-at-rule'; export function locationOf( diagnostic: Pick @@ -502,6 +507,8 @@ export const FONT_FACE_PRELOAD_COSTLY = 'animus.style.font-face-preload-costly'; export const LOWERED_DIR_SELECTOR = 'animus.selector.lowered-dir'; +export const UNSUPPORTED_FEATURE = 'animus.style.unsupported-feature'; + type DiagnosticSeverity = 'error' | 'warn' | 'info'; const DIAGNOSTIC_SEVERITY: ReadonlyMap = new Map([ diff --git a/packages/extract/pipeline/run-analysis.ts b/packages/extract/pipeline/run-analysis.ts index acb96533..1c5fa145 100644 --- a/packages/extract/pipeline/run-analysis.ts +++ b/packages/extract/pipeline/run-analysis.ts @@ -12,6 +12,11 @@ import { type ProbeEvidenceGatherer, } from './probe-evidence'; import { checkCustomProperties } from './property-diagnostics'; +import { + unsupportedFeatures, + withoutLoweredFeatures, + type UnsupportedFeature, +} from './target-support'; import { applyUnitFallback } from './unit-fallback'; import type { FontPreloadEntry } from './core-options'; @@ -25,6 +30,7 @@ import type { } from './manifest-diagnostics'; import type { ProjectManifest } from './manifest-schema'; import type { ExtensionOrder } from './native-resolution'; +import type { HostLightning } from './post-process-css'; import type { IngestionOpening } from './source-ingestion'; import type { SystemConfig } from './system-config'; @@ -70,6 +76,7 @@ export interface AnalysisOptions { extraDiagnostics?: import('./manifest-diagnostics').ManifestDiagnostic[]; unitFallback?: (css: string) => string; kitDescriptors?: readonly KitDescriptorRecord[]; + targetSupport?: HostLightning; } type AnalysisContextWire = { @@ -95,6 +102,7 @@ export interface AnalysisContext { fontPreloads?: FontPreloadEntry[]; propOrder?: boolean; exclude?: readonly string[]; + unsupportedFeatures?: Record; } type EmitterConfigWire = { @@ -159,11 +167,26 @@ export function buildAnalysisInputs( if (opts.system.viewTransitionsJson) { inputs.viewTransitionsJson = opts.system.viewTransitionsJson; } - const context = analysisContextJson(opts.analysisContext); + const context = analysisContextJson( + opts.targetSupport + ? { + ...opts.analysisContext, + unsupportedFeatures: wireFeatures( + unsupportedFeatures(opts.targetSupport.targets) + ), + } + : opts.analysisContext + ); if (context !== undefined) inputs.analysisContextJson = context; return inputs; } +function wireFeatures( + features: Map +): AnalysisContext['unsupportedFeatures'] { + return features.size > 0 ? Object.fromEntries(features) : undefined; +} + export function analysisContextJson( context: AnalysisContext | undefined ): string | undefined { @@ -179,7 +202,8 @@ export function analysisContextJson( context?.closedDynamicImports?.length || context?.foreignPackages?.length || context?.fontPreloads || - context?.propOrder + context?.propOrder || + context?.unsupportedFeatures ) ) { return undefined; @@ -203,6 +227,7 @@ export function analysisContextJson( fontPreloads: context.fontPreloads, propOrder: context.propOrder === true ? true : undefined, exclude: context.exclude, + unsupportedFeatures: context.unsupportedFeatures, } satisfies AnalysisContextWire; return JSON.stringify(wire); } @@ -297,6 +322,25 @@ export function runProjectAnalysis( t = performance.now(); const manifest = JSON.parse(manifestJson) as ProjectManifest; + let publishedJson = manifestJson; + let fullJson = fullManifestJson; + if (opts.targetSupport && manifest.diagnostics) { + const kept = withoutLoweredFeatures( + manifest.diagnostics, + opts.targetSupport + ); + if (kept.length !== manifest.diagnostics.length) { + manifest.diagnostics = kept; + publishedJson = JSON.stringify(manifest); + fullJson = + fullManifestJson && + (() => { + const full = JSON.parse(fullManifestJson()) as ProjectManifest; + full.diagnostics = kept; + return JSON.stringify(full); + }); + } + } const systemErrors = systemLoadDiagnostics(opts.system).filter( (diagnostic) => diagnostic.kind === 'error' ); @@ -338,8 +382,8 @@ export function runProjectAnalysis( return { manifest, - manifestJson, - fullManifestJson: fullManifestJson ?? (() => manifestJson), + manifestJson: publishedJson, + fullManifestJson: fullJson ?? (() => publishedJson), globalCss: manifest.sheets.global, componentCss, inputs, diff --git a/packages/extract/pipeline/target-support.ts b/packages/extract/pipeline/target-support.ts new file mode 100644 index 00000000..c8076278 --- /dev/null +++ b/packages/extract/pipeline/target-support.ts @@ -0,0 +1,145 @@ +import { transform } from 'lightningcss'; + +import { CSS_SUPPORT } from './css-support-table'; +import { UNSUPPORTED_FEATURE } from './manifest-diagnostics'; + +import type { ManifestDiagnostic } from './manifest-diagnostics'; +import type { HostLightning, LightningTargets } from './post-process-css'; + +export interface UnsupportedFeature { + feature: string; + targets: string[]; +} + +const SUPPORT_COLUMN = { + chrome: 'chrome', + android: 'chrome_android', + edge: 'edge', + firefox: 'firefox', + safari: 'safari', + ios_saf: 'safari_ios', +} as const satisfies Partial< + Record +>; + +const FEATURE_NAMES = new Map( + CSS_SUPPORT.features.map((entry) => { + const at = entry.indexOf('='); + return [entry.slice(0, at), entry.slice(at + 1)] as const; + }) +); + +const SECTIONS = [ + ['property', CSS_SUPPORT.properties], + ['at-rule', CSS_SUPPORT.atRules], + ['function', CSS_SUPPORT.functions], +] as const; + +function packedVersion(written: string): number { + const [major = 0, minor = 0, patch = 0] = written.split('.').map(Number); + return (major << 16) | (minor << 8) | patch; +} + +function describedVersion(packed: number): string { + const parts = [packed >>> 16, (packed >> 8) & 0xff, packed & 0xff]; + while (parts.length > 1 && parts.at(-1) === 0) parts.pop(); + return parts.join('.'); +} + +export function unsupportedFeatures( + targets: LightningTargets +): Map { + const checked = Object.entries(targets).flatMap(([browser, packed]) => { + if (packed === undefined || !Object.hasOwn(SUPPORT_COLUMN, browser)) { + return []; + } + const column = SUPPORT_COLUMN[browser as keyof typeof SUPPORT_COLUMN]; + return [ + { + label: `${browser} ${describedVersion(packed)}`, + cell: CSS_SUPPORT.browsers.indexOf(column) + 2, + packed, + }, + ]; + }); + const found = new Map(); + for (const [kind, rows] of SECTIONS) { + for (const row of rows) { + const cells = row.split(' '); + const lacking = checked + .filter(({ cell, packed }) => { + const since = cells[cell]; + return since === '-' || packed < packedVersion(since!); + }) + .map(({ label }) => label); + if (lacking.length === 0) continue; + found.set(`${kind}:${cells[0]}`, { + feature: FEATURE_NAMES.get(cells[1]!) ?? cells[1]!, + targets: lacking, + }); + } + } + return found; +} + +function probe(diagnostic: ManifestDiagnostic): string | undefined { + const emitted = diagnostic.emitted; + if (emitted === undefined) return undefined; + if (diagnostic.reason === 'unsupported-at-rule') { + return `${emitted.replaceAll('&', '.a')}{.a{color:red}}`; + } + return `.a{${emitted}}`; +} + +function needle(diagnostic: ManifestDiagnostic): string | undefined { + const [kind, name] = diagnostic.feature?.split(/:(.*)/) ?? []; + if (name === undefined) return undefined; + if (kind === 'property') return `${name}:`; + if (kind === 'function') return `${name}(`; + return `@${name}`; +} + +function lowered( + css: string, + sought: string, + lightning: HostLightning +): boolean { + const run = (targets: LightningTargets | undefined) => + transform({ + filename: 'animus-target-probe.css', + code: Buffer.from(css), + minify: true, + targets, + include: lightning.features.include ?? 0, + exclude: lightning.features.exclude ?? 0, + }).code.toString(); + try { + const output = run({ ...lightning.targets }); + return ( + !output.toLowerCase().includes(sought.toLowerCase()) || + output !== run(undefined) + ); + } catch { + return false; + } +} + +export function withoutLoweredFeatures( + diagnostics: ManifestDiagnostic[], + lightning: HostLightning +): ManifestDiagnostic[] { + const verdicts = new Map(); + return diagnostics.filter((diagnostic) => { + if (diagnostic.code !== UNSUPPORTED_FEATURE) return true; + const css = probe(diagnostic); + const sought = needle(diagnostic); + if (css === undefined || sought === undefined) return true; + const key = `${sought}\n${css}`; + let gone = verdicts.get(key); + if (gone === undefined) { + gone = lowered(css, sought, lightning); + verdicts.set(key, gone); + } + return !gone; + }); +} diff --git a/packages/extract/scripts/css-keywords.ts b/packages/extract/scripts/css-keywords.ts index e18f6d15..da5095b5 100644 --- a/packages/extract/scripts/css-keywords.ts +++ b/packages/extract/scripts/css-keywords.ts @@ -104,7 +104,7 @@ export function checkFormatterRun(run: ToolRun): void { checkExit('vp fmt', run, 0); } -function formatted(file: string, text: string): string { +export function formatted(file: string, text: string): string { const run = spawnSync( join(ROOT, 'node_modules/.bin/vp'), ['fmt', `--stdin-filepath=${relative(ROOT, file)}`], diff --git a/packages/extract/scripts/css-support.ts b/packages/extract/scripts/css-support.ts new file mode 100644 index 00000000..ed0c1467 --- /dev/null +++ b/packages/extract/scripts/css-support.ts @@ -0,0 +1,175 @@ +import { readFileSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; + +import { formatted } from './css-keywords.ts'; + +const ROOT = join(import.meta.dirname, '../../..'); + +const SUPPORT_FILE = join( + ROOT, + 'packages/extract/pipeline/css-support-table.ts' +); + +const BROWSERS = [ + 'chrome', + 'chrome_android', + 'edge', + 'firefox', + 'firefox_android', + 'safari', + 'safari_ios', +] as const; + +const NOT_FUNCTION_GROUPS = new Set([ + 'corner-shape-value', + 'global_keywords', + 'length', + 'url', +]); + +interface CompatStatus { + support: Partial>; +} + +interface WebFeature { + kind: string; + name: string; + status?: { by_compat_key?: Record }; +} + +interface Specification { + functions: { name: string }[]; + types: { name: string }[]; +} + +type Entry = { feature: string; support: CompatStatus['support'] }; + +function readJson(specifier: string): T { + return JSON.parse( + readFileSync(new URL(import.meta.resolve(specifier)), 'utf8') + ); +} + +function compatEntries(): Map { + const { features } = readJson<{ features: Record }>( + 'web-features/data.json' + ); + const entries = new Map(); + for (const [feature, record] of Object.entries(features)) { + if (record.kind !== 'feature') continue; + for (const [key, status] of Object.entries( + record.status?.by_compat_key ?? {} + )) { + if (key.startsWith('css.')) { + entries.set(key, { feature, support: status.support }); + } + } + } + return entries; +} + +function version(raw: string | undefined): string { + return raw === undefined ? '-' : raw.replace(/^≤/, ''); +} + +function row(entry: Entry): string { + return [ + entry.feature, + ...BROWSERS.map((b) => version(entry.support[b])), + ].join(' '); +} + +function widest(entries: Entry[]): Entry { + const support: CompatStatus['support'] = {}; + for (const browser of BROWSERS) { + const versions = entries + .map((entry) => entry.support[browser]) + .filter((v): v is string => v !== undefined) + .map((v) => v.replace(/^≤/, '')); + if (versions.length === 0) continue; + support[browser] = versions.sort((a, b) => + a.localeCompare(b, 'en', { numeric: true }) + )[0]; + } + return { feature: entries[0]!.feature, support }; +} + +function sorted(record: Map, separator: string): string[] { + return [...record] + .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)) + .map(([key, value]) => `${key}${separator}${value}`); +} + +function deriveCssSupport() { + const entries = compatEntries(); + const properties = new Map(); + const atRules = new Map(); + const functions = new Map(); + for (const [key, entry] of entries) { + const path = key.split('.'); + if (path.length !== 3) continue; + if (path[1] === 'properties') properties.set(path[2]!, row(entry)); + if (path[1] === 'at-rules') atRules.set(path[2]!, row(entry)); + } + const css = readJson('@webref/css/css.json'); + const typeNames = new Set(css.types.map((type) => type.name)); + for (const { name } of css.functions) { + const fn = name.replace(/\(\)$/, ''); + if (fn.startsWith('-')) continue; + const candidates = [...entries].filter(([key]) => { + const path = key.split('.'); + return ( + path[1] === 'types' && + path.at(-1) === fn && + (path.length === 3 || + (path.length === 4 && !NOT_FUNCTION_GROUPS.has(path[2]!))) + ); + }); + const grouped = candidates.filter(([key]) => key.split('.').length === 4); + const chosen = + typeNames.has(fn) || grouped.length > 0 ? grouped : candidates; + if (chosen.length === 0) continue; + functions.set(fn.toLowerCase(), row(widest(chosen.map(([, e]) => e)))); + } + const { features } = readJson<{ features: Record }>( + 'web-features/data.json' + ); + const used = new Set( + [...properties.values(), ...atRules.values(), ...functions.values()].map( + (value) => value.split(' ')[0]! + ) + ); + return { + browsers: [...BROWSERS], + features: sorted( + new Map([...used].map((id) => [id, features[id]!.name] as const)), + '=' + ), + properties: sorted(properties, ' '), + atRules: sorted(atRules, ' '), + functions: sorted(functions, ' '), + }; +} + +function renderCssSupport(): string { + const table = deriveCssSupport(); + return formatted( + SUPPORT_FILE, + `export const CSS_SUPPORT = ${JSON.stringify(table)} as const;\n` + ); +} + +if (import.meta.main ?? process.argv[1] === import.meta.filename) { + const rendered = renderCssSupport(); + if (process.argv.includes('--check')) { + if (readFileSync(SUPPORT_FILE, 'utf8') !== rendered) { + // oxlint-disable-next-line no-console + console.error( + `css-support: stale ${SUPPORT_FILE}; run node packages/extract/scripts/css-support.ts --write` + ); + process.exit(1); + } + } else if (process.argv.includes('--write')) { + writeFileSync(SUPPORT_FILE, rendered); + } +} diff --git a/packages/extract/session/extraction-session.ts b/packages/extract/session/extraction-session.ts index 9ee3fe03..400ca27e 100644 --- a/packages/extract/session/extraction-session.ts +++ b/packages/extract/session/extraction-session.ts @@ -83,6 +83,7 @@ import { readTsconfigAliasPairs, projectExternalFileOwners, resolveAssetFile, + lightningTargetsFor, resolveLightningTargets, resolveMode, resolveVerbosity, @@ -114,6 +115,7 @@ import { pruneStaleAssets, surfaceManifestDiagnostics, systemLoadReads, + withoutLoweredFeatures, } from '../pipeline/index'; import { parseInternalWire } from '../pipeline/internal-wire'; import { @@ -570,7 +572,15 @@ export class ExtractionSession { ]), devMode: options.devMode ?? inputs.devMode, }); - return JSON.parse(api.fullManifestJson!()) as FullProjectManifest; + const manifest = JSON.parse(api.fullManifestJson!()) as FullProjectManifest; + const targetSupport = this.targetSupport(); + if (targetSupport && manifest.diagnostics) { + manifest.diagnostics = withoutLoweredFeatures( + manifest.diagnostics, + targetSupport + ); + } + return manifest; } private stagedPublication: Omit< SessionPublication, @@ -681,6 +691,21 @@ export class ExtractionSession { private debouncePending = new Map(); private sessionStartHygieneDone = false; private lightning: HostLightning | null = null; + private checkedTargets: HostLightning | null | undefined; + + private targetSupport(): HostLightning | undefined { + if (this.checkedTargets === undefined) { + const { targets, source } = lightningTargetsFor( + this.options.targets, + this.rootDir! + ); + this.checkedTargets = + source === 'browserslist defaults' + ? null + : { targets, features: this.hostLightning?.features ?? {} }; + } + return this.checkedTargets ?? undefined; + } constructor( options: SessionOptions, @@ -2660,6 +2685,7 @@ export class ExtractionSession { this.publishDiagnostics(fileEntries, diagnostics), }), kitDescriptors: this.kitDescriptors, + targetSupport: this.targetSupport(), ...(devMode && { unitFallback: this.unitFallback }), }); this.lastAnalysisInputs = result.inputs; diff --git a/packages/react/CLAUDE.md b/packages/react/CLAUDE.md index 8ed3fd17..fd0870b9 100644 --- a/packages/react/CLAUDE.md +++ b/packages/react/CLAUDE.md @@ -4,7 +4,7 @@ React terminals, slot composition and the component runtime over `@animus-ui/cor ## What lives here -- `src/Animus.ts` — `ReactAnimusRuntime extends AnimusChain` adds `asElement`, `asComponent` and bound `extend`; the file registers `react` on core's `ChainTerminals` and exports `Animus = ChainRoot<'react', …>`. +- `src/Animus.ts` — `ReactAnimusRuntime extends AnimusChain` adds `contract`, `asElement`, `asComponent` and bound `extend`; the file registers `react` on core's `ChainTerminals` and exports `Animus = ChainRoot<'react', …>`. - `src/AnimusExtended.ts` — the `.extend()` chain of a built component. - `src/SystemBuilder.ts` — subclass of core's `CoreSystemBuilder` that mints React roots. - `src/runtime/` — `createComponent`, `createComposedFamily`, and this package's own `is-dev.ts` (kept in the runtime chunk; never imported from core). Runtime modules import core only through `@animus-ui/core/runtime`. diff --git a/packages/react/src/Animus.ts b/packages/react/src/Animus.ts index dc0ec762..c0dd60a9 100644 --- a/packages/react/src/Animus.ts +++ b/packages/react/src/Animus.ts @@ -11,8 +11,16 @@ import { VariantConfig, type AnimusCoreWithAll, type ChainRoot, + type ContractRule, + type ContractRuleEntry, } from '@animus-ui/core'; -import { AnimusChain, uncompiledDefinition } from '@animus-ui/core/binding'; +import { + AnimusChain, + uncompiledDefinition, + type ExactContractRule, + type StripIndex, + type VariantOptionMap, +} from '@animus-ui/core/binding'; import { AnimusExtended } from './AnimusExtended'; import { createComponent } from './runtime'; @@ -27,6 +35,14 @@ import type { } from './types/component'; class ReactAnimusRuntime extends AnimusChain { + contracts: readonly ContractRuleEntry[] = []; + + contract(rule: ContractRuleEntry) { + const next = this.spawn({}) as ReactAnimusRuntime; + next.contracts = [...this.contracts, rule]; + return next; + } + protected extend() { return new AnimusExtended( this.propRegistry, @@ -36,13 +52,15 @@ class ReactAnimusRuntime extends AnimusChain { this.statesConfig, this.activeGroups, this.custom, - this.compounds + this.compounds, + this.contracts ); } asElement(component: string) { const config = { ...this._buildComponentConfig(), + ...(this.contracts.length > 0 ? { contracts: this.contracts } : {}), uncompiled: uncompiledDefinition(`<${component}>`), }; const Component = createComponent(component, '', config); @@ -59,6 +77,7 @@ class ReactAnimusRuntime extends AnimusChain { const forward = options?.forward as true | readonly string[] | undefined; const config = { ...this._buildComponentConfig(), + ...(this.contracts.length > 0 ? { contracts: this.contracts } : {}), ...(forward === undefined ? {} : { forward }), uncompiled: uncompiledDefinition( `a component wrapping ${AsComponent.displayName || AsComponent.name || 'an anonymous component'}` @@ -80,6 +99,7 @@ export interface AnimusWithAll< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + Contracts extends readonly ContractRuleEntry[] = readonly [], > extends AnimusCoreWithAll< PropRegistry, GroupRegistry, @@ -99,7 +119,8 @@ export interface AnimusWithAll< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts >; asComponent>( @@ -112,7 +133,9 @@ export interface AnimusWithAll< Variants, States, ActiveGroups, - CustomProps + CustomProps, + never, + Contracts >; asComponent< C extends ComponentType, @@ -131,7 +154,26 @@ export interface AnimusWithAll< States, ActiveGroups, CustomProps, - RequiredForward + RequiredForward, + Contracts + >; + + contract< + const Rule extends ContractRule< + VariantOptionMap, + Extract, string> + >, + >( + rule: ExactContractRule> + ): AnimusWithAll< + PropRegistry, + GroupRegistry, + BaseStyles, + Variants, + States, + ActiveGroups, + CustomProps, + readonly [...Contracts, Rule] >; } diff --git a/packages/react/src/AnimusExtended.ts b/packages/react/src/AnimusExtended.ts index dbcb9e17..d2318713 100644 --- a/packages/react/src/AnimusExtended.ts +++ b/packages/react/src/AnimusExtended.ts @@ -4,6 +4,8 @@ import { AbstractParser, AbstractProps, CompoundEntry, + type ContractRule, + type ContractRuleEntry, createClassResolver, CSSPropMap, CSSProps, @@ -27,6 +29,9 @@ import { uncompiledDefinition, withDefaultKey, type AdmittedNames, + type ExactContractRule, + type StripIndex, + type VariantOptionMap, type StylingNames, type SystemPicks, type UnadmittedName, @@ -66,6 +71,7 @@ export class AnimusExtendedWithAll< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + in out Contracts extends readonly ContractRuleEntry[] = readonly [], > { propRegistry = {} as PropRegistry; groupRegistry = {} as GroupRegistry; @@ -75,6 +81,7 @@ export class AnimusExtendedWithAll< activeGroups = {} as ActiveGroups; custom = {} as CustomProps; compounds: CompoundEntry[] = []; + contracts: readonly ContractRuleEntry[] = []; constructor( props: PropRegistry, @@ -84,7 +91,8 @@ export class AnimusExtendedWithAll< states: States, activeGroups: ActiveGroups, custom: CustomProps, - compounds: CompoundEntry[] = [] + compounds: CompoundEntry[] = [], + contracts: readonly ContractRuleEntry[] = [] ) { this.propRegistry = props; this.groupRegistry = groups; @@ -94,6 +102,7 @@ export class AnimusExtendedWithAll< this.activeGroups = activeGroups; this.custom = custom; this.compounds = compounds; + this.contracts = contracts; } protected extend(): AnimusExtended< @@ -103,9 +112,58 @@ export class AnimusExtendedWithAll< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts + > { + return new AnimusExtended< + PropRegistry, + GroupRegistry, + BaseStyles, + Variants, + States, + ActiveGroups, + CustomProps, + Contracts + >( + this.propRegistry, + this.groupRegistry, + this.baseStyles, + this.variants, + this.statesConfig, + this.activeGroups, + this.custom, + this.compounds, + this.contracts + ); + } + + contract< + const Rule extends ContractRule< + VariantOptionMap, + Extract, string> + >, + >( + rule: ExactContractRule> + ): AnimusExtendedWithAll< + PropRegistry, + GroupRegistry, + BaseStyles, + Variants, + States, + ActiveGroups, + CustomProps, + readonly [...Contracts, Rule] > { - return new AnimusExtended( + return new AnimusExtendedWithAll< + PropRegistry, + GroupRegistry, + BaseStyles, + Variants, + States, + ActiveGroups, + CustomProps, + readonly [...Contracts, Rule] + >( this.propRegistry, this.groupRegistry, this.baseStyles, @@ -113,13 +171,15 @@ export class AnimusExtendedWithAll< this.statesConfig, this.activeGroups, this.custom, - this.compounds + this.compounds, + [...this.contracts, rule] ); } asElement(component: El) { const config = { ...this._buildComponentConfig(), + ...(this.contracts.length > 0 ? { contracts: this.contracts } : {}), uncompiled: uncompiledDefinition(`<${component}>`), }; const Component = createComponent(component, '', config); @@ -134,7 +194,8 @@ export class AnimusExtendedWithAll< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts >; } @@ -148,7 +209,9 @@ export class AnimusExtendedWithAll< Variants, States, ActiveGroups, - CustomProps + CustomProps, + never, + Contracts >; asComponent< C extends ComponentType, @@ -167,7 +230,8 @@ export class AnimusExtendedWithAll< States, ActiveGroups, CustomProps, - RequiredForward + RequiredForward, + Contracts >; asComponent( AsComponent: ComponentType, @@ -175,6 +239,7 @@ export class AnimusExtendedWithAll< ): unknown { const config = { ...this._buildComponentConfig(), + ...(this.contracts.length > 0 ? { contracts: this.contracts } : {}), ...(options?.forward === undefined ? {} : { forward: options.forward as true | readonly string[] }), @@ -243,6 +308,7 @@ class AnimusExtendedWithSystem< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + in out Contracts extends readonly ContractRuleEntry[] = readonly [], > extends AnimusExtendedWithAll< PropRegistry, GroupRegistry, @@ -250,7 +316,8 @@ class AnimusExtendedWithSystem< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts > { props< NewCustomProps extends Record, @@ -262,7 +329,8 @@ class AnimusExtendedWithSystem< Variants, States, ActiveGroups, - Redeclared + Redeclared, + Contracts >( this.propRegistry, this.groupRegistry, @@ -271,7 +339,8 @@ class AnimusExtendedWithSystem< this.statesConfig, this.activeGroups, { ...this.custom, ...config }, - this.compounds + this.compounds, + this.contracts ); } } @@ -284,6 +353,7 @@ class AnimusExtendedWithStates< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + in out Contracts extends readonly ContractRuleEntry[] = readonly [], > extends AnimusExtendedWithSystem< PropRegistry, GroupRegistry, @@ -291,7 +361,8 @@ class AnimusExtendedWithStates< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts > { system< PickedKeys extends @@ -311,7 +382,8 @@ class AnimusExtendedWithStates< Variants, States, Record & ActiveGroups, - CustomProps + CustomProps, + Contracts >( this.propRegistry, this.groupRegistry, @@ -320,7 +392,8 @@ class AnimusExtendedWithStates< this.statesConfig, deepMerge(this.activeGroups as any, config) as any, this.custom, - this.compounds + this.compounds, + this.contracts ); } } @@ -333,6 +406,7 @@ class AnimusExtendedWithCompounds< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + in out Contracts extends readonly ContractRuleEntry[] = readonly [], > extends AnimusExtendedWithStates< PropRegistry, GroupRegistry, @@ -340,7 +414,8 @@ class AnimusExtendedWithCompounds< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts > { compound( condition: { @@ -357,7 +432,8 @@ class AnimusExtendedWithCompounds< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts >( this.propRegistry, this.groupRegistry, @@ -372,7 +448,8 @@ class AnimusExtendedWithCompounds< condition: condition as Record, styles: styles as any, }, - ] + ], + this.contracts ); } @@ -389,7 +466,8 @@ class AnimusExtendedWithCompounds< UnadmittedStates>) & States, ActiveGroups, - CustomProps + CustomProps, + Contracts >( this.propRegistry, this.groupRegistry, @@ -398,7 +476,8 @@ class AnimusExtendedWithCompounds< deepMerge(this.statesConfig as any, config) as any, this.activeGroups, this.custom, - this.compounds + this.compounds, + this.contracts ); } } @@ -411,6 +490,7 @@ class AnimusExtendedWithVariants< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + in out Contracts extends readonly ContractRuleEntry[] = readonly [], > extends AnimusExtendedWithCompounds< PropRegistry, GroupRegistry, @@ -418,7 +498,8 @@ class AnimusExtendedWithVariants< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts > { compound( condition: { @@ -435,7 +516,8 @@ class AnimusExtendedWithVariants< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts >( this.propRegistry, this.groupRegistry, @@ -450,7 +532,8 @@ class AnimusExtendedWithVariants< condition: condition as Record, styles: styles as any, }, - ] + ], + this.contracts ); } @@ -484,7 +567,8 @@ class AnimusExtendedWithVariants< NextVariants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts >( this.propRegistry, this.groupRegistry, @@ -495,7 +579,8 @@ class AnimusExtendedWithVariants< this.statesConfig, this.activeGroups, this.custom, - this.compounds + this.compounds, + this.contracts ); } } @@ -508,6 +593,7 @@ class AnimusExtendedWithBase< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + in out Contracts extends readonly ContractRuleEntry[] = readonly [], > extends AnimusExtendedWithVariants< PropRegistry, GroupRegistry, @@ -515,7 +601,8 @@ class AnimusExtendedWithBase< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts > { variant< Keys extends keyof Props, @@ -547,7 +634,8 @@ class AnimusExtendedWithBase< NextVariants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts >( this.propRegistry, this.groupRegistry, @@ -558,7 +646,8 @@ class AnimusExtendedWithBase< this.statesConfig, this.activeGroups, this.custom, - this.compounds + this.compounds, + this.contracts ); } } @@ -571,6 +660,7 @@ export class AnimusExtended< States extends CSSPropMap>, ActiveGroups extends Record, CustomProps extends Record, + in out Contracts extends readonly ContractRuleEntry[] = readonly [], > extends AnimusExtendedWithBase< PropRegistry, GroupRegistry, @@ -578,7 +668,8 @@ export class AnimusExtended< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts > { styles( config: ThemedCSSInputProps @@ -590,7 +681,8 @@ export class AnimusExtended< Variants, States, ActiveGroups, - CustomProps + CustomProps, + Contracts >( this.propRegistry, this.groupRegistry, @@ -599,7 +691,8 @@ export class AnimusExtended< this.statesConfig, this.activeGroups, this.custom, - this.compounds + this.compounds, + this.contracts ); } } diff --git a/packages/react/src/runtime/index.ts b/packages/react/src/runtime/index.ts index cf9b7fce..c10a6edb 100644 --- a/packages/react/src/runtime/index.ts +++ b/packages/react/src/runtime/index.ts @@ -18,10 +18,13 @@ import { import { IS_DEV } from './is-dev'; +import type { ContractRuleEntry } from '@animus-ui/core'; + declare const __ANIMUS_DEV__: boolean | undefined; interface ComponentConfig extends ClassResolverConfig { forward?: true | readonly string[]; + contracts?: readonly ContractRuleEntry[]; } type ElementType = string | React.ComponentType; @@ -145,6 +148,47 @@ export function renderAsChild( return renderSlot(children, props as Record, ref); } +function matchesExpected( + actual: unknown, + expected: string | readonly string[] +): boolean { + return typeof expected === 'string' + ? actual === expected + : expected.includes(actual as string); +} + +function contractAttrs( + contracts: readonly ContractRuleEntry[], + target: unknown, + props: Record, + variantDefaults: Readonly> +): Record | undefined { + let attrs: Record | undefined; + for (const rule of contracts) { + if (!rule.attrs) continue; + if (rule.whenTag !== undefined) { + if (typeof target !== 'string') continue; + if (!matchesExpected(target, rule.whenTag)) continue; + } + let matched = true; + for (const [key, expected] of Object.entries(rule.when ?? {})) { + if (expected === undefined) continue; + if (!matchesExpected(props[key] ?? variantDefaults[key], expected)) { + matched = false; + break; + } + } + if (!matched) continue; + for (const [name, value] of Object.entries(rule.attrs)) { + if (props[name] === undefined) { + attrs ??= {}; + attrs[name] ??= value; + } + } + } + return attrs; +} + function joinClassNames(classes: string, className: unknown): string { return className ? `${classes} ${className}` : classes; } @@ -156,11 +200,15 @@ function renderElement( ref: ForwardedRef, classes: string[], dynamicStyle: Record | undefined, - forwardedDefaults: ReadonlyArray<[string, string | boolean]> + forwardedDefaults: ReadonlyArray<[string, string | boolean]>, + contracts: readonly ContractRuleEntry[] | undefined, + variantDefaults: Readonly> ): ReactElement { const ownsElement = typeof element === 'string'; const target = ownsElement ? props.as || element : element; const { className, style } = props; + const attrs = + contracts && contractAttrs(contracts, target, props, variantDefaults); const ownClassName = classes.join(' '); const domProps: Record = { @@ -172,6 +220,7 @@ function renderElement( }; forwardProps(props, filterProps, domProps); for (const [name, value] of forwardedDefaults) domProps[name] ??= value; + if (attrs) Object.assign(domProps, attrs); if (dynamicStyle && !ownsElement && typeof style === 'function') { domProps.style = (state: unknown) => ({ ...style(state), ...dynamicStyle }); @@ -211,6 +260,9 @@ export function createComponent( ...Object.entries(variantDefaults), ...stateProps.map((name): [string, boolean] => [name, false]), ].filter(([name]) => forwarded(name)); + const contracts = componentConfig.contracts?.some((rule) => rule.attrs) + ? componentConfig.contracts + : undefined; const Component = forwardRef( (props: Record, ref: ForwardedRef) => { @@ -233,6 +285,12 @@ export function createComponent( className: joinClassNames(classes.join(' '), props.className), }; forwardProps(props, filterProps, slotProps); + if (contracts) { + Object.assign( + slotProps, + contractAttrs(contracts, undefined, props, variantDefaults) + ); + } return renderSlot(props.children, slotProps, ref, dynamicStyle); } return renderElement( @@ -242,7 +300,9 @@ export function createComponent( ref, classes, dynamicStyle, - forwardedDefaults + forwardedDefaults, + contracts, + variantDefaults ); } ); diff --git a/packages/react/src/types/component.ts b/packages/react/src/types/component.ts index 429989d1..70573bfb 100644 --- a/packages/react/src/types/component.ts +++ b/packages/react/src/types/component.ts @@ -9,6 +9,7 @@ import type { import { type AbstractParser, type AbstractProps, + type ContractRuleEntry, type CSSProps, type SelectorAliasProps, type SystemProp, @@ -25,6 +26,7 @@ import { } from '@animus-ui/core/binding'; import type { AnimusExtended } from '../AnimusExtended'; +import type { ContractProps } from './contract'; declare const ConsumerProps: unique symbol; declare const VariantConfigBrand: unique symbol; @@ -43,6 +45,7 @@ type ExtendFn< S, AG, CP, + Rules extends readonly ContractRuleEntry[], > = { extend: () => AnimusExtended< PR, @@ -51,7 +54,8 @@ type ExtendFn< V & Record, S & Record, AG & Record, - CP & Record + CP & Record, + Rules >; }; @@ -99,8 +103,15 @@ type AnimusNativeProps< S, AG, CP extends Record, + Rules extends readonly ContractRuleEntry[], > = Omit, AnimusManagedKeys> & - AnimusOwnProps; + AnimusOwnProps & + ContractProps< + Rules, + E extends string ? E : string, + V, + ComponentPropsWithRef + >; type AnimusConsumerProps< El extends keyof JSX.IntrinsicElements, @@ -110,7 +121,10 @@ type AnimusConsumerProps< S, AG, CP extends Record, -> = AnimusNativeProps & { as?: AsTarget | undefined }; + Rules extends readonly ContractRuleEntry[], +> = AnimusNativeProps & { + as?: AsTarget | undefined; +}; type ElementFor = [ AsTarget, @@ -127,16 +141,35 @@ export type AnimusComponent< S, AG, CP extends Record, + Rules extends readonly ContractRuleEntry[] = readonly [], > = ForwardRefExoticComponent< - AnimusNativeProps & { as?: El | undefined } + AnimusNativeProps & { as?: El | undefined } > & (( - props: AnimusNativeProps, PR, GR, V, S, AG, CP> & { + props: AnimusNativeProps< + ElementFor, + PR, + GR, + V, + S, + AG, + CP, + Rules + > & { as?: As | undefined; } ) => ReactNode) & - ExtendFn & { - readonly [ConsumerProps]: AnimusConsumerProps; + ExtendFn & { + readonly [ConsumerProps]: AnimusConsumerProps< + El, + PR, + GR, + V, + S, + AG, + CP, + Rules + >; readonly [VariantConfigBrand]: V; readonly variantDefaults: Readonly>; }; @@ -220,6 +253,7 @@ type AnimusWrappedConsumerProps< AG, CP extends Record, RK extends string, + Rules extends readonly ContractRuleEntry[], > = DistributiveOmit< ComponentPropsWithRef, Exclude, 'as' | 'asChild'> @@ -238,7 +272,8 @@ type AnimusWrappedConsumerProps< VariantProps[K & keyof VariantProps], undefined >; - }); + }) & + ContractProps>; export type AnimusWrappedComponent< C extends ComponentType, @@ -250,10 +285,11 @@ export type AnimusWrappedComponent< AG, CP extends Record, RK extends string = never, + Rules extends readonly ContractRuleEntry[] = readonly [], > = ForwardRefExoticComponent< - AnimusWrappedConsumerProps + AnimusWrappedConsumerProps > & - ExtendFn & { + ExtendFn & { readonly [ConsumerProps]: AnimusWrappedConsumerProps< C, PR, @@ -262,7 +298,8 @@ export type AnimusWrappedComponent< S, AG, CP, - RK + RK, + Rules >; readonly [VariantConfigBrand]: V; readonly variantDefaults: Readonly>; @@ -300,7 +337,7 @@ export type SharedConfig> = { type SealedProps = C extends { readonly [ConsumerProps]: infer P; } - ? Omit & { children?: ReactNode } + ? DistributiveOmit & { children?: ReactNode } : C extends ForwardRefExoticComponent ? Omit & { className?: string | undefined; diff --git a/packages/react/src/types/contract.ts b/packages/react/src/types/contract.ts new file mode 100644 index 00000000..d8417065 --- /dev/null +++ b/packages/react/src/types/contract.ts @@ -0,0 +1,133 @@ +import type { ContractRuleEntry, VariantKeyOf } from '@animus-ui/core'; +import type { + ContractTagMatches, + ContractValues, + StripIndex, + VariantOptionMap, +} from '@animus-ui/core/binding'; + +type AttrValue = A extends keyof Native + ? Exclude + : string; + +type RuleAttrs = Rule extends { + readonly require: { readonly attrs: readonly (infer A extends string)[] }; +} + ? A + : never; + +type RuleAnyAttr = Rule extends { + readonly require: { readonly anyAttr: readonly (infer G extends string)[] }; +} + ? G + : never; + +type RuleStates = Rule extends { + readonly dischargedByState: readonly (infer S extends string)[]; +} + ? S + : never; + +type RequireAll = [A] extends [never] + ? unknown + : { [K in A]: AttrValue }; + +type RequireOne = [G] extends [never] + ? unknown + : G extends string + ? { [K in G]: AttrValue } + : never; + +type SetState = S extends string ? { [K in S]: true } : never; + +type RuleDischarge = [ + RuleAttrs | RuleAnyAttr, +] extends [never] + ? unknown + : + | (RequireAll, Native> & + RequireOne, Native>) + | SetState>; + +type RuleWhen = Rule extends { readonly when: infer When } ? When : {}; + +type Expected = ContractValues< + Exclude +>; + +type ConditionKeys = { + [K in keyof When]-?: [Expected] extends [never] ? never : K; +}[keyof When] & + string; + +type DefaultOf = K extends keyof StripIndex + ? StripIndex[K] extends { defaultVariant?: infer D } + ? VariantKeyOf> + : never + : never; + +type DefaultMatches = [ + Extract, Expected>, +] extends [never] + ? false + : true; + +type Matching = { + [K in Keys as DefaultMatches extends true ? never : K]: Expected< + When, + K + >; +} & { + [K in Keys as DefaultMatches extends true ? K : never]?: + | Expected + | undefined; +}; + +type Unmatched = + DefaultMatches extends true + ? { + [P in K]: Exclude< + VariantOptionMap[P & keyof VariantOptionMap], + Expected + >; + } + : { + [P in K]?: + | Exclude< + VariantOptionMap[P & keyof VariantOptionMap], + Expected + > + | undefined; + }; + +type Conditioned = [ConditionKeys] extends [never] + ? Discharge + : + | (Matching> & Discharge) + | { + [K in ConditionKeys]: Unmatched; + }[ConditionKeys]; + +type RuleProps = + ContractTagMatches< + Tag, + Rule extends { readonly whenTag: infer WhenTag } ? WhenTag : undefined + > extends true + ? RuleDischarge extends infer Discharge + ? unknown extends Discharge + ? unknown + : Conditioned, Discharge> + : never + : unknown; + +export type ContractProps< + C extends readonly ContractRuleEntry[], + Tag extends string, + V, + Native, +> = C extends readonly [ + infer Rule, + ...infer Rest extends readonly ContractRuleEntry[], +] + ? RuleProps & ContractProps + : unknown; diff --git a/packages/react/types/published/contract.tsx b/packages/react/types/published/contract.tsx new file mode 100644 index 00000000..66894620 --- /dev/null +++ b/packages/react/types/published/contract.tsx @@ -0,0 +1,108 @@ +import type { ComponentPropsWithRef } from 'react'; + +import { ds } from './kit'; + +import type { Assert, Equal, RequiredKeys } from './guards'; + +const IconButton = ds + .styles({ display: 'inline-flex' }) + .variant({ + prop: 'kind', + defaultVariant: 'solid', + variants: { solid: { padding: '8px 12px' }, iconOnly: { padding: '8px' } }, + }) + .contract({ + when: { kind: 'iconOnly' }, + require: { anyAttr: ['aria-label', 'aria-labelledby'] }, + }) + .asElement('button'); + +const Glyph = ds + .styles({ display: 'inline-flex' }) + .variant({ + prop: 'kind', + defaultVariant: 'iconOnly', + variants: { labelled: {}, iconOnly: {} }, + }) + .contract({ + when: { kind: 'iconOnly' }, + require: { attrs: ['aria-label'] }, + }) + .asElement('span'); + +const Picture = ds + .styles({ display: 'block' }) + .states({ decorative: { pointerEvents: 'none' } }) + .contract({ require: { attrs: ['alt'] }, dischargedByState: ['decorative'] }) + .asElement('img'); + +const Link = ds + .styles({ color: 'ink' }) + .contract({ whenTag: 'a', require: { attrs: ['href'] } }) + .asElement('a'); + +const ExtendedPicture = Picture.extend() + .styles({ opacity: 0.9 }) + .asElement('img'); + +const Plain = ds.styles({ display: 'flex' }).asElement('div'); + +export const accepted = ( + <> + Save + Save + + × + + + × + + Label + ★ + + + + Docs + Not a link + Plain + +); + +// @ts-expect-error +export const iconOnlyUnlabelled = ×; +export const iconOnlyUndefinedLabel = ( + // @ts-expect-error + + × + +); +// @ts-expect-error +export const defaultIconOnly = ★; +// @ts-expect-error +export const explicitIconOnly = ★; +// @ts-expect-error +export const noAlt = ; +// @ts-expect-error +export const notDecorative = ; +// @ts-expect-error +export const extendedNoAlt = ; +// @ts-expect-error +export const anchorNoHref = Docs; + +export const ruleKey = ds + .styles({}) + // @ts-expect-error + .contract({ requires: { attrs: ['href'] } }); +export const requirementKey = ds.styles({}).contract({ + // @ts-expect-error + require: { attrs: ['href'], anyAttrs: ['title'] }, +}); +export const conditionAxis = ds + .styles({}) + .variant({ prop: 'kind', variants: { solid: {} } }) + // @ts-expect-error + .contract({ when: { tone: 'solid' } }); + +export type _NoContract = Assert< + Equal>, never> +>; diff --git a/packages/showcase/src/components/docs/ChainStep.tsx b/packages/showcase/src/components/docs/ChainStep.tsx index 28702627..ae57d360 100644 --- a/packages/showcase/src/components/docs/ChainStep.tsx +++ b/packages/showcase/src/components/docs/ChainStep.tsx @@ -655,7 +655,7 @@ const LAYER_KEYS = ['0', '1', '2', '3', '4', '5'] as const; type LayerKey = (typeof LAYER_KEYS)[number]; function layerKeyAt(index: number): LayerKey { - const key = LAYER_KEYS[index]; + const key = LAYER_KEYS.at(index); if (key === undefined) { throw new Error(`ChainStep supports at most ${LAYER_KEYS.length} steps.`); } @@ -720,7 +720,7 @@ export function ChainStep({ return () => window.removeEventListener('keydown', handler); }, [isControlled, controlledClick, activeStep, steps.length]); - const step = activeStep >= 0 ? steps[activeStep] : null; + const step = activeStep >= 0 ? steps.at(activeStep) : null; const layerKey = activeStep >= 0 ? layerKeyAt(activeStep) : LAYER_KEYS[0]; return ( diff --git a/packages/showcase/src/components/docs/PageNav.tsx b/packages/showcase/src/components/docs/PageNav.tsx index 0bf15b50..2ab3c7c2 100644 --- a/packages/showcase/src/components/docs/PageNav.tsx +++ b/packages/showcase/src/components/docs/PageNav.tsx @@ -73,7 +73,7 @@ export function PageNav() { if (idx === -1) return null; const prev = idx > 0 ? ALL_PAGES[idx - 1] : null; - const next = idx < ALL_PAGES.length - 1 ? ALL_PAGES[idx + 1] : null; + const next = idx < ALL_PAGES.length - 1 ? ALL_PAGES.at(idx + 1) : null; if (!prev && !next) return null; diff --git a/packages/showcase/src/components/surfaces/SyntaxBlock.tsx b/packages/showcase/src/components/surfaces/SyntaxBlock.tsx index 4b666cbd..ba8b4a64 100644 --- a/packages/showcase/src/components/surfaces/SyntaxBlock.tsx +++ b/packages/showcase/src/components/surfaces/SyntaxBlock.tsx @@ -303,15 +303,9 @@ type HighlightLanguage = | 'javascript' | 'plain'; -const HIGHLIGHT_LANGUAGE = { - tsx: 'tsx', - css: 'css', - jsx: 'jsx', - typescript: 'typescript', - javascript: 'javascript', - sh: 'plain', - svelte: 'plain', -} as const satisfies Record; +function highlightLanguage(lang: Language): HighlightLanguage { + return lang === 'sh' || lang === 'svelte' ? 'plain' : lang; +} function detectLanguage(code: string): Language { if ( @@ -399,7 +393,7 @@ export function SyntaxBlock({ {({ tokens: tokenLines, getLineProps, getTokenProps }) => ( @@ -407,32 +401,27 @@ export function SyntaxBlock({ const lineNum = i + 1; const isHighlighted = highlights?.includes(lineNum); const diffType = diffs?.[lineNum]; - const hasDiff = diffType === '+' || diffType === '-'; + const diff = + diffType === '+' + ? 'added' + : diffType === '-' + ? 'removed' + : undefined; return ( {diffs && ( - - {diffType || ' '} + + {diff === 'added' + ? '+' + : diff === 'removed' + ? '-' + : ' '} )} {showLineNumbers && (