Skip to content

Commit 99dc762

Browse files
refactor(compiler): delete the unused selectors module and give toRNProperty one home
src/compiler/selectors.ts's getSelectors is imported by nothing; the compiler builds selectors in selector-builder.ts. The module stayed alive only through its toRNProperty, which atRules.ts and declarations.ts imported while selector-builder.ts and stylesheet.ts used a second copy. toRNProperty moves to utilities/property-names.ts and every caller imports it from there.
1 parent eda2b28 commit 99dc762

7 files changed

Lines changed: 16 additions & 521 deletions

File tree

‎src/compiler/atRules.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type {
66
TokenOrValue,
77
} from "lightningcss";
88

9+
import { toRNProperty } from "../utilities";
910
import type { StyleRuleMapping } from "./compiler.types";
10-
import { toRNProperty } from "./selectors";
1111
import { splitByDelimiter } from "./split-by-delimiter";
1212
import type { StylesheetBuilder } from "./stylesheet";
1313

‎src/compiler/declarations.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ import type {
3636
UnresolvedColor,
3737
} from "lightningcss";
3838

39-
import { isStyleFunction } from "../utilities";
39+
import { isStyleFunction, toRNProperty } from "../utilities";
4040
import { isMappingProperty } from "./atRules";
4141
import type {
4242
StyleDescriptor,
4343
StyleFunction,
4444
StyleRule,
4545
} from "./compiler.types";
4646
import { parseEasingFunction, parseIterationCount } from "./keyframes";
47-
import { toRNProperty } from "./selectors";
4847
import type { StylesheetBuilder } from "./stylesheet";
4948

5049
const CommaSeparator = Symbol("CommaSeparator");

‎src/compiler/selector-builder.ts‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { AttrOperation, Selector, SelectorList } from "lightningcss";
22

3-
import { Specificity } from "../utilities";
3+
import { Specificity, toRNProperty } from "../utilities";
44
import type {
55
AttributeQuery,
66
AttrSelectorOperator,
@@ -597,17 +597,6 @@ function isUniversalSelector([first, second]: Selector) {
597597
return first && first.type === "universal" && !second;
598598
}
599599

600-
export function toRNProperty<T extends string>(str: T) {
601-
return str
602-
.replace(/^-rn-/, "")
603-
.replace(/-./g, (x) => x[1]?.toUpperCase() ?? "") as CamelCase<T>;
604-
}
605-
606-
type CamelCase<S extends string> =
607-
S extends `${infer P1}-${infer P2}${infer P3}`
608-
? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}`
609-
: Lowercase<S>;
610-
611600
const operatorMap: Record<AttrOperation["operator"], AttrSelectorOperator> = {
612601
"equal": "=",
613602
"includes": "~=",

0 commit comments

Comments
 (0)