@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,735 @@
|
|
|
1
|
+
import type { GrammarConfigView } from './candidate'
|
|
2
|
+
import {
|
|
3
|
+
resolveCandidateTarget,
|
|
4
|
+
type CandidateContribution,
|
|
5
|
+
type CandidatePropertyMismatch,
|
|
6
|
+
} from './candidateTarget'
|
|
7
|
+
import { createGrammarConfigView, type GrammarSourceConfig } from './config'
|
|
8
|
+
import { splitGeometricShorthandValue } from './geometricShorthand'
|
|
9
|
+
import { formatParsedValue } from './mergeFlatValues'
|
|
10
|
+
import { validatePayloadShape, type PayloadShapeDiagnostic } from './payloadShape'
|
|
11
|
+
import { legacyPartComposite, programEligibility } from './programEligibility'
|
|
12
|
+
import {
|
|
13
|
+
resolvePayload,
|
|
14
|
+
type PayloadReference,
|
|
15
|
+
type PayloadResolveErrorCode,
|
|
16
|
+
type ReferenceKind,
|
|
17
|
+
} from './resolvePayload'
|
|
18
|
+
import {
|
|
19
|
+
fontWeightNames,
|
|
20
|
+
grammarEntries,
|
|
21
|
+
standaloneValueProps,
|
|
22
|
+
type TokenCategory,
|
|
23
|
+
} from './registry'
|
|
24
|
+
import {
|
|
25
|
+
parseValue,
|
|
26
|
+
parseValueWithSourceSpans,
|
|
27
|
+
type ValueSourceSpan,
|
|
28
|
+
} from './valueParser'
|
|
29
|
+
import type {
|
|
30
|
+
ModifierRegistryView,
|
|
31
|
+
ParsedValue,
|
|
32
|
+
ValueParseError,
|
|
33
|
+
ValueParseErrorCode,
|
|
34
|
+
} from './valueTypes'
|
|
35
|
+
import { v6RemovedThemeNames, v6ThemeNameReplacements } from './v6ThemeNames'
|
|
36
|
+
|
|
37
|
+
type Names = readonly string[] | ReadonlySet<string> | Readonly<Record<string, unknown>>
|
|
38
|
+
|
|
39
|
+
export type CandidatePropertyVocabulary = ReadonlyMap<
|
|
40
|
+
string,
|
|
41
|
+
readonly CandidateContribution[]
|
|
42
|
+
>
|
|
43
|
+
|
|
44
|
+
export type StyleValueDiagnosticCode =
|
|
45
|
+
| ValueParseErrorCode
|
|
46
|
+
| PayloadResolveErrorCode
|
|
47
|
+
| CandidatePropertyMismatch['code']
|
|
48
|
+
| PayloadShapeDiagnostic['code']
|
|
49
|
+
| 'legacy-part-conditional'
|
|
50
|
+
| 'v6-theme-name-replaced'
|
|
51
|
+
| 'v6-theme-name-removed'
|
|
52
|
+
|
|
53
|
+
export interface StyleValueDiagnostic {
|
|
54
|
+
code: StyleValueDiagnosticCode
|
|
55
|
+
/** kept for compatibility; always equals `start` */
|
|
56
|
+
index: number
|
|
57
|
+
/** character span within the authored value the diagnostic points at */
|
|
58
|
+
start: number
|
|
59
|
+
end: number
|
|
60
|
+
message: string
|
|
61
|
+
candidate?: string
|
|
62
|
+
property?: string
|
|
63
|
+
contributedProperties?: readonly string[]
|
|
64
|
+
replacement?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface DiagnoseStyleValueOptions {
|
|
68
|
+
config: GrammarConfigView
|
|
69
|
+
registry: ModifierRegistryView
|
|
70
|
+
candidates?: CandidatePropertyVocabulary
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SerializedGrammarSourceConfig {
|
|
74
|
+
shorthands?: GrammarSourceConfig['shorthands']
|
|
75
|
+
media?: GrammarSourceConfig['media']
|
|
76
|
+
themes?: GrammarSourceConfig['themes']
|
|
77
|
+
tokens?: GrammarSourceConfig['tokensParsed']
|
|
78
|
+
fonts?: GrammarSourceConfig['fontsParsed']
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface SerializedGrammarConfigMetadata {
|
|
82
|
+
themeFields: 'values-only'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type StyleValueCompletionKind = 'configured' | 'keyword' | 'modifier'
|
|
86
|
+
|
|
87
|
+
export interface StyleValueCompletion {
|
|
88
|
+
value: string
|
|
89
|
+
kind: StyleValueCompletionKind
|
|
90
|
+
insertText?: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface StyleValueCursorCompletions {
|
|
94
|
+
replaceStart: number
|
|
95
|
+
replaceLength: number
|
|
96
|
+
completions: readonly StyleValueCompletion[]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type CanonicalStyleValueResult =
|
|
100
|
+
| { ok: true; value: string; parsed: ParsedValue }
|
|
101
|
+
| { ok: false; errors: readonly ValueParseError[] }
|
|
102
|
+
|
|
103
|
+
/** Parses and prints the canonical surface spelling for the same value IR. */
|
|
104
|
+
export function canonicalizeStyleValue(
|
|
105
|
+
input: string,
|
|
106
|
+
registry: ModifierRegistryView
|
|
107
|
+
): CanonicalStyleValueResult {
|
|
108
|
+
const parsed = parseValue(input, registry)
|
|
109
|
+
if (!parsed.ok) return parsed
|
|
110
|
+
return {
|
|
111
|
+
ok: true,
|
|
112
|
+
value: formatParsedValue(parsed.value),
|
|
113
|
+
parsed: parsed.value,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function forEachName(names: Names | undefined, visit: (name: string) => void): void {
|
|
118
|
+
if (!names) return
|
|
119
|
+
if (Array.isArray(names)) {
|
|
120
|
+
for (const name of names) visit(name)
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
if (names instanceof Set) {
|
|
124
|
+
for (const name of names) visit(name)
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
for (const name in names as Readonly<Record<string, unknown>>) visit(name)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Projects the config vocabulary into the properties each name can target.
|
|
132
|
+
*
|
|
133
|
+
* Tooling consumes this projection rather than inferring from spelling. A name
|
|
134
|
+
* shared by categories keeps every contribution, and the shared target
|
|
135
|
+
* validator selects the authored property or reports the mismatch.
|
|
136
|
+
*/
|
|
137
|
+
export function createCandidatePropertyVocabulary(
|
|
138
|
+
config: GrammarConfigView
|
|
139
|
+
): CandidatePropertyVocabulary {
|
|
140
|
+
const byName = new Map<string, CandidateContribution[]>()
|
|
141
|
+
const entriesByCategory = new Map<TokenCategory, CandidateContribution[]>()
|
|
142
|
+
|
|
143
|
+
for (const entry of grammarEntries) {
|
|
144
|
+
if (!entry.tokenCategory) continue
|
|
145
|
+
const contributions = entriesByCategory.get(entry.tokenCategory) || []
|
|
146
|
+
contributions.push({ property: entry.prop, tokenCategory: entry.tokenCategory })
|
|
147
|
+
entriesByCategory.set(entry.tokenCategory, contributions)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
for (const [category, contributions] of entriesByCategory) {
|
|
151
|
+
forEachName(config.tokenNames?.[category], (name) => {
|
|
152
|
+
const existing = byName.get(name) || []
|
|
153
|
+
for (const contribution of contributions) {
|
|
154
|
+
if (!existing.some((item) => item.property === contribution.property)) {
|
|
155
|
+
existing.push(contribution)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
byName.set(name, existing)
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return byName
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Projects the JSON config emitted by Tamagui's compiler into the same grammar
|
|
167
|
+
* view the runtime creates from its live config.
|
|
168
|
+
*/
|
|
169
|
+
export function createGrammarConfigViewFromSerializedConfig(
|
|
170
|
+
config: SerializedGrammarSourceConfig,
|
|
171
|
+
metadata?: unknown
|
|
172
|
+
): GrammarConfigView {
|
|
173
|
+
const isVersioned =
|
|
174
|
+
typeof metadata === 'object' &&
|
|
175
|
+
metadata !== null &&
|
|
176
|
+
(metadata as { themeFields?: unknown }).themeFields === 'values-only'
|
|
177
|
+
if (metadata !== undefined && !isVersioned) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
'@tamagui/style-grammar: unsupported serialized config themeFields format'
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const themes: Record<string, Readonly<Record<string, unknown>>> = {}
|
|
184
|
+
for (const themeName in config.themes) {
|
|
185
|
+
const serializedTheme = config.themes[themeName]
|
|
186
|
+
if (!serializedTheme || typeof serializedTheme !== 'object') continue
|
|
187
|
+
const runtimeTheme: Record<string, unknown> = {}
|
|
188
|
+
for (const key in serializedTheme) {
|
|
189
|
+
// Unversioned compiler artifacts injected `id` into the theme value
|
|
190
|
+
// namespace and overwrote any user value with that name. Keep this exact
|
|
191
|
+
// legacy cleanup only until stale artifacts have been regenerated.
|
|
192
|
+
if (isVersioned || key !== 'id') {
|
|
193
|
+
runtimeTheme[key] = (serializedTheme as Readonly<Record<string, unknown>>)[key]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
themes[themeName] = runtimeTheme
|
|
197
|
+
}
|
|
198
|
+
return createGrammarConfigView({
|
|
199
|
+
shorthands: config.shorthands,
|
|
200
|
+
media: config.media,
|
|
201
|
+
themes,
|
|
202
|
+
tokensParsed: config.tokens,
|
|
203
|
+
fontsParsed: config.fonts,
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const removedThemeNames: ReadonlySet<string> = new Set(v6RemovedThemeNames)
|
|
208
|
+
const grammarProperties: ReadonlySet<string> = new Set(
|
|
209
|
+
grammarEntries.map((entry) => entry.prop)
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
const categoryReferenceKind: Readonly<Record<TokenCategory, ReferenceKind>> = {
|
|
213
|
+
color: 'color',
|
|
214
|
+
space: 'length',
|
|
215
|
+
size: 'length',
|
|
216
|
+
radius: 'length',
|
|
217
|
+
zIndex: 'number',
|
|
218
|
+
fontFamily: 'other',
|
|
219
|
+
fontSize: 'length',
|
|
220
|
+
fontWeight: 'number',
|
|
221
|
+
lineHeight: 'length',
|
|
222
|
+
letterSpacing: 'length',
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The reference kind a candidate resolves as for one target property: the
|
|
227
|
+
* category it binds the target through, else color if any contribution is a
|
|
228
|
+
* color (so opacity suffixes keep their authored meaning), else the first.
|
|
229
|
+
*/
|
|
230
|
+
export function referenceKindFor(
|
|
231
|
+
contributions: readonly CandidateContribution[],
|
|
232
|
+
targetProperty: string
|
|
233
|
+
): ReferenceKind {
|
|
234
|
+
let fallback: ReferenceKind | undefined
|
|
235
|
+
for (const contribution of contributions) {
|
|
236
|
+
const kind = contribution.tokenCategory
|
|
237
|
+
? categoryReferenceKind[contribution.tokenCategory]
|
|
238
|
+
: 'other'
|
|
239
|
+
if (contribution.property === targetProperty) return kind
|
|
240
|
+
if (fallback !== 'color') fallback = kind
|
|
241
|
+
}
|
|
242
|
+
return fallback ?? 'other'
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function parseErrorSpan(
|
|
246
|
+
input: string,
|
|
247
|
+
error: ValueParseError
|
|
248
|
+
): { start: number; end: number } {
|
|
249
|
+
const length = input.length
|
|
250
|
+
if (error.code === 'unregistered-modifier' && error.modifier) {
|
|
251
|
+
return { start: error.index, end: error.index + error.modifier.length }
|
|
252
|
+
}
|
|
253
|
+
if (
|
|
254
|
+
error.code === 'unterminated-string' ||
|
|
255
|
+
error.code === 'unterminated-function' ||
|
|
256
|
+
error.code === 'unterminated-comment'
|
|
257
|
+
) {
|
|
258
|
+
// an unclosed delimiter owns everything after it, so the squiggle does too
|
|
259
|
+
return { start: Math.max(0, Math.min(error.index, length - 1)), end: length }
|
|
260
|
+
}
|
|
261
|
+
const start = Math.max(0, Math.min(error.index, length - 1))
|
|
262
|
+
// `*/` is two characters; every other single-character code is one
|
|
263
|
+
const width = error.code === 'stray-comment-close' ? 2 : 1
|
|
264
|
+
return { start, end: Math.min(length, start + width) }
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** index just past the candidate and any attached `/suffix` run */
|
|
268
|
+
function candidateEndWithSuffix(payload: string, end: number): number {
|
|
269
|
+
if (payload.charCodeAt(end) !== 47) return end
|
|
270
|
+
let cursor = end + 1
|
|
271
|
+
while (cursor < payload.length) {
|
|
272
|
+
const code = payload.charCodeAt(cursor)
|
|
273
|
+
// component-value boundary, matching the resolver's isBoundary
|
|
274
|
+
if (code === 32 || code === 9 || code === 10 || code === 13 || code === 12) break
|
|
275
|
+
if (code === 44 || code === 40 || code === 41) break
|
|
276
|
+
cursor++
|
|
277
|
+
}
|
|
278
|
+
return cursor
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
type CandidateSighting = {
|
|
282
|
+
start: number
|
|
283
|
+
end: number
|
|
284
|
+
name: string
|
|
285
|
+
resolved: PayloadReference | undefined
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Returns the diagnostics every static frontend must agree on for one authored
|
|
290
|
+
* style value. Source tools locate the value; this function owns its meaning.
|
|
291
|
+
*/
|
|
292
|
+
export function diagnoseStyleValue(
|
|
293
|
+
property: string,
|
|
294
|
+
input: string,
|
|
295
|
+
options: DiagnoseStyleValueOptions
|
|
296
|
+
): readonly StyleValueDiagnostic[] {
|
|
297
|
+
const { result, spans } = parseValueWithSourceSpans(input, options.registry)
|
|
298
|
+
if (!result.ok) {
|
|
299
|
+
return result.errors.map((error) => {
|
|
300
|
+
const span = parseErrorSpan(input, error)
|
|
301
|
+
return {
|
|
302
|
+
code: error.code,
|
|
303
|
+
index: span.start,
|
|
304
|
+
...span,
|
|
305
|
+
message: error.message,
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const targetProperty = options.config.shorthands?.[property] || property
|
|
311
|
+
const targetIsKnown = grammarProperties.has(targetProperty)
|
|
312
|
+
const candidates =
|
|
313
|
+
options.candidates || createCandidatePropertyVocabulary(options.config)
|
|
314
|
+
const diagnostics: StyleValueDiagnostic[] = []
|
|
315
|
+
const diagnosed = new Set<string>()
|
|
316
|
+
|
|
317
|
+
const push = (key: string, diagnostic: Omit<StyleValueDiagnostic, 'index'>): void => {
|
|
318
|
+
if (diagnosed.has(key)) return
|
|
319
|
+
diagnosed.add(key)
|
|
320
|
+
diagnostics.push({ index: diagnostic.start, ...diagnostic })
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const diagnoseSegment = (payload: string, offset: number): void => {
|
|
324
|
+
const sightings: CandidateSighting[] = []
|
|
325
|
+
const resolved = resolvePayload(payload, {
|
|
326
|
+
lookup(name) {
|
|
327
|
+
const contributions = candidates.get(name)
|
|
328
|
+
if (!contributions) return undefined
|
|
329
|
+
return { name, kind: referenceKindFor(contributions, targetProperty) }
|
|
330
|
+
},
|
|
331
|
+
onCandidate(start, end, name, reference) {
|
|
332
|
+
sightings.push({ start, end, name, resolved: reference })
|
|
333
|
+
if (reference) return
|
|
334
|
+
|
|
335
|
+
const replacement =
|
|
336
|
+
v6ThemeNameReplacements[name as keyof typeof v6ThemeNameReplacements]
|
|
337
|
+
if (replacement) {
|
|
338
|
+
push(`v6-theme-name-replaced:${name}`, {
|
|
339
|
+
code: 'v6-theme-name-replaced',
|
|
340
|
+
start: offset + start,
|
|
341
|
+
end: offset + end,
|
|
342
|
+
candidate: name,
|
|
343
|
+
replacement,
|
|
344
|
+
message: `"${name}" is not a v6 built-in name; use "${replacement}"`,
|
|
345
|
+
})
|
|
346
|
+
} else if (removedThemeNames.has(name)) {
|
|
347
|
+
push(`v6-theme-name-removed:${name}`, {
|
|
348
|
+
code: 'v6-theme-name-removed',
|
|
349
|
+
start: offset + start,
|
|
350
|
+
end: offset + end,
|
|
351
|
+
candidate: name,
|
|
352
|
+
message: `"${name}" was removed from the v6 built-in theme vocabulary`,
|
|
353
|
+
})
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
if (targetIsKnown) {
|
|
359
|
+
for (const error of resolved.errors) {
|
|
360
|
+
// an opacity attempt on an unresolved ident is legal CSS slash syntax
|
|
361
|
+
// (`grid-area: a/2`), so only resolved candidates report
|
|
362
|
+
const sighting = sightings.find((entry) => entry.start === error.index)
|
|
363
|
+
if (!sighting?.resolved) continue
|
|
364
|
+
push(`${error.code}:${error.name}:${error.opacity}`, {
|
|
365
|
+
code: error.code,
|
|
366
|
+
start: offset + error.index,
|
|
367
|
+
end: offset + candidateEndWithSuffix(payload, sighting.end),
|
|
368
|
+
candidate: error.name,
|
|
369
|
+
message: error.message,
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const candidate =
|
|
375
|
+
resolved.segments.length === 1 && typeof resolved.segments[0] !== 'string'
|
|
376
|
+
? resolved.segments[0].name
|
|
377
|
+
: null
|
|
378
|
+
if (candidate === null || !targetIsKnown) return
|
|
379
|
+
const contributions = candidates.get(candidate)
|
|
380
|
+
if (!contributions) return
|
|
381
|
+
|
|
382
|
+
const target = resolveCandidateTarget(targetProperty, candidate, contributions)
|
|
383
|
+
if (target.ok) return
|
|
384
|
+
const sighting = sightings.find((entry) => entry.name === candidate && entry.resolved)
|
|
385
|
+
push(`${target.diagnostic.code}:${candidate}:${targetProperty}`, {
|
|
386
|
+
...target.diagnostic,
|
|
387
|
+
start: offset + (sighting?.start ?? 0),
|
|
388
|
+
end: offset + (sighting?.end ?? payload.length),
|
|
389
|
+
})
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
for (const span of spans) {
|
|
393
|
+
if (span.kind !== 'base' && span.kind !== 'payload') continue
|
|
394
|
+
if (span.start >= span.end) continue
|
|
395
|
+
diagnoseSegment(input.slice(span.start, span.end), span.start)
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return diagnostics
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* The modifier chain whose final colon sits directly before `start`, outermost
|
|
403
|
+
* first. Shared by cursor completions and value annotations.
|
|
404
|
+
*/
|
|
405
|
+
export function modifierChainBefore(
|
|
406
|
+
input: string,
|
|
407
|
+
spans: readonly ValueSourceSpan[],
|
|
408
|
+
start: number
|
|
409
|
+
): readonly string[] {
|
|
410
|
+
const byEnd = new Map<number, ValueSourceSpan>()
|
|
411
|
+
for (const span of spans) {
|
|
412
|
+
if (span.kind === 'modifier') byEnd.set(span.end, span)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const reversed: string[] = []
|
|
416
|
+
let colon = start - 1
|
|
417
|
+
while (colon >= 0 && input.charCodeAt(colon) === 58) {
|
|
418
|
+
const span = byEnd.get(colon)
|
|
419
|
+
if (!span) break
|
|
420
|
+
reversed.push(input.slice(span.start, span.end))
|
|
421
|
+
colon = span.start - 1
|
|
422
|
+
}
|
|
423
|
+
reversed.reverse()
|
|
424
|
+
return reversed
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Every prop name static tooling treats as a flat style value site: grammar
|
|
429
|
+
* properties, legacy part props, and both sides of every configured shorthand.
|
|
430
|
+
*/
|
|
431
|
+
export function createStylePropSet(config: GrammarConfigView): ReadonlySet<string> {
|
|
432
|
+
const styleProps = new Set([
|
|
433
|
+
...grammarEntries.map((entry) => entry.prop),
|
|
434
|
+
...Object.keys(legacyPartComposite),
|
|
435
|
+
])
|
|
436
|
+
for (const shorthand in config.shorthands) {
|
|
437
|
+
styleProps.add(shorthand)
|
|
438
|
+
styleProps.add(config.shorthands[shorthand])
|
|
439
|
+
}
|
|
440
|
+
return styleProps
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** the span of `payload` within `input`, else the whole value */
|
|
444
|
+
function payloadSpan(input: string, payload: string): { start: number; end: number } {
|
|
445
|
+
const at = input.indexOf(payload)
|
|
446
|
+
return at === -1
|
|
447
|
+
? { start: 0, end: input.length }
|
|
448
|
+
: { start: at, end: at + payload.length }
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* The complete static verdict for one authored value: everything
|
|
453
|
+
* `diagnoseStyleValue` reports, plus the program-level rules — part props take
|
|
454
|
+
* no conditionals, geometric shorthands split before per-slot target checks,
|
|
455
|
+
* and single-value longhands take one component per slot. Every static
|
|
456
|
+
* frontend (editor plugin, checker, lint rule) reports exactly this list.
|
|
457
|
+
*/
|
|
458
|
+
export function diagnoseStyleValueProgram(
|
|
459
|
+
property: string,
|
|
460
|
+
input: string,
|
|
461
|
+
options: DiagnoseStyleValueOptions
|
|
462
|
+
): readonly StyleValueDiagnostic[] {
|
|
463
|
+
const candidates =
|
|
464
|
+
options.candidates || createCandidatePropertyVocabulary(options.config)
|
|
465
|
+
const scoped = { ...options, candidates }
|
|
466
|
+
const diagnostics = diagnoseStyleValue(property, input, scoped)
|
|
467
|
+
if (diagnostics.length > 0) return diagnostics
|
|
468
|
+
|
|
469
|
+
const parsed = parseValue(input, options.registry)
|
|
470
|
+
if (!parsed.ok) return diagnostics
|
|
471
|
+
|
|
472
|
+
const targetProperty = options.config.shorthands?.[property] || property
|
|
473
|
+
if (
|
|
474
|
+
parsed.value.clauses.length > 0 &&
|
|
475
|
+
programEligibility(targetProperty) === 'legacy-part'
|
|
476
|
+
) {
|
|
477
|
+
return [
|
|
478
|
+
{
|
|
479
|
+
code: 'legacy-part-conditional',
|
|
480
|
+
index: 0,
|
|
481
|
+
start: 0,
|
|
482
|
+
end: input.length,
|
|
483
|
+
property: targetProperty,
|
|
484
|
+
message: `conditional values are not supported on part prop "${targetProperty}"; move the condition onto \`${legacyPartComposite[targetProperty]}\``,
|
|
485
|
+
},
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const results: StyleValueDiagnostic[] = []
|
|
490
|
+
const reported = new Set<string>()
|
|
491
|
+
const geometric = splitGeometricShorthandValue(targetProperty, parsed.value)
|
|
492
|
+
const programs =
|
|
493
|
+
geometric && geometric.errors.length === 0
|
|
494
|
+
? geometric.entries
|
|
495
|
+
: [{ property: targetProperty, value: parsed.value }]
|
|
496
|
+
|
|
497
|
+
for (const program of programs) {
|
|
498
|
+
const { base, clauses } = program.value
|
|
499
|
+
const payloads = [
|
|
500
|
+
...(base === null ? [] : [base]),
|
|
501
|
+
...clauses.map((clause) => clause.payload),
|
|
502
|
+
]
|
|
503
|
+
for (const payload of payloads) {
|
|
504
|
+
for (const diagnostic of diagnoseStyleValueProgramSlot(
|
|
505
|
+
program.property,
|
|
506
|
+
payload,
|
|
507
|
+
scoped
|
|
508
|
+
)) {
|
|
509
|
+
const key = `${diagnostic.code}:${diagnostic.candidate}:${program.property}`
|
|
510
|
+
if (reported.has(key)) continue
|
|
511
|
+
reported.add(key)
|
|
512
|
+
const span = payloadSpan(input, payload)
|
|
513
|
+
results.push({ ...diagnostic, index: span.start, ...span })
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
if (base !== null) {
|
|
517
|
+
pushShapeDiagnostic(results, reported, input, program.property, base, true)
|
|
518
|
+
}
|
|
519
|
+
for (const clause of clauses) {
|
|
520
|
+
pushShapeDiagnostic(
|
|
521
|
+
results,
|
|
522
|
+
reported,
|
|
523
|
+
input,
|
|
524
|
+
program.property,
|
|
525
|
+
clause.payload,
|
|
526
|
+
base !== null
|
|
527
|
+
)
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return results
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function diagnoseStyleValueProgramSlot(
|
|
535
|
+
property: string,
|
|
536
|
+
payload: string,
|
|
537
|
+
options: DiagnoseStyleValueOptions
|
|
538
|
+
): readonly StyleValueDiagnostic[] {
|
|
539
|
+
const slotDiagnostics = diagnoseStyleValue(property, payload, options)
|
|
540
|
+
return slotDiagnostics.filter(
|
|
541
|
+
(diagnostic) => diagnostic.code === 'candidate-property-mismatch'
|
|
542
|
+
)
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function pushShapeDiagnostic(
|
|
546
|
+
results: StyleValueDiagnostic[],
|
|
547
|
+
reported: Set<string>,
|
|
548
|
+
input: string,
|
|
549
|
+
property: string,
|
|
550
|
+
payload: string,
|
|
551
|
+
hasBase: boolean
|
|
552
|
+
): void {
|
|
553
|
+
const diagnostic = validatePayloadShape(property, payload, hasBase)
|
|
554
|
+
if (!diagnostic) return
|
|
555
|
+
const key = `${diagnostic.code}:${diagnostic.payload}:${property}`
|
|
556
|
+
if (reported.has(key)) return
|
|
557
|
+
reported.add(key)
|
|
558
|
+
const span = payloadSpan(input, payload)
|
|
559
|
+
results.push({
|
|
560
|
+
code: diagnostic.code,
|
|
561
|
+
index: span.start,
|
|
562
|
+
...span,
|
|
563
|
+
property,
|
|
564
|
+
message: diagnostic.message,
|
|
565
|
+
})
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Returns the finite configured and keyword values that are valid for one
|
|
570
|
+
* property. Every result passes through the same parser, config lookup, and
|
|
571
|
+
* target validator used by diagnostics.
|
|
572
|
+
*/
|
|
573
|
+
export function completeStyleValue(
|
|
574
|
+
property: string,
|
|
575
|
+
options: DiagnoseStyleValueOptions
|
|
576
|
+
): readonly StyleValueCompletion[] {
|
|
577
|
+
const candidates =
|
|
578
|
+
options.candidates || createCandidatePropertyVocabulary(options.config)
|
|
579
|
+
const targetProperty = options.config.shorthands?.[property] || property
|
|
580
|
+
if (!grammarProperties.has(targetProperty)) return []
|
|
581
|
+
|
|
582
|
+
const byValue = new Map<string, StyleValueCompletionKind>()
|
|
583
|
+
for (const [value, contributions] of candidates) {
|
|
584
|
+
if (resolveCandidateTarget(targetProperty, value, contributions).ok) {
|
|
585
|
+
byValue.set(value, 'configured')
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
const standalone = standaloneValueProps[targetProperty]
|
|
590
|
+
if (standalone) {
|
|
591
|
+
for (const value in standalone) {
|
|
592
|
+
if (!byValue.has(value)) byValue.set(value, 'keyword')
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (targetProperty === 'fontWeight') {
|
|
596
|
+
for (const value in fontWeightNames) {
|
|
597
|
+
if (!byValue.has(value)) byValue.set(value, 'keyword')
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
const completions: StyleValueCompletion[] = []
|
|
602
|
+
for (const [value, kind] of byValue) {
|
|
603
|
+
if (
|
|
604
|
+
diagnoseStyleValue(property, value, {
|
|
605
|
+
...options,
|
|
606
|
+
candidates,
|
|
607
|
+
}).length === 0
|
|
608
|
+
) {
|
|
609
|
+
completions.push({ value, kind })
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
completions.sort((a, b) => (a.value < b.value ? -1 : a.value > b.value ? 1 : 0))
|
|
614
|
+
return completions
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Returns completions and a replacement span for one cursor position. Source
|
|
619
|
+
* boundaries come from the runtime value scanner, including incomplete clause
|
|
620
|
+
* payloads and modifier chains.
|
|
621
|
+
*/
|
|
622
|
+
export function completeStyleValueAtCursor(
|
|
623
|
+
property: string,
|
|
624
|
+
input: string,
|
|
625
|
+
cursor: number,
|
|
626
|
+
options: DiagnoseStyleValueOptions
|
|
627
|
+
): StyleValueCursorCompletions | null {
|
|
628
|
+
if (cursor < 0 || cursor > input.length) return null
|
|
629
|
+
const parsed = parseValueWithSourceSpans(input, options.registry)
|
|
630
|
+
const active =
|
|
631
|
+
parsed.spans.find(
|
|
632
|
+
(span) => cursor >= span.start && cursor <= span.end && span.kind === 'modifier'
|
|
633
|
+
) ??
|
|
634
|
+
parsed.spans.find(
|
|
635
|
+
(span) =>
|
|
636
|
+
cursor >= span.start &&
|
|
637
|
+
cursor <= span.end &&
|
|
638
|
+
span.kind === 'word' &&
|
|
639
|
+
span.start > 0 &&
|
|
640
|
+
parsed.result.ok &&
|
|
641
|
+
parsed.spans.some(
|
|
642
|
+
(segment) =>
|
|
643
|
+
(segment.kind === 'base' || segment.kind === 'payload') &&
|
|
644
|
+
segment.start < span.start &&
|
|
645
|
+
segment.end >= span.end
|
|
646
|
+
)
|
|
647
|
+
) ??
|
|
648
|
+
parsed.spans.find(
|
|
649
|
+
(span) =>
|
|
650
|
+
cursor >= span.start &&
|
|
651
|
+
cursor <= span.end &&
|
|
652
|
+
span.kind !== 'modifier' &&
|
|
653
|
+
span.kind !== 'word'
|
|
654
|
+
)
|
|
655
|
+
|
|
656
|
+
if (active?.kind === 'modifier' || active?.kind === 'word') {
|
|
657
|
+
if (
|
|
658
|
+
!parsed.result.ok &&
|
|
659
|
+
parsed.result.errors.some(
|
|
660
|
+
(error) =>
|
|
661
|
+
error.code !== 'unregistered-modifier' &&
|
|
662
|
+
error.code !== 'empty-modifier' &&
|
|
663
|
+
error.code !== 'empty-payload'
|
|
664
|
+
)
|
|
665
|
+
) {
|
|
666
|
+
return null
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
replaceStart: active.start,
|
|
670
|
+
replaceLength: active.end - active.start,
|
|
671
|
+
completions: completeModifiers(
|
|
672
|
+
options,
|
|
673
|
+
input.charCodeAt(active.end) !== 58,
|
|
674
|
+
active.kind === 'modifier'
|
|
675
|
+
? modifierChainBefore(input, parsed.spans, active.start)
|
|
676
|
+
: []
|
|
677
|
+
),
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (active) {
|
|
682
|
+
if (
|
|
683
|
+
!parsed.result.ok &&
|
|
684
|
+
parsed.result.errors.some((error) => error.code !== 'empty-payload')
|
|
685
|
+
) {
|
|
686
|
+
return null
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
replaceStart: active.start,
|
|
690
|
+
replaceLength: active.end - active.start,
|
|
691
|
+
// the first payload word is also where another modifier in the chain
|
|
692
|
+
// begins, so both vocabularies remain available until the author picks.
|
|
693
|
+
completions:
|
|
694
|
+
active.kind === 'payload' && input.charCodeAt(active.start - 1) === 58
|
|
695
|
+
? [
|
|
696
|
+
...completeModifiers(
|
|
697
|
+
options,
|
|
698
|
+
true,
|
|
699
|
+
modifierChainBefore(input, parsed.spans, active.start)
|
|
700
|
+
),
|
|
701
|
+
...completeStyleValue(property, options),
|
|
702
|
+
]
|
|
703
|
+
: completeStyleValue(property, options),
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (parsed.result.ok && cursor === input.length) {
|
|
708
|
+
return {
|
|
709
|
+
replaceStart: cursor,
|
|
710
|
+
replaceLength: 0,
|
|
711
|
+
completions: completeModifiers(options, true, []),
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
return null
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function completeModifiers(
|
|
719
|
+
options: DiagnoseStyleValueOptions,
|
|
720
|
+
appendColon: boolean,
|
|
721
|
+
modifiers: readonly string[]
|
|
722
|
+
): readonly StyleValueCompletion[] {
|
|
723
|
+
const names = options.registry.next?.(modifiers)
|
|
724
|
+
if (!names) return []
|
|
725
|
+
const completions: StyleValueCompletion[] = []
|
|
726
|
+
for (const name of names) {
|
|
727
|
+
completions.push({
|
|
728
|
+
value: name,
|
|
729
|
+
kind: 'modifier',
|
|
730
|
+
insertText: appendColon ? `${name}:` : name,
|
|
731
|
+
})
|
|
732
|
+
}
|
|
733
|
+
completions.sort((a, b) => (a.value < b.value ? -1 : a.value > b.value ? 1 : 0))
|
|
734
|
+
return completions
|
|
735
|
+
}
|