init
This commit is contained in:
97
node_modules/stacktrace-js/CHANGELOG.md
generated
vendored
Normal file
97
node_modules/stacktrace-js/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
## v2.0.0
|
||||
|
||||
### ES6 Support
|
||||
|
||||
ES6 code is now parsed and enhanced!
|
||||
|
||||
### Extensible StackFrames
|
||||
|
||||
StackFrames returned are now able to report on whether a function call was a `Constructor`, `native` code, or `eval` code.
|
||||
|
||||
### MIT License
|
||||
|
||||
The community [has voted](https://github.com/stacktracejs/stacktrace.js/issues/187) to change the license of the project to the [MIT License](https://opensource.org/licenses/MIT)
|
||||
|
||||
## v1.3.0
|
||||
* `Stacktrace.getSync()` gets a stack trace, synchronously. It does not attempt to map sources or guess function names, because those typically require network requests.
|
||||
|
||||
## v1.2.0
|
||||
|
||||
* `StackTrace.report` now accepts an error message argument, and will add a `message: "given thing"` to the JSON payload if it is provided.
|
||||
* Various bug fixes from v1.1.0
|
||||
|
||||
## v1.1.0
|
||||
|
||||
### Better parsing
|
||||
Updated [error-stack-parser](https://github.com/stacktracejs/error-stack-parser) to v1.3 which parses eval stack entries in a better way and fixes a bunch of bugs.
|
||||
|
||||
### Better resource handling
|
||||
Updated [stacktrace-gps](https://github.com/stacktracejs/stacktrace-gps). Now reuses the same instance to avoid duplicate requests for the same resource by default.
|
||||
|
||||
### Better dev experience
|
||||
JSCS and automated PR testing have been implemented to ensure consistent styles and quick feedback.
|
||||
|
||||
> Possibly breaking changes: ErrorStackParser now provides it's own polyfill for `Array.map` and `Array.filter`. `eval` information is will display differently in stack traces.
|
||||
|
||||
## v1.0.0
|
||||
|
||||
### stacktrace.js is reborn
|
||||
|
||||
stacktrace.js is now modularized into 5 projects:
|
||||
|
||||
* [stacktrace-gps](https://github.com/stacktracejs/stacktrace-gps) - turn partial code location into precise code location
|
||||
* [error-stack-parser](https://github.com/stacktracejs/error-stack-parser) - extract meaning from JS Errors
|
||||
* [stack-generator](https://github.com/stacktracejs/stack-generator) - generate artificial backtrace in old browsers
|
||||
* [stackframe](https://github.com/stacktracejs/stackframe) - JS Object representation of a stack frame
|
||||
|
||||
... and putting it all together: [stacktrace.js](stacktracejs/stacktrace.js) for instrumenting your code and generating stack traces!
|
||||
|
||||
### Key Features
|
||||
|
||||
* Fully asynchronous API, using [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Use your own polyfill or use [our distribution with polyfills included](https://github.com/stacktracejs/stacktrace.js/blob/master/dist/stacktrace-with-polyfills.min.js). See the [Migration Guide](http://www.stacktracejs.com/docs/v0-migration-guide)
|
||||
* [Source Maps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/) support
|
||||
* Forward-compatible: stacktrace.js no longer assumes a given browser formats Error stacks in a given way. This prevents new browser versions from breaking error parsing
|
||||
* Stack entries are now fully parsed and returned as [StackFrame objects](https://github.com/stacktracejs/stackframe). Prefer the old format? - just call `.toString()`!
|
||||
* Use only what you need. All 5 projects work independently as well as together!
|
||||
* iOS 8+ Safari support
|
||||
|
||||
### Available everywhere
|
||||
|
||||
```
|
||||
npm install stacktrace-js
|
||||
bower install stacktrace-js
|
||||
component install stacktracejs/stacktrace.js
|
||||
https://cdnjs.cloudflare.com/ajax/libs/stacktrace.js/1.0.0/stacktrace.min.js
|
||||
```
|
||||
|
||||
### Better for contributors
|
||||
|
||||
* gulp build
|
||||
* TravisCI + Sauce for testing a bunch of browsers
|
||||
* EditorConfig for style adherence
|
||||
|
||||
## v0.6.2
|
||||
|
||||
* Ignore test/ dir in bower
|
||||
* Migrate references eriwen/javascript-stacktrace -> stacktracejs/stacktrace.js
|
||||
|
||||
## v0.6.1
|
||||
|
||||
* Fix printStackTrace throws exception with "use strict" code and PhantomJS
|
||||
|
||||
## v0.6.0
|
||||
|
||||
* Added AMD support using a UMD pattern (thanks @jeffrose)
|
||||
|
||||
## v0.5.3
|
||||
|
||||
* Fix Chrome 27 detection; Chrome no longer has Error#arguments
|
||||
|
||||
## v0.5.1
|
||||
|
||||
* Fix Bower integration; Added proper bower.json file
|
||||
|
||||
## v0.5.0
|
||||
|
||||
* Lots and lots of stuff
|
||||
|
19
node_modules/stacktrace-js/LICENSE
generated
vendored
Normal file
19
node_modules/stacktrace-js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2017 Eric Wendelin and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
186
node_modules/stacktrace-js/README.md
generated
vendored
Normal file
186
node_modules/stacktrace-js/README.md
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
# stacktrace.js
|
||||
Generate, parse and enhance JavaScript stack traces in all browsers
|
||||
|
||||
[](https://travis-ci.org/stacktracejs/stacktrace.js)
|
||||
[](https://coveralls.io/r/stacktracejs/stacktrace.js?branch=master)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://cdnjs.com/libraries/stacktrace.js)
|
||||
[](https://github.com/stacktracejs/stacktrace.js/releases)
|
||||
[](https://github.com/stacktracejs/stacktrace.js/releases)
|
||||
[](https://github.com/stacktracejs/stacktrace.js/releases)
|
||||
|
||||
Debug and profile your JavaScript with a [stack trace](http://en.wikipedia.org/wiki/Stack_trace) of function calls leading to an error (or any condition you specify).
|
||||
|
||||
stacktrace.js uses browsers' `Error.stack` mechanism to generate stack traces, parses them, enhances them with
|
||||
[source maps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/) and uses
|
||||
[Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
||||
to return an Array of [StackFrames](https://github.com/stacktracejs/stackframe).
|
||||
|
||||
#### Upgrading? Check the [0.x -> 1.x Migration Guide](https://www.stacktracejs.com/#!/docs/v0-migration-guide)
|
||||
|
||||
## Usage
|
||||
#### Get a stack trace from current location
|
||||
```js
|
||||
var callback = function(stackframes) {
|
||||
var stringifiedStack = stackframes.map(function(sf) {
|
||||
return sf.toString();
|
||||
}).join('\n');
|
||||
console.log(stringifiedStack);
|
||||
};
|
||||
|
||||
var errback = function(err) { console.log(err.message); };
|
||||
|
||||
StackTrace.get().then(callback).catch(errback);
|
||||
//===> Promise(Array[StackFrame], Error)
|
||||
//===> callback([
|
||||
// StackFrame({functionName: 'func1', args: [], fileName: 'file.js', lineNumber: 203, columnNumber: 9}),
|
||||
// StackFrame({functionName: 'func2', args: [], fileName: 'http://localhost:3000/file.min.js', lineNumber: 1, columnNumber: 3284})
|
||||
//])
|
||||
```
|
||||
|
||||
#### You can also get a stack trace synchronously
|
||||
**HEADS UP:** This method does not resolve source maps or guess anonymous function names.
|
||||
|
||||
```js
|
||||
StackTrace.getSync();
|
||||
//==> [
|
||||
// StackFrame({functionName: 'func1', args: [], fileName: 'file.js', lineNumber: 203, columnNumber: 9}),
|
||||
// StackFrame({functionName: 'func2', args: [], fileName: 'http://localhost:3000/file.min.js', lineNumber: 1, columnNumber: 3284})
|
||||
//]
|
||||
```
|
||||
|
||||
#### window.onerror integration
|
||||
Automatically handle errors
|
||||
```js
|
||||
window.onerror = function(msg, file, line, col, error) {
|
||||
// callback is called with an Array[StackFrame]
|
||||
StackTrace.fromError(error).then(callback).catch(errback);
|
||||
};
|
||||
```
|
||||
|
||||
#### Get stack trace from an Error
|
||||
```js
|
||||
var error = new Error('BOOM!');
|
||||
|
||||
StackTrace.fromError(error).then(callback).catch(errback);
|
||||
//===> Promise(Array[StackFrame], Error)
|
||||
```
|
||||
|
||||
#### Generate a stacktrace from walking arguments.callee
|
||||
This might capture arguments information, but isn't supported in ES5 strict-mode
|
||||
```js
|
||||
StackTrace.generateArtificially().then(callback).catch(errback);
|
||||
//===> Promise(Array[StackFrame], Error)
|
||||
```
|
||||
|
||||
#### Trace every time a given function is invoked
|
||||
```js
|
||||
// callback is called with an Array[StackFrame] every time wrapped function is called
|
||||
var myFunc = function(arg) { return 'Hello ' + arg; };
|
||||
var myWrappedFunc = StackTrace.instrument(myFunc, callback, errback);
|
||||
//===> Instrumented Function
|
||||
myWrappedFunc('world');
|
||||
//===> 'Hello world'
|
||||
|
||||
// Use this if you overwrote you original function
|
||||
myFunc = StackTrace.deinstrument(myFunc);
|
||||
//===> De-instrumented Function
|
||||
```
|
||||
|
||||
## Get stacktrace.js
|
||||
```
|
||||
npm install stacktrace-js
|
||||
bower install stacktrace-js
|
||||
component install stacktracejs/stacktrace.js
|
||||
http://cdnjs.com/libraries/stacktrace.js
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
#### `StackTrace.get(/*optional*/ options)` => [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)(Array[[StackFrame](https://github.com/stacktracejs/stackframe)])
|
||||
Generate a backtrace from invocation point, then parse and enhance it.
|
||||
|
||||
**(Optional) options: Object**
|
||||
* *filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`
|
||||
* *sourceCache: Object (String URL => String Source)* - Pre-populate source cache to avoid network requests
|
||||
* *offline: Boolean (default: false)* - Set to `true` to prevent all network requests
|
||||
|
||||
#### `StackTrace.getSync(/*optional*/ options)` => Array[[StackFrame](https://github.com/stacktracejs/stackframe)]
|
||||
Generate a backtrace from invocation point, then parse it. This method does not use source maps or guess anonymous functions.
|
||||
|
||||
**(Optional) options: Object**
|
||||
* *filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`
|
||||
|
||||
#### `StackTrace.fromError(error, /*optional*/ options)` => [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)(Array[[StackFrame](https://github.com/stacktracejs/stackframe)])
|
||||
Given an Error object, use [error-stack-parser](https://github.com/stacktracejs/error-stack-parser)
|
||||
to parse it and enhance location information with [stacktrace-gps](https://github.com/stacktracejs/stacktrace-gps).
|
||||
|
||||
**error: Error**
|
||||
|
||||
**(Optional) options: Object**
|
||||
* *filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`
|
||||
* *sourceCache: Object (String URL => String Source)* - Pre-populate source cache to avoid network requests
|
||||
* *offline: Boolean (default: false)* - Set to `true` to prevent all network requests
|
||||
|
||||
#### `StackTrace.generateArtificially(/*optional*/ options)` => [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)(Array[[StackFrame](https://github.com/stacktracejs/stackframe)])
|
||||
Use [stack-generator](https://github.com/stacktracejs/stack-generator) to generate a backtrace by walking the `arguments.callee.caller` chain.
|
||||
|
||||
**(Optional) options: Object**
|
||||
* *filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`
|
||||
* *sourceCache: Object (String URL => String Source)* - Pre-populate source cache to avoid network requests
|
||||
* *offline: Boolean (default: false)* - Set to `true` to prevent all network requests
|
||||
|
||||
#### `StackTrace.instrument(fn, callback, /*optional*/ errback)` => Function
|
||||
* Given a function, wrap it such that invocations trigger a callback that is called with a stack trace.
|
||||
|
||||
* **fn: Function** - to wrap, call callback on invocation and call-through
|
||||
* **callback: Function** - to call with stack trace (generated by `StackTrace.get()`) when fn is called
|
||||
* **(Optional) errback: Function** - to call with Error object if there was a problem getting a stack trace.
|
||||
Fails silently (though `fn` is still called) if a stack trace couldn't be generated.
|
||||
|
||||
#### `StackTrace.deinstrument(fn)` => Function
|
||||
Given a function that has been instrumented, revert the function to it's original (non-instrumented) state.
|
||||
|
||||
* **fn: Function** - Instrumented Function
|
||||
|
||||
#### `StackTrace.report(stackframes, url, message, requestOptions)` => [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)(String)
|
||||
Given an an error message and Array of StackFrames, serialize and POST to given URL. Promise is resolved with response text from POST request.
|
||||
|
||||
Example JSON POST data:
|
||||
```
|
||||
{
|
||||
message: 'BOOM',
|
||||
stack: [
|
||||
{functionName: 'fn', fileName: 'file.js', lineNumber: 32, columnNumber: 1},
|
||||
{functionName: 'fn2', fileName: 'file.js', lineNumber: 543, columnNumber: 32},
|
||||
{functionName: 'fn3', fileName: 'file.js', lineNumber: 8, columnNumber: 1}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
* **stackframes: Array([StackFrame](https://github.com/stacktracejs/stackframe))** - Previously wrapped Function
|
||||
* **url: String** - URL to POST stack JSON to
|
||||
* **message: String** - The error message
|
||||
* **requestOptions: Object** - HTTP request options object. Only `headers: {key: val}` is supported.
|
||||
|
||||
## Browser Support
|
||||
[](https://saucelabs.com/u/stacktracejs)
|
||||
|
||||
> **HEADS UP**: You won't get the benefit of [source maps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/)
|
||||
in IE9- or other very old browsers.
|
||||
|
||||
## Using node.js/io.js only?
|
||||
I recommend the [stack-trace node package](https://www.npmjs.com/package/stack-trace) specifically built for node.
|
||||
It has a very similar API and also supports source maps.
|
||||
|
||||
## Contributing
|
||||
This project adheres to the [Open Code of Conduct](http://todogroup.org/opencodeofconduct/#stacktrace.js/me@eriwen.com). By participating, you are expected to honor this code.
|
||||
|
||||
Want to be listed as a *Contributor*? Start with the [Contributing Guide](https://github.com/stacktracejs/stacktrace.js/blob/master/.github/CONTRIBUTING.md)!
|
||||
|
||||
This project is made possible due to the efforts of these fine people:
|
||||
|
||||
* [Eric Wendelin](https://www.eriwen.com)
|
||||
* [Victor Homyakov](https://github.com/victor-homyakov)
|
||||
* [Oliver Salzburg](https://github.com/oliversalzburg)
|
||||
* [Many others](https://github.com/stacktracejs/stacktrace.js/graphs/contributors)
|
5405
node_modules/stacktrace-js/dist/stacktrace-with-promises-and-json-polyfills.js
generated
vendored
Normal file
5405
node_modules/stacktrace-js/dist/stacktrace-with-promises-and-json-polyfills.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/stacktrace-js/dist/stacktrace-with-promises-and-json-polyfills.min.js
generated
vendored
Normal file
3
node_modules/stacktrace-js/dist/stacktrace-with-promises-and-json-polyfills.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/stacktrace-js/dist/stacktrace-with-promises-and-json-polyfills.min.js.map
generated
vendored
Normal file
1
node_modules/stacktrace-js/dist/stacktrace-with-promises-and-json-polyfills.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3025
node_modules/stacktrace-js/dist/stacktrace.js
generated
vendored
Normal file
3025
node_modules/stacktrace-js/dist/stacktrace.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/stacktrace-js/dist/stacktrace.min.js
generated
vendored
Normal file
2
node_modules/stacktrace-js/dist/stacktrace.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/stacktrace-js/dist/stacktrace.min.js.map
generated
vendored
Normal file
1
node_modules/stacktrace-js/dist/stacktrace.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
82
node_modules/stacktrace-js/package.json
generated
vendored
Normal file
82
node_modules/stacktrace-js/package.json
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "stacktrace-js",
|
||||
"description": "Framework-agnostic, micro-library for getting stack traces in all environments",
|
||||
"maintainers": [
|
||||
"Eric Wendelin <me@eriwen.com> (https://www.eriwen.com)",
|
||||
"Victor Homyakov <vkhomyackov@gmail.com> (https://github.com/victor-homyakov)",
|
||||
"Oliver Salzburg (https://github.com/oliversalzburg)",
|
||||
"Ben Gourley (https://github.com/bengourley)"
|
||||
],
|
||||
"version": "2.0.2",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"stacktrace",
|
||||
"error",
|
||||
"debugger",
|
||||
"client",
|
||||
"browser"
|
||||
],
|
||||
"homepage": "https://www.stacktracejs.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stacktracejs/stacktrace.js.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"error-stack-parser": "^2.0.6",
|
||||
"stack-generator": "^2.0.5",
|
||||
"stacktrace-gps": "^3.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.3.0",
|
||||
"colors": "^1.1.2",
|
||||
"del": "^3.0.0",
|
||||
"es6-promise": "^3.1.2",
|
||||
"eslint": "^6.8.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-concat": "^2.6.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-sourcemaps": "^1.12.0",
|
||||
"gulp-uglify": "^1.5.1",
|
||||
"jasmine": "^2.7.0",
|
||||
"jasmine-ajax": "^3.2.0",
|
||||
"jasmine-core": "^2.7.0",
|
||||
"jsdoc-dash-template": "^2.1.0",
|
||||
"json3": "^3.3.2",
|
||||
"karma": "^4.4.1",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-coverage": "^2.0.1",
|
||||
"karma-coveralls": "^2.1.0",
|
||||
"karma-firefox-launcher": "^1.2.0",
|
||||
"karma-ie-launcher": "^1.0.0",
|
||||
"karma-jasmine": "^1.1.2",
|
||||
"karma-jasmine-ajax": "^0.1.13",
|
||||
"karma-opera-launcher": "^1.0.0",
|
||||
"karma-phantomjs-launcher": "^1.0.4",
|
||||
"karma-safari-launcher": "^1.0.0",
|
||||
"karma-sauce-launcher": "^2.0.2",
|
||||
"karma-spec-reporter": "^0.0.32",
|
||||
"run-sequence": "^1.1.2",
|
||||
"vinyl-buffer": "^1.0.0",
|
||||
"vinyl-source-stream": "^1.1.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stacktracejs/stacktrace.js/issues"
|
||||
},
|
||||
"main": "./stacktrace.js",
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
"README.md",
|
||||
"stacktrace.js",
|
||||
"stacktrace-js.d.ts",
|
||||
"dist/"
|
||||
],
|
||||
"typings": "./stacktrace-js.d.ts",
|
||||
"scripts": {
|
||||
"lint": "eslint --fix polyfills.js stacktrace.js spec/",
|
||||
"prepare": "gulp dist",
|
||||
"test": "karma start karma.conf.js --single-run",
|
||||
"test-pr": "karma start karma.conf.js --single-run --browsers Firefox,Chrome_Travis",
|
||||
"test-ci": "karma start karma.conf.ci.js --single-run"
|
||||
}
|
||||
}
|
134
node_modules/stacktrace-js/stacktrace-js.d.ts
generated
vendored
Normal file
134
node_modules/stacktrace-js/stacktrace-js.d.ts
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
// Type definitions for stacktrace.js v2.0.0
|
||||
// Project: https://github.com/stacktracejs/stacktrace.js
|
||||
// Definitions by: Eric Wendelin <https://github.com/exceptionless>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace StackTrace {
|
||||
|
||||
export interface SourceCache {
|
||||
[key: string]: string | Promise<string>;
|
||||
}
|
||||
|
||||
export interface StackTraceOptions {
|
||||
filter?: (stackFrame: StackFrame) => boolean;
|
||||
sourceCache?: SourceCache;
|
||||
offline?: boolean;
|
||||
}
|
||||
|
||||
export interface StackFrame {
|
||||
constructor(object: StackFrame): StackFrame;
|
||||
|
||||
isConstructor?: boolean;
|
||||
getIsConstructor(): boolean;
|
||||
setIsConstructor(): void;
|
||||
|
||||
isEval?: boolean;
|
||||
getIsEval(): boolean;
|
||||
setIsEval(): void;
|
||||
|
||||
isNative?: boolean;
|
||||
getIsNative(): boolean;
|
||||
setIsNative(): void;
|
||||
|
||||
isTopLevel?: boolean;
|
||||
getIsTopLevel(): boolean;
|
||||
setIsTopLevel(): void;
|
||||
|
||||
columnNumber?: number;
|
||||
getColumnNumber(): number;
|
||||
setColumnNumber(): void;
|
||||
|
||||
lineNumber?: number;
|
||||
getLineNumber(): number;
|
||||
setLineNumber(): void;
|
||||
|
||||
fileName?: string;
|
||||
getFileName(): string;
|
||||
setFileName(): void;
|
||||
|
||||
functionName?: string;
|
||||
getFunctionName(): string;
|
||||
setFunctionName(): void;
|
||||
|
||||
source?: string;
|
||||
getSource(): string;
|
||||
setSource(): void;
|
||||
|
||||
args?: any[];
|
||||
getArgs(): any[];
|
||||
setArgs(): void;
|
||||
|
||||
evalOrigin?: StackFrame;
|
||||
getEvalOrigin(): StackFrame;
|
||||
setEvalOrigin(): void;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a backtrace from invocation point.
|
||||
*
|
||||
* @param options Options Object
|
||||
* @return Array[StackFrame]
|
||||
*/
|
||||
export function get(options?: StackTraceOptions): Promise<StackFrame[]>;
|
||||
|
||||
/**
|
||||
* Get a backtrace from invocation point, synchronously. Does not
|
||||
* attempt to map sources.
|
||||
*
|
||||
* @param options Options Object
|
||||
* @return Array[StackFrame]
|
||||
*/
|
||||
export function getSync(options?: StackTraceOptions): StackFrame[];
|
||||
|
||||
/**
|
||||
* Given an error object, parse it.
|
||||
*
|
||||
* @param error Error object
|
||||
* @param options Object for options
|
||||
* @return Array[StackFrame]
|
||||
*/
|
||||
export function fromError(error: Error, options?: StackTraceOptions): Promise<StackFrame[]>;
|
||||
|
||||
/**
|
||||
* Use StackGenerator to generate a backtrace.
|
||||
* @param options Object options
|
||||
* @returns Array[StackFrame]
|
||||
*/
|
||||
export function generateArtificially(options?: StackTraceOptions): Promise<StackFrame[]>;
|
||||
|
||||
/**
|
||||
* Given a function, wrap it such that invocations trigger a callback that
|
||||
* is called with a stack trace.
|
||||
*
|
||||
* @param {Function} fn to be instrumented
|
||||
* @param {Function} callback function to call with a stack trace on invocation
|
||||
* @param {Function} errback optional function to call with error if unable to get stack trace.
|
||||
* @param {Object} thisArg optional context object (e.g. window)
|
||||
*/
|
||||
export function instrument<TFunc extends Function>(fn: TFunc, callback: (stackFrames: StackFrame[]) => void, errback?: (error: Error) => void, thisArg?: any): TFunc;
|
||||
|
||||
/**
|
||||
* Given a function that has been instrumented,
|
||||
* revert the function to it's original (non-instrumented) state.
|
||||
*
|
||||
* @param fn {Function}
|
||||
*/
|
||||
export function deinstrument<TFunc extends Function>(fn: TFunc): TFunc;
|
||||
|
||||
/**
|
||||
* Given an Array of StackFrames, serialize and POST to given URL.
|
||||
*
|
||||
* @param stackframes - Array[StackFrame]
|
||||
* @param url - URL as String
|
||||
* @param errorMsg - Error message as String
|
||||
* @param requestOptions - Object with headers information
|
||||
* @return Promise<any>
|
||||
*/
|
||||
export function report(stackframes: StackFrame[], url: string, errorMsg?: string, requestOptions?: object): Promise<any>;
|
||||
}
|
||||
|
||||
declare module "stacktrace-js" {
|
||||
export = StackTrace;
|
||||
}
|
227
node_modules/stacktrace-js/stacktrace.js
generated
vendored
Normal file
227
node_modules/stacktrace-js/stacktrace.js
generated
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
(function(root, factory) {
|
||||
'use strict';
|
||||
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('stacktrace', ['error-stack-parser', 'stack-generator', 'stacktrace-gps'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory(require('error-stack-parser'), require('stack-generator'), require('stacktrace-gps'));
|
||||
} else {
|
||||
root.StackTrace = factory(root.ErrorStackParser, root.StackGenerator, root.StackTraceGPS);
|
||||
}
|
||||
}(this, function StackTrace(ErrorStackParser, StackGenerator, StackTraceGPS) {
|
||||
var _options = {
|
||||
filter: function(stackframe) {
|
||||
// Filter out stackframes for this library by default
|
||||
return (stackframe.functionName || '').indexOf('StackTrace$$') === -1 &&
|
||||
(stackframe.functionName || '').indexOf('ErrorStackParser$$') === -1 &&
|
||||
(stackframe.functionName || '').indexOf('StackTraceGPS$$') === -1 &&
|
||||
(stackframe.functionName || '').indexOf('StackGenerator$$') === -1;
|
||||
},
|
||||
sourceCache: {}
|
||||
};
|
||||
|
||||
var _generateError = function StackTrace$$GenerateError() {
|
||||
try {
|
||||
// Error must be thrown to get stack in IE
|
||||
throw new Error();
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Merge 2 given Objects. If a conflict occurs the second object wins.
|
||||
* Does not do deep merges.
|
||||
*
|
||||
* @param {Object} first base object
|
||||
* @param {Object} second overrides
|
||||
* @returns {Object} merged first and second
|
||||
* @private
|
||||
*/
|
||||
function _merge(first, second) {
|
||||
var target = {};
|
||||
|
||||
[first, second].forEach(function(obj) {
|
||||
for (var prop in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
||||
target[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
return target;
|
||||
});
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function _isShapedLikeParsableError(err) {
|
||||
return err.stack || err['opera#sourceloc'];
|
||||
}
|
||||
|
||||
function _filtered(stackframes, filter) {
|
||||
if (typeof filter === 'function') {
|
||||
return stackframes.filter(filter);
|
||||
}
|
||||
return stackframes;
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get a backtrace from invocation point.
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @returns {Array} of StackFrame
|
||||
*/
|
||||
get: function StackTrace$$get(opts) {
|
||||
var err = _generateError();
|
||||
return _isShapedLikeParsableError(err) ? this.fromError(err, opts) : this.generateArtificially(opts);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a backtrace from invocation point.
|
||||
* IMPORTANT: Does not handle source maps or guess function names!
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @returns {Array} of StackFrame
|
||||
*/
|
||||
getSync: function StackTrace$$getSync(opts) {
|
||||
opts = _merge(_options, opts);
|
||||
var err = _generateError();
|
||||
var stack = _isShapedLikeParsableError(err) ? ErrorStackParser.parse(err) : StackGenerator.backtrace(opts);
|
||||
return _filtered(stack, opts.filter);
|
||||
},
|
||||
|
||||
/**
|
||||
* Given an error object, parse it.
|
||||
*
|
||||
* @param {Error} error object
|
||||
* @param {Object} opts
|
||||
* @returns {Promise} for Array[StackFrame}
|
||||
*/
|
||||
fromError: function StackTrace$$fromError(error, opts) {
|
||||
opts = _merge(_options, opts);
|
||||
var gps = new StackTraceGPS(opts);
|
||||
return new Promise(function(resolve) {
|
||||
var stackframes = _filtered(ErrorStackParser.parse(error), opts.filter);
|
||||
resolve(Promise.all(stackframes.map(function(sf) {
|
||||
return new Promise(function(resolve) {
|
||||
function resolveOriginal() {
|
||||
resolve(sf);
|
||||
}
|
||||
|
||||
gps.pinpoint(sf).then(resolve, resolveOriginal)['catch'](resolveOriginal);
|
||||
});
|
||||
})));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Use StackGenerator to generate a backtrace.
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @returns {Promise} of Array[StackFrame]
|
||||
*/
|
||||
generateArtificially: function StackTrace$$generateArtificially(opts) {
|
||||
opts = _merge(_options, opts);
|
||||
var stackFrames = StackGenerator.backtrace(opts);
|
||||
if (typeof opts.filter === 'function') {
|
||||
stackFrames = stackFrames.filter(opts.filter);
|
||||
}
|
||||
return Promise.resolve(stackFrames);
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a function, wrap it such that invocations trigger a callback that
|
||||
* is called with a stack trace.
|
||||
*
|
||||
* @param {Function} fn to be instrumented
|
||||
* @param {Function} callback function to call with a stack trace on invocation
|
||||
* @param {Function} errback optional function to call with error if unable to get stack trace.
|
||||
* @param {Object} thisArg optional context object (e.g. window)
|
||||
*/
|
||||
instrument: function StackTrace$$instrument(fn, callback, errback, thisArg) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new Error('Cannot instrument non-function object');
|
||||
} else if (typeof fn.__stacktraceOriginalFn === 'function') {
|
||||
// Already instrumented, return given Function
|
||||
return fn;
|
||||
}
|
||||
|
||||
var instrumented = function StackTrace$$instrumented() {
|
||||
try {
|
||||
this.get().then(callback, errback)['catch'](errback);
|
||||
return fn.apply(thisArg || this, arguments);
|
||||
} catch (e) {
|
||||
if (_isShapedLikeParsableError(e)) {
|
||||
this.fromError(e).then(callback, errback)['catch'](errback);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}.bind(this);
|
||||
instrumented.__stacktraceOriginalFn = fn;
|
||||
|
||||
return instrumented;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a function that has been instrumented,
|
||||
* revert the function to it's original (non-instrumented) state.
|
||||
*
|
||||
* @param {Function} fn to de-instrument
|
||||
*/
|
||||
deinstrument: function StackTrace$$deinstrument(fn) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new Error('Cannot de-instrument non-function object');
|
||||
} else if (typeof fn.__stacktraceOriginalFn === 'function') {
|
||||
return fn.__stacktraceOriginalFn;
|
||||
} else {
|
||||
// Function not instrumented, return original
|
||||
return fn;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Given an error message and Array of StackFrames, serialize and POST to given URL.
|
||||
*
|
||||
* @param {Array} stackframes
|
||||
* @param {String} url
|
||||
* @param {String} errorMsg
|
||||
* @param {Object} requestOptions
|
||||
*/
|
||||
report: function StackTrace$$report(stackframes, url, errorMsg, requestOptions) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var req = new XMLHttpRequest();
|
||||
req.onerror = reject;
|
||||
req.onreadystatechange = function onreadystatechange() {
|
||||
if (req.readyState === 4) {
|
||||
if (req.status >= 200 && req.status < 400) {
|
||||
resolve(req.responseText);
|
||||
} else {
|
||||
reject(new Error('POST to ' + url + ' failed with status: ' + req.status));
|
||||
}
|
||||
}
|
||||
};
|
||||
req.open('post', url);
|
||||
|
||||
// Set request headers
|
||||
req.setRequestHeader('Content-Type', 'application/json');
|
||||
if (requestOptions && typeof requestOptions.headers === 'object') {
|
||||
var headers = requestOptions.headers;
|
||||
for (var header in headers) {
|
||||
if (Object.prototype.hasOwnProperty.call(headers, header)) {
|
||||
req.setRequestHeader(header, headers[header]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var reportPayload = {stack: stackframes};
|
||||
if (errorMsg !== undefined && errorMsg !== null) {
|
||||
reportPayload.message = errorMsg;
|
||||
}
|
||||
|
||||
req.send(JSON.stringify(reportPayload));
|
||||
});
|
||||
}
|
||||
};
|
||||
}));
|
Reference in New Issue
Block a user