@stylexjs/shared 0.7.5 → 0.9.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/lib/common-types.d.ts +1 -0
  2. package/lib/common-types.js.flow +1 -0
  3. package/lib/convert-to-className.d.ts +1 -1
  4. package/lib/convert-to-className.js +13 -11
  5. package/lib/convert-to-className.js.flow +1 -1
  6. package/lib/generate-css-rule.js +1 -1
  7. package/lib/index.js +2 -2
  8. package/lib/physical-rtl/generate-ltr.d.ts +3 -1
  9. package/lib/physical-rtl/generate-ltr.js +8 -12
  10. package/lib/physical-rtl/generate-ltr.js.flow +2 -2
  11. package/lib/physical-rtl/generate-rtl.d.ts +2 -2
  12. package/lib/physical-rtl/generate-rtl.js +57 -64
  13. package/lib/physical-rtl/generate-rtl.js.flow +2 -2
  14. package/lib/preprocess-rules/PreRule.d.ts +13 -6
  15. package/lib/preprocess-rules/PreRule.js +14 -13
  16. package/lib/preprocess-rules/PreRule.js.flow +14 -6
  17. package/lib/preprocess-rules/application-order.d.ts +4 -111
  18. package/lib/preprocess-rules/application-order.js.flow +3 -110
  19. package/lib/preprocess-rules/basic-validation.js +1 -1
  20. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +1 -2
  21. package/lib/preprocess-rules/flatten-raw-style-obj.js +7 -21
  22. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +1 -2
  23. package/lib/preprocess-rules/index.d.ts +1 -1
  24. package/lib/preprocess-rules/index.js +1 -1
  25. package/lib/preprocess-rules/index.js.flow +4 -1
  26. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +3 -38
  27. package/lib/preprocess-rules/legacy-expand-shorthands.js +12 -1
  28. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +3 -38
  29. package/lib/preprocess-rules/property-specificity.d.ts +4 -15
  30. package/lib/preprocess-rules/property-specificity.js.flow +3 -14
  31. package/lib/stylex-create-theme.js +2 -2
  32. package/lib/stylex-create.d.ts +4 -0
  33. package/lib/stylex-create.js +20 -8
  34. package/lib/stylex-create.js.flow +9 -1
  35. package/lib/stylex-define-vars.d.ts +8 -5
  36. package/lib/stylex-define-vars.js +2 -2
  37. package/lib/stylex-define-vars.js.flow +5 -1
  38. package/lib/stylex-include.js +1 -1
  39. package/lib/stylex-keyframes.js +1 -1
  40. package/lib/transform-value.js +7 -4
  41. package/lib/types/index.js.flow +1 -1
  42. package/lib/utils/default-options.js +1 -0
  43. package/lib/utils/normalize-value.js +1 -1
  44. package/lib/utils/normalizers/convert-camel-case-values.js +1 -1
  45. package/lib/utils/normalizers/detect-unclosed-fns.js +1 -1
  46. package/lib/utils/normalizers/font-size-px-to-rem.js +1 -1
  47. package/lib/utils/normalizers/leading-zero.js +1 -1
  48. package/lib/utils/normalizers/timings.js +1 -1
  49. package/lib/utils/normalizers/zero-dimensions.js +1 -1
  50. package/lib/utils/object-utils.d.ts +3 -2
  51. package/lib/utils/object-utils.js.flow +5 -2
  52. package/lib/utils/property-priorities.d.ts +3 -56
  53. package/lib/utils/property-priorities.js.flow +56 -56
  54. package/lib/utils/rule-utils.d.ts +15 -0
  55. package/lib/utils/rule-utils.js +41 -0
  56. package/lib/utils/rule-utils.js.flow +16 -0
  57. package/lib/utils/split-css-value.js +1 -1
  58. package/package.json +2 -2
@@ -36,6 +36,7 @@ export type FlatCompiledStyles = Readonly<{
36
36
  }>;
