@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
package/src/candidate.ts
ADDED
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
import {
|
|
2
|
+
grammarEntries,
|
|
3
|
+
fontWeightNames,
|
|
4
|
+
modifierAliases,
|
|
5
|
+
prefixToEntries,
|
|
6
|
+
radiusCornerProps,
|
|
7
|
+
standaloneValueProps,
|
|
8
|
+
textAlignKeywords,
|
|
9
|
+
wholeClassConveniences,
|
|
10
|
+
wholeClassUtilities,
|
|
11
|
+
type GrammarEntry,
|
|
12
|
+
type TokenCategory,
|
|
13
|
+
} from './registry'
|
|
14
|
+
import { createModifierRegistry } from './modifierRegistry'
|
|
15
|
+
import { splitColorOpacitySuffix } from './resolvePayload'
|
|
16
|
+
import { getSafeAreaEdge } from './safeAreaVariables'
|
|
17
|
+
import type { ModifierKind, ModifierRegistryView } from './valueTypes'
|
|
18
|
+
|
|
19
|
+
type Names = readonly string[] | ReadonlySet<string> | Readonly<Record<string, unknown>>
|
|
20
|
+
|
|
21
|
+
export interface GrammarConfigView {
|
|
22
|
+
shorthands?: Readonly<Record<string, string>>
|
|
23
|
+
mediaNames?: Names
|
|
24
|
+
themeNames?: Names
|
|
25
|
+
platformNames?: Names
|
|
26
|
+
tokenNames?: Partial<Record<TokenCategory, Names>>
|
|
27
|
+
/**
|
|
28
|
+
* the media keys that measure a size, so `@key:` is a meaningful container
|
|
29
|
+
* query. derived by createGrammarConfigView when the media input carries
|
|
30
|
+
* query information; absent means UNKNOWN, and the modifier registry then
|
|
31
|
+
* refuses container claims with a diagnostic rather than over-claiming
|
|
32
|
+
*/
|
|
33
|
+
containerSizeNames?: readonly string[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ParsedCandidate {
|
|
37
|
+
candidate: string
|
|
38
|
+
base: string
|
|
39
|
+
modifiers: readonly string[]
|
|
40
|
+
negative: boolean
|
|
41
|
+
kind: 'utility' | 'dynamic'
|
|
42
|
+
valueKind: 'token' | 'arbitrary' | 'enum' | 'convenience'
|
|
43
|
+
properties?: Readonly<Record<string, string | number>>
|
|
44
|
+
entry?: GrammarEntry
|
|
45
|
+
prefix?: string
|
|
46
|
+
rawValue?: string
|
|
47
|
+
arbitrary?: boolean
|
|
48
|
+
convenience?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type CandidateClassification =
|
|
52
|
+
| { kind: 'tamagui'; parsed: ParsedCandidate }
|
|
53
|
+
| { kind: 'passthrough'; reason: string }
|
|
54
|
+
|
|
55
|
+
const sizingConveniences = new Set(['full', 'auto', 'screen', 'min', 'max', 'fit'])
|
|
56
|
+
const fontGenerics = new Set(['sans', 'serif', 'mono'])
|
|
57
|
+
const numericPattern = /^\d+(?:\.\d+)?$/
|
|
58
|
+
const extraPrefixes = [
|
|
59
|
+
'border-x',
|
|
60
|
+
'border-y',
|
|
61
|
+
'rounded-t',
|
|
62
|
+
'rounded-r',
|
|
63
|
+
'rounded-b',
|
|
64
|
+
'rounded-l',
|
|
65
|
+
]
|
|
66
|
+
const negativeTokenProps = new Set([
|
|
67
|
+
'margin',
|
|
68
|
+
'marginTop',
|
|
69
|
+
'marginRight',
|
|
70
|
+
'marginBottom',
|
|
71
|
+
'marginLeft',
|
|
72
|
+
'marginHorizontal',
|
|
73
|
+
'marginVertical',
|
|
74
|
+
'top',
|
|
75
|
+
'right',
|
|
76
|
+
'bottom',
|
|
77
|
+
'left',
|
|
78
|
+
'inset',
|
|
79
|
+
'x',
|
|
80
|
+
'y',
|
|
81
|
+
'letterSpacing',
|
|
82
|
+
])
|
|
83
|
+
const borderWidthKeywords = new Set(['thin', 'medium', 'thick'])
|
|
84
|
+
const ambiguousCssKeywords = new Set([
|
|
85
|
+
'auto',
|
|
86
|
+
'dashed',
|
|
87
|
+
'dotted',
|
|
88
|
+
'double',
|
|
89
|
+
'groove',
|
|
90
|
+
'hidden',
|
|
91
|
+
'inherit',
|
|
92
|
+
'initial',
|
|
93
|
+
'inset',
|
|
94
|
+
'none',
|
|
95
|
+
'outset',
|
|
96
|
+
'revert',
|
|
97
|
+
'revert-layer',
|
|
98
|
+
'ridge',
|
|
99
|
+
'solid',
|
|
100
|
+
'unset',
|
|
101
|
+
])
|
|
102
|
+
const cssLengthUnits =
|
|
103
|
+
'(?:px|em|rem|ex|ch|cap|ic|lh|rlh|vw|vh|vmin|vmax|svw|svh|svmin|svmax|lvw|lvh|lvmin|lvmax|dvw|dvh|dvmin|dvmax|cm|mm|q|in|pt|pc)'
|
|
104
|
+
const cssLengthPattern = new RegExp(`^-?(?:\\d+|\\d*\\.\\d+)${cssLengthUnits}$`, 'i')
|
|
105
|
+
|
|
106
|
+
function hasName(names: Names | undefined, name: string): boolean {
|
|
107
|
+
if (!names) return false
|
|
108
|
+
if (Array.isArray(names)) return names.includes(name)
|
|
109
|
+
if (names instanceof Set) return names.has(name)
|
|
110
|
+
return Object.prototype.hasOwnProperty.call(names, name)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function splitCandidate(candidate: string): { modifiers: string[]; base: string } | null {
|
|
114
|
+
const parts: string[] = []
|
|
115
|
+
let current = ''
|
|
116
|
+
let bracketDepth = 0
|
|
117
|
+
let escaped = false
|
|
118
|
+
for (const char of candidate) {
|
|
119
|
+
if (escaped) {
|
|
120
|
+
current += char
|
|
121
|
+
escaped = false
|
|
122
|
+
continue
|
|
123
|
+
}
|
|
124
|
+
if (char === '\\') {
|
|
125
|
+
current += char
|
|
126
|
+
escaped = true
|
|
127
|
+
continue
|
|
128
|
+
}
|
|
129
|
+
if (char === '[') bracketDepth++
|
|
130
|
+
if (char === ']') bracketDepth--
|
|
131
|
+
if (char === ':' && bracketDepth === 0) {
|
|
132
|
+
parts.push(current)
|
|
133
|
+
current = ''
|
|
134
|
+
} else {
|
|
135
|
+
current += char
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (!current || bracketDepth !== 0) return null
|
|
139
|
+
return { modifiers: parts, base: current }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const modifierRegistryCache = new WeakMap<GrammarConfigView, ModifierRegistryView>()
|
|
143
|
+
|
|
144
|
+
function getModifierRegistry(config: GrammarConfigView): ModifierRegistryView {
|
|
145
|
+
let registry = modifierRegistryCache.get(config)
|
|
146
|
+
if (!registry) {
|
|
147
|
+
registry = createModifierRegistry(config).registry
|
|
148
|
+
modifierRegistryCache.set(config, registry)
|
|
149
|
+
}
|
|
150
|
+
return registry
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function modifierKind(modifier: string, config: GrammarConfigView): ModifierKind | null {
|
|
154
|
+
const canonical = modifierAliases[modifier] || modifier
|
|
155
|
+
return getModifierRegistry(config).get(canonical) || null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function modifiersAreKnown(
|
|
159
|
+
modifiers: readonly string[],
|
|
160
|
+
config: GrammarConfigView
|
|
161
|
+
): boolean {
|
|
162
|
+
const seen = new Set<ModifierKind>()
|
|
163
|
+
for (const modifier of modifiers) {
|
|
164
|
+
const kind = modifierKind(modifier, config)
|
|
165
|
+
if (!kind || seen.has(kind)) return false
|
|
166
|
+
seen.add(kind)
|
|
167
|
+
}
|
|
168
|
+
return true
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function hasTokenDomain(config: GrammarConfigView, category: TokenCategory): boolean {
|
|
172
|
+
return config.tokenNames?.[category] !== undefined
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function hasTokenName(
|
|
176
|
+
config: GrammarConfigView,
|
|
177
|
+
category: TokenCategory,
|
|
178
|
+
name: string
|
|
179
|
+
): boolean {
|
|
180
|
+
return hasName(config.tokenNames?.[category], name)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function resolveEntries(
|
|
184
|
+
prefix: string,
|
|
185
|
+
config: GrammarConfigView
|
|
186
|
+
): readonly GrammarEntry[] {
|
|
187
|
+
const registered = prefixToEntries[prefix]
|
|
188
|
+
if (registered) return registered
|
|
189
|
+
if (prefix === 'border-x' || prefix === 'border-y') {
|
|
190
|
+
const props =
|
|
191
|
+
prefix === 'border-x'
|
|
192
|
+
? ['borderLeft', 'borderRight']
|
|
193
|
+
: ['borderTop', 'borderBottom']
|
|
194
|
+
return grammarEntries.filter((entry) =>
|
|
195
|
+
props.some((prop) => entry.prop === `${prop}Width` || entry.prop === `${prop}Color`)
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
if (prefix.startsWith('rounded-')) {
|
|
199
|
+
const props = radiusCornerProps[prefix.slice('rounded-'.length)]
|
|
200
|
+
return props ? grammarEntries.filter((entry) => props.includes(entry.prop)) : []
|
|
201
|
+
}
|
|
202
|
+
const expanded = config.shorthands?.[prefix]
|
|
203
|
+
if (!expanded) return []
|
|
204
|
+
return grammarEntries.filter((entry) => entry.prop === expanded)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function findPrefix(base: string, config: GrammarConfigView): string | null {
|
|
208
|
+
const prefixes = new Set(Object.keys(prefixToEntries))
|
|
209
|
+
for (const prefix of extraPrefixes) prefixes.add(prefix)
|
|
210
|
+
for (const shorthand in config.shorthands) prefixes.add(shorthand)
|
|
211
|
+
let found: string | null = null
|
|
212
|
+
for (const prefix of prefixes) {
|
|
213
|
+
if (base.startsWith(`${prefix}-`) && (!found || prefix.length > found.length)) {
|
|
214
|
+
found = prefix
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return found
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function arbitraryInner(rawValue: string): string | null {
|
|
221
|
+
if (rawValue.length <= 2 || rawValue[0] !== '[' || rawValue.at(-1) !== ']') {
|
|
222
|
+
return null
|
|
223
|
+
}
|
|
224
|
+
const inner = rawValue.slice(1, -1)
|
|
225
|
+
return arbitraryValueIsBalanced(decodeArbitrary(inner)) ? inner : null
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function arbitraryValueIsBalanced(value: string): boolean {
|
|
229
|
+
const opening = new Set(['(', '[', '{'])
|
|
230
|
+
const matching: Readonly<Record<string, string>> = { ')': '(', ']': '[', '}': '{' }
|
|
231
|
+
const stack: string[] = []
|
|
232
|
+
let quote = ''
|
|
233
|
+
let escaped = false
|
|
234
|
+
for (const char of value) {
|
|
235
|
+
if (escaped) {
|
|
236
|
+
escaped = false
|
|
237
|
+
continue
|
|
238
|
+
}
|
|
239
|
+
if (char === '\\') {
|
|
240
|
+
escaped = true
|
|
241
|
+
continue
|
|
242
|
+
}
|
|
243
|
+
if (quote) {
|
|
244
|
+
if (char === quote) quote = ''
|
|
245
|
+
continue
|
|
246
|
+
}
|
|
247
|
+
if (char === '"' || char === "'") {
|
|
248
|
+
quote = char
|
|
249
|
+
continue
|
|
250
|
+
}
|
|
251
|
+
if (opening.has(char)) {
|
|
252
|
+
stack.push(char)
|
|
253
|
+
continue
|
|
254
|
+
}
|
|
255
|
+
const expected = matching[char]
|
|
256
|
+
if (expected && stack.pop() !== expected) return false
|
|
257
|
+
}
|
|
258
|
+
return !escaped && !quote && stack.length === 0
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function fractionIsValid(value: string): boolean {
|
|
262
|
+
const fraction = /^(\d+)\/(\d+)$/.exec(value)
|
|
263
|
+
return !!fraction && Number(fraction[2]) !== 0
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function arbitraryBorderKind(value: string): 'width' | 'color' | null {
|
|
267
|
+
if (/^-?(?:\d+|\d*\.\d+)$/.test(value)) return 'width'
|
|
268
|
+
if (cssLengthPattern.test(value) || borderWidthKeywords.has(value)) return 'width'
|
|
269
|
+
if (/^(?:calc|min|max|clamp)\(/.test(value)) return 'width'
|
|
270
|
+
if (ambiguousCssKeywords.has(value) || value.startsWith('var(')) return null
|
|
271
|
+
if (
|
|
272
|
+
value.startsWith('#') ||
|
|
273
|
+
/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color|color-mix|light-dark)\(/.test(value) ||
|
|
274
|
+
/^[a-zA-Z][a-zA-Z0-9-]*$/.test(value)
|
|
275
|
+
) {
|
|
276
|
+
return 'color'
|
|
277
|
+
}
|
|
278
|
+
return null
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function tokenLookupName(category: TokenCategory, value: string): string {
|
|
282
|
+
if (category !== 'color') return value
|
|
283
|
+
const suffix = splitColorOpacitySuffix(value)
|
|
284
|
+
return suffix.kind === 'none' ? value : suffix.name
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function chooseEntry(
|
|
288
|
+
entries: readonly GrammarEntry[],
|
|
289
|
+
prefix: string,
|
|
290
|
+
rawValue: string,
|
|
291
|
+
negative: boolean,
|
|
292
|
+
config: GrammarConfigView
|
|
293
|
+
): {
|
|
294
|
+
entry: GrammarEntry
|
|
295
|
+
valueKind: ParsedCandidate['valueKind']
|
|
296
|
+
convenience?: string
|
|
297
|
+
} | null {
|
|
298
|
+
if (getSafeAreaEdge(rawValue)) {
|
|
299
|
+
const entry = entries.find(
|
|
300
|
+
({ tokenCategory }) =>
|
|
301
|
+
tokenCategory === 'space' ||
|
|
302
|
+
tokenCategory === 'size' ||
|
|
303
|
+
tokenCategory === 'radius' ||
|
|
304
|
+
tokenCategory === 'fontSize' ||
|
|
305
|
+
tokenCategory === 'lineHeight' ||
|
|
306
|
+
tokenCategory === 'letterSpacing'
|
|
307
|
+
)
|
|
308
|
+
if (entry) {
|
|
309
|
+
return { entry, valueKind: 'convenience', convenience: 'safe-area' }
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const arbitrary = arbitraryInner(rawValue)
|
|
314
|
+
if (arbitrary !== null) {
|
|
315
|
+
if (!arbitrary) return null
|
|
316
|
+
if (prefix.startsWith('border')) {
|
|
317
|
+
const width = entries.find((entry) => entry.prop.endsWith('Width'))
|
|
318
|
+
const color = entries.find((entry) => entry.prop.endsWith('Color'))
|
|
319
|
+
const kind = arbitraryBorderKind(decodeArbitrary(arbitrary))
|
|
320
|
+
if (!kind || !width || !color) return null
|
|
321
|
+
return {
|
|
322
|
+
entry: kind === 'width' ? width : color,
|
|
323
|
+
valueKind: 'arbitrary',
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (prefix === 'text') {
|
|
327
|
+
return {
|
|
328
|
+
entry: entries.find((entry) => entry.prop === 'fontSize')!,
|
|
329
|
+
valueKind: 'arbitrary',
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (prefix === 'font') {
|
|
333
|
+
return {
|
|
334
|
+
entry: entries.find((entry) => entry.prop === 'fontFamily')!,
|
|
335
|
+
valueKind: 'arbitrary',
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return { entry: entries[0], valueKind: 'arbitrary' }
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (prefix === 'text') {
|
|
342
|
+
const fontSize = entries.find((entry) => entry.prop === 'fontSize')
|
|
343
|
+
if (fontSize && hasTokenName(config, 'fontSize', rawValue)) {
|
|
344
|
+
return { entry: fontSize, valueKind: 'token' }
|
|
345
|
+
}
|
|
346
|
+
if (textAlignKeywords.has(rawValue)) {
|
|
347
|
+
return {
|
|
348
|
+
entry: entries.find((entry) => entry.prop === 'textAlign')!,
|
|
349
|
+
valueKind: 'enum',
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return null
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (prefix === 'font') {
|
|
356
|
+
const fontFamily = entries.find((entry) => entry.prop === 'fontFamily')
|
|
357
|
+
const fontWeight = entries.find((entry) => entry.prop === 'fontWeight')
|
|
358
|
+
if (!fontFamily) return null
|
|
359
|
+
const matchesFamily = hasTokenName(config, 'fontFamily', rawValue)
|
|
360
|
+
const matchesWeight = fontWeight && hasTokenName(config, 'fontWeight', rawValue)
|
|
361
|
+
// a name configured as both a family and a weight is ambiguous, like the
|
|
362
|
+
// border width/color rule above
|
|
363
|
+
if (matchesFamily && matchesWeight) return null
|
|
364
|
+
if (matchesFamily) {
|
|
365
|
+
return { entry: fontFamily, valueKind: 'token' }
|
|
366
|
+
}
|
|
367
|
+
if (matchesWeight) {
|
|
368
|
+
return { entry: fontWeight, valueKind: 'token' }
|
|
369
|
+
}
|
|
370
|
+
return fontGenerics.has(rawValue)
|
|
371
|
+
? { entry: fontFamily, valueKind: 'convenience', convenience: 'font-generic' }
|
|
372
|
+
: null
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (prefix.startsWith('border')) {
|
|
376
|
+
const width = entries.find((entry) => entry.prop.endsWith('Width'))
|
|
377
|
+
const color = entries.find((entry) => entry.prop.endsWith('Color'))
|
|
378
|
+
const token = negative ? `-${rawValue}` : rawValue
|
|
379
|
+
const matchesWidth = width && hasTokenName(config, 'space', token)
|
|
380
|
+
const colorName = tokenLookupName('color', rawValue)
|
|
381
|
+
const matchesColor = color && hasTokenName(config, 'color', colorName)
|
|
382
|
+
if (matchesWidth && matchesColor) return null
|
|
383
|
+
if (matchesWidth) {
|
|
384
|
+
return { entry: width, valueKind: 'token' }
|
|
385
|
+
}
|
|
386
|
+
if (matchesColor) {
|
|
387
|
+
return { entry: color, valueKind: 'token' }
|
|
388
|
+
}
|
|
389
|
+
return null
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
for (const entry of entries) {
|
|
393
|
+
if (entry.tokenCategory) {
|
|
394
|
+
const name = negative ? `-${rawValue}` : rawValue
|
|
395
|
+
const tokenName = tokenLookupName(entry.tokenCategory, name)
|
|
396
|
+
if (hasTokenName(config, entry.tokenCategory, tokenName)) {
|
|
397
|
+
return { entry, valueKind: 'token' }
|
|
398
|
+
}
|
|
399
|
+
if (
|
|
400
|
+
entry.tokenCategory === 'size' &&
|
|
401
|
+
(sizingConveniences.has(rawValue) || fractionIsValid(rawValue))
|
|
402
|
+
) {
|
|
403
|
+
return { entry, valueKind: 'convenience', convenience: 'sizing-keyword' }
|
|
404
|
+
}
|
|
405
|
+
if (entry.tokenCategory === 'zIndex' && numericPattern.test(rawValue)) {
|
|
406
|
+
return { entry, valueKind: 'convenience', convenience: 'integer' }
|
|
407
|
+
}
|
|
408
|
+
continue
|
|
409
|
+
}
|
|
410
|
+
if (prefix === 'opacity' || prefix === 'scale') {
|
|
411
|
+
if (numericPattern.test(rawValue)) {
|
|
412
|
+
return { entry, valueKind: 'convenience', convenience: 'percentage' }
|
|
413
|
+
}
|
|
414
|
+
continue
|
|
415
|
+
}
|
|
416
|
+
if (entry.prop === 'zIndex' && numericPattern.test(rawValue)) {
|
|
417
|
+
return { entry, valueKind: 'convenience', convenience: 'integer' }
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return null
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export function parseCandidate(
|
|
424
|
+
candidate: string,
|
|
425
|
+
config: GrammarConfigView
|
|
426
|
+
): ParsedCandidate | null {
|
|
427
|
+
const split = splitCandidate(candidate)
|
|
428
|
+
if (!split || !modifiersAreKnown(split.modifiers, config)) {
|
|
429
|
+
return null
|
|
430
|
+
}
|
|
431
|
+
const modifiers = split.modifiers.map(
|
|
432
|
+
(modifier) => modifierAliases[modifier] || modifier
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
const negative = split.base[0] === '-'
|
|
436
|
+
const core = negative ? split.base.slice(1) : split.base
|
|
437
|
+
const prefix = findPrefix(core, config)
|
|
438
|
+
let dynamic:
|
|
439
|
+
| {
|
|
440
|
+
prefix: string
|
|
441
|
+
rawValue: string
|
|
442
|
+
selected: NonNullable<ReturnType<typeof chooseEntry>>
|
|
443
|
+
}
|
|
444
|
+
| undefined
|
|
445
|
+
if (prefix) {
|
|
446
|
+
const rawValue = core.slice(prefix.length + 1)
|
|
447
|
+
if (rawValue) {
|
|
448
|
+
const entries = resolveEntries(prefix, config)
|
|
449
|
+
const selected = chooseEntry(entries, prefix, rawValue, negative, config)
|
|
450
|
+
if (
|
|
451
|
+
selected &&
|
|
452
|
+
(!negative ||
|
|
453
|
+
(selected.valueKind === 'token' && negativeTokenProps.has(selected.entry.prop)))
|
|
454
|
+
) {
|
|
455
|
+
dynamic = { prefix, rawValue, selected }
|
|
456
|
+
// An exact configured token owns its spelling before a reserved whole utility. Other
|
|
457
|
+
// dynamic forms defer to the whole utility and are used only when no whole form exists.
|
|
458
|
+
if (selected.valueKind === 'token') {
|
|
459
|
+
return {
|
|
460
|
+
candidate,
|
|
461
|
+
base: split.base,
|
|
462
|
+
modifiers,
|
|
463
|
+
negative,
|
|
464
|
+
kind: 'dynamic',
|
|
465
|
+
prefix,
|
|
466
|
+
rawValue,
|
|
467
|
+
arbitrary: arbitraryInner(rawValue) !== null,
|
|
468
|
+
entry: selected.entry,
|
|
469
|
+
valueKind: selected.valueKind,
|
|
470
|
+
convenience: selected.convenience,
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const direct = wholeClassUtilities[split.base]
|
|
478
|
+
if (!negative && direct) {
|
|
479
|
+
const convenience = wholeClassConveniences[split.base]
|
|
480
|
+
return {
|
|
481
|
+
candidate,
|
|
482
|
+
base: split.base,
|
|
483
|
+
modifiers,
|
|
484
|
+
kind: 'utility',
|
|
485
|
+
valueKind: convenience ? 'convenience' : 'enum',
|
|
486
|
+
properties: direct,
|
|
487
|
+
convenience,
|
|
488
|
+
negative: false,
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (dynamic) {
|
|
492
|
+
return {
|
|
493
|
+
candidate,
|
|
494
|
+
base: split.base,
|
|
495
|
+
modifiers,
|
|
496
|
+
negative,
|
|
497
|
+
kind: 'dynamic',
|
|
498
|
+
prefix: dynamic.prefix,
|
|
499
|
+
rawValue: dynamic.rawValue,
|
|
500
|
+
arbitrary: arbitraryInner(dynamic.rawValue) !== null,
|
|
501
|
+
entry: dynamic.selected.entry,
|
|
502
|
+
valueKind: dynamic.selected.valueKind,
|
|
503
|
+
convenience: dynamic.selected.convenience,
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return null
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export function classifyCandidate(
|
|
510
|
+
candidate: string,
|
|
511
|
+
config: GrammarConfigView
|
|
512
|
+
): CandidateClassification {
|
|
513
|
+
const parsed = parseCandidate(candidate, config)
|
|
514
|
+
return parsed
|
|
515
|
+
? { kind: 'tamagui', parsed }
|
|
516
|
+
: { kind: 'passthrough', reason: 'not in the configured Tamagui grammar' }
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export interface FormatCandidateInput {
|
|
520
|
+
prop: string
|
|
521
|
+
value: string
|
|
522
|
+
valueKind: ParsedCandidate['valueKind']
|
|
523
|
+
modifiers?: readonly string[]
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function tokenValidationConfig(
|
|
527
|
+
entry: GrammarEntry,
|
|
528
|
+
value: string,
|
|
529
|
+
config: GrammarConfigView | undefined
|
|
530
|
+
): GrammarConfigView {
|
|
531
|
+
const tokenNames: Partial<Record<TokenCategory, Names>> = {
|
|
532
|
+
...config?.tokenNames,
|
|
533
|
+
}
|
|
534
|
+
const category = entry.tokenCategory!
|
|
535
|
+
if (tokenNames[category] === undefined) {
|
|
536
|
+
tokenNames[category] = [tokenLookupName(category, value)]
|
|
537
|
+
}
|
|
538
|
+
for (const other of prefixToEntries[entry.prefix] || []) {
|
|
539
|
+
if (other.tokenCategory && tokenNames[other.tokenCategory] === undefined) {
|
|
540
|
+
tokenNames[other.tokenCategory] = []
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return { ...config, tokenNames }
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export function formatCandidate(
|
|
547
|
+
{ prop, value, valueKind, modifiers = [] }: FormatCandidateInput,
|
|
548
|
+
config?: GrammarConfigView
|
|
549
|
+
): string | null {
|
|
550
|
+
const entry = grammarEntries.find((candidate) => candidate.prop === prop)
|
|
551
|
+
if (!entry) return null
|
|
552
|
+
if (valueKind === 'arbitrary' && value === '') return null
|
|
553
|
+
if (!modifiersAreKnown(modifiers, config || {})) return null
|
|
554
|
+
const normalizedModifiers = modifiers.map(
|
|
555
|
+
(modifier) => modifierAliases[modifier] || modifier
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
if (valueKind === 'enum') {
|
|
559
|
+
const whole = standaloneValueProps[prop]?.[value]
|
|
560
|
+
if (whole) {
|
|
561
|
+
const candidate = normalizedModifiers.length
|
|
562
|
+
? `${normalizedModifiers.join(':')}:${whole}`
|
|
563
|
+
: whole
|
|
564
|
+
if (config) {
|
|
565
|
+
const parsed = parseCandidate(candidate, config)
|
|
566
|
+
if (!parsed?.properties || parsed.properties[prop] !== value) return null
|
|
567
|
+
}
|
|
568
|
+
return candidate
|
|
569
|
+
}
|
|
570
|
+
if (prop === 'fontWeight') {
|
|
571
|
+
const name = fontWeightNames[value]
|
|
572
|
+
if (!name) return null
|
|
573
|
+
const core = `font-${name}`
|
|
574
|
+
if (String(wholeClassUtilities[core]?.fontWeight) !== value) return null
|
|
575
|
+
const candidate = normalizedModifiers.length
|
|
576
|
+
? `${normalizedModifiers.join(':')}:${core}`
|
|
577
|
+
: core
|
|
578
|
+
if (config) {
|
|
579
|
+
const parsed = parseCandidate(candidate, config)
|
|
580
|
+
if (!parsed?.properties || String(parsed.properties.fontWeight) !== value) {
|
|
581
|
+
return null
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return candidate
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (!entry.prefix) return null
|
|
588
|
+
if (valueKind === 'token') {
|
|
589
|
+
if (!entry.tokenCategory) return null
|
|
590
|
+
const sourceDomainKnown = !!config && hasTokenDomain(config, entry.tokenCategory)
|
|
591
|
+
const lookupName = tokenLookupName(entry.tokenCategory, value)
|
|
592
|
+
if (sourceDomainKnown && !hasTokenName(config!, entry.tokenCategory, lookupName))
|
|
593
|
+
return null
|
|
594
|
+
const colliding = prefixToEntries[entry.prefix].filter(
|
|
595
|
+
(other) => other.prop !== prop && other.tokenCategory
|
|
596
|
+
)
|
|
597
|
+
if (colliding.length) {
|
|
598
|
+
if (!config || !sourceDomainKnown) return null
|
|
599
|
+
for (const other of colliding) {
|
|
600
|
+
if (!hasTokenDomain(config, other.tokenCategory!)) return null
|
|
601
|
+
if (hasTokenName(config, other.tokenCategory!, value)) return null
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
const formattedValue = valueKind === 'arbitrary' ? `[${encodeArbitrary(value)}]` : value
|
|
606
|
+
const core =
|
|
607
|
+
formattedValue[0] === '-' && formattedValue[1] !== '['
|
|
608
|
+
? `-${entry.prefix}-${formattedValue.slice(1)}`
|
|
609
|
+
: formattedValue
|
|
610
|
+
? `${entry.prefix}-${formattedValue}`
|
|
611
|
+
: entry.prefix
|
|
612
|
+
const candidate = normalizedModifiers.length
|
|
613
|
+
? `${normalizedModifiers.join(':')}:${core}`
|
|
614
|
+
: core
|
|
615
|
+
const whole = wholeClassUtilities[core]
|
|
616
|
+
if (whole) {
|
|
617
|
+
if (valueKind === 'token') {
|
|
618
|
+
if (!config || !hasTokenDomain(config, entry.tokenCategory!)) return null
|
|
619
|
+
} else if (config) {
|
|
620
|
+
const parsed = parseCandidate(candidate, config)
|
|
621
|
+
if (parsed?.kind === 'utility') {
|
|
622
|
+
return Object.prototype.hasOwnProperty.call(parsed.properties, prop) &&
|
|
623
|
+
String(parsed.properties?.[prop]) === value
|
|
624
|
+
? candidate
|
|
625
|
+
: null
|
|
626
|
+
}
|
|
627
|
+
return parsed?.entry?.prop === prop && parsed.valueKind === valueKind
|
|
628
|
+
? candidate
|
|
629
|
+
: null
|
|
630
|
+
} else if (
|
|
631
|
+
Object.prototype.hasOwnProperty.call(whole, prop) &&
|
|
632
|
+
String(whole[prop]) === value
|
|
633
|
+
) {
|
|
634
|
+
return candidate
|
|
635
|
+
} else {
|
|
636
|
+
return null
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (valueKind === 'token') {
|
|
640
|
+
if (
|
|
641
|
+
!hasTokenDomain(config || {}, entry.tokenCategory!) &&
|
|
642
|
+
parseCandidate(candidate, config || {})
|
|
643
|
+
) {
|
|
644
|
+
return null
|
|
645
|
+
}
|
|
646
|
+
const parsed = parseCandidate(candidate, tokenValidationConfig(entry, value, config))
|
|
647
|
+
const parsedValue = parsed?.rawValue
|
|
648
|
+
? `${parsed.negative ? '-' : ''}${parsed.rawValue}`
|
|
649
|
+
: null
|
|
650
|
+
if (
|
|
651
|
+
parsed?.kind !== 'dynamic' ||
|
|
652
|
+
parsed.entry?.prop !== prop ||
|
|
653
|
+
parsed.valueKind !== 'token' ||
|
|
654
|
+
parsedValue !== value
|
|
655
|
+
) {
|
|
656
|
+
return null
|
|
657
|
+
}
|
|
658
|
+
return candidate
|
|
659
|
+
}
|
|
660
|
+
const parsed = parseCandidate(candidate, config || {})
|
|
661
|
+
if (!parsed || parsed.entry?.prop !== prop || parsed.valueKind !== valueKind)
|
|
662
|
+
return null
|
|
663
|
+
return candidate
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
export function encodeArbitrary(value: string): string {
|
|
667
|
+
let encoded = ''
|
|
668
|
+
for (const char of value) {
|
|
669
|
+
if (char === '\\' || char === '_' || char === '[' || char === ']') {
|
|
670
|
+
encoded += `\\${char}`
|
|
671
|
+
} else if (/\s/.test(char)) {
|
|
672
|
+
encoded += '_'
|
|
673
|
+
} else {
|
|
674
|
+
encoded += char
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return encoded
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export function decodeArbitrary(value: string): string {
|
|
681
|
+
let decoded = ''
|
|
682
|
+
for (let index = 0; index < value.length; index++) {
|
|
683
|
+
const char = value[index]
|
|
684
|
+
if (char === '\\' && index + 1 < value.length) {
|
|
685
|
+
decoded += value[++index]
|
|
686
|
+
} else {
|
|
687
|
+
decoded += char === '_' ? ' ' : char
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return decoded
|
|
691
|
+
}
|