@stylexjs/babel-plugin 0.11.1 → 0.13.0

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.
Files changed (121) hide show
  1. package/lib/index.d.ts +2 -1
  2. package/lib/index.js +3797 -2229
  3. package/lib/index.js.flow +11 -1
  4. package/lib/shared/common-types.d.ts +57 -0
  5. package/lib/shared/common-types.js.flow +71 -0
  6. package/lib/shared/hash.d.ts +12 -0
  7. package/lib/shared/hash.js.flow +12 -0
  8. package/lib/shared/index.d.ts +57 -0
  9. package/lib/shared/index.js.flow +66 -0
  10. package/lib/shared/messages.d.ts +35 -0
  11. package/lib/shared/messages.js.flow +40 -0
  12. package/lib/shared/physical-rtl/generate-ltr.d.ts +13 -0
  13. package/lib/shared/physical-rtl/generate-ltr.js.flow +12 -0
  14. package/lib/shared/physical-rtl/generate-rtl.d.ts +13 -0
  15. package/lib/shared/physical-rtl/generate-rtl.js.flow +12 -0
  16. package/lib/shared/preprocess-rules/PreRule.d.ts +51 -0
  17. package/lib/shared/preprocess-rules/PreRule.js.flow +63 -0
  18. package/lib/shared/preprocess-rules/application-order.d.ts +183 -0
  19. package/lib/shared/preprocess-rules/application-order.js.flow +134 -0
  20. package/lib/shared/preprocess-rules/basic-validation.d.ts +13 -0
  21. package/lib/shared/preprocess-rules/basic-validation.js.flow +13 -0
  22. package/lib/shared/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
  23. package/lib/shared/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
  24. package/lib/shared/preprocess-rules/index.d.ts +18 -0
  25. package/lib/shared/preprocess-rules/index.js.flow +22 -0
  26. package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +165 -0
  27. package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +144 -0
  28. package/lib/shared/preprocess-rules/property-specificity.d.ts +78 -0
  29. package/lib/shared/preprocess-rules/property-specificity.js.flow +87 -0
  30. package/lib/shared/stylex-consts-utils.d.ts +11 -0
  31. package/lib/shared/stylex-consts-utils.js.flow +14 -0
  32. package/lib/shared/stylex-create-theme.d.ts +26 -0
  33. package/lib/shared/stylex-create-theme.js.flow +19 -0
  34. package/lib/shared/stylex-create.d.ts +27 -0
  35. package/lib/shared/stylex-create.js.flow +37 -0
  36. package/lib/shared/stylex-define-consts.d.ts +23 -0
  37. package/lib/shared/stylex-define-consts.js.flow +19 -0
  38. package/lib/shared/stylex-define-vars.d.ts +28 -0
  39. package/lib/shared/stylex-define-vars.js.flow +26 -0
  40. package/lib/shared/stylex-first-that-works.d.ts +13 -0
  41. package/lib/shared/stylex-first-that-works.js.flow +12 -0
  42. package/lib/shared/stylex-keyframes.d.ts +17 -0
  43. package/lib/shared/stylex-keyframes.js.flow +20 -0
  44. package/lib/shared/stylex-position-try.d.ts +15 -0
  45. package/lib/shared/stylex-position-try.js.flow +18 -0
  46. package/lib/shared/stylex-vars-utils.d.ts +27 -0
  47. package/lib/shared/stylex-vars-utils.js.flow +31 -0
  48. package/lib/shared/types/index.d.ts +240 -0
  49. package/lib/shared/types/index.js.flow +280 -0
  50. package/lib/shared/utils/Rule.d.ts +58 -0
  51. package/lib/shared/utils/Rule.js.flow +64 -0
  52. package/lib/shared/utils/convert-to-className.d.ts +21 -0
  53. package/lib/shared/utils/convert-to-className.js.flow +29 -0
  54. package/lib/shared/utils/dashify.d.ts +11 -0
  55. package/lib/shared/utils/dashify.js.flow +10 -0
  56. package/lib/shared/utils/default-options.d.ts +11 -0
  57. package/lib/shared/utils/default-options.js.flow +12 -0
  58. package/lib/shared/utils/file-based-identifier.d.ts +15 -0
  59. package/lib/shared/utils/file-based-identifier.js.flow +14 -0
  60. package/lib/shared/utils/generate-css-rule.d.ts +18 -0
  61. package/lib/shared/utils/generate-css-rule.js.flow +19 -0
  62. package/lib/shared/utils/normalize-value.d.ts +16 -0
  63. package/lib/shared/utils/normalize-value.js.flow +16 -0
  64. package/lib/shared/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  65. package/lib/shared/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  66. package/lib/shared/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  67. package/lib/shared/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  68. package/lib/shared/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  69. package/lib/shared/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  70. package/lib/shared/utils/normalizers/leading-zero.d.ts +17 -0
  71. package/lib/shared/utils/normalizers/leading-zero.js.flow +16 -0
  72. package/lib/shared/utils/normalizers/quotes.d.ts +18 -0
  73. package/lib/shared/utils/normalizers/quotes.js.flow +17 -0
  74. package/lib/shared/utils/normalizers/timings.d.ts +18 -0
  75. package/lib/shared/utils/normalizers/timings.js.flow +17 -0
  76. package/lib/shared/utils/normalizers/whitespace.d.ts +19 -0
  77. package/lib/shared/utils/normalizers/whitespace.js.flow +18 -0
  78. package/lib/shared/utils/normalizers/zero-dimensions.d.ts +19 -0
  79. package/lib/shared/utils/normalizers/zero-dimensions.js.flow +18 -0
  80. package/lib/shared/utils/object-utils.d.ts +66 -0
  81. package/lib/shared/utils/object-utils.js.flow +78 -0
  82. package/lib/shared/utils/property-priorities.d.ts +17 -0
  83. package/lib/shared/utils/property-priorities.js.flow +78 -0
  84. package/lib/shared/utils/rule-utils.d.ts +15 -0
  85. package/lib/shared/utils/rule-utils.js.flow +16 -0
  86. package/lib/shared/utils/split-css-value.d.ts +14 -0
  87. package/lib/shared/utils/split-css-value.js.flow +15 -0
  88. package/lib/shared/utils/transform-value.d.ts +22 -0
  89. package/lib/shared/utils/transform-value.js.flow +25 -0
  90. package/lib/shared/validate.d.ts +12 -0
  91. package/lib/shared/validate.js.flow +12 -0
  92. package/lib/utils/add-sourcemap-data.d.ts +1 -1
  93. package/lib/utils/add-sourcemap-data.js.flow +1 -1
  94. package/lib/utils/dev-classname.d.ts +1 -1
  95. package/lib/utils/dev-classname.js.flow +2 -1
  96. package/lib/utils/evaluate-path.d.ts +19 -0
  97. package/lib/utils/evaluate-path.js.flow +26 -0
  98. package/lib/utils/js-to-ast.d.ts +1 -1
  99. package/lib/utils/js-to-ast.js.flow +1 -1
  100. package/lib/utils/state-manager.d.ts +36 -6
  101. package/lib/utils/state-manager.js.flow +35 -5
  102. package/lib/visitors/imports.d.ts +1 -1
  103. package/lib/visitors/imports.js.flow +2 -1
  104. package/lib/visitors/{stylex-create/parse-stylex-create-arg.d.ts → parse-stylex-create-arg.d.ts} +2 -2
  105. package/lib/visitors/{stylex-create/parse-stylex-create-arg.js.flow → parse-stylex-create-arg.js.flow} +5 -4
  106. package/lib/visitors/stylex-create-theme.d.ts +1 -1
  107. package/lib/visitors/stylex-create-theme.js.flow +1 -1
  108. package/lib/visitors/{stylex-create/index.d.ts → stylex-create.d.ts} +2 -2
  109. package/lib/visitors/{stylex-create/index.js.flow → stylex-create.js.flow} +3 -3
  110. package/lib/visitors/{stylex-attrs.d.ts → stylex-define-consts.d.ts} +3 -7
  111. package/lib/visitors/stylex-define-consts.js.flow +25 -0
  112. package/lib/visitors/stylex-define-vars.d.ts +1 -1
  113. package/lib/visitors/stylex-define-vars.js.flow +1 -1
  114. package/lib/visitors/stylex-keyframes.d.ts +1 -1
  115. package/lib/visitors/stylex-keyframes.js.flow +1 -1
  116. package/lib/visitors/stylex-position-try.d.ts +17 -0
  117. package/lib/visitors/stylex-position-try.js.flow +22 -0
  118. package/package.json +11 -12
  119. package/lib/babel-path-utils.d.ts +0 -1100
  120. package/lib/babel-path-utils.js.flow +0 -1108
  121. package/lib/visitors/stylex-attrs.js.flow +0 -25