37
37
  export type StyleXOptions = Readonly<{
38
38
  dev: boolean;
39
+ debug: null | undefined | boolean;
39
40
  test: boolean;
40
41
  useRemForFontSize: boolean;
41
42
  classNamePrefix: string;
@@ -43,6 +43,7 @@ export type FlatCompiledStyles = $ReadOnly<{
43
43
 
44
44
  export type StyleXOptions = $ReadOnly<{
45
45
  dev: boolean,
46
+ debug: ?boolean,
46
47
  test: boolean,
47
48
  useRemForFontSize: boolean,
48
49
  classNamePrefix: string,
@@ -16,5 +16,5 @@ export declare function convertStyleToClassName(
16
16
  ): StyleRule;
17
17
  declare function variableFallbacks(
18
18
  values: ReadonlyArray<string>,
19
- ): Array<string>;
19
+ ): ReadonlyArray<string>;
20
20
  export default variableFallbacks;
@@ -10,15 +10,16 @@ var _dashify = _interopRequireDefault(require("./utils/dashify"));
10
10
  var _transformValue = _interopRequireDefault(require("./transform-value"));
11
11
  var _generateCssRule = require("./generate-css-rule");
12
12
  var _defaultOptions = require("./utils/default-options");
13
- var _objectUtils = require("./utils/object-utils");
14
13
  var messages = _interopRequireWildcard(require("./messages"));
14
+ var _ruleUtils = require("./utils/rule-utils");
15
15
  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); }
16
- 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; }
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ 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 && {}.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; }
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
18
  function convertStyleToClassName(objEntry, pseudos, atRules) {
19
19
  let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions.defaultOptions;
20
20
  const {
21
- classNamePrefix = 'x'
21
+ classNamePrefix = 'x',
22
+ debug = false
22
23
  } = options;
23
24
  const [key, rawValue] = objEntry;
24
25
  const dashedKey = (0, _dashify.default)(key);
@@ -26,13 +27,14 @@ function convertStyleToClassName(objEntry, pseudos, atRules) {
26
27
  if (Array.isArray(value) && value.find(val => val.startsWith('var(') && val.endsWith(')'))) {
27
28
  value = variableFallbacks(value);
28
29
  }
29
- const sortedPseudos = (0, _objectUtils.arraySort)(pseudos ?? []);
30
- const sortedAtRules = (0, _objectUtils.arraySort)(atRules ?? []);
31
- const atRuleHashString = sortedPseudos.join('');
32
- const pseudoHashString = sortedAtRules.join('');
33
- const modifierHashString = atRuleHashString + pseudoHashString || 'null';
34
- const stringToHash = Array.isArray(value) ? dashedKey + value.join(', ') + modifierHashString : dashedKey + value + modifierHashString;
35
- const className = classNamePrefix + (0, _hash.default)('<>' + stringToHash);
30
+ const sortedPseudos = (0, _ruleUtils.sortPseudos)(pseudos ?? []);
31
+ const sortedAtRules = (0, _ruleUtils.sortAtRules)(atRules ?? []);
32
+ const pseudoHashString = sortedPseudos.join('');
33
+ const atRuleHashString = sortedAtRules.join('');
34
+ const modifierHashString = pseudoHashString + atRuleHashString || 'null';
35
+ const valueAsString = Array.isArray(value) ? value.join(', ') : value;
36
+ const stringToHash = dashedKey + valueAsString + modifierHashString;
37
+ const className = debug ? `${key}-${classNamePrefix}${(0, _hash.default)('<>' + stringToHash)}` : classNamePrefix + (0, _hash.default)('<>' + stringToHash);
36
38
  const cssRules = (0, _generateCssRule.generateRule)(className, dashedKey, value, pseudos, atRules);
37
39
  return [key, className, cssRules];
38
40
  }
@@ -24,4 +24,4 @@ declare export function convertStyleToClassName(
24
24
 
25
25
  declare export default function variableFallbacks(
26
26
  values: $ReadOnlyArray<string>,
27
- ): Array<string>;
27
+ ): $ReadOnlyArray<string>;
@@ -8,7 +8,7 @@ var _generateLtr = _interopRequireDefault(require("./physical-rtl/generate-ltr")
8
8
  var _generateRtl = _interopRequireDefault(require("./physical-rtl/generate-rtl"));
9
9
  var _genCSSRule = require("./utils/genCSSRule");
10
10
  var _propertyPriorities = _interopRequireDefault(require("./utils/property-priorities"));
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  function generateRule(className, key, value, pseudos, atRules) {
13
13
  const pairs = Array.isArray(value) ? value.map(eachValue => [key, eachValue]) : [[key, value]];
14
14
  const ltrPairs = pairs.map(_generateLtr.default);
package/lib/index.js CHANGED
@@ -17,8 +17,8 @@ var _types = _interopRequireWildcard(require("./types"));
17
17
  exports.types = _types;
18
18
  var _propertyPriorities = require("./utils/property-priorities");
19
19
  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); }
20
- 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; }
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ 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 && {}.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; }
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
22
  const create = exports.create = _stylexCreate.default;
