@aesthetic/sss
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
import { toArray, isObject } from 'aesthetic-utils'; | ||
import { toArray, isObject, generateHash, objectLoop, arrayLoop } from '@aesthetic/utils'; | ||
@@ -375,9 +375,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
if (handlers) { | ||
Object.entries(handlers).forEach(function (_ref) { | ||
var key = _ref[0], | ||
value = _ref[1]; | ||
_this.on(key.slice(2).replace(/([A-Z])/g, function (match, char) { | ||
objectLoop(handlers, function (handler, name) { | ||
_this.on(name.slice(2).replace(/([A-Z])/g, function (match, char) { | ||
return ":" + char.toLowerCase(); | ||
}), value); | ||
}), handler); | ||
}); | ||
@@ -394,3 +391,3 @@ } | ||
return parts.join('-') + "-" + Date.now().toString(32); | ||
return generateHash(parts.join('-')); | ||
}; | ||
@@ -407,6 +404,3 @@ | ||
Object.entries(object).forEach(function (_ref2) { | ||
var key = _ref2[0], | ||
value = _ref2[1]; | ||
objectLoop(object, function (value, key) { | ||
if (value === undefined) { | ||
@@ -416,5 +410,7 @@ return; | ||
if (key.startsWith(':') || key.startsWith('[')) { | ||
var char = key.charAt(0); | ||
if (char === ':' || char === '[') { | ||
_this2.parseSelector(builder, key, value); | ||
} else if (key.startsWith('@')) { | ||
} else if (char === '@') { | ||
builder.addNested(_this2.parseBlock(new Block(key), value)); | ||
@@ -438,6 +434,3 @@ } else { | ||
Object.entries(object).forEach(function (_ref3) { | ||
var query = _ref3[0], | ||
block = _ref3[1]; | ||
objectLoop(object, function (block, query) { | ||
_this3.emit("block:" + type, builder, query, _this3.parseLocalBlock(new Block("@" + type + " " + query), block)); | ||
@@ -456,6 +449,3 @@ }); | ||
Object.entries(fallbacks).forEach(function (_ref4) { | ||
var prop = _ref4[0], | ||
value = _ref4[1]; | ||
objectLoop(fallbacks, function (value, prop) { | ||
_this4.emit('block:fallback', builder, prop, toArray(value)); | ||
@@ -478,6 +468,3 @@ }); | ||
var keyframes = new Block("@keyframes " + name); | ||
Object.entries(object).forEach(function (_ref5) { | ||
var key = _ref5[0], | ||
value = _ref5[1]; | ||
objectLoop(object, function (value, key) { | ||
if (key === 'name' || value === undefined) { | ||
@@ -511,6 +498,3 @@ return; | ||
if (props['@selectors']) { | ||
Object.entries(props['@selectors']).forEach(function (_ref6) { | ||
var key = _ref6[0], | ||
value = _ref6[1]; | ||
objectLoop(props['@selectors'], function (value, key) { | ||
_this6.parseSelector(builder, key, value, true); | ||
@@ -546,3 +530,3 @@ }); | ||
var specificity = 0; | ||
selector.split(',').forEach(function (k) { | ||
arrayLoop(selector.split(','), function (k) { | ||
var name = k.trim(); | ||
@@ -633,3 +617,3 @@ var type = 'block:selector'; | ||
var enqueue = function () { | ||
var _ref7 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(cb) { | ||
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(cb) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -662,3 +646,3 @@ while (1) { | ||
return function enqueue(_x) { | ||
return _ref7.apply(this, arguments); | ||
return _ref.apply(this, arguments); | ||
}; | ||
@@ -780,6 +764,4 @@ }(); | ||
Object.entries(fontFaces).forEach(function (_ref) { | ||
var name = _ref[0], | ||
faces = _ref[1]; | ||
toArray(faces).forEach(function (fontFace) { | ||
objectLoop(fontFaces, function (faces, name) { | ||
arrayLoop(toArray(faces), function (fontFace) { | ||
_this2.parseFontFace(name, fontFace); | ||
@@ -809,3 +791,3 @@ }); | ||
imports.forEach(function (value) { | ||
arrayLoop(imports, function (value) { | ||
_this3.emit('import', formatImport(value)); | ||
@@ -828,6 +810,3 @@ }); | ||
Object.entries(keyframes).forEach(function (_ref2) { | ||
var name = _ref2[0], | ||
keyframe = _ref2[1]; | ||
objectLoop(keyframes, function (keyframe, name) { | ||
_this4.parseKeyframesAnimation(name, keyframe); | ||
@@ -834,0 +813,0 @@ }); |
@@ -24,3 +24,3 @@ 'use strict'; | ||
var aestheticUtils = require('aesthetic-utils'); | ||
var utils = require('@aesthetic/utils'); | ||
@@ -244,4 +244,4 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
return aestheticUtils.toArray(property).map(function (prop) { | ||
return aestheticUtils.isObject(prop) ? transformAnimation(prop) : prop; | ||
return utils.toArray(property).map(function (prop) { | ||
return utils.isObject(prop) ? transformAnimation(prop) : prop; | ||
}).join(', '); | ||
@@ -255,3 +255,3 @@ } | ||
return aestheticUtils.toArray(property).map(function (prop) { | ||
return utils.toArray(property).map(function (prop) { | ||
if (typeof prop === 'string') { | ||
@@ -272,3 +272,3 @@ return prop; | ||
var fontFaces = new Map(); | ||
aestheticUtils.toArray(property).forEach(function (prop) { | ||
utils.toArray(property).forEach(function (prop) { | ||
if (typeof prop === 'string') { | ||
@@ -312,4 +312,4 @@ output.add(prop); | ||
return aestheticUtils.toArray(property).map(function (prop) { | ||
return aestheticUtils.isObject(prop) ? transformTransition(prop) : prop; | ||
return utils.toArray(property).map(function (prop) { | ||
return utils.isObject(prop) ? transformTransition(prop) : prop; | ||
}).join(', '); | ||
@@ -403,9 +403,6 @@ } | ||
if (handlers) { | ||
Object.entries(handlers).forEach(function (_ref) { | ||
var key = _ref[0], | ||
value = _ref[1]; | ||
_this.on(key.slice(2).replace(/([A-Z])/g, function (match, char) { | ||
utils.objectLoop(handlers, function (handler, name) { | ||
_this.on(name.slice(2).replace(/([A-Z])/g, function (match, char) { | ||
return ":" + char.toLowerCase(); | ||
}), value); | ||
}), handler); | ||
}); | ||
@@ -422,3 +419,3 @@ } | ||
return parts.join('-') + "-" + Date.now().toString(32); | ||
return utils.generateHash(parts.join('-')); | ||
}; | ||
@@ -430,3 +427,3 @@ | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (!aestheticUtils.isObject(object)) { | ||
if (!utils.isObject(object)) { | ||
throw new TypeError("Block \"" + builder.selector + "\" must be an object of properties."); | ||
@@ -436,6 +433,3 @@ } | ||
Object.entries(object).forEach(function (_ref2) { | ||
var key = _ref2[0], | ||
value = _ref2[1]; | ||
utils.objectLoop(object, function (value, key) { | ||
if (value === undefined) { | ||
@@ -445,5 +439,7 @@ return; | ||
if (key.startsWith(':') || key.startsWith('[')) { | ||
var char = key.charAt(0); | ||
if (char === ':' || char === '[') { | ||
_this2.parseSelector(builder, key, value); | ||
} else if (key.startsWith('@')) { | ||
} else if (char === '@') { | ||
builder.addNested(_this2.parseBlock(new Block(key), value)); | ||
@@ -462,3 +458,3 @@ } else { | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (!aestheticUtils.isObject(object)) { | ||
if (!utils.isObject(object)) { | ||
throw new Error("@" + type + " must be an object of queries or conditions to declarations."); | ||
@@ -468,6 +464,3 @@ } | ||
Object.entries(object).forEach(function (_ref3) { | ||
var query = _ref3[0], | ||
block = _ref3[1]; | ||
utils.objectLoop(object, function (block, query) { | ||
_this3.emit("block:" + type, builder, query, _this3.parseLocalBlock(new Block("@" + type + " " + query), block)); | ||
@@ -481,3 +474,3 @@ }); | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (!aestheticUtils.isObject(fallbacks)) { | ||
if (!utils.isObject(fallbacks)) { | ||
throw new Error('@fallbacks must be an object of property names to fallback values.'); | ||
@@ -487,7 +480,4 @@ } | ||
Object.entries(fallbacks).forEach(function (_ref4) { | ||
var prop = _ref4[0], | ||
value = _ref4[1]; | ||
_this4.emit('block:fallback', builder, prop, aestheticUtils.toArray(value)); | ||
utils.objectLoop(fallbacks, function (value, prop) { | ||
_this4.emit('block:fallback', builder, prop, utils.toArray(value)); | ||
}); | ||
@@ -509,6 +499,3 @@ }; | ||
var keyframes = new Block("@keyframes " + name); | ||
Object.entries(object).forEach(function (_ref5) { | ||
var key = _ref5[0], | ||
value = _ref5[1]; | ||
utils.objectLoop(object, function (value, key) { | ||
if (key === 'name' || value === undefined) { | ||
@@ -542,6 +529,3 @@ return; | ||
if (props['@selectors']) { | ||
Object.entries(props['@selectors']).forEach(function (_ref6) { | ||
var key = _ref6[0], | ||
value = _ref6[1]; | ||
utils.objectLoop(props['@selectors'], function (value, key) { | ||
_this6.parseSelector(builder, key, value, true); | ||
@@ -568,3 +552,3 @@ }); | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (!aestheticUtils.isObject(object)) { | ||
if (!utils.isObject(object)) { | ||
throw new Error("Selector \"" + selector + "\" must be an object of properties."); | ||
@@ -578,3 +562,3 @@ } else if ((selector.includes(',') || !selector.match(SELECTOR)) && !inAtRule) { | ||
var specificity = 0; | ||
selector.split(',').forEach(function (k) { | ||
utils.arrayLoop(selector.split(','), function (k) { | ||
var name = k.trim(); | ||
@@ -622,3 +606,3 @@ var type = 'block:selector'; | ||
{ | ||
if (key in shorthandProperties && aestheticUtils.isObject(value)) { | ||
if (key in shorthandProperties && utils.isObject(value)) { | ||
return shorthandProperties[key](value); | ||
@@ -666,3 +650,3 @@ } | ||
var enqueue = function () { | ||
var _ref7 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(cb) { | ||
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(cb) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -695,3 +679,3 @@ while (1) { | ||
return function enqueue(_x) { | ||
return _ref7.apply(this, arguments); | ||
return _ref.apply(this, arguments); | ||
}; | ||
@@ -808,3 +792,3 @@ }(); | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (!aestheticUtils.isObject(fontFaces)) { | ||
if (!utils.isObject(fontFaces)) { | ||
throw new Error('@font-face must be an object of font family names to font faces.'); | ||
@@ -814,6 +798,4 @@ } | ||
Object.entries(fontFaces).forEach(function (_ref) { | ||
var name = _ref[0], | ||
faces = _ref[1]; | ||
aestheticUtils.toArray(faces).forEach(function (fontFace) { | ||
utils.objectLoop(fontFaces, function (faces, name) { | ||
utils.arrayLoop(utils.toArray(faces), function (fontFace) { | ||
_this2.parseFontFace(name, fontFace); | ||
@@ -843,3 +825,3 @@ }); | ||
imports.forEach(function (value) { | ||
utils.arrayLoop(imports, function (value) { | ||
_this3.emit('import', formatImport(value)); | ||
@@ -857,3 +839,3 @@ }); | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (!aestheticUtils.isObject(keyframes)) { | ||
if (!utils.isObject(keyframes)) { | ||
throw new Error('@keyframes must be an object of animation names to keyframes.'); | ||
@@ -863,6 +845,3 @@ } | ||
Object.entries(keyframes).forEach(function (_ref2) { | ||
var name = _ref2[0], | ||
keyframe = _ref2[1]; | ||
utils.objectLoop(keyframes, function (keyframe, name) { | ||
_this4.parseKeyframesAnimation(name, keyframe); | ||
@@ -956,3 +935,3 @@ }); | ||
} | ||
} else if (aestheticUtils.isObject(declaration)) { | ||
} else if (utils.isObject(declaration)) { | ||
enqueue(function () { | ||
@@ -959,0 +938,0 @@ _this2.emit('ruleset', selector, _this2.parseLocalBlock(new Block(selector), declaration)); |
{ | ||
"name": "@aesthetic/sss", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A strict, type-safe, and structure-safe CSS-in-JS style sheet format.", | ||
@@ -28,6 +28,7 @@ "keywords": [ | ||
"dependencies": { | ||
"aesthetic-utils": "^3.0.0", | ||
"@aesthetic/utils": "^0.0.1", | ||
"csstype": "^2.6.8", | ||
"stylis": "^3.5.4" | ||
} | ||
}, | ||
"gitHead": "464508115172da900d3d14ea1a5b255c982649f8" | ||
} |
Sorry, the diff of this file is not supported yet
94513
1955
+ Added@aesthetic/utils@^0.0.1
+ Added@aesthetic/utils@0.0.1(transitive)
+ Addedstring-hash@1.1.3(transitive)
- Removedaesthetic-utils@^3.0.0
- Removedaesthetic-utils@3.1.0(transitive)