Izmjenjena struktura, dodan backand

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

180
web/node_modules/babel-loader/lib/fs-cache.js generated vendored Normal file
View File

@@ -0,0 +1,180 @@
"use strict";
/**
* Filesystem cache
*
* Given a file and a transform function, cache the result into files
* or retrieve the previously cached files if the given file is already known.
*
* @see https://github.com/babel/babel-loader/issues/34
* @see https://github.com/babel/babel-loader/pull/41
*/
var crypto = require("crypto");
var mkdirp = require("mkdirp");
var findCacheDir = require("find-cache-dir");
var fs = require("fs");
var os = require("os");
var path = require("path");
var zlib = require("zlib");
var defaultCacheDirectory = null; // Lazily instantiated when needed
/**
* Read the contents from the compressed file.
*
* @async
* @params {String} filename
* @params {Function} callback
*/
var read = function read(filename, callback) {
return fs.readFile(filename, function (err, data) {
if (err) return callback(err);
return zlib.gunzip(data, function (err, content) {
if (err) return callback(err);
var result = {};
try {
result = JSON.parse(content);
} catch (e) {
return callback(e);
}
return callback(null, result);
});
});
};
/**
* Write contents into a compressed file.
*
* @async
* @params {String} filename
* @params {String} result
* @params {Function} callback
*/
var write = function write(filename, result, callback) {
var content = JSON.stringify(result);
return zlib.gzip(content, function (err, data) {
if (err) return callback(err);
return fs.writeFile(filename, data, callback);
});
};
/**
* Build the filename for the cached file
*
* @params {String} source File source code
* @params {Object} options Options used
*
* @return {String}
*/
var filename = function filename(source, identifier, options) {
var hash = crypto.createHash("SHA1");
var contents = JSON.stringify({
source: source,
options: options,
identifier: identifier
});
hash.end(contents);
return hash.read().toString("hex") + ".json.gz";
};
/**
* Handle the cache
*
* @params {String} directory
* @params {Object} params
* @params {Function} callback
*/
var handleCache = function handleCache(directory, params, callback) {
var source = params.source;
var options = params.options || {};
var transform = params.transform;
var identifier = params.identifier;
var shouldFallback = typeof params.directory !== "string" && directory !== os.tmpdir();
// Make sure the directory exists.
mkdirp(directory, function (err) {
// Fallback to tmpdir if node_modules folder not writable
if (err) return shouldFallback ? handleCache(os.tmpdir(), params, callback) : callback(err);
var file = path.join(directory, filename(source, identifier, options));
return read(file, function (err, content) {
var result = {};
// No errors mean that the file was previously cached
// we just need to return it
if (!err) return callback(null, content);
// Otherwise just transform the file
// return it to the user asap and write it in cache
try {
result = transform(source, options);
} catch (error) {
return callback(error);
}
return write(file, result, function (err) {
// Fallback to tmpdir if node_modules folder not writable
if (err) return shouldFallback ? handleCache(os.tmpdir(), params, callback) : callback(err);
callback(null, result);
});
});
});
};
/**
* Retrieve file from cache, or create a new one for future reads
*
* @async
* @param {Object} params
* @param {String} params.directory Directory to store cached files
* @param {String} params.identifier Unique identifier to bust cache
* @param {String} params.source Original contents of the file to be cached
* @param {Object} params.options Options to be given to the transform fn
* @param {Function} params.transform Function that will transform the
* original file and whose result will be
* cached
*
* @param {Function<err, result>} callback
*
* @example
*
* cache({
* directory: '.tmp/cache',
* identifier: 'babel-loader-cachefile',
* source: *source code from file*,
* options: {
* experimental: true,
* runtime: true
* },
* transform: function(source, options) {
* var content = *do what you need with the source*
* return content;
* }
* }, function(err, result) {
*
* });
*/
module.exports = function (params, callback) {
var directory = void 0;
if (typeof params.directory === "string") {
directory = params.directory;
} else {
if (defaultCacheDirectory === null) {
defaultCacheDirectory = findCacheDir({ name: "babel-loader" }) || os.tmpdir();
}
directory = defaultCacheDirectory;
}
handleCache(directory, params, callback);
};

