initial commit

This commit is contained in:
air66
2019-07-24 18:16:32 +01:00
commit 5efebf4ded
8591 changed files with 899103 additions and 0 deletions

15
node_modules/gulp-sourcemaps/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,15 @@
## ISC License
Copyright (c) 2014, Florian Reiterer
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

407
node_modules/gulp-sourcemaps/README.md generated vendored Normal file
View File

@@ -0,0 +1,407 @@
## gulp-sourcemaps [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url]
### Branching
__2.X now supports node 0.10+ due to switching out a dependency.__
### Usage
#### Write inline source maps
Inline source maps are embedded in the source file.
Example:
```javascript
var gulp = require('gulp');
var plugin1 = require('gulp-plugin1');
var plugin2 = require('gulp-plugin2');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('javascript', function() {
gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
```
All plugins between `sourcemaps.init()` and `sourcemaps.write()` need to have support for `gulp-sourcemaps`. You can find a list of such plugins in the [wiki](https://github.com/gulp-sourcemaps/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support).
#### Write external source map files
To write external source map files, pass a path relative to the destination to `sourcemaps.write()`.
Example:
```javascript
var gulp = require('gulp');
var plugin1 = require('gulp-plugin1');
var plugin2 = require('gulp-plugin2');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('javascript', function() {
gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('dist'));
});
```
#### Load existing source maps
To load existing source maps, pass the option `loadMaps: true` to `sourcemaps.init()`.
Example:
```javascript
var gulp = require('gulp');
var plugin1 = require('gulp-plugin1');
var plugin2 = require('gulp-plugin2');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('javascript', function() {
gulp.src('src/**/*.js')
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
```
#### Handle large files
To handle large files, pass the option `largeFile: true` to `sourcemaps.init()`.
Example:
```javascript
var gulp = require('gulp');
var plugin1 = require('gulp-plugin1');
var plugin2 = require('gulp-plugin2');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('javascript', function() {
gulp.src('src/**/*.js')
.pipe(sourcemaps.init({largeFile: true}))
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
```
#### Handle source files from different directories
Use the `base` option on `gulp.src` to make sure all files are relative to a common base directory.
Example:
```javascript
var gulp = require('gulp');
var plugin1 = require('gulp-plugin1');
var plugin2 = require('gulp-plugin2');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('javascript', function() {
gulp.src(['src/test.js', 'src/testdir/test2.js'], { base: 'src' })
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('dist'));
});
```
#### Alter `sources` property on sourcemaps
The exported `mapSources` method gives full control over the source paths. It takes a function that is called for every source and receives the default source path as a parameter and the original vinyl file.
Example:
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
// be careful with the sources returned otherwise contents might not be loaded properly
.pipe(sourcemaps.mapSources(function(sourcePath, file) {
// source paths are prefixed with '../src/'
return '../src/' + sourcePath;
}))
.pipe(sourcemaps.write('../maps')
.pipe(gulp.dest('public/scripts'));
});
```
#### Generate Identity Sourcemap
The exported `identityMap` method allows you to generate a full valid source map encoding no changes (slower, only for Javascript and CSS) instead of the default empty source map (no mappings, fast). __Use this option if you get missing or incorrect mappings, e.g. when debugging.__
Example:
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
// An identity sourcemap will be generated at this step
.pipe(sourcemaps.identityMap())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps')
.pipe(gulp.dest('public/scripts'));
});
```
### Init Options
- `loadMaps`
Set to true to load existing maps for source files. Supports the following:
- inline source maps
- source map files referenced by a `sourceMappingURL=` comment
- source map files with the same name (plus .map) in the same directory
- `identityMap`
__This option is deprecated. Upgrade to use our [`sourcemap.identityMap`](#generate-identity-sourcemap) API.__
### Write Options
- `addComment`
By default a comment containing / referencing the source map is added. Set this to `false` to disable the comment (e.g. if you want to load the source maps by header).
Example:
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps', {addComment: false}))
.pipe(gulp.dest('dist'));
});
```
- `includeContent`
By default the source maps include the source code. Pass `false` to use the original files.
Including the content is the recommended way, because it "just works". When setting this to `false` you have to host the source files and set the correct `sourceRoot`.
- `sourceRoot`
Set the location where the source files are hosted (use this when `includeContent` is set to `false`). This is usually a URL (or an absolute URL path), not a local file system path.
By default the source root is '' or in case `destPath` is set, the relative path from the source map to the source base directory (this should work for many dev environments).
If a relative path is used (empty string or one starting with a `.`), it is interpreted as a path relative to the destination. The plugin rewrites it to a path relative to each source map.
Example:
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write({includeContent: false, sourceRoot: '/src'}))
.pipe(gulp.dest('dist'));
});
```
Example (using a function):
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write({
includeContent: false,
sourceRoot: function(file) {
return '/src';
}
}))
.pipe(gulp.dest('dist'));
});
```
Example (relative path):
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: '../src'}))
.pipe(gulp.dest('dist'));
});
```
In this case for a file written to `dist/subdir/example.js`, the source map is written to `dist/subdir/example.js.map` and the sourceRoot will be `../../src` (resulting in the full source path `../../src/subdir/example.js`).
- `destPath`
Set the destination path (the same you pass to `gulp.dest()`). If the source map destination path is not a sub path of the destination path, this is needed to get the correct path in the `file` property of the source map.
In addition, it allows to automatically set a relative `sourceRoot` if none is set explicitly.
- `sourceMappingURLPrefix`
Specify a prefix to be prepended onto the source map URL when writing external source maps. Relative paths will have their leading dots stripped.
Example:
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps', {
sourceMappingURLPrefix: 'https://asset-host.example.com/assets'
}))
.pipe(gulp.dest('public/scripts'));
});
```
This will result in a source mapping URL comment like `sourceMappingURL=https://asset-host.example.com/assets/maps/helloworld.js.map`.
- `sourceMappingURL`
If you need full control over the source map URL you can pass a function to this option. The output of the function must be the full URL to the source map (in function of the output file).
Example:
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps', {
sourceMappingURL: function(file) {
return 'https://asset-host.example.com/' + file.relative + '.map';
}
}))
.pipe(gulp.dest('public/scripts'));
});
```
This will result in a source mapping URL comment like `sourceMappingURL=https://asset-host.example.com/helloworld.js.map`.
- `mapFile`
This option allows to rename the map file. It takes a function that is called for every map and receives the default map path as a parameter.
Example:
```javascript
gulp.task('javascript', function() {
var stream = gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps', {
mapFile: function(mapFilePath) {
// source map files are named *.map instead of *.js.map
return mapFilePath.replace('.js.map', '.map');
}
}))
.pipe(gulp.dest('public/scripts'));
});
```
- `mapSources`
__This option is deprecated. Upgrade to use our [`sourcemap.mapSources`](#alter-sources-property-on-sourcemaps) API.__
- `charset`
Sets the charset for inline source maps. Default: `utf8`
- `clone`
Clones the original file for creation of the map file. Could be important if file history is important. See [file.clone()](https://github.com/gulpjs/vinyl#filecloneoptions) for possible options. Default: `{deep:false, contents:false}`
### Plugin developers only:
- **How to add source map support to plugins**
- Generate a source map for the transformation the plugin is applying
- **Important**: Make sure the paths in the generated source map (`file` and `sources`) are relative to `file.base` (e.g. use `file.relative`).
- Apply this source map to the vinyl `file`. E.g. by using [vinyl-sourcemaps-apply](https://github.com/gulp-sourcemaps/vinyl-sourcemaps-apply).
This combines the source map of this plugin with the source maps coming from plugins further up the chain.
- Add your plugin to the [wiki page](https://github.com/gulp-sourcemaps/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support)
#### Example:
```js
var through = require('through2');
var applySourceMap = require('vinyl-sourcemaps-apply');
var myTransform = require('myTransform');
module.exports = function(options) {
function transform(file, encoding, callback) {
// generate source maps if plugin source-map present
if (file.sourceMap) {
options.makeSourceMaps = true;
}
// do normal plugin logic
var result = myTransform(file.contents, options);
file.contents = new Buffer(result.code);
// apply source map to the chain
if (file.sourceMap) {
applySourceMap(file, result.map);
}
this.push(file);
callback();
}
return through.obj(transform);
};
```
- **Verify sourcemaps are working**
See example below or refer to [test/write.js](./test/write.js)
#### Example:
```js
var stream = plugin();
var init = sourcemaps.init();
var write = sourcemaps.write();
init.pipe(stream).pipe(write);
write.on('data', function (file) {
assert(...);
cb();
});
init.write(new gutil.File(...));
init.end();
```
### Debugging
All debugging output relies on [visionmedia/debug](https://github.com/visionmedia/debug). Follow the directions to set the
environment variable `$DEBUG`.
For a few examples of debug you could use:
```sh
DEBUG='gulp-sourcemaps:*' #everything
DEBUG='gulp-sourcemaps:init' #init/index.js
DEBUG='gulp-sourcemaps:init:*' #init/index.internals.js
DEBUG='gulp-sourcemaps:write:' #write/index.js
DEBUG='gulp-sourcemaps:write:*' #write/index.internals.js
DEBUG='gulp-sourcemaps:write:,gulp-sourcemaps:init:**' #write/index.internals.js and init/index.internals.js
```
[npm-image]: https://img.shields.io/npm/v/gulp-sourcemaps.svg
[npm-url]: https://www.npmjs.com/package/gulp-sourcemaps
[travis-image]: https://img.shields.io/travis/gulp-sourcemaps/gulp-sourcemaps.svg
[travis-url]: https://travis-ci.org/gulp-sourcemaps/gulp-sourcemaps
[coveralls-image]: https://img.shields.io/coveralls/gulp-sourcemaps/gulp-sourcemaps.svg
[coveralls-url]: https://coveralls.io/r/gulp-sourcemaps/gulp-sourcemaps?branch=master

8
node_modules/gulp-sourcemaps/index.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
module.exports = {
init: require('./src/init'),
write: require('./src/write'),
mapSources: require('@gulp-sourcemaps/map-sources'),
identityMap: require('@gulp-sourcemaps/identity-map')
};

100
node_modules/gulp-sourcemaps/package.json generated vendored Normal file
View File

@@ -0,0 +1,100 @@
{
"_from": "gulp-sourcemaps",
"_id": "gulp-sourcemaps@2.6.5",
"_inBundle": false,
"_integrity": "sha512-SYLBRzPTew8T5Suh2U8jCSDKY+4NARua4aqjj8HOysBh2tSgT9u4jc1FYirAdPx1akUxxDeK++fqw6Jg0LkQRg==",
"_location": "/gulp-sourcemaps",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "gulp-sourcemaps",
"name": "gulp-sourcemaps",
"escapedName": "gulp-sourcemaps",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#DEV:/",
"#USER"
],
"_resolved": "https://registry.npmjs.org/gulp-sourcemaps/-/gulp-sourcemaps-2.6.5.tgz",
"_shasum": "a3f002d87346d2c0f3aec36af7eb873f23de8ae6",
"_spec": "gulp-sourcemaps",
"_where": "D:\\Air66 Files\\dev_sites\\www.airurl.dev.cc\\user\\plugins\\air66Theme",
"author": {
"name": "Florian Reiterer",
"email": "me@florianreiterer.com"
},
"bugs": {
"url": "https://github.com/gulp-sourcemaps/gulp-sourcemaps/issues"
},
"bundleDependencies": false,
"dependencies": {
"@gulp-sourcemaps/identity-map": "1.X",
"@gulp-sourcemaps/map-sources": "1.X",
"acorn": "5.X",
"convert-source-map": "1.X",
"css": "2.X",
"debug-fabulous": "1.X",
"detect-newline": "2.X",
"graceful-fs": "4.X",
"source-map": "~0.6.0",
"strip-bom-string": "1.X",
"through2": "2.X"
},
"deprecated": false,
"description": "Source map support for Gulp.js",
"devDependencies": {
"bootstrap": "3.3.7",
"coveralls": "2.X",
"faucet": "0.0.X",
"gulp": "3.X",
"gulp-concat": "2.X",
"gulp-if": "2.X",
"gulp-less": "3.X",
"gulp-load-plugins": "1.X",
"hook-std": "0.2.X",
"http-server": "0.10.X",
"istanbul": "0.X",
"jshint": "2.X",
"lodash": "4.X",
"mississippi": "1.X",
"object-assign": "4.X",
"tape": "4.X",
"vinyl": "2.X",
"yargs": "7.X"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js",
"src"
],
"homepage": "http://github.com/gulp-sourcemaps/gulp-sourcemaps",
"keywords": [
"gulpplugin",
"gulp",
"source maps",
"sourcemaps"
],
"license": "ISC",
"main": "index.js",
"name": "gulp-sourcemaps",
"repository": {
"type": "git",
"url": "git://github.com/gulp-sourcemaps/gulp-sourcemaps.git"
},
"scripts": {
"cover": "istanbul cover --dir reports/coverage tape \"test/*.js\"",
"coveralls": "istanbul cover tape \"test/*.js\" --report lcovonly && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"lint": "jshint ./src/**/*.js ./test/*.js",
"serve": "http-server",
"tape": "tape",
"test": "npm run lint && faucet test/*.js $@",
"test:int": "rm -rf ./tmp && tape ./test/integration.js"
},
"version": "2.6.5"
}

1
node_modules/gulp-sourcemaps/src/debug.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('debug-fabulous').spawnable(require('../package.json').name);

View File

@@ -0,0 +1,128 @@
'use strict';
var utils = require('../utils');
var rootDebug = require('../debug');
var convert = require('convert-source-map');
var stripBom = require('strip-bom-string');
var urlRegex = utils.urlRegex;
var fs = require('graceful-fs');
var path = require('path');
var unixStylePath = utils.unixStylePath;
var exceptionToString = utils.exceptionToString;
module.exports = function(options, file, fileContent) {
function loadMaps() {
var sources = {
path: '',
map: null,
content: fileContent,
preExistingComment: null
};
_getInlineSources(sources);
if (!sources.map) // ahh not inline, so try file
_getFileSources(sources);
_fixSources(sources);
return sources;
}
function _fixSources(sources) {
var debug = rootDebug.spawn('init:internals:loadMaps:_fixSources');
// fix source paths and sourceContent for imported source map
if (sources.map) {
sources.map.sourcesContent = sources.map.sourcesContent || [];
sources.map.sources.forEach(function(source, i) {
if (source.match(urlRegex)) {
sources.map.sourcesContent[i] = sources.map.sourcesContent[i] || null;
return;
}
var absPath = path.resolve(sources.path, source);
sources.map.sources[i] = unixStylePath(path.relative(file.base, absPath));
if (!sources.map.sourcesContent[i]) {
var sourceContent = null;
if (sources.map.sourceRoot) {
if (sources.map.sourceRoot.match(urlRegex)) {
sources.map.sourcesContent[i] = null;
return;
}
absPath = path.resolve(sources.path, sources.map.sourceRoot, source);
}
// if current file: use content
if (absPath === file.path) {
sourceContent = sources.content;
} else { //attempt load content from file
try {
debug(function() { return 'No source content for "' + source + '". Loading from file.'; });
sourceContent = stripBom(fs.readFileSync(absPath, 'utf8'));
} catch (e) {
debug(function() { return 'warn: source file not found: ' + absPath; });
}
}
sources.map.sourcesContent[i] = sourceContent;
}
});
// remove source map comment from source
file.contents = new Buffer(sources.content, 'utf8');
}
}
function _getInlineSources(sources) {
var debug = rootDebug.spawn('init:internals:loadMaps:_getInlineSources');
sources.preExistingComment = utils.getInlinePreExisting(sources.content);
// Try to read inline source map
sources.map = convert.fromSource(sources.content, options.largeFile);
if (!sources.map)
return sources;
sources.map = sources.map.toObject();
// sources in map are relative to the source file
sources.path = path.dirname(file.path);
if (!options.largeFile) {
debug('comment REMOVED');
sources.content = convert.removeComments(sources.content);
}
}
function _getFileSources(sources) {
var debug = rootDebug.spawn('init:internals:loadMaps:_getFileSources');
// look for source map comment referencing a source map file
var mapComment = convert.mapFileCommentRegex.exec(sources.content);
var mapFile;
if (mapComment) {
sources.preExistingComment = mapComment[1] || mapComment[2];
mapFile = path.resolve(path.dirname(file.path), sources.preExistingComment);
sources.content = convert.removeMapFileComments(sources.content);
// if no comment try map file with same name as source file
} else {
mapFile = file.path + '.map';
}
// sources in external map are relative to map file
sources.path = path.dirname(mapFile);
try {
sources.map = JSON.parse(stripBom(fs.readFileSync(mapFile, 'utf8')));
} catch (e) {
debug(function() {
return 'warn: external source map not found or invalid: ' + mapFile + ' ' + exceptionToString(e);
});
}
}
return {
loadMaps: loadMaps
};
};

141
node_modules/gulp-sourcemaps/src/init/index.js generated vendored Normal file
View File

@@ -0,0 +1,141 @@
'use strict';
var utils = require('../utils');
var unixStylePath = utils.unixStylePath;
var through = require('through2');
var path = require('path');
var acorn = require('acorn');
var SourceMapGenerator = require('source-map').SourceMapGenerator;
var css = require('css');
var initInternals = require('./index.internals');
/**
* Initialize source mapping chain
*/
function init(options) {
var debug = require('../debug').spawn('init');
function sourceMapInit(file, encoding, callback) {
/*jshint validthis:true */
// pass through if file is null or already has a source map
if (file.isNull() || file.sourceMap) {
this.push(file);
return callback();
}
if (file.isStream()) {
return callback(new Error(utils.PLUGIN_NAME + '-init: Streaming not supported'));
}
if (options === undefined) {
options = {};
}
debug(function() {
return options;
});
var fileContent = file.contents.toString();
var sourceMap, preExistingComment;
var internals = initInternals(options, file, fileContent);
if (options.loadMaps) {
var result = internals.loadMaps();
sourceMap = result.map;
fileContent = result.content;
preExistingComment = result.preExistingComment;
}
if (!sourceMap && options.identityMap) {
debug(function() { return '**identityMap option is deprecated, update to use sourcemap.identityMap stream**'; });
debug(function() {
return 'identityMap';
});
var fileType = path.extname(file.path);
var source = unixStylePath(file.relative);
var generator = new SourceMapGenerator({file: source});
if (fileType === '.js') {
var tokenizer = acorn.tokenizer(fileContent, {locations: true});
while (true) {
var token = tokenizer.getToken();
if (token.type.label === "eof")
break;
var mapping = {
original: token.loc.start,
generated: token.loc.start,
source: source
};
if (token.type.label === 'name') {
mapping.name = token.value;
}
generator.addMapping(mapping);
}
generator.setSourceContent(source, fileContent);
sourceMap = generator.toJSON();
} else if (fileType === '.css') {
debug('css');
var ast = css.parse(fileContent, {silent: true});
debug(function() {
return ast;
});
var registerTokens = function(ast) {
if (ast.position) {
generator.addMapping({original: ast.position.start, generated: ast.position.start, source: source});
}
function logAst(key, ast) {
debug(function() {
return 'key: ' + key;
});
debug(function() {
return ast[key];
});
}
for (var key in ast) {
logAst(key, ast);
if (key !== "position") {
if (Object.prototype.toString.call(ast[key]) === '[object Object]') {
registerTokens(ast[key]);
} else if (Array.isArray(ast[key])) {
debug(function() {
return "@@@@ ast[key] isArray @@@@";
});
for (var i = 0; i < ast[key].length; i++) {
registerTokens(ast[key][i]);
}
}
}
}
};
registerTokens(ast);
generator.setSourceContent(source, fileContent);
sourceMap = generator.toJSON();
}
}
if (!sourceMap) {
// Make an empty source map
sourceMap = {
version: 3,
names: [],
mappings: '',
sources: [unixStylePath(file.relative)],
sourcesContent: [fileContent]
};
}
else if(preExistingComment !== null && typeof preExistingComment !== 'undefined')
sourceMap.preExistingComment = preExistingComment;
sourceMap.file = unixStylePath(file.relative);
file.sourceMap = sourceMap;
this.push(file);
callback();
}
return through.obj(sourceMapInit);
}
module.exports = init;

76
node_modules/gulp-sourcemaps/src/utils.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
'use strict';
var path = require('path'),
detectNewline = require('detect-newline');
function unixStylePath(filePath) {
return filePath.split(path.sep).join('/');
}
var PLUGIN_NAME = require('../package.json').name;
var urlRegex = /^(https?|webpack(-[^:]+)?):\/\//;
var debug = require('./debug').spawn('utils');
/*
So reusing the same ref for a regex (with global (g)) is from a poor decision in js.
See http://stackoverflow.com/questions/10229144/bug-with-regexp-in-javascript-when-do-global-search
So we either need to use a new instance of a regex everywhere.
*/
var sourceMapUrlRegEx = function(){ return /\/\/\# sourceMappingURL\=.*/g;};
var commentFormatters = {
css: function cssCommentFormatter(preLine, newline, url) {
return preLine + "/*# sourceMappingURL=" + url + " */" + newline;
},
js: function jsCommentFormatter(preLine, newline, url) {
return preLine + "//# sourceMappingURL=" + url + newline;
},
'default': function defaultFormatter() {
return '';
}
}
var getCommentFormatter = function (file) {
var extension = file.relative.split('.').pop(),
fileContents = file.contents.toString(),
newline = detectNewline.graceful(fileContents || '');
var commentFormatter = commentFormatters.default;
if (file.sourceMap.preExistingComment) {
commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, '', newline)
debug(function () {
return 'preExistingComment commentFormatter ' + commentFormatter.name;
});
} else {
commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, newline, newline);
}
debug(function () {
return 'commentFormatter ' + commentFormatter.name;
});
return commentFormatter;
};
var getInlinePreExisting = function(fileContent){
if(sourceMapUrlRegEx().test(fileContent)){
debug(function() { return 'has preExisting'; });
return fileContent.match(sourceMapUrlRegEx())[0];
}
};
var exceptionToString = function (exception) {
return exception.message || '';
};
module.exports = {
unixStylePath: unixStylePath,
PLUGIN_NAME: PLUGIN_NAME,
urlRegex: urlRegex,
sourceMapUrlRegEx: sourceMapUrlRegEx,
getCommentFormatter: getCommentFormatter,
getInlinePreExisting: getInlinePreExisting,
exceptionToString: exceptionToString
};

View File

@@ -0,0 +1,179 @@
'use strict';
module.exports = function(destPath, options) {
var utils = require('../utils');
var unixStylePath = utils.unixStylePath;
var fs = require('graceful-fs');
var path = require('path');
var stripBom = require('strip-bom-string');
var rootDebug = require('../debug').spawn('write:internals');
rootDebug(function() { return "options"; });
rootDebug(function() { return options; });
function setSourceRoot(file) {
var debug = rootDebug.spawn('setSourceRoot');
var sourceMap = file.sourceMap;
if (typeof options.sourceRoot === 'function') {
debug(function() { return 'is function'; });
sourceMap.sourceRoot = options.sourceRoot(file);
} else {
debug(function() { return 'from options'; });
sourceMap.sourceRoot = options.sourceRoot;
}
if (sourceMap.sourceRoot === null) {
debug(function() { return 'undefined'; });
sourceMap.sourceRoot = undefined;
}
}
function mapSources(file) {
var debug = rootDebug.spawn('mapSources');
//NOTE: make sure source mapping happens after content has been loaded
if (options.mapSources && typeof options.mapSources === 'function') {
debug(function() { return '**Option is deprecated, update to use sourcemap.mapSources stream**'; });
debug(function() { return 'function'; });
file.sourceMap.sources = file.sourceMap.sources.map(function (filePath) {
return options.mapSources(filePath, file);
});
return;
}
debug(function() { return "file.path: " + file.path; });
debug(function() { return "file.cwd: " + file.cwd; });
debug(function() { return "file.base: " + file.base; });
file.sourceMap.sources = file.sourceMap.sources.map(function(filePath) {
// keep the references files like ../node_modules within the sourceRoot
debug(function() { return "filePath: " + filePath; });
if (options.mapSourcesAbsolute === true){
debug(function() { return 'mapSourcesAbsolute'; });
if (!file.dirname){
debug(function() { return '!file.dirname'; });
filePath = path.join(file.base, filePath).replace(file.cwd, '');
} else {
debug(function() { return 'file.dirname: ' + file.dirname; });
filePath = path.resolve(file.dirname, filePath).replace(file.cwd, '');
}
}
return unixStylePath(filePath);
});
}
function loadContent(file) {
var debug = rootDebug.spawn('loadContent');
var sourceMap = file.sourceMap;
if (options.includeContent) {
sourceMap.sourcesContent = sourceMap.sourcesContent || [];
// load missing source content
for (var i = 0; i < sourceMap.sources.length; i++) {
if (!sourceMap.sourcesContent[i]) {
var sourcePath = path.resolve(file.base, sourceMap.sources[i]);
try {
debug('No source content for "' + sourceMap.sources[i] + '". Loading from file.');
sourceMap.sourcesContent[i] = stripBom(fs.readFileSync(sourcePath, 'utf8'));
}
catch (e) {
debug('source file not found: ' + sourcePath);
}
}
}
} else {
delete sourceMap.sourcesContent;
}
}
function mapDestPath(file, stream) {
var debug = rootDebug.spawn('mapDestPath');
var sourceMap = file.sourceMap;
var comment,
commentFormatter = utils.getCommentFormatter(file);
if (destPath === undefined || destPath === null) {
// encode source map into comment
var base64Map = new Buffer(JSON.stringify(sourceMap)).toString('base64');
comment = commentFormatter('data:application/json;charset=' + options.charset + ';base64,' + base64Map);
} else {
var mapFile = path.join(destPath, file.relative) + '.map';
// custom map file name
if (options.mapFile && typeof options.mapFile === 'function') {
mapFile = options.mapFile(mapFile);
}
var sourceMapPath = path.join(file.base, mapFile);
// if explicit destination path is set
if (options.destPath) {
var destSourceMapPath = path.join(file.cwd, options.destPath, mapFile);
var destFilePath = path.join(file.cwd, options.destPath, file.relative);
sourceMap.file = unixStylePath(path.relative(path.dirname(destSourceMapPath), destFilePath));
if (sourceMap.sourceRoot === undefined) {
sourceMap.sourceRoot = unixStylePath(path.relative(path.dirname(destSourceMapPath), file.base));
} else if (sourceMap.sourceRoot === '' || (sourceMap.sourceRoot && sourceMap.sourceRoot[0] === '.')) {
sourceMap.sourceRoot = unixStylePath(path.join(path.relative(path.dirname(destSourceMapPath), file.base), sourceMap.sourceRoot));
}
} else {
// best effort, can be incorrect if options.destPath not set
sourceMap.file = unixStylePath(path.relative(path.dirname(sourceMapPath), file.path));
if (sourceMap.sourceRoot === '' || (sourceMap.sourceRoot && sourceMap.sourceRoot[0] === '.')) {
sourceMap.sourceRoot = unixStylePath(path.join(path.relative(path.dirname(sourceMapPath), file.base), sourceMap.sourceRoot));
}
}
var sourceMapFile;
sourceMapFile = file.clone(options.clone || {deep:false, contents:false});
sourceMapFile.path = sourceMapPath;
sourceMapFile.contents = new Buffer(JSON.stringify(sourceMap));
sourceMapFile.stat = {
isFile: function () { return true; },
isDirectory: function () { return false; },
isBlockDevice: function () { return false; },
isCharacterDevice: function () { return false; },
isSymbolicLink: function () { return false; },
isFIFO: function () { return false; },
isSocket: function () { return false; }
};
stream.push(sourceMapFile);
var sourceMapPathRelative = path.relative(path.dirname(file.path), sourceMapPath);
if (options.sourceMappingURLPrefix) {
var prefix = '';
if (typeof options.sourceMappingURLPrefix === 'function') {
prefix = options.sourceMappingURLPrefix(file);
} else {
prefix = options.sourceMappingURLPrefix;
}
sourceMapPathRelative = prefix + path.join('/', sourceMapPathRelative);
}
debug(function() { return "destPath comment"; });
comment = commentFormatter(unixStylePath(sourceMapPathRelative));
if (options.sourceMappingURL && typeof options.sourceMappingURL === 'function') {
debug(function() { return "options.sourceMappingURL comment"; });
comment = commentFormatter(options.sourceMappingURL(file));
}
}
// append source map comment
if (options.addComment){
file.contents = Buffer.concat([file.contents, new Buffer(comment)]);
}
}
return {
setSourceRoot: setSourceRoot,
loadContent: loadContent,
mapSources: mapSources,
mapDestPath: mapDestPath
};
};

70
node_modules/gulp-sourcemaps/src/write/index.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
'use strict';
var utils = require('../utils');
var through = require('through2');
var unixStylePath = utils.unixStylePath;
var internalsInit = require('./index.internals');
/**
* Write the source map
*
* @param options options to change the way the source map is written
*
*/
function write(destPath, options) {
var debug = require('../debug').spawn('write');
debug(function() { return "destPath"; });
debug(function() { return destPath; });
debug(function() { return "original options";});
debug(function() { return options; });
if (options === undefined && typeof destPath !== 'string') {
options = destPath;
destPath = undefined;
}
options = options || {};
// set defaults for options if unset
if (options.includeContent === undefined)
options.includeContent = true;
if (options.addComment === undefined)
options.addComment = true;
if (options.charset === undefined)
options.charset = "utf8";
debug(function() { return "derrived options"; });
debug(function() { return options; });
var internals = internalsInit(destPath, options);
function sourceMapWrite(file, encoding, callback) {
/*jshint validthis:true */
if (file.isNull() || !file.sourceMap) {
this.push(file);
return callback();
}
if (file.isStream()) {
return callback(new Error(utils.PLUGIN_NAME + '-write: Streaming not supported'));
}
// fix paths if Windows style paths
file.sourceMap.file = unixStylePath(file.relative);
internals.setSourceRoot(file);
internals.loadContent(file);
internals.mapSources(file);
internals.mapDestPath(file, this);
this.push(file);
callback();
}
return through.obj(sourceMapWrite);
}
module.exports = write;