Izmjenjena struktura, dodan backand

This commit is contained in:
GotPPay
2017-10-16 11:19:46 +02:00
parent 1ec88afacb
commit 048e32c4aa
37153 changed files with 2975854 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function removeNextBr(parent, component) {
while (component != null && component.tagName.toLowerCase() !== 'br') {
component = component.nextElementSibling;
}
if (component != null) {
parent.removeChild(component);
}
}
function absolutifyCaret(component) {
var ccn = component.childNodes;
for (var index = 0; index < ccn.length; ++index) {
var c = ccn[index];
// $FlowFixMe
if (c.tagName.toLowerCase() !== 'span') {
continue;
}
var _text = c.innerText;
if (_text == null) {
continue;
}
var text = _text.replace(/\s/g, '');
if (text !== '|^') {
continue;
}
// $FlowFixMe
c.style.position = 'absolute';
// $FlowFixMe
removeNextBr(component, c);
}
}
export { absolutifyCaret };

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function consumeEvent(e) {
e.preventDefault();
if (typeof e.target.blur === 'function') {
e.target.blur();
}
}
export { consumeEvent };

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
var injectedCount = 0;
var injectedCache = {};
function getHead(document) {
return document.head || document.getElementsByTagName('head')[0];
}
function injectCss(document, css) {
var head = getHead(document);
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
head.appendChild(style);
injectedCache[++injectedCount] = style;
return injectedCount;
}
function removeCss(document, ref) {
if (injectedCache[ref] == null) {
return;
}
var head = getHead(document);
head.removeChild(injectedCache[ref]);
delete injectedCache[ref];
}
function applyStyles(element, styles) {
element.setAttribute('style', '');
for (var key in styles) {
if (!styles.hasOwnProperty(key)) {
continue;
}
// $FlowFixMe
element.style[key] = styles[key];
}
}
export { getHead, injectCss, removeCss, applyStyles };

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function enableTabClick(node) {
node.setAttribute('tabindex', '0');
node.addEventListener('keydown', function (e) {
var key = e.key,
which = e.which,
keyCode = e.keyCode;
if (key === 'Enter' || which === 13 || keyCode === 13) {
e.preventDefault();
if (typeof e.target.click === 'function') {
e.target.click();
}
}
});
}
export { enableTabClick };

View File

@@ -0,0 +1,65 @@
import { parse } from './parser'; /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { map } from './mapper';
import { unmap } from './unmapper';
var recorded = [];
var errorsConsumed = 0;
function consume(error) {
var unhandledRejection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var contextSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
var parsedFrames = parse(error);
var enhancedFramesPromise = void 0;
if (error.__unmap_source) {
enhancedFramesPromise = unmap(
// $FlowFixMe
error.__unmap_source, parsedFrames, contextSize);
} else {
enhancedFramesPromise = map(parsedFrames, contextSize);
}
return enhancedFramesPromise.then(function (enhancedFrames) {
if (enhancedFrames.map(function (f) {
return f._originalFileName;
}).filter(function (f) {
return f != null && f.indexOf('node_modules') === -1;
}).length === 0) {
return null;
}
enhancedFrames = enhancedFrames.filter(function (_ref) {
var functionName = _ref.functionName;
return functionName == null || functionName.indexOf('__stack_frame_overlay_proxy_console__') === -1;
});
recorded[++errorsConsumed] = {
error: error,
unhandledRejection: unhandledRejection,
contextSize: contextSize,
enhancedFrames: enhancedFrames
};
return errorsConsumed;
});
}
function getErrorRecord(ref) {
return recorded[ref];
}
function drain() {
// $FlowFixMe
var keys = Object.keys(recorded);
for (var index = 0; index < keys.length; ++index) {
delete recorded[keys[index]];
}
}
export { consume, getErrorRecord, drain };

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { ScriptLine } from './stack-frame';
/**
*
* @param {number} line The line number to provide context around.
* @param {number} count The number of lines you'd like for context.
* @param {string[] | string} lines The source code.
*/
function getLinesAround(line, count, lines) {
if (typeof lines === 'string') {
lines = lines.split('\n');
}
var result = [];
for (var index = Math.max(0, line - 1 - count); index <= Math.min(lines.length - 1, line - 1 + count); ++index) {
result.push(new ScriptLine(index + 1, lines[index], index === line - 1));
}
return result;
}
export { getLinesAround };
export default getLinesAround;

