var test = require('tap').test; var pack = require('../'); var convert = require('convert-source-map'); var parse = require('parse-base64vlq-mappings'); var foo = { version: 3, file: 'foo.js', sourceRoot: '', sources: [ 'foo.coffee' ], names: [], mappings: ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ', sourcesContent: [ 'console.log(require \'./bar.js\')\n' ] }; test('pack one file with source file field and existing sourcemap', function (t) { t.plan(7); var mapComment = convert.fromObject(foo).toComment(); var fooMappings = parse(foo.mappings); var p = pack(); var src = ''; p.on('data', function (buf) { src += buf }); p.on('end', function () { var sm = convert.fromSource(src).toObject(); var mappings = parse(sm.mappings); var remainingMaps = src.match(convert.commentRegex); // remove map for _prelude.js mappings.shift(); var fstMap = mappings[0]; var fstFooMap = fooMappings[0]; var lstMap = mappings.pop(); var lstFooMap = fooMappings.pop(); t.deepEqual(fstMap.original, fstFooMap.original, 'first original mappings are same'); t.deepEqual(lstMap.original, lstFooMap.original, 'last original mappings are same'); t.equal(fstMap.generated.column, fstFooMap.generated.column, 'first generated columns are same'); t.equal(lstMap.generated.column, lstFooMap.generated.column, 'last generated columns are same'); t.equal(fstMap.generated.line, fstFooMap.generated.line + 1, 'first generated line is offset by 1'); t.equal(lstMap.generated.line, lstFooMap.generated.line + 1, 'last generated line is offset by 1'); t.equal(remainingMaps.length, 1, 'removes orinal source maps'); }); p.end(JSON.stringify([ { id: 'xyz', source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + mapComment, sourceFile: 'foo.js' } ])); });
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/browser-pack/test/source-maps-existing.js | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |