@stylexjs/shared
Advanced tools
+8
-0
@@ -29,2 +29,7 @@ /** | ||
| export * as types from './types'; | ||
| import { | ||
| PSEUDO_CLASS_PRIORITIES as _PSEUDO_CLASS_PRIORITIES, | ||
| AT_RULE_PRIORITIES as _AT_RULE_PRIORITIES, | ||
| PSEUDO_ELEMENT_PRIORITY as _PSEUDO_ELEMENT_PRIORITY, | ||
| } from './utils/property-priorities'; | ||
| import type { | ||
@@ -48,2 +53,5 @@ InjectableStyle as _InjectableStyle, | ||
| export declare const firstThatWorks: typeof stylexFirstThatWorks; | ||
| export declare const PSEUDO_CLASS_PRIORITIES: typeof _PSEUDO_CLASS_PRIORITIES; | ||
| export declare const AT_RULE_PRIORITIES: typeof _AT_RULE_PRIORITIES; | ||
| export declare const PSEUDO_ELEMENT_PRIORITY: typeof _PSEUDO_ELEMENT_PRIORITY; | ||
| export type InjectableStyle = _InjectableStyle; | ||
@@ -50,0 +58,0 @@ export type CompiledNamespaces = _CompiledNamespaces; |
+6
-2
@@ -6,3 +6,3 @@ "use strict"; | ||
| }); | ||
| exports.utils = exports.types = exports.messages = exports.keyframes = exports.include = exports.firstThatWorks = exports.defineVars = exports.createTheme = exports.create = exports.IncludedStyles = void 0; | ||
| exports.utils = exports.types = exports.messages = exports.keyframes = exports.include = exports.firstThatWorks = exports.defineVars = exports.createTheme = exports.create = exports.PSEUDO_ELEMENT_PRIORITY = exports.PSEUDO_CLASS_PRIORITIES = exports.IncludedStyles = exports.AT_RULE_PRIORITIES = void 0; | ||
| var _stylexCreate = _interopRequireDefault(require("./stylex-create")); | ||
@@ -19,2 +19,3 @@ var _stylexDefineVars = _interopRequireDefault(require("./stylex-define-vars")); | ||
| exports.types = _types; | ||
| var _propertyPriorities = require("./utils/property-priorities"); | ||
| function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
@@ -34,2 +35,5 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
| const IncludedStyles = exports.IncludedStyles = _stylexInclude.IncludedStyles; | ||
| const firstThatWorks = exports.firstThatWorks = _stylexFirstThatWorks.default; | ||
| const firstThatWorks = exports.firstThatWorks = _stylexFirstThatWorks.default; | ||
| const PSEUDO_CLASS_PRIORITIES = exports.PSEUDO_CLASS_PRIORITIES = _propertyPriorities.PSEUDO_CLASS_PRIORITIES; | ||
| const AT_RULE_PRIORITIES = exports.AT_RULE_PRIORITIES = _propertyPriorities.AT_RULE_PRIORITIES; | ||
| const PSEUDO_ELEMENT_PRIORITY = exports.PSEUDO_ELEMENT_PRIORITY = _propertyPriorities.PSEUDO_ELEMENT_PRIORITY; |
@@ -21,3 +21,6 @@ "use strict"; | ||
| function flatMapExpandedShorthands(objEntry, options) { | ||
| const [key, value] = objEntry; | ||
| let [key, value] = objEntry; | ||
| if (key.startsWith('var(') && key.endsWith(')')) { | ||
| key = key.slice(4, -1); | ||
| } | ||
| const expansion = expansions[options.styleResolution ?? 'application-order'][key]; | ||
@@ -24,0 +27,0 @@ if (expansion) { |
@@ -22,2 +22,12 @@ 'use strict'; | ||
| case 'div': | ||
| { | ||
| if (node.value === ',') { | ||
| node.before = ''; | ||
| node.after = ''; | ||
| } else { | ||
| node.before = ' '; | ||
| node.after = ' '; | ||
| } | ||
| break; | ||
| } | ||
| case 'function': | ||
@@ -24,0 +34,0 @@ { |
@@ -12,3 +12,10 @@ 'use strict'; | ||
| function normalizeZeroDimensions(ast, _) { | ||
| let endFunction = 0; | ||
| ast.walk(node => { | ||
| if (node.type === 'function' && !endFunction) { | ||
| endFunction = node.sourceEndIndex ?? 0; | ||
| } | ||
| if (endFunction > 0 && node.sourceIndex > endFunction) { | ||
| endFunction = 0; | ||
| } | ||
| if (node.type !== 'word') { | ||
@@ -25,3 +32,3 @@ return; | ||
| node.value = '0s'; | ||
| } else { | ||
| } else if (!endFunction) { | ||
| node.value = '0'; | ||
@@ -28,0 +35,0 @@ } |
@@ -10,3 +10,62 @@ /** | ||
| type PseudoClassPriorities = { | ||
| ':is': 40; | ||
| ':where': 40; | ||
| ':not': 40; | ||
| ':has': 45; | ||
| ':dir': 50; | ||
| ':lang': 51; | ||
| ':first-child': 52; | ||
| ':first-of-type': 53; | ||
| ':last-child': 54; | ||
| ':last-of-type': 55; | ||
| ':only-child': 56; | ||
| ':only-of-type': 57; | ||
| ':nth-child': 60; | ||
| ':nth-last-child': 61; | ||
| ':nth-of-type': 62; | ||
| ':nth-last-of-type': 63; | ||
| ':empty': 70; | ||
| ':link': 80; | ||
| ':any-link': 81; | ||
| ':local-link': 82; | ||
| ':target-within': 83; | ||
| ':target': 84; | ||
| ':visited': 85; | ||
| ':enabled': 91; | ||
| ':disabled': 92; | ||
| ':required': 93; | ||
| ':optional': 94; | ||
| ':read-only': 95; | ||
| ':read-write': 96; | ||
| ':placeholder-shown': 97; | ||
| ':in-range': 98; | ||
| ':out-of-range': 99; | ||
| ':default': 100; | ||
| ':checked': 101; | ||
| ':indeterminate': 101; | ||
| ':blank': 102; | ||
| ':valid': 103; | ||
| ':invalid': 104; | ||
| ':user-invalid': 105; | ||
| ':autofill': 110; | ||
| ':picture-in-picture': 120; | ||
| ':modal': 121; | ||
| ':fullscreen': 122; | ||
| ':paused': 123; | ||
| ':playing': 124; | ||
| ':current': 125; | ||
| ':past': 126; | ||
| ':future': 127; | ||
| ':hover': 130; | ||
| ':focusWithin': 140; | ||
| ':focus': 150; | ||
| ':focusVisible': 160; | ||
| ':active': 170; | ||
| }; | ||
| export declare const PSEUDO_CLASS_PRIORITIES: Readonly<PseudoClassPriorities>; | ||
| type AtRulePriorities = { '@supports': 30; '@media': 200; '@container': 300 }; | ||
| export declare const AT_RULE_PRIORITIES: Readonly<AtRulePriorities>; | ||
| export declare const PSEUDO_ELEMENT_PRIORITY: number; | ||
| declare function getPriority(key: string): number; | ||
| export default getPriority; |
@@ -6,2 +6,3 @@ "use strict"; | ||
| }); | ||
| exports.PSEUDO_ELEMENT_PRIORITY = exports.PSEUDO_CLASS_PRIORITIES = exports.AT_RULE_PRIORITIES = void 0; | ||
| exports.default = getPriority; | ||
@@ -444,3 +445,3 @@ const longHandPhysical = new Set(); | ||
| longHandLogical.add('touch-action'); | ||
| const PRIORITIES = { | ||
| const PSEUDO_CLASS_PRIORITIES = exports.PSEUDO_CLASS_PRIORITIES = { | ||
| ':is': 40, | ||
@@ -500,2 +501,8 @@ ':where': 40, | ||
| }; | ||
| const AT_RULE_PRIORITIES = exports.AT_RULE_PRIORITIES = { | ||
| '@supports': 30, | ||
| '@media': 200, | ||
| '@container': 300 | ||
| }; | ||
| const PSEUDO_ELEMENT_PRIORITY = exports.PSEUDO_ELEMENT_PRIORITY = 5000; | ||
| function getPriority(key) { | ||
@@ -506,16 +513,16 @@ if (key.startsWith('--')) { | ||
| if (key.startsWith('@supports')) { | ||
| return 30; | ||
| return AT_RULE_PRIORITIES['@supports']; | ||
| } | ||
| if (key.startsWith('@media')) { | ||
| return 200; | ||
| return AT_RULE_PRIORITIES['@media']; | ||
| } | ||
| if (key.startsWith('@container')) { | ||
| return 300; | ||
| return AT_RULE_PRIORITIES['@container']; | ||
| } | ||
| if (key.startsWith('::')) { | ||
| return 5000; | ||
| return PSEUDO_ELEMENT_PRIORITY; | ||
| } | ||
| if (key.startsWith(':')) { | ||
| const prop = key.startsWith(':') && key.includes('(') ? key.slice(0, key.indexOf('(')) : key; | ||
| return PRIORITIES[prop] ?? 40; | ||
| return PSEUDO_CLASS_PRIORITIES[prop] ?? 40; | ||
| } | ||
@@ -522,0 +529,0 @@ if (longHandPhysical.has(key)) { |
+2
-2
| { | ||
| "name": "@stylexjs/shared", | ||
| "version": "0.5.0-alpha.4", | ||
| "version": "0.5.0", | ||
| "main": "lib/index.js", | ||
@@ -16,3 +16,3 @@ "repository": "https://www.github.com/facebook/stylex", | ||
| "devDependencies": { | ||
| "@stylexjs/scripts": "0.5.0-alpha.4" | ||
| "@stylexjs/scripts": "0.5.0" | ||
| }, | ||
@@ -19,0 +19,0 @@ "jest": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
857509
0.6%25993
0.38%