taro-css-to-react-native 3.5.11 → 3.6.0-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.
@@ -4,26 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
7
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
8
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11
-
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
10
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
-
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
13
  var SYMBOL_MATCH = 'SYMBOL_MATCH';
15
-
16
14
  var TokenStream = /*#__PURE__*/function () {
17
15
  function TokenStream(nodes, parent) {
18
16
  _classCallCheck(this, TokenStream);
19
-
20
17
  this.index = 0;
21
18
  this.nodes = nodes;
22
19
  this.functionName = parent != null ? parent.value : null;
23
20
  this.lastValue = null;
24
21
  this.rewindIndex = -1;
25
22
  }
26
-
27
23
  _createClass(TokenStream, [{
28
24
  key: "node",
29
25
  get: function get() {
@@ -44,18 +40,15 @@ var TokenStream = /*#__PURE__*/function () {
44
40
  value: function value() {
45
41
  if (!this.hasTokens()) return null;
46
42
  var node = this.node;
47
-
48
43
  for (var i = 0; i < arguments.length; i += 1) {
49
44
  var tokenDescriptor = i < 0 || arguments.length <= i ? undefined : arguments[i];
50
45
  var value = tokenDescriptor(node);
51
-
52
46
  if (value !== null) {
53
47
  this.index += 1;
54
48
  this.lastValue = value;
55
49
  return value;
56
50
  }
57
51
  }
58
-
59
52
  return null;
60
53
  }
61
54
  }, {
@@ -94,7 +87,6 @@ var TokenStream = /*#__PURE__*/function () {
94
87
  key: "throw",
95
88
  value: function _throw() {
96
89
  var _this$node;
97
-
98
90
  throw new Error("Unexpected token type: ".concat((_this$node = this.node) === null || _this$node === void 0 ? void 0 : _this$node.type));
99
91
  }
100
92
  }, {
@@ -110,8 +102,6 @@ var TokenStream = /*#__PURE__*/function () {
110
102
  this.lastValue = null;
111
103
  }
112
104
  }]);
113
-
114
105
  return TokenStream;
115
106
  }();
116
-
117
107
  exports["default"] = TokenStream;
@@ -4,34 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.transformRawValue = exports.getStylesForProperty = exports.getPropertyName = exports["default"] = void 0;
7
-
8
7
  var _camelize = _interopRequireDefault(require("camelize"));
9
-
10
8
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
11
-
12
9
  var _TokenStream = _interopRequireDefault(require("./TokenStream"));
13
-
14
10
  var _index = _interopRequireDefault(require("./transforms/index"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
12
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
16
  // Note if this is wrong, you'll need to change tokenTypes.js too
21
17
  var numberOrLengthRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)((?:px)|(?:vw$)|(?:vh$)|(?:vmin$)|(?:vmax$))?$/i;
22
18
  var boolRe = /^true|false$/i;
23
19
  var nullRe = /^null$/i;
24
- var undefinedRe = /^undefined$/i; // Undocumented export
20
+ var undefinedRe = /^undefined$/i;
25
21
 
22
+ // Undocumented export
26
23
  var transformRawValue = function transformRawValue(input) {
27
24
  var value = input.trim();
28
25
  var numberMatch = value.match(numberOrLengthRe);
29
-
30
26
  if (numberMatch !== null) {
31
27
  var num = Number(numberMatch[1]);
32
28
  var unit = numberMatch[2];
33
29
  var isViewportUnit = ['vw', 'vh', 'vmin', 'vmax'].includes(unit);
34
-
35
30
  if (isViewportUnit) {
36
31
  return "scaleVu2dp(".concat(num, ", '").concat(unit, "')");
37
32
  } else if (/(\d+)px/.test(value)) {
@@ -40,7 +35,6 @@ var transformRawValue = function transformRawValue(input) {
40
35
  return num;
41
36
  }
42
37
  }
43
-
44
38
  var boolMatch = input.match(boolRe);
45
39
  if (boolMatch !== null) return boolMatch[0].toLowerCase() === 'true';
46
40
  var nullMatch = input.match(nullRe);
@@ -49,16 +43,13 @@ var transformRawValue = function transformRawValue(input) {
49
43
  if (undefinedMatch !== null) return undefined;
50
44
  return value;
51
45
  };
52
-
53
46
  exports.transformRawValue = transformRawValue;
54
-
55
47
  var baseTransformShorthandValue = function baseTransformShorthandValue(propName, inputValue) {
56
48
  // const ast = parse(inputValue.trim().replace(/PX|Px|pX$/g, ""));
57
49
  var ast = (0, _postcssValueParser["default"])(inputValue);
58
50
  var tokenStream = new _TokenStream["default"](ast.nodes);
59
51
  return _index["default"][propName](tokenStream);
60
52
  };
61
-
62
53
  var checkBaseTransformShorthandValue = function checkBaseTransformShorthandValue(propName, inputValue) {
63
54
  try {
64
55
  return baseTransformShorthandValue(propName, inputValue);
@@ -66,29 +57,21 @@ var checkBaseTransformShorthandValue = function checkBaseTransformShorthandValue
66
57
  throw new Error("".concat(e.message, " Failed to parse declaration \"").concat(propName, ": ").concat(inputValue, "\""));
67
58
  }
68
59
  };
69
-
70
60
  var transformShorthandValue = process.env.NODE_ENV === 'production' ? baseTransformShorthandValue : checkBaseTransformShorthandValue;
71
-
72
61
  var getStylesForProperty = function getStylesForProperty(propName, inputValue, allowShorthand) {
73
62
  var isRawValue = allowShorthand === false || !(propName in _index["default"]);
74
63
  var propValue = isRawValue ? transformRawValue(inputValue) : transformShorthandValue(propName, inputValue.trim());
75
64
  return propValue && propValue.$merge ? propValue.$merge : _defineProperty({}, propName, propValue);
76
65
  };
77
-
78
66
  exports.getStylesForProperty = getStylesForProperty;
79
-
80
67
  var getPropertyName = function getPropertyName(propName) {
81
68
  var isCustomProp = /^--\w+/.test(propName);
82
-
83
69
  if (isCustomProp) {
84
70
  return propName;
85
71
  }
86
-
87
72
  return (0, _camelize["default"])(propName);
88
73
  };
89
-
90
74
  exports.getPropertyName = getPropertyName;
91
-
92
75
  var _default = function _default(rules) {
93
76
  var shorthandBlacklist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
94
77
  return rules.reduce(function (accum, rule) {
@@ -98,5 +81,4 @@ var _default = function _default(rules) {
98
81
  return Object.assign(accum, getStylesForProperty(propertyName, value, allowShorthand));
99
82
  }, {});
100
83
  };
101
-
102
84
  exports["default"] = _default;
@@ -4,58 +4,48 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.tokens = exports.regExpToken = void 0;
7
-
8
7
  var _cssColorKeywords = _interopRequireDefault(require("css-color-keywords"));
9
-
10
8
  var _postcssValueParser = require("postcss-value-parser");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  /* eslint-disable react/display-name */
11
+
15
12
  var matchString = function matchString(node) {
16
13
  if (node.type !== 'string') return null;
17
14
  return node.value.replace(/\\([0-9a-f]{1,6})(?:\s|$)/gi, function (match, charCode) {
18
15
  return String.fromCharCode(parseInt(charCode, 16));
19
16
  }).replace(/\\/g, '');
20
17
  };
21
-
22
18
  var hexColorRe = /^(#(?:[0-9a-f]{3,4}){1,2})$/i;
23
19
  var cssFunctionNameRe = /^(rgba?|hsla?|hwb|lab|lch|gray|color)$/;
24
-
25
20
  var matchColor = function matchColor(node) {
26
21
  if (node.type === 'word' && (hexColorRe.test(node.value) || node.value in _cssColorKeywords["default"] || node.value === 'transparent')) {
27
22
  return node.value;
28
23
  } else if (node.type === 'function' && cssFunctionNameRe.test(node.value)) {
29
24
  return (0, _postcssValueParser.stringify)(node);
30
25
  }
31
-
32
26
  return null;
33
27
  };
34
-
35
28
  var noneRe = /^(none)$/i;
36
29
  var autoRe = /^(auto)$/i;
37
- var identRe = /(^-?[_a-z][_a-z0-9-]*$)/i; // Note if these are wrong, you'll need to change index.js too
38
-
39
- var numberRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)$/; // Note lengthRe is sneaky: you can omit units for 0
40
-
30
+ var identRe = /(^-?[_a-z][_a-z0-9-]*$)/i;
31
+ // Note if these are wrong, you'll need to change index.js too
32
+ var numberRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)$/;
33
+ // Note lengthRe is sneaky: you can omit units for 0
41
34
  var lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)((?=px$)|(?=Px$)|(?=PX$)|(?=pX$)|(?=vw$)|(?=vh$)|(?=vmin$)|(?=vmax$)))/;
42
35
  var unsupportedUnitRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?(ch|em|ex|rem|cm|mm|in|pc|pt))$/;
43
36
  var angleRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?(?:deg|rad))$/;
44
37
  var percentRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?%)$/;
45
38
  var viewportUnitRe = /(\d+)(vw|vh|vmin|vmax)/;
46
-
47
39
  var noopToken = function noopToken(predicate) {
48
40
  return function (node) {
49
41
  return predicate(node) ? '<token>' : null;
50
42
  };
51
43
  };
52
-
53
44
  var valueForTypeToken = function valueForTypeToken(type) {
54
45
  return function (node) {
55
46
  return node.type === type ? node.value : null;
56
47
  };
57
48
  };
58
-
59
49
  var functionValueForTypeToken = function functionValueForTypeToken(type) {
60
50
  return function (node) {
61
51
  if (node.type === type) {
@@ -69,23 +59,19 @@ var functionValueForTypeToken = function functionValueForTypeToken(type) {
69
59
  return "".concat(node.value, "(").concat(result.join(', '), ")");
70
60
  }
71
61
  }
72
-
73
62
  return null;
74
63
  };
75
64
  };
76
-
77
65
  var regExpToken = function regExpToken(regExp) {
78
66
  var transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String;
79
67
  return function (node) {
80
68
  var _node$value$match;
81
-
82
69
  if (node.type !== 'word') return null;
83
70
  var match = node.value.match(regExp);
84
71
  if (match === null) return null;
85
72
  var value = transform(match[1]);
86
73
  var unit = (_node$value$match = node.value.match(viewportUnitRe)) === null || _node$value$match === void 0 ? void 0 : _node$value$match[2];
87
74
  var isViewportUnit = ['vh', 'vw', 'vmin', 'vmax'].includes(unit);
88
-
89
75
  if (isViewportUnit) {
90
76
  return "scaleVu2dp(".concat(value, ", '").concat(unit, "')");
91
77
  } else if (/(\d+)px/.test(node.value)) {
@@ -95,7 +81,6 @@ var regExpToken = function regExpToken(regExp) {
95
81
  }
96
82
  };
97
83
  };
98
-
99
84
  exports.regExpToken = regExpToken;
100
85
  var tokens = {
101
86
  SPACE: noopToken(function (node) {
@@ -4,22 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.borderWidth = exports.borderTop = exports.borderRight = exports.borderRadius = exports.borderLeft = exports.borderColor = exports.borderBottom = exports.border = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
8
  var _util = require("./util");
11
-
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
9
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
13
  var WORD = _tokenTypes.tokens.WORD,
15
- FUNC = _tokenTypes.tokens.FUNC,
16
- COLOR = _tokenTypes.tokens.COLOR,
17
- LENGTH = _tokenTypes.tokens.LENGTH,
18
- UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT;
19
-
14
+ FUNC = _tokenTypes.tokens.FUNC,
15
+ COLOR = _tokenTypes.tokens.COLOR,
16
+ LENGTH = _tokenTypes.tokens.LENGTH,
17
+ UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT;
20
18
  function borderDirectionFactory() {
21
19
  var _anyOrderFactory;
22
-
23
20
  var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
24
21
  var prefix = "border".concat(direction);
25
22
  return (0, _util.anyOrderFactory)((_anyOrderFactory = {}, _defineProperty(_anyOrderFactory, "".concat(prefix, "Width"), {
@@ -33,7 +30,6 @@ function borderDirectionFactory() {
33
30
  "default": 'solid'
34
31
  }), _anyOrderFactory));
35
32
  }
36
-
37
33
  var border = borderDirectionFactory();
38
34
  exports.border = border;
39
35
  var borderTop = borderDirectionFactory('Top');
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _util = require("./util");
9
-
10
8
  var _default = function _default(tokenStream) {
11
9
  var _parseShadow = (0, _util.parseShadow)(tokenStream),
12
- offset = _parseShadow.offset,
13
- radius = _parseShadow.radius,
14
- color = _parseShadow.color;
15
-
10
+ offset = _parseShadow.offset,
11
+ radius = _parseShadow.radius,
12
+ color = _parseShadow.color;
16
13
  return {
17
14
  $merge: {
18
15
  shadowOffset: offset,
@@ -22,5 +19,4 @@ var _default = function _default(tokenStream) {
22
19
  }
23
20
  };
24
21
  };
25
-
26
22
  exports["default"] = _default;
@@ -4,23 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
8
  var NONE = _tokenTypes.tokens.NONE,
11
- AUTO = _tokenTypes.tokens.AUTO,
12
- NUMBER = _tokenTypes.tokens.NUMBER,
13
- LENGTH = _tokenTypes.tokens.LENGTH,
14
- SPACE = _tokenTypes.tokens.SPACE;
9
+ AUTO = _tokenTypes.tokens.AUTO,
10
+ NUMBER = _tokenTypes.tokens.NUMBER,
11
+ LENGTH = _tokenTypes.tokens.LENGTH,
12
+ SPACE = _tokenTypes.tokens.SPACE;
15
13
  var defaultFlexGrow = 1;
16
14
  var defaultFlexShrink = 1;
17
15
  var defaultFlexBasis = 0;
18
-
19
16
  var _default = function _default(tokenStream) {
20
17
  var flexGrow;
21
18
  var flexShrink;
22
19
  var flexBasis;
23
-
24
20
  if (tokenStream.matches(NONE)) {
25
21
  tokenStream.expectEmpty();
26
22
  return {
@@ -31,9 +27,7 @@ var _default = function _default(tokenStream) {
31
27
  }
32
28
  };
33
29
  }
34
-
35
30
  tokenStream.saveRewindPoint();
36
-
37
31
  if (tokenStream.matches(AUTO) && !tokenStream.hasTokens()) {
38
32
  return {
39
33
  $merge: {
@@ -43,17 +37,13 @@ var _default = function _default(tokenStream) {
43
37
  }
44
38
  };
45
39
  }
46
-
47
40
  tokenStream.rewind();
48
41
  var partsParsed = 0;
49
-
50
42
  while (partsParsed < 2 && tokenStream.hasTokens()) {
51
43
  if (partsParsed !== 0) tokenStream.expect(SPACE);
52
-
53
44
  if (typeof flexGrow === 'undefined' && tokenStream.matches(NUMBER)) {
54
45
  flexGrow = tokenStream.lastValue;
55
46
  tokenStream.saveRewindPoint();
56
-
57
47
  if (tokenStream.matches(SPACE) && tokenStream.matches(NUMBER)) {
58
48
  flexShrink = tokenStream.lastValue;
59
49
  } else {
@@ -66,10 +56,8 @@ var _default = function _default(tokenStream) {
66
56
  } else {
67
57
  tokenStream["throw"]();
68
58
  }
69
-
70
59
  partsParsed += 1;
71
60
  }
72
-
73
61
  tokenStream.expectEmpty();
74
62
  if (typeof flexGrow === 'undefined') flexGrow = defaultFlexGrow;
75
63
  if (typeof flexShrink === 'undefined') flexShrink = defaultFlexShrink;
@@ -82,5 +70,4 @@ var _default = function _default(tokenStream) {
82
70
  }
83
71
  };
84
72
  };
85
-
86
73
  exports["default"] = _default;
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
8
  var _fontFamily = _interopRequireDefault(require("./fontFamily"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  var SPACE = _tokenTypes.tokens.SPACE,
15
- LENGTH = _tokenTypes.tokens.LENGTH,
16
- UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT,
17
- NUMBER = _tokenTypes.tokens.NUMBER,
18
- SLASH = _tokenTypes.tokens.SLASH;
11
+ LENGTH = _tokenTypes.tokens.LENGTH,
12
+ UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT,
13
+ NUMBER = _tokenTypes.tokens.NUMBER,
14
+ SLASH = _tokenTypes.tokens.SLASH;
19
15
  var NORMAL = (0, _tokenTypes.regExpToken)(/^(normal)$/);
20
16
  var STYLE = (0, _tokenTypes.regExpToken)(/^(italic)$/);
21
17
  var WEIGHT = (0, _tokenTypes.regExpToken)(/^([1-9]00|bold)$/);
@@ -23,16 +19,15 @@ var VARIANT = (0, _tokenTypes.regExpToken)(/^(small-caps)$/);
23
19
  var defaultFontStyle = 'normal';
24
20
  var defaultFontWeight = 'normal';
25
21
  var defaultFontVariant = [];
26
-
27
22
  var _default = function _default(tokenStream) {
28
23
  var fontStyle;
29
24
  var fontWeight;
30
- var fontVariant; // let fontSize;
31
-
32
- var lineHeight; // let fontFamily;
25
+ var fontVariant;
26
+ // let fontSize;
27
+ var lineHeight;
28
+ // let fontFamily;
33
29
 
34
30
  var numStyleWeightVariantMatched = 0;
35
-
36
31
  while (numStyleWeightVariantMatched < 3 && tokenStream.hasTokens()) {
37
32
  if (tokenStream.matches(NORMAL)) {
38
33
  /* pass */
@@ -45,13 +40,10 @@ var _default = function _default(tokenStream) {
45
40
  } else {
46
41
  break;
47
42
  }
48
-
49
43
  tokenStream.expect(SPACE);
50
44
  numStyleWeightVariantMatched += 1;
51
45
  }
52
-
53
46
  var fontSize = tokenStream.expect(LENGTH, UNSUPPORTED_LENGTH_UNIT);
54
-
55
47
  if (tokenStream.matches(SLASH)) {
56
48
  if (tokenStream.matches(NUMBER)) {
57
49
  var size = typeof fontSize === 'string' ? fontSize.replace(/scalePx2dp\((\d+)\)/, '$1') : fontSize;
@@ -60,7 +52,6 @@ var _default = function _default(tokenStream) {
60
52
  lineHeight = tokenStream.expect(LENGTH, UNSUPPORTED_LENGTH_UNIT);
61
53
  }
62
54
  }
63
-
64
55
  tokenStream.expect(SPACE);
65
56
  var fontFamily = (0, _fontFamily["default"])(tokenStream);
66
57
  if (typeof fontStyle === 'undefined') fontStyle = defaultFontStyle;
@@ -78,5 +69,4 @@ var _default = function _default(tokenStream) {
78
69
  $merge: out
79
70
  };
80
71
  };
81
-
82
72
  exports["default"] = _default;
@@ -4,30 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
8
  var SPACE = _tokenTypes.tokens.SPACE,
11
- IDENT = _tokenTypes.tokens.IDENT,
12
- STRING = _tokenTypes.tokens.STRING;
13
-
9
+ IDENT = _tokenTypes.tokens.IDENT,
10
+ STRING = _tokenTypes.tokens.STRING;
14
11
  var _default = function _default(tokenStream) {
15
12
  var fontFamily;
16
-
17
13
  if (tokenStream.matches(STRING)) {
18
14
  fontFamily = tokenStream.lastValue;
19
15
  } else {
20
16
  fontFamily = tokenStream.expect(IDENT);
21
-
22
17
  while (tokenStream.hasTokens()) {
23
18
  tokenStream.expect(SPACE);
24
19
  var nextIdent = tokenStream.expect(IDENT);
25
20
  fontFamily += " ".concat(nextIdent);
26
21
  }
27
22
  }
28
-
29
23
  tokenStream.expectEmpty();
30
24
  return fontFamily;
31
25
  };
32
-
33
26
  exports["default"] = _default;
@@ -4,39 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
8
  var _border = require("./border");
11
-
12
9
  var _boxShadow = _interopRequireDefault(require("./boxShadow"));
13
-
14
10
  var _flex = _interopRequireDefault(require("./flex"));
15
-
16
11
  var _font = _interopRequireDefault(require("./font"));
17
-
18
12
  var _fontFamily = _interopRequireDefault(require("./fontFamily"));
19
-
20
13
  var _textDecoration = _interopRequireDefault(require("./textDecoration"));
21
-
22
14
  var _textDecorationLine = _interopRequireDefault(require("./textDecorationLine"));
23
-
24
15
  var _textShadow = _interopRequireDefault(require("./textShadow"));
25
-
26
16
  var _transform = _interopRequireDefault(require("./transform"));
27
-
28
17
  var _util = require("./util");
29
-
30
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
31
-
32
19
  var IDENT = _tokenTypes.tokens.IDENT,
33
- WORD = _tokenTypes.tokens.WORD,
34
- COLOR = _tokenTypes.tokens.COLOR,
35
- LENGTH = _tokenTypes.tokens.LENGTH,
36
- UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT,
37
- PERCENT = _tokenTypes.tokens.PERCENT,
38
- AUTO = _tokenTypes.tokens.AUTO;
39
-
20
+ WORD = _tokenTypes.tokens.WORD,
21
+ COLOR = _tokenTypes.tokens.COLOR,
22
+ LENGTH = _tokenTypes.tokens.LENGTH,
23
+ UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT,
24
+ PERCENT = _tokenTypes.tokens.PERCENT,
25
+ AUTO = _tokenTypes.tokens.AUTO;
40
26
  var background = function background(tokenStream) {
41
27
  return {
42
28
  $merge: {
@@ -44,7 +30,6 @@ var background = function background(tokenStream) {
44
30
  }
45
31
  };
46
32
  };
47
-
48
33
  var margin = (0, _util.directionFactory)({
49
34
  types: [LENGTH, UNSUPPORTED_LENGTH_UNIT, PERCENT, AUTO],
50
35
  prefix: 'margin'
@@ -62,16 +47,12 @@ var flexFlow = (0, _util.anyOrderFactory)({
62
47
  "default": 'row'
63
48
  }
64
49
  });
65
-
66
50
  var fontVariant = function fontVariant(tokenStream) {
67
51
  return [tokenStream.expect(IDENT)];
68
52
  };
69
-
70
53
  var fontWeight = function fontWeight(tokenStream) {
71
54
  return tokenStream.expect(WORD);
72
55
  }; // Also match numbers as strings
73
-
74
-
75
56
  var shadowOffset = (0, _util.shadowOffsetFactory)();
76
57
  var textShadowOffset = (0, _util.shadowOffsetFactory)();
77
58
  var _default = {
@@ -4,38 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
8
  var SPACE = _tokenTypes.tokens.SPACE,
11
- LINE = _tokenTypes.tokens.LINE,
12
- COLOR = _tokenTypes.tokens.COLOR;
9
+ LINE = _tokenTypes.tokens.LINE,
10
+ COLOR = _tokenTypes.tokens.COLOR;
13
11
  var STYLE = (0, _tokenTypes.regExpToken)(/^(solid|double|dotted|dashed)$/);
14
12
  var defaultTextDecorationLine = 'none';
15
13
  var defaultTextDecorationStyle = 'solid';
16
14
  var defaultTextDecorationColor = 'black';
17
-
18
15
  var _default = function _default(tokenStream) {
19
16
  var line;
20
17
  var style;
21
18
  var color;
22
19
  var didParseFirst = false;
23
-
24
20
  while (tokenStream.hasTokens()) {
25
21
  if (didParseFirst) tokenStream.expect(SPACE);
26
-
27
22
  if (typeof line === 'undefined' && tokenStream.matches(LINE)) {
28
23
  var lines = [tokenStream.lastValue.toLowerCase()];
29
24
  tokenStream.saveRewindPoint();
30
-
31
25
  if (lines[0] !== 'none' && tokenStream.matches(SPACE) && tokenStream.matches(LINE)) {
32
- lines.push(tokenStream.lastValue.toLowerCase()); // Underline comes before line-through
33
-
26
+ lines.push(tokenStream.lastValue.toLowerCase());
27
+ // Underline comes before line-through
34
28
  lines.sort().reverse();
35
29
  } else {
36
30
  tokenStream.rewind();
37
31
  }
38
-
39
32
  line = lines.join(' ');
40
33
  } else if (typeof style === 'undefined' && tokenStream.matches(STYLE)) {
41
34
  style = tokenStream.lastValue;
@@ -44,10 +37,8 @@ var _default = function _default(tokenStream) {
44
37
  } else {
45
38
  tokenStream["throw"]();
46
39
  }
47
-
48
40
  didParseFirst = true;
49
41
  }
50
-
51
42
  var $merge = {
52
43
  textDecorationLine: typeof line !== 'undefined' ? line : defaultTextDecorationLine,
53
44
  textDecorationColor: typeof color !== 'undefined' ? color : defaultTextDecorationColor,
@@ -57,5 +48,4 @@ var _default = function _default(tokenStream) {
57
48
  $merge: $merge
58
49
  };
59
50
  };
60
-
61
51
  exports["default"] = _default;
@@ -4,24 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
8
  var SPACE = _tokenTypes.tokens.SPACE,
11
- LINE = _tokenTypes.tokens.LINE;
12
-
9
+ LINE = _tokenTypes.tokens.LINE;
13
10
  var _default = function _default(tokenStream) {
14
11
  var lines = [];
15
12
  var didParseFirst = false;
16
-
17
13
  while (tokenStream.hasTokens()) {
18
14
  if (didParseFirst) tokenStream.expect(SPACE);
19
15
  lines.push(tokenStream.expect(LINE).toLowerCase());
20
16
  didParseFirst = true;
21
17
  }
22
-
23
18
  lines.sort().reverse();
24
19
  return lines.join(' ');
25
20
  };
26
-
27
21
  exports["default"] = _default;
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _util = require("./util");
9
-
10
8
  var _default = function _default(tokenStream) {
11
9
  var _parseShadow = (0, _util.parseShadow)(tokenStream),
12
- offset = _parseShadow.offset,
13
- radius = _parseShadow.radius,
14
- color = _parseShadow.color;
15
-
10
+ offset = _parseShadow.offset,
11
+ radius = _parseShadow.radius,
12
+ color = _parseShadow.color;
16
13
  return {
17
14
  $merge: {
18
15
  textShadowOffset: offset,
@@ -21,5 +18,4 @@ var _default = function _default(tokenStream) {
21
18
  }
22
19
  };
23
20
  };
24
-
25
21
  exports["default"] = _default;
@@ -4,17 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _tokenTypes = require("../tokenTypes");
9
-
10
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
-
8
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
12
  var SPACE = _tokenTypes.tokens.SPACE,
13
- COMMA = _tokenTypes.tokens.COMMA,
14
- LENGTH = _tokenTypes.tokens.LENGTH,
15
- NUMBER = _tokenTypes.tokens.NUMBER,
16
- ANGLE = _tokenTypes.tokens.ANGLE;
17
-
13
+ COMMA = _tokenTypes.tokens.COMMA,
14
+ LENGTH = _tokenTypes.tokens.LENGTH,
15
+ NUMBER = _tokenTypes.tokens.NUMBER,
16
+ ANGLE = _tokenTypes.tokens.ANGLE;
18
17
  var oneOfType = function oneOfType(tokenType) {
19
18
  return function (functionStream) {
20
19
  var value = functionStream.expect(tokenType);
@@ -22,17 +21,14 @@ var oneOfType = function oneOfType(tokenType) {
22
21
  return value;
23
22
  };
24
23
  };
25
-
26
24
  var singleNumber = oneOfType(NUMBER);
27
25
  var singleLength = oneOfType(LENGTH);
28
26
  var singleAngle = oneOfType(ANGLE);
29
-
30
27
  var xyTransformFactory = function xyTransformFactory(tokenType) {
31
28
  return function (key, valueIfOmitted) {
32
29
  return function (functionStream) {
33
30
  var x = functionStream.expect(tokenType);
34
31
  var y;
35
-
36
32
  if (functionStream.hasTokens()) {
37
33
  functionStream.expect(COMMA);
38
34
  y = functionStream.expect(tokenType);
@@ -43,13 +39,11 @@ var xyTransformFactory = function xyTransformFactory(tokenType) {
43
39
  // I.e. scale(5) => [{ scale: 5 }] rather than [{ scaleX: 5 }, { scaleY: 5 }]
44
40
  return x;
45
41
  }
46
-
47
42
  functionStream.expectEmpty();
48
43
  return [_defineProperty({}, "".concat(key, "Y"), y), _defineProperty({}, "".concat(key, "X"), x)];
49
44
  };
50
45
  };
51
46
  };
52
-
53
47
  var xyNumber = xyTransformFactory(NUMBER);
54
48
  var xyLength = xyTransformFactory(LENGTH);
55
49
  var xyAngle = xyTransformFactory(ANGLE);
@@ -69,26 +63,20 @@ var partTransforms = {
69
63
  skewY: singleAngle,
70
64
  skew: xyAngle('skew', '0deg')
71
65
  };
72
-
73
66
  var _default = function _default(tokenStream) {
74
67
  var transforms = [];
75
68
  var didParseFirst = false;
76
-
77
69
  while (tokenStream.hasTokens()) {
78
70
  if (didParseFirst) tokenStream.expect(SPACE);
79
71
  var functionStream = tokenStream.expectFunction();
80
72
  var functionName = functionStream.functionName;
81
73
  var transformedValues = partTransforms[functionName](functionStream);
82
-
83
74
  if (!Array.isArray(transformedValues)) {
84
75
  transformedValues = [_defineProperty({}, functionName, transformedValues)];
85
76
  }
86
-
87
77
  transforms = transformedValues.concat(transforms);
88
78
  didParseFirst = true;
89
79
  }
90
-
91
80
  return transforms;
92
81
  };
93
-
94
82
  exports["default"] = _default;
@@ -1,87 +1,72 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.shadowOffsetFactory = exports.parseShadow = exports.directionFactory = exports.anyOrderFactory = void 0;
7
-
8
8
  var _tokenTypes = require("../tokenTypes");
9
-
10
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
-
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
12
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
13
-
14
13
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
-
16
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
-
18
15
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
19
-
20
16
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
21
-
22
17
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
-
24
18
  var LENGTH = _tokenTypes.tokens.LENGTH,
25
- UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT,
26
- PERCENT = _tokenTypes.tokens.PERCENT,
27
- COLOR = _tokenTypes.tokens.COLOR,
28
- SPACE = _tokenTypes.tokens.SPACE,
29
- NONE = _tokenTypes.tokens.NONE;
30
-
19
+ UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT,
20
+ PERCENT = _tokenTypes.tokens.PERCENT,
21
+ COLOR = _tokenTypes.tokens.COLOR,
22
+ SPACE = _tokenTypes.tokens.SPACE,
23
+ NONE = _tokenTypes.tokens.NONE;
31
24
  var directionFactory = function directionFactory(_ref) {
32
25
  var _ref$types = _ref.types,
33
- types = _ref$types === void 0 ? [LENGTH, UNSUPPORTED_LENGTH_UNIT, PERCENT] : _ref$types,
34
- _ref$directions = _ref.directions,
35
- directions = _ref$directions === void 0 ? ['Top', 'Right', 'Bottom', 'Left'] : _ref$directions,
36
- _ref$prefix = _ref.prefix,
37
- prefix = _ref$prefix === void 0 ? '' : _ref$prefix,
38
- _ref$suffix = _ref.suffix,
39
- suffix = _ref$suffix === void 0 ? '' : _ref$suffix;
26
+ types = _ref$types === void 0 ? [LENGTH, UNSUPPORTED_LENGTH_UNIT, PERCENT] : _ref$types,
27
+ _ref$directions = _ref.directions,
28
+ directions = _ref$directions === void 0 ? ['Top', 'Right', 'Bottom', 'Left'] : _ref$directions,
29
+ _ref$prefix = _ref.prefix,
30
+ prefix = _ref$prefix === void 0 ? '' : _ref$prefix,
31
+ _ref$suffix = _ref.suffix,
32
+ suffix = _ref$suffix === void 0 ? '' : _ref$suffix;
40
33
  return function (tokenStream) {
41
34
  var _output;
35
+ var values = [];
42
36
 
43
- var values = []; // borderWidth doesn't currently allow a percent value, but may do in the future
44
-
37
+ // borderWidth doesn't currently allow a percent value, but may do in the future
45
38
  values.push(tokenStream.expect.apply(tokenStream, _toConsumableArray(types)));
46
-
47
39
  while (values.length < 4 && tokenStream.hasTokens()) {
48
40
  tokenStream.expect(SPACE);
49
41
  values.push(tokenStream.expect.apply(tokenStream, _toConsumableArray(types)));
50
42
  }
51
-
52
43
  tokenStream.expectEmpty();
53
44
  var top = values[0],
54
- _values$ = values[1],
55
- right = _values$ === void 0 ? top : _values$,
56
- _values$2 = values[2],
57
- bottom = _values$2 === void 0 ? top : _values$2,
58
- _values$3 = values[3],
59
- left = _values$3 === void 0 ? right : _values$3;
60
-
45
+ _values$ = values[1],
46
+ right = _values$ === void 0 ? top : _values$,
47
+ _values$2 = values[2],
48
+ bottom = _values$2 === void 0 ? top : _values$2,
49
+ _values$3 = values[3],
50
+ left = _values$3 === void 0 ? right : _values$3;
61
51
  var keyFor = function keyFor(n) {
62
52
  return "".concat(prefix).concat(directions[n]).concat(suffix);
63
53
  };
64
-
65
54
  var output = (_output = {}, _defineProperty(_output, keyFor(0), top), _defineProperty(_output, keyFor(1), right), _defineProperty(_output, keyFor(2), bottom), _defineProperty(_output, keyFor(3), left), _output);
66
55
  return {
67
56
  $merge: output
68
57
  };
69
58
  };
70
59
  };
71
-
72
60
  exports.directionFactory = directionFactory;
73
-
74
61
  var anyOrderFactory = function anyOrderFactory(properties) {
75
62
  var delim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SPACE;
76
63
  return function (tokenStream) {
77
64
  var propertyNames = Object.keys(properties);
78
65
  var values = propertyNames.reduce(function (accum, propertyName) {
79
66
  typeof accum[propertyName] === 'undefined'; // eslint-disable-line
80
-
81
67
  return accum;
82
68
  }, {});
83
69
  var numParsed = 0;
84
-
85
70
  while (numParsed < propertyNames.length && tokenStream.hasTokens()) {
86
71
  if (numParsed) tokenStream.expect(delim);
87
72
  var matchedPropertyName = propertyNames.find(function (propertyName) {
@@ -89,16 +74,13 @@ var anyOrderFactory = function anyOrderFactory(properties) {
89
74
  return tokenStream.matches(token);
90
75
  });
91
76
  });
92
-
93
77
  if (!matchedPropertyName) {
94
78
  tokenStream["throw"]();
95
79
  } else {
96
80
  values[matchedPropertyName] = tokenStream.lastValue;
97
81
  }
98
-
99
82
  numParsed += 1;
100
83
  }
101
-
102
84
  tokenStream.expectEmpty();
103
85
  propertyNames.forEach(function (propertyName) {
104
86
  if (typeof values[propertyName] === 'undefined') {
@@ -110,9 +92,7 @@ var anyOrderFactory = function anyOrderFactory(properties) {
110
92
  };
111
93
  };
112
94
  };
113
-
114
95
  exports.anyOrderFactory = anyOrderFactory;
115
-
116
96
  var shadowOffsetFactory = function shadowOffsetFactory() {
117
97
  return function (tokenStream) {
118
98
  var width = tokenStream.expect(LENGTH);
@@ -124,15 +104,12 @@ var shadowOffsetFactory = function shadowOffsetFactory() {
124
104
  };
125
105
  };
126
106
  };
127
-
128
107
  exports.shadowOffsetFactory = shadowOffsetFactory;
129
-
130
108
  var parseShadow = function parseShadow(tokenStream) {
131
109
  var offsetX;
132
110
  var offsetY;
133
111
  var radius;
134
112
  var color;
135
-
136
113
  if (tokenStream.matches(NONE)) {
137
114
  tokenStream.expectEmpty();
138
115
  return {
@@ -144,34 +121,27 @@ var parseShadow = function parseShadow(tokenStream) {
144
121
  color: 'black'
145
122
  };
146
123
  }
147
-
148
124
  var didParseFirst = false;
149
-
150
125
  while (tokenStream.hasTokens()) {
151
126
  if (didParseFirst) tokenStream.expect(SPACE);
152
-
153
127
  if (typeof offsetX === 'undefined' && tokenStream.matches(LENGTH, UNSUPPORTED_LENGTH_UNIT)) {
154
128
  offsetX = tokenStream.lastValue;
155
-
156
129
  if (tokenStream.matches(SPACE) && tokenStream.matches(LENGTH, UNSUPPORTED_LENGTH_UNIT)) {
157
130
  offsetY = tokenStream.lastValue;
158
131
  } else {
159
132
  offsetY = offsetX;
160
133
  tokenStream.rewind();
161
134
  }
162
-
163
135
  tokenStream.saveRewindPoint();
164
-
165
136
  if (tokenStream.matches(SPACE) && tokenStream.matches(LENGTH, UNSUPPORTED_LENGTH_UNIT)) {
166
137
  // blur-radius
167
138
  radius = tokenStream.lastValue;
168
139
  } else {
169
140
  tokenStream.rewind();
170
141
  }
171
-
172
142
  tokenStream.saveRewindPoint();
173
-
174
- if (tokenStream.matches(SPACE) && tokenStream.matches(LENGTH, UNSUPPORTED_LENGTH_UNIT)) {// spread-radius
143
+ if (tokenStream.matches(SPACE) && tokenStream.matches(LENGTH, UNSUPPORTED_LENGTH_UNIT)) {
144
+ // spread-radius
175
145
  // 兼容web写法,防止报错
176
146
  } else {
177
147
  tokenStream.rewind();
@@ -181,10 +151,8 @@ var parseShadow = function parseShadow(tokenStream) {
181
151
  } else {
182
152
  tokenStream["throw"]();
183
153
  }
184
-
185
154
  didParseFirst = true;
186
155
  }
187
-
188
156
  if (typeof offsetX === 'undefined') tokenStream["throw"]();
189
157
  return {
190
158
  offset: {
@@ -195,5 +163,4 @@ var parseShadow = function parseShadow(tokenStream) {
195
163
  color: typeof color !== 'undefined' ? color : 'black'
196
164
  };
197
165
  };
198
-
199
166
  exports.parseShadow = parseShadow;
package/dist/index.js CHANGED
@@ -10,38 +10,24 @@ Object.defineProperty(exports, "transformCSS", {
10
10
  return _cssToReactNative["default"];
11
11
  }
12
12
  });
13
-
14
13
  var _parse = _interopRequireDefault(require("css/lib/parse"));
15
-
16
14
  var _cssMediaquery = _interopRequireDefault(require("css-mediaquery"));
17
-
18
15
  var _cssToReactNative = _interopRequireDefault(require("./css-to-react-native"));
19
-
20
16
  var _features = require("./transforms/media-queries/features");
21
-
22
17
  var _types = require("./transforms/media-queries/types");
23
-
24
18
  var _rem = require("./transforms/rem");
25
-
26
19
  var _allEqual = require("./utils/allEqual");
27
-
28
20
  var _camelCase = require("./utils/camelCase");
29
-
30
21
  var _sortRules = require("./utils/sortRules");
31
-
32
22
  var _values = require("./utils/values");
33
-
34
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
-
36
24
  var lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)(?=px|rem$))/;
37
25
  var viewportUnitRe = /^([+-]?[0-9.]+)(vh|vw|vmin|vmax)$/;
38
26
  var percentRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?%)$/;
39
27
  var unsupportedUnitRe = /^([+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?(ch|em|ex|cm|mm|in|pc|pt))$/;
40
28
  var shorthandBorderProps = ['border-radius', 'border-width', 'border-color', 'border-style'];
41
-
42
29
  var transformDecls = function transformDecls(styles, declarations, result) {
43
30
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
44
-
45
31
  for (var d in declarations) {
46
32
  var declaration = declarations[d];
47
33
  if (declaration.type !== 'declaration') continue;
@@ -51,33 +37,27 @@ var transformDecls = function transformDecls(styles, declarations, result) {
51
37
  var isViewportUnit = viewportUnitRe.test(value);
52
38
  var isPercent = percentRe.test(value);
53
39
  var isUnsupportedUnit = unsupportedUnitRe.test(value);
54
-
55
40
  if (property === 'line-height' && !isLengthUnit && !isViewportUnit && !isPercent && !isUnsupportedUnit) {
56
41
  // ignore invalid value avoid throw error cause app crash
57
42
  continue;
58
43
  }
59
-
60
44
  if (!result.__viewportUnits && isViewportUnit) {
61
45
  result.__viewportUnits = true;
62
- } // scalable option, when it is false, transform single value 'px' unit to 'PX'
46
+ }
47
+ // scalable option, when it is false, transform single value 'px' unit to 'PX'
63
48
  // do not be wrapped by scalePx2dp function
64
-
65
-
66
49
  if (typeof options.scalable === 'boolean' && !options.scalable && /(\d+)px/.test(value)) {
67
50
  value = value.replace(/(\d+)px/g, '$1PX');
68
- } // expect value is legal so that remove !import
69
-
70
-
51
+ }
52
+ // expect value is legal so that remove !import
71
53
  if (/!import/i.test(value)) {
72
54
  value = value.replace(/!import/, '');
73
55
  }
74
-
75
56
  if (shorthandBorderProps.indexOf(property) > -1) {
76
57
  // transform single value shorthand border properties back to
77
58
  // shorthand form to support styling `Image`.
78
59
  var transformed = (0, _cssToReactNative["default"])([[property, value]]);
79
60
  var vals = (0, _values.values)(transformed);
80
-
81
61
  if ((0, _allEqual.allEqual)(vals)) {
82
62
  var replacement = {};
83
63
  replacement[(0, _camelCase.camelCase)(property)] = vals[0];
@@ -90,62 +70,48 @@ var transformDecls = function transformDecls(styles, declarations, result) {
90
70
  }
91
71
  }
92
72
  };
93
-
94
73
  var transform = function transform(css, options) {
95
74
  var _parseCSS = (0, _parse["default"])(css),
96
- stylesheet = _parseCSS.stylesheet;
97
-
75
+ stylesheet = _parseCSS.stylesheet;
98
76
  var rules = (0, _sortRules.sortRules)(stylesheet.rules);
99
77
  var result = {};
100
-
101
78
  for (var r in rules) {
102
79
  var rule = rules[r];
103
-
104
80
  for (var s in rule.selectors) {
105
81
  if (rule.selectors[s] === ':export') {
106
82
  if (!result.__exportProps) {
107
83
  result.__exportProps = {};
108
84
  }
109
-
110
85
  rule.declarations.forEach(function (_ref) {
111
86
  var property = _ref.property,
112
- value = _ref.value;
87
+ value = _ref.value;
113
88
  var isAlreadyDefinedAsClass = typeof result[property] !== 'undefined' && typeof result.__exportProps[property] === 'undefined';
114
-
115
89
  if (isAlreadyDefinedAsClass) {
116
90
  throw new Error("Failed to parse :export block because a CSS class in the same file is already using the name \"".concat(property, "\""));
117
91
  }
118
-
119
92
  result.__exportProps[property] = value;
120
93
  });
121
94
  continue;
122
95
  }
123
-
124
96
  if (rule.selectors[s].indexOf('.') !== 0 || rule.selectors[s].indexOf(':') !== -1 || rule.selectors[s].indexOf('[') !== -1 || rule.selectors[s].indexOf('~') !== -1 || rule.selectors[s].indexOf('>') !== -1 || rule.selectors[s].indexOf('+') !== -1 || rule.selectors[s].indexOf(' ') !== -1) {
125
97
  continue;
126
98
  }
127
-
128
99
  var selector = rule.selectors[s].replace(/^\./, '');
129
100
  var styles = result[selector] = result[selector] || {};
130
101
  transformDecls(styles, rule.declarations, result, options);
131
102
  }
132
-
133
103
  if (rule.type === 'media' && options != null && options.parseMediaQueries === true) {
134
104
  var parsed = _cssMediaquery["default"].parse(rule.media);
135
-
136
105
  parsed.forEach(function (mq) {
137
106
  if (_types.mediaQueryTypes.indexOf(mq.type) === -1) {
138
107
  throw new Error("Failed to parse media query type \"".concat(mq.type, "\""));
139
108
  }
140
-
141
109
  mq.expressions.forEach(function (e) {
142
110
  var mf = e.modifier ? "".concat(e.modifier, "-").concat(e.feature) : e.feature;
143
111
  var val = e.value ? ": ".concat(e.value) : '';
144
-
145
112
  if (_features.mediaQueryFeatures.indexOf(e.feature) === -1) {
146
113
  throw new Error("Failed to parse media query feature \"".concat(mf, "\""));
147
114
  }
148
-
149
115
  if (_features.dimensionFeatures.indexOf(e.feature) > -1 && lengthRe.test(e.value) === false) {
150
116
  throw new Error("Failed to parse media query expression \"(".concat(mf).concat(val, ")\""));
151
117
  }
@@ -154,29 +120,22 @@ var transform = function transform(css, options) {
154
120
  var media = '@media ' + rule.media;
155
121
  result.__mediaQueries = result.__mediaQueries || {};
156
122
  result.__mediaQueries[media] = parsed;
157
-
158
123
  for (var _r in rule.rules) {
159
124
  var ruleRule = rule.rules[_r];
160
-
161
125
  for (var _s in ruleRule.selectors) {
162
126
  result[media] = result[media] || {};
163
-
164
127
  var _selector = ruleRule.selectors[_s].replace(/^\./, '');
165
-
166
128
  var mediaStyles = result[media][_selector] = result[media][_selector] || {};
167
129
  transformDecls(mediaStyles, ruleRule.declarations, result, options);
168
130
  }
169
131
  }
170
132
  }
171
133
  }
172
-
173
134
  if (result.__exportProps) {
174
135
  Object.assign(result, result.__exportProps);
175
136
  delete result.__exportProps;
176
137
  }
177
-
178
138
  return result;
179
139
  };
180
-
181
140
  var _default = transform;
182
141
  exports["default"] = _default;
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.remToPx = void 0;
7
-
8
7
  var remToPx = function remToPx(value) {
9
8
  return value.replace(/(\d*\.?\d+)rem/g, function (match, m1) {
10
9
  return parseFloat(m1, 10) * 16 + 'px';
11
10
  });
12
11
  };
13
-
14
12
  exports.remToPx = remToPx;
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.allEqual = void 0;
7
-
8
7
  var allEqual = function allEqual(arr) {
9
8
  return arr.every(function (v) {
10
9
  return v === arr[0];
11
10
  });
12
11
  };
13
-
14
12
  exports.allEqual = allEqual;
@@ -4,15 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.camelCase = camelCase;
7
-
8
7
  function camelCase(str) {
9
8
  // Lower cases the string
10
- return str.toLowerCase() // Replaces any - or _ characters with a space
11
- .replace(/[-_]+/g, ' ') // Removes any non alphanumeric characters
12
- .replace(/[^\w\s]/g, '') // Uppercase the first character in each group immediately following a space
9
+ return str.toLowerCase()
10
+ // Replaces any - or _ characters with a space
11
+ .replace(/[-_]+/g, ' ')
12
+ // Removes any non alphanumeric characters
13
+ .replace(/[^\w\s]/g, '')
14
+ // Uppercase the first character in each group immediately following a space
13
15
  // (delimited by spaces)
14
16
  .replace(/ (.)/g, function ($1) {
15
17
  return $1.toUpperCase();
16
- }) // Removes spaces
18
+ })
19
+ // Removes spaces
17
20
  .replace(/ /g, '');
18
21
  }
@@ -4,37 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.sortRules = sortRules;
7
-
8
7
  function isExport(n) {
9
8
  return Array.isArray(n) && n[0] === ':export';
10
9
  }
11
-
12
10
  function byExport(a, b) {
13
11
  if (!isExport(a.selectors) && isExport(b.selectors)) {
14
12
  return -1;
15
13
  }
16
-
17
14
  if (isExport(a.selectors) && !isExport(b.selectors)) {
18
15
  return 1;
19
16
  }
20
-
21
17
  return 0;
22
18
  }
23
-
24
19
  function byLine(a, b) {
25
20
  if (isExport(a.selectors) && isExport(b.selectors)) {
26
21
  if (a.position.start.line > b.position.start.line) {
27
22
  return 1;
28
23
  }
29
-
30
24
  if (a.position.start.line < b.position.start.line) {
31
25
  return -1;
32
26
  }
33
27
  }
34
-
35
28
  return 0;
36
29
  }
37
-
38
30
  function sortRules(rules) {
39
31
  return rules.sort(byExport).sort(byLine);
40
32
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _sortRules = require("./sortRules");
4
-
5
4
  describe('sortRules', function () {
6
5
  it('should sort :export to be the last rule', function () {
7
6
  expect((0, _sortRules.sortRules)([{
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.values = void 0;
7
-
8
7
  var values = function values(obj) {
9
8
  return Object.keys(obj).map(function (key) {
10
9
  return obj[key];
11
10
  });
12
11
  };
13
-
14
12
  exports.values = values;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "taro-css-to-react-native",
3
3
  "description": "Convert CSS text to a React Native stylesheet object",
4
- "version": "3.5.11",
4
+ "version": "3.6.0-alpha.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
7
7
  "dependencies": {