@stylexjs/shared 0.2.0-beta.10 → 0.2.0-beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/lib/common-types.d.ts +49 -0
  2. package/lib/common-types.js.flow +64 -0
  3. package/lib/convert-to-className.d.ts +16 -0
  4. package/lib/convert-to-className.js.flow +23 -0
  5. package/lib/generate-css-rule.d.ts +17 -0
  6. package/lib/generate-css-rule.js.flow +17 -0
  7. package/lib/hash.d.ts +11 -0
  8. package/lib/hash.js.flow +12 -0
  9. package/lib/index.d.ts +32 -95
  10. package/lib/index.js.flow +46 -3
  11. package/lib/messages.d.ts +32 -0
  12. package/lib/messages.js.flow +35 -0
  13. package/lib/physical-rtl/generate-ltr.d.ts +12 -0
  14. package/lib/physical-rtl/generate-ltr.js.flow +13 -0
  15. package/lib/physical-rtl/generate-rtl.d.ts +14 -0
  16. package/lib/physical-rtl/generate-rtl.js.flow +13 -0
  17. package/lib/preprocess-rules/PreRule.d.ts +52 -0
  18. package/lib/preprocess-rules/PreRule.js.flow +64 -0
  19. package/lib/preprocess-rules/application-order.d.ts +253 -0
  20. package/lib/preprocess-rules/application-order.js.flow +206 -0
  21. package/lib/preprocess-rules/basic-validation.d.ts +13 -0
  22. package/lib/preprocess-rules/basic-validation.js +3 -3
  23. package/lib/preprocess-rules/basic-validation.js.flow +13 -0
  24. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +25 -0
  25. package/lib/preprocess-rules/flatten-raw-style-obj.js +5 -5
  26. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +27 -0
  27. package/lib/preprocess-rules/index.d.ts +18 -0
  28. package/lib/preprocess-rules/index.js.flow +19 -0
  29. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +122 -0
  30. package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -139
  31. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +101 -0
  32. package/lib/preprocess-rules/property-specificity.d.ts +76 -0
  33. package/lib/preprocess-rules/property-specificity.js.flow +87 -0
  34. package/lib/stylex-create-vars.d.ts +27 -0
  35. package/lib/stylex-create-vars.js +59 -0
  36. package/lib/stylex-create-vars.js.flow +22 -0
  37. package/lib/stylex-create.d.ts +23 -0
  38. package/lib/stylex-create.js.flow +30 -0
  39. package/lib/stylex-first-that-works.d.ts +14 -0
  40. package/lib/stylex-first-that-works.js.flow +13 -0
  41. package/lib/stylex-include.d.ts +19 -0
  42. package/lib/stylex-include.js.flow +21 -0
  43. package/lib/stylex-keyframes.d.ts +17 -0
  44. package/lib/stylex-keyframes.js.flow +20 -0
  45. package/lib/transform-value.d.ts +13 -0
  46. package/lib/transform-value.js.flow +15 -0
  47. package/lib/utils/Rule.d.ts +58 -0
  48. package/lib/utils/Rule.js.flow +64 -0
  49. package/lib/utils/dashify.d.ts +10 -0
  50. package/lib/utils/dashify.js.flow +9 -0
  51. package/lib/utils/default-options.d.ts +10 -0
  52. package/lib/utils/default-options.js.flow +24 -0
  53. package/lib/utils/file-based-identifier.d.ts +14 -0
  54. package/lib/utils/file-based-identifier.js +22 -0
  55. package/lib/utils/file-based-identifier.js.flow +13 -0
  56. package/lib/utils/genCSSRule.d.ts +16 -0
  57. package/lib/utils/genCSSRule.js.flow +16 -0
  58. package/lib/utils/normalize-value.d.ts +12 -0
  59. package/lib/utils/normalize-value.js.flow +14 -0
  60. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  61. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  62. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  63. package/lib/utils/normalizers/font-size-px-to-rem.js +9 -4
  64. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  65. package/lib/utils/normalizers/leading-zero.d.ts +17 -0
  66. package/lib/utils/normalizers/leading-zero.js.flow +16 -0
  67. package/lib/utils/normalizers/quotes.d.ts +19 -0
  68. package/lib/utils/normalizers/quotes.js.flow +18 -0
  69. package/lib/utils/normalizers/timings.d.ts +19 -0
  70. package/lib/utils/normalizers/timings.js.flow +18 -0
  71. package/lib/utils/normalizers/whitespace.d.ts +20 -0
  72. package/lib/utils/normalizers/whitespace.js.flow +19 -0
  73. package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
  74. package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
  75. package/lib/utils/object-utils.d.ts +61 -0
  76. package/lib/utils/object-utils.js.flow +81 -0
  77. package/lib/utils/property-priorities.d.ts +11 -0
  78. package/lib/utils/property-priorities.js.flow +10 -0
  79. package/lib/utils/split-css-value.d.ts +15 -0
  80. package/lib/utils/split-css-value.js.flow +16 -0
  81. package/lib/validate.d.ts +12 -0
  82. package/lib/validate.js.flow +12 -0
  83. package/package.json +4 -4
  84. package/lib/expand-shorthands.d.ts +0 -5
  85. package/lib/expand-shorthands.js +0 -330
  86. package/lib/namespace-transforms/__tests__/preflatten.test.js +0 -120
  87. package/lib/namespace-transforms/preflatten.js +0 -89
  88. package/lib/preprocess-rules/expand-shorthands.js +0 -156
  89. package/lib/preprocess-rules/null-out-longhand.js +0 -310
  90. package/lib/preprocess-rules/react-native-web.js +0 -142
  91. package/lib/stylex-defaultValue.js +0 -397
@@ -0,0 +1,49 @@
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 { IncludedStyles } from './stylex-include';
11
+ export type TRawValue = number | string | ReadonlyArray<number | string>;
12
+ export type TStyleValue = null | TRawValue;
13
+ export type TNestableStyleValue = TStyleValue | PrimitiveRawStyles;
14
+ export type RawStyles = Readonly<{
15
+ [$$Key$$: string]: TNestableStyleValue | IncludedStyles;
16
+ }>;
17
+ export type PrimitiveRawStyles = Readonly<{
18
+ [$$Key$$: string]: TNestableStyleValue;
19
+ }>;
20
+ export type InjectableStyle = {
21
+ readonly priority: number;
22
+ readonly ltr: string;
23
+ readonly rtl: null | string;
24
+ };
25
+ export type StyleRule = [string, string, InjectableStyle];
26
+ export type CompiledStyles = Readonly<{
27
+ [$$Key$$: string]:
28
+ | IncludedStyles
29
+ | null
30
+ | string
31
+ | Readonly<{ [$$Key$$: string]: null | string }>;
32
+ }>;
33
+ export type FlatCompiledStyles = Readonly<{
34
+ [$$Key$$: string]: string | IncludedStyles | null;
35
+ $$css: true;
36
+ }>;
37
+ export type StyleXOptions = {
38
+ dev: boolean;
39
+ test: boolean;
40
+ stylexSheetName?: string | void;
41
+ classNamePrefix: string;
42
+ definedStylexCSSVariables?: { [key: string]: unknown };
43
+ styleResolution:
44
+ | 'application-order'
45
+ | 'property-specificity'
46
+ | 'legacy-expand-shorthands';
47
+ };
48
+ export type MutableCompiledNamespaces = { [key: string]: FlatCompiledStyles };
49
+ export type CompiledNamespaces = Readonly<MutableCompiledNamespaces>;
@@ -0,0 +1,64 @@
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 { IncludedStyles } from './stylex-include';
11
+
12
+ export type TRawValue = number | string | $ReadOnlyArray<number | string>;
13
+ export type TStyleValue = null | TRawValue;
14
+ export type TNestableStyleValue = TStyleValue | PrimitiveRawStyles;
15
+
16
+ export type RawStyles = $ReadOnly<{
17
+ [string]: TNestableStyleValue | IncludedStyles,
18
+ }>;
19
+ export type PrimitiveRawStyles = $ReadOnly<{
20
+ [string]: TNestableStyleValue,
21
+ }>;
22
+
23
+ export type InjectableStyle = {
24
+ +priority: number,
25
+ +ltr: string,
26
+ +rtl: null | string,
27
+ };
28
+
29
+ export type StyleRule = [string, string, InjectableStyle];
30
+
31
+ export type CompiledStyles = $ReadOnly<{
32
+ [string]:
33
+ | IncludedStyles
34
+ | null
35
+ | string
36
+ | $ReadOnly<{ [string]: null | string }>,
37
+ }>;
38
+
39
+ export type FlatCompiledStyles = $ReadOnly<{
40
+ [string]: string | IncludedStyles | null,
41
+ $$css: true,
42
+ }>;
43
+
44
+ export type StyleXOptions = {
45
+ dev: boolean,
46
+ test: boolean,
47
+ stylexSheetName?: string | void,
48
+ classNamePrefix: string,
49
+ definedStylexCSSVariables?: { [key: string]: mixed },
50
+ styleResolution:
51
+ | 'application-order' // The last style applied wins.
52
+ // More specific styles will win over less specific styles. (margin-top wins over margin)
53
+ | 'property-specificity'
54
+ // Legacy behavior, that expands shorthand properties into their longhand counterparts at compile-time.
55
+ // This is not recommended, and will be removed in a future version.
56
+ | 'legacy-expand-shorthands',
57
+ ...
58
+ };
59
+
60
+ export type MutableCompiledNamespaces = {
61
+ [key: string]: FlatCompiledStyles,
62
+ };
63
+
64
+ export type CompiledNamespaces = $ReadOnly<MutableCompiledNamespaces>;
@@ -0,0 +1,16 @@
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 { TRawValue, StyleRule, StyleXOptions } from './common-types';
11
+ export declare function convertStyleToClassName(
12
+ objEntry: [string, TRawValue],
13
+ pseudos: ReadonlyArray<string>,
14
+ atRules: ReadonlyArray<string>,
15
+ $$PARAM_3$$: StyleXOptions
16
+ ): StyleRule;
@@ -0,0 +1,23 @@
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 { TRawValue, StyleRule, StyleXOptions } from './common-types';
11
+ // This function takes a single style rule and transforms it into a CSS rule.
12
+ // [color: 'red'] => ['color', 'classname-for-color-red', CSSRULE{ltr, rtl, priority}]
13
+ //
14
+ // It converts the camelCased style key to a dash-separated key.
15
+ // Handles RTL-flipping
16
+ // Hashes to get a className
17
+ // Returns the final key, className a CSS Rule
18
+ declare export function convertStyleToClassName(
19
+ objEntry: [string, TRawValue],
20
+ pseudos: $ReadOnlyArray<string>,
21
+ atRules: $ReadOnlyArray<string>,
22
+ StyleXOptions
23
+ ): StyleRule;
@@ -0,0 +1,17 @@
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 } from './common-types';
11
+ export declare function generateRule(
12
+ className: string,
13
+ key: string,
14
+ value: string | ReadonlyArray<string>,
15
+ pseudos: ReadonlyArray<string>,
16
+ atRules: ReadonlyArray<string>
17
+ ): InjectableStyle;
@@ -0,0 +1,17 @@
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 } from './common-types';
11
+ declare export function generateRule(
12
+ className: string,
13
+ key: string,
14
+ value: string | $ReadOnlyArray<string>,
15
+ pseudos: $ReadOnlyArray<string>,
16
+ atRules: $ReadOnlyArray<string>
17
+ ): InjectableStyle;
package/lib/hash.d.ts ADDED
@@ -0,0 +1,11 @@
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 var hash: (str: string) => string;
11
+ export default hash;
@@ -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 var hash: (str: string) => string;
11
+
12
+ declare export default hash;
package/lib/index.d.ts CHANGED
@@ -3,100 +3,37 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
6
8
  */
7
9
 
8
- export type TRawValue = number | string | Array<number | string>;
9
-
10
- export type TStyleValue = number | string | Array<number | string>;
11
- export type TNestableStyleValue =
12
- | TStyleValue
13
- | { readonly [key: string]: TStyleValue };
14
-
15
- export type RawStyles = $ReadOnly<{
16
- [key: string]: TNestableStyleValue;
17
- }>;
18
-
19
- export type InjectableStyle = {
20
- readonly priority: number;
21
- readonly ltr: string;
22
- readonly rtl?: string;
23
- };
24
-
25
- export type StyleRule = readonly [string, string, InjectableStyle];
26
-
27
- export type CompiledStyles = {
28
- readonly [key: string]: string | null;
29
- readonly $$css: true;
30
- };
31
- export type MutableCompiledStyles = {
32
- [key: string]: string | null;
33
- $$css: true;
34
- };
35
-
36
- export type CompiledNamespaces = { readonly [key: string]: CompiledStyles };
37
-
38
- export type MutableCompiledNamespaces = {
39
- [key: string]: MutableCompiledStyles;
40
- };
41
-
42
- export function create<N extends { readonly [key: string]: RawStyles }>(
43
- namespaces: N,
44
- options?: StyleXOptions
45
- ): readonly [CompiledNamespaces, { readonly [key: string]: InjectableStyle }];
46
-
47
- export function keyframes<
48
- Obj extends {
49
- readonly [key: string]: { readonly [k: string]: string | number };
50
- }
51
- >(animation: Obj, options?: StyleXOptions): readonly [string, InjectableStyle];
52
-
53
- export function include(animation: {
54
- readonly [key: string]: string | number;
55
- }): readonly { [key: string]: IncludedStyles };
56
-
57
- export class IncludedStyles {
58
- astNode: any;
59
- }
60
-
61
- export type StyleXOptions = {
62
- dev: boolean;
63
- test: boolean;
64
- stylexSheetName?: string | undefined;
65
- classNamePrefix: string;
66
- definedStylexCSSVariables?: { [key: string]: any };
67
- styleResolution:
68
- | 'application-order' // The last style applied wins.
69
- // More specific styles will win over less specific styles. (margin-top wins over margin)
70
- | 'property-specificity'
71
- // Legacy behavior, that expands shorthand properties into their longhand counterparts at compile-time.
72
- // This is not recommended, and will be removed in a future version.
73
- | 'legacy-expand-shorthands';
74
- [key: string]: any;
75
- };
76
-
77
- export function firstThatWorks<T>(...args: T[]): T[];
78
-
79
- export const messages: {
80
- ILLEGAL_ARGUMENT_LENGTH: string;
81
- NON_STATIC_VALUE: string;
82
- ESCAPED_STYLEX_VALUE: string;
83
- UNBOUND_STYLEX_CALL_VALUE: string;
84
- ONLY_TOP_LEVEL: string;
85
- NON_OBJECT_FOR_STYLEX_CALL: string;
86
- UNKNOWN_PROP_KEY: string;
87
- INVALID_PSEUDO: string;
88
- ILLEGAL_NAMESPACE_TYPE: string;
89
- UNKNOWN_NAMESPACE: string;
90
- ILLEGAL_NESTED_PSEUDO: string;
91
- ILLEGAL_PROP_VALUE: string;
92
- ILLEGAL_PROP_ARRAY_VALUE: string;
93
- ILLEGAL_NAMESPACE_VALUE: string;
94
- INVALID_SPREAD: string;
95
- LINT_UNCLOSED_FUNCTION: string;
96
- LOCAL_ONLY: string;
97
- UNEXPECTED_ARGUMENT: string;
98
- EXPECTED_FUNCTION_CALL: string;
99
- INVALID_PSEUDO_OR_AT_RULE: string;
100
- ONLY_TOP_LEVEL_INLCUDES: string;
101
- DUPLICATE_CONDITIONAL: string;
102
- };
10
+ export type {
11
+ RawStyles,
12
+ StyleRule,
13
+ TNestableStyleValue,
14
+ TRawValue,
15
+ TStyleValue,
16
+ } from './common-types';
17
+ import styleXCreateSet from './stylex-create';
18
+ import stylexKeyframes from './stylex-keyframes';
19
+ import stylexInclude, {
20
+ IncludedStyles as _IncludedStyles,
21
+ } from './stylex-include';
22
+ import stylexFirstThatWorks from './stylex-first-that-works';
23
+ import * as m from './messages';
24
+ import type {
25
+ InjectableStyle as _InjectableStyle,
26
+ CompiledNamespaces as _CompiledNamespaces,
27
+ MutableCompiledNamespaces as _MutableCompiledNamespaces,
28
+ StyleXOptions as _StyleXOptions,
29
+ } from './common-types';
30
+ export declare var create: typeof styleXCreateSet;
31
+ export declare var keyframes: typeof stylexKeyframes;
32
+ export declare var include: typeof stylexInclude;
33
+ export declare var messages: typeof m;
34
+ export declare var IncludedStyles: typeof _IncludedStyles;
35
+ export declare var firstThatWorks: typeof stylexFirstThatWorks;
36
+ export type InjectableStyle = _InjectableStyle;
37
+ export type CompiledNamespaces = _CompiledNamespaces;
38
+ export type MutableCompiledNamespaces = _MutableCompiledNamespaces;
39
+ export type StyleXOptions = _StyleXOptions;
package/lib/index.js.flow CHANGED
@@ -1,5 +1,48 @@
1
1
  /**
2
- * Flowtype definitions for index.js
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
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
5
8
  */
