styled-components 6.0.0-beta.8 → 6.0.0-rc.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.
- package/dist/base.d.ts +2 -8
- package/dist/constructors/constructWithOptions.d.ts +10 -7
- package/dist/constructors/styled.d.ts +176 -176
- package/dist/hoc/withTheme.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/models/ComponentStyle.d.ts +0 -1
- package/dist/models/StyleSheetManager.d.ts +27 -9
- package/dist/models/ThemeProvider.d.ts +4 -3
- package/dist/native/index.d.ts +26 -27
- package/dist/sheet/GroupedTag.d.ts +1 -1
- package/dist/sheet/Sheet.d.ts +3 -3
- package/dist/sheet/types.d.ts +1 -1
- package/dist/styled-components-macro.cjs.js +5 -6
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components-macro.esm.js +0 -1
- package/dist/styled-components-macro.esm.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +1 -1844
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +1 -1818
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +1 -1864
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +1 -1838
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +269 -249
- package/dist/styled-components.js.map +1 -1
- package/dist/styled-components.min.js +1 -1
- package/dist/styled-components.min.js.map +1 -1
- package/dist/test/types.d.ts +9 -0
- package/dist/test/utils.d.ts +176 -176
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +34 -41
- package/dist/utils/determineTheme.d.ts +4 -2
- package/dist/utils/domElements.d.ts +1 -1
- package/dist/utils/flatten.d.ts +1 -1
- package/dist/utils/hoist.d.ts +3 -3
- package/dist/utils/isFunction.d.ts +1 -1
- package/dist/utils/isPlainObject.d.ts +1 -1
- package/dist/utils/isStatelessFunction.d.ts +1 -1
- package/dist/utils/joinStrings.d.ts +2 -1
- package/dist/utils/stylis.d.ts +1 -1
- package/native/dist/base.d.ts +2 -8
- package/native/dist/constructors/constructWithOptions.d.ts +10 -7
- package/native/dist/constructors/styled.d.ts +176 -176
- package/native/dist/hoc/withTheme.d.ts +1 -1
- package/native/dist/index.d.ts +1 -1
- package/native/dist/models/ComponentStyle.d.ts +0 -1
- package/native/dist/models/StyleSheetManager.d.ts +27 -9
- package/native/dist/models/ThemeProvider.d.ts +4 -3
- package/native/dist/native/index.d.ts +26 -27
- package/native/dist/sheet/GroupedTag.d.ts +1 -1
- package/native/dist/sheet/Sheet.d.ts +3 -3
- package/native/dist/sheet/types.d.ts +1 -1
- package/native/dist/styled-components.native.cjs.js +1 -1305
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +1 -1287
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/test/types.d.ts +9 -0
- package/native/dist/test/utils.d.ts +176 -176
- package/native/dist/types.d.ts +34 -41
- package/native/dist/utils/determineTheme.d.ts +4 -2
- package/native/dist/utils/domElements.d.ts +1 -1
- package/native/dist/utils/flatten.d.ts +1 -1
- package/native/dist/utils/hoist.d.ts +3 -3
- package/native/dist/utils/isFunction.d.ts +1 -1
- package/native/dist/utils/isPlainObject.d.ts +1 -1
- package/native/dist/utils/isStatelessFunction.d.ts +1 -1
- package/native/dist/utils/joinStrings.d.ts +2 -1
- package/native/dist/utils/stylis.d.ts +1 -1
- package/package.json +22 -34
- package/dist/hooks/useTheme.d.ts +0 -3
|
@@ -24,14 +24,15 @@ import React from 'react';
|
|
|
24
24
|
export interface DefaultTheme {
|
|
25
25
|
[key: string]: any;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
type ThemeFn = (outerTheme?: DefaultTheme) => DefaultTheme;
|
|
28
|
+
type ThemeArgument = DefaultTheme | ThemeFn;
|
|
29
|
+
type Props = {
|
|
30
30
|
children?: React.ReactNode;
|
|
31
31
|
theme: ThemeArgument;
|
|
32
32
|
};
|
|
33
33
|
export declare const ThemeContext: React.Context<DefaultTheme | undefined>;
|
|
34
34
|
export declare const ThemeConsumer: React.Consumer<DefaultTheme | undefined>;
|
|
35
|
+
export declare function useTheme(): DefaultTheme | undefined;
|
|
35
36
|
/**
|
|
36
37
|
* Provide a theme to an entire react component tree via context
|
|
37
38
|
*/
|
package/dist/native/index.d.ts
CHANGED
|
@@ -2,35 +2,34 @@ import React from 'react';
|
|
|
2
2
|
import { Styled } from '../constructors/constructWithOptions';
|
|
3
3
|
import css from '../constructors/css';
|
|
4
4
|
import withTheme from '../hoc/withTheme';
|
|
5
|
-
import useTheme from '../
|
|
6
|
-
import ThemeProvider, { ThemeConsumer, ThemeContext } from '../models/ThemeProvider';
|
|
5
|
+
import ThemeProvider, { ThemeConsumer, ThemeContext, useTheme } from '../models/ThemeProvider';
|
|
7
6
|
import { NativeTarget } from '../types';
|
|
8
7
|
import isStyledComponent from '../utils/isStyledComponent';
|
|
9
|
-
declare const styled: (<Target extends NativeTarget>(tag: Target) => Styled<"native", Target, Target extends import("../types").KnownTarget ? React.ComponentPropsWithRef<Target> : object, object>) & {
|
|
10
|
-
ActivityIndicator: Styled<"native", typeof import("react-native").ActivityIndicator, import("react-native").ActivityIndicatorProps
|
|
11
|
-
Button: Styled<"native", typeof import("react-native").Button, import("react-native").ButtonProps
|
|
12
|
-
DatePickerIOS: Styled<"native", typeof import("react-native").DatePickerIOS, import("react-native").DatePickerIOSProps
|
|
13
|
-
DrawerLayoutAndroid: Styled<"native", typeof import("react-native").DrawerLayoutAndroid, import("react-native").DrawerLayoutAndroidProps
|
|
14
|
-
FlatList: Styled<"native", typeof import("react-native").FlatList, import("react-native").FlatListProps<unknown
|
|
15
|
-
Image: Styled<"native", typeof import("react-native").Image, import("react-native").ImageProps
|
|
16
|
-
ImageBackground: Styled<"native", typeof import("react-native").ImageBackground, import("react-native").ImageBackgroundProps
|
|
17
|
-
KeyboardAvoidingView: Styled<"native", typeof import("react-native").KeyboardAvoidingView, import("react-native").KeyboardAvoidingViewProps
|
|
18
|
-
Modal: Styled<"native", typeof import("react-native").Modal, import("react-native").ModalBaseProps & import("react-native").ModalPropsIOS & import("react-native").ModalPropsAndroid & import("react-native").ViewProps
|
|
19
|
-
Pressable: Styled<"native", import("react").ForwardRefExoticComponent<import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>>, import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>, object>;
|
|
20
|
-
ProgressBarAndroid: Styled<"native", typeof import("react-native").ProgressBarAndroid, import("react-native").ProgressBarAndroidProps
|
|
21
|
-
ProgressViewIOS: Styled<"native", typeof import("react-native").ProgressViewIOS, import("react-native").ProgressViewIOSProps
|
|
22
|
-
RefreshControl: Styled<"native", typeof import("react-native").RefreshControl, import("react-native").RefreshControlProps
|
|
23
|
-
SafeAreaView: Styled<"native", typeof import("react-native").SafeAreaView, import("react-native").ViewProps
|
|
24
|
-
ScrollView: Styled<"native", typeof import("react-native").ScrollView, import("react-native").ScrollViewProps
|
|
25
|
-
SectionList: Styled<"native", typeof import("react-native").SectionList, import("react-native").SectionListProps<unknown, unknown
|
|
26
|
-
Slider: Styled<"native", typeof import("react-native").Slider, import("react-native").SliderProps
|
|
27
|
-
Switch: Styled<"native", typeof import("react-native").Switch, import("react-native").SwitchProps
|
|
28
|
-
Text: Styled<"native", typeof import("react-native").Text, import("react-native").TextProps
|
|
29
|
-
TextInput: Styled<"native", typeof import("react-native").TextInput, import("react-native").TextInputProps
|
|
30
|
-
TouchableHighlight: Styled<"native", typeof import("react-native").TouchableHighlight, import("react-native").TouchableHighlightProps
|
|
31
|
-
TouchableOpacity: Styled<"native", typeof import("react-native").TouchableOpacity, import("react-native").TouchableOpacityProps
|
|
32
|
-
View: Styled<"native", typeof import("react-native").View, import("react-native").ViewProps
|
|
33
|
-
VirtualizedList: Styled<"native", typeof import("react-native").VirtualizedList, import("react-native").VirtualizedListProps<unknown
|
|
8
|
+
declare const styled: (<Target extends NativeTarget>(tag: Target) => Styled<"native", Target, Target extends import("../types").KnownTarget ? React.ComponentPropsWithRef<Target> : object, object, object>) & {
|
|
9
|
+
ActivityIndicator: Styled<"native", typeof import("react-native").ActivityIndicator, import("react-native").ActivityIndicatorProps, object, object>;
|
|
10
|
+
Button: Styled<"native", typeof import("react-native").Button, import("react-native").ButtonProps, object, object>;
|
|
11
|
+
DatePickerIOS: Styled<"native", typeof import("react-native").DatePickerIOS, import("react-native").DatePickerIOSProps, object, object>;
|
|
12
|
+
DrawerLayoutAndroid: Styled<"native", typeof import("react-native").DrawerLayoutAndroid, import("react-native").DrawerLayoutAndroidProps, object, object>;
|
|
13
|
+
FlatList: Styled<"native", typeof import("react-native").FlatList, import("react-native").FlatListProps<unknown>, object, object>;
|
|
14
|
+
Image: Styled<"native", typeof import("react-native").Image, import("react-native").ImageProps, object, object>;
|
|
15
|
+
ImageBackground: Styled<"native", typeof import("react-native").ImageBackground, import("react-native").ImageBackgroundProps, object, object>;
|
|
16
|
+
KeyboardAvoidingView: Styled<"native", typeof import("react-native").KeyboardAvoidingView, import("react-native").KeyboardAvoidingViewProps, object, object>;
|
|
17
|
+
Modal: Styled<"native", typeof import("react-native").Modal, import("react-native").ModalBaseProps & import("react-native").ModalPropsIOS & import("react-native").ModalPropsAndroid & import("react-native").ViewProps, object, object>;
|
|
18
|
+
Pressable: Styled<"native", import("react").ForwardRefExoticComponent<import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>>, import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>, object, object>;
|
|
19
|
+
ProgressBarAndroid: Styled<"native", typeof import("react-native").ProgressBarAndroid, import("react-native").ProgressBarAndroidProps, object, object>;
|
|
20
|
+
ProgressViewIOS: Styled<"native", typeof import("react-native").ProgressViewIOS, import("react-native").ProgressViewIOSProps, object, object>;
|
|
21
|
+
RefreshControl: Styled<"native", typeof import("react-native").RefreshControl, import("react-native").RefreshControlProps, object, object>;
|
|
22
|
+
SafeAreaView: Styled<"native", typeof import("react-native").SafeAreaView, import("react-native").ViewProps, object, object>;
|
|
23
|
+
ScrollView: Styled<"native", typeof import("react-native").ScrollView, import("react-native").ScrollViewProps, object, object>;
|
|
24
|
+
SectionList: Styled<"native", typeof import("react-native").SectionList, import("react-native").SectionListProps<unknown, unknown>, object, object>;
|
|
25
|
+
Slider: Styled<"native", typeof import("react-native").Slider, import("react-native").SliderProps, object, object>;
|
|
26
|
+
Switch: Styled<"native", typeof import("react-native").Switch, import("react-native").SwitchProps, object, object>;
|
|
27
|
+
Text: Styled<"native", typeof import("react-native").Text, import("react-native").TextProps, object, object>;
|
|
28
|
+
TextInput: Styled<"native", typeof import("react-native").TextInput, import("react-native").TextInputProps, object, object>;
|
|
29
|
+
TouchableHighlight: Styled<"native", typeof import("react-native").TouchableHighlight, import("react-native").TouchableHighlightProps, object, object>;
|
|
30
|
+
TouchableOpacity: Styled<"native", typeof import("react-native").TouchableOpacity, import("react-native").TouchableOpacityProps, object, object>;
|
|
31
|
+
View: Styled<"native", typeof import("react-native").View, import("react-native").ViewProps, object, object>;
|
|
32
|
+
VirtualizedList: Styled<"native", typeof import("react-native").VirtualizedList, import("react-native").VirtualizedListProps<unknown>, object, object>;
|
|
34
33
|
};
|
|
35
34
|
export { DefaultTheme, ExecutionContext, ExecutionProps, IStyledComponent, IStyledComponentFactory, IStyledStatics, NativeTarget, PolymorphicComponent, PolymorphicComponentProps, Runtime, StyledObject, StyledOptions, } from '../types';
|
|
36
35
|
export { css, isStyledComponent, ThemeProvider, ThemeConsumer, ThemeContext, withTheme, useTheme };
|
|
@@ -5,7 +5,7 @@ export declare const makeGroupedTag: (tag: Tag) => {
|
|
|
5
5
|
length: number;
|
|
6
6
|
tag: Tag;
|
|
7
7
|
indexOfGroup(group: number): number;
|
|
8
|
-
insertRules(group: number, rules: string
|
|
8
|
+
insertRules(group: number, rules: string[]): void;
|
|
9
9
|
clearGroup(group: number): void;
|
|
10
10
|
getGroup(group: number): string;
|
|
11
11
|
};
|
package/dist/sheet/Sheet.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { GroupedTag, Sheet, SheetOptions } from './types';
|
|
2
|
-
|
|
2
|
+
type SheetConstructorArgs = {
|
|
3
3
|
isServer?: boolean;
|
|
4
4
|
useCSSOMInjection?: boolean;
|
|
5
5
|
target?: HTMLElement;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type GlobalStylesAllocationMap = {
|
|
8
8
|
[key: string]: number;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type NamesAllocationMap = Map<string, Set<string>>;
|
|
11
11
|
/** Contains the main stylesheet logic for stringification and caching */
|
|
12
12
|
export default class StyleSheet implements Sheet {
|
|
13
13
|
gs: GlobalStylesAllocationMap;
|
package/dist/sheet/types.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ var traverse = require('@babel/traverse');
|
|
|
8
8
|
var babelPluginMacros = require('babel-plugin-macros');
|
|
9
9
|
var babelPlugin = require('babel-plugin-styled-components');
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
|
-
var traverse__default = /*#__PURE__*/
|
|
14
|
-
var babelPlugin__default = /*#__PURE__*/
|
|
13
|
+
var traverse__default = /*#__PURE__*/_interopDefault(traverse);
|
|
14
|
+
var babelPlugin__default = /*#__PURE__*/_interopDefault(babelPlugin);
|
|
15
15
|
|
|
16
16
|
function styledComponentsMacro(_a) {
|
|
17
17
|
var references = _a.references, state = _a.state, t = _a.babel.types, _b = _a.config, _c = _b === void 0 ? {} : _b, _d = _c.importModuleName, importModuleName = _d === void 0 ? 'styled-components' : _d, config = tslib.__rest(_c, ["importModuleName"]);
|
|
@@ -32,17 +32,16 @@ function styledComponentsMacro(_a) {
|
|
|
32
32
|
}
|
|
33
33
|
// update references with the new identifiers
|
|
34
34
|
references[refName].forEach(function (referencePath) {
|
|
35
|
-
// eslint-disable-next-line no-param-reassign
|
|
36
35
|
referencePath.node.name = id.name;
|
|
37
36
|
});
|
|
38
37
|
});
|
|
39
38
|
// SECOND STEP : apply babel-plugin-styled-components to the file
|
|
40
39
|
var stateWithOpts = tslib.__assign(tslib.__assign({}, state), { opts: tslib.__assign(tslib.__assign({}, config), { topLevelImportPaths: (config.topLevelImportPaths || []).concat(importModuleName) }), customImportName: customImportName });
|
|
41
|
-
traverse__default
|
|
40
|
+
traverse__default.default(program.parent, babelPlugin__default.default({ types: t }).visitor, undefined, stateWithOpts);
|
|
42
41
|
}
|
|
43
42
|
var index = babelPluginMacros.createMacro(styledComponentsMacro, {
|
|
44
43
|
configName: 'styledComponents',
|
|
45
44
|
});
|
|
46
45
|
|
|
47
|
-
exports
|
|
46
|
+
exports.default = index;
|
|
48
47
|
//# sourceMappingURL=styled-components-macro.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled-components-macro.cjs.js","sources":["../src/macro/index.ts"],"sourcesContent":["import { types } from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport traverse from '@babel/traverse';\nimport { createMacro, MacroParams } from 'babel-plugin-macros';\nimport babelPlugin from 'babel-plugin-styled-components';\n\nfunction styledComponentsMacro({\n references,\n state,\n babel: { types: t },\n config: { importModuleName = 'styled-components', ...config } = {},\n}: MacroParams) {\n const program = state.file.path;\n\n // FIRST STEP : replace `styled-components/macro` by `styled-components\n // references looks like this\n // { default: [path, path], css: [path], ... }\n let customImportName;\n Object.keys(references).forEach(refName => {\n // generate new identifier\n let id: types.Identifier;\n if (refName === 'default') {\n id = addDefault(program, importModuleName, { nameHint: 'styled' });\n customImportName = id;\n } else {\n id = addNamed(program, refName, importModuleName, { nameHint: refName });\n }\n\n // update references with the new identifiers\n references[refName].forEach(referencePath => {\n
|
|
1
|
+
{"version":3,"file":"styled-components-macro.cjs.js","sources":["../src/macro/index.ts"],"sourcesContent":["import { types } from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport traverse from '@babel/traverse';\nimport { createMacro, MacroParams } from 'babel-plugin-macros';\nimport babelPlugin from 'babel-plugin-styled-components';\n\nfunction styledComponentsMacro({\n references,\n state,\n babel: { types: t },\n config: { importModuleName = 'styled-components', ...config } = {},\n}: MacroParams) {\n const program = state.file.path;\n\n // FIRST STEP : replace `styled-components/macro` by `styled-components\n // references looks like this\n // { default: [path, path], css: [path], ... }\n let customImportName;\n Object.keys(references).forEach(refName => {\n // generate new identifier\n let id: types.Identifier;\n if (refName === 'default') {\n id = addDefault(program, importModuleName, { nameHint: 'styled' });\n customImportName = id;\n } else {\n id = addNamed(program, refName, importModuleName, { nameHint: refName });\n }\n\n // update references with the new identifiers\n references[refName].forEach(referencePath => {\n (referencePath.node as types.Identifier).name = id.name;\n });\n });\n\n // SECOND STEP : apply babel-plugin-styled-components to the file\n const stateWithOpts = {\n ...state,\n opts: {\n ...config,\n topLevelImportPaths: (config.topLevelImportPaths || []).concat(importModuleName),\n },\n customImportName,\n };\n traverse(program.parent, babelPlugin({ types: t }).visitor, undefined, stateWithOpts);\n}\n\nexport default createMacro(styledComponentsMacro, {\n configName: 'styledComponents',\n});\n"],"names":["__rest","addDefault","addNamed","__assign","traverse","babelPlugin","createMacro"],"mappings":";;;;;;;;;;;;;;;AAMA,SAAS,qBAAqB,CAAC,EAKjB,EAAA;IAJZ,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,KAAK,GAAA,EAAA,CAAA,KAAA,EACW,CAAC,GAAA,EAAA,CAAA,KAAA,CAAA,KAAA,EACjB,EAAA,GAAA,EAAA,CAAA,MAAkE,EAAlE,EAAA,GAAA,EAAA,KAAA,KAAA,CAAA,GAAgE,EAAE,GAAA,EAAA,EAAxD,EAAsC,GAAA,EAAA,CAAA,gBAAA,EAAtC,gBAAgB,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,mBAAmB,GAAA,EAAA,EAAK,MAAM,GAAnDA,YAAA,CAAA,EAAA,EAA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ED,YAAeC,6BAAW,CAAC,qBAAqB,EAAE;AAChD,IAAA,UAAU,EAAE,kBAAkB;AAC/B,CAAA,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled-components-macro.esm.js","sources":["../src/macro/index.ts"],"sourcesContent":["import { types } from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport traverse from '@babel/traverse';\nimport { createMacro, MacroParams } from 'babel-plugin-macros';\nimport babelPlugin from 'babel-plugin-styled-components';\n\nfunction styledComponentsMacro({\n references,\n state,\n babel: { types: t },\n config: { importModuleName = 'styled-components', ...config } = {},\n}: MacroParams) {\n const program = state.file.path;\n\n // FIRST STEP : replace `styled-components/macro` by `styled-components\n // references looks like this\n // { default: [path, path], css: [path], ... }\n let customImportName;\n Object.keys(references).forEach(refName => {\n // generate new identifier\n let id: types.Identifier;\n if (refName === 'default') {\n id = addDefault(program, importModuleName, { nameHint: 'styled' });\n customImportName = id;\n } else {\n id = addNamed(program, refName, importModuleName, { nameHint: refName });\n }\n\n // update references with the new identifiers\n references[refName].forEach(referencePath => {\n
|
|
1
|
+
{"version":3,"file":"styled-components-macro.esm.js","sources":["../src/macro/index.ts"],"sourcesContent":["import { types } from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport traverse from '@babel/traverse';\nimport { createMacro, MacroParams } from 'babel-plugin-macros';\nimport babelPlugin from 'babel-plugin-styled-components';\n\nfunction styledComponentsMacro({\n references,\n state,\n babel: { types: t },\n config: { importModuleName = 'styled-components', ...config } = {},\n}: MacroParams) {\n const program = state.file.path;\n\n // FIRST STEP : replace `styled-components/macro` by `styled-components\n // references looks like this\n // { default: [path, path], css: [path], ... }\n let customImportName;\n Object.keys(references).forEach(refName => {\n // generate new identifier\n let id: types.Identifier;\n if (refName === 'default') {\n id = addDefault(program, importModuleName, { nameHint: 'styled' });\n customImportName = id;\n } else {\n id = addNamed(program, refName, importModuleName, { nameHint: refName });\n }\n\n // update references with the new identifiers\n references[refName].forEach(referencePath => {\n (referencePath.node as types.Identifier).name = id.name;\n });\n });\n\n // SECOND STEP : apply babel-plugin-styled-components to the file\n const stateWithOpts = {\n ...state,\n opts: {\n ...config,\n topLevelImportPaths: (config.topLevelImportPaths || []).concat(importModuleName),\n },\n customImportName,\n };\n traverse(program.parent, babelPlugin({ types: t }).visitor, undefined, stateWithOpts);\n}\n\nexport default createMacro(styledComponentsMacro, {\n configName: 'styledComponents',\n});\n"],"names":[],"mappings":";;;;;;AAMA,SAAS,qBAAqB,CAAC,EAKjB,EAAA;IAJZ,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,KAAK,GAAA,EAAA,CAAA,KAAA,EACW,CAAC,GAAA,EAAA,CAAA,KAAA,CAAA,KAAA,EACjB,EAAA,GAAA,EAAA,CAAA,MAAkE,EAAlE,EAAA,GAAA,EAAA,KAAA,KAAA,CAAA,GAAgE,EAAE,GAAA,EAAA,EAAxD,EAAsC,GAAA,EAAA,CAAA,gBAAA,EAAtC,gBAAgB,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,mBAAmB,GAAA,EAAA,EAAK,MAAM,GAAnD,MAAA,CAAA,EAAA,EAAA,CAAA,kBAAA,CAAqD,CAAK,CAAA;AAElE,IAAA,IAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;;;AAKhC,IAAA,IAAI,gBAAgB,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,OAAO,EAAA;;AAErC,QAAA,IAAI,EAAoB,CAAC;QACzB,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,YAAA,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YACnE,gBAAgB,GAAG,EAAE,CAAC;AACvB,SAAA;AAAM,aAAA;AACL,YAAA,EAAE,GAAG,QAAQ,CAAC,OAAO,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