@tarojs/rn-style-transformer 4.0.0-beta.93 → 4.0.0-beta.95

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 (95) hide show
  1. package/LICENSE +8 -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 +3 -0
  41. package/dist/transforms/sass.js.map +1 -1
  42. package/dist/transforms/stylus.d.ts +3 -0
  43. package/dist/transforms/stylus.js +1 -1
  44. package/dist/transforms/stylus.js.map +1 -1
  45. package/dist/types/index.d.ts +206 -0
  46. package/dist/utils/index.d.ts +21 -0
  47. package/dist/utils/index.js.map +1 -1
  48. package/dist/utils/lessImport.d.ts +5 -0
  49. package/dist/utils/reporterSkip.d.ts +7 -0
  50. package/dist/utils/reporterSkip.js.map +1 -1
  51. package/package.json +32 -31
  52. package/.eslintrc.js +0 -8
  53. package/__tests__/config.spec.js +0 -203
  54. package/__tests__/index.spec.js +0 -252
  55. package/__tests__/platform.spec.js +0 -78
  56. package/__tests__/styles/b.css +0 -3
  57. package/__tests__/styles/b.less +0 -3
  58. package/__tests__/styles/b.rn.css +0 -3
  59. package/__tests__/styles/b.scss +0 -3
  60. package/__tests__/styles/b.styl +0 -3
  61. package/__tests__/styles/c.css +0 -3
  62. package/__tests__/styles/c.less +0 -5
  63. package/__tests__/styles/c.rn.scss +0 -5
  64. package/__tests__/styles/c.scss +0 -5
  65. package/__tests__/styles/d.rn.scss +0 -3
  66. package/__tests__/styles/d.scss +0 -3
  67. package/__tests__/styles/mixins.scss +0 -18
  68. package/__tests__/styles/nest.rn.less +0 -3
  69. package/__tests__/styles/variable.scss +0 -1
  70. package/babel.config.js +0 -12
  71. package/jest.config.js +0 -8
  72. package/src/config/rn-stylelint.json +0 -5
  73. package/src/index.ts +0 -52
  74. package/src/transforms/StyleSheet/ColorPropType.ts +0 -76
  75. package/src/transforms/StyleSheet/ImageResizeMode.ts +0 -50
  76. package/src/transforms/StyleSheet/ImageStylePropTypes.ts +0 -62
  77. package/src/transforms/StyleSheet/LayoutPropTypes.ts +0 -559
  78. package/src/transforms/StyleSheet/ShadowPropTypesIOS.ts +0 -48
  79. package/src/transforms/StyleSheet/StyleSheetValidation.ts +0 -81
  80. package/src/transforms/StyleSheet/TextStylePropTypes.ts +0 -123
  81. package/src/transforms/StyleSheet/TransformPropTypes.ts +0 -109
  82. package/src/transforms/StyleSheet/ViewStylePropTypes.ts +0 -61
  83. package/src/transforms/StyleSheet/deprecatedPropType.ts +0 -31
  84. package/src/transforms/StyleSheet/index.ts +0 -5
  85. package/src/transforms/StyleSheet/normalizeColor.ts +0 -369
  86. package/src/transforms/index.ts +0 -229
  87. package/src/transforms/less.ts +0 -50
  88. package/src/transforms/postcss.ts +0 -95
  89. package/src/transforms/sass.ts +0 -148
  90. package/src/transforms/stylus.ts +0 -124
  91. package/src/types/index.ts +0 -242
  92. package/src/utils/index.ts +0 -229
  93. package/src/utils/lessImport.ts +0 -50
  94. package/src/utils/reporterSkip.ts +0 -27
  95. package/tsconfig.json +0 -12
