@tarojs/rn-style-transformer 4.0.1 → 4.0.3-alpha.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/LICENSE +8 -8
- package/README.md +36 -21
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/transforms/StyleSheet/ColorPropType.d.ts +10 -0
- package/dist/transforms/StyleSheet/ColorPropType.js.map +1 -1
- package/dist/transforms/StyleSheet/ImageResizeMode.d.ts +6 -0
- package/dist/transforms/StyleSheet/ImageStylePropTypes.d.ts +128 -0
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/LayoutPropTypes.d.ts +388 -0
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.d.ts +45 -0
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js +1 -1
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js.map +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.d.ts +15 -0
- package/dist/transforms/StyleSheet/StyleSheetValidation.js +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.js.map +1 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.d.ts +191 -0
- package/dist/transforms/StyleSheet/TextStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/TransformPropTypes.d.ts +67 -0
- package/dist/transforms/StyleSheet/TransformPropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.d.ts +136 -0
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/deprecatedPropType.d.ts +13 -0
- package/dist/transforms/StyleSheet/deprecatedPropType.js.map +1 -1
- package/dist/transforms/StyleSheet/index.d.ts +2 -0
- package/dist/transforms/StyleSheet/normalizeColor.d.ts +10 -0
- package/dist/transforms/StyleSheet/normalizeColor.js.map +1 -1
- package/dist/transforms/index.d.ts +56 -0
- package/dist/transforms/index.js +6 -6
- package/dist/transforms/index.js.map +1 -1
- package/dist/transforms/less.d.ts +2 -0
- package/dist/transforms/less.js +1 -1
- package/dist/transforms/less.js.map +1 -1
- package/dist/transforms/postcss.d.ts +13 -0
- package/dist/transforms/postcss.js +17 -5
- package/dist/transforms/postcss.js.map +1 -1
- package/dist/transforms/sass.d.ts +2 -0
- package/dist/transforms/sass.js +2 -2
- package/dist/transforms/sass.js.map +1 -1
- package/dist/transforms/stylus.d.ts +3 -0
- package/dist/transforms/stylus.js +1 -1
- package/dist/transforms/stylus.js.map +1 -1
- package/dist/types/index.d.ts +206 -0
- package/dist/utils/index.d.ts +21 -0
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lessImport.d.ts +5 -0
- package/dist/utils/reporterSkip.d.ts +7 -0
- package/dist/utils/reporterSkip.js.map +1 -1
- package/package.json +34 -31
- package/.eslintrc.js +0 -8
- package/__tests__/config.spec.js +0 -203
- package/__tests__/index.spec.js +0 -252
- package/__tests__/platform.spec.js +0 -78
- package/__tests__/styles/b.css +0 -3
- package/__tests__/styles/b.less +0 -3
- package/__tests__/styles/b.rn.css +0 -3
- package/__tests__/styles/b.scss +0 -3
- package/__tests__/styles/b.styl +0 -3
- package/__tests__/styles/c.css +0 -3
- package/__tests__/styles/c.less +0 -5
- package/__tests__/styles/c.rn.scss +0 -5
- package/__tests__/styles/c.scss +0 -5
- package/__tests__/styles/d.rn.scss +0 -3
- package/__tests__/styles/d.scss +0 -3
- package/__tests__/styles/mixins.scss +0 -18
- package/__tests__/styles/nest.rn.less +0 -3
- package/__tests__/styles/variable.scss +0 -1
- package/babel.config.js +0 -12
- package/jest.config.js +0 -8
- package/src/config/rn-stylelint.json +0 -5
- package/src/index.ts +0 -52
- package/src/transforms/StyleSheet/ColorPropType.ts +0 -76
- package/src/transforms/StyleSheet/ImageResizeMode.ts +0 -50
- package/src/transforms/StyleSheet/ImageStylePropTypes.ts +0 -62
- package/src/transforms/StyleSheet/LayoutPropTypes.ts +0 -559
- package/src/transforms/StyleSheet/ShadowPropTypesIOS.ts +0 -48
- package/src/transforms/StyleSheet/StyleSheetValidation.ts +0 -81
- package/src/transforms/StyleSheet/TextStylePropTypes.ts +0 -123
- package/src/transforms/StyleSheet/TransformPropTypes.ts +0 -109
- package/src/transforms/StyleSheet/ViewStylePropTypes.ts +0 -61
- package/src/transforms/StyleSheet/deprecatedPropType.ts +0 -31
- package/src/transforms/StyleSheet/index.ts +0 -5
- package/src/transforms/StyleSheet/normalizeColor.ts +0 -369
- package/src/transforms/index.ts +0 -231
- package/src/transforms/less.ts +0 -50
- package/src/transforms/postcss.ts +0 -96
- package/src/transforms/sass.ts +0 -151
- package/src/transforms/stylus.ts +0 -124
- package/src/types/index.ts +0 -242
- package/src/utils/index.ts +0 -229
- package/src/utils/lessImport.ts +0 -50
- package/src/utils/reporterSkip.ts +0 -27
- package/tsconfig.json +0 -12
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 对于不能打包到 RN 的样式,可以用 mixins 引入,相对美观一些
|
|
3
|
-
*/
|
|
4
|
-
@mixin eject($attr, $value) {
|
|
5
|
-
/*postcss-pxtransform rn eject enable*/
|
|
6
|
-
#{$attr}: $value;
|
|
7
|
-
/*postcss-pxtransform rn eject disable*/
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* // TODO 1px 的线在各端上实现方式不同,统一出来后续再兼容,目前注意两点:
|
|
12
|
-
* 1. Taro 中大写的 PX 不会被编译成 rpx/em,但 RN 还未兼容该写法
|
|
13
|
-
* 2. H5 中 1px(转成 rem 后实际小于 0.5px) + border-radius 会导致 border 不显示
|
|
14
|
-
*/
|
|
15
|
-
@mixin hairline($attr) {
|
|
16
|
-
#{$attr}: 1px;
|
|
17
|
-
@include eject($attr, 1PX);
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$base-color: #c6538c;
|
package/babel.config.js
DELETED
package/jest.config.js
DELETED
package/src/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
|
|
3
|
-
import StyleTransform from './transforms'
|
|
4
|
-
import { Config, TransformOptions } from './types'
|
|
5
|
-
|
|
6
|
-
const RN_CSS_EXT = ['.css', '.scss', '.sass', '.less', '.styl', '.stylus']
|
|
7
|
-
const upstreamTransformer = require('metro-react-native-babel-transformer')
|
|
8
|
-
|
|
9
|
-
const getSingleStyleTransform = styleTransformIns()
|
|
10
|
-
|
|
11
|
-
function styleTransformIns () {
|
|
12
|
-
let styleTransform: StyleTransform | null = null
|
|
13
|
-
return function (config: Config) {
|
|
14
|
-
// 初始化 config
|
|
15
|
-
if (!styleTransform) {
|
|
16
|
-
styleTransform = new StyleTransform(config)
|
|
17
|
-
}
|
|
18
|
-
return styleTransform
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function transform (src: string, filename: string, options: TransformOptions) {
|
|
23
|
-
if (typeof src === 'object') {
|
|
24
|
-
// handle RN >= 0.46
|
|
25
|
-
({ src, filename, options } = src)
|
|
26
|
-
}
|
|
27
|
-
const ext = path.extname(filename)
|
|
28
|
-
if (RN_CSS_EXT.includes(ext)) {
|
|
29
|
-
const styleTransform = getSingleStyleTransform(options.config)
|
|
30
|
-
const styles = await styleTransform.transform(src, filename, options)
|
|
31
|
-
return upstreamTransformer.transform({
|
|
32
|
-
src: styles,
|
|
33
|
-
filename,
|
|
34
|
-
options
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
return upstreamTransformer.transform({ src, filename, options })
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function rollupTransform (options: TransformOptions) {
|
|
41
|
-
return {
|
|
42
|
-
name: 'rn-style-transformer', // this name will show up in warnings and errors
|
|
43
|
-
async transform (src: string, filename: string) {
|
|
44
|
-
const ext = path.extname(filename)
|
|
45
|
-
if (RN_CSS_EXT.includes(ext)) {
|
|
46
|
-
const styleTransform = getSingleStyleTransform(options.config)
|
|
47
|
-
const code = await styleTransform.transform(src, filename, options)
|
|
48
|
-
return { code }
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict'
|
|
11
|
-
|
|
12
|
-
import normalizeColor from './normalizeColor'
|
|
13
|
-
|
|
14
|
-
const colorPropType = function (
|
|
15
|
-
isRequired,
|
|
16
|
-
props,
|
|
17
|
-
propName,
|
|
18
|
-
componentName,
|
|
19
|
-
location,
|
|
20
|
-
propFullName
|
|
21
|
-
) {
|
|
22
|
-
const color = props[propName]
|
|
23
|
-
if (color === undefined || color === null) {
|
|
24
|
-
if (isRequired) {
|
|
25
|
-
return new Error(
|
|
26
|
-
'Required ' +
|
|
27
|
-
location +
|
|
28
|
-
' `' +
|
|
29
|
-
(propFullName || propName) +
|
|
30
|
-
'` was not specified in `' +
|
|
31
|
-
componentName +
|
|
32
|
-
'`.'
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (typeof color === 'number') {
|
|
39
|
-
// Developers should not use a number, but we are using the prop type
|
|
40
|
-
// both for user provided colors and for transformed ones. This isn't ideal
|
|
41
|
-
// and should be fixed but will do for now...
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (normalizeColor(color) === null) {
|
|
46
|
-
return new Error(
|
|
47
|
-
'Invalid ' +
|
|
48
|
-
location +
|
|
49
|
-
' `' +
|
|
50
|
-
(propFullName || propName) +
|
|
51
|
-
'` supplied to `' +
|
|
52
|
-
componentName +
|
|
53
|
-
'`: ' +
|
|
54
|
-
color +
|
|
55
|
-
'\n' +
|
|
56
|
-
`Valid color formats are
|
|
57
|
-
- '#f0f' (#rgb)
|
|
58
|
-
- '#f0fc' (#rgba)
|
|
59
|
-
- '#ff00ff' (#rrggbb)
|
|
60
|
-
- '#ff00ff00' (#rrggbbaa)
|
|
61
|
-
- 'rgb(255, 255, 255)'
|
|
62
|
-
- 'rgba(255, 255, 255, 1.0)'
|
|
63
|
-
- 'hsl(360, 100%, 100%)'
|
|
64
|
-
- 'hsla(360, 100%, 100%, 1.0)'
|
|
65
|
-
- 'transparent'
|
|
66
|
-
- 'red'
|
|
67
|
-
- 0xff00ff00 (0xrrggbbaa)
|
|
68
|
-
`
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const ColorPropType = colorPropType.bind(null, false /* isRequired */)
|
|
74
|
-
ColorPropType.isRequired = colorPropType.bind(null, true /* isRequired */)
|
|
75
|
-
|
|
76
|
-
export default ColorPropType
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
|
11
|
-
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
|
12
|
-
* run Flow. */
|
|
13
|
-
import keyMirror from 'fbjs/lib/keyMirror'
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* ImageResizeMode - Enum for different image resizing modes, set via
|
|
17
|
-
* `resizeMode` style property on `<Image>` components.
|
|
18
|
-
*/
|
|
19
|
-
const ImageResizeMode = keyMirror({
|
|
20
|
-
/**
|
|
21
|
-
* contain - The image will be resized such that it will be completely
|
|
22
|
-
* visible, contained within the frame of the View.
|
|
23
|
-
*/
|
|
24
|
-
contain: null,
|
|
25
|
-
/**
|
|
26
|
-
* cover - The image will be resized such that the entire area of the view
|
|
27
|
-
* is covered by the image, potentially clipping parts of the image.
|
|
28
|
-
*/
|
|
29
|
-
cover: null,
|
|
30
|
-
/**
|
|
31
|
-
* stretch - The image will be stretched to fill the entire frame of the
|
|
32
|
-
* view without clipping. This may change the aspect ratio of the image,
|
|
33
|
-
* distorting it.
|
|
34
|
-
*/
|
|
35
|
-
stretch: null,
|
|
36
|
-
/**
|
|
37
|
-
* center - The image will be scaled down such that it is completely visible,
|
|
38
|
-
* if bigger than the area of the view.
|
|
39
|
-
* The image will not be scaled up.
|
|
40
|
-
*/
|
|
41
|
-
center: null,
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* repeat - The image will be repeated to cover the frame of the View. The
|
|
45
|
-
* image will keep it's size and aspect ratio.
|
|
46
|
-
*/
|
|
47
|
-
repeat: null
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
export default ImageResizeMode
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict'
|
|
11
|
-
|
|
12
|
-
import ColorPropType from './ColorPropType'
|
|
13
|
-
import ImageResizeMode from './ImageResizeMode'
|
|
14
|
-
import LayoutPropTypes from './LayoutPropTypes'
|
|
15
|
-
import * as ReactPropTypes from 'prop-types'
|
|
16
|
-
import ShadowPropTypesIOS from './ShadowPropTypesIOS'
|
|
17
|
-
import TransformPropTypes from './TransformPropTypes'
|
|
18
|
-
|
|
19
|
-
const ImageStylePropTypes = {
|
|
20
|
-
...LayoutPropTypes,
|
|
21
|
-
...ShadowPropTypesIOS,
|
|
22
|
-
...TransformPropTypes,
|
|
23
|
-
resizeMode: ReactPropTypes.oneOf(Object.keys(ImageResizeMode)),
|
|
24
|
-
backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']),
|
|
25
|
-
backgroundColor: ColorPropType,
|
|
26
|
-
borderColor: ColorPropType,
|
|
27
|
-
borderWidth: ReactPropTypes.number,
|
|
28
|
-
borderRadius: ReactPropTypes.number,
|
|
29
|
-
overflow: ReactPropTypes.oneOf(['visible', 'hidden']),
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Changes the color of all the non-transparent pixels to the tintColor.
|
|
33
|
-
*/
|
|
34
|
-
tintColor: ColorPropType,
|
|
35
|
-
opacity: ReactPropTypes.number,
|
|
36
|
-
/**
|
|
37
|
-
* When the image has rounded corners, specifying an overlayColor will
|
|
38
|
-
* cause the remaining space in the corners to be filled with a solid color.
|
|
39
|
-
* This is useful in cases which are not supported by the Android
|
|
40
|
-
* implementation of rounded corners:
|
|
41
|
-
* - Certain resize modes, such as 'contain'
|
|
42
|
-
* - Animated GIFs
|
|
43
|
-
*
|
|
44
|
-
* A typical way to use this prop is with images displayed on a solid
|
|
45
|
-
* background and setting the `overlayColor` to the same color
|
|
46
|
-
* as the background.
|
|
47
|
-
*
|
|
48
|
-
* For details of how this works under the hood, see
|
|
49
|
-
* http://frescolib.org/docs/rounded-corners-and-circles.html
|
|
50
|
-
*
|
|
51
|
-
* @platform android
|
|
52
|
-
*/
|
|
53
|
-
overlayColor: ReactPropTypes.string,
|
|
54
|
-
|
|
55
|
-
// Android-Specific styles
|
|
56
|
-
borderTopLeftRadius: ReactPropTypes.number,
|
|
57
|
-
borderTopRightRadius: ReactPropTypes.number,
|
|
58
|
-
borderBottomLeftRadius: ReactPropTypes.number,
|
|
59
|
-
borderBottomRightRadius: ReactPropTypes.number
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default ImageStylePropTypes
|