package/lib/index.js.flow CHANGED
@@ -9,6 +9,7 @@
9
9
 
10
10
  import type { PluginObj } from '../flow_modules/@babel/core';
11
11
  import type { StyleXOptions } from './utils/state-manager';
12
+
12
13
  export type Options = StyleXOptions;
13
14
 
14
15
  /**
@@ -34,7 +35,16 @@ declare function stylexPluginWithOptions(
34
35
  *
35
36
  * End-users can choose to not use this function and use their own logic instead.
36
37
  */
37
- export type Rule = [string, { ltr: string, rtl?: null | string }, number];
38
+ export type Rule = [
39
+ string,
40
+ {
41
+ ltr: string,
42
+ rtl?: null | string,
43
+ constKey?: string,
44
+ constVal?: string | number,
45
+ },
46
+ number,
47
+ ];
38
48
  declare function processStylexRules(
39
49
  rules: Array<Rule>,
40
50
  useLayers: boolean,
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ export type TRawValue = number | string | ReadonlyArray<number | string>;
11
+ export type TStyleValue = null | TRawValue;
12
+ export type TNestableStyleValue = TStyleValue | PrimitiveRawStyles;
13
+ export type RawStyles = Readonly<{ [$$Key$$: string]: TNestableStyleValue }>;
14
+ export type PrimitiveRawStyles = Readonly<{
15
+ [$$Key$$: string]: TNestableStyleValue;
16
+ }>;
17
+ export type InjectableStyle = {
18
+ readonly priority: number;
19
+ readonly ltr: string;
20
+ readonly rtl: null | string;
21
+ };
22
+ export type InjectableConstStyle = {
23
+ readonly priority: number;
24
+ readonly ltr: string;
25
+ readonly rtl: null | string;
26
+ readonly constKey: string;
27
+ readonly constVal: string | number;
28
+ };
29
+ export type StyleRule = [string, string, InjectableStyle];
30
+ export type CompiledStyles = Readonly<{
31
+ [$$Key$$: string]:
32
+ | null
33
+ | string
34
+ | Readonly<{ [$$Key$$: string]: null | string }>;
35
+ }>;
36
+ export type FlatCompiledStyles = Readonly<{
37
+ [$$Key$$: string]: string | null;
38
+ $$css: true | string;
39
+ }>;
40
+ export type StyleXOptions = Readonly<{
41
+ classNamePrefix: string;
42
+ debug: null | undefined | boolean;
43
+ definedStylexCSSVariables?: { [key: string]: unknown };
44
+ dev: boolean;
45
+ enableDebugClassNames?: null | undefined | boolean;
46
+ enableDebugDataProp?: null | undefined | boolean;
47
+ enableDevClassNames?: null | undefined | boolean;
48
+ enableFontSizePxToRem?: null | undefined | boolean;
49
+ enableMinifiedKeys?: null | undefined | boolean;
50
+ styleResolution:
51
+ | 'application-order'
52
+ | 'property-specificity'
53
+ | 'legacy-expand-shorthands';
54
+ test: boolean;
55
+ }>;
56
+ export type MutableCompiledNamespaces = { [key: string]: FlatCompiledStyles };
57
+ export type CompiledNamespaces = Readonly<MutableCompiledNamespaces>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ export type TRawValue = number | string | $ReadOnlyArray<number | string>;
11
+ export type TStyleValue = null | TRawValue;
12
+ export type TNestableStyleValue = TStyleValue | PrimitiveRawStyles;
13
+
14
+ export type RawStyles = $ReadOnly<{
15
+ [string]: TNestableStyleValue,
16
+ }>;
17
+ export type PrimitiveRawStyles = $ReadOnly<{
18
+ [string]: TNestableStyleValue,
19
+ }>;
20
+
21
+ export type InjectableStyle = {
22
+ +priority: number,
23
+ +ltr: string,
24
+ +rtl: null | string,
25
+ };
26
+
27
+ export type InjectableConstStyle = {
28
+ +priority: number,
29
+ +ltr: string,
30
+ +rtl: null | string,
31
+ +constKey: string,
32
+ +constVal: string | number,
33
+ };
34
+
35
+ export type StyleRule = [string, string, InjectableStyle];
36
+
37
+ export type CompiledStyles = $ReadOnly<{
38
+ [string]: null | string | $ReadOnly<{ [string]: null | string }>,
39
+ }>;
40
+
41
+ export type FlatCompiledStyles = $ReadOnly<{
42
+ [string]: string | null,
43
+ $$css: true | string,
44
+ }>;
45
+
46
+ export type StyleXOptions = $ReadOnly<{
47
+ classNamePrefix: string,
48
+ debug: ?boolean,
49
+ definedStylexCSSVariables?: { [key: string]: mixed },
50
+ dev: boolean,
51
+ enableDebugClassNames?: ?boolean,
52
+ enableDebugDataProp?: ?boolean,
53
+ enableDevClassNames?: ?boolean,
54
+ enableFontSizePxToRem?: ?boolean,
55
+ enableMinifiedKeys?: ?boolean,
56
+ styleResolution:
57
+ | 'application-order' // The last style applied wins.
58
+ // More specific styles will win over less specific styles. (margin-top wins over margin)
59
+ | 'property-specificity'
60
+ // Legacy behavior, that expands shorthand properties into their longhand counterparts at compile-time.
61
+ // This is not recommended, and will be removed in a future version.
62
+ | 'legacy-expand-shorthands',
63
+ test: boolean,
64
+ ...
65
+ }>;
66
+
67
+ export type MutableCompiledNamespaces = {
68
+ [key: string]: FlatCompiledStyles,
69
+ };
70
+
71
+ export type CompiledNamespaces = $ReadOnly<MutableCompiledNamespaces>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: (str: string) => string;
11
+ export default $$EXPORT_DEFAULT_DECLARATION$$;
12
+ export declare const createShortHash: (str: string) => string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ declare export default (str: string) => string;
11
+
12
+ declare export const createShortHash: (str: string) => string;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type {
11
+ InjectableStyle as _InjectableStyle,
12
+ CompiledNamespaces as _CompiledNamespaces,
13
+ MutableCompiledNamespaces as _MutableCompiledNamespaces,
14
+ StyleXOptions as _StyleXOptions,
15
+ } from './common-types';
16
+ export type {
17
+ RawStyles,
18
+ StyleRule,
19
+ TNestableStyleValue,
20
+ TRawValue,
21
+ TStyleValue,
22
+ } from './common-types';
23
+ import styleXCreateSet from './stylex-create';
24
+ import styleXDefineVars from './stylex-define-vars';
25
+ import styleXDefineConsts from './stylex-define-consts';
26
+ import styleXCreateTheme from './stylex-create-theme';
27
+ import stylexKeyframes from './stylex-keyframes';
28
+ import stylexPositionTry from './stylex-position-try';
29
+ import stylexFirstThatWorks from './stylex-first-that-works';
30
+ import hash from './hash';
31
+ import genFileBasedIdentifier from './utils/file-based-identifier';
32
+ import * as m from './messages';
33
+ export * as types from './types';
34
+ import {
35
+ PSEUDO_CLASS_PRIORITIES as _PSEUDO_CLASS_PRIORITIES,
36
+ AT_RULE_PRIORITIES as _AT_RULE_PRIORITIES,
37
+ PSEUDO_ELEMENT_PRIORITY as _PSEUDO_ELEMENT_PRIORITY,
38
+ } from './utils/property-priorities';
39
+ export declare const create: typeof styleXCreateSet;
40
+ export declare const defineVars: typeof styleXDefineVars;
41
+ export declare const defineConsts: typeof styleXDefineConsts;
42
+ export declare const createTheme: typeof styleXCreateTheme;
43
+ export declare const keyframes: typeof stylexKeyframes;
44
+ export declare const positionTry: typeof stylexPositionTry;
45
+ export declare const utils: {
46
+ hash: typeof hash;
47
+ genFileBasedIdentifier: typeof genFileBasedIdentifier;
48
+ };
49
+ export declare const messages: typeof m;
50
+ export declare const firstThatWorks: typeof stylexFirstThatWorks;
51
+ export declare const PSEUDO_CLASS_PRIORITIES: typeof _PSEUDO_CLASS_PRIORITIES;
52
+ export declare const AT_RULE_PRIORITIES: typeof _AT_RULE_PRIORITIES;
53
+ export declare const PSEUDO_ELEMENT_PRIORITY: typeof _PSEUDO_ELEMENT_PRIORITY;
54
+ export type InjectableStyle = _InjectableStyle;
55
+ export type CompiledNamespaces = _CompiledNamespaces;
56
+ export type MutableCompiledNamespaces = _MutableCompiledNamespaces;
57
+ export type StyleXOptions = _StyleXOptions;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type {
11
+ InjectableStyle as _InjectableStyle,
12
+ CompiledNamespaces as _CompiledNamespaces,
13
+ MutableCompiledNamespaces as _MutableCompiledNamespaces,
14
+ StyleXOptions as _StyleXOptions,
15
+ } from './common-types';
16
+
17
+ export type {
18
+ RawStyles,
19
+ StyleRule,
20
+ TNestableStyleValue,
21
+ TRawValue,
22
+ TStyleValue,
23
+ } from './common-types';
24
+
25
+ // All functions exposed from `stylex` are defined in a way that can be run
26
+ // entirely in the browser.
27
+
28
+ // These are the implementations of those functions.
29
+
30
+ import styleXCreateSet from './stylex-create';
31
+ import styleXDefineVars from './stylex-define-vars';
32
+ import styleXDefineConsts from './stylex-define-consts';
33
+ import styleXCreateTheme from './stylex-create-theme';
34
+ import stylexKeyframes from './stylex-keyframes';
35
+ import stylexPositionTry from './stylex-position-try';
36
+ import stylexFirstThatWorks from './stylex-first-that-works';
37
+ import hash from './hash';
38
+ import genFileBasedIdentifier from './utils/file-based-identifier';
39
+ import * as m from './messages';
40
+ export * as types from './types';
41
+ import {
42
+ PSEUDO_CLASS_PRIORITIES as _PSEUDO_CLASS_PRIORITIES,
43
+ AT_RULE_PRIORITIES as _AT_RULE_PRIORITIES,
44
+ PSEUDO_ELEMENT_PRIORITY as _PSEUDO_ELEMENT_PRIORITY,
45
+ } from './utils/property-priorities';
46
+
47
+ declare export const create: typeof styleXCreateSet;
48
+ declare export const defineVars: typeof styleXDefineVars;
49
+ declare export const defineConsts: typeof styleXDefineConsts;
50
+ declare export const createTheme: typeof styleXCreateTheme;
51
+ declare export const keyframes: typeof stylexKeyframes;
52
+ declare export const positionTry: typeof stylexPositionTry;
53
+ declare export const utils: {
54
+ hash: typeof hash,
55
+ genFileBasedIdentifier: typeof genFileBasedIdentifier,
56
+ };
57
+ declare export const messages: typeof m;
58
+ declare export const firstThatWorks: typeof stylexFirstThatWorks;
59
+ declare export const PSEUDO_CLASS_PRIORITIES: typeof _PSEUDO_CLASS_PRIORITIES;
60
+ declare export const AT_RULE_PRIORITIES: typeof _AT_RULE_PRIORITIES;
61
+ declare export const PSEUDO_ELEMENT_PRIORITY: typeof _PSEUDO_ELEMENT_PRIORITY;
62
+
63
+ export type InjectableStyle = _InjectableStyle;
64
+ export type CompiledNamespaces = _CompiledNamespaces;
65
+ export type MutableCompiledNamespaces = _MutableCompiledNamespaces;
66
+ export type StyleXOptions = _StyleXOptions;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ export declare const illegalArgumentLength: (
11
+ fn: string,
12
+ argLength: number,
13
+ ) => string;
14
+ export declare const nonStaticValue: (fn: string) => string;
15
+ export declare const nonStyleObject: (fn: string) => string;
16
+ export declare const nonExportNamedDeclaration: (fn: string) => string;
17
+ export declare const unboundCallValue: (fn: string) => string;
18
+ export declare const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
19
+ export declare const ESCAPED_STYLEX_VALUE: 'Escaping a create() value is not allowed.';
20
+ export declare const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
21
+ export declare const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
22
+ export declare const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
23
+ export declare const ILLEGAL_NAMESPACE_VALUE: 'A StyleX namespace must be an object.';
24
+ export declare const INVALID_CONST_KEY: 'Keys in defineConsts() cannot start with "--".';
25
+ export declare const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
26
+ export declare const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
27
+ export declare const LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
28
+ export declare const LOCAL_ONLY: 'The return value of create() should not be exported.';
29
+ export declare const NON_OBJECT_KEYFRAME: 'Every frame within a keyframes() call must be an object.';
30
+ export declare const NON_CONTIGUOUS_VARS: 'All variables passed to firstThatWorks() must be contiguous.';
31
+ export declare const NO_OBJECT_SPREADS: 'Object spreads are not allowed in create() calls.';
32
+ export declare const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
33
+ export declare const ONLY_TOP_LEVEL: 'create() is only allowed at the root of a program.';
34
+ export declare const UNKNOWN_PROP_KEY: 'Unknown property key';
35
+ export declare const POSITION_TRY_INVALID_PROPERTY: 'Invalid property in `positionTry()` call. It may only contain, positionAnchor, positionArea, inset properties (top, left, insetInline etc.), margin properties, size properties (height, inlineSize, etc.), and self-alignment properties (alignSelf, justifySelf, placeSelf)';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ // This file contains constants to be used within Error messages.
11
+ // The URLs within will eventually be replaced by links to the documentation website for Stylex.
12
+
13
+ declare export const illegalArgumentLength: (
14
+ fn: string,
15
+ argLength: number,
16
+ ) => string;
17
+ declare export const nonStaticValue: (fn: string) => string;
18
+ declare export const nonStyleObject: (fn: string) => string;
19
+ declare export const nonExportNamedDeclaration: (fn: string) => string;
20
+ declare export const unboundCallValue: (fn: string) => string;
21
+
22
+ declare export const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
23
+ declare export const ESCAPED_STYLEX_VALUE: 'Escaping a create() value is not allowed.';
24
+ declare export const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
25
+ declare export const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
26
+ declare export const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
27
+ declare export const ILLEGAL_NAMESPACE_VALUE: 'A StyleX namespace must be an object.';
28
+ declare export const INVALID_CONST_KEY: 'Keys in defineConsts() cannot start with "--".';
29
+ declare export const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
30
+ declare export const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
31
+ declare export const LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
32
+ declare export const LOCAL_ONLY: 'The return value of create() should not be exported.';
33
+ declare export const NON_OBJECT_KEYFRAME: 'Every frame within a keyframes() call must be an object.';
34
+ declare export const NON_CONTIGUOUS_VARS: 'All variables passed to firstThatWorks() must be contiguous.';
35
+ declare export const NO_OBJECT_SPREADS: 'Object spreads are not allowed in create() calls.';
36
+ declare export const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
37
+ declare export const ONLY_TOP_LEVEL: 'create() is only allowed at the root of a program.';
38
+ declare export const UNKNOWN_PROP_KEY: 'Unknown property key';
39
+
40
+ declare export const POSITION_TRY_INVALID_PROPERTY: 'Invalid property in `positionTry()` call. It may only contain, positionAnchor, positionArea, inset properties (top, left, insetInline etc.), margin properties, size properties (height, inlineSize, etc.), and self-alignment properties (alignSelf, justifySelf, placeSelf)';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ declare function generateLTR(
11
+ pair: Readonly<[string, string]>,
12
+ ): Readonly<[string, string]>;
13
+ export default generateLTR;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ declare export default function generateLTR(
11
+ pair: $ReadOnly<[string, string]>,
12
+ ): $ReadOnly<[string, string]>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ declare function generateRTL(
11
+ $$PARAM_0$$: Readonly<[string, string]>,
12
+ ): null | undefined | Readonly<[string, string]>;
13
+ export default generateRTL;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ declare export default function generateRTL(
11
+ $ReadOnly<[string, string]>,
12
+ ): ?$ReadOnly<[string, string]>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { InjectableStyle, StyleXOptions } from '../common-types';
11
+ export type ClassesToOriginalPaths = {
12
+ readonly [className: string]: ReadonlyArray<string>;
13
+ };
14
+ export type ComputedStyle = null | Readonly<
15
+ [string, InjectableStyle, ClassesToOriginalPaths]
16
+ >;
17
+ export interface IPreRule {
18
+ compiled(options: StyleXOptions): ReadonlyArray<ComputedStyle>;
19
+ equals(other: IPreRule): boolean;
20
+ }
21
+ export type AnyPreRule = NullPreRule | PreRule | PreRuleSet;
22
+ export declare class NullPreRule implements IPreRule {
23
+ compiled(_options: StyleXOptions): [null];
24
+ equals(other: IPreRule): boolean;
25
+ }
26
+ export declare class PreRule implements IPreRule {
27
+ readonly property: string;
28
+ readonly value: string | number | ReadonlyArray<string | number>;
29
+ readonly keyPath: ReadonlyArray<string>;
30
+ constructor(
31
+ property: string,
32
+ value: string | number | ReadonlyArray<string | number>,
33
+ keyPath?: ReadonlyArray<string>,
34
+ );
35
+ get pseudos(): ReadonlyArray<string>;
36
+ get atRules(): ReadonlyArray<string>;
37
+ get constRules(): ReadonlyArray<string>;
38
+ compiled(
39
+ options: StyleXOptions,
40
+ ): ReadonlyArray<[string, InjectableStyle, ClassesToOriginalPaths]>;
41
+ equals(other: IPreRule): boolean;
42
+ }
43
+ export declare class PreRuleSet implements IPreRule {
44
+ readonly rules: ReadonlyArray<PreRule | NullPreRule>;
45
+ constructor(rules: ReadonlyArray<PreRule | NullPreRule>);
46
+ static create(
47
+ rules: ReadonlyArray<PreRule | NullPreRule | PreRuleSet>,
48
+ ): AnyPreRule;
49
+ compiled(options: StyleXOptions): ReadonlyArray<ComputedStyle>;
50
+ equals(other: IPreRule): boolean;
51
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { InjectableStyle, StyleXOptions } from '../common-types';
11
+
12
+ export type ClassesToOriginalPaths = {
13
+ +[className: string]: $ReadOnlyArray<string>,
14
+ };
15
+
16
+ export type ComputedStyle = null | $ReadOnly<
17
+ [string, InjectableStyle, ClassesToOriginalPaths],
18
+ >;
19
+
20
+ // The classes in this file are used to represent objects that
21
+ // can be compiled into one or CSS rules.
22
+ //
23
+ // These are thin wrappers around the "values" in Raw Style Objects
24
+ // with all the metadata needed to compile them into CSS.
25
+ export interface IPreRule {
26
+ compiled(options: StyleXOptions): $ReadOnlyArray<ComputedStyle>;
27
+ equals(other: IPreRule): boolean;
28
+ }
29
+
30
+ export type AnyPreRule = NullPreRule | PreRule | PreRuleSet;
31
+
32
+ declare export class NullPreRule implements IPreRule {
33
+ compiled(_options: StyleXOptions): [null];
34
+ equals(other: IPreRule): boolean;
35
+ }
36
+
37
+ declare export class PreRule implements IPreRule {
38
+ +property: string;
39
+ +value: string | number | $ReadOnlyArray<string | number>;
40
+ +keyPath: $ReadOnlyArray<string>;
41
+ constructor(
42
+ property: string,
43
+ value: string | number | $ReadOnlyArray<string | number>,
44
+ keyPath?: $ReadOnlyArray<string>,
45
+ ): void;
46
+ get pseudos(): $ReadOnlyArray<string>;
47
+ get atRules(): $ReadOnlyArray<string>;
48
+ get constRules(): $ReadOnlyArray<string>;
49
+ compiled(
50
+ options: StyleXOptions,
51
+ ): $ReadOnlyArray<[string, InjectableStyle, ClassesToOriginalPaths]>;
52
+ equals(other: IPreRule): boolean;
53
+ }
54
+
55
+ declare export class PreRuleSet implements IPreRule {
56
+ +rules: $ReadOnlyArray<PreRule | NullPreRule>;
57
+ constructor(rules: $ReadOnlyArray<PreRule | NullPreRule>): void;
58
+ static create(
59
+ rules: $ReadOnlyArray<PreRule | NullPreRule | PreRuleSet>,
60
+ ): AnyPreRule;
61
+ compiled(options: StyleXOptions): $ReadOnlyArray<ComputedStyle>;
62
+ equals(other: IPreRule): boolean;
63
+ }