@@ -1,123 +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
-
11
- 'use strict'
12
-
13
- import ColorPropType from './ColorPropType'
14
- import * as ReactPropTypes from 'prop-types'
15
- import ViewStylePropTypes from './ViewStylePropTypes'
16
-
17
- const TextStylePropTypes = {
18
- ...ViewStylePropTypes,
19
-
20
- color: ColorPropType,
21
- fontFamily: ReactPropTypes.string,
22
- fontSize: ReactPropTypes.number,
23
- fontStyle: ReactPropTypes.oneOf(['normal', 'italic']),
24
- /**
25
- * Specifies font weight. The values 'normal' and 'bold' are supported for
26
- * most fonts. Not all fonts have a variant for each of the numeric values,
27
- * in that case the closest one is chosen.
28
- */
29
- fontWeight: ReactPropTypes.oneOf([
30
- 'normal' /* default */,
31
- 'bold',
32
- '100',
33
- '200',
34
- '300',
35
- '400',
36
- '500',
37
- '600',
38
- '700',
39
- '800',
40
- '900'
41
- ]),
42
- /**
43
- * @platform ios
44
- */
45
- fontVariant: ReactPropTypes.arrayOf(
46
- ReactPropTypes.oneOf([
47
- 'small-caps',
48
- 'oldstyle-nums',
49
- 'lining-nums',
50
- 'tabular-nums',
51
- 'proportional-nums'
52
- ])
53
- ),
54
- textShadowOffset: ReactPropTypes.shape({
55
- width: ReactPropTypes.number,
56
- height: ReactPropTypes.number
57
- }),
58
- textShadowRadius: ReactPropTypes.number,
59
- textShadowColor: ColorPropType,
60
- /**
61
- * @platform ios
62
- */
63
- letterSpacing: ReactPropTypes.number,
64
- lineHeight: ReactPropTypes.number,
65
- /**
66
- * Specifies text alignment. The value 'justify' is only supported on iOS and
67
- * fallbacks to `left` on Android.
68
- */
69
- textAlign: ReactPropTypes.oneOf([
70
- 'auto' /* default */,
71
- 'left',
72
- 'right',
73
- 'center',
74
- 'justify'
75
- ]),
76
- /**
77
- * @platform android
78
- */
79
- textAlignVertical: ReactPropTypes.oneOf([
80
- 'auto' /* default */,
81
- 'top',
82
- 'bottom',
83
- 'center'
84
- ]),
85
- /**
86
- * Set to `false` to remove extra font padding intended to make space for certain ascenders / descenders.
87
- * With some fonts, this padding can make text look slightly misaligned when centered vertically.
88
- * For best results also set `textAlignVertical` to `center`. Default is true.
89
- * @platform android
90
- */
91
- includeFontPadding: ReactPropTypes.bool,
92
- textDecorationLine: ReactPropTypes.oneOf([
93
- 'none' /* default */,
94
- 'underline',
95
- 'line-through',
96
- 'underline line-through'
97
- ]),
98
- /**
99
- * @platform ios
100
- */
101
- textDecorationStyle: ReactPropTypes.oneOf([
102
- 'solid' /* default */,
103
- 'double',
104
- 'dotted',
105
- 'dashed'
106
- ]),
107
- /**
108
- * @platform ios
109
- */
110
- textDecorationColor: ColorPropType,
111
- textTransform: ReactPropTypes.oneOf([
112
- 'none' /* default */,
113
- 'capitalize',
114
- 'uppercase',
115
- 'lowercase'
116
- ]),
117
- /**
118
- * @platform ios
119
- */
120
- writingDirection: ReactPropTypes.oneOf(['auto' /* default */, 'ltr', 'rtl'])
121
- }
122
-
123
- export default TextStylePropTypes
@@ -1,109 +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
-
11
- 'use strict'
12
-
13
- import * as ReactPropTypes from 'prop-types'
14
-
15
- import deprecatedPropType from './deprecatedPropType'
16
-
17
- const TransformMatrixPropType = function (
18
- props,
19
- propName,
20
- _componentName
21
- ) {
22
- if (props[propName]) {
23
- return new Error(
24
- 'The transformMatrix style property is deprecated. ' +
25
- 'Use `transform: [{ matrix: ... }]` instead.'
26
- )
27
- }
28
- }
29
-
30
- const DecomposedMatrixPropType = function (
31
- props,
32
- propName,
33
- _componentName
34
- ) {
35
- if (props[propName]) {
36
- return new Error(
37
- 'The decomposedMatrix style property is deprecated. ' +
38
- 'Use `transform: [...]` instead.'
39
- )
40
- }
41
- }
42
-
43
- const TransformPropTypes = {
44
- /**
45
- * `transform` accepts an array of transformation objects. Each object specifies
46
- * the property that will be transformed as the key, and the value to use in the
47
- * transformation. Objects should not be combined. Use a single key/value pair
48
- * per object.
49
- *
50
- * The rotate transformations require a string so that the transform may be
51
- * expressed in degrees (deg) or radians (rad). For example:
52
- *
53
- * `transform([{ rotateX: '45deg' }, { rotateZ: '0.785398rad' }])`
54
- *
55
- * The skew transformations require a string so that the transform may be
56
- * expressed in degrees (deg). For example:
57
- *
58
- * `transform([{ skewX: '45deg' }])`
59
- */
60
- transform: ReactPropTypes.arrayOf(
61
- ReactPropTypes.oneOfType([
62
- ReactPropTypes.shape({ perspective: ReactPropTypes.number }),
63
- ReactPropTypes.shape({ rotate: ReactPropTypes.string }),
64
- ReactPropTypes.shape({ rotateX: ReactPropTypes.string }),
65
- ReactPropTypes.shape({ rotateY: ReactPropTypes.string }),
66
- ReactPropTypes.shape({ rotateZ: ReactPropTypes.string }),
67
- ReactPropTypes.shape({ scale: ReactPropTypes.number }),
68
- ReactPropTypes.shape({ scaleX: ReactPropTypes.number }),
69
- ReactPropTypes.shape({ scaleY: ReactPropTypes.number }),
70
- ReactPropTypes.shape({ translateX: ReactPropTypes.number }),
71
- ReactPropTypes.shape({ translateY: ReactPropTypes.number }),
72
- ReactPropTypes.shape({ skewX: ReactPropTypes.string }),
73
- ReactPropTypes.shape({ skewY: ReactPropTypes.string })
74
- ])
75
- ),
76
-
77
- /**
78
- * Deprecated. Use the transform prop instead.
79
- */
80
- transformMatrix: TransformMatrixPropType,
81
- /**
82
- * Deprecated. Use the transform prop instead.
83
- */
84
- decomposedMatrix: DecomposedMatrixPropType,
85
-
86
- /* Deprecated transform props used on Android only */
87
- scaleX: deprecatedPropType(
88
- ReactPropTypes.number,
89
- 'Use the transform prop instead.'
90
- ),
91
- scaleY: deprecatedPropType(
92
- ReactPropTypes.number,
93
- 'Use the transform prop instead.'
94
- ),
95
- rotation: deprecatedPropType(
96
- ReactPropTypes.number,
97
- 'Use the transform prop instead.'
98
- ),
99
- translateX: deprecatedPropType(
100
- ReactPropTypes.number,
101
- 'Use the transform prop instead.'
102
- ),
103
- translateY: deprecatedPropType(
104
- ReactPropTypes.number,
105
- 'Use the transform prop instead.'
106
- )
107
- }
108
-
109
- export default TransformPropTypes
@@ -1,61 +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
-
11
- 'use strict'
12
-
13
- import ColorPropType from './ColorPropType'
14
- import LayoutPropTypes from './LayoutPropTypes'
15
- import * as ReactPropTypes from 'prop-types'
16
- import ShadowPropTypesIOS from './ShadowPropTypesIOS'
17
- import TransformPropTypes from './TransformPropTypes'
18
-
19
- /**
20
- * Warning: Some of these properties may not be supported in all releases.
21
- */
22
- const ViewStylePropTypes = {
23
- ...LayoutPropTypes,
24
- ...ShadowPropTypesIOS,
25
- ...TransformPropTypes,
26
- backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']),
27
- backgroundColor: ColorPropType,
28
- borderColor: ColorPropType,
29
- borderTopColor: ColorPropType,
30
- borderRightColor: ColorPropType,
31
- borderBottomColor: ColorPropType,
32
- borderLeftColor: ColorPropType,
33
- borderStartColor: ColorPropType,
34
- borderEndColor: ColorPropType,
35
- borderRadius: ReactPropTypes.number,
36
- borderTopLeftRadius: ReactPropTypes.number,
37
- borderTopRightRadius: ReactPropTypes.number,
38
- borderTopStartRadius: ReactPropTypes.number,
39
- borderTopEndRadius: ReactPropTypes.number,
40
- borderBottomLeftRadius: ReactPropTypes.number,
41
- borderBottomRightRadius: ReactPropTypes.number,
42
- borderBottomStartRadius: ReactPropTypes.number,
43
- borderBottomEndRadius: ReactPropTypes.number,
44
- borderStyle: ReactPropTypes.oneOf(['solid', 'dotted', 'dashed']),
45
- borderWidth: ReactPropTypes.number,
46
- borderTopWidth: ReactPropTypes.number,
47
- borderRightWidth: ReactPropTypes.number,
48
- borderBottomWidth: ReactPropTypes.number,
49
- borderLeftWidth: ReactPropTypes.number,
50
- opacity: ReactPropTypes.number,
51
- /**
52
- * (Android-only) Sets the elevation of a view, using Android's underlying
53
- * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation).
54
- * This adds a drop shadow to the item and affects z-order for overlapping views.
55
- * Only supported on Android 5.0+, has no effect on earlier versions.
56
- * @platform android
57
- */
58
- elevation: ReactPropTypes.number
59
- }
60
-
61
- export default ViewStylePropTypes
@@ -1,31 +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
- * strict-local
9
- */
10
-
11
- // const UIManager = require('UIManager')
12
-
13
- /**
14
- * Adds a deprecation warning when the prop is used.
15
- */
16
- export default function deprecatedPropType (
17
- propType,
18
- explanation
19
- ) {
20
- return function validate (props, propName, componentName, ...rest) {
21
- // Don't warn for native components.
22
- // if (!UIManager[componentName] && props[propName] !== undefined) {
23
- if (props[propName] !== undefined) {
24
- console.warn(
25
- `\`${propName}\` supplied to \`${componentName}\` has been deprecated. ${explanation}`
26
- )
27
- }
28
-
29
- return propType(props, propName, componentName, ...rest)
30
- }
31
- }
@@ -1,5 +0,0 @@
1
- import StyleSheetValidation from './StyleSheetValidation'
2
-
3
- export {
4
- StyleSheetValidation
5
- }
@@ -1,369 +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
-
11
- /* eslint no-bitwise: 0 */
12
-
13
- export default function normalizeColor (color) {
14
- const matchers = getMatchers()
15
- let match
16
-
17
- if (typeof color === 'number') {
18
- if (color >>> 0 === color && color >= 0 && color <= 0xffffffff) {
19
- return color
20
- }
21
- return null
22
- }
23
-
24
- // Ordered based on occurrences on Facebook codebase
25
- if ((match = matchers.hex6.exec(color))) {
26
- return parseInt(match[1] + 'ff', 16) >>> 0
27
- }
28
-
29
- if (names.hasOwnProperty(color)) {
30
- return names[color]
31
- }
32
-
33
- if ((match = matchers.rgb.exec(color))) {
34
- return (
35
- // b
36
- ((parse255(match[1]) << 24) | // r
37
- (parse255(match[2]) << 16) | // g
38
- (parse255(match[3]) << 8) |
39
- 0x000000ff) >>> // a
40
- 0
41
- )
42
- }
43
-
44
- if ((match = matchers.rgba.exec(color))) {
45
- return (
46
- // b
47
- ((parse255(match[1]) << 24) | // r
48
- (parse255(match[2]) << 16) | // g
49
- (parse255(match[3]) << 8) |
50
- parse1(match[4])) >>> // a
51
- 0
52
- )
53
- }
54
-
55
- if ((match = matchers.hex3.exec(color))) {
56
- return (
57
- parseInt(
58
- match[1] +
59
- match[1] + // r
60
- match[2] +
61
- match[2] + // g
62
- match[3] +
63
- match[3] + // b
64
- 'ff', // a
65
- 16
66
- ) >>> 0
67
- )
68
- }
69
-
70
- // https://drafts.csswg.org/css-color-4/#hex-notation
71
- if ((match = matchers.hex8.exec(color))) {
72
- return parseInt(match[1], 16) >>> 0
73
- }
74
-
75
- if ((match = matchers.hex4.exec(color))) {
76
- return (
77
- parseInt(
78
- match[1] +
79
- match[1] + // r
80
- match[2] +
81
- match[2] + // g
82
- match[3] +
83
- match[3] + // b
84
- match[4] +
85
- match[4], // a
86
- 16
87
- ) >>> 0
88
- )
89
- }
90
-
91
- if ((match = matchers.hsl.exec(color))) {
92
- return (
93
- (hslToRgb(
94
- parse360(match[1]), // h
95
- parsePercentage(match[2]), // s
96
- parsePercentage(match[3]) // l
97
- ) |
98
- 0x000000ff) >>> // a
99
- 0
100
- )
101
- }
102
-
103
- if ((match = matchers.hsla.exec(color))) {
104
- return (
105
- (hslToRgb(
106
- parse360(match[1]), // h
107
- parsePercentage(match[2]), // s
108
- parsePercentage(match[3]) // l
109
- ) |
110
- parse1(match[4])) >>> // a
111
- 0
112
- )
113
- }
114
-
115
- return null
116
- }
117
-
118
- function hue2rgb (p, q, t) {
119
- if (t < 0) {
120
- t += 1
121
- }
122
- if (t > 1) {
123
- t -= 1
124
- }
125
- if (t < 1 / 6) {
126
- return p + (q - p) * 6 * t
127
- }
128
- if (t < 1 / 2) {
129
- return q
130
- }
131
- if (t < 2 / 3) {
132
- return p + (q - p) * (2 / 3 - t) * 6
133
- }
134
- return p
135
- }
136
-
137
- function hslToRgb (h, s, l) {
138
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s
139
- const p = 2 * l - q
140
- const r = hue2rgb(p, q, h + 1 / 3)
141
- const g = hue2rgb(p, q, h)
142
- const b = hue2rgb(p, q, h - 1 / 3)
143
-
144
- return (
145
- (Math.round(r * 255) << 24) |
146
- (Math.round(g * 255) << 16) |
147
- (Math.round(b * 255) << 8)
148
- )
149
- }
150
-
151
- // var INTEGER = '[-+]?\\d+';
152
- const NUMBER = '[-+]?\\d*\\.?\\d+'
153
- const PERCENTAGE = NUMBER + '%'
154
-
155
- function call (...args) {
156
- return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)'
157
- }
158
-
159
- let cachedMatchers
160
-
161
- function getMatchers () {
162
- if (cachedMatchers === undefined) {
163
- cachedMatchers = {
164
- rgb: new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)),
165
- rgba: new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER)),
166
- hsl: new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)),
167
- hsla: new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)),
168
- hex3: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
169
- hex4: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
170
- hex6: /^#([0-9a-fA-F]{6})$/,
171
- hex8: /^#([0-9a-fA-F]{8})$/
172
- }
173
- }
174
- return cachedMatchers
175
- }
176
-
177
- function parse255 (str) {
178
- const int = parseInt(str, 10)
179
- if (int < 0) {
180
- return 0
181
- }
182
- if (int > 255) {
183
- return 255
184
- }
185
- return int
186
- }
187
-
188
- function parse360 (str) {
189
- const int = parseFloat(str)
190
- return (((int % 360) + 360) % 360) / 360
191
- }
192
-
193
- function parse1 (str) {
194
- const num = parseFloat(str)
195
- if (num < 0) {
196
- return 0
197
- }
198
- if (num > 1) {
199
- return 255
200
- }
201
- return Math.round(num * 255)
202
- }
203
-
204
- function parsePercentage (str) {
205
- // parseFloat conveniently ignores the final %
206
- const int = parseFloat(str)
207
- if (int < 0) {
208
- return 0
209
- }
210
- if (int > 100) {
211
- return 1
212
- }
213
- return int / 100
214
- }
215
-
216
- const names = {
217
- transparent: 0x00000000,
218
-
219
- // http://www.w3.org/TR/css3-color/#svg-color
220
- aliceblue: 0xf0f8ffff,
221
- antiquewhite: 0xfaebd7ff,
222
- aqua: 0x00ffffff,
223
- aquamarine: 0x7fffd4ff,
224
- azure: 0xf0ffffff,
225
- beige: 0xf5f5dcff,
226
- bisque: 0xffe4c4ff,
227
- black: 0x000000ff,
228
- blanchedalmond: 0xffebcdff,
229
- blue: 0x0000ffff,
230
- blueviolet: 0x8a2be2ff,
231
- brown: 0xa52a2aff,
232
- burlywood: 0xdeb887ff,
233
- burntsienna: 0xea7e5dff,
234
- cadetblue: 0x5f9ea0ff,
235
- chartreuse: 0x7fff00ff,
236
- chocolate: 0xd2691eff,
237
- coral: 0xff7f50ff,
238
- cornflowerblue: 0x6495edff,
239
- cornsilk: 0xfff8dcff,
240
- crimson: 0xdc143cff,
241
- cyan: 0x00ffffff,
242
- darkblue: 0x00008bff,
243
- darkcyan: 0x008b8bff,
244
- darkgoldenrod: 0xb8860bff,
245
- darkgray: 0xa9a9a9ff,
246
- darkgreen: 0x006400ff,
247
- darkgrey: 0xa9a9a9ff,
248
- darkkhaki: 0xbdb76bff,
249
- darkmagenta: 0x8b008bff,
250
- darkolivegreen: 0x556b2fff,
251
- darkorange: 0xff8c00ff,
252
- darkorchid: 0x9932ccff,
253
- darkred: 0x8b0000ff,
254
- darksalmon: 0xe9967aff,
255
- darkseagreen: 0x8fbc8fff,
256
- darkslateblue: 0x483d8bff,
257
- darkslategray: 0x2f4f4fff,
258
- darkslategrey: 0x2f4f4fff,
259
- darkturquoise: 0x00ced1ff,
260
- darkviolet: 0x9400d3ff,
261
- deeppink: 0xff1493ff,
262
- deepskyblue: 0x00bfffff,
263
- dimgray: 0x696969ff,
264
- dimgrey: 0x696969ff,
265
- dodgerblue: 0x1e90ffff,
266
- firebrick: 0xb22222ff,
267
- floralwhite: 0xfffaf0ff,
268
- forestgreen: 0x228b22ff,
269
- fuchsia: 0xff00ffff,
270
- gainsboro: 0xdcdcdcff,
271
- ghostwhite: 0xf8f8ffff,
272
- gold: 0xffd700ff,
273
- goldenrod: 0xdaa520ff,
274
- gray: 0x808080ff,
275
- green: 0x008000ff,
276
- greenyellow: 0xadff2fff,
277
- grey: 0x808080ff,
278
- honeydew: 0xf0fff0ff,
279
- hotpink: 0xff69b4ff,
280
- indianred: 0xcd5c5cff,
281
- indigo: 0x4b0082ff,
282
- ivory: 0xfffff0ff,
283
- khaki: 0xf0e68cff,
284
- lavender: 0xe6e6faff,
285
- lavenderblush: 0xfff0f5ff,
286
- lawngreen: 0x7cfc00ff,
287
- lemonchiffon: 0xfffacdff,
288
- lightblue: 0xadd8e6ff,
289
- lightcoral: 0xf08080ff,
290
- lightcyan: 0xe0ffffff,
291
- lightgoldenrodyellow: 0xfafad2ff,
292
- lightgray: 0xd3d3d3ff,
293
- lightgreen: 0x90ee90ff,
294
- lightgrey: 0xd3d3d3ff,
295
- lightpink: 0xffb6c1ff,
296
- lightsalmon: 0xffa07aff,
297
- lightseagreen: 0x20b2aaff,
298
- lightskyblue: 0x87cefaff,
299
- lightslategray: 0x778899ff,
300
- lightslategrey: 0x778899ff,
301
- lightsteelblue: 0xb0c4deff,
302
- lightyellow: 0xffffe0ff,
303
- lime: 0x00ff00ff,
304
- limegreen: 0x32cd32ff,
305
- linen: 0xfaf0e6ff,
306
- magenta: 0xff00ffff,
307
- maroon: 0x800000ff,
308
- mediumaquamarine: 0x66cdaaff,
309
- mediumblue: 0x0000cdff,
310
- mediumorchid: 0xba55d3ff,
311
- mediumpurple: 0x9370dbff,
312
- mediumseagreen: 0x3cb371ff,
313
- mediumslateblue: 0x7b68eeff,
314
- mediumspringgreen: 0x00fa9aff,
315
- mediumturquoise: 0x48d1ccff,
316
- mediumvioletred: 0xc71585ff,
317
- midnightblue: 0x191970ff,
318
- mintcream: 0xf5fffaff,
319
- mistyrose: 0xffe4e1ff,
320
- moccasin: 0xffe4b5ff,
321
- navajowhite: 0xffdeadff,
322
- navy: 0x000080ff,
323
- oldlace: 0xfdf5e6ff,
324
- olive: 0x808000ff,
325
- olivedrab: 0x6b8e23ff,
326
- orange: 0xffa500ff,
327
- orangered: 0xff4500ff,
328
- orchid: 0xda70d6ff,
329
- palegoldenrod: 0xeee8aaff,
330
- palegreen: 0x98fb98ff,
331
- paleturquoise: 0xafeeeeff,
332
- palevioletred: 0xdb7093ff,
333
- papayawhip: 0xffefd5ff,
334
- peachpuff: 0xffdab9ff,
335
- peru: 0xcd853fff,
336
- pink: 0xffc0cbff,
337
- plum: 0xdda0ddff,
338
- powderblue: 0xb0e0e6ff,
339
- purple: 0x800080ff,
340
- rebeccapurple: 0x663399ff,
341
- red: 0xff0000ff,
342
- rosybrown: 0xbc8f8fff,
343
- royalblue: 0x4169e1ff,
344
- saddlebrown: 0x8b4513ff,
345
- salmon: 0xfa8072ff,
346
- sandybrown: 0xf4a460ff,
347
- seagreen: 0x2e8b57ff,
348
- seashell: 0xfff5eeff,
349
- sienna: 0xa0522dff,
350
- silver: 0xc0c0c0ff,
351
- skyblue: 0x87ceebff,
352
- slateblue: 0x6a5acdff,
353
- slategray: 0x708090ff,
354
- slategrey: 0x708090ff,
355
- snow: 0xfffafaff,
356
- springgreen: 0x00ff7fff,
357
- steelblue: 0x4682b4ff,
358
- tan: 0xd2b48cff,
359
- teal: 0x008080ff,
360
- thistle: 0xd8bfd8ff,
361
- tomato: 0xff6347ff,
362
- turquoise: 0x40e0d0ff,
363
- violet: 0xee82eeff,
364
- wheat: 0xf5deb3ff,
365
- white: 0xffffffff,
366
- whitesmoke: 0xf5f5f5ff,
367
- yellow: 0xffff00ff,
368
- yellowgreen: 0x9acd32ff
369
- }