BVB Source Codes

reactide Show plugin.js Source code

Return Download reactide: download plugin.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4.  
  5. var _getIterator2 = require("babel-runtime/core-js/get-iterator");
  6.  
  7. var _getIterator3 = _interopRequireDefault(_getIterator2);
  8.  
  9. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  10.  
  11. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  12.  
  13. var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
  14.  
  15. var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  16.  
  17. var _inherits2 = require("babel-runtime/helpers/inherits");
  18.  
  19. var _inherits3 = _interopRequireDefault(_inherits2);
  20.  
  21. var _optionManager = require("./file/options/option-manager");
  22.  
  23. var _optionManager2 = _interopRequireDefault(_optionManager);
  24.  
  25. var _babelMessages = require("babel-messages");
  26.  
  27. var messages = _interopRequireWildcard(_babelMessages);
  28.  
  29. var _store = require("../store");
  30.  
  31. var _store2 = _interopRequireDefault(_store);
  32.  
  33. var _babelTraverse = require("babel-traverse");
  34.  
  35. var _babelTraverse2 = _interopRequireDefault(_babelTraverse);
  36.  
  37. var _assign = require("lodash/assign");
  38.  
  39. var _assign2 = _interopRequireDefault(_assign);
  40.  
  41. var _clone = require("lodash/clone");
  42.  
  43. var _clone2 = _interopRequireDefault(_clone);
  44.  
  45. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  46.  
  47. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  48.  
  49. /* eslint max-len: 0 */
  50.  
  51. var GLOBAL_VISITOR_PROPS = ["enter", "exit"];
  52.  
  53. var Plugin = function (_Store) {
  54.   (0, _inherits3.default)(Plugin, _Store);
  55.  
  56.   function Plugin(plugin, key) {
  57.     (0, _classCallCheck3.default)(this, Plugin);
  58.  
  59.     var _this = (0, _possibleConstructorReturn3.default)(this, _Store.call(this));
  60.  
  61.     _this.initialized = false;
  62.     _this.raw = (0, _assign2.default)({}, plugin);
  63.     _this.key = key;
  64.  
  65.     _this.manipulateOptions = _this.take("manipulateOptions");
  66.     _this.post = _this.take("post");
  67.     _this.pre = _this.take("pre");
  68.     _this.visitor = _this.normaliseVisitor((0, _clone2.default)(_this.take("visitor")) || {});
  69.     return _this;
  70.   }
  71.  
  72.   Plugin.prototype.take = function take(key) {
  73.     var val = this.raw[key];
  74.     delete this.raw[key];
  75.     return val;
  76.   };
  77.  
  78.   Plugin.prototype.chain = function chain(target, key) {
  79.     if (!target[key]) return this[key];
  80.     if (!this[key]) return target[key];
  81.  
  82.     var fns = [target[key], this[key]];
  83.  
  84.     return function () {
  85.       var val = void 0;
  86.  
  87.       for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  88.         args[_key] = arguments[_key];
  89.       }
  90.  
  91.       for (var _iterator = fns, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
  92.         var _ref;
  93.  
  94.         if (_isArray) {
  95.           if (_i >= _iterator.length) break;
  96.           _ref = _iterator[_i++];
  97.         } else {
  98.           _i = _iterator.next();
  99.           if (_i.done) break;
  100.           _ref = _i.value;
  101.         }
  102.  
  103.         var fn = _ref;
  104.  
  105.         if (fn) {
  106.           var ret = fn.apply(this, args);
  107.           if (ret != null) val = ret;
  108.         }
  109.       }
  110.       return val;
  111.     };
  112.   };
  113.  
  114.   Plugin.prototype.maybeInherit = function maybeInherit(loc) {
  115.     var inherits = this.take("inherits");
  116.     if (!inherits) return;
  117.  
  118.     inherits = _optionManager2.default.normalisePlugin(inherits, loc, "inherits");
  119.  
  120.     this.manipulateOptions = this.chain(inherits, "manipulateOptions");
  121.     this.post = this.chain(inherits, "post");
  122.     this.pre = this.chain(inherits, "pre");
  123.     this.visitor = _babelTraverse2.default.visitors.merge([inherits.visitor, this.visitor]);
  124.   };
  125.  
  126.   /**
  127.    * We lazy initialise parts of a plugin that rely on contextual information such as
  128.    * position on disk and how it was specified.
  129.    */
  130.  
  131.   Plugin.prototype.init = function init(loc, i) {
  132.     if (this.initialized) return;
  133.     this.initialized = true;
  134.  
  135.     this.maybeInherit(loc);
  136.  
  137.     for (var key in this.raw) {
  138.       throw new Error(messages.get("pluginInvalidProperty", loc, i, key));
  139.     }
  140.   };
  141.  
  142.   Plugin.prototype.normaliseVisitor = function normaliseVisitor(visitor) {
  143.     for (var _iterator2 = GLOBAL_VISITOR_PROPS, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
  144.       var _ref2;
  145.  
  146.       if (_isArray2) {
  147.         if (_i2 >= _iterator2.length) break;
  148.         _ref2 = _iterator2[_i2++];
  149.       } else {
  150.         _i2 = _iterator2.next();
  151.         if (_i2.done) break;
  152.         _ref2 = _i2.value;
  153.       }
  154.  
  155.       var key = _ref2;
  156.  
  157.       if (visitor[key]) {
  158.         throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. Please target individual nodes.");
  159.       }
  160.     }
  161.  
  162.     _babelTraverse2.default.explode(visitor);
  163.     return visitor;
  164.   };
  165.  
  166.   return Plugin;
  167. }(_store2.default);
  168.  
  169. exports.default = Plugin;
  170. module.exports = exports["default"];
downloadplugin.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top