@tamagui/style-grammar 0.0.0-bootstrap.0 → 3.0.0-beta.643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -1
- package/dist/cjs/backgroundFamily.cjs +176 -0
- package/dist/cjs/backgroundFamily.native.cjs +195 -0
- package/dist/cjs/backgroundFamily.native.js +197 -0
- package/dist/cjs/backgroundFamily.native.js.map +1 -0
- package/dist/cjs/borderFamily.cjs +169 -0
- package/dist/cjs/borderFamily.native.cjs +247 -0
- package/dist/cjs/borderFamily.native.js +249 -0
- package/dist/cjs/borderFamily.native.js.map +1 -0
- package/dist/cjs/candidate.cjs +608 -0
- package/dist/cjs/candidate.native.cjs +821 -0
- package/dist/cjs/candidate.native.js +823 -0
- package/dist/cjs/candidate.native.js.map +1 -0
- package/dist/cjs/candidateTarget.cjs +50 -0
- package/dist/cjs/candidateTarget.native.cjs +88 -0
- package/dist/cjs/candidateTarget.native.js +90 -0
- package/dist/cjs/candidateTarget.native.js.map +1 -0
- package/dist/cjs/clauseCapability.cjs +130 -0
- package/dist/cjs/clauseCapability.native.cjs +152 -0
- package/dist/cjs/clauseCapability.native.js +154 -0
- package/dist/cjs/clauseCapability.native.js.map +1 -0
- package/dist/cjs/clausePrecedence.cjs +153 -0
- package/dist/cjs/clausePrecedence.native.cjs +204 -0
- package/dist/cjs/clausePrecedence.native.js +206 -0
- package/dist/cjs/clausePrecedence.native.js.map +1 -0
- package/dist/cjs/clauseSources.cjs +47 -0
- package/dist/cjs/clauseSources.native.cjs +49 -0
- package/dist/cjs/clauseSources.native.js +51 -0
- package/dist/cjs/clauseSources.native.js.map +1 -0
- package/dist/cjs/config.cjs +130 -0
- package/dist/cjs/config.native.cjs +185 -0
- package/dist/cjs/config.native.js +187 -0
- package/dist/cjs/config.native.js.map +1 -0
- package/dist/cjs/evaluateProgram.cjs +65 -0
- package/dist/cjs/evaluateProgram.native.cjs +70 -0
- package/dist/cjs/evaluateProgram.native.js +72 -0
- package/dist/cjs/evaluateProgram.native.js.map +1 -0
- package/dist/cjs/fontShorthand.cjs +207 -0
- package/dist/cjs/fontShorthand.native.cjs +260 -0
- package/dist/cjs/fontShorthand.native.js +262 -0
- package/dist/cjs/fontShorthand.native.js.map +1 -0
- package/dist/cjs/geometricShorthand.cjs +122 -0
- package/dist/cjs/geometricShorthand.native.cjs +128 -0
- package/dist/cjs/geometricShorthand.native.js +130 -0
- package/dist/cjs/geometricShorthand.native.js.map +1 -0
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +23 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/lowerProgram.cjs +205 -0
- package/dist/cjs/lowerProgram.native.cjs +257 -0
- package/dist/cjs/lowerProgram.native.js +259 -0
- package/dist/cjs/lowerProgram.native.js.map +1 -0
- package/dist/cjs/mergeFlatValues.cjs +50 -0
- package/dist/cjs/mergeFlatValues.native.cjs +71 -0
- package/dist/cjs/mergeFlatValues.native.js +73 -0
- package/dist/cjs/mergeFlatValues.native.js.map +1 -0
- package/dist/cjs/modifierRegistry.cjs +246 -0
- package/dist/cjs/modifierRegistry.native.cjs +426 -0
- package/dist/cjs/modifierRegistry.native.js +428 -0
- package/dist/cjs/modifierRegistry.native.js.map +1 -0
- package/dist/cjs/payloadShape.cjs +69 -0
- package/dist/cjs/payloadShape.native.cjs +71 -0
- package/dist/cjs/payloadShape.native.js +73 -0
- package/dist/cjs/payloadShape.native.js.map +1 -0
- package/dist/cjs/programEligibility.cjs +46 -0
- package/dist/cjs/programEligibility.native.cjs +48 -0
- package/dist/cjs/programEligibility.native.js +50 -0
- package/dist/cjs/programEligibility.native.js.map +1 -0
- package/dist/cjs/programHash.cjs +86 -0
- package/dist/cjs/programHash.native.cjs +106 -0
- package/dist/cjs/programHash.native.js +108 -0
- package/dist/cjs/programHash.native.js.map +1 -0
- package/dist/cjs/programs.cjs +128 -0
- package/dist/cjs/programs.native.cjs +220 -0
- package/dist/cjs/programs.native.js +222 -0
- package/dist/cjs/programs.native.js.map +1 -0
- package/dist/cjs/registry.cjs +629 -0
- package/dist/cjs/registry.native.cjs +635 -0
- package/dist/cjs/registry.native.js +637 -0
- package/dist/cjs/registry.native.js.map +1 -0
- package/dist/cjs/resolvePayload.cjs +296 -0
- package/dist/cjs/resolvePayload.native.cjs +302 -0
- package/dist/cjs/resolvePayload.native.js +304 -0
- package/dist/cjs/resolvePayload.native.js.map +1 -0
- package/dist/cjs/runtime.cjs +50 -0
- package/dist/cjs/runtime.native.cjs +52 -0
- package/dist/cjs/runtime.native.js +54 -0
- package/dist/cjs/runtime.native.js.map +1 -0
- package/dist/cjs/safeAreaVariables.cjs +42 -0
- package/dist/cjs/safeAreaVariables.native.cjs +44 -0
- package/dist/cjs/safeAreaVariables.native.js +46 -0
- package/dist/cjs/safeAreaVariables.native.js.map +1 -0
- package/dist/cjs/scanFlatValue.cjs +181 -0
- package/dist/cjs/scanFlatValue.native.cjs +183 -0
- package/dist/cjs/scanFlatValue.native.js +185 -0
- package/dist/cjs/scanFlatValue.native.js.map +1 -0
- package/dist/cjs/serializePayload.cjs +149 -0
- package/dist/cjs/serializePayload.native.cjs +187 -0
- package/dist/cjs/serializePayload.native.js +189 -0
- package/dist/cjs/serializePayload.native.js.map +1 -0
- package/dist/cjs/stateModifiers.cjs +43 -0
- package/dist/cjs/stateModifiers.native.cjs +45 -0
- package/dist/cjs/stateModifiers.native.js +47 -0
- package/dist/cjs/stateModifiers.native.js.map +1 -0
- package/dist/cjs/states.cjs +97 -0
- package/dist/cjs/states.native.cjs +131 -0
- package/dist/cjs/states.native.js +133 -0
- package/dist/cjs/states.native.js.map +1 -0
- package/dist/cjs/table.cjs +54 -0
- package/dist/cjs/table.native.cjs +135 -0
- package/dist/cjs/table.native.js +137 -0
- package/dist/cjs/table.native.js.map +1 -0
- package/dist/cjs/textDecorationFamily.cjs +129 -0
- package/dist/cjs/textDecorationFamily.native.cjs +199 -0
- package/dist/cjs/textDecorationFamily.native.js +201 -0
- package/dist/cjs/textDecorationFamily.native.js.map +1 -0
- package/dist/cjs/tooling.cjs +26 -0
- package/dist/cjs/tooling.native.cjs +28 -0
- package/dist/cjs/tooling.native.js +30 -0
- package/dist/cjs/tooling.native.js.map +1 -0
- package/dist/cjs/toolingAnnotations.cjs +105 -0
- package/dist/cjs/toolingAnnotations.native.cjs +133 -0
- package/dist/cjs/toolingAnnotations.native.js +135 -0
- package/dist/cjs/toolingAnnotations.native.js.map +1 -0
- package/dist/cjs/toolingDiagnostics.cjs +459 -0
- package/dist/cjs/toolingDiagnostics.native.cjs +788 -0
- package/dist/cjs/toolingDiagnostics.native.js +790 -0
- package/dist/cjs/toolingDiagnostics.native.js.map +1 -0
- package/dist/cjs/toolingRegistry.cjs +159 -0
- package/dist/cjs/toolingRegistry.native.cjs +164 -0
- package/dist/cjs/toolingRegistry.native.js +166 -0
- package/dist/cjs/toolingRegistry.native.js.map +1 -0
- package/dist/cjs/transformFamily.cjs +425 -0
- package/dist/cjs/transformFamily.native.cjs +517 -0
- package/dist/cjs/transformFamily.native.js +519 -0
- package/dist/cjs/transformFamily.native.js.map +1 -0
- package/dist/cjs/transition.cjs +459 -0
- package/dist/cjs/transition.native.cjs +499 -0
- package/dist/cjs/transition.native.js +501 -0
- package/dist/cjs/transition.native.js.map +1 -0
- package/dist/cjs/transitionAlign.cjs +115 -0
- package/dist/cjs/transitionAlign.native.cjs +154 -0
- package/dist/cjs/transitionAlign.native.js +156 -0
- package/dist/cjs/transitionAlign.native.js.map +1 -0
- package/dist/cjs/transitionLegacy.cjs +217 -0
- package/dist/cjs/transitionLegacy.native.cjs +260 -0
- package/dist/cjs/transitionLegacy.native.js +262 -0
- package/dist/cjs/transitionLegacy.native.js.map +1 -0
- package/dist/cjs/transitionNative.cjs +281 -0
- package/dist/cjs/transitionNative.native.cjs +285 -0
- package/dist/cjs/transitionNative.native.js +287 -0
- package/dist/cjs/transitionNative.native.js.map +1 -0
- package/dist/cjs/unitlessNumbers.cjs +86 -0
- package/dist/cjs/unitlessNumbers.native.cjs +106 -0
- package/dist/cjs/unitlessNumbers.native.js +108 -0
- package/dist/cjs/unitlessNumbers.native.js.map +1 -0
- package/dist/cjs/v6ThemeNames.cjs +47 -0
- package/dist/cjs/v6ThemeNames.native.cjs +53 -0
- package/dist/cjs/v6ThemeNames.native.js +55 -0
- package/dist/cjs/v6ThemeNames.native.js.map +1 -0
- package/dist/cjs/valueParser.cjs +148 -0
- package/dist/cjs/valueParser.native.cjs +150 -0
- package/dist/cjs/valueParser.native.js +152 -0
- package/dist/cjs/valueParser.native.js.map +1 -0
- package/dist/cjs/valueTypes.cjs +38 -0
- package/dist/cjs/valueTypes.native.cjs +40 -0
- package/dist/cjs/valueTypes.native.js +42 -0
- package/dist/cjs/valueTypes.native.js.map +1 -0
- package/dist/esm/backgroundFamily.mjs +150 -0
- package/dist/esm/backgroundFamily.mjs.map +1 -0
- package/dist/esm/backgroundFamily.native.js +167 -0
- package/dist/esm/backgroundFamily.native.js.map +1 -0
- package/dist/esm/borderFamily.mjs +146 -0
- package/dist/esm/borderFamily.mjs.map +1 -0
- package/dist/esm/borderFamily.native.js +222 -0
- package/dist/esm/borderFamily.native.js.map +1 -0
- package/dist/esm/candidate.mjs +581 -0
- package/dist/esm/candidate.mjs.map +1 -0
- package/dist/esm/candidate.native.js +792 -0
- package/dist/esm/candidate.native.js.map +1 -0
- package/dist/esm/candidateTarget.mjs +29 -0
- package/dist/esm/candidateTarget.mjs.map +1 -0
- package/dist/esm/candidateTarget.native.js +65 -0
- package/dist/esm/candidateTarget.native.js.map +1 -0
- package/dist/esm/clauseCapability.mjs +107 -0
- package/dist/esm/clauseCapability.mjs.map +1 -0
- package/dist/esm/clauseCapability.native.js +127 -0
- package/dist/esm/clauseCapability.native.js.map +1 -0
- package/dist/esm/clausePrecedence.mjs +121 -0
- package/dist/esm/clausePrecedence.mjs.map +1 -0
- package/dist/esm/clausePrecedence.native.js +170 -0
- package/dist/esm/clausePrecedence.native.js.map +1 -0
- package/dist/esm/clauseSources.mjs +23 -0
- package/dist/esm/clauseSources.mjs.map +1 -0
- package/dist/esm/clauseSources.native.js +23 -0
- package/dist/esm/clauseSources.native.js.map +1 -0
- package/dist/esm/config.mjs +103 -0
- package/dist/esm/config.mjs.map +1 -0
- package/dist/esm/config.native.js +156 -0
- package/dist/esm/config.native.js.map +1 -0
- package/dist/esm/evaluateProgram.mjs +45 -0
- package/dist/esm/evaluateProgram.mjs.map +1 -0
- package/dist/esm/evaluateProgram.native.js +48 -0
- package/dist/esm/evaluateProgram.native.js.map +1 -0
- package/dist/esm/fontShorthand.mjs +184 -0
- package/dist/esm/fontShorthand.mjs.map +1 -0
- package/dist/esm/fontShorthand.native.js +235 -0
- package/dist/esm/fontShorthand.native.js.map +1 -0
- package/dist/esm/geometricShorthand.mjs +102 -0
- package/dist/esm/geometricShorthand.mjs.map +1 -0
- package/dist/esm/geometricShorthand.native.js +106 -0
- package/dist/esm/geometricShorthand.native.js.map +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/lowerProgram.mjs +182 -0
- package/dist/esm/lowerProgram.mjs.map +1 -0
- package/dist/esm/lowerProgram.native.js +232 -0
- package/dist/esm/lowerProgram.native.js.map +1 -0
- package/dist/esm/mergeFlatValues.mjs +27 -0
- package/dist/esm/mergeFlatValues.mjs.map +1 -0
- package/dist/esm/mergeFlatValues.native.js +46 -0
- package/dist/esm/mergeFlatValues.native.js.map +1 -0
- package/dist/esm/modifierRegistry.mjs +219 -0
- package/dist/esm/modifierRegistry.mjs.map +1 -0
- package/dist/esm/modifierRegistry.native.js +397 -0
- package/dist/esm/modifierRegistry.native.js.map +1 -0
- package/dist/esm/payloadShape.mjs +49 -0
- package/dist/esm/payloadShape.mjs.map +1 -0
- package/dist/esm/payloadShape.native.js +49 -0
- package/dist/esm/payloadShape.native.js.map +1 -0
- package/dist/esm/programEligibility.mjs +22 -0
- package/dist/esm/programEligibility.mjs.map +1 -0
- package/dist/esm/programEligibility.native.js +22 -0
- package/dist/esm/programEligibility.native.js.map +1 -0
- package/dist/esm/programHash.mjs +62 -0
- package/dist/esm/programHash.mjs.map +1 -0
- package/dist/esm/programHash.native.js +80 -0
- package/dist/esm/programHash.native.js.map +1 -0
- package/dist/esm/programs.mjs +103 -0
- package/dist/esm/programs.mjs.map +1 -0
- package/dist/esm/programs.native.js +193 -0
- package/dist/esm/programs.native.js.map +1 -0
- package/dist/esm/registry.mjs +595 -0
- package/dist/esm/registry.mjs.map +1 -0
- package/dist/esm/registry.native.js +599 -0
- package/dist/esm/registry.native.js.map +1 -0
- package/dist/esm/resolvePayload.mjs +273 -0
- package/dist/esm/resolvePayload.mjs.map +1 -0
- package/dist/esm/resolvePayload.native.js +277 -0
- package/dist/esm/resolvePayload.native.js.map +1 -0
- package/dist/esm/runtime.mjs +63 -0
- package/dist/esm/runtime.native.js +63 -0
- package/dist/esm/safeAreaVariables.mjs +18 -0
- package/dist/esm/safeAreaVariables.mjs.map +1 -0
- package/dist/esm/safeAreaVariables.native.js +18 -0
- package/dist/esm/safeAreaVariables.native.js.map +1 -0
- package/dist/esm/scanFlatValue.mjs +160 -0
- package/dist/esm/scanFlatValue.mjs.map +1 -0
- package/dist/esm/scanFlatValue.native.js +160 -0
- package/dist/esm/scanFlatValue.native.js.map +1 -0
- package/dist/esm/serializePayload.mjs +125 -0
- package/dist/esm/serializePayload.mjs.map +1 -0
- package/dist/esm/serializePayload.native.js +161 -0
- package/dist/esm/serializePayload.native.js.map +1 -0
- package/dist/esm/stateModifiers.mjs +19 -0
- package/dist/esm/stateModifiers.mjs.map +1 -0
- package/dist/esm/stateModifiers.native.js +19 -0
- package/dist/esm/stateModifiers.native.js.map +1 -0
- package/dist/esm/states.mjs +69 -0
- package/dist/esm/states.mjs.map +1 -0
- package/dist/esm/states.native.js +101 -0
- package/dist/esm/states.native.js.map +1 -0
- package/dist/esm/table.mjs +31 -0
- package/dist/esm/table.mjs.map +1 -0
- package/dist/esm/table.native.js +110 -0
- package/dist/esm/table.native.js.map +1 -0
- package/dist/esm/textDecorationFamily.mjs +106 -0
- package/dist/esm/textDecorationFamily.mjs.map +1 -0
- package/dist/esm/textDecorationFamily.native.js +174 -0
- package/dist/esm/textDecorationFamily.native.js.map +1 -0
- package/dist/esm/tooling.mjs +15 -0
- package/dist/esm/tooling.native.js +15 -0
- package/dist/esm/toolingAnnotations.mjs +85 -0
- package/dist/esm/toolingAnnotations.mjs.map +1 -0
- package/dist/esm/toolingAnnotations.native.js +111 -0
- package/dist/esm/toolingAnnotations.native.js.map +1 -0
- package/dist/esm/toolingDiagnostics.mjs +428 -0
- package/dist/esm/toolingDiagnostics.mjs.map +1 -0
- package/dist/esm/toolingDiagnostics.native.js +755 -0
- package/dist/esm/toolingDiagnostics.native.js.map +1 -0
- package/dist/esm/toolingRegistry.mjs +135 -0
- package/dist/esm/toolingRegistry.mjs.map +1 -0
- package/dist/esm/toolingRegistry.native.js +138 -0
- package/dist/esm/toolingRegistry.native.js.map +1 -0
- package/dist/esm/transformFamily.mjs +392 -0
- package/dist/esm/transformFamily.mjs.map +1 -0
- package/dist/esm/transformFamily.native.js +482 -0
- package/dist/esm/transformFamily.native.js.map +1 -0
- package/dist/esm/transition.mjs +434 -0
- package/dist/esm/transition.mjs.map +1 -0
- package/dist/esm/transition.native.js +472 -0
- package/dist/esm/transition.native.js.map +1 -0
- package/dist/esm/transitionAlign.mjs +95 -0
- package/dist/esm/transitionAlign.mjs.map +1 -0
- package/dist/esm/transitionAlign.native.js +132 -0
- package/dist/esm/transitionAlign.native.js.map +1 -0
- package/dist/esm/transitionLegacy.mjs +197 -0
- package/dist/esm/transitionLegacy.mjs.map +1 -0
- package/dist/esm/transitionLegacy.native.js +238 -0
- package/dist/esm/transitionLegacy.native.js.map +1 -0
- package/dist/esm/transitionNative.mjs +257 -0
- package/dist/esm/transitionNative.mjs.map +1 -0
- package/dist/esm/transitionNative.native.js +259 -0
- package/dist/esm/transitionNative.native.js.map +1 -0
- package/dist/esm/unitlessNumbers.mjs +65 -0
- package/dist/esm/unitlessNumbers.mjs.map +1 -0
- package/dist/esm/unitlessNumbers.native.js +83 -0
- package/dist/esm/unitlessNumbers.native.js.map +1 -0
- package/dist/esm/v6ThemeNames.mjs +23 -0
- package/dist/esm/v6ThemeNames.mjs.map +1 -0
- package/dist/esm/v6ThemeNames.native.js +27 -0
- package/dist/esm/v6ThemeNames.native.js.map +1 -0
- package/dist/esm/valueParser.mjs +125 -0
- package/dist/esm/valueParser.mjs.map +1 -0
- package/dist/esm/valueParser.native.js +125 -0
- package/dist/esm/valueParser.native.js.map +1 -0
- package/dist/esm/valueTypes.mjs +14 -0
- package/dist/esm/valueTypes.mjs.map +1 -0
- package/dist/esm/valueTypes.native.js +14 -0
- package/dist/esm/valueTypes.native.js.map +1 -0
- package/package.json +98 -4
- package/src/backgroundFamily.ts +182 -0
- package/src/borderFamily.ts +172 -0
- package/src/candidate.ts +691 -0
- package/src/candidateTarget.ts +67 -0
- package/src/clauseCapability.ts +209 -0
- package/src/clausePrecedence.ts +198 -0
- package/src/clauseSources.ts +29 -0
- package/src/config.ts +169 -0
- package/src/evaluateProgram.ts +91 -0
- package/src/fontShorthand.ts +177 -0
- package/src/geometricShorthand.ts +105 -0
- package/src/index.ts +1 -0
- package/src/lowerProgram.ts +398 -0
- package/src/modifierRegistry.ts +340 -0
- package/src/payloadShape.ts +92 -0
- package/src/programEligibility.ts +46 -0
- package/src/programHash.ts +128 -0
- package/src/programs.ts +95 -0
- package/src/registry.ts +367 -0
- package/src/resolvePayload.ts +480 -0
- package/src/runtime.ts +32 -0
- package/src/safeAreaVariables.ts +19 -0
- package/src/scanFlatValue.ts +327 -0
- package/src/serializePayload.ts +199 -0
- package/src/stateModifiers.ts +36 -0
- package/src/states.ts +128 -0
- package/src/table.ts +47 -0
- package/src/textDecorationFamily.ts +119 -0
- package/src/tooling.ts +8 -0
- package/src/toolingAnnotations.ts +151 -0
- package/src/toolingDiagnostics.ts +735 -0
- package/src/toolingRegistry.ts +130 -0
- package/src/transformFamily.ts +590 -0
- package/src/transition.ts +553 -0
- package/src/transitionAlign.ts +165 -0
- package/src/transitionLegacy.ts +237 -0
- package/src/transitionNative.ts +357 -0
- package/src/unitlessNumbers.ts +61 -0
- package/src/v6ThemeNames.ts +40 -0
- package/src/valueParser.ts +193 -0
- package/src/valueTypes.ts +136 -0
- package/types/backgroundFamily.d.ts +17 -0
- package/types/backgroundFamily.d.ts.map +11 -0
- package/types/borderFamily.d.ts +23 -0
- package/types/borderFamily.d.ts.map +11 -0
- package/types/candidate.d.ts +52 -0
- package/types/candidate.d.ts.map +11 -0
- package/types/candidateTarget.d.ts +32 -0
- package/types/candidateTarget.d.ts.map +11 -0
- package/types/clauseCapability.d.ts +69 -0
- package/types/clauseCapability.d.ts.map +11 -0
- package/types/clausePrecedence.d.ts +30 -0
- package/types/clausePrecedence.d.ts.map +11 -0
- package/types/clauseSources.d.ts +12 -0
- package/types/clauseSources.d.ts.map +11 -0
- package/types/config.d.ts +44 -0
- package/types/config.d.ts.map +11 -0
- package/types/evaluateProgram.d.ts +27 -0
- package/types/evaluateProgram.d.ts.map +11 -0
- package/types/fontShorthand.d.ts +25 -0
- package/types/fontShorthand.d.ts.map +11 -0
- package/types/geometricShorthand.d.ts +21 -0
- package/types/geometricShorthand.d.ts.map +11 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +11 -0
- package/types/lowerProgram.d.ts +73 -0
- package/types/lowerProgram.d.ts.map +11 -0
- package/types/mergeFlatValues.d.ts +14 -0
- package/types/mergeFlatValues.d.ts.map +11 -0
- package/types/modifierRegistry.d.ts +70 -0
- package/types/modifierRegistry.d.ts.map +11 -0
- package/types/payloadShape.d.ts +15 -0
- package/types/payloadShape.d.ts.map +11 -0
- package/types/programEligibility.d.ts +23 -0
- package/types/programEligibility.d.ts.map +11 -0
- package/types/programHash.d.ts +20 -0
- package/types/programHash.d.ts.map +11 -0
- package/types/programs.d.ts +18 -0
- package/types/programs.d.ts.map +11 -0
- package/types/registry.d.ts +24 -0
- package/types/registry.d.ts.map +11 -0
- package/types/resolvePayload.d.ts +75 -0
- package/types/resolvePayload.d.ts.map +11 -0
- package/types/runtime.d.ts +34 -0
- package/types/runtime.d.ts.map +11 -0
- package/types/safeAreaVariables.d.ts +5 -0
- package/types/safeAreaVariables.d.ts.map +11 -0
- package/types/scanFlatValue.d.ts +29 -0
- package/types/scanFlatValue.d.ts.map +11 -0
- package/types/serializePayload.d.ts +13 -0
- package/types/serializePayload.d.ts.map +11 -0
- package/types/stateModifiers.d.ts +14 -0
- package/types/stateModifiers.d.ts.map +11 -0
- package/types/states.d.ts +22 -0
- package/types/states.d.ts.map +11 -0
- package/types/table.d.ts +4 -0
- package/types/table.d.ts.map +11 -0
- package/types/textDecorationFamily.d.ts +23 -0
- package/types/textDecorationFamily.d.ts.map +11 -0
- package/types/tooling.d.ts +10 -0
- package/types/tooling.d.ts.map +11 -0
- package/types/toolingAnnotations.d.ts +29 -0
- package/types/toolingAnnotations.d.ts.map +11 -0
- package/types/toolingDiagnostics.d.ts +114 -0
- package/types/toolingDiagnostics.d.ts.map +11 -0
- package/types/toolingRegistry.d.ts +10 -0
- package/types/toolingRegistry.d.ts.map +11 -0
- package/types/transformFamily.d.ts +83 -0
- package/types/transformFamily.d.ts.map +11 -0
- package/types/transition.d.ts +65 -0
- package/types/transition.d.ts.map +11 -0
- package/types/transitionAlign.d.ts +15 -0
- package/types/transitionAlign.d.ts.map +11 -0
- package/types/transitionLegacy.d.ts +9 -0
- package/types/transitionLegacy.d.ts.map +11 -0
- package/types/transitionNative.d.ts +41 -0
- package/types/transitionNative.d.ts.map +11 -0
- package/types/unitlessNumbers.d.ts +3 -0
- package/types/unitlessNumbers.d.ts.map +11 -0
- package/types/v6ThemeNames.d.ts +7 -0
- package/types/v6ThemeNames.d.ts.map +11 -0
- package/types/valueParser.d.ts +36 -0
- package/types/valueParser.d.ts.map +11 -0
- package/types/valueTypes.d.ts +66 -0
- package/types/valueTypes.d.ts.map +11 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// The one flat-value lexer.
|
|
2
|
+
//
|
|
3
|
+
// value := base? clause*
|
|
4
|
+
// clause := modifier (":" modifier)* ":" payload
|
|
5
|
+
//
|
|
6
|
+
// Every implementation of this grammar splits a value the same way, so the
|
|
7
|
+
// split lives here once and every consumer drives it with a visitor:
|
|
8
|
+
// `parseValue` builds the canonical result on top of it, and the web runtime's
|
|
9
|
+
// style, variant and lifecycle scanners drive it directly so that what they
|
|
10
|
+
// consume cannot drift from what the canonical parser says the value means.
|
|
11
|
+
//
|
|
12
|
+
// The visitor gets index ranges, never slices. A style prop is scanned on every
|
|
13
|
+
// render it is not classed away, so the scan itself allocates nothing and the
|
|
14
|
+
// consumer slices only what it keeps.
|
|
15
|
+
//
|
|
16
|
+
// Clause detection is purely syntactic. A colon counts only at the top level:
|
|
17
|
+
// outside strings, outside comments, outside `url()` and outside every paren
|
|
18
|
+
// nesting, which covers every other function. A top-level colon is never valid
|
|
19
|
+
// inside a CSS value, so an unregistered modifier is a hard error rather than
|
|
20
|
+
// silent value content.
|
|
21
|
+
//
|
|
22
|
+
// A top-level `{`, `}`, or `;` is rejected for the same reason: those tokens are
|
|
23
|
+
// never valid in a CSS component value. Inside strings, comments, `url()` and
|
|
24
|
+
// parens they stay ordinary content.
|
|
25
|
+
//
|
|
26
|
+
// The states below mirror CSS's tokenizer rather than approximating it, because
|
|
27
|
+
// the whole class of bugs here has been the scan believing it was inside a
|
|
28
|
+
// construct the tokenizer had already left:
|
|
29
|
+
//
|
|
30
|
+
// - a comment outranks paren depth, because comments are lexical. `/*` opens
|
|
31
|
+
// one at ANY depth, since `calc(1px /* pad */ + 2px)` is real CSS. It runs
|
|
32
|
+
// to `*/` however many lines that takes and holds no escapes: `\*/` still
|
|
33
|
+
// closes it. A comment is opaque content belonging to whatever segment it
|
|
34
|
+
// sits in, so a colon inside one is not a clause boundary and a `;` inside
|
|
35
|
+
// one is not a refused character.
|
|
36
|
+
// - a string outranks a comment opener: `"/*"` is a two-character string.
|
|
37
|
+
// - a comment outranks a quote: a `"` inside one is just text.
|
|
38
|
+
// - `url(` outranks BOTH. It is the one function CSS does not tokenize: no
|
|
39
|
+
// comments, no strings, only an escape and the `)` that ends it.
|
|
40
|
+
// `url("...")` is an ordinary function whose string IS real, so the quote
|
|
41
|
+
// lookahead in `opensUrlToken` has to tell the two apart.
|
|
42
|
+
// - a backslash escapes its next character everywhere except inside a comment.
|
|
43
|
+
//
|
|
44
|
+
// Containment is only real if the delimiter actually closes, so an unbalanced
|
|
45
|
+
// value is an error rather than trusted for a containment the emitted CSS will
|
|
46
|
+
// not honour:
|
|
47
|
+
//
|
|
48
|
+
// - a string. CSS ends an unterminated one at a NEWLINE, as a parse error, so
|
|
49
|
+
// `"abc\n;}.x{y"` would read quoted end to end to a naive scan while the
|
|
50
|
+
// browser reads a bad string, a top-level `;}` and a new rule. The scan
|
|
51
|
+
// reports the error at the opening quote and RESUMES at the newline, so the
|
|
52
|
+
// `;}` is seen where the browser sees it. A backslash before the newline is
|
|
53
|
+
// a line continuation and does stay inside the string, which is why the
|
|
54
|
+
// escape branch is checked first.
|
|
55
|
+
// - a comment. `red/*` opens one that swallows whatever follows it, and
|
|
56
|
+
// `insertStyleRule`'s `getAllRules` joins rules into one blob that SSR emits
|
|
57
|
+
// as a single style tag, so an unclosed comment blanks other components'
|
|
58
|
+
// rules until some later `*/` turns them back on.
|
|
59
|
+
// - a `*/` with nothing open, at any depth, closes a comment somewhere else in
|
|
60
|
+
// that same blob.
|
|
61
|
+
//
|
|
62
|
+
// This runs at runtime on native, so it is one left-to-right pass with no
|
|
63
|
+
// regexes and no substrings.
|
|
64
|
+
|
|
65
|
+
const CHAR_TAB = 9
|
|
66
|
+
const CHAR_LF = 10
|
|
67
|
+
const CHAR_FF = 12
|
|
68
|
+
const CHAR_CR = 13
|
|
69
|
+
const CHAR_SPACE = 32
|
|
70
|
+
const CHAR_DOUBLE_QUOTE = 34
|
|
71
|
+
const CHAR_SINGLE_QUOTE = 39
|
|
72
|
+
const CHAR_PAREN_OPEN = 40
|
|
73
|
+
const CHAR_PAREN_CLOSE = 41
|
|
74
|
+
const CHAR_STAR = 42
|
|
75
|
+
const CHAR_SLASH = 47
|
|
76
|
+
const CHAR_SEMICOLON = 59
|
|
77
|
+
const CHAR_COLON = 58
|
|
78
|
+
const CHAR_BACKSLASH = 92
|
|
79
|
+
const CHAR_BRACE_OPEN = 123
|
|
80
|
+
const CHAR_BRACE_CLOSE = 125
|
|
81
|
+
|
|
82
|
+
export type FlatScanErrorCode =
|
|
83
|
+
| 'invalid-character'
|
|
84
|
+
| 'unterminated-string'
|
|
85
|
+
| 'unterminated-function'
|
|
86
|
+
| 'unterminated-comment'
|
|
87
|
+
| 'stray-comment-close'
|
|
88
|
+
|
|
89
|
+
/** why a scan stopped short, or null when it ran to the end cleanly */
|
|
90
|
+
export type FlatScanFailure = FlatScanErrorCode | 'refused-chain'
|
|
91
|
+
|
|
92
|
+
export interface FlatValueVisitor {
|
|
93
|
+
/**
|
|
94
|
+
* The base, or one clause's payload, just ended. `start` and `end` are
|
|
95
|
+
* already trimmed, and `start === end` means the segment is empty: an empty
|
|
96
|
+
* base is simply no base, an empty payload is a clause with nothing in it.
|
|
97
|
+
*/
|
|
98
|
+
segment(start: number, end: number, isBase: boolean): void
|
|
99
|
+
/**
|
|
100
|
+
* A modifier chain just ended, without its trailing colon, so
|
|
101
|
+
* `source.slice(start, end)` is `dark:hover` for `dark:hover:red`. Returning
|
|
102
|
+
* false stops the scan: the consumer has refused the value and does not want
|
|
103
|
+
* later chains resolved.
|
|
104
|
+
*/
|
|
105
|
+
chain(start: number, end: number): boolean
|
|
106
|
+
/**
|
|
107
|
+
* A character the grammar refuses, or a delimiter left open at the end. The
|
|
108
|
+
* scan continues, so a consumer that only wants the first one records it and
|
|
109
|
+
* refuses the next chain.
|
|
110
|
+
*/
|
|
111
|
+
error?(code: FlatScanErrorCode, index: number): void
|
|
112
|
+
/** every top-level word, whether or not it turned out to carry a chain */
|
|
113
|
+
word?(start: number, end: number, isChain: boolean): void
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isWhitespace(code: number): boolean {
|
|
117
|
+
return (
|
|
118
|
+
code === CHAR_SPACE ||
|
|
119
|
+
code === CHAR_TAB ||
|
|
120
|
+
code === CHAR_LF ||
|
|
121
|
+
code === CHAR_CR ||
|
|
122
|
+
code === CHAR_FF
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* `index` points at the `(`. A url token is the ident `url` followed directly by
|
|
128
|
+
* it, with no ident character before the `u` (`myurl(` is an ordinary function)
|
|
129
|
+
* and no quote after it (`url("a")` is one too).
|
|
130
|
+
*/
|
|
131
|
+
function opensUrlToken(source: string, index: number): boolean {
|
|
132
|
+
if (index < 3) return false
|
|
133
|
+
if (
|
|
134
|
+
(source.charCodeAt(index - 3) | 32) !== 117 ||
|
|
135
|
+
(source.charCodeAt(index - 2) | 32) !== 114 ||
|
|
136
|
+
(source.charCodeAt(index - 1) | 32) !== 108
|
|
137
|
+
) {
|
|
138
|
+
return false
|
|
139
|
+
}
|
|
140
|
+
const before = index > 3 ? source.charCodeAt(index - 4) : 0
|
|
141
|
+
if (
|
|
142
|
+
before === 45 ||
|
|
143
|
+
before === 95 ||
|
|
144
|
+
before >= 128 ||
|
|
145
|
+
(before >= 48 && before <= 57) ||
|
|
146
|
+
(before >= 65 && before <= 90) ||
|
|
147
|
+
(before >= 97 && before <= 122)
|
|
148
|
+
) {
|
|
149
|
+
return false
|
|
150
|
+
}
|
|
151
|
+
let next = index + 1
|
|
152
|
+
while (next < source.length && source.charCodeAt(next) <= 32) next++
|
|
153
|
+
const quote = source.charCodeAt(next)
|
|
154
|
+
return quote !== CHAR_DOUBLE_QUOTE && quote !== CHAR_SINGLE_QUOTE
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Closes the base (before any clause) or the payload of the pending clause.
|
|
159
|
+
*
|
|
160
|
+
* A module function rather than a closure over the scan: a style prop is
|
|
161
|
+
* scanned on every render it is not classed away, and one closure per scan is
|
|
162
|
+
* one allocation per prop per render for nothing.
|
|
163
|
+
*/
|
|
164
|
+
function closeSegment(
|
|
165
|
+
source: string,
|
|
166
|
+
visitor: FlatValueVisitor,
|
|
167
|
+
segmentStart: number,
|
|
168
|
+
end: number,
|
|
169
|
+
isBase: boolean
|
|
170
|
+
): void {
|
|
171
|
+
let start = segmentStart
|
|
172
|
+
let stop = end
|
|
173
|
+
while (start < stop && isWhitespace(source.charCodeAt(start))) start++
|
|
174
|
+
while (stop > start && isWhitespace(source.charCodeAt(stop - 1))) stop--
|
|
175
|
+
visitor.segment(start, stop, isBase)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function scanFlatValue(
|
|
179
|
+
source: string,
|
|
180
|
+
visitor: FlatValueVisitor
|
|
181
|
+
): FlatScanFailure | null {
|
|
182
|
+
const length = source.length
|
|
183
|
+
|
|
184
|
+
let failure: FlatScanFailure | null = null
|
|
185
|
+
let sawChain = false
|
|
186
|
+
// where the base, or the current payload, starts
|
|
187
|
+
let segmentStart = 0
|
|
188
|
+
|
|
189
|
+
// scanner state: in a comment, in a string, in a url token, inside parens, or
|
|
190
|
+
// at the top level
|
|
191
|
+
let comment = false
|
|
192
|
+
let commentStart = -1
|
|
193
|
+
let quote = 0
|
|
194
|
+
let quoteStart = -1
|
|
195
|
+
let url = false
|
|
196
|
+
let depth = 0
|
|
197
|
+
let parenStart = -1
|
|
198
|
+
// the top-level word being scanned, and the last top-level colon inside it
|
|
199
|
+
let wordStart = -1
|
|
200
|
+
let lastColon = -1
|
|
201
|
+
|
|
202
|
+
for (let index = 0; index < length; index++) {
|
|
203
|
+
const code = source.charCodeAt(index)
|
|
204
|
+
|
|
205
|
+
if (comment) {
|
|
206
|
+
// no escapes inside a comment: `\*/` still closes it
|
|
207
|
+
if (code === CHAR_STAR && source.charCodeAt(index + 1) === CHAR_SLASH) {
|
|
208
|
+
comment = false
|
|
209
|
+
index++
|
|
210
|
+
}
|
|
211
|
+
continue
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (quote !== 0) {
|
|
215
|
+
// inside a string an unescaped matching quote ends it, and a newline ends
|
|
216
|
+
// it as a parse error the browser sees the same way
|
|
217
|
+
if (code === CHAR_BACKSLASH) index++
|
|
218
|
+
else if (code === quote) quote = 0
|
|
219
|
+
else if (code === CHAR_LF || code === CHAR_CR || code === CHAR_FF) {
|
|
220
|
+
if (failure === null) failure = 'unterminated-string'
|
|
221
|
+
if (visitor.error !== undefined) visitor.error('unterminated-string', quoteStart)
|
|
222
|
+
quote = 0
|
|
223
|
+
// re-read the newline at top level, where it is ordinary whitespace
|
|
224
|
+
index--
|
|
225
|
+
}
|
|
226
|
+
continue
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (url) {
|
|
230
|
+
// the one function CSS does not tokenize: only an escape and the `)`
|
|
231
|
+
if (code === CHAR_BACKSLASH) index++
|
|
232
|
+
else if (code === CHAR_PAREN_CLOSE) {
|
|
233
|
+
url = false
|
|
234
|
+
depth--
|
|
235
|
+
}
|
|
236
|
+
continue
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// comments are lexical, so they open at any depth and outrank paren nesting
|
|
240
|
+
if (code === CHAR_SLASH && source.charCodeAt(index + 1) === CHAR_STAR) {
|
|
241
|
+
comment = true
|
|
242
|
+
commentStart = index
|
|
243
|
+
index++
|
|
244
|
+
continue
|
|
245
|
+
}
|
|
246
|
+
if (code === CHAR_STAR && source.charCodeAt(index + 1) === CHAR_SLASH) {
|
|
247
|
+
if (failure === null) failure = 'stray-comment-close'
|
|
248
|
+
if (visitor.error !== undefined) visitor.error('stray-comment-close', index)
|
|
249
|
+
index++
|
|
250
|
+
continue
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (depth > 0) {
|
|
254
|
+
// inside parens whitespace and colons are ordinary content
|
|
255
|
+
if (code === CHAR_BACKSLASH) index++
|
|
256
|
+
else if (code === CHAR_DOUBLE_QUOTE || code === CHAR_SINGLE_QUOTE) {
|
|
257
|
+
quote = code
|
|
258
|
+
quoteStart = index
|
|
259
|
+
} else if (code === CHAR_PAREN_OPEN) {
|
|
260
|
+
if (opensUrlToken(source, index)) url = true
|
|
261
|
+
depth++
|
|
262
|
+
} else if (code === CHAR_PAREN_CLOSE) depth--
|
|
263
|
+
continue
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (isWhitespace(code)) {
|
|
267
|
+
if (wordStart !== -1) {
|
|
268
|
+
if (visitor.word !== undefined) visitor.word(wordStart, index, lastColon !== -1)
|
|
269
|
+
if (lastColon !== -1) {
|
|
270
|
+
closeSegment(source, visitor, segmentStart, wordStart, !sawChain)
|
|
271
|
+
if (!visitor.chain(wordStart, lastColon)) return 'refused-chain'
|
|
272
|
+
sawChain = true
|
|
273
|
+
segmentStart = lastColon + 1
|
|
274
|
+
}
|
|
275
|
+
wordStart = -1
|
|
276
|
+
lastColon = -1
|
|
277
|
+
}
|
|
278
|
+
continue
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// any other top-level character starts or continues a word
|
|
282
|
+
if (wordStart === -1) wordStart = index
|
|
283
|
+
|
|
284
|
+
if (
|
|
285
|
+
code === CHAR_BRACE_OPEN ||
|
|
286
|
+
code === CHAR_BRACE_CLOSE ||
|
|
287
|
+
code === CHAR_SEMICOLON
|
|
288
|
+
) {
|
|
289
|
+
if (failure === null) failure = 'invalid-character'
|
|
290
|
+
if (visitor.error !== undefined) visitor.error('invalid-character', index)
|
|
291
|
+
} else if (code === CHAR_BACKSLASH) index++
|
|
292
|
+
else if (code === CHAR_DOUBLE_QUOTE || code === CHAR_SINGLE_QUOTE) {
|
|
293
|
+
quote = code
|
|
294
|
+
quoteStart = index
|
|
295
|
+
} else if (code === CHAR_PAREN_OPEN) {
|
|
296
|
+
if (opensUrlToken(source, index)) url = true
|
|
297
|
+
depth = 1
|
|
298
|
+
parenStart = index
|
|
299
|
+
} else if (code === CHAR_COLON) lastColon = index
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (comment) {
|
|
303
|
+
if (failure === null) failure = 'unterminated-comment'
|
|
304
|
+
if (visitor.error !== undefined) visitor.error('unterminated-comment', commentStart)
|
|
305
|
+
}
|
|
306
|
+
if (quote !== 0) {
|
|
307
|
+
if (failure === null) failure = 'unterminated-string'
|
|
308
|
+
if (visitor.error !== undefined) visitor.error('unterminated-string', quoteStart)
|
|
309
|
+
}
|
|
310
|
+
if (depth > 0) {
|
|
311
|
+
if (failure === null) failure = 'unterminated-function'
|
|
312
|
+
if (visitor.error !== undefined) visitor.error('unterminated-function', parenStart)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (wordStart !== -1) {
|
|
316
|
+
if (visitor.word !== undefined) visitor.word(wordStart, length, lastColon !== -1)
|
|
317
|
+
if (lastColon !== -1) {
|
|
318
|
+
closeSegment(source, visitor, segmentStart, wordStart, !sawChain)
|
|
319
|
+
if (!visitor.chain(wordStart, lastColon)) return 'refused-chain'
|
|
320
|
+
sawChain = true
|
|
321
|
+
segmentStart = lastColon + 1
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
closeSegment(source, visitor, segmentStart, length, !sawChain)
|
|
325
|
+
|
|
326
|
+
return failure
|
|
327
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// The two serializers over a ResolvedPayload: one representation, two targets.
|
|
2
|
+
//
|
|
3
|
+
// See plans/dom-tailwind-flat-values.md — "the resolver's mechanical contract".
|
|
4
|
+
// Web joins references as `var(--name)` so theme switches stay zero-re-render,
|
|
5
|
+
// and a color opacity suffix becomes `color-mix(in srgb, var(--name) NN%,
|
|
6
|
+
// transparent)`, which keeps opacity variants theme-reactive without generating
|
|
7
|
+
// per-alpha variables. Native looks references up through the granular theme
|
|
8
|
+
// subscription at evaluate time and alpha-composes the color right there.
|
|
9
|
+
//
|
|
10
|
+
// Both spellings match what core already emits: the `color-mix` form is
|
|
11
|
+
// `normalizeColor` on web, and the `rgba(r,g,b,a)` form is `normalizeColor` on
|
|
12
|
+
// native. Neither is imported — this package stays dependency-free.
|
|
13
|
+
//
|
|
14
|
+
// With a payload whose references are empty (every lookup missed), both
|
|
15
|
+
// functions return the input string byte for byte, which is what makes literal
|
|
16
|
+
// CSS provably untouched.
|
|
17
|
+
|
|
18
|
+
import type { PayloadReference, ResolvedPayload } from './resolvePayload'
|
|
19
|
+
|
|
20
|
+
export function serializePayloadWeb(
|
|
21
|
+
resolved: ResolvedPayload,
|
|
22
|
+
toVar: (name: string) => string
|
|
23
|
+
): string {
|
|
24
|
+
let out = ''
|
|
25
|
+
for (const segment of resolved.segments) {
|
|
26
|
+
if (typeof segment === 'string') {
|
|
27
|
+
out += segment
|
|
28
|
+
continue
|
|
29
|
+
}
|
|
30
|
+
const variable = toVar(segment.name)
|
|
31
|
+
out +=
|
|
32
|
+
segment.opacity === undefined
|
|
33
|
+
? variable
|
|
34
|
+
: `color-mix(in srgb, ${variable} ${segment.opacity}%, transparent)`
|
|
35
|
+
}
|
|
36
|
+
return out
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface SerializeNativeOptions {
|
|
40
|
+
/**
|
|
41
|
+
* `px-to-number` finalizes a single `<number>px` result to the bare number,
|
|
42
|
+
* which React Native requires for length props. Whether a property takes
|
|
43
|
+
* unitless numbers is property-table knowledge, so it stays with the caller.
|
|
44
|
+
*/
|
|
45
|
+
unit?: 'px-to-number'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function serializePayloadNative(
|
|
49
|
+
resolved: ResolvedPayload,
|
|
50
|
+
get: (name: string) => string | number,
|
|
51
|
+
opts?: SerializeNativeOptions
|
|
52
|
+
): string | number {
|
|
53
|
+
let out = ''
|
|
54
|
+
for (const segment of resolved.segments) {
|
|
55
|
+
if (typeof segment === 'string') {
|
|
56
|
+
out += segment
|
|
57
|
+
continue
|
|
58
|
+
}
|
|
59
|
+
const value = get(segment.name)
|
|
60
|
+
out += segment.opacity === undefined ? value : composeAlpha(value, segment)
|
|
61
|
+
}
|
|
62
|
+
return finalizeNumeric(out, opts?.unit)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Alpha-composes a resolved color so native matches what `color-mix(in srgb, C
|
|
67
|
+
* NN%, transparent)` produces on web: the suffix scales the color's existing
|
|
68
|
+
* alpha rather than replacing it.
|
|
69
|
+
*/
|
|
70
|
+
function composeAlpha(value: string | number, reference: PayloadReference): string {
|
|
71
|
+
const parsed = typeof value === 'string' ? readColor(value) : null
|
|
72
|
+
if (!parsed) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`cannot apply the /${reference.opacity} opacity suffix to "${reference.name}": ` +
|
|
75
|
+
`its value ${JSON.stringify(value)} is not a #hex, rgb(), or rgba() color`
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
const alpha = round4(parsed.a * (reference.opacity! / 100))
|
|
79
|
+
return `rgba(${parsed.r},${parsed.g},${parsed.b},${alpha})`
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface Rgba {
|
|
83
|
+
r: number
|
|
84
|
+
g: number
|
|
85
|
+
b: number
|
|
86
|
+
a: number
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function readColor(input: string): Rgba | null {
|
|
90
|
+
const color = input.trim()
|
|
91
|
+
if (color.charCodeAt(0) === 35) return readHex(color)
|
|
92
|
+
|
|
93
|
+
const open = color.indexOf('(')
|
|
94
|
+
if (open === -1 || color.charCodeAt(color.length - 1) !== 41) return null
|
|
95
|
+
const fn = color.slice(0, open).toLowerCase()
|
|
96
|
+
if (fn !== 'rgb' && fn !== 'rgba') return null
|
|
97
|
+
|
|
98
|
+
const parts = color.slice(open + 1, -1).split(',')
|
|
99
|
+
if (parts.length !== 3 && parts.length !== 4) return null
|
|
100
|
+
|
|
101
|
+
const channels: number[] = []
|
|
102
|
+
for (let index = 0; index < 3; index++) {
|
|
103
|
+
const channel = readNumber(parts[index])
|
|
104
|
+
// percentage channels would need a second scale; not supported here
|
|
105
|
+
if (channel === null) return null
|
|
106
|
+
channels.push(clamp(Math.round(channel), 0, 255))
|
|
107
|
+
}
|
|
108
|
+
let alpha = 1
|
|
109
|
+
if (parts.length === 4) {
|
|
110
|
+
const parsedAlpha = readNumber(parts[3])
|
|
111
|
+
if (parsedAlpha === null) return null
|
|
112
|
+
alpha = clamp(parsedAlpha, 0, 1)
|
|
113
|
+
}
|
|
114
|
+
return { r: channels[0], g: channels[1], b: channels[2], a: alpha }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function readHex(color: string): Rgba | null {
|
|
118
|
+
const digits = color.slice(1)
|
|
119
|
+
const size = digits.length
|
|
120
|
+
if (size !== 3 && size !== 4 && size !== 6 && size !== 8) return null
|
|
121
|
+
for (let index = 0; index < size; index++) {
|
|
122
|
+
const code = digits.charCodeAt(index)
|
|
123
|
+
const isHex =
|
|
124
|
+
(code >= 48 && code <= 57) ||
|
|
125
|
+
(code >= 97 && code <= 102) ||
|
|
126
|
+
(code >= 65 && code <= 70)
|
|
127
|
+
if (!isHex) return null
|
|
128
|
+
}
|
|
129
|
+
const short = size === 3 || size === 4
|
|
130
|
+
const pair = (position: number): number =>
|
|
131
|
+
short
|
|
132
|
+
? Number.parseInt(digits[position].repeat(2), 16)
|
|
133
|
+
: Number.parseInt(digits.slice(position * 2, position * 2 + 2), 16)
|
|
134
|
+
const hasAlpha = size === 4 || size === 8
|
|
135
|
+
return {
|
|
136
|
+
r: pair(0),
|
|
137
|
+
g: pair(1),
|
|
138
|
+
b: pair(2),
|
|
139
|
+
a: hasAlpha ? round4(pair(3) / 255) : 1,
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function readNumber(text: string): number | null {
|
|
144
|
+
const trimmed = text.trim()
|
|
145
|
+
if (!trimmed) return null
|
|
146
|
+
for (let index = 0; index < trimmed.length; index++) {
|
|
147
|
+
const code = trimmed.charCodeAt(index)
|
|
148
|
+
const ok =
|
|
149
|
+
(code >= 48 && code <= 57) ||
|
|
150
|
+
code === 46 || // .
|
|
151
|
+
((code === 45 || code === 43) && index === 0) // leading sign
|
|
152
|
+
if (!ok) return null
|
|
153
|
+
}
|
|
154
|
+
const value = Number(trimmed)
|
|
155
|
+
return Number.isFinite(value) ? value : null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function clamp(value: number, min: number, max: number): number {
|
|
159
|
+
return value < min ? min : value > max ? max : value
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** 8-bit alpha needs nowhere near this much precision; this just kills float noise */
|
|
163
|
+
function round4(value: number): number {
|
|
164
|
+
return Math.round(value * 10000) / 10000
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* React Native wants bare numbers for numeric props, so a result that is exactly
|
|
169
|
+
* one plain number becomes a number, and `<number>px` becomes one when the
|
|
170
|
+
* caller says this property's lengths are unitless.
|
|
171
|
+
*/
|
|
172
|
+
function finalizeNumeric(out: string, unit: 'px-to-number' | undefined): string | number {
|
|
173
|
+
let end = out.length
|
|
174
|
+
if (unit === 'px-to-number' && end > 2 && out.endsWith('px')) end -= 2
|
|
175
|
+
if (end === 0) return out
|
|
176
|
+
|
|
177
|
+
let index = 0
|
|
178
|
+
const first = out.charCodeAt(0)
|
|
179
|
+
if (first === 45 || first === 43) index++
|
|
180
|
+
let digits = 0
|
|
181
|
+
let dots = 0
|
|
182
|
+
for (; index < end; index++) {
|
|
183
|
+
const code = out.charCodeAt(index)
|
|
184
|
+
if (code >= 48 && code <= 57) {
|
|
185
|
+
digits++
|
|
186
|
+
continue
|
|
187
|
+
}
|
|
188
|
+
if (code === 46) {
|
|
189
|
+
dots++
|
|
190
|
+
if (dots > 1) return out
|
|
191
|
+
continue
|
|
192
|
+
}
|
|
193
|
+
return out
|
|
194
|
+
}
|
|
195
|
+
if (digits === 0) return out
|
|
196
|
+
|
|
197
|
+
const value = Number(out.slice(0, end))
|
|
198
|
+
return Number.isFinite(value) ? value : out
|
|
199
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type CoreStateModifierName =
|
|
2
|
+
| 'hover'
|
|
3
|
+
| 'press'
|
|
4
|
+
| 'focus'
|
|
5
|
+
| 'focus-visible'
|
|
6
|
+
| 'focus-within'
|
|
7
|
+
| 'disabled'
|
|
8
|
+
| 'enter'
|
|
9
|
+
| 'exit'
|
|
10
|
+
|
|
11
|
+
export const coreStateModifierNames: readonly CoreStateModifierName[] = Object.freeze([
|
|
12
|
+
'hover',
|
|
13
|
+
'press',
|
|
14
|
+
'focus',
|
|
15
|
+
'focus-visible',
|
|
16
|
+
'focus-within',
|
|
17
|
+
'disabled',
|
|
18
|
+
'enter',
|
|
19
|
+
'exit',
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Every alternate spelling of a core state modifier, and the one it means.
|
|
24
|
+
*
|
|
25
|
+
* This table is the only place an alias is written down. The web runtime used
|
|
26
|
+
* to re-map `pressed`, `starting` and `ending` inline while resolving a
|
|
27
|
+
* condition, which meant `parseValue` reported them as unregistered modifiers
|
|
28
|
+
* and the runtime styled them anyway. `stateVocabulary` in states.ts already
|
|
29
|
+
* calls all four aliases, so the two tables now agree by construction.
|
|
30
|
+
*/
|
|
31
|
+
export const modifierAliases: Readonly<Record<string, string>> = Object.freeze({
|
|
32
|
+
active: 'press',
|
|
33
|
+
pressed: 'press',
|
|
34
|
+
starting: 'enter',
|
|
35
|
+
ending: 'exit',
|
|
36
|
+
})
|
package/src/states.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// A1 — the shared STATE VOCABULARY + style-grammar modifiers.
|
|
2
|
+
//
|
|
3
|
+
// The canonical set of states a styled skin can respond to and how each maps to
|
|
4
|
+
// a Tailwind modifier. The registry generator reads this table as the single
|
|
5
|
+
// source of truth for stateful styles.
|
|
6
|
+
//
|
|
7
|
+
// Two tiers:
|
|
8
|
+
// - `pseudo`: a core interaction or lifecycle state applies at runtime.
|
|
9
|
+
// - `component`: the behavior toggles a web data/aria attribute and the skin
|
|
10
|
+
// styles through that selector. No core pseudo-prop — the Tailwind modifier is
|
|
11
|
+
// an attribute variant (`data-[…]` / `aria-…`).
|
|
12
|
+
|
|
13
|
+
export type StateTier = 'pseudo' | 'component'
|
|
14
|
+
|
|
15
|
+
export interface StateEntry {
|
|
16
|
+
/** canonical state name — the vocabulary word. */
|
|
17
|
+
state: string
|
|
18
|
+
/** how the state is applied: a core interaction state, or a DOM attribute. */
|
|
19
|
+
tier: StateTier
|
|
20
|
+
/** canonical Tailwind modifier (e.g. 'press', 'data-[state=open]'). */
|
|
21
|
+
modifier: string
|
|
22
|
+
/** the web attribute selector the behavior emits (tier === 'component'). */
|
|
23
|
+
selector?: string
|
|
24
|
+
/** additional modifier spellings that resolve to the canonical one. */
|
|
25
|
+
aliases?: readonly string[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The eight-state vocabulary (open/checked/pressed/highlighted/disabled/invalid/
|
|
29
|
+
// starting/ending). hover/focus/focus-visible/focus-within are interaction
|
|
30
|
+
// states outside the eight but compose the same way.
|
|
31
|
+
export const stateVocabulary: readonly StateEntry[] = [
|
|
32
|
+
// tier 1 — interaction / lifecycle. The state word can differ from the modifier word
|
|
33
|
+
// (pressed→press, starting→enter, ending→exit).
|
|
34
|
+
{
|
|
35
|
+
state: 'pressed',
|
|
36
|
+
tier: 'pseudo',
|
|
37
|
+
modifier: 'press',
|
|
38
|
+
aliases: ['active', 'pressed'],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
state: 'disabled',
|
|
42
|
+
tier: 'pseudo',
|
|
43
|
+
modifier: 'disabled',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
state: 'starting',
|
|
47
|
+
tier: 'pseudo',
|
|
48
|
+
modifier: 'enter',
|
|
49
|
+
aliases: ['starting'],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
state: 'ending',
|
|
53
|
+
tier: 'pseudo',
|
|
54
|
+
modifier: 'exit',
|
|
55
|
+
aliases: ['ending'],
|
|
56
|
+
},
|
|
57
|
+
// tier 2 — component / ARIA states (behavior-driven attributes).
|
|
58
|
+
{
|
|
59
|
+
state: 'open',
|
|
60
|
+
tier: 'component',
|
|
61
|
+
modifier: 'data-[state=open]',
|
|
62
|
+
selector: '[data-state="open"]',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
state: 'checked',
|
|
66
|
+
tier: 'component',
|
|
67
|
+
modifier: 'data-[state=checked]',
|
|
68
|
+
selector: '[data-state="checked"]',
|
|
69
|
+
aliases: ['data-[state=on]', 'aria-checked'],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
state: 'highlighted',
|
|
73
|
+
tier: 'component',
|
|
74
|
+
modifier: 'data-[highlighted]',
|
|
75
|
+
selector: '[data-highlighted]',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
// item selection (Select/RadioGroup items, ToggleGroup) — the behavior emits
|
|
79
|
+
// data-state="active"/"inactive"; distinct from `checked`. The bare word
|
|
80
|
+
// `active` is NOT an alias here (it stays an alias of `pressed`).
|
|
81
|
+
state: 'selected',
|
|
82
|
+
tier: 'component',
|
|
83
|
+
modifier: 'data-[state=active]',
|
|
84
|
+
selector: '[data-state="active"]',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
state: 'invalid',
|
|
88
|
+
tier: 'component',
|
|
89
|
+
modifier: 'aria-invalid',
|
|
90
|
+
selector: '[aria-invalid="true"]',
|
|
91
|
+
aliases: ['data-[invalid]'],
|
|
92
|
+
},
|
|
93
|
+
] as const
|
|
94
|
+
|
|
95
|
+
export type StateName = (typeof stateVocabulary)[number]['state']
|
|
96
|
+
|
|
97
|
+
export const stateNames: readonly string[] = Object.freeze(
|
|
98
|
+
stateVocabulary.map((entry) => entry.state)
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
// state name -> canonical Tailwind modifier.
|
|
102
|
+
export const stateToModifier: Readonly<Record<string, string>> = Object.freeze(
|
|
103
|
+
Object.fromEntries(stateVocabulary.map((entry) => [entry.state, entry.modifier]))
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
// any recognized modifier spelling (canonical or alias) -> canonical state name.
|
|
107
|
+
export const modifierToState: Readonly<Record<string, string>> = Object.freeze(
|
|
108
|
+
stateVocabulary.reduce<Record<string, string>>((out, entry) => {
|
|
109
|
+
out[entry.modifier] = entry.state
|
|
110
|
+
for (const alias of entry.aliases ?? []) out[alias] = entry.state
|
|
111
|
+
return out
|
|
112
|
+
}, {})
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
// state name -> web attribute selector (component-tier states only).
|
|
116
|
+
export const stateToSelector: Readonly<Record<string, string>> = Object.freeze(
|
|
117
|
+
Object.fromEntries(
|
|
118
|
+
stateVocabulary
|
|
119
|
+
.filter((entry) => entry.selector)
|
|
120
|
+
.map((entry) => [entry.state, entry.selector as string])
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
export const componentStateNames: readonly string[] = Object.freeze(
|
|
125
|
+
stateVocabulary
|
|
126
|
+
.filter((entry) => entry.tier === 'component')
|
|
127
|
+
.map((entry) => entry.state)
|
|
128
|
+
)
|