23
23
  const defineVars = exports.defineVars = _stylexDefineVars.default;
24
24
  const createTheme = exports.createTheme = _stylexCreateTheme.default;
@@ -7,5 +7,7 @@
7
7
  *
8
8
  */
9
9
 
10
- declare function generateLTR(pair: [string, string]): [string, string];
10
+ declare function generateLTR(
11
+ pair: Readonly<[string, string]>,
12
+ ): Readonly<[string, string]>;
11
13
  export default generateLTR;
@@ -73,28 +73,24 @@ const propertyToLTR = {
73
73
  let [_key, val] = _ref16;
74
74
  return ['border-bottom-right-radius', val];
75
75
  },
76
- 'text-align': _ref17 => {
76
+ float: _ref17 => {
77
77
  let [key, val] = _ref17;
78
78
  return [key, logicalToPhysical[val] ?? val];
79
79
  },
80
- float: _ref18 => {
80
+ clear: _ref18 => {
81
81
  let [key, val] = _ref18;
82
82
  return [key, logicalToPhysical[val] ?? val];
83
83
  },
84
- clear: _ref19 => {
85
- let [key, val] = _ref19;
86
- return [key, logicalToPhysical[val] ?? val];
87
- },
88
- start: _ref20 => {
89
- let [_key, val] = _ref20;
84
+ start: _ref19 => {
85
+ let [_key, val] = _ref19;
90
86
  return ['left', val];
91
87
  },
92
- end: _ref21 => {
93
- let [_key, val] = _ref21;
88
+ end: _ref20 => {
89
+ let [_key, val] = _ref20;
94
90
  return ['right', val];
95
91
  },
96
- 'background-position': _ref22 => {
97
- let [key, val] = _ref22;
92
+ 'background-position': _ref21 => {
93
+ let [key, val] = _ref21;
98
94
  return [key, val.split(' ').map(word => word === 'start' ? 'left' : word === 'end' ? 'right' : word).join(' ')];
99
95
  }
100
96
  };
@@ -8,5 +8,5 @@
8
8
  */
9
9
 
10
10
  declare export default function generateLTR(
11
- pair: [string, string],
12
- ): [string, string];
11
+ pair: $ReadOnly<[string, string]>,
12
+ ): $ReadOnly<[string, string]>;
@@ -8,6 +8,6 @@
8
8
  */
9
9
 
10
10
  declare function generateRTL(
11
- $$PARAM_0$$: [string, string],
12
- ): null | undefined | [string, string];
11
+ $$PARAM_0$$: Readonly<[string, string]>,
12
+ ): null | undefined | Readonly<[string, string]>;
13
13
  export default generateRTL;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = generateRTL;
7
7
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  const cursorFlip = {
10
10
  'e-resize': 'w-resize',
11
11
  'w-resize': 'e-resize',
@@ -60,123 +60,116 @@ function flipShadow(value) {
60
60
  return rtl;
61
61
  }
62
62
  }
63
- const shadowsFlip = {
64
- 'box-shadow': _ref => {
65
- let [key, val] = _ref;
66
- const rtlVal = flipShadow(val);
67
- return rtlVal ? [key, rtlVal] : null;
68
- },
69
- 'text-shadow': _ref2 => {
70
- let [key, val] = _ref2;
71
- const rtlVal = flipShadow(val);
72
- return rtlVal ? [key, rtlVal] : null;
73
- }
74
- };
75
63
  const logicalToPhysical = {
76
64
  start: 'right',
77
65
  end: 'left'
78
66
  };
79
67
  const propertyToRTL = {
80
- 'margin-start': _ref3 => {
81
- let [_key, val] = _ref3;
68
+ 'margin-start': _ref => {
69
+ let [_key, val] = _ref;
82
70
  return ['margin-right', val];
83
71
  },
84
- 'margin-end': _ref4 => {
85
- let [_key, val] = _ref4;
72
+ 'margin-end': _ref2 => {
73
+ let [_key, val] = _ref2;
86
74
  return ['margin-left', val];
87
75
  },
88
- 'padding-start': _ref5 => {
89
- let [_key, val] = _ref5;
76
+ 'padding-start': _ref3 => {
77
+ let [_key, val] = _ref3;
90
78
  return ['padding-right', val];
91
79
  },
92
- 'padding-end': _ref6 => {
93
- let [_key, val] = _ref6;
80
+ 'padding-end': _ref4 => {
81
+ let [_key, val] = _ref4;
94
82
  return ['padding-left', val];
95
83
  },
96
- 'border-start': _ref7 => {
97
- let [_key, val] = _ref7;
84
+ 'border-start': _ref5 => {
85
+ let [_key, val] = _ref5;
98
86
  return ['border-right', val];
99
87
  },
100
- 'border-end': _ref8 => {
101
- let [_key, val] = _ref8;
88
+ 'border-end': _ref6 => {
89
+ let [_key, val] = _ref6;
102
90
  return ['border-left', val];
103
91
  },
104
- 'border-start-width': _ref9 => {
105
- let [_key, val] = _ref9;
92
+ 'border-start-width': _ref7 => {
93
+ let [_key, val] = _ref7;
106
94
  return ['border-right-width', val];
107
95
  },
108
- 'border-end-width': _ref10 => {
109
- let [_key, val] = _ref10;
96
+ 'border-end-width': _ref8 => {
97
+ let [_key, val] = _ref8;
110
98
  return ['border-left-width', val];
111
99
  },
112
- 'border-start-color': _ref11 => {
113
- let [_key, val] = _ref11;
100
+ 'border-start-color': _ref9 => {
101
+ let [_key, val] = _ref9;
114
102
  return ['border-right-color', val];
115
103
  },
116
- 'border-end-color': _ref12 => {
117
- let [_key, val] = _ref12;
104
+ 'border-end-color': _ref10 => {
105
+ let [_key, val] = _ref10;
118
106
  return ['border-left-color', val];
119
107
  },
120
- 'border-start-style': _ref13 => {
121
- let [_key, val] = _ref13;
108
+ 'border-start-style': _ref11 => {
109
+ let [_key, val] = _ref11;
122
110
  return ['border-right-style', val];
123
111
  },
124
- 'border-end-style': _ref14 => {
125
- let [_key, val] = _ref14;
112
+ 'border-end-style': _ref12 => {
113
+ let [_key, val] = _ref12;
126
114
  return ['border-left-style', val];
127
115
  },
128
- 'border-top-start-radius': _ref15 => {
129
- let [_key, val] = _ref15;
116
+ 'border-top-start-radius': _ref13 => {
117
+ let [_key, val] = _ref13;
130
118
  return ['border-top-right-radius', val];
131
119
  },
132
- 'border-bottom-start-radius': _ref16 => {
133
- let [_key, val] = _ref16;
120
+ 'border-bottom-start-radius': _ref14 => {
121
+ let [_key, val] = _ref14;
134
122
  return ['border-bottom-right-radius', val];
135
123
  },
136
- 'border-top-end-radius': _ref17 => {
137
- let [_key, val] = _ref17;
124
+ 'border-top-end-radius': _ref15 => {
125
+ let [_key, val] = _ref15;
138
126
  return ['border-top-left-radius', val];
139
127
  },
140
- 'border-bottom-end-radius': _ref18 => {
141
- let [_key, val] = _ref18;
128
+ 'border-bottom-end-radius': _ref16 => {
129
+ let [_key, val] = _ref16;
142
130
  return ['border-bottom-left-radius', val];
143
131
  },
144
- 'text-align': _ref19 => {
145
- let [key, val] = _ref19;
132
+ float: _ref17 => {
133
+ let [key, val] = _ref17;
146
134
  return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
147
135
  },
148
- float: _ref20 => {
149
- let [key, val] = _ref20;
136
+ clear: _ref18 => {
137
+ let [key, val] = _ref18;
150
138
  return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
151
139
  },
152
- clear: _ref21 => {
153
- let [key, val] = _ref21;
154
- return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
155
- },
156
- start: _ref22 => {
157
- let [_key, val] = _ref22;
140
+ start: _ref19 => {
141
+ let [_key, val] = _ref19;
158
142
  return ['right', val];
159
143
  },
160
- end: _ref23 => {
161
- let [_key, val] = _ref23;
144
+ end: _ref20 => {
145
+ let [_key, val] = _ref20;
162
146
  return ['left', val];
163
147
  },
164
- 'background-position': _ref24 => {
165
- let [key, val] = _ref24;
148
+ 'background-position': _ref21 => {
149
+ let [key, val] = _ref21;
166
150
  const words = val.split(' ');
167
151
  if (!words.includes('start') && !words.includes('end')) {
168
152
  return null;
169
153
  }
170
154
  return [key, words.map(word => word === 'start' ? 'right' : word === 'end' ? 'left' : word).join(' ')];
171
155
  },
172
- cursor: _ref25 => {
173
- let [key, val] = _ref25;
156
+ cursor: _ref22 => {
157
+ let [key, val] = _ref22;
174
158
  return cursorFlip[val] != null ? [key, cursorFlip[val]] : null;
175
159
  },
176
- ...shadowsFlip
160
+ 'box-shadow': _ref23 => {
161
+ let [key, val] = _ref23;
162
+ const rtlVal = flipShadow(val);
163
+ return rtlVal ? [key, rtlVal] : null;
164
+ },
165
+ 'text-shadow': _ref24 => {
166
+ let [key, val] = _ref24;
167
+ const rtlVal = flipShadow(val);
168
+ return rtlVal ? [key, rtlVal] : null;
169
+ }
177
170
  };
178
- function generateRTL(_ref26) {
179
- let [key, value] = _ref26;
171
+ function generateRTL(_ref25) {
172
+ let [key, value] = _ref25;
180
173
  if (propertyToRTL[key]) {
181
174
  return propertyToRTL[key]([key, value]);
182
175
  }
@@ -8,5 +8,5 @@
8
8
  */
9
9
 
10
10
  declare export default function generateRTL(
11
- [string, string],
12
- ): ?[string, string];
11
+ $ReadOnly<[string, string]>,
12
+ ): ?$ReadOnly<[string, string]>;
@@ -9,7 +9,12 @@
9
9
 
10
10
  import type { InjectableStyle, StyleXOptions } from '../common-types';
11
11
  import type { IncludedStyles } from '../stylex-include';
12
- export type ComputedStyle = null | Readonly<[string, InjectableStyle]>;
12
+ export type ClassesToOriginalPaths = {
13
+ readonly [className: string]: ReadonlyArray<string>;
14
+ };
15
+ export type ComputedStyle = null | Readonly<
16
+ [string, InjectableStyle, ClassesToOriginalPaths]
17
+ >;
13
18
  export interface IPreRule {
14
19
  compiled(
15
20
  options: StyleXOptions,
@@ -30,15 +35,17 @@ export declare class PreIncludedStylesRule implements IPreRule {
30
35
  export declare class PreRule implements IPreRule {
31
36
  readonly property: string;
32
37
  readonly value: string | number | ReadonlyArray<string | number>;
33
- readonly pseudos: ReadonlyArray<string>;
34
- readonly atRules: ReadonlyArray<string>;
38
+ readonly keyPath: ReadonlyArray<string>;
35
39
  constructor(
36
40
  property: string,
37
41
  value: string | number | ReadonlyArray<string | number>,
38
- pseudos?: null | undefined | ReadonlyArray<string>,
39
- atRules?: null | undefined | ReadonlyArray<string>,
42
+ keyPath?: ReadonlyArray<string>,
40
43
  );
41
- compiled(options: StyleXOptions): ReadonlyArray<[string, InjectableStyle]>;
44
+ get pseudos(): ReadonlyArray<string>;
45
+ get atRules(): ReadonlyArray<string>;
46
+ compiled(
47
+ options: StyleXOptions,
48
+ ): ReadonlyArray<[string, InjectableStyle, ClassesToOriginalPaths]>;
42
49
  equals(other: IPreRule): boolean;
43
50
  }
44
51
  export declare class PreRuleSet implements IPreRule {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PreRuleSet = exports.PreRule = exports.PreIncludedStylesRule = exports.NullPreRule = void 0;
7
7
  var _convertToClassName = require("../convert-to-className");
8
8
  var _objectUtils = require("../utils/object-utils");
9
+ var _ruleUtils = require("../utils/rule-utils");
9
10
  class NullPreRule {
10
11
  compiled(_options) {
11
12
  return [null];
@@ -27,25 +28,25 @@ class PreIncludedStylesRule {
27
28
  }
28
29
  }
29
30
  exports.PreIncludedStylesRule = PreIncludedStylesRule;
30
- const stringComparator = (a, b) => {
31
- if (a === 'default') {
32
- return -1;
33
- }
34
- if (b === 'default') {
35
- return 1;
36
- }
37
- return a.localeCompare(b);
38
- };
39
31
  class PreRule {
40
- constructor(property, value, pseudos, atRules) {
32
+ constructor(property, value, keyPath) {
41
33
  this.property = property;
34
+ this.keyPath = keyPath ?? [];
42
35
  this.value = value;
43
- this.pseudos = pseudos ? (0, _objectUtils.arraySort)(pseudos, stringComparator) : [];
44
- this.atRules = atRules ? (0, _objectUtils.arraySort)(atRules) : [];
36
+ }
37
+ get pseudos() {
38
+ const unsortedPseudos = this.keyPath.filter(key => key.startsWith(':'));
39
+ return (0, _ruleUtils.sortPseudos)(unsortedPseudos);
40
+ }
41
+ get atRules() {
42
+ const unsortedAtRules = this.keyPath.filter(key => key.startsWith('@'));
43
+ return (0, _ruleUtils.sortAtRules)(unsortedAtRules);
45
44
  }
46
45
  compiled(options) {
47
46
  const [_key, className, rule] = (0, _convertToClassName.convertStyleToClassName)([this.property, this.value], this.pseudos ?? [], this.atRules ?? [], options);
48
- return [[className, rule]];
47
+ return [[className, rule, {
48
+ [className]: this.keyPath
49
+ }]];
49
50
  }
50
51
  equals(other) {
51
52
  if (!(other instanceof PreRule)) {
@@ -10,7 +10,13 @@
10
10
  import type { InjectableStyle, StyleXOptions } from '../common-types';
11
11
  import type { IncludedStyles } from '../stylex-include';
12
12
 
13
- export type ComputedStyle = null | $ReadOnly<[string, InjectableStyle]>;
13
+ export type ClassesToOriginalPaths = {
14
+ +[className: string]: $ReadOnlyArray<string>,
15
+ };
16
+
17
+ export type ComputedStyle = null | $ReadOnly<
18
+ [string, InjectableStyle, ClassesToOriginalPaths],
19
+ >;
14
20
 
15
21
  // The classes in this file are used to represent objects that
16
22
  // can be compiled into one or CSS rules.
@@ -41,15 +47,17 @@ declare export class PreIncludedStylesRule implements IPreRule {
41
47
  declare export class PreRule implements IPreRule {
42
48
  +property: string;
43
49
  +value: string | number | $ReadOnlyArray<string | number>;
44
- +pseudos: $ReadOnlyArray<string>;
45
- +atRules: $ReadOnlyArray<string>;
50
+ +keyPath: $ReadOnlyArray<string>;
46
51
  constructor(
47
52
  property: string,
48
53
  value: string | number | $ReadOnlyArray<string | number>,
49
- pseudos?: ?$ReadOnlyArray<string>,
50
- atRules?: ?$ReadOnlyArray<string>,
54
+ keyPath?: $ReadOnlyArray<string>,
51
55
  ): void;
52
- compiled(options: StyleXOptions): $ReadOnlyArray<[string, InjectableStyle]>;
56
+ get pseudos(): $ReadOnlyArray<string>;
57
+ get atRules(): $ReadOnlyArray<string>;
58
+ compiled(
59
+ options: StyleXOptions,
60
+ ): $ReadOnlyArray<[string, InjectableStyle, ClassesToOriginalPaths]>;
53
61
  equals(other: IPreRule): boolean;
54
62
  }
55
63
 
@@ -111,116 +111,9 @@ import type { TStyleValue } from '../common-types';
111
111
  */
112
112
 
113
113
  type TReturn = ReadonlyArray<[string, TStyleValue]>;
114
- declare const shorthands: {
115
- all: (_: TStyleValue) => TReturn;
116
- animation: (value: TStyleValue) => Array<[string, TStyleValue]>;
117
- animationRange: (value: TStyleValue) => TReturn;
118
- background: (value: TStyleValue) => TReturn;
119
- backgroundPosition: (value: TStyleValue) => TReturn;
120
- border: (rawValue: TStyleValue) => TReturn;
121
- borderInline: (rawValue: TStyleValue) => TReturn;
122
- borderBlock: (rawValue: TStyleValue) => TReturn;
123
- borderTop: (rawValue: TStyleValue) => TReturn;
124
- borderInlineEnd: (rawValue: TStyleValue) => TReturn;
125
- borderRight: (rawValue: TStyleValue) => TReturn;
126
- borderBottom: (rawValue: TStyleValue) => TReturn;
127
- borderInlineStart: (rawValue: TStyleValue) => TReturn;
128
- borderLeft: (rawValue: TStyleValue) => TReturn;
129
- borderInlineWidth: (rawValue: TStyleValue) => TReturn;
130
- borderInlineStyle: (rawValue: TStyleValue) => TReturn;
131
- borderInlineColor: (rawValue: TStyleValue) => TReturn;
132
- borderBlockWidth: (rawValue: TStyleValue) => TReturn;
133
- borderBlockStyle: (rawValue: TStyleValue) => TReturn;
134
- borderBlockColor: (rawValue: TStyleValue) => TReturn;
135
- borderColor: (value: TStyleValue) => TReturn;
136
- borderStyle: (value: TStyleValue) => TReturn;
137
- borderWidth: (value: TStyleValue) => TReturn;
138
- borderInlineStartColor: (value: TStyleValue) => TReturn;
139
- borderInlineEndColor: (value: TStyleValue) => TReturn;
140
- borderInlineStartStyle: (value: TStyleValue) => TReturn;
141
- borderInlineEndStyle: (value: TStyleValue) => TReturn;
142
- borderInlineStartWidth: (value: TStyleValue) => TReturn;
143
- borderInlineEndWidth: (value: TStyleValue) => TReturn;
144
- borderLeftColor: (value: TStyleValue) => TReturn;
145
- borderRightColor: (value: TStyleValue) => TReturn;
146
- borderLeftStyle: (value: TStyleValue) => TReturn;
147
- borderRightStyle: (value: TStyleValue) => TReturn;
148
- borderLeftWidth: (value: TStyleValue) => TReturn;
149
- borderRightWidth: (value: TStyleValue) => TReturn;
150
- borderRadius: (value: TStyleValue) => TReturn;
151
- borderStartStartRadius: (value: TStyleValue) => TReturn;
152
- borderStartEndRadius: (value: TStyleValue) => TReturn;
153
- borderEndStartRadius: (value: TStyleValue) => TReturn;
154
- borderEndEndRadius: (value: TStyleValue) => TReturn;
155
- borderTopLeftRadius: (value: TStyleValue) => TReturn;
156
- borderTopRightRadius: (value: TStyleValue) => TReturn;
157
- borderBottomLeftRadius: (value: TStyleValue) => TReturn;
158
- borderBottomRightRadius: (value: TStyleValue) => TReturn;
159
- borderImage: (value: TStyleValue) => TReturn;
160
- columnRule: (value: TStyleValue) => TReturn;
161
- columns: (value: TStyleValue) => TReturn;
162
- container: (value: TStyleValue) => TReturn;
163
- containIntrinsicSize: (value: TStyleValue) => TReturn;
164
- flex: (value: TStyleValue) => TReturn;
165
- flexFlow: (value: TStyleValue) => TReturn;
166
- font: (value: TStyleValue) => TReturn;
167
- fontVariant: (value: TStyleValue) => TReturn;
168
- gap: (value: TStyleValue) => TReturn;
169
- grid: (value: TStyleValue) => TReturn;
170
- gridArea: (value: TStyleValue) => TReturn;
171
- gridRow: (value: TStyleValue) => TReturn;
172
- gridColumn: (value: TStyleValue) => TReturn;
173
- gridTemplate: (value: TStyleValue) => TReturn;
174
- inset: (value: TStyleValue) => TReturn;
175
- insetInline: (value: TStyleValue) => TReturn;
176
- insetBlock: (value: TStyleValue) => TReturn;
177
- insetInlineStart: (value: TStyleValue) => TReturn;
178
- insetInlineEnd: (value: TStyleValue) => TReturn;
179
- left: (value: TStyleValue) => TReturn;
180
- right: (value: TStyleValue) => TReturn;
181
- listStyle: (value: TStyleValue) => TReturn;
182
- margin: (value: TStyleValue) => TReturn;
183
- marginInline: (value: TStyleValue) => TReturn;
184
- marginBlock: (value: TStyleValue) => TReturn;
185
- marginInlineStart: (value: TStyleValue) => TReturn;
186
- marginInlineEnd: (value: TStyleValue) => TReturn;
187
- marginLeft: (value: TStyleValue) => TReturn;
188
- marginRight: (value: TStyleValue) => TReturn;
189
- mask: (value: TStyleValue) => TReturn;
190
- maskBorder: (value: TStyleValue) => TReturn;
191
- offset: (value: TStyleValue) => TReturn;
192
- outline: (value: TStyleValue) => TReturn;
193
- overflow: (value: TStyleValue) => TReturn;
194
- padding: (rawValue: TStyleValue) => TReturn;
195
- paddingInline: (rawValue: TStyleValue) => TReturn;
196
- paddingBlock: (rawValue: TStyleValue) => TReturn;
197
- paddingInlineStart: (value: TStyleValue) => TReturn;
198
- paddingInlineEnd: (value: TStyleValue) => TReturn;
199
- paddingLeft: (value: TStyleValue) => TReturn;
200
- paddingRight: (value: TStyleValue) => TReturn;
201
- placeContent: (value: TStyleValue) => TReturn;
202
- placeItems: (value: TStyleValue) => TReturn;
203
- placeSelf: (value: TStyleValue) => TReturn;
204
- scrollMargin: (value: TStyleValue) => TReturn;
205
- scrollMarginBlock: (value: TStyleValue) => TReturn;
206
- scrollMarginInline: (value: TStyleValue) => TReturn;
207
- scrollMarginInlineStart: (value: TStyleValue) => TReturn;
208
- scrollMarginInlineEnd: (value: TStyleValue) => TReturn;
209
- scrollMarginLeft: (value: TStyleValue) => TReturn;
210
- scrollMarginRight: (value: TStyleValue) => TReturn;
211
- scrollPadding: (value: TStyleValue) => TReturn;
212
- scrollPaddingBlock: (value: TStyleValue) => TReturn;
213
- scrollPaddingInline: (value: TStyleValue) => TReturn;
214
- scrollPaddingInlineStart: (value: TStyleValue) => TReturn;
215
- scrollPaddingInlineEnd: (value: TStyleValue) => TReturn;
216
- scrollPaddingLeft: (value: TStyleValue) => TReturn;
217
- scrollPaddingRight: (value: TStyleValue) => TReturn;
218
- scrollSnapType: (value: TStyleValue) => TReturn;
219
- scrollTimeline: (value: TStyleValue) => TReturn;
220
- textDecoration: (value: TStyleValue) => TReturn;
221
- textEmphasis: (value: TStyleValue) => TReturn;
222
- transition: (value: TStyleValue) => TReturn;
223
- };
114
+ declare const shorthands: Readonly<{
115
+ [key: string]: ($$PARAM_0$$: TStyleValue) => TReturn;
116
+ }>;
224
117
  declare const aliases: {
225
118
  borderHorizontal: any;
226
119
  borderVertical: any;
@@ -283,7 +176,7 @@ declare const aliases: {
283
176
  end: any;
284
177
  };
285
178
  declare const $$EXPORT_DEFAULT_DECLARATION$$: Readonly</**
286
- * > 239 | ...typeof shorthands,
179
+ * > 132 | ...typeof shorthands,
287
180
  * | ^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
288
181
  **/
289
182
  any>;