BVB Source Codes

reactide Show index.js Source code

Return Download reactide: download index.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4.  
  5. exports.default = function (_ref) {
  6.   var t = _ref.types;
  7.  
  8.   function makeTrace(fileNameIdentifier, lineNumber) {
  9.     var fileLineLiteral = lineNumber != null ? t.numericLiteral(lineNumber) : t.nullLiteral();
  10.     var fileNameProperty = t.objectProperty(t.identifier("fileName"), fileNameIdentifier);
  11.     var lineNumberProperty = t.objectProperty(t.identifier("lineNumber"), fileLineLiteral);
  12.     return t.objectExpression([fileNameProperty, lineNumberProperty]);
  13.   }
  14.  
  15.   var visitor = {
  16.     JSXOpeningElement: function JSXOpeningElement(path, state) {
  17.       var id = t.jSXIdentifier(TRACE_ID);
  18.       var location = path.container.openingElement.loc;
  19.       if (!location) {
  20.         return;
  21.       }
  22.  
  23.       var attributes = path.container.openingElement.attributes;
  24.       for (var i = 0; i < attributes.length; i++) {
  25.         var name = attributes[i].name;
  26.         if (name && name.name === TRACE_ID) {
  27.           return;
  28.         }
  29.       }
  30.  
  31.       if (!state.fileNameIdentifier) {
  32.         var fileName = state.file.log.filename !== "unknown" ? state.file.log.filename : null;
  33.  
  34.         var fileNameIdentifier = path.scope.generateUidIdentifier(FILE_NAME_VAR);
  35.         path.hub.file.scope.push({ id: fileNameIdentifier, init: t.stringLiteral(fileName) });
  36.         state.fileNameIdentifier = fileNameIdentifier;
  37.       }
  38.  
  39.       var trace = makeTrace(state.fileNameIdentifier, location.start.line);
  40.       attributes.push(t.jSXAttribute(id, t.jSXExpressionContainer(trace)));
  41.     }
  42.   };
  43.  
  44.   return {
  45.     visitor: visitor
  46.   };
  47. };
  48.  
  49. var TRACE_ID = "__source";
  50. var FILE_NAME_VAR = "_jsxFileName";
  51.  
  52. module.exports = exports["default"];
downloadindex.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