@compiled/react 0.7.0 → 0.10.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/CHANGELOG.md +68 -1
- package/dist/browser/class-names/index.d.ts +2 -2
- package/dist/browser/class-names/index.js.flow +45 -0
- package/dist/browser/class-names/index.js.map +1 -1
- package/dist/browser/css/index.d.ts +16 -3
- package/dist/browser/css/index.js +1 -13
- package/dist/browser/css/index.js.flow +35 -0
- package/dist/browser/css/index.js.map +1 -1
- package/dist/browser/index.d.ts +15 -23
- package/dist/browser/index.js +4 -0
- package/dist/browser/index.js.flow +15 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/browser/jsx/jsx-dev-runtime.js +4 -0
- package/dist/browser/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/browser/jsx/jsx-local-namespace.d.ts +40 -0
- package/dist/browser/jsx/jsx-local-namespace.js +2 -0
- package/dist/browser/jsx/jsx-local-namespace.js.map +1 -0
- package/dist/browser/jsx/jsx-runtime.d.ts +2 -0
- package/dist/browser/jsx/jsx-runtime.js +4 -0
- package/dist/browser/jsx/jsx-runtime.js.map +1 -0
- package/dist/browser/keyframes/index.js.flow +54 -0
- package/dist/browser/runtime/ax.js.flow +27 -0
- package/dist/browser/runtime/css-custom-property.d.ts +1 -1
- package/dist/browser/runtime/css-custom-property.js.flow +19 -0
- package/dist/browser/runtime/css-custom-property.js.map +1 -1
- package/dist/browser/runtime/dev-warnings.d.ts +0 -1
- package/dist/browser/runtime/dev-warnings.js +1 -1
- package/dist/browser/runtime/dev-warnings.js.flow +7 -0
- package/dist/browser/runtime/dev-warnings.js.map +1 -1
- package/dist/browser/runtime/index.js.flow +10 -0
- package/dist/browser/runtime/is-node.js.flow +19 -0
- package/dist/browser/runtime/sheet.d.ts +1 -1
- package/dist/browser/runtime/sheet.js.flow +36 -0
- package/dist/browser/runtime/style-cache.d.ts +1 -1
- package/dist/browser/runtime/style-cache.js.flow +19 -0
- package/dist/browser/runtime/style-cache.js.map +1 -1
- package/dist/browser/runtime/style.d.ts +1 -1
- package/dist/browser/runtime/style.js +2 -2
- package/dist/browser/runtime/style.js.flow +17 -0
- package/dist/browser/runtime/style.js.map +1 -1
- package/dist/browser/runtime/types.js.flow +23 -0
- package/dist/browser/runtime.js.flow +7 -0
- package/dist/browser/styled/index.d.ts +6 -9
- package/dist/browser/styled/index.js.flow +69 -0
- package/dist/browser/styled/index.js.map +1 -1
- package/dist/browser/types.d.ts +6 -3
- package/dist/browser/types.js.flow +29 -0
- package/dist/browser/utils/error.js.flow +7 -0
- package/dist/cjs/class-names/index.d.ts +2 -2
- package/dist/cjs/class-names/index.js.flow +45 -0
- package/dist/cjs/class-names/index.js.map +1 -1
- package/dist/cjs/css/index.d.ts +16 -3
- package/dist/cjs/css/index.js +1 -13
- package/dist/cjs/css/index.js.flow +35 -0
- package/dist/cjs/css/index.js.map +1 -1
- package/dist/cjs/index.d.ts +15 -23
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.flow +15 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/cjs/jsx/jsx-dev-runtime.js +16 -0
- package/dist/cjs/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/cjs/jsx/jsx-local-namespace.d.ts +40 -0
- package/dist/cjs/jsx/jsx-local-namespace.js +3 -0
- package/dist/cjs/jsx/jsx-local-namespace.js.map +1 -0
- package/dist/cjs/jsx/jsx-runtime.d.ts +2 -0
- package/dist/cjs/jsx/jsx-runtime.js +16 -0
- package/dist/cjs/jsx/jsx-runtime.js.map +1 -0
- package/dist/cjs/keyframes/index.js.flow +54 -0
- package/dist/cjs/runtime/ax.js.flow +27 -0
- package/dist/cjs/runtime/css-custom-property.d.ts +1 -1
- package/dist/cjs/runtime/css-custom-property.js.flow +19 -0
- package/dist/cjs/runtime/css-custom-property.js.map +1 -1
- package/dist/cjs/runtime/dev-warnings.d.ts +0 -1
- package/dist/cjs/runtime/dev-warnings.js +2 -3
- package/dist/cjs/runtime/dev-warnings.js.flow +7 -0
- package/dist/cjs/runtime/dev-warnings.js.map +1 -1
- package/dist/cjs/runtime/index.js.flow +10 -0
- package/dist/cjs/runtime/is-node.js.flow +19 -0
- package/dist/cjs/runtime/sheet.d.ts +1 -1
- package/dist/cjs/runtime/sheet.js.flow +36 -0
- package/dist/cjs/runtime/style-cache.d.ts +1 -1
- package/dist/cjs/runtime/style-cache.js.flow +19 -0
- package/dist/cjs/runtime/style-cache.js.map +1 -1
- package/dist/cjs/runtime/style.d.ts +1 -1
- package/dist/cjs/runtime/style.js +2 -2
- package/dist/cjs/runtime/style.js.flow +17 -0
- package/dist/cjs/runtime/style.js.map +1 -1
- package/dist/cjs/runtime/types.js.flow +23 -0
- package/dist/cjs/runtime.js.flow +7 -0
- package/dist/cjs/styled/index.d.ts +6 -9
- package/dist/cjs/styled/index.js.flow +69 -0
- package/dist/cjs/styled/index.js.map +1 -1
- package/dist/cjs/types.d.ts +6 -3
- package/dist/cjs/types.js.flow +29 -0
- package/dist/cjs/utils/error.js.flow +7 -0
- package/dist/esm/class-names/index.d.ts +2 -2
- package/dist/esm/class-names/index.js.flow +45 -0
- package/dist/esm/class-names/index.js.map +1 -1
- package/dist/esm/css/index.d.ts +16 -3
- package/dist/esm/css/index.js +1 -13
- package/dist/esm/css/index.js.flow +35 -0
- package/dist/esm/css/index.js.map +1 -1
- package/dist/esm/index.d.ts +15 -23
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.flow +15 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/esm/jsx/jsx-dev-runtime.js +4 -0
- package/dist/esm/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/esm/jsx/jsx-local-namespace.d.ts +40 -0
- package/dist/esm/jsx/jsx-local-namespace.js +2 -0
- package/dist/esm/jsx/jsx-local-namespace.js.map +1 -0
- package/dist/esm/jsx/jsx-runtime.d.ts +2 -0
- package/dist/esm/jsx/jsx-runtime.js +4 -0
- package/dist/esm/jsx/jsx-runtime.js.map +1 -0
- package/dist/esm/keyframes/index.js.flow +54 -0
- package/dist/esm/runtime/ax.js.flow +27 -0
- package/dist/esm/runtime/css-custom-property.d.ts +1 -1
- package/dist/esm/runtime/css-custom-property.js.flow +19 -0
- package/dist/esm/runtime/css-custom-property.js.map +1 -1
- package/dist/esm/runtime/dev-warnings.d.ts +0 -1
- package/dist/esm/runtime/dev-warnings.js +1 -1
- package/dist/esm/runtime/dev-warnings.js.flow +7 -0
- package/dist/esm/runtime/dev-warnings.js.map +1 -1
- package/dist/esm/runtime/index.js.flow +10 -0
- package/dist/esm/runtime/is-node.js.flow +19 -0
- package/dist/esm/runtime/sheet.d.ts +1 -1
- package/dist/esm/runtime/sheet.js.flow +36 -0
- package/dist/esm/runtime/style-cache.d.ts +1 -1
- package/dist/esm/runtime/style-cache.js.flow +19 -0
- package/dist/esm/runtime/style-cache.js.map +1 -1
- package/dist/esm/runtime/style.d.ts +1 -1
- package/dist/esm/runtime/style.js +2 -2
- package/dist/esm/runtime/style.js.flow +17 -0
- package/dist/esm/runtime/style.js.map +1 -1
- package/dist/esm/runtime/types.js.flow +23 -0
- package/dist/esm/runtime.js.flow +7 -0
- package/dist/esm/styled/index.d.ts +6 -9
- package/dist/esm/styled/index.js.flow +69 -0
- package/dist/esm/styled/index.js.map +1 -1
- package/dist/esm/types.d.ts +6 -3
- package/dist/esm/types.js.flow +29 -0
- package/dist/esm/utils/error.js.flow +7 -0
- package/jsx-dev-runtime/package.json +6 -0
- package/jsx-runtime/package.json +6 -0
- package/package.json +41 -15
- package/src/__tests__/browser.test.tsx +5 -5
- package/src/__tests__/jest-matcher.test.tsx +197 -0
- package/src/__tests__/server-side-hydrate.test.tsx +1 -0
- package/src/__tests__/ssr.test.tsx +2 -2
- package/src/class-names/__tests__/index.test.tsx +1 -1
- package/src/class-names/__tests__/types.test.js.flow +28 -0
- package/src/class-names/index.js.flow +45 -0
- package/src/class-names/index.tsx +3 -2
- package/src/css/__tests__/index.test.tsx +40 -0
- package/src/css/__tests__/types.test.js.flow +17 -0
- package/src/css/index.js.flow +35 -0
- package/src/css/index.tsx +27 -3
- package/src/index.js.flow +15 -0
- package/src/index.tsx +20 -26
- package/src/jsx/__tests__/index.test.tsx +1 -2
- package/src/jsx/__tests__/jsx-import-source-pragma.test.tsx +37 -0
- package/src/jsx/__tests__/jsx-pragma.test.tsx +39 -0
- package/src/jsx/jsx-dev-runtime.tsx +5 -0
- package/src/jsx/jsx-local-namespace.tsx +49 -0
- package/src/jsx/jsx-runtime.tsx +5 -0
- package/src/keyframes/__tests__/index.test.tsx +2 -1
- package/src/keyframes/__tests__/types.test.js.flow +31 -0
- package/src/keyframes/index.js.flow +54 -0
- package/src/runtime/__perf__/ax.test.ts +42 -0
- package/src/runtime/__perf__/cs.test.tsx +111 -0
- package/src/runtime/__perf__/sheet.test.ts +61 -0
- package/src/runtime/__perf__/utils/cs.tsx +60 -0
- package/src/runtime/__perf__/utils/sheet.tsx +151 -0
- package/src/runtime/__tests__/style-ssr.test.tsx +1 -0
- package/src/runtime/__tests__/style.test.tsx +92 -58
- package/src/runtime/ax.js.flow +27 -0
- package/src/runtime/css-custom-property.js.flow +19 -0
- package/src/runtime/css-custom-property.tsx +1 -1
- package/src/runtime/dev-warnings.js.flow +7 -0
- package/src/runtime/dev-warnings.tsx +1 -1
- package/src/runtime/index.js.flow +10 -0
- package/src/runtime/is-node.js.flow +19 -0
- package/src/runtime/sheet.js.flow +36 -0
- package/src/runtime/sheet.tsx +1 -1
- package/src/runtime/style-cache.js.flow +19 -0
- package/src/runtime/style-cache.tsx +2 -1
- package/src/runtime/style.js.flow +17 -0
- package/src/runtime/style.tsx +4 -3
- package/src/runtime/types.js.flow +23 -0
- package/src/runtime.js.flow +7 -0
- package/src/styled/__tests__/index.test.tsx +3 -3
- package/src/styled/__tests__/types.test.js.flow +30 -0
- package/src/styled/index.js.flow +69 -0
- package/src/styled/index.tsx +7 -10
- package/src/types.js.flow +29 -0
- package/src/types.tsx +7 -3
- package/src/utils/error.js.flow +7 -0
- package/dist/browser/codemods/codemods-helpers.d.ts +0 -60
- package/dist/browser/codemods/codemods-helpers.js +0 -201
- package/dist/browser/codemods/codemods-helpers.js.map +0 -1
- package/dist/browser/codemods/constants.d.ts +0 -3
- package/dist/browser/codemods/constants.js +0 -4
- package/dist/browser/codemods/constants.js.map +0 -1
- package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
- package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -178
- package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
- package/dist/browser/codemods/emotion-to-compiled/index.d.ts +0 -1
- package/dist/browser/codemods/emotion-to-compiled/index.js +0 -2
- package/dist/browser/codemods/emotion-to-compiled/index.js.map +0 -1
- package/dist/browser/codemods/styled-components-to-compiled/index.d.ts +0 -1
- package/dist/browser/codemods/styled-components-to-compiled/index.js +0 -2
- package/dist/browser/codemods/styled-components-to-compiled/index.js.map +0 -1
- package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
- package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -33
- package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
- package/dist/cjs/codemods/codemods-helpers.d.ts +0 -60
- package/dist/cjs/codemods/codemods-helpers.js +0 -217
- package/dist/cjs/codemods/codemods-helpers.js.map +0 -1
- package/dist/cjs/codemods/constants.d.ts +0 -3
- package/dist/cjs/codemods/constants.js +0 -7
- package/dist/cjs/codemods/constants.js.map +0 -1
- package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
- package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -180
- package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
- package/dist/cjs/codemods/emotion-to-compiled/index.d.ts +0 -1
- package/dist/cjs/codemods/emotion-to-compiled/index.js +0 -9
- package/dist/cjs/codemods/emotion-to-compiled/index.js.map +0 -1
- package/dist/cjs/codemods/styled-components-to-compiled/index.d.ts +0 -1
- package/dist/cjs/codemods/styled-components-to-compiled/index.js +0 -9
- package/dist/cjs/codemods/styled-components-to-compiled/index.js.map +0 -1
- package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
- package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -35
- package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
- package/dist/esm/codemods/codemods-helpers.d.ts +0 -60
- package/dist/esm/codemods/codemods-helpers.js +0 -201
- package/dist/esm/codemods/codemods-helpers.js.map +0 -1
- package/dist/esm/codemods/constants.d.ts +0 -3
- package/dist/esm/codemods/constants.js +0 -4
- package/dist/esm/codemods/constants.js.map +0 -1
- package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
- package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -178
- package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
- package/dist/esm/codemods/emotion-to-compiled/index.d.ts +0 -1
- package/dist/esm/codemods/emotion-to-compiled/index.js +0 -2
- package/dist/esm/codemods/emotion-to-compiled/index.js.map +0 -1
- package/dist/esm/codemods/styled-components-to-compiled/index.d.ts +0 -1
- package/dist/esm/codemods/styled-components-to-compiled/index.js +0 -2
- package/dist/esm/codemods/styled-components-to-compiled/index.js.map +0 -1
- package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
- package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -33
- package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
- package/src/codemods/README.md +0 -8
- package/src/codemods/codemods-helpers.tsx +0 -369
- package/src/codemods/constants.tsx +0 -3
- package/src/codemods/emotion-to-compiled/README.md +0 -71
- package/src/codemods/emotion-to-compiled/__tests__/emotion-to-compiled.test.tsx +0 -526
- package/src/codemods/emotion-to-compiled/emotion-to-compiled.tsx +0 -249
- package/src/codemods/emotion-to-compiled/index.tsx +0 -1
- package/src/codemods/styled-components-to-compiled/README.md +0 -37
- package/src/codemods/styled-components-to-compiled/__tests__/styled-components-to-compiled.test.tsx +0 -109
- package/src/codemods/styled-components-to-compiled/index.tsx +0 -1
- package/src/codemods/styled-components-to-compiled/styled-components-to-compiled.tsx +0 -45
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for index
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.15.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import type { ComponentType } from 'react';
|
|
8
|
+
import type { BasicTemplateInterpolations, CssFunction, FunctionInterpolation } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Typing for the CSS object.
|
|
11
|
+
*/
|
|
12
|
+
export type CssObject<TProps> = CssFunction<FunctionInterpolation<TProps>>;
|
|
13
|
+
/**
|
|
14
|
+
* Extra props added to the output Styled Component.
|
|
15
|
+
*/
|
|
16
|
+
export type StyledProps = {
|
|
17
|
+
as?: $Keys<$JSXIntrinsics>,
|
|
18
|
+
};
|
|
19
|
+
export type Interpolations<TProps: mixed> = (
|
|
20
|
+
| BasicTemplateInterpolations
|
|
21
|
+
| FunctionInterpolation<TProps>
|
|
22
|
+
| CssObject<TProps>
|
|
23
|
+
| CssObject<TProps>[]
|
|
24
|
+
)[];
|
|
25
|
+
/**
|
|
26
|
+
* This allows us to take the generic `TTag` (that will be a valid `DOM` tag) and then use it to
|
|
27
|
+
* define correct props based on it from `$JSXIntrinsics`, while also injecting our own
|
|
28
|
+
* props from `StyledProps`.
|
|
29
|
+
*/
|
|
30
|
+
export interface StyledFunctionFromTag<TTag: $Keys<$JSXIntrinsics>> {
|
|
31
|
+
<TProps: mixed>(
|
|
32
|
+
css: CssObject<TProps> | $ReadOnlyArray<CssObject<TProps>>,
|
|
33
|
+
...interpolations: Interpolations<TProps>
|
|
34
|
+
): React$ComponentType<{
|
|
35
|
+
...TProps,
|
|
36
|
+
...$Exact<$ElementType<$JSXIntrinsics, TTag>>,
|
|
37
|
+
...StyledProps,
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export interface StyledFunctionFromComponent<TInheritedProps: mixed> {
|
|
41
|
+
<TProps: mixed>(
|
|
42
|
+
css: CssObject<TProps> | $ReadOnlyArray<string>,
|
|
43
|
+
...interpolations: Interpolations<TProps>
|
|
44
|
+
): React$ComponentType<{ ...TProps, ...StyledProps, ...TInheritedProps }>;
|
|
45
|
+
}
|
|
46
|
+
export type StyledComponentMap = $ObjMapi<$JSXIntrinsics, <Tag>(Tag) => StyledFunctionFromTag<Tag>>;
|
|
47
|
+
export type StyledComponentInstantiator = {
|
|
48
|
+
/**
|
|
49
|
+
* Typing to enable consumers to compose components, e.g: `styled(Component)`
|
|
50
|
+
*/
|
|
51
|
+
<TInheritedProps: mixed>(
|
|
52
|
+
Component: ComponentType<TInheritedProps>
|
|
53
|
+
): StyledFunctionFromComponent<TInheritedProps>,
|
|
54
|
+
...
|
|
55
|
+
} & StyledComponentMap;
|
|
56
|
+
/**
|
|
57
|
+
* Create a component that ties styles to an element which comes with built-in behavior such as `ref` and `as` prop support.
|
|
58
|
+
*
|
|
59
|
+
* ```
|
|
60
|
+
* styled.div`font-size: 12px`; // Template literal CSS
|
|
61
|
+
* styled.div({ fontSize: 12 }); // Object CSS
|
|
62
|
+
* styled.div([{ fontSize: 12 }, `font-size: 12px;`]) // Array CSS
|
|
63
|
+
* styled.div({ fontSize: 12 }, `font-size: 12px`) Multi arguments CSS
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* For more help, read the docs:
|
|
67
|
+
* https://compiledcssinjs.com/docs/api-styled
|
|
68
|
+
*/
|
|
69
|
+
declare export var styled: StyledComponentInstantiator;
|
package/src/styled/index.tsx
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import { createSetupError } from '../utils/error';
|
|
3
|
-
import { BasicTemplateInterpolations, CssFunction, CSSProps } from '../types';
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
3
|
+
import type { BasicTemplateInterpolations, CssFunction, FunctionInterpolation } from '../types';
|
|
4
|
+
import { createSetupError } from '../utils/error';
|
|
8
5
|
|
|
9
6
|
/**
|
|
10
7
|
* Typing for the CSS object.
|
|
11
8
|
*/
|
|
12
|
-
export type CssObject<TProps> = CssFunction<
|
|
9
|
+
export type CssObject<TProps> = CssFunction<FunctionInterpolation<TProps>>;
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
* Extra props added to the output Styled Component.
|
|
@@ -20,7 +17,7 @@ export interface StyledProps {
|
|
|
20
17
|
|
|
21
18
|
export type Interpolations<TProps extends unknown> = (
|
|
22
19
|
| BasicTemplateInterpolations
|
|
23
|
-
|
|
|
20
|
+
| FunctionInterpolation<TProps>
|
|
24
21
|
| CssObject<TProps>
|
|
25
22
|
| CssObject<TProps>[]
|
|
26
23
|
)[];
|
|
@@ -34,7 +31,7 @@ export interface StyledFunctionFromTag<TTag extends keyof JSX.IntrinsicElements>
|
|
|
34
31
|
<TProps extends unknown>(
|
|
35
32
|
// Allows either string or object (`` or ({}))
|
|
36
33
|
css: CssObject<TProps> | CssObject<TProps>[],
|
|
37
|
-
...
|
|
34
|
+
...interpolations: Interpolations<TProps>
|
|
38
35
|
): React.ComponentType<TProps & JSX.IntrinsicElements[TTag] & StyledProps>;
|
|
39
36
|
}
|
|
40
37
|
|
|
@@ -42,7 +39,7 @@ export interface StyledFunctionFromComponent<TInheritedProps extends unknown> {
|
|
|
42
39
|
<TProps extends unknown>(
|
|
43
40
|
// Allows either string or object (`` or ({}))
|
|
44
41
|
css: CssObject<TProps> | TemplateStringsArray,
|
|
45
|
-
...
|
|
42
|
+
...interpolations: Interpolations<TProps>
|
|
46
43
|
): React.ComponentType<TProps & StyledProps & TInheritedProps>;
|
|
47
44
|
}
|
|
48
45
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for types
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.15.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import * as CSS from 'csstype';
|
|
8
|
+
/**
|
|
9
|
+
* Typing for the interpolations.
|
|
10
|
+
*/
|
|
11
|
+
export type BasicTemplateInterpolations = string | number;
|
|
12
|
+
export interface FunctionInterpolation<TProps> {
|
|
13
|
+
(props: TProps): CSSProps | BasicTemplateInterpolations | boolean | void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* These are all the CSS props that will exist.
|
|
17
|
+
*/
|
|
18
|
+
export type CSSProps = CSS.Properties<BasicTemplateInterpolations>;
|
|
19
|
+
export type AnyKeyCssProps<TValue> = {
|
|
20
|
+
[key: string]: AnyKeyCssProps<TValue> | CSSProps | BasicTemplateInterpolations | TValue,
|
|
21
|
+
...
|
|
22
|
+
};
|
|
23
|
+
export type CssFunction<TValue = void> =
|
|
24
|
+
| CSSProps
|
|
25
|
+
| AnyKeyCssProps<TValue>
|
|
26
|
+
| $ReadOnlyArray<string>
|
|
27
|
+
| string
|
|
28
|
+
| boolean
|
|
29
|
+
| void;
|
package/src/types.tsx
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import * as CSS from 'csstype';
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Typing for the interpolations.
|
|
5
5
|
*/
|
|
6
6
|
export type BasicTemplateInterpolations = string | number;
|
|
7
7
|
|
|
8
|
+
export interface FunctionInterpolation<TProps> {
|
|
9
|
+
(props: TProps): CSSProps | BasicTemplateInterpolations | boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* These are all the CSS props that will exist.
|
|
10
14
|
*/
|
|
11
|
-
export type CSSProps = CSS.Properties<
|
|
15
|
+
export type CSSProps = CSS.Properties<BasicTemplateInterpolations>;
|
|
12
16
|
|
|
13
17
|
export type AnyKeyCssProps<TValue> = {
|
|
14
|
-
[key: string]: AnyKeyCssProps<TValue> | CSSProps |
|
|
18
|
+
[key: string]: AnyKeyCssProps<TValue> | CSSProps | BasicTemplateInterpolations | TValue;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
export type CssFunction<TValue = void> =
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { JSCodeshift, ImportDeclaration, ImportDefaultSpecifier, ImportSpecifier, Program, Identifier, JSXIdentifier, TSTypeParameter, Node, Collection } from 'jscodeshift';
|
|
2
|
-
declare type Identifiers = Array<Identifier | JSXIdentifier | TSTypeParameter>;
|
|
3
|
-
export declare const getImportDeclarationCollection: ({ j, collection, importPath, }: {
|
|
4
|
-
j: JSCodeshift;
|
|
5
|
-
collection: Collection<any>;
|
|
6
|
-
importPath: string;
|
|
7
|
-
}) => Collection<ImportDeclaration>;
|
|
8
|
-
export declare const hasImportDeclaration: ({ j, collection, importPath, }: {
|
|
9
|
-
j: JSCodeshift;
|
|
10
|
-
collection: Collection<any>;
|
|
11
|
-
importPath: string;
|
|
12
|
-
}) => boolean;
|
|
13
|
-
export declare const getImportDefaultSpecifierName: (importDefaultSpecifierCollection: Collection<ImportDefaultSpecifier>) => string;
|
|
14
|
-
export declare const getImportSpecifierName: (importSpecifierCollection: Collection<ImportSpecifier>) => string | undefined;
|
|
15
|
-
export declare const getAllImportSpecifiers: ({ j, importDeclarationCollection, }: {
|
|
16
|
-
j: JSCodeshift;
|
|
17
|
-
importDeclarationCollection: Collection<ImportDeclaration>;
|
|
18
|
-
}) => Identifiers;
|
|
19
|
-
export declare const findImportSpecifierName: ({ j, importDeclarationCollection, importName, }: {
|
|
20
|
-
j: JSCodeshift;
|
|
21
|
-
importDeclarationCollection: Collection<ImportDeclaration>;
|
|
22
|
-
importName: string;
|
|
23
|
-
}) => string | null | undefined;
|
|
24
|
-
export declare const convertDefaultImportToNamedImport: ({ j, collection, importPath, namedImport, }: {
|
|
25
|
-
j: JSCodeshift;
|
|
26
|
-
collection: Collection<any>;
|
|
27
|
-
importPath: string;
|
|
28
|
-
namedImport: string;
|
|
29
|
-
}) => void;
|
|
30
|
-
export declare const addCommentBefore: ({ j, collection, message, }: {
|
|
31
|
-
j: JSCodeshift;
|
|
32
|
-
collection: Collection<Program>;
|
|
33
|
-
message: string;
|
|
34
|
-
}) => void;
|
|
35
|
-
export declare const addCommentToStartOfFile: ({ j, collection, message, }: {
|
|
36
|
-
j: JSCodeshift;
|
|
37
|
-
collection: Collection<Node>;
|
|
38
|
-
message: string;
|
|
39
|
-
}) => void;
|
|
40
|
-
export declare const addCommentForUnresolvedImportSpecifiers: ({ j, collection, importPath, allowedImportSpecifierNames, }: {
|
|
41
|
-
j: JSCodeshift;
|
|
42
|
-
collection: Collection<Node>;
|
|
43
|
-
importPath: string;
|
|
44
|
-
allowedImportSpecifierNames: string[];
|
|
45
|
-
}) => void;
|
|
46
|
-
export declare const addReactIdentifier: ({ j, collection, }: {
|
|
47
|
-
j: JSCodeshift;
|
|
48
|
-
collection: Collection<Node>;
|
|
49
|
-
}) => void;
|
|
50
|
-
export declare const replaceImportDeclaration: ({ j, collection, importPath, }: {
|
|
51
|
-
j: JSCodeshift;
|
|
52
|
-
collection: Collection<Node>;
|
|
53
|
-
importPath: string;
|
|
54
|
-
}) => void;
|
|
55
|
-
export declare const mergeImportSpecifiersAlongWithTheirComments: ({ j, collection, filter, }: {
|
|
56
|
-
j: JSCodeshift;
|
|
57
|
-
collection: Collection<Node>;
|
|
58
|
-
filter?: ((name: string | undefined) => boolean) | undefined;
|
|
59
|
-
}) => void;
|
|
60
|
-
export {};
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { COMPILED_IMPORT_PATH, REACT_IMPORT_PATH, REACT_IMPORT_NAME } from './constants';
|
|
2
|
-
export var getImportDeclarationCollection = function (_a) {
|
|
3
|
-
var j = _a.j, collection = _a.collection, importPath = _a.importPath;
|
|
4
|
-
var found = collection
|
|
5
|
-
.find(j.ImportDeclaration)
|
|
6
|
-
.filter(function (importDeclarationPath) { return importDeclarationPath.node.source.value === importPath; });
|
|
7
|
-
return found;
|
|
8
|
-
};
|
|
9
|
-
export var hasImportDeclaration = function (_a) {
|
|
10
|
-
var j = _a.j, collection = _a.collection, importPath = _a.importPath;
|
|
11
|
-
var result = getImportDeclarationCollection({
|
|
12
|
-
j: j,
|
|
13
|
-
collection: collection,
|
|
14
|
-
importPath: importPath,
|
|
15
|
-
});
|
|
16
|
-
return result.length > 0;
|
|
17
|
-
};
|
|
18
|
-
export var getImportDefaultSpecifierName = function (importDefaultSpecifierCollection) {
|
|
19
|
-
var name = importDefaultSpecifierCollection.nodes()[0].local.name;
|
|
20
|
-
if (!name) {
|
|
21
|
-
throw new Error('Name should exist.');
|
|
22
|
-
}
|
|
23
|
-
return name;
|
|
24
|
-
};
|
|
25
|
-
export var getImportSpecifierName = function (importSpecifierCollection) { return importSpecifierCollection.nodes()[0].local.name; };
|
|
26
|
-
export var getAllImportSpecifiers = function (_a) {
|
|
27
|
-
var j = _a.j, importDeclarationCollection = _a.importDeclarationCollection;
|
|
28
|
-
var importSpecifiersImportedNodes = [];
|
|
29
|
-
importDeclarationCollection.find(j.ImportSpecifier).forEach(function (importSpecifierPath) {
|
|
30
|
-
var node = importSpecifierPath.node.imported;
|
|
31
|
-
if (node) {
|
|
32
|
-
importSpecifiersImportedNodes.push(node);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return importSpecifiersImportedNodes;
|
|
36
|
-
};
|
|
37
|
-
export var findImportSpecifierName = function (_a) {
|
|
38
|
-
var j = _a.j, importDeclarationCollection = _a.importDeclarationCollection, importName = _a.importName;
|
|
39
|
-
var importSpecifierCollection = importDeclarationCollection
|
|
40
|
-
.find(j.ImportSpecifier)
|
|
41
|
-
.filter(function (importSpecifierPath) { return importSpecifierPath.node.imported.name === importName; });
|
|
42
|
-
if (importSpecifierCollection.length === 0) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return getImportSpecifierName(importSpecifierCollection);
|
|
46
|
-
};
|
|
47
|
-
export var convertDefaultImportToNamedImport = function (_a) {
|
|
48
|
-
var j = _a.j, collection = _a.collection, importPath = _a.importPath, namedImport = _a.namedImport;
|
|
49
|
-
var importDeclarationCollection = getImportDeclarationCollection({
|
|
50
|
-
j: j,
|
|
51
|
-
collection: collection,
|
|
52
|
-
importPath: importPath,
|
|
53
|
-
});
|
|
54
|
-
importDeclarationCollection.forEach(function (importDeclarationPath) {
|
|
55
|
-
var importDefaultSpecifierCollection = j(importDeclarationPath).find(j.ImportDefaultSpecifier);
|
|
56
|
-
if (importDefaultSpecifierCollection.length > 0) {
|
|
57
|
-
var oldNode = importDeclarationPath.node;
|
|
58
|
-
var comments = oldNode.comments;
|
|
59
|
-
j(importDeclarationPath).replaceWith([
|
|
60
|
-
j.importDeclaration([
|
|
61
|
-
j.importSpecifier(j.identifier(namedImport), j.identifier(getImportDefaultSpecifierName(importDefaultSpecifierCollection))),
|
|
62
|
-
], j.literal(COMPILED_IMPORT_PATH)),
|
|
63
|
-
]);
|
|
64
|
-
var newNode = importDeclarationPath.node;
|
|
65
|
-
if (newNode !== oldNode) {
|
|
66
|
-
newNode.comments = comments;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
// not replacing newlines (which \s does)
|
|
72
|
-
var spacesAndTabs = /[ \t]{2,}/g;
|
|
73
|
-
var lineStartWithSpaces = /^[ \t]*/gm;
|
|
74
|
-
var clean = function (value) {
|
|
75
|
-
return value
|
|
76
|
-
.replace(spacesAndTabs, ' ')
|
|
77
|
-
.replace(lineStartWithSpaces, '')
|
|
78
|
-
// using .trim() to clear the any newlines before the first text and after last text
|
|
79
|
-
.trim();
|
|
80
|
-
};
|
|
81
|
-
export var addCommentBefore = function (_a) {
|
|
82
|
-
var j = _a.j, collection = _a.collection, message = _a.message;
|
|
83
|
-
var content = " TODO(" + COMPILED_IMPORT_PATH + " codemod): " + clean(message) + " ";
|
|
84
|
-
collection.forEach(function (path) {
|
|
85
|
-
path.value.comments = path.value.comments || [];
|
|
86
|
-
var exists = path.value.comments.find(function (comment) { return comment.value === content; });
|
|
87
|
-
// avoiding duplicates of the same comment
|
|
88
|
-
if (exists) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
path.value.comments.push(j.commentBlock(content));
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
export var addCommentToStartOfFile = function (_a) {
|
|
95
|
-
var j = _a.j, collection = _a.collection, message = _a.message;
|
|
96
|
-
addCommentBefore({
|
|
97
|
-
j: j,
|
|
98
|
-
collection: collection.find(j.Program),
|
|
99
|
-
message: message,
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
export var addCommentForUnresolvedImportSpecifiers = function (_a) {
|
|
103
|
-
var j = _a.j, collection = _a.collection, importPath = _a.importPath, allowedImportSpecifierNames = _a.allowedImportSpecifierNames;
|
|
104
|
-
var importDeclarationCollection = getImportDeclarationCollection({
|
|
105
|
-
j: j,
|
|
106
|
-
collection: collection,
|
|
107
|
-
importPath: importPath,
|
|
108
|
-
});
|
|
109
|
-
var importSpecifiers = getAllImportSpecifiers({
|
|
110
|
-
j: j,
|
|
111
|
-
importDeclarationCollection: importDeclarationCollection,
|
|
112
|
-
});
|
|
113
|
-
importSpecifiers
|
|
114
|
-
.filter(function (identifierPath) { return !allowedImportSpecifierNames.includes(identifierPath.name); })
|
|
115
|
-
.forEach(function (importSpecifierPath) {
|
|
116
|
-
addCommentToStartOfFile({
|
|
117
|
-
j: j,
|
|
118
|
-
collection: collection,
|
|
119
|
-
message: "\"" + importSpecifierPath.name + "\" is not exported from \"" + COMPILED_IMPORT_PATH + "\" at the moment. Please find an alternative for it.",
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
export var addReactIdentifier = function (_a) {
|
|
124
|
-
var j = _a.j, collection = _a.collection;
|
|
125
|
-
var hasReactImportDeclaration = hasImportDeclaration({
|
|
126
|
-
j: j,
|
|
127
|
-
collection: collection,
|
|
128
|
-
importPath: REACT_IMPORT_PATH,
|
|
129
|
-
});
|
|
130
|
-
if (!hasReactImportDeclaration) {
|
|
131
|
-
collection.find(j.Program).forEach(function (programPath) {
|
|
132
|
-
programPath.node.body.unshift(j.importDeclaration([j.importNamespaceSpecifier(j.identifier(REACT_IMPORT_NAME))], j.literal(REACT_IMPORT_PATH)));
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
var importDeclarationCollection = getImportDeclarationCollection({
|
|
137
|
-
j: j,
|
|
138
|
-
collection: collection,
|
|
139
|
-
importPath: REACT_IMPORT_PATH,
|
|
140
|
-
});
|
|
141
|
-
importDeclarationCollection.forEach(function (importDeclarationPath) {
|
|
142
|
-
var importDefaultSpecifierCollection = j(importDeclarationPath).find(j.ImportDefaultSpecifier);
|
|
143
|
-
var importNamespaceSpecifierCollection = j(importDeclarationPath).find(j.ImportNamespaceSpecifier);
|
|
144
|
-
var hasNoDefaultReactImportDeclaration = importDefaultSpecifierCollection.length === 0;
|
|
145
|
-
var hasNoNamespaceReactImportDeclaration = importNamespaceSpecifierCollection.length === 0;
|
|
146
|
-
if (hasNoDefaultReactImportDeclaration &&
|
|
147
|
-
hasNoNamespaceReactImportDeclaration &&
|
|
148
|
-
importDeclarationPath.node.specifiers) {
|
|
149
|
-
importDeclarationPath.node.specifiers.unshift(j.importDefaultSpecifier(j.identifier(REACT_IMPORT_NAME)));
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
export var replaceImportDeclaration = function (_a) {
|
|
155
|
-
var j = _a.j, collection = _a.collection, importPath = _a.importPath;
|
|
156
|
-
var importDeclarationCollection = getImportDeclarationCollection({
|
|
157
|
-
j: j,
|
|
158
|
-
collection: collection,
|
|
159
|
-
importPath: importPath,
|
|
160
|
-
});
|
|
161
|
-
importDeclarationCollection.forEach(function (importDeclarationPath) {
|
|
162
|
-
importDeclarationPath.node.source.value = COMPILED_IMPORT_PATH;
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
export var mergeImportSpecifiersAlongWithTheirComments = function (_a) {
|
|
166
|
-
var j = _a.j, collection = _a.collection, _b = _a.filter, filter = _b === void 0 ? function (_) { return true; } : _b;
|
|
167
|
-
var importDeclarationCollection = getImportDeclarationCollection({
|
|
168
|
-
j: j,
|
|
169
|
-
collection: collection,
|
|
170
|
-
importPath: COMPILED_IMPORT_PATH,
|
|
171
|
-
});
|
|
172
|
-
var importSpecifiers = [];
|
|
173
|
-
importDeclarationCollection
|
|
174
|
-
.find(j.ImportSpecifier)
|
|
175
|
-
.filter(function (importSpecifierPath) { return filter(importSpecifierPath.node.imported.name); })
|
|
176
|
-
.forEach(function (importSpecifierPath) {
|
|
177
|
-
importSpecifiers.push(importSpecifierPath.node);
|
|
178
|
-
});
|
|
179
|
-
var importDeclarationCollectionLength = importDeclarationCollection.length;
|
|
180
|
-
var importDeclarationComments = [];
|
|
181
|
-
importDeclarationCollection.forEach(function (importDeclarationPath, index) {
|
|
182
|
-
var oldNode = importDeclarationPath.node;
|
|
183
|
-
var comments = oldNode.comments;
|
|
184
|
-
if (comments) {
|
|
185
|
-
importDeclarationComments.push.apply(importDeclarationComments, comments);
|
|
186
|
-
}
|
|
187
|
-
if (index === importDeclarationCollectionLength - 1) {
|
|
188
|
-
j(importDeclarationPath).replaceWith([
|
|
189
|
-
j.importDeclaration(importSpecifiers, j.literal(COMPILED_IMPORT_PATH)),
|
|
190
|
-
]);
|
|
191
|
-
var newNode = importDeclarationPath.node;
|
|
192
|
-
if (newNode !== oldNode) {
|
|
193
|
-
newNode.comments = importDeclarationComments;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
j(importDeclarationPath).remove();
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
//# sourceMappingURL=codemods-helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codemods-helpers.js","sourceRoot":"","sources":["../../../src/codemods/codemods-helpers.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIzF,MAAM,CAAC,IAAM,8BAA8B,GAAG,UAAC,EAQ9C;QAPC,CAAC,OAAA,EACD,UAAU,gBAAA,EACV,UAAU,gBAAA;IAMV,IAAM,KAAK,GAAkC,UAAU;SACpD,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC;SACzB,MAAM,CAAC,UAAC,qBAAqB,IAAK,OAAA,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,EAAtD,CAAsD,CAAC,CAAC;IAE7F,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAAC,EAQpC;QAPC,CAAC,OAAA,EACD,UAAU,gBAAA,EACV,UAAU,gBAAA;IAMV,IAAM,MAAM,GAAkC,8BAA8B,CAAC;QAC3E,CAAC,GAAA;QACD,UAAU,YAAA;QACV,UAAU,YAAA;KACX,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,6BAA6B,GAAG,UAC3C,gCAAoE;IAEpE,IAAM,IAAI,GAAG,gCAAgC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAE,CAAC,KAAM,CAAC,IAAI,CAAC;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appings":"AAAA,MAAM,CAAC,IAAM,oBAAoB,GAAG,iBAAiB,CAAC;AACtD,MAAM,CAAC,IAAM,iBAAiB,GAAG,OAAO,CAAC;AACzC,MAAM,CAAC,IAAM,iBAAiB,GAAG,OAAO,CAAC"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
2
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
3
|
-
to[j] = from[i];
|
|
4
|
-
return to;
|
|
5
|
-
};
|
|
6
|
-
import { COMPILED_IMPORT_PATH } from '../constants';
|
|
7
|
-
import { hasImportDeclaration, getImportDeclarationCollection, findImportSpecifierName, addCommentForUnresolvedImportSpecifiers, addReactIdentifier, convertDefaultImportToNamedImport, replaceImportDeclaration, mergeImportSpecifiersAlongWithTheirComments, addCommentBefore, } from '../codemods-helpers';
|
|
8
|
-
var imports = {
|
|
9
|
-
compiledStyledImportName: 'styled',
|
|
10
|
-
emotionStyledPackageName: '@emotion/styled',
|
|
11
|
-
emotionCoreJSXPragma: '@jsx jsx',
|
|
12
|
-
emotionCoreImportNames: { jsx: 'jsx', css: 'css', ClassNames: 'ClassNames' },
|
|
13
|
-
emotionCorePackageName: '@emotion/core',
|
|
14
|
-
};
|
|
15
|
-
var removeEmotionCoreJSXPragma = function (j, collection) {
|
|
16
|
-
var commentCollection = collection.find(j.Comment);
|
|
17
|
-
commentCollection.forEach(function (commentPath) {
|
|
18
|
-
var commentBlockCollection = j(commentPath).filter(function (commentBlockPath) {
|
|
19
|
-
return commentBlockPath.value.value.includes(imports.emotionCoreJSXPragma);
|
|
20
|
-
});
|
|
21
|
-
commentBlockCollection.forEach(function (commentBlockPath) {
|
|
22
|
-
j(commentBlockPath).remove();
|
|
23
|
-
addReactIdentifier({ j: j, collection: collection });
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
var replaceEmotionCoreCSSTaggedTemplateExpression = function (j, collection) {
|
|
28
|
-
var importDeclarationCollection = getImportDeclarationCollection({
|
|
29
|
-
j: j,
|
|
30
|
-
collection: collection,
|
|
31
|
-
importPath: imports.emotionCorePackageName,
|
|
32
|
-
});
|
|
33
|
-
var name = findImportSpecifierName({
|
|
34
|
-
j: j,
|
|
35
|
-
importDeclarationCollection: importDeclarationCollection,
|
|
36
|
-
importName: imports.emotionCoreImportNames.css,
|
|
37
|
-
});
|
|
38
|
-
if (name == null) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
collection
|
|
42
|
-
.find(j.TaggedTemplateExpression)
|
|
43
|
-
.filter(function (taggedTemplateExpressionPath) {
|
|
44
|
-
return j(taggedTemplateExpressionPath)
|
|
45
|
-
.find(j.Identifier)
|
|
46
|
-
.some(function (identifierPath) { return identifierPath.node.name === name; });
|
|
47
|
-
})
|
|
48
|
-
.forEach(function (taggedTemplateExpressionPath) {
|
|
49
|
-
var quasi = taggedTemplateExpressionPath.node.quasi;
|
|
50
|
-
if (quasi) {
|
|
51
|
-
j(taggedTemplateExpressionPath).replaceWith([quasi]);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
var handleClassNamesCXBehavior = function (j, objectPattern) {
|
|
56
|
-
var cxIdentifierName = 'cx';
|
|
57
|
-
var axIdentifierName = 'ax';
|
|
58
|
-
var compiledRuntimePackageName = COMPILED_IMPORT_PATH + "/runtime";
|
|
59
|
-
var cxObjectPropertyCollection = j(objectPattern)
|
|
60
|
-
.find(j.ObjectProperty)
|
|
61
|
-
.filter(function (objectPropertyPath) {
|
|
62
|
-
return objectPropertyPath.node.key.type === 'Identifier' &&
|
|
63
|
-
objectPropertyPath.node.key.name === cxIdentifierName;
|
|
64
|
-
});
|
|
65
|
-
cxObjectPropertyCollection.forEach(function (cxObjectPropertyPath) {
|
|
66
|
-
addCommentBefore({
|
|
67
|
-
j: j,
|
|
68
|
-
collection: j(cxObjectPropertyPath.node),
|
|
69
|
-
message: "Please replace \"" + cxIdentifierName + "\" with \"" + axIdentifierName + "\" from \"" + compiledRuntimePackageName + "\".\n Usage: import { " + axIdentifierName + " } from '" + compiledRuntimePackageName + "';\n\n NOTE: Both \"" + cxIdentifierName + "\" and \"" + axIdentifierName + "\" have some differences, so we have not replaced its usage.\n Please check the docs for \"" + axIdentifierName + "\" usage.\n\n In future, we will expose \"" + axIdentifierName + "\" directly from \"" + imports.emotionCoreImportNames.ClassNames + "\" props.\n\n Issue tracked on Github: https://github.com/atlassian-labs/compiled/issues/373",
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
var handleClassNamesStyleBehavior = function (j, objectPattern) {
|
|
74
|
-
var styleIdentifierName = 'style';
|
|
75
|
-
var hasStyleObjectProperty = j(objectPattern)
|
|
76
|
-
.find(j.ObjectProperty)
|
|
77
|
-
.some(function (objectPropertyPath) {
|
|
78
|
-
return objectPropertyPath.node.key.type === 'Identifier' &&
|
|
79
|
-
objectPropertyPath.node.key.name === styleIdentifierName;
|
|
80
|
-
});
|
|
81
|
-
if (!hasStyleObjectProperty) {
|
|
82
|
-
var styleObjectProperty = j.objectProperty(j.identifier(styleIdentifierName), j.identifier(styleIdentifierName));
|
|
83
|
-
objectPattern.properties.push(styleObjectProperty);
|
|
84
|
-
addCommentBefore({
|
|
85
|
-
j: j,
|
|
86
|
-
collection: j(styleObjectProperty),
|
|
87
|
-
message: "We have exported \"" + styleIdentifierName + "\" from \"" + imports.emotionCoreImportNames.ClassNames + "\" props.\n If you are using dynamic declarations, make sure to set the \"" + styleIdentifierName + "\"\n prop otherwise remove it.",
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
var handleClassNamesBehavior = function (j, collection) {
|
|
92
|
-
var importDeclarationCollection = getImportDeclarationCollection({
|
|
93
|
-
j: j,
|
|
94
|
-
collection: collection,
|
|
95
|
-
importPath: imports.emotionCorePackageName,
|
|
96
|
-
});
|
|
97
|
-
var name = findImportSpecifierName({
|
|
98
|
-
j: j,
|
|
99
|
-
importDeclarationCollection: importDeclarationCollection,
|
|
100
|
-
importName: imports.emotionCoreImportNames.ClassNames,
|
|
101
|
-
});
|
|
102
|
-
if (name == null) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
collection
|
|
106
|
-
.find(j.JSXElement)
|
|
107
|
-
.filter(function (jsxElementPath) {
|
|
108
|
-
return j(jsxElementPath)
|
|
109
|
-
.find(j.JSXIdentifier)
|
|
110
|
-
.some(function (jsxIdentifierPath) { return jsxIdentifierPath.node.name === name; });
|
|
111
|
-
})
|
|
112
|
-
.find(j.JSXExpressionContainer)
|
|
113
|
-
.forEach(function (jsxExpressionContainer) {
|
|
114
|
-
var expression = jsxExpressionContainer.node.expression;
|
|
115
|
-
if (expression.type === 'FunctionExpression' ||
|
|
116
|
-
expression.type === 'ArrowFunctionExpression') {
|
|
117
|
-
if (expression.params.length && expression.params[0].type === 'ObjectPattern') {
|
|
118
|
-
var objectPattern = expression.params[0];
|
|
119
|
-
handleClassNamesStyleBehavior(j, objectPattern);
|
|
120
|
-
handleClassNamesCXBehavior(j, objectPattern);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
var mergeCompiledImportSpecifiers = function (j, collection) {
|
|
126
|
-
var allowedCompiledNames = __spreadArray([
|
|
127
|
-
imports.compiledStyledImportName
|
|
128
|
-
], Object.values(imports.emotionCoreImportNames)).filter(function (name) {
|
|
129
|
-
return ![imports.emotionCoreImportNames.jsx, imports.emotionCoreImportNames.css].includes(name);
|
|
130
|
-
});
|
|
131
|
-
mergeImportSpecifiersAlongWithTheirComments({
|
|
132
|
-
j: j,
|
|
133
|
-
collection: collection,
|
|
134
|
-
filter: function (name) { return !!(name && allowedCompiledNames.includes(name)); },
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
var transformer = function (fileInfo, _a, options) {
|
|
138
|
-
var j = _a.jscodeshift;
|
|
139
|
-
var source = fileInfo.source;
|
|
140
|
-
var collection = j(source);
|
|
141
|
-
var hasEmotionCoreImportDeclaration = hasImportDeclaration({
|
|
142
|
-
j: j,
|
|
143
|
-
collection: collection,
|
|
144
|
-
importPath: imports.emotionCorePackageName,
|
|
145
|
-
});
|
|
146
|
-
var hasEmotionStyledImportDeclaration = hasImportDeclaration({
|
|
147
|
-
j: j,
|
|
148
|
-
collection: collection,
|
|
149
|
-
importPath: imports.emotionStyledPackageName,
|
|
150
|
-
});
|
|
151
|
-
if (!hasEmotionCoreImportDeclaration && !hasEmotionStyledImportDeclaration) {
|
|
152
|
-
return source;
|
|
153
|
-
}
|
|
154
|
-
if (hasEmotionStyledImportDeclaration) {
|
|
155
|
-
convertDefaultImportToNamedImport({
|
|
156
|
-
j: j,
|
|
157
|
-
collection: collection,
|
|
158
|
-
importPath: imports.emotionStyledPackageName,
|
|
159
|
-
namedImport: imports.compiledStyledImportName,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (hasEmotionCoreImportDeclaration) {
|
|
163
|
-
removeEmotionCoreJSXPragma(j, collection);
|
|
164
|
-
addCommentForUnresolvedImportSpecifiers({
|
|
165
|
-
j: j,
|
|
166
|
-
collection: collection,
|
|
167
|
-
importPath: imports.emotionCorePackageName,
|
|
168
|
-
allowedImportSpecifierNames: Object.values(imports.emotionCoreImportNames),
|
|
169
|
-
});
|
|
170
|
-
replaceEmotionCoreCSSTaggedTemplateExpression(j, collection);
|
|
171
|
-
handleClassNamesBehavior(j, collection);
|
|
172
|
-
replaceImportDeclaration({ j: j, collection: collection, importPath: imports.emotionCorePackageName });
|
|
173
|
-
}
|
|
174
|
-
mergeCompiledImportSpecifiers(j, collection);
|
|
175
|
-
return collection.toSource(options.printOptions || { quote: 'single' });
|
|
176
|
-
};
|
|
177
|
-
export default transformer;
|
|
178
|
-
//# sourceMappingURL=emotion-to-compiled.js.map
|