173
web/node_modules/babel-loader/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,173 @@
"use strict";
var babel = require("babel-core");
var loaderUtils = require("loader-utils");
var path = require("path");
var cache = require("./fs-cache.js");
var exists = require("./utils/exists")();
var relative = require("./utils/relative");
var read = require("./utils/read")();
var resolveRc = require("./resolve-rc.js");
var pkg = require("../package.json");
/**
* Error thrown by Babel formatted to conform to Webpack reporting.
*/
function BabelLoaderError(name, message, codeFrame, hideStack, error) {
Error.call(this);
Error.captureStackTrace(this, BabelLoaderError);
this.name = "BabelLoaderError";
this.message = formatMessage(name, message, codeFrame);
this.hideStack = hideStack;
this.error = error;
}
BabelLoaderError.prototype = Object.create(Error.prototype);
BabelLoaderError.prototype.constructor = BabelLoaderError;
var STRIP_FILENAME_RE = /^[^:]+: /;
var formatMessage = function formatMessage(name, message, codeFrame) {
return (name ? name + ": " : "") + message + "\n\n" + codeFrame + "\n";
};
var transpile = function transpile(source, options) {
var forceEnv = options.forceEnv;
var tmpEnv = void 0;
delete options.forceEnv;
if (forceEnv) {
tmpEnv = process.env.BABEL_ENV;
process.env.BABEL_ENV = forceEnv;
}
var result = void 0;
try {
result = babel.transform(source, options);
} catch (error) {
if (forceEnv) restoreBabelEnv(tmpEnv);
if (error.message && error.codeFrame) {
var message = error.message;
var name = void 0;
var hideStack = void 0;
if (error instanceof SyntaxError) {
message = message.replace(STRIP_FILENAME_RE, "");
name = "SyntaxError";
hideStack = true;
} else if (error instanceof TypeError) {
message = message.replace(STRIP_FILENAME_RE, "");
hideStack = true;
}
throw new BabelLoaderError(name, message, error.codeFrame, hideStack, error);
} else {
throw error;
}
}
var code = result.code;
var map = result.map;
var metadata = result.metadata;
if (map && (!map.sourcesContent || !map.sourcesContent.length)) {
map.sourcesContent = [source];
}
if (forceEnv) restoreBabelEnv(tmpEnv);
return {
code: code,
map: map,
metadata: metadata
};
};
function restoreBabelEnv(prevValue) {
if (prevValue === undefined) {
delete process.env.BABEL_ENV;
} else {
process.env.BABEL_ENV = prevValue;
}
}
function passMetadata(s, context, metadata) {
if (context[s]) {
context[s](metadata);
}
}
module.exports = function (source, inputSourceMap) {
var _this = this;
// Handle filenames (#106)
var webpackRemainingChain = loaderUtils.getRemainingRequest(this).split("!");
var filename = webpackRemainingChain[webpackRemainingChain.length - 1];
// Handle options
var loaderOptions = loaderUtils.getOptions(this) || {};
var defaultOptions = {
metadataSubscribers: [],
inputSourceMap: inputSourceMap,
sourceRoot: process.cwd(),
filename: filename,
cacheIdentifier: JSON.stringify({
"babel-loader": pkg.version,
"babel-core": babel.version,
babelrc: exists(loaderOptions.babelrc) ? read(loaderOptions.babelrc) : resolveRc(path.dirname(filename)),
env: loaderOptions.forceEnv || process.env.BABEL_ENV || process.env.NODE_ENV || "development"
})
};
var options = Object.assign({}, defaultOptions, loaderOptions);
if (loaderOptions.sourceMap === undefined) {
options.sourceMap = this.sourceMap;
}
if (options.sourceFileName === undefined) {
options.sourceFileName = relative(options.sourceRoot, options.filename);
}
var cacheDirectory = options.cacheDirectory;
var cacheIdentifier = options.cacheIdentifier;
var metadataSubscribers = options.metadataSubscribers;
delete options.cacheDirectory;
delete options.cacheIdentifier;
delete options.metadataSubscribers;
if (cacheDirectory) {
var callback = this.async();
return cache({
directory: cacheDirectory,
identifier: cacheIdentifier,
source: source,
options: options,
transform: transpile
}, function (err) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
code = _ref.code,
map = _ref.map,
metadata = _ref.metadata;
if (err) return callback(err);
metadataSubscribers.forEach(function (s) {
return passMetadata(s, _this, metadata);
});
return callback(null, code, map);
});
}
var _transpile = transpile(source, options),
code = _transpile.code,
map = _transpile.map,
metadata = _transpile.metadata;
metadataSubscribers.forEach(function (s) {
return passMetadata(s, _this, metadata);
});
this.callback(null, code, map);
};

38
web/node_modules/babel-loader/lib/resolve-rc.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
"use strict";
/**
* The purpose of this module, is to find the project's .babelrc and
* use its contents to bust the babel-loader's internal cache whenever an option
* changes.
*
* @see https://github.com/babel/babel-loader/issues/62
* @see http://git.io/vLEvu
*/
var path = require("path");
var exists = require("./utils/exists")({});
var read = require("./utils/read")({});
var cache = {};
var find = function find(start, rel) {
var file = path.join(start, rel);
if (exists(file)) {
return read(file);
}
var up = path.dirname(start);
if (up !== start) {
// Reached root
return find(up, rel);
}
};
module.exports = function (loc, rel) {
rel = rel || ".babelrc";
var cacheKey = `${loc}/${rel}`;
if (!(cacheKey in cache)) {
cache[cacheKey] = find(loc, rel);
}
return cache[cacheKey];
};

22
web/node_modules/babel-loader/lib/utils/exists.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
var fs = require("fs");
/**
* Check if file exists and cache the result
* return the result in cache
*
* @example
* var exists = require('./helpers/fsExists')({});
* exists('.babelrc'); // false
*/
module.exports = function (cache) {
cache = cache || {};
return function (filename) {
if (!filename) return false;
cache[filename] = cache[filename] || fs.existsSync(filename) && fs.statSync(filename).isFile();
return cache[filename];
};
};

24
web/node_modules/babel-loader/lib/utils/read.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
var fs = require("fs");
/**
* Read the file and cache the result
* return the result in cache
*
* @example
* var read = require('./helpers/fsExists')({});
* read('.babelrc'); // file contents...
*/
module.exports = function (cache) {
cache = cache || {};
return function (filename) {
if (!filename) {
throw new Error("filename must be a string");
}
cache[filename] = cache[filename] || fs.readFileSync(filename, "utf8");
return cache[filename];
};
};

15
web/node_modules/babel-loader/lib/utils/relative.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
"use strict";
var path = require("path");
module.exports = function relative(sourceRoot, filename) {
var rootPath = sourceRoot.replace(/\\/g, "/").split("/")[1];
var fileRootPath = filename.replace(/\\/g, "/").split("/")[1];
// If the file is in a completely different root folder use the absolute path of file.
if (rootPath && rootPath !== fileRootPath) {
return filename;
}
return path.relative(sourceRoot, filename);
};