View File

@@ -0,0 +1,179 @@
import _regeneratorRuntime from 'babel-runtime/regenerator';
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; }; }();
/**
* Returns an instance of <code>{@link SourceMap}</code> for a given fileUri and fileContents.
* @param {string} fileUri The URI of the source file.
* @param {string} fileContents The contents of the source file.
*/
var getSourceMap = function () {
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(fileUri, fileContents) {
var sm, base64, match2, index, url, obj;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return extractSourceMapUrl(fileUri, fileContents);
case 2:
sm = _context.sent;
if (!(sm.indexOf('data:') === 0)) {
_context.next = 14;
break;
}
base64 = /^data:application\/json;([\w=:"-]+;)*base64,/;
match2 = sm.match(base64);
if (match2) {
_context.next = 8;
break;
}
throw new Error('Sorry, non-base64 inline source-map encoding is not supported.');
case 8:
sm = sm.substring(match2[0].length);
sm = window.atob(sm);
sm = JSON.parse(sm);
return _context.abrupt('return', new SourceMap(new SourceMapConsumer(sm)));
case 14:
index = fileUri.lastIndexOf('/');
url = fileUri.substring(0, index + 1) + sm;
_context.next = 18;
return fetch(url).then(function (res) {
return res.json();
});
case 18:
obj = _context.sent;
return _context.abrupt('return', new SourceMap(new SourceMapConsumer(obj)));
case 20:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function getSourceMap(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { SourceMapConsumer } from 'source-map';
/**
* A wrapped instance of a <code>{@link https://github.com/mozilla/source-map SourceMapConsumer}</code>.
*
* This exposes methods which will be indifferent to changes made in <code>{@link https://github.com/mozilla/source-map source-map}</code>.
*/
var SourceMap = function () {
function SourceMap(sourceMap) {
_classCallCheck(this, SourceMap);
this.__source_map = sourceMap;
}
/**
* Returns the original code position for a generated code position.
* @param {number} line The line of the generated code position.
* @param {number} column The column of the generated code position.
*/
_createClass(SourceMap, [{
key: 'getOriginalPosition',
value: function getOriginalPosition(line, column) {
var _source_map$original = this.__source_map.originalPositionFor({
line: line,
column: column
}),
l = _source_map$original.line,
c = _source_map$original.column,
s = _source_map$original.source;
return { line: l, column: c, source: s };
}
/**
* Returns the generated code position for an original position.
* @param {string} source The source file of the original code position.
* @param {number} line The line of the original code position.
* @param {number} column The column of the original code position.
*/
}, {
key: 'getGeneratedPosition',
value: function getGeneratedPosition(source, line, column) {
var _source_map$generate = this.__source_map.generatedPositionFor({
source: source,
line: line,
column: column
}),
l = _source_map$generate.line,
c = _source_map$generate.column;
return {
line: l,
column: c
};
}
/**
* Returns the code for a given source file name.
* @param {string} sourceName The name of the source file.
*/
}, {
key: 'getSource',
value: function getSource(sourceName) {
return this.__source_map.sourceContentFor(sourceName);
}
}, {
key: 'getSources',
value: function getSources() {
return this.__source_map.sources;
}
}]);
return SourceMap;
}();
function extractSourceMapUrl(fileUri, fileContents) {
var regex = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/gm;
var match = null;
for (;;) {
var next = regex.exec(fileContents);
if (next == null) {
break;
}
match = next;
}
if (!(match && match[1])) {
return Promise.reject('Cannot find a source map directive for ' + fileUri + '.');
}
return Promise.resolve(match[1].toString());
}
export { extractSourceMapUrl, getSourceMap };
export default getSourceMap;

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function isInternalFile(sourceFileName, fileName) {
return sourceFileName == null || sourceFileName === '' || sourceFileName.indexOf('/~/') !== -1 || sourceFileName.indexOf('/node_modules/') !== -1 || sourceFileName.trim().indexOf(' ') !== -1 || fileName == null || fileName === '';
}
export { isInternalFile };

View File

@@ -0,0 +1,122 @@
import _regeneratorRuntime from 'babel-runtime/regenerator';
/**
* Enhances a set of <code>StackFrame</code>s with their original positions and code (when available).
* @param {StackFrame[]} frames A set of <code>StackFrame</code>s which contain (generated) code positions.
* @param {number} [contextLines=3] The number of lines to provide before and after the line specified in the <code>StackFrame</code>.
*/
var map = function () {
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(frames) {
var _this = this;
var contextLines = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
var cache, files;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
cache = {};
files = [];
frames.forEach(function (frame) {
var fileName = frame.fileName;
if (fileName == null) {
return;
}
if (files.indexOf(fileName) !== -1) {
return;
}
files.push(fileName);
});
_context2.next = 5;
return settle(files.map(function () {
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(fileName) {
var fileSource, map;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return fetch(fileName).then(function (r) {
return r.text();
});
case 2:
fileSource = _context.sent;
_context.next = 5;
return getSourceMap(fileName, fileSource);
case 5:
map = _context.sent;
cache[fileName] = { fileSource: fileSource, map: map };
case 7:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}));
return function (_x3) {
return _ref2.apply(this, arguments);
};
}()));
case 5:
return _context2.abrupt('return', frames.map(function (frame) {
var functionName = frame.functionName,
fileName = frame.fileName,
lineNumber = frame.lineNumber,
columnNumber = frame.columnNumber;
var _ref3 = cache[fileName] || {},
map = _ref3.map,
fileSource = _ref3.fileSource;
if (map == null || lineNumber == null) {
return frame;
}
var _map$getOriginalPosit = map.getOriginalPosition(lineNumber, columnNumber),
source = _map$getOriginalPosit.source,
line = _map$getOriginalPosit.line,
column = _map$getOriginalPosit.column;
var originalSource = source == null ? [] : map.getSource(source);
return new StackFrame(functionName, fileName, lineNumber, columnNumber, getLinesAround(lineNumber, contextLines, fileSource), functionName, source, line, column, getLinesAround(line, contextLines, originalSource));
}));
case 6:
case 'end':
return _context2.stop();
}
}
}, _callee2, this);
}));
return function map(_x2) {
return _ref.apply(this, arguments);
};
}();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import StackFrame from './stack-frame';
import { getSourceMap } from './getSourceMap';
import { getLinesAround } from './getLinesAround';
import { settle } from 'settle-promise';
export { map };
export default map;

