fela-utils
Advanced tools
Comparing version 11.7.0 to 12.0.0-rc.0
@@ -5,11 +5,7 @@ var _handlers; | ||
import arrayReduce from 'fast-loops/lib/arrayReduce'; | ||
import objectReduce from 'fast-loops/lib/objectReduce'; | ||
import { arrayReduce, objectReduce } from 'fast-loops'; | ||
import generateCSSRule from './generateCSSRule'; | ||
import objectSortByScore from './objectSortByScore'; | ||
import getRuleScore from './getRuleScore'; | ||
import { RULE_TYPE, KEYFRAME_TYPE, FONT_TYPE, STATIC_TYPE } from './styleTypes'; | ||
var handlers = (_handlers = {}, _defineProperty(_handlers, RULE_TYPE, function (cluster, _ref) { | ||
@@ -20,3 +16,2 @@ var selector = _ref.selector, | ||
media = _ref.media; | ||
var cssRule = generateCSSRule(selector, declaration); | ||
@@ -53,7 +48,5 @@ | ||
var fontFace = _ref2.fontFace; | ||
cluster.fontFaces += fontFace; | ||
}), _defineProperty(_handlers, KEYFRAME_TYPE, function (cluster, _ref3) { | ||
var keyframe = _ref3.keyframe; | ||
cluster.keyframes += keyframe; | ||
@@ -70,10 +63,7 @@ }), _defineProperty(_handlers, STATIC_TYPE, function (cluster, _ref4) { | ||
}), _handlers); | ||
export default function clusterCache(cache) { | ||
var ruleOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var sortedCache = objectSortByScore(cache, function (value) { | ||
return getRuleScore(ruleOrder, value.pseudo); | ||
}); | ||
return objectReduce(sortedCache, function (cluster, entry) { | ||
@@ -80,0 +70,0 @@ var handler = handlers[entry.type]; |
@@ -1,5 +0,3 @@ | ||
import objectReduce from 'fast-loops/lib/objectReduce'; | ||
import { objectReduce } from 'fast-loops'; | ||
import generateCSSSupportRule from './generateCSSSupportRule'; | ||
export default function cssifySupportRules(supportRules) { | ||
@@ -6,0 +4,0 @@ return objectReduce(supportRules, function (css, cssRules, support) { |
// workaround, because can't use native Array findIndex in IE https://github.com/robinweser/fela/pull/766 | ||
export default function findIndex(array, predicate) { | ||
var index = -1; | ||
for (var i = 0; i < array.length; i++) { | ||
@@ -10,3 +11,4 @@ if (predicate(array[i])) { | ||
} | ||
return index; | ||
} |
@@ -6,3 +6,3 @@ export default function generateCombinedMediaQuery(currentMediaQuery, nestedMediaQuery) { | ||
return currentMediaQuery + " and " + nestedMediaQuery; | ||
return "".concat(currentMediaQuery, " and ").concat(nestedMediaQuery); | ||
} |
export default function generateCSSRule(selector, cssDeclaration) { | ||
return selector + "{" + cssDeclaration + "}"; | ||
return "".concat(selector, "{").concat(cssDeclaration, "}"); | ||
} |
@@ -5,6 +5,4 @@ export default function generateCSSSelector(className) { | ||
var propertyPriority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; | ||
var classNameSelector = ('.' + className).repeat(propertyPriority); | ||
return '' + specificityPrefix + classNameSelector + pseudo; | ||
var classNameSelector = ".".concat(className).repeat(propertyPriority); | ||
return "".concat(specificityPrefix).concat(classNameSelector).concat(pseudo); | ||
} |
export default function generateCSSSupportRule(support, cssRules) { | ||
return "@supports " + support + "{" + cssRules + "}"; | ||
return "@supports ".concat(support, "{").concat(cssRules, "}"); | ||
} |
@@ -5,4 +5,3 @@ export default function generateDeclarationReference(property, value) { | ||
var support = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ''; | ||
return support + media + pseudo + property + value; | ||
} |
@@ -18,3 +18,2 @@ import clusterCache from './clusterCache'; | ||
import { RULE_TYPE, KEYFRAME_TYPE, FONT_TYPE, STATIC_TYPE, CLEAR_TYPE } from './styleTypes'; | ||
export { clusterCache, cssifySupportRules, generateDeclarationReference, generateCombinedMediaQuery, generateCSSRule, generateCSSSelector, generateCSSSupportRule, getRuleScore, isMediaQuery, isNestedSelector, isSupport, isUndefinedValue, isValidHTMLElement, normalizeNestedProperty, processStyleWithPlugins, sheetMap, RULE_TYPE, KEYFRAME_TYPE, FONT_TYPE, STATIC_TYPE, CLEAR_TYPE }; |
@@ -1,5 +0,15 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
export default function insertAtIndex(arr, el, index) { | ||
return [].concat(_toConsumableArray(arr.slice(0, index)), [el], _toConsumableArray(arr.slice(index, arr.length))); | ||
} |
var regex = /^(:|\[|>|&)/; | ||
export default function isNestedSelector(property) { | ||
return regex.test(property); | ||
} |
var FALSY_REGEX = /undefined|null/; | ||
var URL_REGEX = /url/; | ||
export default function isUndefinedValue(value) { | ||
return value === undefined || value === null || typeof value === 'string' && FALSY_REGEX.test(value) && !URL_REGEX.test(value); | ||
} |
@@ -1,9 +0,17 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
import arrayReduce from 'fast-loops/lib/arrayReduce'; | ||
import objectReduce from 'fast-loops/lib/objectReduce'; | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
import { arrayReduce, objectReduce } from 'fast-loops'; | ||
import findIndex from './findIndex'; | ||
import insertAtIndex from './insertAtIndex'; | ||
import insertAtIndex from './insertAtIndex'; // TODO: we can further improve this one | ||
// TODO: we can further improve this one | ||
export default function objectSortByScore(obj, getScore) { | ||
@@ -21,3 +29,2 @@ var sortedKeys = objectReduce(obj, function (resultSortedKeys, value, key) { | ||
}, []); | ||
return arrayReduce(sortedKeys, function (sortedObj, key) { | ||
@@ -24,0 +31,0 @@ sortedObj[key] = obj[key]; |
@@ -1,3 +0,2 @@ | ||
import arrayReduce from 'fast-loops/lib/arrayReduce'; | ||
import { arrayReduce } from 'fast-loops'; | ||
export default function processStyleWithPlugins(renderer, style, type) { | ||
@@ -4,0 +3,0 @@ var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; |
import { FONT_TYPE, STATIC_TYPE, KEYFRAME_TYPE, RULE_TYPE } from './styleTypes'; | ||
export default { | ||
@@ -4,0 +3,0 @@ fontFaces: FONT_TYPE, |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,31 +6,18 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports["default"] = clusterCache; | ||
var _handlers; | ||
var _fastLoops = require("fast-loops"); | ||
exports.default = clusterCache; | ||
var _generateCSSRule = _interopRequireDefault(require("./generateCSSRule")); | ||
var _arrayReduce = require('fast-loops/lib/arrayReduce'); | ||
var _objectSortByScore = _interopRequireDefault(require("./objectSortByScore")); | ||
var _arrayReduce2 = _interopRequireDefault(_arrayReduce); | ||
var _getRuleScore = _interopRequireDefault(require("./getRuleScore")); | ||
var _objectReduce = require('fast-loops/lib/objectReduce'); | ||
var _styleTypes = require("./styleTypes"); | ||
var _objectReduce2 = _interopRequireDefault(_objectReduce); | ||
var _handlers; | ||
var _generateCSSRule = require('./generateCSSRule'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _generateCSSRule2 = _interopRequireDefault(_generateCSSRule); | ||
var _objectSortByScore = require('./objectSortByScore'); | ||
var _objectSortByScore2 = _interopRequireDefault(_objectSortByScore); | ||
var _getRuleScore = require('./getRuleScore'); | ||
var _getRuleScore2 = _interopRequireDefault(_getRuleScore); | ||
var _styleTypes = require('./styleTypes'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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; } | ||
@@ -43,5 +30,4 @@ | ||
media = _ref.media; | ||
var cssRule = (0, _generateCSSRule["default"])(selector, declaration); | ||
var cssRule = (0, _generateCSSRule2.default)(selector, declaration); | ||
if (support) { | ||
@@ -76,7 +62,5 @@ if (media) { | ||
var fontFace = _ref2.fontFace; | ||
cluster.fontFaces += fontFace; | ||
}), _defineProperty(_handlers, _styleTypes.KEYFRAME_TYPE, function (cluster, _ref3) { | ||
var keyframe = _ref3.keyframe; | ||
cluster.keyframes += keyframe; | ||
@@ -88,3 +72,3 @@ }), _defineProperty(_handlers, _styleTypes.STATIC_TYPE, function (cluster, _ref4) { | ||
if (selector) { | ||
cluster.statics += (0, _generateCSSRule2.default)(selector, css); | ||
cluster.statics += (0, _generateCSSRule["default"])(selector, css); | ||
} else { | ||
@@ -97,8 +81,6 @@ cluster.statics += css; | ||
var ruleOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var sortedCache = (0, _objectSortByScore2.default)(cache, function (value) { | ||
return (0, _getRuleScore2.default)(ruleOrder, value.pseudo); | ||
var sortedCache = (0, _objectSortByScore["default"])(cache, function (value) { | ||
return (0, _getRuleScore["default"])(ruleOrder, value.pseudo); | ||
}); | ||
return (0, _objectReduce2.default)(sortedCache, function (cluster, entry) { | ||
return (0, _fastLoops.objectReduce)(sortedCache, function (cluster, entry) { | ||
var handler = handlers[entry.type]; | ||
@@ -105,0 +87,0 @@ |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,18 +6,14 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = cssifySupportRules; | ||
exports["default"] = cssifySupportRules; | ||
var _objectReduce = require('fast-loops/lib/objectReduce'); | ||
var _fastLoops = require("fast-loops"); | ||
var _objectReduce2 = _interopRequireDefault(_objectReduce); | ||
var _generateCSSSupportRule = _interopRequireDefault(require("./generateCSSSupportRule")); | ||
var _generateCSSSupportRule = require('./generateCSSSupportRule'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _generateCSSSupportRule2 = _interopRequireDefault(_generateCSSSupportRule); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function cssifySupportRules(supportRules) { | ||
return (0, _objectReduce2.default)(supportRules, function (css, cssRules, support) { | ||
return (0, _fastLoops.objectReduce)(supportRules, function (css, cssRules, support) { | ||
if (cssRules.length > 0) { | ||
css += (0, _generateCSSSupportRule2.default)(support, cssRules); | ||
css += (0, _generateCSSSupportRule["default"])(support, cssRules); | ||
} | ||
@@ -24,0 +20,0 @@ |
@@ -6,6 +6,8 @@ "use strict"; | ||
}); | ||
exports.default = findIndex; | ||
exports["default"] = findIndex; | ||
// workaround, because can't use native Array findIndex in IE https://github.com/robinweser/fela/pull/766 | ||
function findIndex(array, predicate) { | ||
var index = -1; | ||
for (var i = 0; i < array.length; i++) { | ||
@@ -17,3 +19,4 @@ if (predicate(array[i])) { | ||
} | ||
return index; | ||
} |
@@ -6,3 +6,4 @@ "use strict"; | ||
}); | ||
exports.default = generateCombinedMediaQuery; | ||
exports["default"] = generateCombinedMediaQuery; | ||
function generateCombinedMediaQuery(currentMediaQuery, nestedMediaQuery) { | ||
@@ -13,3 +14,3 @@ if (currentMediaQuery.length === 0) { | ||
return currentMediaQuery + " and " + nestedMediaQuery; | ||
return "".concat(currentMediaQuery, " and ").concat(nestedMediaQuery); | ||
} |
@@ -6,5 +6,6 @@ "use strict"; | ||
}); | ||
exports.default = generateCSSRule; | ||
exports["default"] = generateCSSRule; | ||
function generateCSSRule(selector, cssDeclaration) { | ||
return selector + "{" + cssDeclaration + "}"; | ||
return "".concat(selector, "{").concat(cssDeclaration, "}"); | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,4 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = generateCSSSelector; | ||
exports["default"] = generateCSSSelector; | ||
function generateCSSSelector(className) { | ||
@@ -12,6 +13,4 @@ var pseudo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var propertyPriority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; | ||
var classNameSelector = ('.' + className).repeat(propertyPriority); | ||
return '' + specificityPrefix + classNameSelector + pseudo; | ||
var classNameSelector = ".".concat(className).repeat(propertyPriority); | ||
return "".concat(specificityPrefix).concat(classNameSelector).concat(pseudo); | ||
} |
@@ -6,5 +6,6 @@ "use strict"; | ||
}); | ||
exports.default = generateCSSSupportRule; | ||
exports["default"] = generateCSSSupportRule; | ||
function generateCSSSupportRule(support, cssRules) { | ||
return "@supports " + support + "{" + cssRules + "}"; | ||
return "@supports ".concat(support, "{").concat(cssRules, "}"); | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,4 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = generateDeclarationReference; | ||
exports["default"] = generateDeclarationReference; | ||
function generateDeclarationReference(property, value) { | ||
@@ -12,4 +13,3 @@ var pseudo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
var support = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ''; | ||
return support + media + pseudo + property + value; | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,4 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = getRuleScore; | ||
exports["default"] = getRuleScore; | ||
function getRuleScore() { | ||
@@ -9,0 +10,0 @@ var ruleOrder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
219
lib/index.js
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,92 +6,163 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.CLEAR_TYPE = exports.STATIC_TYPE = exports.FONT_TYPE = exports.KEYFRAME_TYPE = exports.RULE_TYPE = exports.sheetMap = exports.processStyleWithPlugins = exports.normalizeNestedProperty = exports.isValidHTMLElement = exports.isUndefinedValue = exports.isSupport = exports.isNestedSelector = exports.isMediaQuery = exports.getRuleScore = exports.generateCSSSupportRule = exports.generateCSSSelector = exports.generateCSSRule = exports.generateCombinedMediaQuery = exports.generateDeclarationReference = exports.cssifySupportRules = exports.clusterCache = undefined; | ||
Object.defineProperty(exports, "CLEAR_TYPE", { | ||
enumerable: true, | ||
get: function get() { | ||
return _styleTypes.CLEAR_TYPE; | ||
} | ||
}); | ||
Object.defineProperty(exports, "FONT_TYPE", { | ||
enumerable: true, | ||
get: function get() { | ||
return _styleTypes.FONT_TYPE; | ||
} | ||
}); | ||
Object.defineProperty(exports, "KEYFRAME_TYPE", { | ||
enumerable: true, | ||
get: function get() { | ||
return _styleTypes.KEYFRAME_TYPE; | ||
} | ||
}); | ||
Object.defineProperty(exports, "RULE_TYPE", { | ||
enumerable: true, | ||
get: function get() { | ||
return _styleTypes.RULE_TYPE; | ||
} | ||
}); | ||
Object.defineProperty(exports, "STATIC_TYPE", { | ||
enumerable: true, | ||
get: function get() { | ||
return _styleTypes.STATIC_TYPE; | ||
} | ||
}); | ||
Object.defineProperty(exports, "clusterCache", { | ||
enumerable: true, | ||
get: function get() { | ||
return _clusterCache["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "cssifySupportRules", { | ||
enumerable: true, | ||
get: function get() { | ||
return _cssifySupportRules["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "generateCSSRule", { | ||
enumerable: true, | ||
get: function get() { | ||
return _generateCSSRule["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "generateCSSSelector", { | ||
enumerable: true, | ||
get: function get() { | ||
return _generateCSSSelector["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "generateCSSSupportRule", { | ||
enumerable: true, | ||
get: function get() { | ||
return _generateCSSSupportRule["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "generateCombinedMediaQuery", { | ||
enumerable: true, | ||
get: function get() { | ||
return _generateCombinedMediaQuery["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "generateDeclarationReference", { | ||
enumerable: true, | ||
get: function get() { | ||
return _generateDeclarationReference["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getRuleScore", { | ||
enumerable: true, | ||
get: function get() { | ||
return _getRuleScore["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isMediaQuery", { | ||
enumerable: true, | ||
get: function get() { | ||
return _isMediaQuery["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isNestedSelector", { | ||
enumerable: true, | ||
get: function get() { | ||
return _isNestedSelector["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isSupport", { | ||
enumerable: true, | ||
get: function get() { | ||
return _isSupport["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isUndefinedValue", { | ||
enumerable: true, | ||
get: function get() { | ||
return _isUndefinedValue["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isValidHTMLElement", { | ||
enumerable: true, | ||
get: function get() { | ||
return _isValidHTMLElement["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "normalizeNestedProperty", { | ||
enumerable: true, | ||
get: function get() { | ||
return _normalizeNestedProperty["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "processStyleWithPlugins", { | ||
enumerable: true, | ||
get: function get() { | ||
return _processStyleWithPlugins["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "sheetMap", { | ||
enumerable: true, | ||
get: function get() { | ||
return _sheetMap["default"]; | ||
} | ||
}); | ||
var _clusterCache = require('./clusterCache'); | ||
var _clusterCache = _interopRequireDefault(require("./clusterCache")); | ||
var _clusterCache2 = _interopRequireDefault(_clusterCache); | ||
var _cssifySupportRules = _interopRequireDefault(require("./cssifySupportRules")); | ||
var _cssifySupportRules = require('./cssifySupportRules'); | ||
var _generateCombinedMediaQuery = _interopRequireDefault(require("./generateCombinedMediaQuery")); | ||
var _cssifySupportRules2 = _interopRequireDefault(_cssifySupportRules); | ||
var _generateCSSRule = _interopRequireDefault(require("./generateCSSRule")); | ||
var _generateCombinedMediaQuery = require('./generateCombinedMediaQuery'); | ||
var _generateCSSSelector = _interopRequireDefault(require("./generateCSSSelector")); | ||
var _generateCombinedMediaQuery2 = _interopRequireDefault(_generateCombinedMediaQuery); | ||
var _generateCSSSupportRule = _interopRequireDefault(require("./generateCSSSupportRule")); | ||
var _generateCSSRule = require('./generateCSSRule'); | ||
var _getRuleScore = _interopRequireDefault(require("./getRuleScore")); | ||
var _generateCSSRule2 = _interopRequireDefault(_generateCSSRule); | ||
var _isMediaQuery = _interopRequireDefault(require("./isMediaQuery")); | ||
var _generateCSSSelector = require('./generateCSSSelector'); | ||
var _isNestedSelector = _interopRequireDefault(require("./isNestedSelector")); | ||
var _generateCSSSelector2 = _interopRequireDefault(_generateCSSSelector); | ||
var _isSupport = _interopRequireDefault(require("./isSupport")); | ||
var _generateCSSSupportRule = require('./generateCSSSupportRule'); | ||
var _isUndefinedValue = _interopRequireDefault(require("./isUndefinedValue")); | ||
var _generateCSSSupportRule2 = _interopRequireDefault(_generateCSSSupportRule); | ||
var _isValidHTMLElement = _interopRequireDefault(require("./isValidHTMLElement")); | ||
var _getRuleScore = require('./getRuleScore'); | ||
var _normalizeNestedProperty = _interopRequireDefault(require("./normalizeNestedProperty")); | ||
var _getRuleScore2 = _interopRequireDefault(_getRuleScore); | ||
var _processStyleWithPlugins = _interopRequireDefault(require("./processStyleWithPlugins")); | ||
var _isMediaQuery = require('./isMediaQuery'); | ||
var _generateDeclarationReference = _interopRequireDefault(require("./generateDeclarationReference")); | ||
var _isMediaQuery2 = _interopRequireDefault(_isMediaQuery); | ||
var _sheetMap = _interopRequireDefault(require("./sheetMap")); | ||
var _isNestedSelector = require('./isNestedSelector'); | ||
var _styleTypes = require("./styleTypes"); | ||
var _isNestedSelector2 = _interopRequireDefault(_isNestedSelector); | ||
var _isSupport = require('./isSupport'); | ||
var _isSupport2 = _interopRequireDefault(_isSupport); | ||
var _isUndefinedValue = require('./isUndefinedValue'); | ||
var _isUndefinedValue2 = _interopRequireDefault(_isUndefinedValue); | ||
var _isValidHTMLElement = require('./isValidHTMLElement'); | ||
var _isValidHTMLElement2 = _interopRequireDefault(_isValidHTMLElement); | ||
var _normalizeNestedProperty = require('./normalizeNestedProperty'); | ||
var _normalizeNestedProperty2 = _interopRequireDefault(_normalizeNestedProperty); | ||
var _processStyleWithPlugins = require('./processStyleWithPlugins'); | ||
var _processStyleWithPlugins2 = _interopRequireDefault(_processStyleWithPlugins); | ||
var _generateDeclarationReference = require('./generateDeclarationReference'); | ||
var _generateDeclarationReference2 = _interopRequireDefault(_generateDeclarationReference); | ||
var _sheetMap = require('./sheetMap'); | ||
var _sheetMap2 = _interopRequireDefault(_sheetMap); | ||
var _styleTypes = require('./styleTypes'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.clusterCache = _clusterCache2.default; | ||
exports.cssifySupportRules = _cssifySupportRules2.default; | ||
exports.generateDeclarationReference = _generateDeclarationReference2.default; | ||
exports.generateCombinedMediaQuery = _generateCombinedMediaQuery2.default; | ||
exports.generateCSSRule = _generateCSSRule2.default; | ||
exports.generateCSSSelector = _generateCSSSelector2.default; | ||
exports.generateCSSSupportRule = _generateCSSSupportRule2.default; | ||
exports.getRuleScore = _getRuleScore2.default; | ||
exports.isMediaQuery = _isMediaQuery2.default; | ||
exports.isNestedSelector = _isNestedSelector2.default; | ||
exports.isSupport = _isSupport2.default; | ||
exports.isUndefinedValue = _isUndefinedValue2.default; | ||
exports.isValidHTMLElement = _isValidHTMLElement2.default; | ||
exports.normalizeNestedProperty = _normalizeNestedProperty2.default; | ||
exports.processStyleWithPlugins = _processStyleWithPlugins2.default; | ||
exports.sheetMap = _sheetMap2.default; | ||
exports.RULE_TYPE = _styleTypes.RULE_TYPE; | ||
exports.KEYFRAME_TYPE = _styleTypes.KEYFRAME_TYPE; | ||
exports.FONT_TYPE = _styleTypes.FONT_TYPE; | ||
exports.STATIC_TYPE = _styleTypes.STATIC_TYPE; | ||
exports.CLEAR_TYPE = _styleTypes.CLEAR_TYPE; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } |
@@ -6,8 +6,18 @@ "use strict"; | ||
}); | ||
exports.default = insertAtIndex; | ||
exports["default"] = insertAtIndex; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
function insertAtIndex(arr, el, index) { | ||
return [].concat(_toConsumableArray(arr.slice(0, index)), [el], _toConsumableArray(arr.slice(index, arr.length))); | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,5 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = isMediaQuery; | ||
exports["default"] = isMediaQuery; | ||
function isMediaQuery(property) { | ||
return property.substr(0, 6) === '@media'; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = isNestedSelector; | ||
exports["default"] = isNestedSelector; | ||
var regex = /^(:|\[|>|&)/; | ||
@@ -9,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,5 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = isSupport; | ||
exports["default"] = isSupport; | ||
function isSupport(property) { | ||
return property.substr(0, 9) === '@supports'; | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = isUndefinedValue; | ||
exports["default"] = isUndefinedValue; | ||
var FALSY_REGEX = /undefined|null/; | ||
@@ -9,0 +9,0 @@ var URL_REGEX = /url/; |
@@ -6,5 +6,6 @@ "use strict"; | ||
}); | ||
exports.default = isValidHTMLElement; | ||
exports["default"] = isValidHTMLElement; | ||
function isValidHTMLElement(mountNode) { | ||
return mountNode && mountNode.nodeType === 1; | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,4 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = normalizeNestedProperty; | ||
exports["default"] = normalizeNestedProperty; | ||
function normalizeNestedProperty(nestedProperty) { | ||
@@ -9,0 +10,0 @@ if (nestedProperty.charAt(0) === '&') { |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,28 +6,28 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = objectSortByScore; | ||
exports["default"] = objectSortByScore; | ||
var _arrayReduce = require('fast-loops/lib/arrayReduce'); | ||
var _fastLoops = require("fast-loops"); | ||
var _arrayReduce2 = _interopRequireDefault(_arrayReduce); | ||
var _findIndex = _interopRequireDefault(require("./findIndex")); | ||
var _objectReduce = require('fast-loops/lib/objectReduce'); | ||
var _insertAtIndex = _interopRequireDefault(require("./insertAtIndex")); | ||
var _objectReduce2 = _interopRequireDefault(_objectReduce); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _findIndex = require('./findIndex'); | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
var _findIndex2 = _interopRequireDefault(_findIndex); | ||
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."); } | ||
var _insertAtIndex = require('./insertAtIndex'); | ||
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); } | ||
var _insertAtIndex2 = _interopRequireDefault(_insertAtIndex); | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
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; } | ||
// TODO: we can further improve this one | ||
function objectSortByScore(obj, getScore) { | ||
var sortedKeys = (0, _objectReduce2.default)(obj, function (resultSortedKeys, value, key) { | ||
var index = (0, _findIndex2.default)(resultSortedKeys, function (el) { | ||
var sortedKeys = (0, _fastLoops.objectReduce)(obj, function (resultSortedKeys, value, key) { | ||
var index = (0, _findIndex["default"])(resultSortedKeys, function (el) { | ||
return getScore(obj[el], el) > getScore(value, key); | ||
@@ -37,3 +37,3 @@ }); | ||
if (index !== -1) { | ||
return (0, _insertAtIndex2.default)(resultSortedKeys, key, index); | ||
return (0, _insertAtIndex["default"])(resultSortedKeys, key, index); | ||
} | ||
@@ -43,4 +43,3 @@ | ||
}, []); | ||
return (0, _arrayReduce2.default)(sortedKeys, function (sortedObj, key) { | ||
return (0, _fastLoops.arrayReduce)(sortedKeys, function (sortedObj, key) { | ||
sortedObj[key] = obj[key]; | ||
@@ -47,0 +46,0 @@ return sortedObj; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = processStyleWithPlugins; | ||
exports["default"] = processStyleWithPlugins; | ||
var _arrayReduce = require('fast-loops/lib/arrayReduce'); | ||
var _fastLoops = require("fast-loops"); | ||
var _arrayReduce2 = _interopRequireDefault(_arrayReduce); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function processStyleWithPlugins(renderer, style, type) { | ||
@@ -20,3 +16,3 @@ var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
if (plugins.length > 0) { | ||
return (0, _arrayReduce2.default)(plugins, function (processedStyle, plugin) { | ||
return (0, _fastLoops.arrayReduce)(plugins, function (processedStyle, plugin) { | ||
return plugin(processedStyle, type, renderer, props); | ||
@@ -23,0 +19,0 @@ }, style); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports["default"] = void 0; | ||
var _styleTypes = require('./styleTypes'); | ||
var _styleTypes = require("./styleTypes"); | ||
exports.default = { | ||
var _default = { | ||
fontFaces: _styleTypes.FONT_TYPE, | ||
@@ -15,2 +16,3 @@ statics: _styleTypes.STATIC_TYPE, | ||
rules: _styleTypes.RULE_TYPE | ||
}; | ||
}; | ||
exports["default"] = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
var RULE_TYPE = exports.RULE_TYPE = 'RULE'; | ||
var KEYFRAME_TYPE = exports.KEYFRAME_TYPE = 'KEYFRAME'; | ||
var FONT_TYPE = exports.FONT_TYPE = 'FONT'; | ||
var STATIC_TYPE = exports.STATIC_TYPE = 'STATIC'; | ||
var CLEAR_TYPE = exports.CLEAR_TYPE = 'CLEAR'; | ||
exports.STATIC_TYPE = exports.RULE_TYPE = exports.KEYFRAME_TYPE = exports.FONT_TYPE = exports.CLEAR_TYPE = void 0; | ||
var RULE_TYPE = 'RULE'; | ||
exports.RULE_TYPE = RULE_TYPE; | ||
var KEYFRAME_TYPE = 'KEYFRAME'; | ||
exports.KEYFRAME_TYPE = KEYFRAME_TYPE; | ||
var FONT_TYPE = 'FONT'; | ||
exports.FONT_TYPE = FONT_TYPE; | ||
var STATIC_TYPE = 'STATIC'; | ||
exports.STATIC_TYPE = STATIC_TYPE; | ||
var CLEAR_TYPE = 'CLEAR'; | ||
exports.CLEAR_TYPE = CLEAR_TYPE; |
{ | ||
"name": "fela-utils", | ||
"version": "11.7.0", | ||
"version": "12.0.0-rc.0", | ||
"description": "Internal utilities for Fela", | ||
@@ -13,4 +13,18 @@ "main": "lib/index.js", | ||
"lib/**", | ||
"es/**" | ||
"es/**", | ||
"umd/**" | ||
], | ||
"scripts": { | ||
"setup": "yarn build", | ||
"clean": "rimraf lib es coverage", | ||
"build": "yarn clean && yarn build:es && yarn build:lib", | ||
"build:es": "babel src --out-dir es --ignore **/__tests__", | ||
"build:lib": "cross-env BABEL_ENV=commonjs babel src --out-dir lib --ignore **/__tests__", | ||
"build:umd": "webpack --config webpack.config.js", | ||
"watch": "npm run watch:lib & npm run watch:es", | ||
"watch:lib": "BABEL_ENV=commonjs babel src -d lib -w", | ||
"watch:es": "babel src -d es -w", | ||
"test": "jest --config=jest.config.js", | ||
"coverage": "yarn test --coverage" | ||
}, | ||
"repository": "https://github.com/robinweser/fela/", | ||
@@ -28,3 +42,20 @@ "keywords": [ | ||
}, | ||
"gitHead": "e067b284984d3dbfc259fcbffde9bb50679fda9b" | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.0", | ||
"@babel/core": "^7.2.2", | ||
"@babel/node": "^7.13.0", | ||
"@babel/plugin-transform-modules-commonjs": "^7.5.0", | ||
"@babel/polyfill": "^7.7.0", | ||
"@babel/preset-env": "^7.5.5", | ||
"babel-core": "7.0.0-bridge.0", | ||
"babel-jest": "^26.6.0", | ||
"babel-loader": "^8.2.3", | ||
"clean-webpack-plugin": "^3.0.0", | ||
"cross-env": "^6.0.3", | ||
"jest": "^26.6.0", | ||
"rimraf": "^3.0.0", | ||
"webpack": "^4.41.6", | ||
"webpack-cli": "^3.3.10" | ||
}, | ||
"gitHead": "00f02f410f17a7693479ea3349bb3a9f223359af" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39224
46
654
15
2