BVB Source Codes

reactide Show metadata.js Source code

Return Download reactide: download metadata.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4. exports.ImportDeclaration = exports.ModuleDeclaration = undefined;
  5.  
  6. var _getIterator2 = require("babel-runtime/core-js/get-iterator");
  7.  
  8. var _getIterator3 = _interopRequireDefault(_getIterator2);
  9.  
  10. exports.ExportDeclaration = ExportDeclaration;
  11. exports.Scope = Scope;
  12.  
  13. var _babelTypes = require("babel-types");
  14.  
  15. var t = _interopRequireWildcard(_babelTypes);
  16.  
  17. 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; } }
  18.  
  19. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20.  
  21. var ModuleDeclaration = exports.ModuleDeclaration = {
  22.   enter: function enter(path, file) {
  23.     var node = path.node;
  24.  
  25.     if (node.source) {
  26.       node.source.value = file.resolveModuleSource(node.source.value);
  27.     }
  28.   }
  29. };
  30.  
  31. var ImportDeclaration = exports.ImportDeclaration = {
  32.   exit: function exit(path, file) {
  33.     var node = path.node;
  34.  
  35.  
  36.     var specifiers = [];
  37.     var imported = [];
  38.     file.metadata.modules.imports.push({
  39.       source: node.source.value,
  40.       imported: imported,
  41.       specifiers: specifiers
  42.     });
  43.  
  44.     for (var _iterator = path.get("specifiers"), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
  45.       var _ref;
  46.  
  47.       if (_isArray) {
  48.         if (_i >= _iterator.length) break;
  49.         _ref = _iterator[_i++];
  50.       } else {
  51.         _i = _iterator.next();
  52.         if (_i.done) break;
  53.         _ref = _i.value;
  54.       }
  55.  
  56.       var specifier = _ref;
  57.  
  58.       var local = specifier.node.local.name;
  59.  
  60.       if (specifier.isImportDefaultSpecifier()) {
  61.         imported.push("default");
  62.         specifiers.push({
  63.           kind: "named",
  64.           imported: "default",
  65.           local: local
  66.         });
  67.       }
  68.  
  69.       if (specifier.isImportSpecifier()) {
  70.         var importedName = specifier.node.imported.name;
  71.         imported.push(importedName);
  72.         specifiers.push({
  73.           kind: "named",
  74.           imported: importedName,
  75.           local: local
  76.         });
  77.       }
  78.  
  79.       if (specifier.isImportNamespaceSpecifier()) {
  80.         imported.push("*");
  81.         specifiers.push({
  82.           kind: "namespace",
  83.           local: local
  84.         });
  85.       }
  86.     }
  87.   }
  88. };
  89.  
  90. function ExportDeclaration(path, file) {
  91.   var node = path.node;
  92.  
  93.  
  94.   var source = node.source ? node.source.value : null;
  95.   var exports = file.metadata.modules.exports;
  96.  
  97.   // export function foo() {}
  98.   // export let foo = "bar";
  99.   var declar = path.get("declaration");
  100.   if (declar.isStatement()) {
  101.     var bindings = declar.getBindingIdentifiers();
  102.  
  103.     for (var name in bindings) {
  104.       exports.exported.push(name);
  105.       exports.specifiers.push({
  106.         kind: "local",
  107.         local: name,
  108.         exported: path.isExportDefaultDeclaration() ? "default" : name
  109.       });
  110.     }
  111.   }
  112.  
  113.   if (path.isExportNamedDeclaration() && node.specifiers) {
  114.     for (var _iterator2 = node.specifiers, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
  115.       var _ref2;
  116.  
  117.       if (_isArray2) {
  118.         if (_i2 >= _iterator2.length) break;
  119.         _ref2 = _iterator2[_i2++];
  120.       } else {
  121.         _i2 = _iterator2.next();
  122.         if (_i2.done) break;
  123.         _ref2 = _i2.value;
  124.       }
  125.  
  126.       var specifier = _ref2;
  127.  
  128.       var exported = specifier.exported.name;
  129.       exports.exported.push(exported);
  130.  
  131.       // export foo from "bar";
  132.       if (t.isExportDefaultSpecifier(specifier)) {
  133.         exports.specifiers.push({
  134.           kind: "external",
  135.           local: exported,
  136.           exported: exported,
  137.           source: source
  138.         });
  139.       }
  140.  
  141.       // export * as foo from "bar";
  142.       if (t.isExportNamespaceSpecifier(specifier)) {
  143.         exports.specifiers.push({
  144.           kind: "external-namespace",
  145.           exported: exported,
  146.           source: source
  147.         });
  148.       }
  149.  
  150.       var local = specifier.local;
  151.       if (!local) continue;
  152.  
  153.       // export { foo } from "bar";
  154.       // export { foo as bar } from "bar";
  155.       if (source) {
  156.         exports.specifiers.push({
  157.           kind: "external",
  158.           local: local.name,
  159.           exported: exported,
  160.           source: source
  161.         });
  162.       }
  163.  
  164.       // export { foo };
  165.       // export { foo as bar };
  166.       if (!source) {
  167.         exports.specifiers.push({
  168.           kind: "local",
  169.           local: local.name,
  170.           exported: exported
  171.         });
  172.       }
  173.     }
  174.   }
  175.  
  176.   // export * from "bar";
  177.   if (path.isExportAllDeclaration()) {
  178.     exports.specifiers.push({
  179.       kind: "external-all",
  180.       source: source
  181.     });
  182.   }
  183. }
  184.  
  185. function Scope(path) {
  186.   path.skip();
  187. }
downloadmetadata.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