node_modules

This commit is contained in:
saeid
2019-07-15 13:07:31 +04:30
parent d3735c6d30
commit ce1a3ebf9c
35713 changed files with 3639219 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
'use strict';
module.exports = require('./index').default;
+123
View File
@@ -0,0 +1,123 @@
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/* eslint-disable class-methods-use-this */
var less = require('less');
var loaderUtils = require('loader-utils');
var pify = require('pify');
var stringifyLoader = require.resolve('./stringifyLoader.js');
var trailingSlash = /[/\\]$/;
var isLessCompatible = /\.(le|c)ss$/;
// Less automatically adds a .less file extension if no extension was given.
// This is problematic if there is a module request like @import "~some-module";
// because in this case Less will call our file manager with `~some-module.less`.
// Since dots in module names are highly discouraged, we can safely assume that
// this is an error and we need to remove the .less extension again.
// However, we must not match something like @import "~some-module/file.less";
var matchMalformedModuleFilename = /(~[^/\\]+)\.less$/;
// This somewhat changed in Less 3.x. Now the file name comes without the
// automatically added extension whereas the extension is passed in as `options.ext`.
// So, if the file name matches this regexp, we simply ignore the proposed extension.
var isModuleName = /^~[^/\\]+$/;
/**
* Creates a Less plugin that uses webpack's resolving engine that is provided by the loaderContext.
*
* @param {LoaderContext} loaderContext
* @param {string=} root
* @returns {LessPlugin}
*/
function createWebpackLessPlugin(loaderContext) {
var fs = loaderContext.fs;
var resolve = pify(loaderContext.resolve.bind(loaderContext));
var loadModule = pify(loaderContext.loadModule.bind(loaderContext));
var readFile = pify(fs.readFile.bind(fs));
var WebpackFileManager = function (_less$FileManager) {
_inherits(WebpackFileManager, _less$FileManager);
function WebpackFileManager() {
_classCallCheck(this, WebpackFileManager);
return _possibleConstructorReturn(this, (WebpackFileManager.__proto__ || Object.getPrototypeOf(WebpackFileManager)).apply(this, arguments));
}
_createClass(WebpackFileManager, [{
key: 'supports',
value: function supports() {
// Our WebpackFileManager handles all the files
return true;
}
// Sync resolving is used at least by the `data-uri` function.
// This file manager doesn't know how to do it, so let's delegate it
// to the default file manager of Less.
// We could probably use loaderContext.resolveSync, but it's deprecated,
// see https://webpack.js.org/api/loaders/#this-resolvesync
}, {
key: 'supportsSync',
value: function supportsSync() {
return false;
}
}, {
key: 'loadFile',
value: function loadFile(filename, currentDirectory, options) {
var url = void 0;
if (less.version[0] >= 3) {
if (options.ext && !isModuleName.test(filename)) {
url = this.tryAppendExtension(filename, options.ext);
} else {
url = filename;
}
} else {
url = filename.replace(matchMalformedModuleFilename, '$1');
}
var moduleRequest = loaderUtils.urlToRequest(url, url.charAt(0) === '/' ? '' : null);
// Less is giving us trailing slashes, but the context should have no trailing slash
var context = currentDirectory.replace(trailingSlash, '');
var resolvedFilename = void 0;
return resolve(context, moduleRequest).then(function (f) {
resolvedFilename = f;
loaderContext.addDependency(resolvedFilename);
if (isLessCompatible.test(resolvedFilename)) {
return readFile(resolvedFilename).then(function (contents) {
return contents.toString('utf8');
});
}
return loadModule([stringifyLoader, resolvedFilename].join('!')).then(JSON.parse);
}).then(function (contents) {
return {
contents,
filename: resolvedFilename
};
});
}
}]);
return WebpackFileManager;
}(less.FileManager);
return {
install(lessInstance, pluginManager) {
pluginManager.addFileManager(new WebpackFileManager());
},
minVersion: [2, 1, 1]
};
}
module.exports = createWebpackLessPlugin;
+62
View File
@@ -0,0 +1,62 @@
'use strict';
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var os = require('os');
/**
* Tries to get an excerpt of the file where the error happened.
* Uses err.line and err.column.
*
* Returns an empty string if the excerpt could not be retrieved.
*
* @param {LessError} err
* @returns {Array<string>}
*/
function getFileExcerptIfPossible(lessErr) {
try {
var excerpt = lessErr.extract.slice(0, 2);
var column = Math.max(lessErr.column - 1, 0);
if (typeof excerpt[0] === 'undefined') {
excerpt.shift();
}
excerpt.push(`${new Array(column).join(' ')}^`);
return excerpt;
} catch (unexpectedErr) {
// If anything goes wrong here, we don't want any errors to be reported to the user
return [];
}
}
/**
* Beautifies the error message from Less.
*
* @param {LessError} lessErr
* @param {string} lessErr.type - e.g. 'Name'
* @param {string} lessErr.message - e.g. '.undefined-mixin is undefined'
* @param {string} lessErr.filename - e.g. '/path/to/style.less'
* @param {number} lessErr.index - e.g. 352
* @param {number} lessErr.line - e.g. 31
* @param {number} lessErr.callLine - e.g. NaN
* @param {string} lessErr.callExtract - e.g. undefined
* @param {number} lessErr.column - e.g. 6
* @param {Array<string>} lessErr.extract - e.g. [' .my-style {', ' .undefined-mixin;', ' display: block;']
* @returns {LessError}
*/
function formatLessError(err) {
/* eslint-disable no-param-reassign */
var msg = err.message;
// Instruct webpack to hide the JS stack from the console
// Usually you're only interested in the SASS stack in this case.
err.hideStack = true;
err.message = [os.EOL].concat(_toConsumableArray(getFileExcerptIfPossible(err)), [msg.charAt(0).toUpperCase() + msg.slice(1), ` in ${err.filename} (line ${err.line}, column ${err.column})`]).join(os.EOL);
return err;
} /* eslint-enable no-param-reassign */
module.exports = formatLessError;
+41
View File
@@ -0,0 +1,41 @@
'use strict';
var loaderUtils = require('loader-utils');
var clone = require('clone');
var createWebpackLessPlugin = require('./createWebpackLessPlugin');
/**
* Retrieves the options from the loaderContext, makes a deep copy of it and normalizes it for further consumption.
*
* @param {LoaderContext} loaderContext
*/
function getOptions(loaderContext) {
var options = Object.assign({
plugins: [],
relativeUrls: true,
compress: Boolean(loaderContext.minimize)
}, clone(loaderUtils.getOptions(loaderContext)));
// We need to set the filename because otherwise our WebpackFileManager will receive an undefined path for the entry
options.filename = loaderContext.resource;
// When no paths are given, we use the webpack resolver
if ('paths' in options === false) {
// It's safe to mutate the array now because it has already been cloned
options.plugins.push(createWebpackLessPlugin(loaderContext));
}
if (options.sourceMap) {
if (typeof options.sourceMap === 'boolean') {
options.sourceMap = {};
}
if ('outputSourceFiles' in options.sourceMap === false) {
// Include source files as `sourceContents` as sane default since this makes source maps "just work" in most cases
options.sourceMap.outputSourceFiles = true;
}
}
return options;
}
module.exports = getOptions;
+40
View File
@@ -0,0 +1,40 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _less = require('less');
var _less2 = _interopRequireDefault(_less);
var _pify = require('pify');
var _pify2 = _interopRequireDefault(_pify);
var _processResult = require('./processResult');
var _processResult2 = _interopRequireDefault(_processResult);
var _getOptions = require('./getOptions');
var _getOptions2 = _interopRequireDefault(_getOptions);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var render = (0, _pify2.default)(_less2.default.render.bind(_less2.default));
function lessLoader(source) {
var loaderContext = this;
var options = (0, _getOptions2.default)(loaderContext);
var done = loaderContext.async();
var isSync = typeof done !== 'function';
if (isSync) {
throw new Error('Synchronous compilation is not supported anymore. See https://github.com/webpack-contrib/less-loader/issues/84');
}
(0, _processResult2.default)(loaderContext, render(source, options));
}
exports.default = lessLoader;
+38
View File
@@ -0,0 +1,38 @@
'use strict';
var removeSourceMappingUrl = require('./removeSourceMappingUrl');
var formatLessError = require('./formatLessError');
/**
* Removes the sourceMappingURL from the generated CSS, parses the source map and calls the next loader.
*
* @param {loaderContext} loaderContext
* @param {Promise<LessResult>} resultPromise
*/
function processResult(loaderContext, resultPromise) {
var callback = loaderContext.callback;
resultPromise.then(function (_ref) {
var css = _ref.css,
map = _ref.map,
imports = _ref.imports;
imports.forEach(loaderContext.addDependency, loaderContext);
return {
// Removing the sourceMappingURL comment.
// See removeSourceMappingUrl.js for the reasoning behind this.
css: removeSourceMappingUrl(css),
map: typeof map === 'string' ? JSON.parse(map) : map
};
}, function (lessError) {
throw formatLessError(lessError);
}).then(function (_ref2) {
var css = _ref2.css,
map = _ref2.map;
callback(null, css, map);
}, callback);
}
module.exports = processResult;
+19
View File
@@ -0,0 +1,19 @@
'use strict';
var matchSourceMappingUrl = /\/\*# sourceMappingURL=[^*]+\*\//;
/**
* Removes the sourceMappingURL comment. This is necessary because the less-loader
* does not know where the final source map will be located. Thus, we remove every
* reference to source maps. In a regular setup, the css-loader will embed the
* source maps into the CommonJS module and the style-loader will translate it into
* base64 blob urls.
*
* @param {string} content
* @returns {string}
*/
function removeSourceMappingUrl(content) {
return content.replace(matchSourceMappingUrl, '');
}
module.exports = removeSourceMappingUrl;
+14
View File
@@ -0,0 +1,14 @@
"use strict";
/**
* The stringifyLoader turns any content into a valid JavaScript string. This allows us to load any content
* with loaderContext.loadModule() without webpack complaining about non-JS modules.
*
* @param {string} content
* @return {string}
*/
function stringifyLoader(content) {
return JSON.stringify(content);
}
module.exports = stringifyLoader;