@tarojs/rn-style-transformer 4.0.0-beta.74 → 4.0.0-beta.76

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.
Files changed (94) hide show
  1. package/LICENSE +1 -8
  2. package/dist/index.d.ts +8 -0
  3. package/dist/index.js +3 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/transforms/StyleSheet/ColorPropType.d.ts +10 -0
  6. package/dist/transforms/StyleSheet/ColorPropType.js.map +1 -1
  7. package/dist/transforms/StyleSheet/ImageResizeMode.d.ts +6 -0
  8. package/dist/transforms/StyleSheet/ImageStylePropTypes.d.ts +128 -0
  9. package/dist/transforms/StyleSheet/ImageStylePropTypes.js +1 -1
  10. package/dist/transforms/StyleSheet/ImageStylePropTypes.js.map +1 -1
  11. package/dist/transforms/StyleSheet/LayoutPropTypes.d.ts +388 -0
  12. package/dist/transforms/StyleSheet/ShadowPropTypesIOS.d.ts +45 -0
  13. package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js +1 -1
  14. package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js.map +1 -1
  15. package/dist/transforms/StyleSheet/StyleSheetValidation.d.ts +15 -0
  16. package/dist/transforms/StyleSheet/StyleSheetValidation.js +1 -1
  17. package/dist/transforms/StyleSheet/StyleSheetValidation.js.map +1 -1
  18. package/dist/transforms/StyleSheet/TextStylePropTypes.d.ts +191 -0
  19. package/dist/transforms/StyleSheet/TextStylePropTypes.js +1 -1
  20. package/dist/transforms/StyleSheet/TextStylePropTypes.js.map +1 -1
  21. package/dist/transforms/StyleSheet/TransformPropTypes.d.ts +67 -0
  22. package/dist/transforms/StyleSheet/TransformPropTypes.js.map +1 -1
  23. package/dist/transforms/StyleSheet/ViewStylePropTypes.d.ts +136 -0
  24. package/dist/transforms/StyleSheet/ViewStylePropTypes.js +1 -1
  25. package/dist/transforms/StyleSheet/ViewStylePropTypes.js.map +1 -1
  26. package/dist/transforms/StyleSheet/deprecatedPropType.d.ts +13 -0
  27. package/dist/transforms/StyleSheet/deprecatedPropType.js.map +1 -1
  28. package/dist/transforms/StyleSheet/index.d.ts +2 -0
  29. package/dist/transforms/StyleSheet/normalizeColor.d.ts +10 -0
  30. package/dist/transforms/StyleSheet/normalizeColor.js.map +1 -1
  31. package/dist/transforms/index.d.ts +56 -0
  32. package/dist/transforms/index.js +5 -5
  33. package/dist/transforms/index.js.map +1 -1
  34. package/dist/transforms/less.d.ts +2 -0
  35. package/dist/transforms/less.js.map +1 -1
  36. package/dist/transforms/postcss.d.ts +13 -0
  37. package/dist/transforms/postcss.js +5 -1
  38. package/dist/transforms/postcss.js.map +1 -1
  39. package/dist/transforms/sass.d.ts +2 -0
  40. package/dist/transforms/sass.js.map +1 -1
  41. package/dist/transforms/stylus.d.ts +3 -0
  42. package/dist/transforms/stylus.js +1 -1
  43. package/dist/transforms/stylus.js.map +1 -1
  44. package/dist/types/index.d.ts +206 -0
  45. package/dist/utils/index.d.ts +21 -0
  46. package/dist/utils/index.js.map +1 -1
  47. package/dist/utils/lessImport.d.ts +5 -0
  48. package/dist/utils/reporterSkip.d.ts +7 -0
  49. package/dist/utils/reporterSkip.js.map +1 -1
  50. package/package.json +32 -31
  51. package/.eslintrc.js +0 -8
  52. package/__tests__/config.spec.js +0 -203
  53. package/__tests__/index.spec.js +0 -252
  54. package/__tests__/platform.spec.js +0 -78
  55. package/__tests__/styles/b.css +0 -3
  56. package/__tests__/styles/b.less +0 -3
  57. package/__tests__/styles/b.rn.css +0 -3
  58. package/__tests__/styles/b.scss +0 -3
  59. package/__tests__/styles/b.styl +0 -3
  60. package/__tests__/styles/c.css +0 -3
  61. package/__tests__/styles/c.less +0 -5
  62. package/__tests__/styles/c.rn.scss +0 -5
  63. package/__tests__/styles/c.scss +0 -5
  64. package/__tests__/styles/d.rn.scss +0 -3
  65. package/__tests__/styles/d.scss +0 -3
  66. package/__tests__/styles/mixins.scss +0 -18
  67. package/__tests__/styles/nest.rn.less +0 -3
  68. package/__tests__/styles/variable.scss +0 -1
  69. package/babel.config.js +0 -12
  70. package/jest.config.js +0 -8
  71. package/src/config/rn-stylelint.json +0 -5
  72. package/src/index.ts +0 -52
  73. package/src/transforms/StyleSheet/ColorPropType.ts +0 -76
  74. package/src/transforms/StyleSheet/ImageResizeMode.ts +0 -50
  75. package/src/transforms/StyleSheet/ImageStylePropTypes.ts +0 -62
  76. package/src/transforms/StyleSheet/LayoutPropTypes.ts +0 -559
  77. package/src/transforms/StyleSheet/ShadowPropTypesIOS.ts +0 -48
  78. package/src/transforms/StyleSheet/StyleSheetValidation.ts +0 -81
  79. package/src/transforms/StyleSheet/TextStylePropTypes.ts +0 -123
  80. package/src/transforms/StyleSheet/TransformPropTypes.ts +0 -109
  81. package/src/transforms/StyleSheet/ViewStylePropTypes.ts +0 -61
  82. package/src/transforms/StyleSheet/deprecatedPropType.ts +0 -31
  83. package/src/transforms/StyleSheet/index.ts +0 -5
  84. package/src/transforms/StyleSheet/normalizeColor.ts +0 -369
  85. package/src/transforms/index.ts +0 -229
  86. package/src/transforms/less.ts +0 -50
  87. package/src/transforms/postcss.ts +0 -95
  88. package/src/transforms/sass.ts +0 -148
  89. package/src/transforms/stylus.ts +0 -124
  90. package/src/types/index.ts +0 -242
  91. package/src/utils/index.ts +0 -229
  92. package/src/utils/lessImport.ts +0 -50
  93. package/src/utils/reporterSkip.ts +0 -27
  94. 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,3 +0,0 @@
1
- .nest {
2
- color: red;
3
- }
@@ -1 +0,0 @@
1
- $base-color: #c6538c;
package/babel.config.js DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- '@babel/preset-env',
5
- {
6
- targets: {
7
- node: 'current'
8
- }
9
- }
10
- ]
11
- ]
12
- }
package/jest.config.js DELETED
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- verbose: true,
3
- transform: {
4
- '^.+\\.js$': 'babel-jest',
5
- '^.+\\.tsx?$': 'ts-jest'
6
- },
7
- testPathIgnorePatterns: ['/node_modules/']
8
- }
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "stylelint-config-taro-rn",
3
- "rules": {
4
- }
5
- }
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('@react-native/metro-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