Permalink
Browse files

Add babel dependencies, moved _mixins consant and css rules ref, firs…

…t dist build
  • Loading branch information...
1 parent 9a6ac90 commit 24cc950ad4f6ed84d848a4f24ceb12524cb54db1 @JonHMChan committed Feb 2, 2016
Showing 36,864 changed files with 1,736,728 additions and 5 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
View
@@ -0,0 +1,3 @@
+{
+ "presets": ["es2015"]
+}
View
@@ -0,0 +1,187 @@
+'use strict';
+
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
+
+var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Descartes = function () {
+ function Descartes(tree) {
+ _classCallCheck(this, Descartes);
+
+ this.tree = tree;
+ this.selector = 'selector';
+ this.rule = 'rule';
+ this.meta = 'meta';
+ this.mixins = '_mixins';
+ this.mappings = {};
+ this.rules = ['align-content', 'align-items', 'align-self', 'all', 'animation', 'animation-delay', 'animation-direction', 'animation-duration', 'animation-fill-mode', 'animation-iteration-count', 'animation-name', 'animation-play-state', 'animation-timing-function', 'backface-visibility', 'background', 'background-attachment', 'background-blend-mode', 'background-clip', 'background-color', 'background-image', 'background-origin', 'background-position', 'background-repeat', 'background-size', 'border', 'border-bottom', 'border-bottom-color', 'border-bottom-left-radius', 'border-bottom-right-radius', 'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-image', 'border-image-outset', 'border-image-repeat', 'border-image-slice', 'border-image-source', 'border-image-width', 'border-left', 'border-left-color', 'border-left-style', 'border-left-width', 'border-radius', 'border-right', 'border-right-color', 'border-right-style', 'border-right-width', 'border-spacing', 'border-style', 'border-top', 'border-top-color', 'border-top-left-radius', 'border-top-right-radius', 'border-top-style', 'border-top-width', 'border-width', 'bottom', 'box-shadow', 'box-sizing', 'caption-side', 'clear', 'clip', 'color', 'column-count', 'column-fill', 'column-gap', 'column-rule', 'column-rule-color', 'column-rule-style', 'column-rule-width', 'column-span', 'column-width', 'columns', 'content', 'counter-increment', 'counter-reset', 'cursor', 'direction', 'display', 'empty-cells', 'filter', 'flex', 'flex-basis', 'flex-direction', 'flex-flow', 'flex-grow', 'flex-shrink', 'flex-wrap', 'float', 'font', '@font-face', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'hanging-punctuation', 'height', 'justify-content', '@keyframes', 'left', 'letter-spacing', 'line-height', 'list-style', 'list-style-image', 'list-style-position', 'list-style-type', 'margin', 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'max-height', 'max-width', '@media', 'min-height', 'min-width', 'nav-down', 'nav-index', 'nav-left', 'nav-right', 'nav-up', 'opacity', 'order', 'outline', 'outline-color', 'outline-offset', 'outline-style', 'outline-width', 'overflow', 'overflow-x', 'overflow-y', 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'page-break-after', 'page-break-before', 'page-break-inside', 'perspective', 'perspective-origin', 'position', 'quotes', 'resize', 'right', 'tab-size', 'table-layout', 'text-align', 'text-align-last', 'text-decoration', 'text-decoration-color', 'text-decoration-line', 'text-decoration-style', 'text-indent', 'text-justify', 'text-overflow', 'text-shadow', 'text-transform', 'top', 'transform', 'transform-origin', 'transform-style', 'transition', 'transition-delay', 'transition-duration', 'transition-property', 'transition-timing-function', 'unicode-bidi', 'vertical-align', 'visibility', 'white-space', 'width', 'word-break', 'word-spacing', 'word-wrap', 'z-index'];
+ }
+
+ // Returns the computed rules tree based on original tree
+
+ _createClass(Descartes, [{
+ key: 'compute',
+ value: function compute() {
+ var tree = arguments.length <= 0 || arguments[0] === undefined ? this.tree : arguments[0];
+
+ if ((typeof tree === 'undefined' ? 'undefined' : _typeof(tree)) === 'object') {
+ var result = {};
+ for (var key in tree) {
+ var val = tree[key];
+ var keyObject = this.parseKey(key);
+ if (keyObject.type === this.selector) {
+ result[keyObject.key] = this.parseMixins(this.compute(val), key);
+ } else if (keyObject.type === this.rule) {
+ return tree;
+ }
+ }
+ return result;
+ }
+ return null;
+ }
+
+ // Expands the computed rules tree into a flat rule mappings object
+
+ }, {
+ key: 'flatten',
+ value: function flatten() {
+ var tree = arguments.length <= 0 || arguments[0] === undefined ? this.compute(tree) : arguments[0];
+ var parentSelector = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
+
+ for (var selector in tree) {
+ var rules = Object.assign({}, tree[selector]);
+
+ // Add the rules in here
+ for (var rule in rules) {
+ if (!this.isRule(rule)) {
+ var subtree = null;
+ if (parentSelector === "") parentSelector = selector;
+ var nestedSelector = this.nestSelector(rule, parentSelector);
+ if (!this.isMeta(rule) && !this.isRule(rule)) {
+ subtree = {};
+ subtree[nestedSelector] = rules[rule];
+ }
+ delete rules[rule];
+ if (subtree !== null) {
+ this.flatten(subtree, nestedSelector);
+ }
+ }
+ }
+ this.mappings[selector] = rules;
+ }
+ return this.mappings;
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ this.flatten();
+ console.log(this.mappings);
+ this.applyAll();
+ }
+ }, {
+ key: 'applyAll',
+ value: function applyAll() {
+ for (var key in this.mappings) {
+ this.apply(key, this.mappings[key]);
+ }
+ }
+ }, {
+ key: 'apply',
+ value: function apply() {
+ var selector = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
+ var rule = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
+
+ if (selector === null || rule === null) return;
+ var elems = Sizzle(selector);
+ var style = "";
+ for (var key in rule) {
+ var computedRule = this.computeRule(rule[key]);
+ style += key + ": " + computedRule + "; ";
+ }
+ style = style.slice(0, -1);
+ elems.map(function (elem) {
+ elem.setAttribute('style', style);
+ });
+ }
+ }, {
+ key: 'computeRule',
+ value: function computeRule(rule) {
+ if (typeof rule === 'function') {
+ rule = rule();
+ }
+ if (Number(rule) === rule && rule % 1 === 0) {
+ return rule.toString() + "px";
+ }
+ return rule.toString();
+ }
+ }, {
+ key: 'nestSelector',
+ value: function nestSelector(current, parent) {
+ var separator = " ";
+ if (this.selIsAppending(current)) {
+ separator = "";
+ current = current.substring(1);
+ }
+ return parent + separator + current;
+ }
+
+ // Runs any checks on the current key to see what type it is
+
+ }, {
+ key: 'parseKey',
+ value: function parseKey(key) {
+ var isMeta = this.isMeta(key);
+ var isRule = this.isRule(key);
+ return {
+ key: key,
+ type: isMeta ? this.meta : isRule ? this.rule : this.selector
+ };
+ }
+
+ // Adds mixins to existing rules
+
+ }, {
+ key: 'parseMixins',
+ value: function parseMixins(rules, key) {
+ var mixins = rules[this.mixins];
+
+ if (!Array.isArray(mixins)) {
+ mixins = [mixins];
+ }
+
+ for (var index in mixins) {
+ var mixin = mixins[index];
+ if (mixin !== null && (typeof mixin === 'undefined' ? 'undefined' : _typeof(mixin)) === 'object') {
+ for (var rule in mixin) {
+ if (!rules.hasOwnProperty(rule) || rules[rule] === null) rules[rule] = mixin[rule];
+ }
+ } else {
+ console.log(mixin);
+ throw "'" + key + "' has an invalid _mixins value. _mixins can only be an object literal or array of object literals.";
+ }
+ }
+ delete rules[this.mixins];
+ return rules;
+ }
+ }, {
+ key: 'isMeta',
+ value: function isMeta(key) {
+ var metas = [this.mixins];
+ return metas.indexOf(key) > -1;
+ }
+ }, {
+ key: 'selIsAppending',
+ value: function selIsAppending(sel) {
+ return sel.substr(0, 1) === '&';
+ }
+ }, {
+ key: 'isRule',
+ value: function isRule(key) {
+ return this.rules.indexOf(key) > -1;
+ }
+ }]);
+
+ return Descartes;
+}();
@@ -0,0 +1,3 @@
+src
+test
+node_modules
@@ -0,0 +1,35 @@
+# babel-preset-es2015
+
+> Babel preset for all es2015 plugins.
+
+## Install
+
+```sh
+$ npm install --save-dev babel-preset-es2015
+```
+
+## Usage
+
+### Via `.babelrc` (Recommended)
+
+**.babelrc**
+
+```json
+{
+ "presets": ["es2015"]
+}
+```
+
+### Via CLI
+
+```sh
+$ babel script.js --presets es2015
+```
+
+### Via Node API
+
+```javascript
+require("babel-core").transform("code", {
+ presets: ["es2015"]
+});
+```
@@ -0,0 +1,24 @@
+module.exports = {
+ plugins: [
+ require("babel-plugin-transform-es2015-template-literals"),
+ require("babel-plugin-transform-es2015-literals"),
+ require("babel-plugin-transform-es2015-function-name"),
+ require("babel-plugin-transform-es2015-arrow-functions"),
+ require("babel-plugin-transform-es2015-block-scoped-functions"),
+ require("babel-plugin-transform-es2015-classes"),
+ require("babel-plugin-transform-es2015-object-super"),
+ require("babel-plugin-transform-es2015-shorthand-properties"),
+ require("babel-plugin-transform-es2015-computed-properties"),
+ require("babel-plugin-transform-es2015-for-of"),
+ require("babel-plugin-transform-es2015-sticky-regex"),
+ require("babel-plugin-transform-es2015-unicode-regex"),
+ require("babel-plugin-check-es2015-constants"),
+ require("babel-plugin-transform-es2015-spread"),
+ require("babel-plugin-transform-es2015-parameters"),
+ require("babel-plugin-transform-es2015-destructuring"),
+ require("babel-plugin-transform-es2015-block-scoping"),
+ require("babel-plugin-transform-es2015-typeof-symbol"),
+ require("babel-plugin-transform-es2015-modules-commonjs"),
+ [require("babel-plugin-transform-regenerator"), { async: false, asyncGenerators: false }],
+ ]
+};
@@ -0,0 +1,4 @@
+node_modules
+*.log
+src
+test
@@ -0,0 +1,39 @@
+# babel-plugin-check-es2015-constants
+
+Validate ES2015 constants
+
+## Installation
+
+```sh
+$ npm install babel-plugin-check-es2015-constants
+```
+
+## Usage
+
+### Via `.babelrc` (Recommended)
+
+**.babelrc**
+
+```json
+{
+ "plugins": ["check-es2015-constants"]
+}
+```
+
+### Via CLI
+
+```sh
+$ babel --plugins check-es2015-constants script.js
+```
+
+### Via Node API
+
+```javascript
+require("babel-core").transform("code", {
+ plugins: ["check-es2015-constants"]
+});
+```
+
+## Note
+
+This check will only validate consts. If you need it to compile down to `var` then you must also install and enable [`transform-es2015-block-scoping`](../babel-plugin-transform-es2015-block-scoping).
@@ -0,0 +1,41 @@
+"use strict";
+
+var _getIterator = require("babel-runtime/core-js/get-iterator")["default"];
+
+exports.__esModule = true;
+
+exports["default"] = function (_ref2) {
+ var messages = _ref2.messages;
+
+ return {
+ visitor: {
+ Scope: function Scope(_ref3) {
+ var scope = _ref3.scope;
+
+ for (var _name in scope.bindings) {
+ var binding = scope.bindings[_name];
+ if (binding.kind !== "const" && binding.kind !== "module") continue;
+
+ for (var _iterator = (binding.constantViolations /*: Array*/), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _getIterator(_iterator);;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ var violation = _ref;
+
+ throw violation.buildCodeFrameError(messages.get("readOnly", _name));
+ }
+ }
+ }
+ }
+ };
+};
+
+module.exports = exports["default"];
@@ -0,0 +1,2 @@
+scripts
+node_modules
@@ -0,0 +1,5 @@
+# babel-runtime
+
+Babel self-contained runtime
+
+For more information please look at [babel](https://github.com/babel/babel).
@@ -0,0 +1,4 @@
+module.exports = {
+ "default": require("core-js/library"),
+ __esModule: true
+};
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/concat"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/copy-within"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/entries"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/every"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/fill"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/filter"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/find-index"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/find"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/for-each"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/includes"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/index-of"), __esModule: true };
@@ -0,0 +1 @@
+module.exports = { "default": require("core-js/library/fn/array/join"), __esModule: true };
Oops, something went wrong.

0 comments on commit 24cc950

Please sign in to comment.