mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 05:32:18 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
38
web/node_modules/css-loader/dist/CssSyntaxError.js
generated
vendored
Normal file
38
web/node_modules/css-loader/dist/CssSyntaxError.js
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class CssSyntaxError extends Error {
|
||||
constructor(error) {
|
||||
super(error);
|
||||
const {
|
||||
reason,
|
||||
line,
|
||||
column
|
||||
} = error;
|
||||
this.name = 'CssSyntaxError'; // Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
|
||||
// We don't need `plugin` and `file` properties.
|
||||
|
||||
this.message = `${this.name}\n\n`;
|
||||
|
||||
if (typeof line !== 'undefined') {
|
||||
this.message += `(${line}:${column}) `;
|
||||
}
|
||||
|
||||
this.message += `${reason}`;
|
||||
const code = error.showSourceCode();
|
||||
|
||||
if (code) {
|
||||
this.message += `\n\n${code}\n`;
|
||||
} // We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
|
||||
|
||||
|
||||
this.stack = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = CssSyntaxError;
|
32
web/node_modules/css-loader/dist/Warning.js
generated
vendored
Normal file
32
web/node_modules/css-loader/dist/Warning.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class Warning extends Error {
|
||||
constructor(warning) {
|
||||
super(warning);
|
||||
const {
|
||||
text,
|
||||
line,
|
||||
column
|
||||
} = warning;
|
||||
this.name = 'Warning'; // Based on https://github.com/postcss/postcss/blob/master/lib/warning.es6#L74
|
||||
// We don't need `plugin` properties.
|
||||
|
||||
this.message = `${this.name}\n\n`;
|
||||
|
||||
if (typeof line !== 'undefined') {
|
||||
this.message += `(${line}:${column}) `;
|
||||
}
|
||||
|
||||
this.message += `${text}`; // We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
|
||||
|
||||
this.stack = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Warning;
|
5
web/node_modules/css-loader/dist/cjs.js
generated
vendored
Normal file
5
web/node_modules/css-loader/dist/cjs.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
const loader = require('./index');
|
||||
|
||||
module.exports = loader.default;
|
176
web/node_modules/css-loader/dist/index.js
generated
vendored
Normal file
176
web/node_modules/css-loader/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,176 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = loader;
|
||||
|
||||
var _loaderUtils = require("loader-utils");
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _package = _interopRequireDefault(require("postcss/package.json"));
|
||||
|
||||
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
|
||||
|
||||
var _semver = require("semver");
|
||||
|
||||
var _CssSyntaxError = _interopRequireDefault(require("./CssSyntaxError"));
|
||||
|
||||
var _Warning = _interopRequireDefault(require("./Warning"));
|
||||
|
||||
var _options = _interopRequireDefault(require("./options.json"));
|
||||
|
||||
var _plugins = require("./plugins");
|
||||
|
||||
var _utils = require("./utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
async function loader(content, map, meta) {
|
||||
const rawOptions = (0, _loaderUtils.getOptions)(this);
|
||||
(0, _schemaUtils.default)(_options.default, rawOptions, {
|
||||
name: 'CSS Loader',
|
||||
baseDataPath: 'options'
|
||||
});
|
||||
const plugins = [];
|
||||
const callback = this.async();
|
||||
let options;
|
||||
|
||||
try {
|
||||
options = (0, _utils.normalizeOptions)(rawOptions, this);
|
||||
} catch (error) {
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
|
||||
const replacements = [];
|
||||
const exports = [];
|
||||
|
||||
if ((0, _utils.shouldUseModulesPlugins)(options)) {
|
||||
plugins.push(...(0, _utils.getModulesPlugins)(options, this));
|
||||
}
|
||||
|
||||
const importPluginImports = [];
|
||||
const importPluginApi = [];
|
||||
|
||||
if ((0, _utils.shouldUseImportPlugin)(options)) {
|
||||
const resolver = this.getResolve({
|
||||
conditionNames: ['style'],
|
||||
extensions: ['.css'],
|
||||
mainFields: ['css', 'style', 'main', '...'],
|
||||
mainFiles: ['index', '...'],
|
||||
restrictions: [/\.css$/i]
|
||||
});
|
||||
plugins.push((0, _plugins.importParser)({
|
||||
imports: importPluginImports,
|
||||
api: importPluginApi,
|
||||
context: this.context,
|
||||
rootContext: this.rootContext,
|
||||
filter: (0, _utils.getFilter)(options.import, this.resourcePath),
|
||||
resolver,
|
||||
urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, (0, _utils.getPreRequester)(this)(options.importLoaders) + url)
|
||||
}));
|
||||
}
|
||||
|
||||
const urlPluginImports = [];
|
||||
|
||||
if ((0, _utils.shouldUseURLPlugin)(options)) {
|
||||
const urlResolver = this.getResolve({
|
||||
conditionNames: ['asset'],
|
||||
mainFields: ['asset'],
|
||||
mainFiles: [],
|
||||
extensions: []
|
||||
});
|
||||
plugins.push((0, _plugins.urlParser)({
|
||||
imports: urlPluginImports,
|
||||
replacements,
|
||||
context: this.context,
|
||||
rootContext: this.rootContext,
|
||||
filter: (0, _utils.getFilter)(options.url, this.resourcePath),
|
||||
resolver: urlResolver,
|
||||
urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, url)
|
||||
}));
|
||||
}
|
||||
|
||||
const icssPluginImports = [];
|
||||
const icssPluginApi = [];
|
||||
|
||||
if ((0, _utils.shouldUseIcssPlugin)(options)) {
|
||||
const icssResolver = this.getResolve({
|
||||
conditionNames: ['style'],
|
||||
extensions: [],
|
||||
mainFields: ['css', 'style', 'main', '...'],
|
||||
mainFiles: ['index', '...']
|
||||
});
|
||||
plugins.push((0, _plugins.icssParser)({
|
||||
imports: icssPluginImports,
|
||||
api: icssPluginApi,
|
||||
replacements,
|
||||
exports,
|
||||
context: this.context,
|
||||
rootContext: this.rootContext,
|
||||
resolver: icssResolver,
|
||||
urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, (0, _utils.getPreRequester)(this)(options.importLoaders) + url)
|
||||
}));
|
||||
} // Reuse CSS AST (PostCSS AST e.g 'postcss-loader') to avoid reparsing
|
||||
|
||||
|
||||
if (meta) {
|
||||
const {
|
||||
ast
|
||||
} = meta;
|
||||
|
||||
if (ast && ast.type === 'postcss' && (0, _semver.satisfies)(ast.version, `^${_package.default.version}`)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
content = ast.root;
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
resourcePath
|
||||
} = this;
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = await (0, _postcss.default)(plugins).process(content, {
|
||||
from: resourcePath,
|
||||
to: resourcePath,
|
||||
map: options.sourceMap ? {
|
||||
prev: map ? (0, _utils.normalizeSourceMap)(map, resourcePath) : null,
|
||||
inline: false,
|
||||
annotation: false
|
||||
} : false
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.file) {
|
||||
this.addDependency(error.file);
|
||||
}
|
||||
|
||||
callback(error.name === 'CssSyntaxError' ? new _CssSyntaxError.default(error) : error);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const warning of result.warnings()) {
|
||||
this.emitWarning(new _Warning.default(warning));
|
||||
}
|
||||
|
||||
const imports = [].concat(icssPluginImports.sort(_utils.sort)).concat(importPluginImports.sort(_utils.sort)).concat(urlPluginImports.sort(_utils.sort));
|
||||
const api = [].concat(importPluginApi.sort(_utils.sort)).concat(icssPluginApi.sort(_utils.sort));
|
||||
|
||||
if (options.modules.exportOnlyLocals !== true) {
|
||||
imports.unshift({
|
||||
importName: '___CSS_LOADER_API_IMPORT___',
|
||||
url: (0, _loaderUtils.stringifyRequest)(this, require.resolve('./runtime/api'))
|
||||
});
|
||||
}
|
||||
|
||||
const importCode = (0, _utils.getImportCode)(imports, options);
|
||||
const moduleCode = (0, _utils.getModuleCode)(result, api, replacements, options, this);
|
||||
const exportCode = (0, _utils.getExportCode)(exports, replacements, options);
|
||||
callback(null, `${importCode}${moduleCode}${exportCode}`);
|
||||
}
|
153
web/node_modules/css-loader/dist/options.json
generated
vendored
Normal file
153
web/node_modules/css-loader/dist/options.json
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"import": {
|
||||
"description": "Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": {
|
||||
"description": "Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"enum": ["local", "global", "pure"]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"compileType": {
|
||||
"description": "Controls the extent to which css-loader will process module code (https://github.com/webpack-contrib/css-loader#type)",
|
||||
"enum": ["module", "icss"]
|
||||
},
|
||||
"auto": {
|
||||
"description": "Allows auto enable CSS modules based on filename (https://github.com/webpack-contrib/css-loader#auto).",
|
||||
"anyOf": [
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mode": {
|
||||
"description": "Setup `mode` option (https://github.com/webpack-contrib/css-loader#mode).",
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": ["local", "global", "pure"]
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"localIdentName": {
|
||||
"description": "Allows to configure the generated local ident name (https://github.com/webpack-contrib/css-loader#localidentname).",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"localIdentContext": {
|
||||
"description": "Allows to redefine basic loader context for local ident name (https://github.com/webpack-contrib/css-loader#localidentcontext).",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"localIdentHashPrefix": {
|
||||
"description": "Allows to add custom hash to generate more unique classes (https://github.com/webpack-contrib/css-loader#localidenthashprefix).",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"localIdentRegExp": {
|
||||
"description": "Allows to specify custom RegExp for local ident name (https://github.com/webpack-contrib/css-loader#localidentregexp).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
}
|
||||
]
|
||||
},
|
||||
"getLocalIdent": {
|
||||
"description": "Allows to specify a function to generate the classname (https://github.com/webpack-contrib/css-loader#getlocalident).",
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"namedExport": {
|
||||
"description": "Enables/disables ES modules named export for locals (https://github.com/webpack-contrib/css-loader#namedexport).",
|
||||
"type": "boolean"
|
||||
},
|
||||
"exportGlobals": {
|
||||
"description": "Allows to export names from global class or id, so you can use that as local name (https://github.com/webpack-contrib/css-loader#exportglobals).",
|
||||
"type": "boolean"
|
||||
},
|
||||
"exportLocalsConvention": {
|
||||
"description": "Style of exported classnames (https://github.com/webpack-contrib/css-loader#localsconvention).",
|
||||
"enum": [
|
||||
"asIs",
|
||||
"camelCase",
|
||||
"camelCaseOnly",
|
||||
"dashes",
|
||||
"dashesOnly"
|
||||
]
|
||||
},
|
||||
"exportOnlyLocals": {
|
||||
"description": "Export only locals (https://github.com/webpack-contrib/css-loader#exportonlylocals).",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"icss": {
|
||||
"description": "Enables/Disables handling the CSS module interoperable import/export format ((https://github.com/webpack-contrib/css-loader#icss)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"sourceMap": {
|
||||
"description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/css-loader#sourcemap).",
|
||||
"type": "boolean"
|
||||
},
|
||||
"importLoaders": {
|
||||
"description": "Enables/Disables or setups number of loaders applied before CSS loader (https://github.com/webpack-contrib/css-loader#importloaders).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"esModule": {
|
||||
"description": "Use the ES modules syntax (https://github.com/webpack-contrib/css-loader#esmodule).",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
31
web/node_modules/css-loader/dist/plugins/index.js
generated
vendored
Normal file
31
web/node_modules/css-loader/dist/plugins/index.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "importParser", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _postcssImportParser.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "icssParser", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _postcssIcssParser.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "urlParser", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _postcssUrlParser.default;
|
||||
}
|
||||
});
|
||||
|
||||
var _postcssImportParser = _interopRequireDefault(require("./postcss-import-parser"));
|
||||
|
||||
var _postcssIcssParser = _interopRequireDefault(require("./postcss-icss-parser"));
|
||||
|
||||
var _postcssUrlParser = _interopRequireDefault(require("./postcss-url-parser"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
113
web/node_modules/css-loader/dist/plugins/postcss-icss-parser.js
generated
vendored
Normal file
113
web/node_modules/css-loader/dist/plugins/postcss-icss-parser.js
generated
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _icssUtils = require("icss-utils");
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = _postcss.default.plugin('postcss-icss-parser', options => async css => {
|
||||
const importReplacements = Object.create(null);
|
||||
const {
|
||||
icssImports,
|
||||
icssExports
|
||||
} = (0, _icssUtils.extractICSS)(css);
|
||||
const imports = new Map();
|
||||
const tasks = []; // eslint-disable-next-line guard-for-in
|
||||
|
||||
for (const url in icssImports) {
|
||||
const tokens = icssImports[url];
|
||||
|
||||
if (Object.keys(tokens).length === 0) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
let normalizedUrl = url;
|
||||
let prefix = '';
|
||||
const queryParts = normalizedUrl.split('!');
|
||||
|
||||
if (queryParts.length > 1) {
|
||||
normalizedUrl = queryParts.pop();
|
||||
prefix = queryParts.join('!');
|
||||
}
|
||||
|
||||
const request = (0, _utils.requestify)((0, _utils.normalizeUrl)(normalizedUrl, true), options.rootContext);
|
||||
|
||||
const doResolve = async () => {
|
||||
const {
|
||||
resolver,
|
||||
context
|
||||
} = options;
|
||||
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, context, [...new Set([normalizedUrl, request])]);
|
||||
return {
|
||||
url: resolvedUrl,
|
||||
prefix,
|
||||
tokens
|
||||
};
|
||||
};
|
||||
|
||||
tasks.push(doResolve());
|
||||
}
|
||||
|
||||
const results = await Promise.all(tasks);
|
||||
|
||||
for (let index = 0; index <= results.length - 1; index++) {
|
||||
const {
|
||||
url,
|
||||
prefix,
|
||||
tokens
|
||||
} = results[index];
|
||||
const newUrl = prefix ? `${prefix}!${url}` : url;
|
||||
const importKey = newUrl;
|
||||
let importName = imports.get(importKey);
|
||||
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_ICSS_IMPORT_${imports.size}___`;
|
||||
imports.set(importKey, importName);
|
||||
options.imports.push({
|
||||
importName,
|
||||
url: options.urlHandler(newUrl),
|
||||
icss: true,
|
||||
index
|
||||
});
|
||||
options.api.push({
|
||||
importName,
|
||||
dedupe: true,
|
||||
index
|
||||
});
|
||||
}
|
||||
|
||||
for (const [replacementIndex, token] of Object.keys(tokens).entries()) {
|
||||
const replacementName = `___CSS_LOADER_ICSS_IMPORT_${index}_REPLACEMENT_${replacementIndex}___`;
|
||||
const localName = tokens[token];
|
||||
importReplacements[token] = replacementName;
|
||||
options.replacements.push({
|
||||
replacementName,
|
||||
importName,
|
||||
localName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(importReplacements).length > 0) {
|
||||
(0, _icssUtils.replaceSymbols)(css, importReplacements);
|
||||
}
|
||||
|
||||
for (const name of Object.keys(icssExports)) {
|
||||
const value = (0, _icssUtils.replaceValueSymbols)(icssExports[name], importReplacements);
|
||||
options.exports.push({
|
||||
name,
|
||||
value
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
exports.default = _default;
|
214
web/node_modules/css-loader/dist/plugins/postcss-import-parser.js
generated
vendored
Normal file
214
web/node_modules/css-loader/dist/plugins/postcss-import-parser.js
generated
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _util = require("util");
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const pluginName = 'postcss-import-parser';
|
||||
|
||||
function walkAtRules(css, result, options, callback) {
|
||||
const accumulator = [];
|
||||
css.walkAtRules(/^import$/i, atRule => {
|
||||
// Convert only top-level @import
|
||||
if (atRule.parent.type !== 'root') {
|
||||
return;
|
||||
} // Nodes do not exists - `@import url('http://') :root {}`
|
||||
|
||||
|
||||
if (atRule.nodes) {
|
||||
result.warn("It looks like you didn't end your @import statement correctly. Child nodes are attached to it.", {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
nodes: paramsNodes
|
||||
} = (0, _postcssValueParser.default)(atRule.params); // No nodes - `@import ;`
|
||||
// Invalid type - `@import foo-bar;`
|
||||
|
||||
if (paramsNodes.length === 0 || paramsNodes[0].type !== 'string' && paramsNodes[0].type !== 'function') {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let isStringValue;
|
||||
let url;
|
||||
|
||||
if (paramsNodes[0].type === 'string') {
|
||||
isStringValue = true;
|
||||
url = paramsNodes[0].value;
|
||||
} else {
|
||||
// Invalid function - `@import nourl(test.css);`
|
||||
if (paramsNodes[0].value.toLowerCase() !== 'url') {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
isStringValue = paramsNodes[0].nodes.length !== 0 && paramsNodes[0].nodes[0].type === 'string';
|
||||
url = isStringValue ? paramsNodes[0].nodes[0].value : _postcssValueParser.default.stringify(paramsNodes[0].nodes);
|
||||
} // Empty url - `@import "";` or `@import url();`
|
||||
|
||||
|
||||
if (url.trim().length === 0) {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
accumulator.push({
|
||||
atRule,
|
||||
url,
|
||||
isStringValue,
|
||||
mediaNodes: paramsNodes.slice(1)
|
||||
});
|
||||
});
|
||||
callback(null, accumulator);
|
||||
}
|
||||
|
||||
const asyncWalkAtRules = (0, _util.promisify)(walkAtRules);
|
||||
|
||||
var _default = _postcss.default.plugin(pluginName, options => async (css, result) => {
|
||||
const parsedResults = await asyncWalkAtRules(css, result, options);
|
||||
|
||||
if (parsedResults.length === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const imports = new Map();
|
||||
const tasks = [];
|
||||
|
||||
for (const parsedResult of parsedResults) {
|
||||
const {
|
||||
atRule,
|
||||
url,
|
||||
isStringValue,
|
||||
mediaNodes
|
||||
} = parsedResult;
|
||||
let normalizedUrl = url;
|
||||
let prefix = '';
|
||||
const isRequestable = (0, _utils.isUrlRequestable)(normalizedUrl);
|
||||
|
||||
if (isRequestable) {
|
||||
const queryParts = normalizedUrl.split('!');
|
||||
|
||||
if (queryParts.length > 1) {
|
||||
normalizedUrl = queryParts.pop();
|
||||
prefix = queryParts.join('!');
|
||||
}
|
||||
|
||||
normalizedUrl = (0, _utils.normalizeUrl)(normalizedUrl, isStringValue); // Empty url after normalize - `@import '\
|
||||
// \
|
||||
// \
|
||||
// ';
|
||||
|
||||
if (normalizedUrl.trim().length === 0) {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
}); // eslint-disable-next-line no-continue
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let media;
|
||||
|
||||
if (mediaNodes.length > 0) {
|
||||
media = _postcssValueParser.default.stringify(mediaNodes).trim().toLowerCase();
|
||||
}
|
||||
|
||||
if (options.filter && !options.filter(normalizedUrl, media)) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
atRule.remove();
|
||||
|
||||
if (isRequestable) {
|
||||
const request = (0, _utils.requestify)(normalizedUrl, options.rootContext);
|
||||
tasks.push((async () => {
|
||||
const {
|
||||
resolver,
|
||||
context
|
||||
} = options;
|
||||
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, context, [...new Set([request, normalizedUrl])]);
|
||||
return {
|
||||
url: resolvedUrl,
|
||||
media,
|
||||
prefix,
|
||||
isRequestable
|
||||
};
|
||||
})());
|
||||
} else {
|
||||
tasks.push({
|
||||
url,
|
||||
media,
|
||||
prefix,
|
||||
isRequestable
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const results = await Promise.all(tasks);
|
||||
|
||||
for (let index = 0; index <= results.length - 1; index++) {
|
||||
const {
|
||||
url,
|
||||
isRequestable,
|
||||
media
|
||||
} = results[index];
|
||||
|
||||
if (isRequestable) {
|
||||
const {
|
||||
prefix
|
||||
} = results[index];
|
||||
const newUrl = prefix ? `${prefix}!${url}` : url;
|
||||
const importKey = newUrl;
|
||||
let importName = imports.get(importKey);
|
||||
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_AT_RULE_IMPORT_${imports.size}___`;
|
||||
imports.set(importKey, importName);
|
||||
options.imports.push({
|
||||
importName,
|
||||
url: options.urlHandler(newUrl),
|
||||
index
|
||||
});
|
||||
}
|
||||
|
||||
options.api.push({
|
||||
importName,
|
||||
media,
|
||||
index
|
||||
}); // eslint-disable-next-line no-continue
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
options.api.push({
|
||||
url,
|
||||
media,
|
||||
index
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
exports.default = _default;
|
257
web/node_modules/css-loader/dist/plugins/postcss-url-parser.js
generated
vendored
Normal file
257
web/node_modules/css-loader/dist/plugins/postcss-url-parser.js
generated
vendored
Normal file
|
@ -0,0 +1,257 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _util = require("util");
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const pluginName = 'postcss-url-parser';
|
||||
const isUrlFunc = /url/i;
|
||||
const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
|
||||
const needParseDecl = /(?:url|(?:-webkit-)?image-set)\(/i;
|
||||
|
||||
function getNodeFromUrlFunc(node) {
|
||||
return node.nodes && node.nodes[0];
|
||||
}
|
||||
|
||||
function shouldHandleRule(rule, decl, result) {
|
||||
// https://www.w3.org/TR/css-syntax-3/#typedef-url-token
|
||||
if (rule.url.replace(/^[\s]+|[\s]+$/g, '').length === 0) {
|
||||
result.warn(`Unable to find uri in '${decl.toString()}'`, {
|
||||
node: decl
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(0, _utils.isUrlRequestable)(rule.url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function walkCss(css, result, options, callback) {
|
||||
const accumulator = [];
|
||||
css.walkDecls(decl => {
|
||||
if (!needParseDecl.test(decl.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsed = (0, _postcssValueParser.default)(decl.value);
|
||||
parsed.walk(node => {
|
||||
if (node.type !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUrlFunc.test(node.value)) {
|
||||
const {
|
||||
nodes
|
||||
} = node;
|
||||
const isStringValue = nodes.length !== 0 && nodes[0].type === 'string';
|
||||
const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
||||
const rule = {
|
||||
node: getNodeFromUrlFunc(node),
|
||||
url,
|
||||
needQuotes: false,
|
||||
isStringValue
|
||||
};
|
||||
|
||||
if (shouldHandleRule(rule, decl, result)) {
|
||||
accumulator.push({
|
||||
decl,
|
||||
rule,
|
||||
parsed
|
||||
});
|
||||
} // Do not traverse inside `url`
|
||||
// eslint-disable-next-line consistent-return
|
||||
|
||||
|
||||
return false;
|
||||
} else if (isImageSetFunc.test(node.value)) {
|
||||
for (const nNode of node.nodes) {
|
||||
const {
|
||||
type,
|
||||
value
|
||||
} = nNode;
|
||||
|
||||
if (type === 'function' && isUrlFunc.test(value)) {
|
||||
const {
|
||||
nodes
|
||||
} = nNode;
|
||||
const isStringValue = nodes.length !== 0 && nodes[0].type === 'string';
|
||||
const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
||||
const rule = {
|
||||
node: getNodeFromUrlFunc(nNode),
|
||||
url,
|
||||
needQuotes: false,
|
||||
isStringValue
|
||||
};
|
||||
|
||||
if (shouldHandleRule(rule, decl, result)) {
|
||||
accumulator.push({
|
||||
decl,
|
||||
rule,
|
||||
parsed
|
||||
});
|
||||
}
|
||||
} else if (type === 'string') {
|
||||
const rule = {
|
||||
node: nNode,
|
||||
url: value,
|
||||
needQuotes: true,
|
||||
isStringValue: true
|
||||
};
|
||||
|
||||
if (shouldHandleRule(rule, decl, result)) {
|
||||
accumulator.push({
|
||||
decl,
|
||||
rule,
|
||||
parsed
|
||||
});
|
||||
}
|
||||
}
|
||||
} // Do not traverse inside `image-set`
|
||||
// eslint-disable-next-line consistent-return
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
callback(null, accumulator);
|
||||
}
|
||||
|
||||
const asyncWalkCss = (0, _util.promisify)(walkCss);
|
||||
|
||||
var _default = _postcss.default.plugin(pluginName, options => async (css, result) => {
|
||||
const parsedResults = await asyncWalkCss(css, result, options);
|
||||
|
||||
if (parsedResults.length === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const tasks = [];
|
||||
const imports = new Map();
|
||||
const replacements = new Map();
|
||||
let hasUrlImportHelper = false;
|
||||
|
||||
for (const parsedResult of parsedResults) {
|
||||
const {
|
||||
url,
|
||||
isStringValue
|
||||
} = parsedResult.rule;
|
||||
let normalizedUrl = url;
|
||||
let prefix = '';
|
||||
const queryParts = normalizedUrl.split('!');
|
||||
|
||||
if (queryParts.length > 1) {
|
||||
normalizedUrl = queryParts.pop();
|
||||
prefix = queryParts.join('!');
|
||||
}
|
||||
|
||||
normalizedUrl = (0, _utils.normalizeUrl)(normalizedUrl, isStringValue);
|
||||
|
||||
if (!options.filter(normalizedUrl)) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hasUrlImportHelper) {
|
||||
options.imports.push({
|
||||
importName: '___CSS_LOADER_GET_URL_IMPORT___',
|
||||
url: options.urlHandler(require.resolve('../runtime/getUrl.js')),
|
||||
index: -1
|
||||
});
|
||||
hasUrlImportHelper = true;
|
||||
}
|
||||
|
||||
const splittedUrl = normalizedUrl.split(/(\?)?#/);
|
||||
const [pathname, query, hashOrQuery] = splittedUrl;
|
||||
let hash = query ? '?' : '';
|
||||
hash += hashOrQuery ? `#${hashOrQuery}` : '';
|
||||
const request = (0, _utils.requestify)(pathname, options.rootContext);
|
||||
tasks.push((async () => {
|
||||
const {
|
||||
resolver,
|
||||
context
|
||||
} = options;
|
||||
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, context, [...new Set([request, normalizedUrl])]);
|
||||
return {
|
||||
url: resolvedUrl,
|
||||
prefix,
|
||||
hash,
|
||||
parsedResult
|
||||
};
|
||||
})());
|
||||
}
|
||||
|
||||
const results = await Promise.all(tasks);
|
||||
|
||||
for (let index = 0; index <= results.length - 1; index++) {
|
||||
const {
|
||||
url,
|
||||
prefix,
|
||||
hash,
|
||||
parsedResult: {
|
||||
decl,
|
||||
rule,
|
||||
parsed
|
||||
}
|
||||
} = results[index];
|
||||
const newUrl = prefix ? `${prefix}!${url}` : url;
|
||||
const importKey = newUrl;
|
||||
let importName = imports.get(importKey);
|
||||
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_URL_IMPORT_${imports.size}___`;
|
||||
imports.set(importKey, importName);
|
||||
options.imports.push({
|
||||
importName,
|
||||
url: options.urlHandler(newUrl),
|
||||
index
|
||||
});
|
||||
}
|
||||
|
||||
const {
|
||||
needQuotes
|
||||
} = rule;
|
||||
const replacementKey = JSON.stringify({
|
||||
newUrl,
|
||||
hash,
|
||||
needQuotes
|
||||
});
|
||||
let replacementName = replacements.get(replacementKey);
|
||||
|
||||
if (!replacementName) {
|
||||
replacementName = `___CSS_LOADER_URL_REPLACEMENT_${replacements.size}___`;
|
||||
replacements.set(replacementKey, replacementName);
|
||||
options.replacements.push({
|
||||
replacementName,
|
||||
importName,
|
||||
hash,
|
||||
needQuotes
|
||||
});
|
||||
} // eslint-disable-next-line no-param-reassign
|
||||
|
||||
|
||||
rule.node.type = 'word'; // eslint-disable-next-line no-param-reassign
|
||||
|
||||
rule.node.value = replacementName; // eslint-disable-next-line no-param-reassign
|
||||
|
||||
decl.value = parsed.toString();
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
exports.default = _default;
|
94
web/node_modules/css-loader/dist/runtime/api.js
generated
vendored
Normal file
94
web/node_modules/css-loader/dist/runtime/api.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
"use strict";
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
// css base code, injected by the css-loader
|
||||
// eslint-disable-next-line func-names
|
||||
module.exports = function (useSourceMap) {
|
||||
var list = []; // return the list of modules as css string
|
||||
|
||||
list.toString = function toString() {
|
||||
return this.map(function (item) {
|
||||
var content = cssWithMappingToString(item, useSourceMap);
|
||||
|
||||
if (item[2]) {
|
||||
return "@media ".concat(item[2], " {").concat(content, "}");
|
||||
}
|
||||
|
||||
return content;
|
||||
}).join('');
|
||||
}; // import a list of modules into the list
|
||||
// eslint-disable-next-line func-names
|
||||
|
||||
|
||||
list.i = function (modules, mediaQuery, dedupe) {
|
||||
if (typeof modules === 'string') {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
modules = [[null, modules, '']];
|
||||
}
|
||||
|
||||
var alreadyImportedModules = {};
|
||||
|
||||
if (dedupe) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
var id = this[i][0];
|
||||
|
||||
if (id != null) {
|
||||
alreadyImportedModules[id] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var _i = 0; _i < modules.length; _i++) {
|
||||
var item = [].concat(modules[_i]);
|
||||
|
||||
if (dedupe && alreadyImportedModules[item[0]]) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mediaQuery) {
|
||||
if (!item[2]) {
|
||||
item[2] = mediaQuery;
|
||||
} else {
|
||||
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
|
||||
}
|
||||
}
|
||||
|
||||
list.push(item);
|
||||
}
|
||||
};
|
||||
|
||||
return list;
|
||||
};
|
||||
|
||||
function cssWithMappingToString(item, useSourceMap) {
|
||||
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
|
||||
|
||||
var cssMapping = item[3];
|
||||
|
||||
if (!cssMapping) {
|
||||
return content;
|
||||
}
|
||||
|
||||
if (useSourceMap && typeof btoa === 'function') {
|
||||
var sourceMapping = toComment(cssMapping);
|
||||
var sourceURLs = cssMapping.sources.map(function (source) {
|
||||
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
|
||||
});
|
||||
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
|
||||
}
|
||||
|
||||
return [content].join('\n');
|
||||
} // Adapted from convert-source-map (MIT)
|
||||
|
||||
|
||||
function toComment(sourceMap) {
|
||||
// eslint-disable-next-line no-undef
|
||||
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
||||
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
||||
return "/*# ".concat(data, " */");
|
||||
}
|
34
web/node_modules/css-loader/dist/runtime/getUrl.js
generated
vendored
Normal file
34
web/node_modules/css-loader/dist/runtime/getUrl.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function (url, options) {
|
||||
if (!options) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = {};
|
||||
} // eslint-disable-next-line no-underscore-dangle, no-param-reassign
|
||||
|
||||
|
||||
url = url && url.__esModule ? url.default : url;
|
||||
|
||||
if (typeof url !== 'string') {
|
||||
return url;
|
||||
} // If url is already wrapped in quotes, remove them
|
||||
|
||||
|
||||
if (/^['"].*['"]$/.test(url)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url = url.slice(1, -1);
|
||||
}
|
||||
|
||||
if (options.hash) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url += options.hash;
|
||||
} // Should url be wrapped?
|
||||
// See https://drafts.csswg.org/css-values-3/#urls
|
||||
|
||||
|
||||
if (/["'() \t\n]/.test(url) || options.needQuotes) {
|
||||
return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, '\\n'), "\"");
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
613
web/node_modules/css-loader/dist/utils.js
generated
vendored
Normal file
613
web/node_modules/css-loader/dist/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,613 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.normalizeOptions = normalizeOptions;
|
||||
exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
|
||||
exports.shouldUseImportPlugin = shouldUseImportPlugin;
|
||||
exports.shouldUseURLPlugin = shouldUseURLPlugin;
|
||||
exports.shouldUseIcssPlugin = shouldUseIcssPlugin;
|
||||
exports.normalizeUrl = normalizeUrl;
|
||||
exports.requestify = requestify;
|
||||
exports.getFilter = getFilter;
|
||||
exports.getModulesOptions = getModulesOptions;
|
||||
exports.getModulesPlugins = getModulesPlugins;
|
||||
exports.normalizeSourceMap = normalizeSourceMap;
|
||||
exports.getPreRequester = getPreRequester;
|
||||
exports.getImportCode = getImportCode;
|
||||
exports.getModuleCode = getModuleCode;
|
||||
exports.getExportCode = getExportCode;
|
||||
exports.resolveRequests = resolveRequests;
|
||||
exports.isUrlRequestable = isUrlRequestable;
|
||||
exports.sort = sort;
|
||||
|
||||
var _url = require("url");
|
||||
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
|
||||
var _loaderUtils = require("loader-utils");
|
||||
|
||||
var _cssesc = _interopRequireDefault(require("cssesc"));
|
||||
|
||||
var _postcssModulesValues = _interopRequireDefault(require("postcss-modules-values"));
|
||||
|
||||
var _postcssModulesLocalByDefault = _interopRequireDefault(require("postcss-modules-local-by-default"));
|
||||
|
||||
var _postcssModulesExtractImports = _interopRequireDefault(require("postcss-modules-extract-imports"));
|
||||
|
||||
var _postcssModulesScope = _interopRequireDefault(require("postcss-modules-scope"));
|
||||
|
||||
var _camelcase = _interopRequireDefault(require("camelcase"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
const whitespace = '[\\x20\\t\\r\\n\\f]';
|
||||
const unescapeRegExp = new RegExp(`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, 'ig');
|
||||
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
|
||||
|
||||
function unescape(str) {
|
||||
return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
|
||||
const high = `0x${escaped}` - 0x10000;
|
||||
/* eslint-disable line-comment-position */
|
||||
// NaN means non-codepoint
|
||||
// Workaround erroneous numeric interpretation of +"0x"
|
||||
// eslint-disable-next-line no-self-compare
|
||||
|
||||
return high !== high || escapedWhitespace ? escaped : high < 0 ? // BMP codepoint
|
||||
String.fromCharCode(high + 0x10000) : // Supplemental Plane codepoint (surrogate pair)
|
||||
// eslint-disable-next-line no-bitwise
|
||||
String.fromCharCode(high >> 10 | 0xd800, high & 0x3ff | 0xdc00);
|
||||
/* eslint-enable line-comment-position */
|
||||
});
|
||||
}
|
||||
|
||||
function normalizePath(file) {
|
||||
return _path.default.sep === '\\' ? file.replace(/\\/g, '/') : file;
|
||||
} // eslint-disable-next-line no-control-regex
|
||||
|
||||
|
||||
const filenameReservedRegex = /[<>:"/\\|?*]/g; // eslint-disable-next-line no-control-regex
|
||||
|
||||
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g;
|
||||
|
||||
function defaultGetLocalIdent(loaderContext, localIdentName, localName, options) {
|
||||
const {
|
||||
context,
|
||||
hashPrefix
|
||||
} = options;
|
||||
const {
|
||||
resourcePath
|
||||
} = loaderContext;
|
||||
const request = normalizePath(_path.default.relative(context, resourcePath)); // eslint-disable-next-line no-param-reassign
|
||||
|
||||
options.content = `${hashPrefix + request}\x00${unescape(localName)}`; // Using `[path]` placeholder outputs `/` we need escape their
|
||||
// Also directories can contains invalid characters for css we need escape their too
|
||||
|
||||
return (0, _cssesc.default)((0, _loaderUtils.interpolateName)(loaderContext, localIdentName, options) // For `[hash]` placeholder
|
||||
.replace(/^((-?[0-9])|--)/, '_$1').replace(filenameReservedRegex, '-').replace(reControlChars, '-').replace(/\./g, '-'), {
|
||||
isIdentifier: true
|
||||
}).replace(/\\\[local\\]/gi, localName);
|
||||
}
|
||||
|
||||
function normalizeUrl(url, isStringValue) {
|
||||
let normalizedUrl = url;
|
||||
|
||||
if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) {
|
||||
normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, '');
|
||||
}
|
||||
|
||||
if (matchNativeWin32Path.test(url)) {
|
||||
return decodeURIComponent(normalizedUrl);
|
||||
}
|
||||
|
||||
return decodeURIComponent(unescape(normalizedUrl));
|
||||
}
|
||||
|
||||
function requestify(url, rootContext) {
|
||||
if (/^file:/i.test(url)) {
|
||||
return (0, _url.fileURLToPath)(url);
|
||||
}
|
||||
|
||||
return url.charAt(0) === '/' ? (0, _loaderUtils.urlToRequest)(url, rootContext) : (0, _loaderUtils.urlToRequest)(url);
|
||||
}
|
||||
|
||||
function getFilter(filter, resourcePath) {
|
||||
return (...args) => {
|
||||
if (typeof filter === 'function') {
|
||||
return filter(...args, resourcePath);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
const moduleRegExp = /\.module\.\w+$/i;
|
||||
|
||||
function getModulesOptions(rawOptions, loaderContext) {
|
||||
const {
|
||||
resourcePath
|
||||
} = loaderContext;
|
||||
|
||||
if (typeof rawOptions.modules === 'undefined') {
|
||||
const isModules = moduleRegExp.test(resourcePath);
|
||||
|
||||
if (!isModules) {
|
||||
return false;
|
||||
}
|
||||
} else if (typeof rawOptions.modules === 'boolean' && rawOptions.modules === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let modulesOptions = {
|
||||
compileType: rawOptions.icss ? 'icss' : 'module',
|
||||
auto: true,
|
||||
mode: 'local',
|
||||
exportGlobals: false,
|
||||
localIdentName: '[hash:base64]',
|
||||
localIdentContext: loaderContext.rootContext,
|
||||
localIdentHashPrefix: '',
|
||||
// eslint-disable-next-line no-undefined
|
||||
localIdentRegExp: undefined,
|
||||
getLocalIdent: defaultGetLocalIdent,
|
||||
namedExport: false,
|
||||
exportLocalsConvention: 'asIs',
|
||||
exportOnlyLocals: false
|
||||
};
|
||||
|
||||
if (typeof rawOptions.modules === 'boolean' || typeof rawOptions.modules === 'string') {
|
||||
modulesOptions.mode = typeof rawOptions.modules === 'string' ? rawOptions.modules : 'local';
|
||||
} else {
|
||||
if (rawOptions.modules) {
|
||||
if (typeof rawOptions.modules.auto === 'boolean') {
|
||||
const isModules = rawOptions.modules.auto && moduleRegExp.test(resourcePath);
|
||||
|
||||
if (!isModules) {
|
||||
return false;
|
||||
}
|
||||
} else if (rawOptions.modules.auto instanceof RegExp) {
|
||||
const isModules = rawOptions.modules.auto.test(resourcePath);
|
||||
|
||||
if (!isModules) {
|
||||
return false;
|
||||
}
|
||||
} else if (typeof rawOptions.modules.auto === 'function') {
|
||||
const isModule = rawOptions.modules.auto(resourcePath);
|
||||
|
||||
if (!isModule) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (rawOptions.modules.namedExport === true && typeof rawOptions.modules.exportLocalsConvention === 'undefined') {
|
||||
modulesOptions.exportLocalsConvention = 'camelCaseOnly';
|
||||
}
|
||||
}
|
||||
|
||||
modulesOptions = { ...modulesOptions,
|
||||
...(rawOptions.modules || {})
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof modulesOptions.mode === 'function') {
|
||||
modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath);
|
||||
}
|
||||
|
||||
if (modulesOptions.namedExport === true) {
|
||||
if (rawOptions.esModule === false) {
|
||||
throw new Error('The "modules.namedExport" option requires the "esModules" option to be enabled');
|
||||
}
|
||||
|
||||
if (modulesOptions.exportLocalsConvention !== 'camelCaseOnly') {
|
||||
throw new Error('The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly"');
|
||||
}
|
||||
}
|
||||
|
||||
return modulesOptions;
|
||||
}
|
||||
|
||||
function normalizeOptions(rawOptions, loaderContext) {
|
||||
if (rawOptions.icss) {
|
||||
loaderContext.emitWarning(new Error('The "icss" option is deprecated, use "modules.compileType: "icss"" instead'));
|
||||
}
|
||||
|
||||
const modulesOptions = getModulesOptions(rawOptions, loaderContext);
|
||||
return {
|
||||
url: typeof rawOptions.url === 'undefined' ? true : rawOptions.url,
|
||||
import: typeof rawOptions.import === 'undefined' ? true : rawOptions.import,
|
||||
modules: modulesOptions,
|
||||
// TODO remove in the next major release
|
||||
icss: typeof rawOptions.icss === 'undefined' ? false : rawOptions.icss,
|
||||
sourceMap: typeof rawOptions.sourceMap === 'boolean' ? rawOptions.sourceMap : loaderContext.sourceMap,
|
||||
importLoaders: typeof rawOptions.importLoaders === 'string' ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders,
|
||||
esModule: typeof rawOptions.esModule === 'undefined' ? true : rawOptions.esModule
|
||||
};
|
||||
}
|
||||
|
||||
function shouldUseImportPlugin(options) {
|
||||
if (options.modules.exportOnlyLocals) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof options.import === 'boolean') {
|
||||
return options.import;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function shouldUseURLPlugin(options) {
|
||||
if (options.modules.exportOnlyLocals) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof options.url === 'boolean') {
|
||||
return options.url;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function shouldUseModulesPlugins(options) {
|
||||
return options.modules.compileType === 'module';
|
||||
}
|
||||
|
||||
function shouldUseIcssPlugin(options) {
|
||||
return options.icss === true || Boolean(options.modules);
|
||||
}
|
||||
|
||||
function getModulesPlugins(options, loaderContext) {
|
||||
const {
|
||||
mode,
|
||||
getLocalIdent,
|
||||
localIdentName,
|
||||
localIdentContext,
|
||||
localIdentHashPrefix,
|
||||
localIdentRegExp
|
||||
} = options.modules;
|
||||
let plugins = [];
|
||||
|
||||
try {
|
||||
plugins = [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
|
||||
mode
|
||||
}), (0, _postcssModulesExtractImports.default)(), (0, _postcssModulesScope.default)({
|
||||
generateScopedName(exportName) {
|
||||
return getLocalIdent(loaderContext, localIdentName, exportName, {
|
||||
context: localIdentContext,
|
||||
hashPrefix: localIdentHashPrefix,
|
||||
regExp: localIdentRegExp
|
||||
});
|
||||
},
|
||||
|
||||
exportGlobals: options.modules.exportGlobals
|
||||
})];
|
||||
} catch (error) {
|
||||
loaderContext.emitError(error);
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
||||
const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i;
|
||||
|
||||
function getURLType(source) {
|
||||
if (source[0] === '/') {
|
||||
if (source[1] === '/') {
|
||||
return 'scheme-relative';
|
||||
}
|
||||
|
||||
return 'path-absolute';
|
||||
}
|
||||
|
||||
if (IS_NATIVE_WIN32_PATH.test(source)) {
|
||||
return 'path-absolute';
|
||||
}
|
||||
|
||||
return ABSOLUTE_SCHEME.test(source) ? 'absolute' : 'path-relative';
|
||||
}
|
||||
|
||||
function normalizeSourceMap(map, resourcePath) {
|
||||
let newMap = map; // Some loader emit source map as string
|
||||
// Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
|
||||
|
||||
if (typeof newMap === 'string') {
|
||||
newMap = JSON.parse(newMap);
|
||||
}
|
||||
|
||||
delete newMap.file;
|
||||
const {
|
||||
sourceRoot
|
||||
} = newMap;
|
||||
delete newMap.sourceRoot;
|
||||
|
||||
if (newMap.sources) {
|
||||
// Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)
|
||||
// We should normalize path because previous loaders like `sass-loader` using backslash when generate source map
|
||||
newMap.sources = newMap.sources.map(source => {
|
||||
// Non-standard syntax from `postcss`
|
||||
if (source.indexOf('<') === 0) {
|
||||
return source;
|
||||
}
|
||||
|
||||
const sourceType = getURLType(source); // Do no touch `scheme-relative` and `absolute` URLs
|
||||
|
||||
if (sourceType === 'path-relative' || sourceType === 'path-absolute') {
|
||||
const absoluteSource = sourceType === 'path-relative' && sourceRoot ? _path.default.resolve(sourceRoot, normalizePath(source)) : normalizePath(source);
|
||||
return _path.default.relative(_path.default.dirname(resourcePath), absoluteSource);
|
||||
}
|
||||
|
||||
return source;
|
||||
});
|
||||
}
|
||||
|
||||
return newMap;
|
||||
}
|
||||
|
||||
function getPreRequester({
|
||||
loaders,
|
||||
loaderIndex
|
||||
}) {
|
||||
const cache = Object.create(null);
|
||||
return number => {
|
||||
if (cache[number]) {
|
||||
return cache[number];
|
||||
}
|
||||
|
||||
if (number === false) {
|
||||
cache[number] = '';
|
||||
} else {
|
||||
const loadersRequest = loaders.slice(loaderIndex, loaderIndex + 1 + (typeof number !== 'number' ? 0 : number)).map(x => x.request).join('!');
|
||||
cache[number] = `-!${loadersRequest}!`;
|
||||
}
|
||||
|
||||
return cache[number];
|
||||
};
|
||||
}
|
||||
|
||||
function getImportCode(imports, options) {
|
||||
let code = '';
|
||||
|
||||
for (const item of imports) {
|
||||
const {
|
||||
importName,
|
||||
url,
|
||||
icss
|
||||
} = item;
|
||||
|
||||
if (options.esModule) {
|
||||
if (icss && options.modules.namedExport) {
|
||||
code += `import ${options.modules.exportOnlyLocals ? '' : `${importName}, `}* as ${importName}_NAMED___ from ${url};\n`;
|
||||
} else {
|
||||
code += `import ${importName} from ${url};\n`;
|
||||
}
|
||||
} else {
|
||||
code += `var ${importName} = require(${url});\n`;
|
||||
}
|
||||
}
|
||||
|
||||
return code ? `// Imports\n${code}` : '';
|
||||
}
|
||||
|
||||
function normalizeSourceMapForRuntime(map, loaderContext) {
|
||||
const resultMap = map ? map.toJSON() : null;
|
||||
|
||||
if (resultMap) {
|
||||
delete resultMap.file;
|
||||
resultMap.sourceRoot = '';
|
||||
resultMap.sources = resultMap.sources.map(source => {
|
||||
// Non-standard syntax from `postcss`
|
||||
if (source.indexOf('<') === 0) {
|
||||
return source;
|
||||
}
|
||||
|
||||
const sourceType = getURLType(source);
|
||||
|
||||
if (sourceType !== 'path-relative') {
|
||||
return source;
|
||||
}
|
||||
|
||||
const resourceDirname = _path.default.dirname(loaderContext.resourcePath);
|
||||
|
||||
const absoluteSource = _path.default.resolve(resourceDirname, source);
|
||||
|
||||
const contextifyPath = normalizePath(_path.default.relative(loaderContext.rootContext, absoluteSource));
|
||||
return `webpack://${contextifyPath}`;
|
||||
});
|
||||
}
|
||||
|
||||
return JSON.stringify(resultMap);
|
||||
}
|
||||
|
||||
function getModuleCode(result, api, replacements, options, loaderContext) {
|
||||
if (options.modules.exportOnlyLocals === true) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const sourceMapValue = options.sourceMap ? `,${normalizeSourceMapForRuntime(result.map, loaderContext)}` : '';
|
||||
let code = JSON.stringify(result.css);
|
||||
let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${options.sourceMap});\n`;
|
||||
|
||||
for (const item of api) {
|
||||
const {
|
||||
url,
|
||||
media,
|
||||
dedupe
|
||||
} = item;
|
||||
beforeCode += url ? `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify(`@import url(${url});`)}${media ? `, ${JSON.stringify(media)}` : ''}]);\n` : `___CSS_LOADER_EXPORT___.i(${item.importName}${media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : ''}${dedupe ? ', true' : ''});\n`;
|
||||
}
|
||||
|
||||
for (const item of replacements) {
|
||||
const {
|
||||
replacementName,
|
||||
importName,
|
||||
localName
|
||||
} = item;
|
||||
|
||||
if (localName) {
|
||||
code = code.replace(new RegExp(replacementName, 'g'), () => options.modules.namedExport ? `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase.default)(localName))}] + "` : `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
|
||||
} else {
|
||||
const {
|
||||
hash,
|
||||
needQuotes
|
||||
} = item;
|
||||
const getUrlOptions = [].concat(hash ? [`hash: ${JSON.stringify(hash)}`] : []).concat(needQuotes ? 'needQuotes: true' : []);
|
||||
const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(', ')} }` : '';
|
||||
beforeCode += `var ${replacementName} = ___CSS_LOADER_GET_URL_IMPORT___(${importName}${preparedOptions});\n`;
|
||||
code = code.replace(new RegExp(replacementName, 'g'), () => `" + ${replacementName} + "`);
|
||||
}
|
||||
}
|
||||
|
||||
return `${beforeCode}// Module\n___CSS_LOADER_EXPORT___.push([module.id, ${code}, ""${sourceMapValue}]);\n`;
|
||||
}
|
||||
|
||||
function dashesCamelCase(str) {
|
||||
return str.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
|
||||
}
|
||||
|
||||
function getExportCode(exports, replacements, options) {
|
||||
let code = '// Exports\n';
|
||||
let localsCode = '';
|
||||
|
||||
const addExportToLocalsCode = (name, value) => {
|
||||
if (options.modules.namedExport) {
|
||||
localsCode += `export const ${(0, _camelcase.default)(name)} = ${JSON.stringify(value)};\n`;
|
||||
} else {
|
||||
if (localsCode) {
|
||||
localsCode += `,\n`;
|
||||
}
|
||||
|
||||
localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}`;
|
||||
}
|
||||
};
|
||||
|
||||
for (const {
|
||||
name,
|
||||
value
|
||||
} of exports) {
|
||||
switch (options.modules.exportLocalsConvention) {
|
||||
case 'camelCase':
|
||||
{
|
||||
addExportToLocalsCode(name, value);
|
||||
const modifiedName = (0, _camelcase.default)(name);
|
||||
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'camelCaseOnly':
|
||||
{
|
||||
addExportToLocalsCode((0, _camelcase.default)(name), value);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'dashes':
|
||||
{
|
||||
addExportToLocalsCode(name, value);
|
||||
const modifiedName = dashesCamelCase(name);
|
||||
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'dashesOnly':
|
||||
{
|
||||
addExportToLocalsCode(dashesCamelCase(name), value);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'asIs':
|
||||
default:
|
||||
addExportToLocalsCode(name, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of replacements) {
|
||||
const {
|
||||
replacementName,
|
||||
localName
|
||||
} = item;
|
||||
|
||||
if (localName) {
|
||||
const {
|
||||
importName
|
||||
} = item;
|
||||
localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => {
|
||||
if (options.modules.namedExport) {
|
||||
return `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase.default)(localName))}] + "`;
|
||||
} else if (options.modules.exportOnlyLocals) {
|
||||
return `" + ${importName}[${JSON.stringify(localName)}] + "`;
|
||||
}
|
||||
|
||||
return `" + ${importName}.locals[${JSON.stringify(localName)}] + "`;
|
||||
});
|
||||
} else {
|
||||
localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => `" + ${replacementName} + "`);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.modules.exportOnlyLocals) {
|
||||
code += options.modules.namedExport ? localsCode : `${options.esModule ? 'export default' : 'module.exports ='} {\n${localsCode}\n};\n`;
|
||||
return code;
|
||||
}
|
||||
|
||||
if (localsCode) {
|
||||
code += options.modules.namedExport ? localsCode : `___CSS_LOADER_EXPORT___.locals = {\n${localsCode}\n};\n`;
|
||||
}
|
||||
|
||||
code += `${options.esModule ? 'export default' : 'module.exports ='} ___CSS_LOADER_EXPORT___;\n`;
|
||||
return code;
|
||||
}
|
||||
|
||||
async function resolveRequests(resolve, context, possibleRequests) {
|
||||
return resolve(context, possibleRequests[0]).then(result => {
|
||||
return result;
|
||||
}).catch(error => {
|
||||
const [, ...tailPossibleRequests] = possibleRequests;
|
||||
|
||||
if (tailPossibleRequests.length === 0) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return resolveRequests(resolve, context, tailPossibleRequests);
|
||||
});
|
||||
}
|
||||
|
||||
function isUrlRequestable(url) {
|
||||
// Protocol-relative URLs
|
||||
if (/^\/\//.test(url)) {
|
||||
return false;
|
||||
} // `file:` protocol
|
||||
|
||||
|
||||
if (/^file:/i.test(url)) {
|
||||
return true;
|
||||
} // Absolute URLs
|
||||
|
||||
|
||||
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !matchNativeWin32Path.test(url)) {
|
||||
return false;
|
||||
} // `#` URLs
|
||||
|
||||
|
||||
if (/^#/.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function sort(a, b) {
|
||||
return a.index - b.index;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue