@stylexjs/shared 0.10.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common-types.d.ts +8 -11
- package/lib/common-types.js.flow +9 -14
- package/lib/convert-to-className.js +3 -2
- package/lib/index.d.ts +0 -5
- package/lib/index.js +1 -4
- package/lib/index.js.flow +0 -5
- package/lib/messages.d.ts +0 -1
- package/lib/messages.js +1 -2
- package/lib/messages.js.flow +0 -1
- package/lib/preprocess-rules/PreRule.d.ts +1 -10
- package/lib/preprocess-rules/PreRule.js +1 -13
- package/lib/preprocess-rules/PreRule.js.flow +1 -11
- package/lib/preprocess-rules/basic-validation.js +0 -10
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +2 -6
- package/lib/preprocess-rules/flatten-raw-style-obj.js +0 -8
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +3 -6
- package/lib/stylex-create.js +13 -18
- package/lib/utils/default-options.js +1 -0
- package/lib/utils/object-utils.d.ts +1 -2
- package/lib/utils/object-utils.js +0 -3
- package/lib/utils/object-utils.js.flow +1 -3
- package/package.json +11 -2
- package/lib/properties/CSS Animations.json +0 -445
- package/lib/properties/CSS Backgrounds and Borders.json +0 -1085
- package/lib/properties/CSS Basic User Interface.json +0 -365
- package/lib/properties/CSS Box Alignment.json +0 -245
- package/lib/properties/CSS Box Model.json +0 -501
- package/lib/properties/CSS Color.json +0 -100
- package/lib/properties/CSS Columns.json +0 -185
- package/lib/properties/CSS Containment.json +0 -203
- package/lib/properties/CSS Counter Styles.json +0 -56
- package/lib/properties/CSS Display.json +0 -20
- package/lib/properties/CSS Flexible Box Layout.json +0 -167
- package/lib/properties/CSS Fonts.json +0 -684
- package/lib/properties/CSS Fragmentation.json +0 -110
- package/lib/properties/CSS Generated Content.json +0 -38
- package/lib/properties/CSS Grid Layout.json +0 -500
- package/lib/properties/CSS Images.json +0 -91
- package/lib/properties/CSS Inline.json +0 -38
- package/lib/properties/CSS Lists and Counters.json +0 -86
- package/lib/properties/CSS Logical Properties.json +0 -1086
- package/lib/properties/CSS Masking.json +0 -399
- package/lib/properties/CSS Miscellaneous.json +0 -38
- package/lib/properties/CSS Motion Path.json +0 -132
- package/lib/properties/CSS Overflow.json +0 -216
- package/lib/properties/CSS Pages.json +0 -83
- package/lib/properties/CSS Positioning.json +0 -166
- package/lib/properties/CSS Ruby.json +0 -55
- package/lib/properties/CSS Scroll Anchoring.json +0 -19
- package/lib/properties/CSS Scroll Snap.json +0 -604
- package/lib/properties/CSS Scrollbars.json +0 -38
- package/lib/properties/CSS Shapes.json +0 -56
- package/lib/properties/CSS Speech.json +0 -20
- package/lib/properties/CSS Table.json +0 -115
- package/lib/properties/CSS Text Decoration.json +0 -312
- package/lib/properties/CSS Text.json +0 -415
- package/lib/properties/CSS Transforms.json +0 -188
- package/lib/properties/CSS Transitions.json +0 -122
- package/lib/properties/CSS Variables.json +0 -20
- package/lib/properties/CSS View Transitions.json +0 -20
- package/lib/properties/CSS Will Change.json +0 -20
- package/lib/properties/CSS Writing Modes.json +0 -92
- package/lib/properties/Compositing and Blending.json +0 -62
- package/lib/properties/Filter Effects.json +0 -38
- package/lib/properties/MathML.json +0 -56
- package/lib/properties/Microsoft Extensions.json +0 -885
- package/lib/properties/Mozilla Extensions.json +0 -607
- package/lib/properties/Pointer Events.json +0 -20
- package/lib/properties/WebKit Extensions.json +0 -707
- package/lib/properties.json +0 -10122
- package/lib/utils/normalizers/convert-camel-case-transition-props.d.ts +0 -14
- package/lib/utils/normalizers/convert-camel-case-transition-props.js +0 -23
- package/lib/utils/normalizers/convert-camel-case-transition-props.js.flow +0 -13
package/lib/common-types.d.ts
CHANGED
@@ -7,13 +7,10 @@
|
|
7
7
|
*
|
8
8
|
*/
|
9
9
|
|
10
|
-
import type { IncludedStyles } from './stylex-include';
|
11
10
|
export type TRawValue = number | string | ReadonlyArray<number | string>;
|
12
11
|
export type TStyleValue = null | TRawValue;
|
13
12
|
export type TNestableStyleValue = TStyleValue | PrimitiveRawStyles;
|
14
|
-
export type RawStyles = Readonly<{
|
15
|
-
[$$Key$$: string]: TNestableStyleValue | IncludedStyles;
|
16
|
-
}>;
|
13
|
+
export type RawStyles = Readonly<{ [$$Key$$: string]: TNestableStyleValue }>;
|
17
14
|
export type PrimitiveRawStyles = Readonly<{
|
18
15
|
[$$Key$$: string]: TNestableStyleValue;
|
19
16
|
}>;
|
@@ -25,26 +22,26 @@ export type InjectableStyle = {
|
|
25
22
|
export type StyleRule = [string, string, InjectableStyle];
|
26
23
|
export type CompiledStyles = Readonly<{
|
27
24
|
[$$Key$$: string]:
|
28
|
-
| IncludedStyles
|
29
25
|
| null
|
30
26
|
| string
|
31
27
|
| Readonly<{ [$$Key$$: string]: null | string }>;
|
32
28
|
}>;
|
33
29
|
export type FlatCompiledStyles = Readonly<{
|
34
|
-
[$$Key$$: string]: string |
|
35
|
-
$$css: true;
|
30
|
+
[$$Key$$: string]: string | null;
|
31
|
+
$$css: true | string;
|
36
32
|
}>;
|
37
33
|
export type StyleXOptions = Readonly<{
|
38
|
-
dev: boolean;
|
39
|
-
debug: null | undefined | boolean;
|
40
|
-
test: boolean;
|
41
|
-
useRemForFontSize: boolean;
|
42
34
|
classNamePrefix: string;
|
35
|
+
debug: null | undefined | boolean;
|
36
|
+
enableDebugClassNames?: null | undefined | boolean;
|
43
37
|
definedStylexCSSVariables?: { [key: string]: unknown };
|
38
|
+
dev: boolean;
|
44
39
|
styleResolution:
|
45
40
|
| 'application-order'
|
46
41
|
| 'property-specificity'
|
47
42
|
| 'legacy-expand-shorthands';
|
43
|
+
test: boolean;
|
44
|
+
useRemForFontSize: boolean;
|
48
45
|
}>;
|
49
46
|
export type MutableCompiledNamespaces = { [key: string]: FlatCompiledStyles };
|
50
47
|
export type CompiledNamespaces = Readonly<MutableCompiledNamespaces>;
|
package/lib/common-types.js.flow
CHANGED
@@ -7,14 +7,12 @@
|
|
7
7
|
* @flow strict
|
8
8
|
*/
|
9
9
|
|
10
|
-
import type { IncludedStyles } from './stylex-include';
|
11
|
-
|
12
10
|
export type TRawValue = number | string | $ReadOnlyArray<number | string>;
|
13
11
|
export type TStyleValue = null | TRawValue;
|
14
12
|
export type TNestableStyleValue = TStyleValue | PrimitiveRawStyles;
|
15
13
|
|
16
14
|
export type RawStyles = $ReadOnly<{
|
17
|
-
[string]: TNestableStyleValue
|
15
|
+
[string]: TNestableStyleValue,
|
18
16
|
}>;
|
19
17
|
export type PrimitiveRawStyles = $ReadOnly<{
|
20
18
|
[string]: TNestableStyleValue,
|
@@ -29,25 +27,20 @@ export type InjectableStyle = {
|
|
29
27
|
export type StyleRule = [string, string, InjectableStyle];
|
30
28
|
|
31
29
|
export type CompiledStyles = $ReadOnly<{
|
32
|
-
[string]:
|
33
|
-
| IncludedStyles
|
34
|
-
| null
|
35
|
-
| string
|
36
|
-
| $ReadOnly<{ [string]: null | string }>,
|
30
|
+
[string]: null | string | $ReadOnly<{ [string]: null | string }>,
|
37
31
|
}>;
|
38
32
|
|
39
33
|
export type FlatCompiledStyles = $ReadOnly<{
|
40
|
-
[string]: string |
|
41
|
-
$$css: true,
|
34
|
+
[string]: string | null,
|
35
|
+
$$css: true | string,
|
42
36
|
}>;
|
43
37
|
|
44
38
|
export type StyleXOptions = $ReadOnly<{
|
45
|
-
dev: boolean,
|
46
|
-
debug: ?boolean,
|
47
|
-
test: boolean,
|
48
|
-
useRemForFontSize: boolean,
|
49
39
|
classNamePrefix: string,
|
40
|
+
debug: ?boolean,
|
41
|
+
enableDebugClassNames?: ?boolean,
|
50
42
|
definedStylexCSSVariables?: { [key: string]: mixed },
|
43
|
+
dev: boolean,
|
51
44
|
styleResolution:
|
52
45
|
| 'application-order' // The last style applied wins.
|
53
46
|
// More specific styles will win over less specific styles. (margin-top wins over margin)
|
@@ -55,6 +48,8 @@ export type StyleXOptions = $ReadOnly<{
|
|
55
48
|
// Legacy behavior, that expands shorthand properties into their longhand counterparts at compile-time.
|
56
49
|
// This is not recommended, and will be removed in a future version.
|
57
50
|
| 'legacy-expand-shorthands',
|
51
|
+
test: boolean,
|
52
|
+
useRemForFontSize: boolean,
|
58
53
|
...
|
59
54
|
}>;
|
60
55
|
|
@@ -19,7 +19,8 @@ function convertStyleToClassName(objEntry, pseudos, atRules) {
|
|
19
19
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions.defaultOptions;
|
20
20
|
const {
|
21
21
|
classNamePrefix = 'x',
|
22
|
-
debug = false
|
22
|
+
debug = false,
|
23
|
+
enableDebugClassNames = true
|
23
24
|
} = options;
|
24
25
|
const [key, rawValue] = objEntry;
|
25
26
|
const dashedKey = key.startsWith('--') ? key : (0, _dashify.default)(key);
|
@@ -34,7 +35,7 @@ function convertStyleToClassName(objEntry, pseudos, atRules) {
|
|
34
35
|
const modifierHashString = pseudoHashString + atRuleHashString || 'null';
|
35
36
|
const valueAsString = Array.isArray(value) ? value.join(', ') : value;
|
36
37
|
const stringToHash = dashedKey + valueAsString + modifierHashString;
|
37
|
-
const className = debug ? `${key}-${classNamePrefix}${(0, _hash.default)('<>' + stringToHash)}` : classNamePrefix + (0, _hash.default)('<>' + stringToHash);
|
38
|
+
const className = debug && enableDebugClassNames ? `${key}-${classNamePrefix}${(0, _hash.default)('<>' + stringToHash)}` : classNamePrefix + (0, _hash.default)('<>' + stringToHash);
|
38
39
|
const cssRules = (0, _generateCssRule.generateRule)(className, dashedKey, value, pseudos, atRules);
|
39
40
|
return [key, className, cssRules];
|
40
41
|
}
|
package/lib/index.d.ts
CHANGED
@@ -18,9 +18,6 @@ import styleXCreateSet from './stylex-create';
|
|
18
18
|
import styleXDefineVars from './stylex-define-vars';
|
19
19
|
import styleXCreateTheme from './stylex-create-theme';
|
20
20
|
import stylexKeyframes from './stylex-keyframes';
|
21
|
-
import stylexInclude, {
|
22
|
-
IncludedStyles as _IncludedStyles,
|
23
|
-
} from './stylex-include';
|
24
21
|
import stylexFirstThatWorks from './stylex-first-that-works';
|
25
22
|
import hash from './hash';
|
26
23
|
import genFileBasedIdentifier from './utils/file-based-identifier';
|
@@ -41,13 +38,11 @@ export declare const create: typeof styleXCreateSet;
|
|
41
38
|
export declare const defineVars: typeof styleXDefineVars;
|
42
39
|
export declare const createTheme: typeof styleXCreateTheme;
|
43
40
|
export declare const keyframes: typeof stylexKeyframes;
|
44
|
-
export declare const include: typeof stylexInclude;
|
45
41
|
export declare const utils: {
|
46
42
|
hash: typeof hash;
|
47
43
|
genFileBasedIdentifier: typeof genFileBasedIdentifier;
|
48
44
|
};
|
49
45
|
export declare const messages: typeof m;
|
50
|
-
export declare const IncludedStyles: typeof _IncludedStyles;
|
51
46
|
export declare const firstThatWorks: typeof stylexFirstThatWorks;
|
52
47
|
export declare const PSEUDO_CLASS_PRIORITIES: typeof _PSEUDO_CLASS_PRIORITIES;
|
53
48
|
export declare const AT_RULE_PRIORITIES: typeof _AT_RULE_PRIORITIES;
|
package/lib/index.js
CHANGED
@@ -3,12 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.utils = exports.types = exports.messages = exports.keyframes = exports.
|
6
|
+
exports.utils = exports.types = exports.messages = exports.keyframes = exports.firstThatWorks = exports.defineVars = exports.createTheme = exports.create = exports.PSEUDO_ELEMENT_PRIORITY = exports.PSEUDO_CLASS_PRIORITIES = exports.AT_RULE_PRIORITIES = void 0;
|
7
7
|
var _stylexCreate = _interopRequireDefault(require("./stylex-create"));
|
8
8
|
var _stylexDefineVars = _interopRequireDefault(require("./stylex-define-vars"));
|
9
9
|
var _stylexCreateTheme = _interopRequireDefault(require("./stylex-create-theme"));
|
10
10
|
var _stylexKeyframes = _interopRequireDefault(require("./stylex-keyframes"));
|
11
|
-
var _stylexInclude = _interopRequireWildcard(require("./stylex-include"));
|
12
11
|
var _stylexFirstThatWorks = _interopRequireDefault(require("./stylex-first-that-works"));
|
13
12
|
var _hash = _interopRequireDefault(require("./hash"));
|
14
13
|
var _fileBasedIdentifier = _interopRequireDefault(require("./utils/file-based-identifier"));
|
@@ -23,13 +22,11 @@ const create = exports.create = _stylexCreate.default;
|
|
23
22
|
const defineVars = exports.defineVars = _stylexDefineVars.default;
|
24
23
|
const createTheme = exports.createTheme = _stylexCreateTheme.default;
|
25
24
|
const keyframes = exports.keyframes = _stylexKeyframes.default;
|
26
|
-
const include = exports.include = _stylexInclude.default;
|
27
25
|
const utils = exports.utils = {
|
28
26
|
hash: _hash.default,
|
29
27
|
genFileBasedIdentifier: _fileBasedIdentifier.default
|
30
28
|
};
|
31
29
|
const messages = exports.messages = m;
|
32
|
-
const IncludedStyles = exports.IncludedStyles = _stylexInclude.IncludedStyles;
|
33
30
|
const firstThatWorks = exports.firstThatWorks = _stylexFirstThatWorks.default;
|
34
31
|
const PSEUDO_CLASS_PRIORITIES = exports.PSEUDO_CLASS_PRIORITIES = _propertyPriorities.PSEUDO_CLASS_PRIORITIES;
|
35
32
|
const AT_RULE_PRIORITIES = exports.AT_RULE_PRIORITIES = _propertyPriorities.AT_RULE_PRIORITIES;
|
package/lib/index.js.flow
CHANGED
@@ -24,9 +24,6 @@ import styleXCreateSet from './stylex-create';
|
|
24
24
|
import styleXDefineVars from './stylex-define-vars';
|
25
25
|
import styleXCreateTheme from './stylex-create-theme';
|
26
26
|
import stylexKeyframes from './stylex-keyframes';
|
27
|
-
import stylexInclude, {
|
28
|
-
IncludedStyles as _IncludedStyles,
|
29
|
-
} from './stylex-include';
|
30
27
|
import stylexFirstThatWorks from './stylex-first-that-works';
|
31
28
|
import hash from './hash';
|
32
29
|
import genFileBasedIdentifier from './utils/file-based-identifier';
|
@@ -49,13 +46,11 @@ declare export const create: typeof styleXCreateSet;
|
|
49
46
|
declare export const defineVars: typeof styleXDefineVars;
|
50
47
|
declare export const createTheme: typeof styleXCreateTheme;
|
51
48
|
declare export const keyframes: typeof stylexKeyframes;
|
52
|
-
declare export const include: typeof stylexInclude;
|
53
49
|
declare export const utils: {
|
54
50
|
hash: typeof hash,
|
55
51
|
genFileBasedIdentifier: typeof genFileBasedIdentifier,
|
56
52
|
};
|
57
53
|
declare export const messages: typeof m;
|
58
|
-
declare export const IncludedStyles: typeof _IncludedStyles;
|
59
54
|
declare export const firstThatWorks: typeof stylexFirstThatWorks;
|
60
55
|
declare export const PSEUDO_CLASS_PRIORITIES: typeof _PSEUDO_CLASS_PRIORITIES;
|
61
56
|
declare export const AT_RULE_PRIORITIES: typeof _AT_RULE_PRIORITIES;
|
package/lib/messages.d.ts
CHANGED
@@ -33,7 +33,6 @@ export declare const LOCAL_ONLY: 'The return value of stylex.create() should not
|
|
33
33
|
export declare const UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
|
34
34
|
export declare const EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
|
35
35
|
export declare const NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
|
36
|
-
export declare const ONLY_TOP_LEVEL_INCLUDES: 'stylex.include() is only at the top level of a style definition object.';
|
37
36
|
export declare const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
|
38
37
|
export declare const NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
|
39
38
|
export declare const NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.defineVars() must be bound to a named export.';
|
package/lib/messages.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.UNKNOWN_PROP_KEY = exports.UNKNOWN_NAMESPACE = exports.UNEXPECTED_ARGUMENT = exports.UNBOUND_STYLEX_CALL_VALUE = exports.
|
6
|
+
exports.UNKNOWN_PROP_KEY = exports.UNKNOWN_NAMESPACE = exports.UNEXPECTED_ARGUMENT = exports.UNBOUND_STYLEX_CALL_VALUE = exports.ONLY_TOP_LEVEL = exports.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = exports.NO_PROJECT_ROOT_DIRECTORY = exports.NO_PARENT_PATH = exports.NO_CONDITIONAL_SHORTHAND = exports.NON_STATIC_VALUE = exports.NON_STATIC_KEYFRAME_VALUE = exports.NON_OBJECT_KEYFRAME = exports.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = exports.NON_OBJECT_FOR_STYLEX_CALL = exports.NON_EXPORT_NAMED_DECLARATION = exports.NON_CONTIGUOUS_VARS = exports.LOCAL_ONLY = exports.LINT_UNCLOSED_FUNCTION = exports.INVALID_SPREAD = exports.INVALID_PSEUDO_OR_AT_RULE = exports.INVALID_PSEUDO = exports.ILLEGAL_PROP_VALUE = exports.ILLEGAL_PROP_ARRAY_VALUE = exports.ILLEGAL_NESTED_PSEUDO = exports.ILLEGAL_NAMESPACE_VALUE = exports.ILLEGAL_NAMESPACE_TYPE = exports.ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = exports.ILLEGAL_ARGUMENT_LENGTH = exports.EXPECTED_FUNCTION_CALL = exports.ESCAPED_STYLEX_VALUE = exports.DUPLICATE_CONDITIONAL = exports.ANONYMOUS_THEME = void 0;
|
7
7
|
const ILLEGAL_ARGUMENT_LENGTH = exports.ILLEGAL_ARGUMENT_LENGTH = 'stylex.create() should have 1 argument.';
|
8
8
|
const ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = exports.ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = 'stylex.keyframes() should have 1 argument.';
|
9
9
|
const NON_STATIC_VALUE = exports.NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
|
@@ -30,7 +30,6 @@ const LOCAL_ONLY = exports.LOCAL_ONLY = 'The return value of stylex.create() sho
|
|
30
30
|
const UNEXPECTED_ARGUMENT = exports.UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
|
31
31
|
const EXPECTED_FUNCTION_CALL = exports.EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
|
32
32
|
const NO_PARENT_PATH = exports.NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
|
33
|
-
const ONLY_TOP_LEVEL_INCLUDES = exports.ONLY_TOP_LEVEL_INCLUDES = 'stylex.include() is only at the top level of a style definition object.';
|
34
33
|
const DUPLICATE_CONDITIONAL = exports.DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
|
35
34
|
const NO_PROJECT_ROOT_DIRECTORY = exports.NO_PROJECT_ROOT_DIRECTORY = 'The project root directory `rootDir` is not configured.';
|
36
35
|
const NON_EXPORT_NAMED_DECLARATION = exports.NON_EXPORT_NAMED_DECLARATION = 'The return value of stylex.defineVars() must be bound to a named export.';
|
package/lib/messages.js.flow
CHANGED
@@ -36,7 +36,6 @@ declare export const LOCAL_ONLY: 'The return value of stylex.create() should not
|
|
36
36
|
declare export const UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
|
37
37
|
declare export const EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
|
38
38
|
declare export const NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
|
39
|
-
declare export const ONLY_TOP_LEVEL_INCLUDES: 'stylex.include() is only at the top level of a style definition object.';
|
40
39
|
declare export const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
|
41
40
|
declare export const NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
|
42
41
|
declare export const NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.defineVars() must be bound to a named export.';
|
@@ -8,7 +8,6 @@
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
import type { InjectableStyle, StyleXOptions } from '../common-types';
|
11
|
-
import type { IncludedStyles } from '../stylex-include';
|
12
11
|
export type ClassesToOriginalPaths = {
|
13
12
|
readonly [className: string]: ReadonlyArray<string>;
|
14
13
|
};
|
@@ -16,9 +15,7 @@ export type ComputedStyle = null | Readonly<
|
|
16
15
|
[string, InjectableStyle, ClassesToOriginalPaths]
|
17
16
|
>;
|
18
17
|
export interface IPreRule {
|
19
|
-
compiled(
|
20
|
-
options: StyleXOptions,
|
21
|
-
): IncludedStyles | ReadonlyArray<ComputedStyle>;
|
18
|
+
compiled(options: StyleXOptions): ReadonlyArray<ComputedStyle>;
|
22
19
|
equals(other: IPreRule): boolean;
|
23
20
|
}
|
24
21
|
export type AnyPreRule = NullPreRule | PreRule | PreRuleSet;
|
@@ -26,12 +23,6 @@ export declare class NullPreRule implements IPreRule {
|
|
26
23
|
compiled(_options: StyleXOptions): [null];
|
27
24
|
equals(other: IPreRule): boolean;
|
28
25
|
}
|
29
|
-
export declare class PreIncludedStylesRule implements IPreRule {
|
30
|
-
readonly includedStyles: IncludedStyles;
|
31
|
-
constructor(IncludedStyles: IncludedStyles);
|
32
|
-
equals(other: IPreRule): boolean;
|
33
|
-
compiled(_options: StyleXOptions): IncludedStyles;
|
34
|
-
}
|
35
26
|
export declare class PreRule implements IPreRule {
|
36
27
|
readonly property: string;
|
37
28
|
readonly value: string | number | ReadonlyArray<string | number>;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.PreRuleSet = exports.PreRule = exports.
|
6
|
+
exports.PreRuleSet = exports.PreRule = exports.NullPreRule = void 0;
|
7
7
|
var _convertToClassName = require("../convert-to-className");
|
8
8
|
var _objectUtils = require("../utils/object-utils");
|
9
9
|
var _ruleUtils = require("../utils/rule-utils");
|
@@ -16,18 +16,6 @@ class NullPreRule {
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
exports.NullPreRule = NullPreRule;
|
19
|
-
class PreIncludedStylesRule {
|
20
|
-
constructor(IncludedStyles) {
|
21
|
-
this.includedStyles = IncludedStyles;
|
22
|
-
}
|
23
|
-
equals(other) {
|
24
|
-
return other instanceof PreIncludedStylesRule && this.includedStyles === other.includedStyles;
|
25
|
-
}
|
26
|
-
compiled(_options) {
|
27
|
-
return this.includedStyles;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
exports.PreIncludedStylesRule = PreIncludedStylesRule;
|
31
19
|
class PreRule {
|
32
20
|
constructor(property, value, keyPath) {
|
33
21
|
this.property = property;
|
@@ -8,7 +8,6 @@
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
import type { InjectableStyle, StyleXOptions } from '../common-types';
|
11
|
-
import type { IncludedStyles } from '../stylex-include';
|
12
11
|
|
13
12
|
export type ClassesToOriginalPaths = {
|
14
13
|
+[className: string]: $ReadOnlyArray<string>,
|
@@ -24,9 +23,7 @@ export type ComputedStyle = null | $ReadOnly<
|
|
24
23
|
// These are thin wrappers around the "values" in Raw Style Objects
|
25
24
|
// with all the metadata needed to compile them into CSS.
|
26
25
|
export interface IPreRule {
|
27
|
-
compiled(
|
28
|
-
options: StyleXOptions,
|
29
|
-
): IncludedStyles | $ReadOnlyArray<ComputedStyle>;
|
26
|
+
compiled(options: StyleXOptions): $ReadOnlyArray<ComputedStyle>;
|
30
27
|
equals(other: IPreRule): boolean;
|
31
28
|
}
|
32
29
|
|
@@ -37,13 +34,6 @@ declare export class NullPreRule implements IPreRule {
|
|
37
34
|
equals(other: IPreRule): boolean;
|
38
35
|
}
|
39
36
|
|
40
|
-
declare export class PreIncludedStylesRule implements IPreRule {
|
41
|
-
+includedStyles: IncludedStyles;
|
42
|
-
constructor(IncludedStyles: IncludedStyles): void;
|
43
|
-
equals(other: IPreRule): boolean;
|
44
|
-
compiled(_options: StyleXOptions): IncludedStyles;
|
45
|
-
}
|
46
|
-
|
47
37
|
declare export class PreRule implements IPreRule {
|
48
38
|
+property: string;
|
49
39
|
+value: string | number | $ReadOnlyArray<string | number>;
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.validateNamespace = validateNamespace;
|
7
|
-
var _stylexInclude = require("../stylex-include");
|
8
7
|
var messages = _interopRequireWildcard(require("../messages"));
|
9
8
|
var _objectUtils = require("../utils/object-utils");
|
10
9
|
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); }
|
@@ -29,12 +28,6 @@ function validateNamespace(namespace) {
|
|
29
28
|
}
|
30
29
|
continue;
|
31
30
|
}
|
32
|
-
if (val instanceof _stylexInclude.IncludedStyles) {
|
33
|
-
if (conditions.length === 0) {
|
34
|
-
continue;
|
35
|
-
}
|
36
|
-
throw new Error(messages.ONLY_TOP_LEVEL_INCLUDES);
|
37
|
-
}
|
38
31
|
if ((0, _objectUtils.isPlainObject)(val)) {
|
39
32
|
if (key.startsWith('@') || key.startsWith(':')) {
|
40
33
|
if (conditions.includes(key)) {
|
@@ -71,9 +64,6 @@ function validateConditionalStyles(val) {
|
|
71
64
|
}
|
72
65
|
continue;
|
73
66
|
}
|
74
|
-
if (v instanceof _stylexInclude.IncludedStyles) {
|
75
|
-
throw new Error(messages.ONLY_TOP_LEVEL_INCLUDES);
|
76
|
-
}
|
77
67
|
if ((0, _objectUtils.isPlainObject)(v)) {
|
78
68
|
validateConditionalStyles(v, [...conditions, key]);
|
79
69
|
continue;
|
@@ -8,11 +8,7 @@
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
import type { RawStyles, StyleXOptions } from '../common-types';
|
11
|
-
import {
|
12
|
-
type AnyPreRule,
|
13
|
-
type IPreRule,
|
14
|
-
PreIncludedStylesRule,
|
15
|
-
} from './PreRule';
|
11
|
+
import { type AnyPreRule, type IPreRule } from './PreRule';
|
16
12
|
export declare function flattenRawStyleObject(
|
17
13
|
style: RawStyles,
|
18
14
|
options: StyleXOptions,
|
@@ -21,4 +17,4 @@ export declare function _flattenRawStyleObject(
|
|
21
17
|
style: RawStyles,
|
22
18
|
keyPath: ReadonlyArray<string>,
|
23
19
|
options: StyleXOptions,
|
24
|
-
): Array<Readonly<[string, AnyPreRule
|
20
|
+
): Array<Readonly<[string, AnyPreRule]>>;
|
@@ -7,7 +7,6 @@ exports._flattenRawStyleObject = _flattenRawStyleObject;
|
|
7
7
|
exports.flattenRawStyleObject = flattenRawStyleObject;
|
8
8
|
var _index = _interopRequireDefault(require("./index"));
|
9
9
|
var _PreRule = require("./PreRule");
|
10
|
-
var _stylexInclude = require("../stylex-include");
|
11
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
11
|
function flattenRawStyleObject(style, options) {
|
13
12
|
return _flattenRawStyleObject(style, [], options);
|
@@ -17,10 +16,6 @@ function _flattenRawStyleObject(style, keyPath, options) {
|
|
17
16
|
for (const _key in style) {
|
18
17
|
const value = style[_key];
|
19
18
|
const key = _key.match(/var\(--[a-z0-9]+\)/) ? _key.slice(4, -1) : _key;
|
20
|
-
if (typeof value === 'object' && value instanceof _stylexInclude.IncludedStyles) {
|
21
|
-
flattened.push([key, new _PreRule.PreIncludedStylesRule(value)]);
|
22
|
-
continue;
|
23
|
-
}
|
24
19
|
if (value === null || typeof value === 'string' || typeof value === 'number') {
|
25
20
|
const pairs = (0, _index.default)([key, value], options);
|
26
21
|
for (const [property, value] of pairs) {
|
@@ -74,9 +69,6 @@ function _flattenRawStyleObject(style, keyPath, options) {
|
|
74
69
|
[key]: innerValue
|
75
70
|
}, keyPath.length > 0 ? [...keyPath, condition] : [key, condition], options);
|
76
71
|
for (const [property, preRule] of pairs) {
|
77
|
-
if (preRule instanceof _PreRule.PreIncludedStylesRule) {
|
78
|
-
throw new Error('stylex.include can only be used at the top-level');
|
79
|
-
}
|
80
72
|
if (equivalentPairs[property] == null) {
|
81
73
|
equivalentPairs[property] = {
|
82
74
|
[condition]: preRule
|
@@ -9,11 +9,8 @@
|
|
9
9
|
|
10
10
|
import type { RawStyles, StyleXOptions } from '../common-types';
|
11
11
|
|
12
|
-
import {
|
13
|
-
|
14
|
-
type IPreRule,
|
15
|
-
PreIncludedStylesRule,
|
16
|
-
} from './PreRule';
|
12
|
+
import { type AnyPreRule, type IPreRule } from './PreRule';
|
13
|
+
|
17
14
|
declare export function flattenRawStyleObject(
|
18
15
|
style: RawStyles,
|
19
16
|
options: StyleXOptions,
|
@@ -23,4 +20,4 @@ declare export function _flattenRawStyleObject(
|
|
23
20
|
style: RawStyles,
|
24
21
|
keyPath: $ReadOnlyArray<string>,
|
25
22
|
options: StyleXOptions,
|
26
|
-
): Array<$ReadOnly<[string, AnyPreRule
|
23
|
+
): Array<$ReadOnly<[string, AnyPreRule]>>;
|
package/lib/stylex-create.js
CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = styleXCreateSet;
|
7
|
-
var _stylexInclude = require("./stylex-include");
|
8
7
|
var _defaultOptions = require("./utils/default-options");
|
9
8
|
var _flattenRawStyleObj = require("./preprocess-rules/flatten-raw-style-obj");
|
10
9
|
var _basicValidation = require("./preprocess-rules/basic-validation");
|
@@ -32,23 +31,19 @@ function styleXCreateSet(namespaces) {
|
|
32
31
|
});
|
33
32
|
const namespaceObj = {};
|
34
33
|
for (const [key, value] of compiledNamespaceTuples) {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
for (const [className, injectable] of classNameTuples) {
|
49
|
-
if (injectedStyles[className] == null) {
|
50
|
-
injectedStyles[className] = injectable;
|
51
|
-
}
|
34
|
+
const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
|
35
|
+
classNameTuples.forEach(_ref2 => {
|
36
|
+
let [_className, _, classesToOriginalPath] = _ref2;
|
37
|
+
Object.assign(classPathsInNamespace, classesToOriginalPath);
|
38
|
+
});
|
39
|
+
const className = classNameTuples.map(_ref3 => {
|
40
|
+
let [className] = _ref3;
|
41
|
+
return className;
|
42
|
+
}).join(' ') || null;
|
43
|
+
namespaceObj[key] = className;
|
44
|
+
for (const [className, injectable] of classNameTuples) {
|
45
|
+
if (injectedStyles[className] == null) {
|
46
|
+
injectedStyles[className] = injectable;
|
52
47
|
}
|
53
48
|
}
|
54
49
|
}
|
@@ -8,11 +8,10 @@
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
import type { CompiledStyles } from '../common-types';
|
11
|
-
import { IncludedStyles } from '../stylex-include';
|
12
11
|
type AnyObject = { readonly [$$Key$$: string]: unknown };
|
13
12
|
export declare function isPlainObject(obj: unknown): obj is AnyObject;
|
14
13
|
export declare function flattenObject(obj: CompiledStyles): {
|
15
|
-
readonly [$$Key$$: string]: null | string
|
14
|
+
readonly [$$Key$$: string]: null | string;
|
16
15
|
};
|
17
16
|
type _ObjectEntries<Obj extends { readonly [$$Key$$: string]: unknown }> = {
|
18
17
|
[Key in keyof Obj]: [Key, Obj[Key]];
|
@@ -12,7 +12,6 @@ exports.objMap = objMap;
|
|
12
12
|
exports.objMapEntry = objMapEntry;
|
13
13
|
exports.objMapKeys = objMapKeys;
|
14
14
|
exports.objValues = objValues;
|
15
|
-
var _stylexInclude = require("../stylex-include");
|
16
15
|
function isPlainObject(obj) {
|
17
16
|
return typeof obj === 'object' && obj != null && !Array.isArray(obj) && obj?.constructor === Object;
|
18
17
|
}
|
@@ -21,8 +20,6 @@ function flattenObject(obj) {
|
|
21
20
|
for (const [key, value] of objEntries(obj)) {
|
22
21
|
if (typeof value === 'string' || value == null) {
|
23
22
|
result[key] = value;
|
24
|
-
} else if (value instanceof _stylexInclude.IncludedStyles) {
|
25
|
-
result[key] = value;
|
26
23
|
} else {
|
27
24
|
for (const [subKey, subValue] of objEntries(value)) {
|
28
25
|
result[`${key}_${subKey}`] = subValue;
|
@@ -11,15 +11,13 @@
|
|
11
11
|
|
12
12
|
import type { CompiledStyles } from '../common-types';
|
13
13
|
|
14
|
-
import { IncludedStyles } from '../stylex-include';
|
15
|
-
|
16
14
|
// eslint-disable-next-line no-unused-vars
|
17
15
|
type AnyObject = { +[string]: mixed };
|
18
16
|
|
19
17
|
declare export function isPlainObject(obj: mixed): implies obj is AnyObject;
|
20
18
|
|
21
19
|
declare export function flattenObject(obj: CompiledStyles): {
|
22
|
-
+[string]: null | string
|
20
|
+
+[string]: null | string,
|
23
21
|
};
|
24
22
|
|
25
23
|
type _ObjectEntries<Obj: { +[string]: mixed }> = {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@stylexjs/shared",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.11.1",
|
4
4
|
"main": "lib/index.js",
|
5
5
|
"repository": "https://www.github.com/facebook/stylex",
|
6
6
|
"license": "MIT",
|
@@ -13,7 +13,16 @@
|
|
13
13
|
"postcss-value-parser": "^4.1.0"
|
14
14
|
},
|
15
15
|
"devDependencies": {
|
16
|
-
"@
|
16
|
+
"@babel/cli": "^7.26.4",
|
17
|
+
"@babel/core": "^7.26.8",
|
18
|
+
"@babel/eslint-parser": "^7.26.8",
|
19
|
+
"@babel/plugin-syntax-flow": "^7.26.0",
|
20
|
+
"@babel/preset-env": "^7.26.8",
|
21
|
+
"@babel/preset-flow": "^7.25.9",
|
22
|
+
"@babel/preset-react": "^7.26.3",
|
23
|
+
"@babel/preset-typescript": "^7.26.0",
|
24
|
+
"@stylexjs/scripts": "0.11.1",
|
25
|
+
"babel-plugin-syntax-hermes-parser": "^0.26.0"
|
17
26
|
},
|
18
27
|
"jest": {
|
19
28
|
"snapshotFormat": {
|