View File

@@ -0,0 +1,80 @@
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import StackFrame from './stack-frame';
var regexExtractLocation = /\(?(.+?)(?::(\d+))?(?::(\d+))?\)?$/;
function extractLocation(token) {
return regexExtractLocation.exec(token).slice(1).map(function (v) {
var p = Number(v);
if (!isNaN(p)) {
return p;
}
return v;
});
}
var regexValidFrame_Chrome = /^\s*(at|in)\s.+(:\d+)/;
var regexValidFrame_FireFox = /(^|@)\S+:\d+|.+line\s+\d+\s+>\s+(eval|Function).+/;
function parseStack(stack) {
var frames = stack.filter(function (e) {
return regexValidFrame_Chrome.test(e) || regexValidFrame_FireFox.test(e);
}).map(function (e) {
if (regexValidFrame_FireFox.test(e)) {
// Strip eval, we don't care about it
var isEval = false;
if (/ > (eval|Function)/.test(e)) {
e = e.replace(/ line (\d+)(?: > eval line \d+)* > (eval|Function):\d+:\d+/g, ':$1');
isEval = true;
}
var data = e.split(/[@]/g);
var last = data.pop();
return new (Function.prototype.bind.apply(StackFrame, [null].concat([data.join('@') || (isEval ? 'eval' : null)], _toConsumableArray(extractLocation(last)))))();
} else {
// Strip eval, we don't care about it
if (e.indexOf('(eval ') !== -1) {
e = e.replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
}
if (e.indexOf('(at ') !== -1) {
e = e.replace(/\(at /, '(');
}
var _data = e.trim().split(/\s+/g).slice(1);
var _last = _data.pop();
return new (Function.prototype.bind.apply(StackFrame, [null].concat([_data.join(' ') || null], _toConsumableArray(extractLocation(_last)))))();
}
});
return frames;
}
/**
* Turns an <code>Error</code>, or similar object, into a set of <code>StackFrame</code>s.
* @alias parse
*/
function parseError(error) {
if (error == null) {
throw new Error('You cannot pass a null object.');
}
if (typeof error === 'string') {
return parseStack(error.split('\n'));
}
if (Array.isArray(error)) {
return parseStack(error);
}
if (typeof error.stack === 'string') {
return parseStack(error.stack.split('\n'));
}
throw new Error('The error you provided does not contain a stack trace.');
}
export { parseError as parse };
export default parseError;

View File

@@ -0,0 +1,117 @@
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"); } }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/** A container holding a script line. */
var ScriptLine =
/** The content (or value) of this line of source. */
function ScriptLine(lineNumber, content) {
var highlight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
_classCallCheck(this, ScriptLine);
this.lineNumber = lineNumber;
this.content = content;
this.highlight = highlight;
}
/** Whether or not this line should be highlighted. Particularly useful for error reporting with context. */
/** The line number of this line of source. */
;
/**
* A representation of a stack frame.
*/
var StackFrame = function () {
function StackFrame() {
var functionName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var lineNumber = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var columnNumber = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var scriptCode = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var sourceFunctionName = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var sourceFileName = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
var sourceLineNumber = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
var sourceColumnNumber = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
var sourceScriptCode = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
_classCallCheck(this, StackFrame);
this.functionName = functionName;
this.fileName = fileName;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
this._originalFunctionName = sourceFunctionName;
this._originalFileName = sourceFileName;
this._originalLineNumber = sourceLineNumber;
this._originalColumnNumber = sourceColumnNumber;
this._scriptCode = scriptCode;
this._originalScriptCode = sourceScriptCode;
}
/**
* Returns the name of this function.
*/
_createClass(StackFrame, [{
key: 'getFunctionName',
value: function getFunctionName() {
return this.functionName;
}
/**
* Returns the source of the frame.
* This contains the file name, line number, and column number when available.
*/
}, {
key: 'getSource',
value: function getSource() {
var str = '';
if (this.fileName != null) {
str += this.fileName + ':';
}
if (this.lineNumber != null) {
str += this.lineNumber + ':';
}
if (this.columnNumber != null) {
str += this.columnNumber + ':';
}
return str.slice(0, -1);
}
/**
* Returns a pretty version of this stack frame.
*/
}, {
key: 'toString',
value: function toString() {
var f = this.getFunctionName();
if (f == null) {
return this.getSource();
}
return f + ' (' + this.getSource() + ')';
}
}]);
return StackFrame;
}();
export { StackFrame, ScriptLine };
export default StackFrame;

View File

@@ -0,0 +1,137 @@
import _regeneratorRuntime from 'babel-runtime/regenerator';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/**
* Turns a set of mapped <code>StackFrame</code>s back into their generated code position and enhances them with code.
* @param {string} fileUri The URI of the <code>bundle.js</code> file.
* @param {StackFrame[]} frames A set of <code>StackFrame</code>s which are already mapped and missing their generated positions.
* @param {number} [fileContents=3] The number of lines to provide before and after the line specified in the <code>StackFrame</code>.
*/
var unmap = function () {
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(_fileUri, frames) {
var contextLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
var fileContents, fileUri, map;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
fileContents = (typeof _fileUri === 'undefined' ? 'undefined' : _typeof(_fileUri)) === 'object' ? _fileUri.contents : null;
fileUri = (typeof _fileUri === 'undefined' ? 'undefined' : _typeof(_fileUri)) === 'object' ? _fileUri.uri : _fileUri;
if (!(fileContents == null)) {
_context.next = 6;
break;
}
_context.next = 5;
return fetch(fileUri).then(function (res) {
return res.text();
});
case 5:
fileContents = _context.sent;
case 6:
_context.next = 8;
return getSourceMap(fileUri, fileContents);
case 8:
map = _context.sent;
return _context.abrupt('return', frames.map(function (frame) {
var functionName = frame.functionName,
lineNumber = frame.lineNumber,
columnNumber = frame.columnNumber,
_originalLineNumber = frame._originalLineNumber;
if (_originalLineNumber != null) {
return frame;
}
var fileName = frame.fileName;
if (fileName) {
fileName = path.normalize(fileName);
}
if (fileName == null) {
return frame;
}
var fN = fileName;
var source = map.getSources().map(function (s) {
return s.replace(/[\\]+/g, '/');
}).filter(function (p) {
p = path.normalize(p);
var i = p.lastIndexOf(fN);
return i !== -1 && i === p.length - fN.length;
}).map(function (p) {
return {
token: p,
seps: count(path.sep, path.normalize(p)),
penalties: count('node_modules', p) + count('~', p)
};
}).sort(function (a, b) {
var s = Math.sign(a.seps - b.seps);
if (s !== 0) {
return s;
}
return Math.sign(a.penalties - b.penalties);
});
if (source.length < 1 || lineNumber == null) {
return new StackFrame(null, null, null, null, null, functionName, fN, lineNumber, columnNumber, null);
}
var sourceT = source[0].token;
var _map$getGeneratedPosi = map.getGeneratedPosition(sourceT, lineNumber,
// $FlowFixMe
columnNumber),
line = _map$getGeneratedPosi.line,
column = _map$getGeneratedPosi.column;
var originalSource = map.getSource(sourceT);
return new StackFrame(functionName, fileUri, line, column || null, getLinesAround(line, contextLines, fileContents || []), functionName, fN, lineNumber, columnNumber, getLinesAround(lineNumber, contextLines, originalSource));
}));
case 10:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function unmap(_x2, _x3) {
return _ref.apply(this, arguments);
};
}();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import StackFrame from './stack-frame';
import { getSourceMap } from './getSourceMap';
import { getLinesAround } from './getLinesAround';
import path from 'path';
function count(search, string) {
// Count starts at -1 becuse a do-while loop always runs at least once
var count = -1,
index = -1;
do {
// First call or the while case evaluated true, meaning we have to make
// count 0 or we found a character
++count;
// Find the index of our search string, starting after the previous index
index = string.indexOf(search, index + 1);
} while (index !== -1);
return count;
}
export { unmap };
export default unmap;

View File

@@ -0,0 +1,48 @@
function stripInlineStacktrace(message) {
return message.split('\n').filter(function (line) {
return !line.match(/^\s*in/);
}).join('\n'); // " in Foo"
} /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function massage(warning, frames) {
var message = stripInlineStacktrace(warning);
// Reassemble the stack with full filenames provided by React
var stack = '';
var lastFilename = void 0;
var lastLineNumber = void 0;
for (var index = 0; index < frames.length; ++index) {
var _frames$index = frames[index],
fileName = _frames$index.fileName,
lineNumber = _frames$index.lineNumber;
if (fileName == null || lineNumber == null) {
continue;
}
// TODO: instead, collapse them in the UI
if (fileName === lastFilename && typeof lineNumber === 'number' && typeof lastLineNumber === 'number' && Math.abs(lineNumber - lastLineNumber) < 3) {
continue;
}
lastFilename = fileName;
lastLineNumber = lineNumber;
var name = frames[index].name;
name = name || '(anonymous function)';
stack += 'in ' + name + ' (at ' + fileName + ':' + lineNumber + ')\n';
}
return { message: message, stack: stack };
}
export { massage };