├── register.js ├── .travis.yml ├── .npmignore ├── browserify-test ├── index.html └── script.coffee ├── webpack-test ├── index.html ├── webpack.config.js └── script.js ├── amd-test ├── index.html ├── script.coffee └── require.js ├── browser-test ├── index.html ├── script.coffee ├── script.js └── script.map ├── .gitignore ├── header-test ├── index.html ├── script.coffee └── server.js ├── package.json ├── LICENSE.md ├── README.md ├── source-map-support.js ├── test.js └── browser-source-map-support.js /register.js: -------------------------------------------------------------------------------- 1 | require('./').install(); 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '8' 4 | - '7' 5 | - '6' 6 | - '4' 7 | - '0.12' 8 | - '0.10' 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | amd-test/ 2 | browser-test/ 3 | browserify-test/ 4 | header-test/ 5 | webpack-test/ 6 | .npmignore 7 | .travis.yml 8 | build.js 9 | test.js 10 | -------------------------------------------------------------------------------- /browserify-test/index.html: -------------------------------------------------------------------------------- 1 |

2 | Make sure to run build.js. 3 | This test should say either "Test failed" or "Test passed": 4 |

5 | 6 | -------------------------------------------------------------------------------- /webpack-test/index.html: -------------------------------------------------------------------------------- 1 |

2 | Make sure to run build.js. 3 | This test should say either "Test failed" or "Test passed": 4 |

5 | 6 | -------------------------------------------------------------------------------- /amd-test/index.html: -------------------------------------------------------------------------------- 1 |

2 | Make sure to run build.js. 3 | This test should say either "Test failed" or "Test passed": 4 |

5 | 6 | 7 | -------------------------------------------------------------------------------- /browser-test/index.html: -------------------------------------------------------------------------------- 1 |

2 | Make sure to run build.js. 3 | This test should say either "Test failed" or "Test passed": 4 |

5 | 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | amd-test/browser-source-map-support.js 3 | amd-test/script.js 4 | amd-test/script.map 5 | browserify-test/compiled.js 6 | browserify-test/script.js 7 | browserify-test/script.map 8 | header-test/script.js 9 | header-test/script.map 10 | webpack-test/compiled.js -------------------------------------------------------------------------------- /webpack-test/webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack'); 2 | 3 | module.exports = { 4 | entry: './script.js', 5 | devtool: 'inline-source-map', 6 | output: { 7 | filename: 'compiled.js' 8 | }, 9 | resolve: { 10 | extensions: ['', '.js'] 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /header-test/index.html: -------------------------------------------------------------------------------- 1 |

2 | Make sure to run build.js, then run server.js and visit http://localhost:1337/. 3 | This test should say either "Test failed" or "Test passed": 4 |

5 | 6 | 7 | -------------------------------------------------------------------------------- /browser-test/script.coffee: -------------------------------------------------------------------------------- 1 | sourceMapSupport.install() 2 | 3 | foo = -> throw new Error 'foo' 4 | 5 | try 6 | foo() 7 | catch e 8 | if /\bscript\.coffee\b/.test e.stack 9 | document.body.appendChild document.createTextNode 'Test passed' 10 | else 11 | document.body.appendChild document.createTextNode 'Test failed' 12 | console.log e.stack 13 | -------------------------------------------------------------------------------- /header-test/script.coffee: -------------------------------------------------------------------------------- 1 | sourceMapSupport.install() 2 | 3 | foo = -> throw new Error 'foo' 4 | 5 | try 6 | foo() 7 | catch e 8 | if /\bscript\.coffee\b/.test e.stack 9 | document.body.appendChild document.createTextNode 'Test passed' 10 | else 11 | document.body.appendChild document.createTextNode 'Test failed' 12 | console.log e.stack 13 | -------------------------------------------------------------------------------- /browserify-test/script.coffee: -------------------------------------------------------------------------------- 1 | (require '../source-map-support').install() 2 | 3 | foo = -> throw new Error 'foo' 4 | 5 | try 6 | foo() 7 | catch e 8 | if /\bscript\.coffee\b/.test e.stack 9 | document.body.appendChild document.createTextNode 'Test passed' 10 | else 11 | document.body.appendChild document.createTextNode 'Test failed' 12 | console.log e.stack 13 | -------------------------------------------------------------------------------- /webpack-test/script.js: -------------------------------------------------------------------------------- 1 | require('../').install(); 2 | 3 | function foo() { 4 | throw new Error('foo'); 5 | } 6 | 7 | try { 8 | foo(); 9 | } catch (e) { 10 | if (/\bscript\.js\b/.test(e.stack)) { 11 | document.body.appendChild(document.createTextNode('Test passed')); 12 | } else { 13 | document.body.appendChild(document.createTextNode('Test failed')); 14 | console.log(e.stack); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /amd-test/script.coffee: -------------------------------------------------------------------------------- 1 | define ['browser-source-map-support'], (sourceMapSupport) -> 2 | sourceMapSupport.install() 3 | 4 | foo = -> throw new Error 'foo' 5 | 6 | try 7 | foo() 8 | catch e 9 | if /\bscript\.coffee\b/.test e.stack 10 | document.body.appendChild document.createTextNode 'Test passed' 11 | else 12 | document.body.appendChild document.createTextNode 'Test failed' 13 | console.log e.stack 14 | -------------------------------------------------------------------------------- /browser-test/script.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.7.1 2 | (function() { 3 | var e, foo; 4 | 5 | sourceMapSupport.install(); 6 | 7 | foo = function() { 8 | throw new Error('foo'); 9 | }; 10 | 11 | try { 12 | foo(); 13 | } catch (_error) { 14 | e = _error; 15 | if (/\bscript\.coffee\b/.test(e.stack)) { 16 | document.body.appendChild(document.createTextNode('Test passed')); 17 | } else { 18 | document.body.appendChild(document.createTextNode('Test failed')); 19 | console.log(e.stack); 20 | } 21 | } 22 | 23 | }).call(this); 24 | 25 | //# sourceMappingURL=script.map 26 | -------------------------------------------------------------------------------- /browser-test/script.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "script.js", 4 | "sourceRoot": "..", 5 | "sources": [ 6 | "browser-test/script.coffee" 7 | ], 8 | "names": [], 9 | "mappings": ";AAAA;AAAA,MAAA,MAAA;;AAAA,EAAA,gBAAgB,CAAC,OAAjB,CAAA,CAAA,CAAA;;AAAA,EAEA,GAAA,GAAM,SAAA,GAAA;AAAG,UAAU,IAAA,KAAA,CAAM,KAAN,CAAV,CAAH;EAAA,CAFN,CAAA;;AAIA;AACE,IAAA,GAAA,CAAA,CAAA,CADF;GAAA,cAAA;AAGE,IADI,UACJ,CAAA;AAAA,IAAA,IAAG,oBAAoB,CAAC,IAArB,CAA0B,CAAC,CAAC,KAA5B,CAAH;AACE,MAAA,QAAQ,CAAC,IAAI,CAAC,WAAd,CAA0B,QAAQ,CAAC,cAAT,CAAwB,aAAxB,CAA1B,CAAA,CADF;KAAA,MAAA;AAGE,MAAA,QAAQ,CAAC,IAAI,CAAC,WAAd,CAA0B,QAAQ,CAAC,cAAT,CAAwB,aAAxB,CAA1B,CAAA,CAAA;AAAA,MACA,OAAO,CAAC,GAAR,CAAY,CAAC,CAAC,KAAd,CADA,CAHF;KAHF;GAJA;AAAA" 10 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "source-map-support", 3 | "description": "Fixes stack traces for files with source maps", 4 | "version": "0.5.0", 5 | "main": "./source-map-support.js", 6 | "scripts": { 7 | "build": "node build.js", 8 | "serve-tests": "http-server -p 1336", 9 | "prepublish": "npm run build", 10 | "test": "mocha" 11 | }, 12 | "dependencies": { 13 | "source-map": "^0.6.0" 14 | }, 15 | "devDependencies": { 16 | "browserify": "3.44.2", 17 | "coffee-script": "1.7.1", 18 | "http-server": "^0.8.5", 19 | "mocha": "1.18.2", 20 | "webpack": "^1.13.3" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "https://github.com/evanw/node-source-map-support" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/evanw/node-source-map-support/issues" 28 | }, 29 | "license": "MIT" 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Evan Wallace 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /header-test/server.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var http = require('http'); 3 | 4 | http.createServer(function(req, res) { 5 | switch (req.url) { 6 | case '/': 7 | case '/index.html': { 8 | res.writeHead(200, { 'Content-Type': 'text/html' }); 9 | res.end(fs.readFileSync('index.html', 'utf8')); 10 | break; 11 | } 12 | 13 | case '/browser-source-map-support.js': { 14 | res.writeHead(200, { 'Content-Type': 'text/javascript' }); 15 | res.end(fs.readFileSync('../browser-source-map-support.js', 'utf8')); 16 | break; 17 | } 18 | 19 | case '/script.js': { 20 | res.writeHead(200, { 'Content-Type': 'text/javascript', 'SourceMap': 'script-source-map.map' }); 21 | res.end(fs.readFileSync('script.js', 'utf8')); 22 | break; 23 | } 24 | 25 | case '/script-source-map.map': { 26 | res.writeHead(200, { 'Content-Type': 'application/json' }); 27 | res.end(fs.readFileSync('script.map', 'utf8')); 28 | break; 29 | } 30 | 31 | case '/header-test/script.coffee': { 32 | res.writeHead(200, { 'Content-Type': 'text/x-coffeescript' }); 33 | res.end(fs.readFileSync('script.coffee', 'utf8')); 34 | break; 35 | } 36 | 37 | default: { 38 | res.writeHead(404, { 'Content-Type': 'text/html' }); 39 | res.end('404 not found'); 40 | break; 41 | } 42 | } 43 | }).listen(1337, '127.0.0.1'); 44 | 45 | console.log('Server running at http://127.0.0.1:1337/'); 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Source Map Support 2 | [![Build Status](https://travis-ci.org/evanw/node-source-map-support.svg?branch=master)](https://travis-ci.org/evanw/node-source-map-support) 3 | 4 | This module provides source map support for stack traces in node via the [V8 stack trace API](https://github.com/v8/v8/wiki/Stack-Trace-API). It uses the [source-map](https://github.com/mozilla/source-map) module to replace the paths and line numbers of source-mapped files with their original paths and line numbers. The output mimics node's stack trace format with the goal of making every compile-to-JS language more of a first-class citizen. Source maps are completely general (not specific to any one language) so you can use source maps with multiple compile-to-JS languages in the same node process. 5 | 6 | ## Installation and Usage 7 | 8 | #### Node support 9 | 10 | ``` 11 | $ npm install source-map-support 12 | ``` 13 | 14 | Source maps can be generated using libraries such as [source-map-index-generator](https://github.com/twolfson/source-map-index-generator). Once you have a valid source map, place a source mapping comment somewhere in the file (usually done automatically or with an option by your transpiler): 15 | 16 | ``` 17 | //# sourceMappingURL=path/to/source.map 18 | ``` 19 | 20 | If multiple sourceMappingURL comments exist in one file, the last sourceMappingURL comment will be 21 | respected (e.g. if a file mentions the comment in code, or went through multiple transpilers). 22 | The path should either be absolute or relative to the compiled file. 23 | 24 | From here you have two options. 25 | 26 | ##### CLI Usage 27 | 28 | ```bash 29 | node -r source-map-support/register compiled.js 30 | ``` 31 | 32 | ##### Programmatic Usage 33 | 34 | Put the following line at the top of the compiled file. 35 | 36 | ```js 37 | require('source-map-support').install(); 38 | ``` 39 | 40 | It is also possible to install the source map support directly by 41 | requiring the `register` module which can be handy with ES6: 42 | 43 | ```js 44 | import 'source-map-support/register' 45 | 46 | // Instead of: 47 | import sourceMapSupport from 'source-map-support' 48 | sourceMapSupport.install() 49 | ``` 50 | Note: if you're using babel-register, it includes source-map-support already. 51 | 52 | It is also very useful with Mocha: 53 | 54 | ``` 55 | $ mocha --require source-map-support/register tests/ 56 | ``` 57 | 58 | #### Browser support 59 | 60 | This library also works in Chrome. While the DevTools console already supports source maps, the V8 engine doesn't and `Error.prototype.stack` will be incorrect without this library. Everything will just work if you deploy your source files using [browserify](http://browserify.org/). Just make sure to pass the `--debug` flag to the browserify command so your source maps are included in the bundled code. 61 | 62 | This library also works if you use another build process or just include the source files directly. In this case, include the file `browser-source-map-support.js` in your page and call `sourceMapSupport.install()`. It contains the whole library already bundled for the browser using browserify. 63 | 64 | ```html 65 | 66 | 67 | ``` 68 | 69 | This library also works if you use AMD (Asynchronous Module Definition), which is used in tools like [RequireJS](http://requirejs.org/). Just list `browser-source-map-support` as a dependency: 70 | 71 | ```html 72 | 77 | ``` 78 | 79 | ## Options 80 | 81 | This module installs two things: a change to the `stack` property on `Error` objects and a handler for uncaught exceptions that mimics node's default exception handler (the handler can be seen in the demos below). You may want to disable the handler if you have your own uncaught exception handler. This can be done by passing an argument to the installer: 82 | 83 | ```js 84 | require('source-map-support').install({ 85 | handleUncaughtExceptions: false 86 | }); 87 | ``` 88 | 89 | This module loads source maps from the filesystem by default. You can provide alternate loading behavior through a callback as shown below. For example, [Meteor](https://github.com/meteor) keeps all source maps cached in memory to avoid disk access. 90 | 91 | ```js 92 | require('source-map-support').install({ 93 | retrieveSourceMap: function(source) { 94 | if (source === 'compiled.js') { 95 | return { 96 | url: 'original.js', 97 | map: fs.readFileSync('compiled.js.map', 'utf8') 98 | }; 99 | } 100 | return null; 101 | } 102 | }); 103 | ``` 104 | 105 | The module will by default assume a browser environment if XMLHttpRequest and window are defined. If either of these do not exist it will instead assume a node environment. 106 | In some rare cases, e.g. when running a browser emulation and where both variables are also set, you can explictly specify the environment to be either 'browser' or 'node'. 107 | 108 | ```js 109 | require('source-map-support').install({ 110 | environment: 'node' 111 | }); 112 | ``` 113 | 114 | To support files with inline source maps, the `hookRequire` options can be specified, which will monitor all source files for inline source maps. 115 | 116 | 117 | ```js 118 | require('source-map-support').install({ 119 | hookRequire: true 120 | }); 121 | ``` 122 | 123 | This monkey patches the `require` module loading chain, so is not enabled by default and is not recommended for any sort of production usage. 124 | 125 | ## Demos 126 | 127 | #### Basic Demo 128 | 129 | original.js: 130 | 131 | ```js 132 | throw new Error('test'); // This is the original code 133 | ``` 134 | 135 | compiled.js: 136 | 137 | ```js 138 | require('source-map-support').install(); 139 | 140 | throw new Error('test'); // This is the compiled code 141 | // The next line defines the sourceMapping. 142 | //# sourceMappingURL=compiled.js.map 143 | ``` 144 | 145 | compiled.js.map: 146 | 147 | ```json 148 | { 149 | "version": 3, 150 | "file": "compiled.js", 151 | "sources": ["original.js"], 152 | "names": [], 153 | "mappings": ";;AAAA,MAAM,IAAI" 154 | } 155 | ``` 156 | 157 | Run compiled.js using node (notice how the stack trace uses original.js instead of compiled.js): 158 | 159 | ``` 160 | $ node compiled.js 161 | 162 | original.js:1 163 | throw new Error('test'); // This is the original code 164 | ^ 165 | Error: test 166 | at Object. (original.js:1:7) 167 | at Module._compile (module.js:456:26) 168 | at Object.Module._extensions..js (module.js:474:10) 169 | at Module.load (module.js:356:32) 170 | at Function.Module._load (module.js:312:12) 171 | at Function.Module.runMain (module.js:497:10) 172 | at startup (node.js:119:16) 173 | at node.js:901:3 174 | ``` 175 | 176 | #### TypeScript Demo 177 | 178 | demo.ts: 179 | 180 | ```typescript 181 | declare function require(name: string); 182 | require('source-map-support').install(); 183 | class Foo { 184 | constructor() { this.bar(); } 185 | bar() { throw new Error('this is a demo'); } 186 | } 187 | new Foo(); 188 | ``` 189 | 190 | Compile and run the file using the TypeScript compiler from the terminal: 191 | 192 | ``` 193 | $ npm install source-map-support typescript 194 | $ node_modules/typescript/bin/tsc -sourcemap demo.ts 195 | $ node demo.js 196 | 197 | demo.ts:5 198 | bar() { throw new Error('this is a demo'); } 199 | ^ 200 | Error: this is a demo 201 | at Foo.bar (demo.ts:5:17) 202 | at new Foo (demo.ts:4:24) 203 | at Object. (demo.ts:7:1) 204 | at Module._compile (module.js:456:26) 205 | at Object.Module._extensions..js (module.js:474:10) 206 | at Module.load (module.js:356:32) 207 | at Function.Module._load (module.js:312:12) 208 | at Function.Module.runMain (module.js:497:10) 209 | at startup (node.js:119:16) 210 | at node.js:901:3 211 | ``` 212 | 213 | #### CoffeeScript Demo 214 | 215 | demo.coffee: 216 | 217 | ```coffee 218 | require('source-map-support').install() 219 | foo = -> 220 | bar = -> throw new Error 'this is a demo' 221 | bar() 222 | foo() 223 | ``` 224 | 225 | Compile and run the file using the CoffeeScript compiler from the terminal: 226 | 227 | ```sh 228 | $ npm install source-map-support coffee-script 229 | $ node_modules/coffee-script/bin/coffee --map --compile demo.coffee 230 | $ node demo.js 231 | 232 | demo.coffee:3 233 | bar = -> throw new Error 'this is a demo' 234 | ^ 235 | Error: this is a demo 236 | at bar (demo.coffee:3:22) 237 | at foo (demo.coffee:4:3) 238 | at Object. (demo.coffee:5:1) 239 | at Object. (demo.coffee:1:1) 240 | at Module._compile (module.js:456:26) 241 | at Object.Module._extensions..js (module.js:474:10) 242 | at Module.load (module.js:356:32) 243 | at Function.Module._load (module.js:312:12) 244 | at Function.Module.runMain (module.js:497:10) 245 | at startup (node.js:119:16) 246 | ``` 247 | 248 | ## Tests 249 | 250 | This repo contains both automated tests for node and manual tests for the browser. The automated tests can be run using mocha (type `mocha` in the root directory). To run the manual tests: 251 | 252 | * Build the tests using `build.js` 253 | * Launch the HTTP server (`npm run serve-tests`) and visit 254 | * http://127.0.0.1:1336/amd-test 255 | * http://127.0.0.1:1336/browser-test 256 | * http://127.0.0.1:1336/browserify-test - **Currently not working** due to a bug with browserify (see [pull request #66](https://github.com/evanw/node-source-map-support/pull/66) for details). 257 | * For `header-test`, run `server.js` inside that directory and visit http://127.0.0.1:1337/ 258 | 259 | ## License 260 | 261 | This code is available under the [MIT license](http://opensource.org/licenses/MIT). 262 | -------------------------------------------------------------------------------- /amd-test/require.js: -------------------------------------------------------------------------------- 1 | /* 2 | RequireJS 2.1.9 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. 3 | Available via the MIT or new BSD license. 4 | see: http://github.com/jrburke/requirejs for details 5 | */ 6 | var requirejs,require,define; 7 | (function(Z){function H(b){return"[object Function]"===L.call(b)}function I(b){return"[object Array]"===L.call(b)}function y(b,c){if(b){var e;for(e=0;ethis.depCount&&!this.defined){if(H(m)){if(this.events.error&&this.map.isDefine||j.onError!==aa)try{d=i.execCb(c,m,b,d)}catch(e){a=e}else d=i.execCb(c,m,b,d);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!== 19 | this.exports?d=b.exports:void 0===d&&this.usingExports&&(d=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",v(this.error=a)}else d=m;this.exports=d;if(this.map.isDefine&&!this.ignore&&(r[c]=d,j.onResourceLoad))j.onResourceLoad(i,this.map,this.depMaps);x(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete= 20 | !0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,e=n(a.prefix);this.depMaps.push(e);s(e,"defined",u(this,function(d){var m,e;e=this.map.name;var g=this.map.parentMap?this.map.parentMap.name:null,h=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(d.normalize&&(e=d.normalize(e,function(a){return c(a,g,!0)})||""),d=n(a.prefix+"!"+e,this.map.parentMap),s(d,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})), 21 | e=l(p,d.id)){this.depMaps.push(d);if(this.events.error)e.on("error",u(this,function(a){this.emit("error",a)}));e.enable()}}else m=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),m.error=u(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];F(p,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&x(a.map.id)});v(a)}),m.fromText=u(this,function(d,c){var e=a.name,g=n(e),B=O;c&&(d=c);B&&(O=!1);q(g);t(k.config,b)&&(k.config[e]=k.config[b]);try{j.exec(d)}catch(ca){return v(A("fromtexteval", 22 | "fromText eval for "+b+" failed: "+ca,ca,[b]))}B&&(O=!0);this.depMaps.push(g);i.completeLoad(e);h([e],m)}),d.load(a.name,h,m,k)}));i.enable(e,this);this.pluginMaps[e.id]=e},enable:function(){T[this.map.id]=this;this.enabling=this.enabled=!0;y(this.depMaps,u(this,function(a,b){var c,d;if("string"===typeof a){a=n(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=l(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;s(a,"defined",u(this,function(a){this.defineDep(b, 23 | a);this.check()}));this.errback&&s(a,"error",u(this,this.errback))}c=a.id;d=p[c];!t(N,c)&&(d&&!d.enabled)&&i.enable(a,this)}));F(this.pluginMaps,u(this,function(a){var b=l(p,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){y(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:k,contextName:b,registry:p,defined:r,urlFetched:S,defQueue:G,Module:X,makeModuleMap:n, 24 | nextTick:j.nextTick,onError:v,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,d={paths:!0,config:!0,map:!0};F(a,function(a,b){d[b]?"map"===b?(k.map||(k.map={}),Q(k[b],a,!0,!0)):Q(k[b],a,!0):k[b]=a});a.shim&&(F(a.shim,function(a,b){I(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);c[b]=a}),k.shim=c);a.packages&&(y(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name, 25 | location:a.location||a.name,main:(a.main||"main").replace(ja,"").replace(ea,"")}}),k.pkgs=b);F(p,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=n(b))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(Z,arguments));return b||a.exports&&ba(a.exports)}},makeRequire:function(a,f){function h(d,c,e){var g,k;f.enableBuildCallback&&(c&&H(c))&&(c.__requireJsBuild=!0);if("string"===typeof d){if(H(c))return v(A("requireargs", 26 | "Invalid require call"),e);if(a&&t(N,d))return N[d](p[a.id]);if(j.get)return j.get(i,d,a,h);g=n(d,a,!1,!0);g=g.id;return!t(r,g)?v(A("notloaded",'Module name "'+g+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[g]}K();i.nextTick(function(){K();k=q(n(null,a));k.skipMap=f.skipMap;k.init(d,c,e,{enabled:!0});C()});return h}f=f||{};Q(h,{isBrowser:z,toUrl:function(b){var f,e=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==e&&(!("."===g||".."===g)||1h.attachEvent.toString().indexOf("[native code"))&&!W?(O=!0,h.attachEvent("onreadystatechange",b.onScriptLoad)):(h.addEventListener("load",b.onScriptLoad,!1),h.addEventListener("error", 34 | b.onScriptError,!1)),h.src=e,K=h,C?x.insertBefore(h,C):x.appendChild(h),K=null,h;if(da)try{importScripts(e),b.completeLoad(c)}catch(l){b.onError(A("importscripts","importScripts failed for "+c+" at "+e,l,[c]))}};z&&!s.skipDataMain&&M(document.getElementsByTagName("script"),function(b){x||(x=b.parentNode);if(J=b.getAttribute("data-main"))return q=J,s.baseUrl||(D=q.split("/"),q=D.pop(),fa=D.length?D.join("/")+"/":"./",s.baseUrl=fa),q=q.replace(ea,""),j.jsExtRegExp.test(q)&&(q=J),s.deps=s.deps?s.deps.concat(q): 35 | [q],!0});define=function(b,c,e){var h,j;"string"!==typeof b&&(e=c,c=b,b=null);I(c)||(e=c,c=null);!c&&H(e)&&(c=[],e.length&&(e.toString().replace(la,"").replace(ma,function(b,e){c.push(e)}),c=(1===e.length?["require"]:["require","exports","module"]).concat(c)));if(O){if(!(h=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),h=P;h&&(b||(b=h.getAttribute("data-requiremodule")),j=E[h.getAttribute("data-requirecontext")])}(j? 36 | j.defQueue:R).push([b,c,e])};define.amd={jQuery:!0};j.exec=function(b){return eval(b)};j(s)}})(this); 37 | -------------------------------------------------------------------------------- /source-map-support.js: -------------------------------------------------------------------------------- 1 | var SourceMapConsumer = require('source-map').SourceMapConsumer; 2 | var path = require('path'); 3 | 4 | var fs; 5 | try { 6 | fs = require('fs'); 7 | if (!fs.existsSync || !fs.readFileSync) { 8 | // fs doesn't have all methods we need 9 | fs = null; 10 | } 11 | } catch (err) { 12 | /* nop */ 13 | } 14 | 15 | // Only install once if called multiple times 16 | var errorFormatterInstalled = false; 17 | var uncaughtShimInstalled = false; 18 | 19 | // If true, the caches are reset before a stack trace formatting operation 20 | var emptyCacheBetweenOperations = false; 21 | 22 | // Supports {browser, node, auto} 23 | var environment = "auto"; 24 | 25 | // Maps a file path to a string containing the file contents 26 | var fileContentsCache = {}; 27 | 28 | // Maps a file path to a source map for that file 29 | var sourceMapCache = {}; 30 | 31 | // Regex for detecting source maps 32 | var reSourceMap = /^data:application\/json[^,]+base64,/; 33 | 34 | // Priority list of retrieve handlers 35 | var retrieveFileHandlers = []; 36 | var retrieveMapHandlers = []; 37 | 38 | function isInBrowser() { 39 | if (environment === "browser") 40 | return true; 41 | if (environment === "node") 42 | return false; 43 | return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function') && !(window.require && window.module && window.process && window.process.type === "renderer")); 44 | } 45 | 46 | function hasGlobalProcessEventEmitter() { 47 | return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function')); 48 | } 49 | 50 | function handlerExec(list) { 51 | return function(arg) { 52 | for (var i = 0; i < list.length; i++) { 53 | var ret = list[i](arg); 54 | if (ret) { 55 | return ret; 56 | } 57 | } 58 | return null; 59 | }; 60 | } 61 | 62 | var retrieveFile = handlerExec(retrieveFileHandlers); 63 | 64 | retrieveFileHandlers.push(function(path) { 65 | // Trim the path to make sure there is no extra whitespace. 66 | path = path.trim(); 67 | if (path.startsWith('file:')) { 68 | // existsSync/readFileSync can't handle file protocol, but once stripped, it works 69 | path = path.replace(/file:\/\/(\w:\\|\/)/, ''); 70 | } 71 | if (path in fileContentsCache) { 72 | return fileContentsCache[path]; 73 | } 74 | 75 | var contents = null; 76 | if (!fs) { 77 | // Use SJAX if we are in the browser 78 | var xhr = new XMLHttpRequest(); 79 | xhr.open('GET', path, false); 80 | xhr.send(null); 81 | var contents = null 82 | if (xhr.readyState === 4 && xhr.status === 200) { 83 | contents = xhr.responseText 84 | } 85 | } else if (fs.existsSync(path)) { 86 | // Otherwise, use the filesystem 87 | try { 88 | contents = fs.readFileSync(path, 'utf8'); 89 | } catch (er) { 90 | contents = ''; 91 | } 92 | } 93 | 94 | return fileContentsCache[path] = contents; 95 | }); 96 | 97 | // Support URLs relative to a directory, but be careful about a protocol prefix 98 | // in case we are in the browser (i.e. directories may start with "http://" or "file:///") 99 | function supportRelativeURL(file, url) { 100 | if (!file) return url; 101 | var dir = path.dirname(file); 102 | var match = /^\w+:\/\/[^\/]*/.exec(dir); 103 | var protocol = match ? match[0] : ''; 104 | var startPath = dir.slice(protocol.length); 105 | if (protocol && /^\/\w\:/.test(startPath)) { 106 | // handle file:///C:/ paths 107 | protocol += '/'; 108 | return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/'); 109 | } 110 | return protocol + path.resolve(dir.slice(protocol.length), url); 111 | } 112 | 113 | function retrieveSourceMapURL(source) { 114 | var fileData; 115 | 116 | if (isInBrowser()) { 117 | try { 118 | var xhr = new XMLHttpRequest(); 119 | xhr.open('GET', source, false); 120 | xhr.send(null); 121 | fileData = xhr.readyState === 4 ? xhr.responseText : null; 122 | 123 | // Support providing a sourceMappingURL via the SourceMap header 124 | var sourceMapHeader = xhr.getResponseHeader("SourceMap") || 125 | xhr.getResponseHeader("X-SourceMap"); 126 | if (sourceMapHeader) { 127 | return sourceMapHeader; 128 | } 129 | } catch (e) { 130 | } 131 | } 132 | 133 | // Get the URL of the source map 134 | fileData = retrieveFile(source); 135 | var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/)[ \t]*$)/mg; 136 | // Keep executing the search to find the *last* sourceMappingURL to avoid 137 | // picking up sourceMappingURLs from comments, strings, etc. 138 | var lastMatch, match; 139 | while (match = re.exec(fileData)) lastMatch = match; 140 | if (!lastMatch) return null; 141 | return lastMatch[1]; 142 | }; 143 | 144 | // Can be overridden by the retrieveSourceMap option to install. Takes a 145 | // generated source filename; returns a {map, optional url} object, or null if 146 | // there is no source map. The map field may be either a string or the parsed 147 | // JSON object (ie, it must be a valid argument to the SourceMapConsumer 148 | // constructor). 149 | var retrieveSourceMap = handlerExec(retrieveMapHandlers); 150 | retrieveMapHandlers.push(function(source) { 151 | var sourceMappingURL = retrieveSourceMapURL(source); 152 | if (!sourceMappingURL) return null; 153 | 154 | // Read the contents of the source map 155 | var sourceMapData; 156 | if (reSourceMap.test(sourceMappingURL)) { 157 | // Support source map URL as a data url 158 | var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1); 159 | sourceMapData = new Buffer(rawData, "base64").toString(); 160 | sourceMappingURL = source; 161 | } else { 162 | // Support source map URLs relative to the source URL 163 | sourceMappingURL = supportRelativeURL(source, sourceMappingURL); 164 | sourceMapData = retrieveFile(sourceMappingURL); 165 | } 166 | 167 | if (!sourceMapData) { 168 | return null; 169 | } 170 | 171 | return { 172 | url: sourceMappingURL, 173 | map: sourceMapData 174 | }; 175 | }); 176 | 177 | function mapSourcePosition(position) { 178 | var sourceMap = sourceMapCache[position.source]; 179 | if (!sourceMap) { 180 | // Call the (overrideable) retrieveSourceMap function to get the source map. 181 | var urlAndMap = retrieveSourceMap(position.source); 182 | if (urlAndMap) { 183 | sourceMap = sourceMapCache[position.source] = { 184 | url: urlAndMap.url, 185 | map: new SourceMapConsumer(urlAndMap.map) 186 | }; 187 | 188 | // Load all sources stored inline with the source map into the file cache 189 | // to pretend like they are already loaded. They may not exist on disk. 190 | if (sourceMap.map.sourcesContent) { 191 | sourceMap.map.sources.forEach(function(source, i) { 192 | var contents = sourceMap.map.sourcesContent[i]; 193 | if (contents) { 194 | var url = supportRelativeURL(sourceMap.url, source); 195 | fileContentsCache[url] = contents; 196 | } 197 | }); 198 | } 199 | } else { 200 | sourceMap = sourceMapCache[position.source] = { 201 | url: null, 202 | map: null 203 | }; 204 | } 205 | } 206 | 207 | // Resolve the source URL relative to the URL of the source map 208 | if (sourceMap && sourceMap.map) { 209 | var originalPosition = sourceMap.map.originalPositionFor(position); 210 | 211 | // Only return the original position if a matching line was found. If no 212 | // matching line is found then we return position instead, which will cause 213 | // the stack trace to print the path and line for the compiled file. It is 214 | // better to give a precise location in the compiled file than a vague 215 | // location in the original file. 216 | if (originalPosition.source !== null) { 217 | originalPosition.source = supportRelativeURL( 218 | sourceMap.url, originalPosition.source); 219 | return originalPosition; 220 | } 221 | } 222 | 223 | return position; 224 | } 225 | 226 | // Parses code generated by FormatEvalOrigin(), a function inside V8: 227 | // https://code.google.com/p/v8/source/browse/trunk/src/messages.js 228 | function mapEvalOrigin(origin) { 229 | // Most eval() calls are in this format 230 | var match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin); 231 | if (match) { 232 | var position = mapSourcePosition({ 233 | source: match[2], 234 | line: +match[3], 235 | column: match[4] - 1 236 | }); 237 | return 'eval at ' + match[1] + ' (' + position.source + ':' + 238 | position.line + ':' + (position.column + 1) + ')'; 239 | } 240 | 241 | // Parse nested eval() calls using recursion 242 | match = /^eval at ([^(]+) \((.+)\)$/.exec(origin); 243 | if (match) { 244 | return 'eval at ' + match[1] + ' (' + mapEvalOrigin(match[2]) + ')'; 245 | } 246 | 247 | // Make sure we still return useful information if we didn't find anything 248 | return origin; 249 | } 250 | 251 | // This is copied almost verbatim from the V8 source code at 252 | // https://code.google.com/p/v8/source/browse/trunk/src/messages.js. The 253 | // implementation of wrapCallSite() used to just forward to the actual source 254 | // code of CallSite.prototype.toString but unfortunately a new release of V8 255 | // did something to the prototype chain and broke the shim. The only fix I 256 | // could find was copy/paste. 257 | function CallSiteToString() { 258 | var fileName; 259 | var fileLocation = ""; 260 | if (this.isNative()) { 261 | fileLocation = "native"; 262 | } else { 263 | fileName = this.getScriptNameOrSourceURL(); 264 | if (!fileName && this.isEval()) { 265 | fileLocation = this.getEvalOrigin(); 266 | fileLocation += ", "; // Expecting source position to follow. 267 | } 268 | 269 | if (fileName) { 270 | fileLocation += fileName; 271 | } else { 272 | // Source code does not originate from a file and is not native, but we 273 | // can still get the source position inside the source string, e.g. in 274 | // an eval string. 275 | fileLocation += ""; 276 | } 277 | var lineNumber = this.getLineNumber(); 278 | if (lineNumber != null) { 279 | fileLocation += ":" + lineNumber; 280 | var columnNumber = this.getColumnNumber(); 281 | if (columnNumber) { 282 | fileLocation += ":" + columnNumber; 283 | } 284 | } 285 | } 286 | 287 | var line = ""; 288 | var functionName = this.getFunctionName(); 289 | var addSuffix = true; 290 | var isConstructor = this.isConstructor(); 291 | var isMethodCall = !(this.isToplevel() || isConstructor); 292 | if (isMethodCall) { 293 | var typeName = this.getTypeName(); 294 | // Fixes shim to be backward compatable with Node v0 to v4 295 | if (typeName === "[object Object]") { 296 | typeName = "null"; 297 | } 298 | var methodName = this.getMethodName(); 299 | if (functionName) { 300 | if (typeName && functionName.indexOf(typeName) != 0) { 301 | line += typeName + "."; 302 | } 303 | line += functionName; 304 | if (methodName && functionName.indexOf("." + methodName) != functionName.length - methodName.length - 1) { 305 | line += " [as " + methodName + "]"; 306 | } 307 | } else { 308 | line += typeName + "." + (methodName || ""); 309 | } 310 | } else if (isConstructor) { 311 | line += "new " + (functionName || ""); 312 | } else if (functionName) { 313 | line += functionName; 314 | } else { 315 | line += fileLocation; 316 | addSuffix = false; 317 | } 318 | if (addSuffix) { 319 | line += " (" + fileLocation + ")"; 320 | } 321 | return line; 322 | } 323 | 324 | function cloneCallSite(frame) { 325 | var object = {}; 326 | Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) { 327 | object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name]; 328 | }); 329 | object.toString = CallSiteToString; 330 | return object; 331 | } 332 | 333 | function wrapCallSite(frame) { 334 | if(frame.isNative()) { 335 | return frame; 336 | } 337 | 338 | // Most call sites will return the source file from getFileName(), but code 339 | // passed to eval() ending in "//# sourceURL=..." will return the source file 340 | // from getScriptNameOrSourceURL() instead 341 | var source = frame.getFileName() || frame.getScriptNameOrSourceURL(); 342 | if (source) { 343 | var line = frame.getLineNumber(); 344 | var column = frame.getColumnNumber() - 1; 345 | 346 | // Fix position in Node where some (internal) code is prepended. 347 | // See https://github.com/evanw/node-source-map-support/issues/36 348 | var headerLength = 62; 349 | if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) { 350 | column -= headerLength; 351 | } 352 | 353 | var position = mapSourcePosition({ 354 | source: source, 355 | line: line, 356 | column: column 357 | }); 358 | frame = cloneCallSite(frame); 359 | frame.getFileName = function() { return position.source; }; 360 | frame.getLineNumber = function() { return position.line; }; 361 | frame.getColumnNumber = function() { return position.column + 1; }; 362 | frame.getScriptNameOrSourceURL = function() { return position.source; }; 363 | return frame; 364 | } 365 | 366 | // Code called using eval() needs special handling 367 | var origin = frame.isEval() && frame.getEvalOrigin(); 368 | if (origin) { 369 | origin = mapEvalOrigin(origin); 370 | frame = cloneCallSite(frame); 371 | frame.getEvalOrigin = function() { return origin; }; 372 | return frame; 373 | } 374 | 375 | // If we get here then we were unable to change the source position 376 | return frame; 377 | } 378 | 379 | // This function is part of the V8 stack trace API, for more info see: 380 | // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi 381 | function prepareStackTrace(error, stack) { 382 | if (emptyCacheBetweenOperations) { 383 | fileContentsCache = {}; 384 | sourceMapCache = {}; 385 | } 386 | 387 | return error + stack.map(function(frame) { 388 | return '\n at ' + wrapCallSite(frame); 389 | }).join(''); 390 | } 391 | 392 | // Generate position and snippet of original source with pointer 393 | function getErrorSource(error) { 394 | var match = /\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack); 395 | if (match) { 396 | var source = match[1]; 397 | var line = +match[2]; 398 | var column = +match[3]; 399 | 400 | // Support the inline sourceContents inside the source map 401 | var contents = fileContentsCache[source]; 402 | 403 | // Support files on disk 404 | if (!contents && fs && fs.existsSync(source)) { 405 | try { 406 | contents = fs.readFileSync(source, 'utf8'); 407 | } catch (er) { 408 | contents = ''; 409 | } 410 | } 411 | 412 | // Format the line from the original source code like node does 413 | if (contents) { 414 | var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1]; 415 | if (code) { 416 | return source + ':' + line + '\n' + code + '\n' + 417 | new Array(column).join(' ') + '^'; 418 | } 419 | } 420 | } 421 | return null; 422 | } 423 | 424 | function printErrorAndExit (error) { 425 | var source = getErrorSource(error); 426 | 427 | if (source) { 428 | console.error(); 429 | console.error(source); 430 | } 431 | 432 | console.error(error.stack); 433 | process.exit(1); 434 | } 435 | 436 | function shimEmitUncaughtException () { 437 | var origEmit = process.emit; 438 | 439 | process.emit = function (type) { 440 | if (type === 'uncaughtException') { 441 | var hasStack = (arguments[1] && arguments[1].stack); 442 | var hasListeners = (this.listeners(type).length > 0); 443 | 444 | if (hasStack && !hasListeners) { 445 | return printErrorAndExit(arguments[1]); 446 | } 447 | } 448 | 449 | return origEmit.apply(this, arguments); 450 | }; 451 | } 452 | 453 | exports.wrapCallSite = wrapCallSite; 454 | exports.getErrorSource = getErrorSource; 455 | exports.mapSourcePosition = mapSourcePosition; 456 | exports.retrieveSourceMap = retrieveSourceMap; 457 | 458 | exports.install = function(options) { 459 | options = options || {}; 460 | 461 | if (options.environment) { 462 | environment = options.environment; 463 | if (["node", "browser", "auto"].indexOf(environment) === -1) { 464 | throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}") 465 | } 466 | } 467 | 468 | // Allow sources to be found by methods other than reading the files 469 | // directly from disk. 470 | if (options.retrieveFile) { 471 | if (options.overrideRetrieveFile) { 472 | retrieveFileHandlers.length = 0; 473 | } 474 | 475 | retrieveFileHandlers.unshift(options.retrieveFile); 476 | } 477 | 478 | // Allow source maps to be found by methods other than reading the files 479 | // directly from disk. 480 | if (options.retrieveSourceMap) { 481 | if (options.overrideRetrieveSourceMap) { 482 | retrieveMapHandlers.length = 0; 483 | } 484 | 485 | retrieveMapHandlers.unshift(options.retrieveSourceMap); 486 | } 487 | 488 | // Support runtime transpilers that include inline source maps 489 | if (options.hookRequire && !isInBrowser()) { 490 | var Module; 491 | try { 492 | Module = require('module'); 493 | } catch (err) { 494 | // NOP: Loading in catch block to convert webpack error to warning. 495 | } 496 | var $compile = Module.prototype._compile; 497 | 498 | if (!$compile.__sourceMapSupport) { 499 | Module.prototype._compile = function(content, filename) { 500 | fileContentsCache[filename] = content; 501 | sourceMapCache[filename] = undefined; 502 | return $compile.call(this, content, filename); 503 | }; 504 | 505 | Module.prototype._compile.__sourceMapSupport = true; 506 | } 507 | } 508 | 509 | // Configure options 510 | if (!emptyCacheBetweenOperations) { 511 | emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ? 512 | options.emptyCacheBetweenOperations : false; 513 | } 514 | 515 | // Install the error reformatter 516 | if (!errorFormatterInstalled) { 517 | errorFormatterInstalled = true; 518 | Error.prepareStackTrace = prepareStackTrace; 519 | } 520 | 521 | if (!uncaughtShimInstalled) { 522 | var installHandler = 'handleUncaughtExceptions' in options ? 523 | options.handleUncaughtExceptions : true; 524 | 525 | // Provide the option to not install the uncaught exception handler. This is 526 | // to support other uncaught exception handlers (in test frameworks, for 527 | // example). If this handler is not installed and there are no other uncaught 528 | // exception handlers, uncaught exceptions will be caught by node's built-in 529 | // exception handler and the process will still be terminated. However, the 530 | // generated JavaScript code will be shown above the stack trace instead of 531 | // the original source code. 532 | if (installHandler && hasGlobalProcessEventEmitter()) { 533 | uncaughtShimInstalled = true; 534 | shimEmitUncaughtException(); 535 | } 536 | } 537 | }; 538 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | require('./source-map-support').install({ 2 | emptyCacheBetweenOperations: true // Needed to be able to test for failure 3 | }); 4 | 5 | var SourceMapGenerator = require('source-map').SourceMapGenerator; 6 | var child_process = require('child_process'); 7 | var assert = require('assert'); 8 | var fs = require('fs'); 9 | 10 | function compareLines(actual, expected) { 11 | assert(actual.length >= expected.length, 'got ' + actual.length + ' lines but expected at least ' + expected.length + ' lines'); 12 | for (var i = 0; i < expected.length; i++) { 13 | // Some tests are regular expressions because the output format changed slightly between node v0.9.2 and v0.9.3 14 | if (expected[i] instanceof RegExp) { 15 | assert(expected[i].test(actual[i]), JSON.stringify(actual[i]) + ' does not match ' + expected[i]); 16 | } else { 17 | assert.equal(actual[i], expected[i]); 18 | } 19 | } 20 | } 21 | 22 | function createEmptySourceMap() { 23 | return new SourceMapGenerator({ 24 | file: '.generated.js', 25 | sourceRoot: '.' 26 | }); 27 | } 28 | 29 | function createSourceMapWithGap() { 30 | var sourceMap = createEmptySourceMap(); 31 | sourceMap.addMapping({ 32 | generated: { line: 100, column: 0 }, 33 | original: { line: 100, column: 0 }, 34 | source: '.original.js' 35 | }); 36 | return sourceMap; 37 | } 38 | 39 | function createSingleLineSourceMap() { 40 | var sourceMap = createEmptySourceMap(); 41 | sourceMap.addMapping({ 42 | generated: { line: 1, column: 0 }, 43 | original: { line: 1, column: 0 }, 44 | source: '.original.js' 45 | }); 46 | return sourceMap; 47 | } 48 | 49 | function createSecondLineSourceMap() { 50 | var sourceMap = createEmptySourceMap(); 51 | sourceMap.addMapping({ 52 | generated: { line: 2, column: 0 }, 53 | original: { line: 1, column: 0 }, 54 | source: '.original.js' 55 | }); 56 | return sourceMap; 57 | } 58 | 59 | function createMultiLineSourceMap() { 60 | var sourceMap = createEmptySourceMap(); 61 | for (var i = 1; i <= 100; i++) { 62 | sourceMap.addMapping({ 63 | generated: { line: i, column: 0 }, 64 | original: { line: 1000 + i, column: 99 + i }, 65 | source: 'line' + i + '.js' 66 | }); 67 | } 68 | return sourceMap; 69 | } 70 | 71 | function createMultiLineSourceMapWithSourcesContent() { 72 | var sourceMap = createEmptySourceMap(); 73 | var original = new Array(1001).join('\n'); 74 | for (var i = 1; i <= 100; i++) { 75 | sourceMap.addMapping({ 76 | generated: { line: i, column: 0 }, 77 | original: { line: 1000 + i, column: 4 }, 78 | source: 'original.js' 79 | }); 80 | original += ' line ' + i + '\n'; 81 | } 82 | sourceMap.setSourceContent('original.js', original); 83 | return sourceMap; 84 | } 85 | 86 | function compareStackTrace(sourceMap, source, expected) { 87 | // Check once with a separate source map 88 | fs.writeFileSync('.generated.js.map', sourceMap); 89 | fs.writeFileSync('.generated.js', 'exports.test = function() {' + 90 | source.join('\n') + '};//@ sourceMappingURL=.generated.js.map'); 91 | try { 92 | delete require.cache[require.resolve('./.generated')]; 93 | require('./.generated').test(); 94 | } catch (e) { 95 | compareLines(e.stack.split(/\r\n|\n/), expected); 96 | } 97 | fs.unlinkSync('.generated.js'); 98 | fs.unlinkSync('.generated.js.map'); 99 | 100 | // Check again with an inline source map (in a data URL) 101 | fs.writeFileSync('.generated.js', 'exports.test = function() {' + 102 | source.join('\n') + '};//@ sourceMappingURL=data:application/json;base64,' + 103 | new Buffer(sourceMap.toString()).toString('base64')); 104 | try { 105 | delete require.cache[require.resolve('./.generated')]; 106 | require('./.generated').test(); 107 | } catch (e) { 108 | compareLines(e.stack.split(/\r\n|\n/), expected); 109 | } 110 | fs.unlinkSync('.generated.js'); 111 | } 112 | 113 | function compareStdout(done, sourceMap, source, expected) { 114 | fs.writeFileSync('.original.js', 'this is the original code'); 115 | fs.writeFileSync('.generated.js.map', sourceMap); 116 | fs.writeFileSync('.generated.js', source.join('\n') + 117 | '//@ sourceMappingURL=.generated.js.map'); 118 | child_process.exec('node ./.generated', function(error, stdout, stderr) { 119 | try { 120 | compareLines( 121 | (stdout + stderr) 122 | .trim() 123 | .split(/\r\n|\n/) 124 | .filter(function (line) { return line !== '' }), // Empty lines are not relevant. 125 | expected 126 | ); 127 | } catch (e) { 128 | return done(e); 129 | } 130 | fs.unlinkSync('.generated.js'); 131 | fs.unlinkSync('.generated.js.map'); 132 | fs.unlinkSync('.original.js'); 133 | done(); 134 | }); 135 | } 136 | 137 | it('normal throw', function() { 138 | compareStackTrace(createMultiLineSourceMap(), [ 139 | 'throw new Error("test");' 140 | ], [ 141 | 'Error: test', 142 | /^ at Object\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/ 143 | ]); 144 | }); 145 | 146 | /* The following test duplicates some of the code in 147 | * `normal throw` but triggers file read failure. 148 | */ 149 | it('fs.readFileSync failure', function() { 150 | compareStackTrace(createMultiLineSourceMap(), [ 151 | 'var fs = require("fs");', 152 | 'var rfs = fs.readFileSync;', 153 | 'fs.readFileSync = function() {', 154 | ' throw new Error("no rfs for you");', 155 | '};', 156 | 'try {', 157 | ' throw new Error("test");', 158 | '} finally {', 159 | ' fs.readFileSync = rfs;', 160 | '}' 161 | ], [ 162 | 'Error: test', 163 | /^ at Object\.exports\.test \((?:.*[/\\])?line7\.js:1007:107\)$/ 164 | ]); 165 | }); 166 | 167 | 168 | it('throw inside function', function() { 169 | compareStackTrace(createMultiLineSourceMap(), [ 170 | 'function foo() {', 171 | ' throw new Error("test");', 172 | '}', 173 | 'foo();' 174 | ], [ 175 | 'Error: test', 176 | /^ at foo \((?:.*[/\\])?line2\.js:1002:102\)$/, 177 | /^ at Object\.exports\.test \((?:.*[/\\])?line4\.js:1004:104\)$/ 178 | ]); 179 | }); 180 | 181 | it('throw inside function inside function', function() { 182 | compareStackTrace(createMultiLineSourceMap(), [ 183 | 'function foo() {', 184 | ' function bar() {', 185 | ' throw new Error("test");', 186 | ' }', 187 | ' bar();', 188 | '}', 189 | 'foo();' 190 | ], [ 191 | 'Error: test', 192 | /^ at bar \((?:.*[/\\])?line3\.js:1003:103\)$/, 193 | /^ at foo \((?:.*[/\\])?line5\.js:1005:105\)$/, 194 | /^ at Object\.exports\.test \((?:.*[/\\])?line7\.js:1007:107\)$/ 195 | ]); 196 | }); 197 | 198 | it('eval', function() { 199 | compareStackTrace(createMultiLineSourceMap(), [ 200 | 'eval("throw new Error(\'test\')");' 201 | ], [ 202 | 'Error: test', 203 | 204 | // Before Node 4, `Object.eval`, after just `eval`. 205 | /^ at (?:Object\.)?eval \(eval at (|exports.test) \((?:.*[/\\])?line1\.js:1001:101\)/, 206 | 207 | /^ at Object\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/ 208 | ]); 209 | }); 210 | 211 | it('eval inside eval', function() { 212 | compareStackTrace(createMultiLineSourceMap(), [ 213 | 'eval("eval(\'throw new Error(\\"test\\")\')");' 214 | ], [ 215 | 'Error: test', 216 | /^ at (?:Object\.)?eval \(eval at (|exports.test) \(eval at (|exports.test) \((?:.*[/\\])?line1\.js:1001:101\)/, 217 | /^ at (?:Object\.)?eval \(eval at (|exports.test) \((?:.*[/\\])?line1\.js:1001:101\)/, 218 | /^ at Object\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/ 219 | ]); 220 | }); 221 | 222 | it('eval inside function', function() { 223 | compareStackTrace(createMultiLineSourceMap(), [ 224 | 'function foo() {', 225 | ' eval("throw new Error(\'test\')");', 226 | '}', 227 | 'foo();' 228 | ], [ 229 | 'Error: test', 230 | /^ at eval \(eval at foo \((?:.*[/\\])?line2\.js:1002:102\)/, 231 | /^ at foo \((?:.*[/\\])?line2\.js:1002:102\)/, 232 | /^ at Object\.exports\.test \((?:.*[/\\])?line4\.js:1004:104\)$/ 233 | ]); 234 | }); 235 | 236 | it('eval with sourceURL', function() { 237 | compareStackTrace(createMultiLineSourceMap(), [ 238 | 'eval("throw new Error(\'test\')//@ sourceURL=sourceURL.js");' 239 | ], [ 240 | 'Error: test', 241 | /^ at (?:Object\.)?eval \(sourceURL\.js:1:7\)$/, 242 | /^ at Object\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/ 243 | ]); 244 | }); 245 | 246 | it('eval with sourceURL inside eval', function() { 247 | compareStackTrace(createMultiLineSourceMap(), [ 248 | 'eval("eval(\'throw new Error(\\"test\\")//@ sourceURL=sourceURL.js\')");' 249 | ], [ 250 | 'Error: test', 251 | /^ at (?:Object\.)?eval \(sourceURL\.js:1:7\)$/, 252 | /^ at (?:Object\.)?eval \(eval at (|exports.test) \((?:.*[/\\])?line1\.js:1001:101\)/, 253 | /^ at Object\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/ 254 | ]); 255 | }); 256 | 257 | it('native function', function() { 258 | compareStackTrace(createSingleLineSourceMap(), [ 259 | '[1].map(function(x) { throw new Error(x); });' 260 | ], [ 261 | 'Error: 1', 262 | /[/\\].original\.js/, 263 | /at Array\.map \((native|)\)/ 264 | ]); 265 | }); 266 | 267 | it('function constructor', function() { 268 | compareStackTrace(createMultiLineSourceMap(), [ 269 | 'throw new Function(")");' 270 | ], [ 271 | 'SyntaxError: Unexpected token )', 272 | ]); 273 | }); 274 | 275 | it('throw with empty source map', function() { 276 | compareStackTrace(createEmptySourceMap(), [ 277 | 'throw new Error("test");' 278 | ], [ 279 | 'Error: test', 280 | /^ at Object\.exports\.test \((?:.*[/\\])?.generated.js:1:34\)$/ 281 | ]); 282 | }); 283 | 284 | it('throw in Timeout with empty source map', function(done) { 285 | compareStdout(done, createEmptySourceMap(), [ 286 | 'require("./source-map-support").install();', 287 | 'setTimeout(function () {', 288 | ' throw new Error("this is the error")', 289 | '})' 290 | ], [ 291 | /[/\\].generated.js:3$/, 292 | ' throw new Error("this is the error")', 293 | /^ \^$/, 294 | 'Error: this is the error', 295 | /^ at ((null)|(Timeout))\._onTimeout \((?:.*[/\\])?.generated.js:3:11\)$/ 296 | ]); 297 | }); 298 | 299 | it('throw with source map with gap', function() { 300 | compareStackTrace(createSourceMapWithGap(), [ 301 | 'throw new Error("test");' 302 | ], [ 303 | 'Error: test', 304 | /^ at Object\.exports\.test \((?:.*[/\\])?.generated.js:1:34\)$/ 305 | ]); 306 | }); 307 | 308 | it('sourcesContent with data URL', function() { 309 | compareStackTrace(createMultiLineSourceMapWithSourcesContent(), [ 310 | 'throw new Error("test");' 311 | ], [ 312 | 'Error: test', 313 | /^ at Object\.exports\.test \((?:.*[/\\])?original.js:1001:5\)$/ 314 | ]); 315 | }); 316 | 317 | it('finds the last sourceMappingURL', function() { 318 | compareStackTrace(createMultiLineSourceMapWithSourcesContent(), [ 319 | '//# sourceMappingURL=missing.map.js', // NB: compareStackTrace adds another source mapping. 320 | 'throw new Error("test");' 321 | ], [ 322 | 'Error: test', 323 | /^ at Object\.exports\.test \((?:.*[/\\])?original.js:1002:5\)$/ 324 | ]); 325 | }); 326 | 327 | it('default options', function(done) { 328 | compareStdout(done, createSecondLineSourceMap(), [ 329 | '', 330 | 'function foo() { throw new Error("this is the error"); }', 331 | 'require("./source-map-support").install();', 332 | 'process.nextTick(foo);', 333 | 'process.nextTick(function() { process.exit(1); });' 334 | ], [ 335 | /[/\\].original\.js:1$/, 336 | 'this is the original code', 337 | '^', 338 | 'Error: this is the error', 339 | /^ at foo \((?:.*[/\\])?.original\.js:1:1\)$/ 340 | ]); 341 | }); 342 | 343 | it('handleUncaughtExceptions is true', function(done) { 344 | compareStdout(done, createSecondLineSourceMap(), [ 345 | '', 346 | 'function foo() { throw new Error("this is the error"); }', 347 | 'require("./source-map-support").install({ handleUncaughtExceptions: true });', 348 | 'process.nextTick(foo);' 349 | ], [ 350 | /[/\\].original\.js:1$/, 351 | 'this is the original code', 352 | '^', 353 | 'Error: this is the error', 354 | /^ at foo \((?:.*[/\\])?.original\.js:1:1\)$/ 355 | ]); 356 | }); 357 | 358 | it('handleUncaughtExceptions is false', function(done) { 359 | compareStdout(done, createSecondLineSourceMap(), [ 360 | '', 361 | 'function foo() { throw new Error("this is the error"); }', 362 | 'require("./source-map-support").install({ handleUncaughtExceptions: false });', 363 | 'process.nextTick(foo);' 364 | ], [ 365 | /[/\\].generated.js:2$/, 366 | 'function foo() { throw new Error("this is the error"); }', 367 | 368 | // Before Node 4, the arrow points on the `new`, after on the 369 | // `throw`. 370 | /^ (?: )?\^$/, 371 | 372 | 'Error: this is the error', 373 | /^ at foo \((?:.*[/\\])?.original\.js:1:1\)$/ 374 | ]); 375 | }); 376 | 377 | it('default options with empty source map', function(done) { 378 | compareStdout(done, createEmptySourceMap(), [ 379 | '', 380 | 'function foo() { throw new Error("this is the error"); }', 381 | 'require("./source-map-support").install();', 382 | 'process.nextTick(foo);' 383 | ], [ 384 | /[/\\].generated.js:2$/, 385 | 'function foo() { throw new Error("this is the error"); }', 386 | /^ (?: )?\^$/, 387 | 'Error: this is the error', 388 | /^ at foo \((?:.*[/\\])?.generated.js:2:24\)$/ 389 | ]); 390 | }); 391 | 392 | it('default options with source map with gap', function(done) { 393 | compareStdout(done, createSourceMapWithGap(), [ 394 | '', 395 | 'function foo() { throw new Error("this is the error"); }', 396 | 'require("./source-map-support").install();', 397 | 'process.nextTick(foo);' 398 | ], [ 399 | /[/\\].generated.js:2$/, 400 | 'function foo() { throw new Error("this is the error"); }', 401 | /^ (?: )?\^$/, 402 | 'Error: this is the error', 403 | /^ at foo \((?:.*[/\\])?.generated.js:2:24\)$/ 404 | ]); 405 | }); 406 | 407 | it('specifically requested error source', function(done) { 408 | compareStdout(done, createSecondLineSourceMap(), [ 409 | '', 410 | 'function foo() { throw new Error("this is the error"); }', 411 | 'var sms = require("./source-map-support");', 412 | 'sms.install({ handleUncaughtExceptions: false });', 413 | 'process.on("uncaughtException", function (e) { console.log("SRC:" + sms.getErrorSource(e)); });', 414 | 'process.nextTick(foo);' 415 | ], [ 416 | /^SRC:.*[/\\].original.js:1$/, 417 | 'this is the original code', 418 | '^' 419 | ]); 420 | }); 421 | 422 | it('sourcesContent', function(done) { 423 | compareStdout(done, createMultiLineSourceMapWithSourcesContent(), [ 424 | '', 425 | 'function foo() { throw new Error("this is the error"); }', 426 | 'require("./source-map-support").install();', 427 | 'process.nextTick(foo);', 428 | 'process.nextTick(function() { process.exit(1); });' 429 | ], [ 430 | /[/\\]original\.js:1002$/, 431 | ' line 2', 432 | ' ^', 433 | 'Error: this is the error', 434 | /^ at foo \((?:.*[/\\])?original\.js:1002:5\)$/ 435 | ]); 436 | }); 437 | 438 | it('missing source maps should also be cached', function(done) { 439 | compareStdout(done, createSingleLineSourceMap(), [ 440 | '', 441 | 'var count = 0;', 442 | 'function foo() {', 443 | ' console.log(new Error("this is the error").stack.split("\\n").slice(0, 2).join("\\n"));', 444 | '}', 445 | 'require("./source-map-support").install({', 446 | ' overrideRetrieveSourceMap: true,', 447 | ' retrieveSourceMap: function(name) {', 448 | ' if (/\\.generated.js$/.test(name)) count++;', 449 | ' return null;', 450 | ' }', 451 | '});', 452 | 'process.nextTick(foo);', 453 | 'process.nextTick(foo);', 454 | 'process.nextTick(function() { console.log(count); });', 455 | ], [ 456 | 'Error: this is the error', 457 | /^ at foo \((?:.*[/\\])?.generated.js:4:15\)$/, 458 | 'Error: this is the error', 459 | /^ at foo \((?:.*[/\\])?.generated.js:4:15\)$/, 460 | '1', // The retrieval should only be attempted once 461 | ]); 462 | }); 463 | 464 | it('should consult all retrieve source map providers', function(done) { 465 | compareStdout(done, createSingleLineSourceMap(), [ 466 | '', 467 | 'var count = 0;', 468 | 'function foo() {', 469 | ' console.log(new Error("this is the error").stack.split("\\n").slice(0, 2).join("\\n"));', 470 | '}', 471 | 'require("./source-map-support").install({', 472 | ' retrieveSourceMap: function(name) {', 473 | ' if (/\\.generated.js$/.test(name)) count++;', 474 | ' return undefined;', 475 | ' }', 476 | '});', 477 | 'require("./source-map-support").install({', 478 | ' retrieveSourceMap: function(name) {', 479 | ' if (/\\.generated.js$/.test(name)) {', 480 | ' count++;', 481 | ' return ' + JSON.stringify({url: '.original.js', map: createMultiLineSourceMapWithSourcesContent().toJSON()}) + ';', 482 | ' }', 483 | ' }', 484 | '});', 485 | 'process.nextTick(foo);', 486 | 'process.nextTick(foo);', 487 | 'process.nextTick(function() { console.log(count); });', 488 | ], [ 489 | 'Error: this is the error', 490 | /^ at foo \((?:.*[/\\])?original.js:1004:5\)$/, 491 | 'Error: this is the error', 492 | /^ at foo \((?:.*[/\\])?original.js:1004:5\)$/, 493 | '1', // The retrieval should only be attempted once 494 | ]); 495 | }); 496 | 497 | it('should allow for runtime inline source maps', function(done) { 498 | var sourceMap = createMultiLineSourceMapWithSourcesContent(); 499 | 500 | fs.writeFileSync('.generated.jss', 'foo'); 501 | 502 | compareStdout(function(err) { 503 | fs.unlinkSync('.generated.jss'); 504 | done(err); 505 | }, createSingleLineSourceMap(), [ 506 | 'require("./source-map-support").install({', 507 | ' hookRequire: true', 508 | '});', 509 | 'require.extensions[".jss"] = function(module, filename) {', 510 | ' module._compile(', 511 | JSON.stringify([ 512 | '', 513 | 'var count = 0;', 514 | 'function foo() {', 515 | ' console.log(new Error("this is the error").stack.split("\\n").slice(0, 2).join("\\n"));', 516 | '}', 517 | 'process.nextTick(foo);', 518 | 'process.nextTick(foo);', 519 | 'process.nextTick(function() { console.log(count); });', 520 | '//@ sourceMappingURL=data:application/json;charset=utf8;base64,' + new Buffer(sourceMap.toString()).toString('base64') 521 | ].join('\n')), 522 | ', filename);', 523 | '};', 524 | 'require("./.generated.jss");', 525 | ], [ 526 | 'Error: this is the error', 527 | /^ at foo \(.*[/\\]original.js:1004:5\)$/, 528 | 'Error: this is the error', 529 | /^ at foo \(.*[/\\]original.js:1004:5\)$/, 530 | '0', // The retrieval should only be attempted once 531 | ]); 532 | }); 533 | 534 | /* The following test duplicates some of the code in 535 | * `compareStackTrace` but appends a charset to the 536 | * source mapping url. 537 | */ 538 | it('finds source maps with charset specified', function() { 539 | var sourceMap = createMultiLineSourceMap() 540 | var source = [ 'throw new Error("test");' ]; 541 | var expected = [ 542 | 'Error: test', 543 | /^ at Object\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/ 544 | ]; 545 | 546 | fs.writeFileSync('.generated.js', 'exports.test = function() {' + 547 | source.join('\n') + '};//@ sourceMappingURL=data:application/json;charset=utf8;base64,' + 548 | new Buffer(sourceMap.toString()).toString('base64')); 549 | try { 550 | delete require.cache[require.resolve('./.generated')]; 551 | require('./.generated').test(); 552 | } catch (e) { 553 | compareLines(e.stack.split(/\r\n|\n/), expected); 554 | } 555 | fs.unlinkSync('.generated.js'); 556 | }); 557 | 558 | /* The following test duplicates some of the code in 559 | * `compareStackTrace` but appends some code and a 560 | * comment to the source mapping url. 561 | */ 562 | it('allows code/comments after sourceMappingURL', function() { 563 | var sourceMap = createMultiLineSourceMap() 564 | var source = [ 'throw new Error("test");' ]; 565 | var expected = [ 566 | 'Error: test', 567 | /^ at Object\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/ 568 | ]; 569 | 570 | fs.writeFileSync('.generated.js', 'exports.test = function() {' + 571 | source.join('\n') + '};//# sourceMappingURL=data:application/json;base64,' + 572 | new Buffer(sourceMap.toString()).toString('base64') + 573 | '\n// Some comment below the sourceMappingURL\nvar foo = 0;'); 574 | try { 575 | delete require.cache[require.resolve('./.generated')]; 576 | require('./.generated').test(); 577 | } catch (e) { 578 | compareLines(e.stack.split(/\r\n|\n/), expected); 579 | } 580 | fs.unlinkSync('.generated.js'); 581 | }); 582 | 583 | it('handleUncaughtExceptions is true with existing listener', function(done) { 584 | var source = [ 585 | 'process.on("uncaughtException", function() { /* Silent */ });', 586 | 'function foo() { throw new Error("this is the error"); }', 587 | 'require("./source-map-support").install();', 588 | 'process.nextTick(foo);', 589 | '//@ sourceMappingURL=.generated.js.map' 590 | ]; 591 | 592 | fs.writeFileSync('.original.js', 'this is the original code'); 593 | fs.writeFileSync('.generated.js.map', createSingleLineSourceMap()); 594 | fs.writeFileSync('.generated.js', source.join('\n')); 595 | 596 | child_process.exec('node ./.generated', function(error, stdout, stderr) { 597 | fs.unlinkSync('.generated.js'); 598 | fs.unlinkSync('.generated.js.map'); 599 | fs.unlinkSync('.original.js'); 600 | assert.equal((stdout + stderr).trim(), ''); 601 | done(); 602 | }); 603 | }); 604 | -------------------------------------------------------------------------------- /browser-source-map-support.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Support for source maps in V8 stack traces 3 | * https://github.com/evanw/node-source-map-support 4 | */ 5 | /* 6 | The buffer module from node.js, for the browser. 7 | 8 | @author Feross Aboukhadijeh 9 | license MIT 10 | */ 11 | (this.define||function(N,O){this.sourceMapSupport=O()})("browser-source-map-support",function(N){(function b(q,v,h){function e(d,a){if(!v[d]){if(!q[d]){var l="function"==typeof require&&require;if(!a&&l)return l(d,!0);if(k)return k(d,!0);throw Error("Cannot find module '"+d+"'");}l=v[d]={exports:{}};q[d][0].call(l.exports,function(a){var b=q[d][1][a];return e(b?b:a)},l,l.exports,b,q,v,h)}return v[d].exports}for(var k="function"==typeof require&&require,n=0;nb)return-1;if(58>b)return b-48+52;if(91>b)return b-65;if(123>b)return b-97+26}var k="undefined"!==typeof Uint8Array?Uint8Array:Array;b.toByteArray=function(b){function d(a){u[t++]=a}if(0>16);d((z&65280)>>8);d(z&255)}2===l?(z=e(b.charAt(a))<<2|e(b.charAt(a+1))>>4,d(z&255)):1===l&&(z=e(b.charAt(a))<<10|e(b.charAt(a+1))<<4|e(b.charAt(a+2))>>2,d(z>>8&255),d(z&255));return u};b.fromByteArray=function(b){var d=b.length%3,a="",l;var e=0;for(l=b.length-d;e>18&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r>>12&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r>>6&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r&63);a+=r}switch(d){case 1:r=b[b.length-1];a+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r>>2);a+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r<< 15 | 4&63);a+="==";break;case 2:r=(b[b.length-2]<<8)+b[b.length-1],a+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r>>10),a+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r>>4&63),a+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(r<<2&63),a+="="}return a}})("undefined"===typeof h?this.base64js={}:h)},{}],3:[function(q,v,h){},{}],4:[function(q,v,h){function b(f,g,x){if(!(this instanceof b))return new b(f,g,x);var a=typeof f; 16 | if("base64"===g&&"string"===a)for(f=f.trim?f.trim():f.replace(/^\s+|\s+$/g,"");0!==f.length%4;)f+="=";if("number"===a)var c=D(f);else if("string"===a)c=b.byteLength(f,g);else if("object"===a)c=D(f.length);else throw Error("First argument needs to be a number, array or string.");if(b._useTypedArrays)var d=b._augment(new Uint8Array(c));else d=this,d.length=c,d._isBuffer=!0;if(b._useTypedArrays&&"number"===typeof f.byteLength)d._set(f);else{var m=f;if(M(m)||b.isBuffer(m)||m&&"object"===typeof m&&"number"=== 17 | typeof m.length)for(g=0;g=a))return x?(x=f[g],g+ 18 | 1=c)){var x;a?(g+2>>0)):(g+1>>0);return x}}function d(f,g,a,c){c||(p("boolean"===typeof a,"missing or invalid endian"), 19 | p(void 0!==g&&null!==g,"missing offset"),p(g+1=f.length))return f=k(f,g,a,!0),f&32768?-1*(65535-f+1):f}function a(f,g,a,c){c||(p("boolean"===typeof a,"missing or invalid endian"),p(void 0!==g&&null!==g,"missing offset"),p(g+3=f.length))return f=n(f,g,a,!0),f&2147483648?-1*(4294967295-f+1):f}function l(f,g,a,c){c||(p("boolean"===typeof a,"missing or invalid endian"),p(g+3=x))for(b=0,x=Math.min(x-a,2);b>>8* 21 | (c?b:1-b)}function t(f,g,a,c,b){b||(p(void 0!==g&&null!==g,"missing value"),p("boolean"===typeof c,"missing or invalid endian"),p(void 0!==a&&null!==a,"missing offset"),p(a+3=x))for(b=0,x=Math.min(x-a,4);b>>8*(c?b:3-b)&255}function z(f,g,a,c,b){b||(p(void 0!==g&&null!==g,"missing value"),p("boolean"===typeof c,"missing or invalid endian"),p(void 0!==a&&null!==a,"missing offset"),p(a+1=f.length||(0<=g?r(f,g,a,c,b):r(f,65535+g+1,a,c,b))}function c(f,g,a,c,b){b||(p(void 0!==g&&null!==g,"missing value"),p("boolean"===typeof c,"missing or invalid endian"),p(void 0!==a&&null!==a,"missing offset"),p(a+3=f.length||(0<=g?t(f,g,a,c,b):t(f,4294967295+g+1,a,c,b))}function m(f,g,a,c,b){b||(p(void 0!==g&&null!==g,"missing value"),p("boolean"===typeof c, 23 | "missing or invalid endian"),p(void 0!==a&&null!==a,"missing offset"),p(a+3=f.length||I.write(f,g,a,c,23,4)}function y(f,g,a,c,b){b||(p(void 0!==g&&null!==g,"missing value"),p("boolean"===typeof c,"missing or invalid endian"),p(void 0!==a&&null!==a,"missing offset"),p(a+7=f.length||I.write(f, 24 | g,a,c,52,8)}function C(f,g,a){if("number"!==typeof f)return a;f=~~f;if(f>=g)return g;if(0<=f)return f;f+=g;return 0<=f?f:0}function D(f){f=~~Math.ceil(+f);return 0>f?0:f}function M(f){return(Array.isArray||function(f){return"[object Array]"===Object.prototype.toString.call(f)})(f)}function K(f){return 16>f?"0"+f.toString(16):f.toString(16)}function L(f){for(var a=[],c=0;c=b)a.push(f.charCodeAt(c));else{var d=c;55296<=b&&57343>=b&&c++;b=encodeURIComponent(f.slice(d, 25 | c+1)).substr(1).split("%");for(d=0;d=a.length||g>=f.length);g++)a[g+c]=f[g];return g}function G(f){try{return decodeURIComponent(f)}catch(g){return String.fromCharCode(65533)}}function H(f,a){p("number"===typeof f,"cannot write a non-number as a number");p(0<=f,"specified a negative value for writing an unsigned value");p(f<= 26 | a,"value is larger than maximum value for type");p(Math.floor(f)===f,"value has a fractional component")}function A(f,a,c){p("number"===typeof f,"cannot write a non-number as a number");p(f<=a,"value larger than maximum allowed value");p(f>=c,"value smaller than minimum allowed value");p(Math.floor(f)===f,"value has a fractional component")}function F(f,a,c){p("number"===typeof f,"cannot write a non-number as a number");p(f<=a,"value larger than maximum allowed value");p(f>=c,"value smaller than minimum allowed value")} 27 | function p(f,a){if(!f)throw Error(a||"Failed assertion");}var E=q("base64-js"),I=q("ieee754");h.Buffer=b;h.SlowBuffer=b;h.INSPECT_MAX_BYTES=50;b.poolSize=8192;b._useTypedArrays=function(){try{var f=new ArrayBuffer(0),a=new Uint8Array(f);a.foo=function(){return 42};return 42===a.foo()&&"function"===typeof a.subarray}catch(x){return!1}}();b.isEncoding=function(f){switch(String(f).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "binary":case "base64":case "raw":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return!0; 28 | default:return!1}};b.isBuffer=function(f){return!(null===f||void 0===f||!f._isBuffer)};b.byteLength=function(f,a){f+="";switch(a||"utf8"){case "hex":var c=f.length/2;break;case "utf8":case "utf-8":c=L(f).length;break;case "ascii":case "binary":case "raw":c=f.length;break;case "base64":c=E.toByteArray(f).length;break;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":c=2*f.length;break;default:throw Error("Unknown encoding");}return c};b.concat=function(f,a){p(M(f),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."); 29 | if(0===f.length)return new b(0);if(1===f.length)return f[0];var c;if("number"!==typeof a)for(c=a=0;cg&&(c=g)):c=g;d=String(d||"utf8").toLowerCase();switch(d){case "hex":a=Number(a)||0;d=this.length-a;c?(c=Number(c),c>d&&(c=d)):c=d;d= 30 | f.length;p(0===d%2,"Invalid hex string");c>d/2&&(c=d/2);for(d=0;d>8;t%=256;g.push(t);g.push(d)}f=b._charsWritten=B(g,this,a,c);break;default:throw Error("Unknown encoding");}return f};b.prototype.toString=function(f,a,c){f=String(f||"utf8").toLowerCase();a=Number(a)||0;c=void 0!==c?Number(c):c=this.length;if(c===a)return"";switch(f){case "hex":f=this.length;if(!a||0>a)a=0;if(!c||0>c||c>f)c=f;for(f="";a=this[a]?(f+=G(g)+String.fromCharCode(this[a]), 32 | g=""):g+="%"+this[a].toString(16);c=f+G(g);break;case "ascii":c=e(this,a,c);break;case "binary":c=e(this,a,c);break;case "base64":c=0===a&&c===this.length?E.fromByteArray(this):E.fromByteArray(this.slice(a,c));break;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":c=this.slice(a,c);a="";for(f=0;f=c,"sourceEnd < sourceStart"),p(0<=a&&athis.length&&(d=this.length),f.length-ad||!b._useTypedArrays)for(var g=0;g=this.length))return this[f]};b.prototype.readUInt16LE=function(f,a){return k(this,f,!0,a)};b.prototype.readUInt16BE=function(a,c){return k(this,a,!1,c)};b.prototype.readUInt32LE=function(a,c){return n(this,a,!0,c)};b.prototype.readUInt32BE=function(a,c){return n(this,a,!1,c)};b.prototype.readInt8=function(a,c){c||(p(void 0!==a&&null!==a,"missing offset"),p(a= 36 | this.length))return this[a]&128?-1*(255-this[a]+1):this[a]};b.prototype.readInt16LE=function(a,c){return d(this,a,!0,c)};b.prototype.readInt16BE=function(a,c){return d(this,a,!1,c)};b.prototype.readInt32LE=function(c,b){return a(this,c,!0,b)};b.prototype.readInt32BE=function(c,b){return a(this,c,!1,b)};b.prototype.readFloatLE=function(a,c){return l(this,a,!0,c)};b.prototype.readFloatBE=function(a,c){return l(this,a,!1,c)};b.prototype.readDoubleLE=function(a,c){return u(this,a,!0,c)};b.prototype.readDoubleBE= 37 | function(a,c){return u(this,a,!1,c)};b.prototype.writeUInt8=function(a,c,b){b||(p(void 0!==a&&null!==a,"missing value"),p(void 0!==c&&null!==c,"missing offset"),p(c=this.length||(this[c]=a)};b.prototype.writeUInt16LE=function(a,c,b){r(this,a,c,!0,b)};b.prototype.writeUInt16BE=function(a,c,b){r(this,a,c,!1,b)};b.prototype.writeUInt32LE=function(a,c,b){t(this,a,c,!0,b)};b.prototype.writeUInt32BE=function(a,c,b){t(this,a,c,!1,b)};b.prototype.writeInt8= 38 | function(a,c,b){b||(p(void 0!==a&&null!==a,"missing value"),p(void 0!==c&&null!==c,"missing offset"),p(c=this.length||(0<=a?this.writeUInt8(a,c,b):this.writeUInt8(255+a+1,c,b))};b.prototype.writeInt16LE=function(a,c,b){z(this,a,c,!0,b)};b.prototype.writeInt16BE=function(a,c,b){z(this,a,c,!1,b)};b.prototype.writeInt32LE=function(a,b,d){c(this,a,b,!0,d)};b.prototype.writeInt32BE=function(a,b,d){c(this,a,b,!1,d)};b.prototype.writeFloatLE= 39 | function(a,c,b){m(this,a,c,!0,b)};b.prototype.writeFloatBE=function(a,c,b){m(this,a,c,!1,b)};b.prototype.writeDoubleLE=function(a,c,b){y(this,a,c,!0,b)};b.prototype.writeDoubleBE=function(a,c,b){y(this,a,c,!1,b)};b.prototype.fill=function(a,c,b){a||(a=0);c||(c=0);b||(b=this.length);"string"===typeof a&&(a=a.charCodeAt(0));p("number"===typeof a&&!isNaN(a),"value is not a number");p(b>=c,"end < start");if(b!==c&&0!==this.length)for(p(0<=c&&c"};b.prototype.toArrayBuffer=function(){if("undefined"!==typeof Uint8Array){if(b._useTypedArrays)return(new b(this)).buffer;for(var a=new Uint8Array(this.length),c=0,d=a.length;c>1,r=-7;d=k?d-1:0;var t=k?-1:1,z=b[e+d];d+=t;k=z&(1<<-r)-1;z>>=-r;for(r+=a;0>=-r;for(r+=n;0>1,z=23===d?Math.pow(2,-24)-Math.pow(2,-77):0;a=n?0:a-1;var c=n?1:-1,m=0>e||0===e&&0>1/e?1:0;e=Math.abs(e);isNaN(e)||Infinity===e?(e=isNaN(e)?1:0,n=r):(n=Math.floor(Math.log(e)/Math.LN2),1>e*(l=Math.pow(2,-n))&&(n--,l*=2),e=1<=n+t?e+z/l:e+z*Math.pow(2,1-t),2<=e*l&&(n++,l/=2),n+t>=r?(e=0,n=r):1<=n+t?(e=(e*l-1)*Math.pow(2,d),n+=t):(e=e*Math.pow(2,t-1)*Math.pow(2,d),n=0));for(;8<=d;b[k+a]=e&255,a+=c,e/=256,d-=8);n=n<b?[]:a.slice(c,b-c+1)}a=h.resolve(a).substr(1);b=h.resolve(b).substr(1);for(var l=d(a.split("/")),t=d(b.split("/")),e=Math.min(l.length,t.length),c=e,m=0;mb&&(b=a.length+b);return a.substr(b,d)}}).call(this,q("node_modules/process/browser.js"))}, 49 | {"node_modules/process/browser.js":7}],7:[function(q,v,h){function b(){}q=v.exports={};q.nextTick=function(){if("undefined"!==typeof window&&window.setImmediate)return function(b){return window.setImmediate(b)};if("undefined"!==typeof window&&window.postMessage&&window.addEventListener){var b=[];window.addEventListener("message",function(e){var k=e.source;k!==window&&null!==k||"process-tick"!==e.data||(e.stopPropagation(),0e?(-e<<1)+1:(e<<1)+0;do e=n&31,n>>>=5,0=d)throw Error("Expected more digits in base 64 VLQ value.");var u=b.decode(e.charCodeAt(k++));if(-1===u)throw Error("Invalid base64 digit: "+e.charAt(k-1));var r=!!(u&32);u&=31;a+=u<>1;n.value=1===(a&1)?-e:e;n.rest=k}},{"./base64":10}],10:[function(q,v,h){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");h.encode=function(e){if(0<=e&&e=b?b-65:97<=b&&122>=b?b-97+26:48<=b&&57>=b?b-48+52:43==b?62:47==b?63:-1}},{}],11:[function(q,v,h){function b(e,k,n,d,a,l){var u=Math.floor((k-e)/2)+e,r=a(n,d[u],!0);return 0===r?u:0e?-1:e}h.GREATEST_LOWER_BOUND=1;h.LEAST_UPPER_BOUND=2;h.search=function(e,k,n,d){if(0===k.length)return-1;e=b(-1,k.length,e,k,n,d||h.GREATEST_LOWER_BOUND);if(0>e)return-1; 55 | for(;0<=e-1&&0===n(k[e],k[e-1],!0);)--e;return e}},{}],12:[function(q,v,h){function b(){this._array=[];this._sorted=!0;this._last={generatedLine:-1,generatedColumn:0}}var e=q("./util");b.prototype.unsortedForEach=function(b,e){this._array.forEach(b,e)};b.prototype.add=function(b){var k=this._last,d=k.generatedLine,a=b.generatedLine,l=k.generatedColumn,u=b.generatedColumn;a>d||a==d&&u>=l||0>=e.compareByGeneratedPositionsInflated(k,b)?this._last=b:this._sorted=!1;this._array.push(b)};b.prototype.toArray= 56 | function(){this._sorted||(this._array.sort(e.compareByGeneratedPositionsInflated),this._sorted=!0);return this._array};h.MappingList=b},{"./util":17}],13:[function(q,v,h){function b(b,e,d){var a=b[e];b[e]=b[d];b[d]=a}function e(k,n,d,a){if(d=n(k[r],u)&&(l+=1,b(k,l,r));b(k,l+1,r);l+=1;e(k,n,d,l-1);e(k,n,l+1,a)}}h.quickSort=function(b,n){e(b,n,0,b.length-1)}},{}],14:[function(q,v,h){function b(a,b){var c=a;"string"=== 57 | typeof a&&(c=d.parseSourceMapInput(a));return null!=c.sections?new n(c,b):new e(c,b)}function e(a,b){var c=a;"string"===typeof a&&(c=d.parseSourceMapInput(a));var m=d.getArg(c,"version"),t=d.getArg(c,"sources"),e=d.getArg(c,"names",[]),r=d.getArg(c,"sourceRoot",null),k=d.getArg(c,"sourcesContent",null),u=d.getArg(c,"mappings");c=d.getArg(c,"file",null);if(m!=this._version)throw Error("Unsupported version: "+m);r&&(r=d.normalize(r));t=t.map(String).map(d.normalize).map(function(a){return r&&d.isAbsolute(r)&& 58 | d.isAbsolute(a)?d.relative(r,a):a});this._names=l.fromArray(e.map(String),!0);this._sources=l.fromArray(t,!0);this.sourceRoot=r;this.sourcesContent=k;this._mappings=u;this._sourceMapURL=b;this.file=c}function k(){this.generatedColumn=this.generatedLine=0;this.name=this.originalColumn=this.originalLine=this.source=null}function n(a,e){var c=a;"string"===typeof a&&(c=d.parseSourceMapInput(a));var m=d.getArg(c,"version");c=d.getArg(c,"sections");if(m!=this._version)throw Error("Unsupported version: "+ 59 | m);this._sources=new l;this._names=new l;var t={line:-1,column:0};this._sections=c.map(function(a){if(a.url)throw Error("Support for url field in sections not implemented.");var c=d.getArg(a,"offset"),m=d.getArg(c,"line"),l=d.getArg(c,"column");if(m=b[c])throw new TypeError("Line must be greater than or equal to 1, got "+b[c]);if(0>b[m])throw new TypeError("Column must be greater than or equal to 0, got "+ 69 | b[m]);return a.search(b,d,e,l)};e.prototype.computeColumnSpans=function(){for(var a=0;a=this._sources.size()&&!this.sourcesContent.some(function(a){return null==a}):!1};e.prototype.sourceContentFor=function(a,b){if(!this.sourcesContent)return null;var c=a;null!=this.sourceRoot&&(c=d.relative(this.sourceRoot,c));if(this._sources.has(c))return this.sourcesContent[this._sources.indexOf(c)];var m=this.sources,e;for(e=0;eb||95!==a.charCodeAt(b-1)||95!==a.charCodeAt(b-2)||111!==a.charCodeAt(b-3)||116!==a.charCodeAt(b-4)||111!==a.charCodeAt(b-5)||114!==a.charCodeAt(b-6)||112!==a.charCodeAt(b-7)||95!==a.charCodeAt(b-8)||95!==a.charCodeAt(b-9))return!1;for(b-=10;0<=b;b--)if(36!==a.charCodeAt(b))return!1;return!0}function r(a,b){return a===b?0:null===a?1:null===b?-1:a>b?1:-1}h.getArg=function(a,b,d){if(b in 98 | a)return a[b];if(3===arguments.length)return d;throw Error('"'+b+'" is a required argument.');};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,z=/^data:.+\,.+$/;h.urlParse=b;h.urlGenerate=e;h.normalize=k;h.join=n;h.isAbsolute=function(a){return"/"===a.charAt(0)||t.test(a)};h.relative=function(a,b){""===a&&(a=".");a=a.replace(/\/$/,"");for(var c=0;0!==b.indexOf(a+"/");){var d=a.lastIndexOf("/");if(0>d)return b;a=a.slice(0,d);if(a.match(/^([^\/]+:\/)?\/*$/))return b;++c}return Array(c+ 99 | 1).join("../")+b.substr(a.length+1)};q=!("__proto__"in Object.create(null));h.toSetString=q?d:a;h.fromSetString=q?d:l;h.compareByOriginalPositions=function(a,b,d){var c=r(a.source,b.source);if(0!==c)return c;c=a.originalLine-b.originalLine;if(0!==c)return c;c=a.originalColumn-b.originalColumn;if(0!==c||d)return c;c=a.generatedColumn-b.generatedColumn;if(0!==c)return c;c=a.generatedLine-b.generatedLine;return 0!==c?c:r(a.name,b.name)};h.compareByGeneratedPositionsDeflated=function(a,b,d){var c=a.generatedLine- 100 | b.generatedLine;if(0!==c)return c;c=a.generatedColumn-b.generatedColumn;if(0!==c||d)return c;c=r(a.source,b.source);if(0!==c)return c;c=a.originalLine-b.originalLine;if(0!==c)return c;c=a.originalColumn-b.originalColumn;return 0!==c?c:r(a.name,b.name)};h.compareByGeneratedPositionsInflated=function(a,b){var c=a.generatedLine-b.generatedLine;if(0!==c)return c;c=a.generatedColumn-b.generatedColumn;if(0!==c)return c;c=r(a.source,b.source);if(0!==c)return c;c=a.originalLine-b.originalLine;if(0!==c)return c; 101 | c=a.originalColumn-b.originalColumn;return 0!==c?c:r(a.name,b.name)};h.parseSourceMapInput=function(a){return JSON.parse(a.replace(/^\)]}'[^\n]*\n/,""))};h.computeSourceURL=function(a,d,h){d=d||"";a&&("/"!==a[a.length-1]&&"/"!==d[0]&&(a+="/"),d=a+d);if(h){a=b(h);if(!a)throw Error("sourceMapURL could not be parsed");a.path&&(h=a.path.lastIndexOf("/"),0<=h&&(a.path=a.path.substring(0,h+1)));d=n(e(a),d)}return k(d)}},{}],18:[function(q,v,h){h.SourceMapGenerator=q("./lib/source-map-generator").SourceMapGenerator; 102 | h.SourceMapConsumer=q("./lib/source-map-consumer").SourceMapConsumer;h.SourceNode=q("./lib/source-node").SourceNode},{"./lib/source-map-consumer":14,"./lib/source-map-generator":15,"./lib/source-node":16}],19:[function(q,v,h){(function(b,e){function k(){return"browser"===J?!0:"node"===J?!1:"undefined"!==typeof window&&"function"===typeof XMLHttpRequest&&!(window.require&&window.module&&window.process&&"renderer"===window.process.type)}function n(a){return function(b){for(var c=0;c";b=this.getLineNumber();null!=b&&(a+=":"+b,(b=this.getColumnNumber())&& 105 | (a+=":"+b))}b="";var c=this.getFunctionName(),d=!0,e=this.isConstructor();if(this.isToplevel()||e)e?b+="new "+(c||""):c?b+=c:(b+=a,d=!1);else{e=this.getTypeName();"[object Object]"===e&&(e="null");var k=this.getMethodName();c?(e&&0!=c.indexOf(e)&&(b+=e+"."),b+=c,k&&c.indexOf("."+k)!=c.length-k.length-1&&(b+=" [as "+k+"]")):b+=e+"."+(k||"")}d&&(b+=" ("+a+")");return b}function r(a){var b={};Object.getOwnPropertyNames(Object.getPrototypeOf(a)).forEach(function(c){b[c]=/^(?:is|get)/.test(c)? 106 | function(){return a[c].call(a)}:a[c]});b.toString=u;return b}function t(b){if(b.isNative())return b;var c=b.getFileName()||b.getScriptNameOrSourceURL();if(c){var d=b.getLineNumber(),e=b.getColumnNumber()-1;1===d&&62