9
+
10
+ export type {
11
+ RawStyles,
12
+ StyleRule,
13
+ TNestableStyleValue,
14
+ TRawValue,
15
+ TStyleValue,
16
+ } from './common-types';
17
+
18
+ // All functions exposed from `stylex` are defined in a way that can be run
19
+ // entirely in the browser.
20
+
21
+ // These are the implementations of those functions.
22
+
23
+ import styleXCreateSet from './stylex-create';
24
+ import stylexKeyframes from './stylex-keyframes';
25
+ import stylexInclude, {
26
+ IncludedStyles as _IncludedStyles,
27
+ } from './stylex-include';
28
+ import stylexFirstThatWorks from './stylex-first-that-works';
29
+ import * as m from './messages';
30
+
31
+ import type {
32
+ InjectableStyle as _InjectableStyle,
33
+ CompiledNamespaces as _CompiledNamespaces,
34
+ MutableCompiledNamespaces as _MutableCompiledNamespaces,
35
+ StyleXOptions as _StyleXOptions,
36
+ } from './common-types';
37
+
38
+ declare export var create: typeof styleXCreateSet;
39
+ declare export var keyframes: typeof stylexKeyframes;
40
+ declare export var include: typeof stylexInclude;
41
+ declare export var messages: typeof m;
42
+ declare export var IncludedStyles: typeof _IncludedStyles;
43
+ declare export var firstThatWorks: typeof stylexFirstThatWorks;
44
+
45
+ export type InjectableStyle = _InjectableStyle;
46
+ export type CompiledNamespaces = _CompiledNamespaces;
47
+ export type MutableCompiledNamespaces = _MutableCompiledNamespaces;
48
+ export type StyleXOptions = _StyleXOptions;
@@ -0,0 +1,32 @@
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
+ export declare var ILLEGAL_ARGUMENT_LENGTH: 'stylex() should have 1 argument.';
10
+ export declare var NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
11
+ export declare var ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
12
+ export declare var UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
13
+ export declare var ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
14
+ export declare var NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
15
+ export declare var UNKNOWN_PROP_KEY: 'Unknown property key';
16
+ export declare var INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
17
+ export declare var INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
18
+ export declare var NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
19
+ export declare var ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
20
+ export declare var UNKNOWN_NAMESPACE: 'Unknown namespace';
21
+ export declare var ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
22
+ export declare var ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
23
+ export declare var ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
24
+ export declare var ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
25
+ export declare var INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
26
+ export declare var LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
27
+ export declare var LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
28
+ export declare var UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
29
+ export declare var EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
30
+ export declare var NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
31
+ export declare var ONLY_TOP_LEVEL_INLCUDES: 'stylex.include() is only at the top level of a style definition object.';
32
+ export declare var DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
@@ -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
+ * @flow strict
7
+ */
8
+
9
+ // This file contains constants to be used within Error messages.
10
+ // The URLs within will eventually be replaced by links to the documenation website for Stylex.
11
+
12
+ declare export var ILLEGAL_ARGUMENT_LENGTH: 'stylex() should have 1 argument.';
13
+ declare export var NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
14
+ declare export var ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
15
+ declare export var UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
16
+ declare export var ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
17
+ declare export var NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
18
+ declare export var UNKNOWN_PROP_KEY: 'Unknown property key';
19
+ declare export var INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
20
+ declare export var INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
21
+ declare export var NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
22
+ declare export var ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
23
+ declare export var UNKNOWN_NAMESPACE: 'Unknown namespace';
24
+ declare export var ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
25
+ declare export var ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
26
+ declare export var ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
27
+ declare export var ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
28
+ declare export var INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
29
+ declare export var LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
30
+ declare export var LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
31
+ declare export var UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
32
+ declare export var EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
33
+ declare export var NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
34
+ declare export var ONLY_TOP_LEVEL_INLCUDES: 'stylex.include() is only at the top level of a style definition object.';
35
+ declare export var DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
@@ -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
+
11
+ declare function generateLTR(pair: [string, string]): [string, string];
12
+ export default generateLTR;
@@ -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
+ * @flow strict
8
+ *
9
+ */
10
+
11
+ declare export default function generateLTR(
12
+ pair: [string, string]
13
+ ): [string, string];
@@ -0,0 +1,14 @@
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
+
11
+ declare function generateRTL(
12
+ $$PARAM_0$$: [string, string]
13
+ ): null | undefined | [string, string];
14
+ export default generateRTL;
@@ -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
+ * @flow strict
8
+ *
9
+ */
10
+
11
+ declare export default function generateRTL(
12
+ [string, string]
13
+ ): ?[string, string];
@@ -0,0 +1,52 @@
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
+ import type { IncludedStyles } from '../stylex-include';
12
+ export type ComputedStyle = null | Readonly<[string, InjectableStyle]>;
13
+ export interface IPreRule {
14
+ compiled(
15
+ options: StyleXOptions
16
+ ): IncludedStyles | ReadonlyArray<ComputedStyle>;
17
+ equals(other: IPreRule): boolean;
18
+ }
19
+ export type AnyPreRule = NullPreRule | PreRule | PreRuleSet;
20
+ export declare class NullPreRule implements IPreRule {
21
+ compiled(_options: StyleXOptions): [null];
22
+ equals(other: IPreRule): boolean;
23
+ }
24
+ export declare class PreIncludedStylesRule implements IPreRule {
25
+ readonly includedStyles: IncludedStyles;
26
+ constructor(IncludedStyles: IncludedStyles);
27
+ equals(other: IPreRule): boolean;
28
+ compiled(_options: StyleXOptions): IncludedStyles;
29
+ }
30
+ export declare class PreRule implements IPreRule {
31
+ readonly property: string;
32
+ readonly value: string | number | ReadonlyArray<string | number>;
33
+ readonly pseudos: ReadonlyArray<string>;
34
+ readonly atRules: ReadonlyArray<string>;
35
+ constructor(
36
+ property: string,
37
+ value: string | number | ReadonlyArray<string | number>,
38
+ pseudos?: null | undefined | ReadonlyArray<string>,
39
+ atRules?: null | undefined | ReadonlyArray<string>
40
+ );
41
+ compiled(options: StyleXOptions): ReadonlyArray<[string, InjectableStyle]>;
42
+ equals(other: IPreRule): boolean;
43
+ }
44
+ export declare class PreRuleSet implements IPreRule {
45
+ readonly rules: ReadonlyArray<PreRule | NullPreRule>;
46
+ constructor(rules: ReadonlyArray<PreRule | NullPreRule>);
47
+ static create(
48
+ rules: ReadonlyArray<PreRule | NullPreRule | PreRuleSet>
49
+ ): AnyPreRule;
50
+ compiled(options: StyleXOptions): ReadonlyArray<ComputedStyle>;
51
+ equals(other: IPreRule): boolean;
52
+ }
@@ -0,0 +1,64 @@
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
+ import type { IncludedStyles } from '../stylex-include';
12
+
13
+ export type ComputedStyle = null | $ReadOnly<[string, InjectableStyle]>;
14
+
15
+ // The classes in this file are used to represent objects that
16
+ // can be compiled into one or CSS rules.
17
+ //
18
+ // These are thin wrappers around the "values" in Raw Style Objects
19
+ // with all the metadata needed to compile them into CSS.
20
+ export interface IPreRule {
21
+ compiled(
22
+ options: StyleXOptions
23
+ ): IncludedStyles | $ReadOnlyArray<ComputedStyle>;
24
+ equals(other: IPreRule): boolean;
25
+ }
26
+
27
+ export type AnyPreRule = NullPreRule | PreRule | PreRuleSet;
28
+
29
+ declare export class NullPreRule implements IPreRule {
30
+ compiled(_options: StyleXOptions): [null];
31
+ equals(other: IPreRule): boolean;
32
+ }
33
+
34
+ declare export class PreIncludedStylesRule implements IPreRule {
35
+ +includedStyles: IncludedStyles;
36
+ constructor(IncludedStyles: IncludedStyles): void;
37
+ equals(other: IPreRule): boolean;
38
+ compiled(_options: StyleXOptions): IncludedStyles;
39
+ }
40
+
41
+ declare export class PreRule implements IPreRule {
42
+ +property: string;
43
+ +value: string | number | $ReadOnlyArray<string | number>;
44
+ +pseudos: $ReadOnlyArray<string>;
45
+ +atRules: $ReadOnlyArray<string>;
46
+ constructor(
47
+ property: string,
48
+ value: string | number | $ReadOnlyArray<string | number>,
49
+ pseudos?: ?$ReadOnlyArray<string>,
50
+ atRules?: ?$ReadOnlyArray<string>
51
+ ): void;
52
+ compiled(options: StyleXOptions): $ReadOnlyArray<[string, InjectableStyle]>;
53
+ equals(other: IPreRule): boolean;
54
+ }
55
+
56
+ declare export class PreRuleSet implements IPreRule {
57
+ +rules: $ReadOnlyArray<PreRule | NullPreRule>;
58
+ constructor(rules: $ReadOnlyArray<PreRule | NullPreRule>): void;
59
+ static create(
60
+ rules: $ReadOnlyArray<PreRule | NullPreRule | PreRuleSet>
61
+ ): AnyPreRule;
62
+ compiled(options: StyleXOptions): $ReadOnlyArray<ComputedStyle>;
63
+ equals(other: IPreRule): boolean;
64
+ }