mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
chore:更换到主分支
This commit is contained in:
19
node_modules/postcss-modules-extract-imports/README.md
generated
vendored
19
node_modules/postcss-modules-extract-imports/README.md
generated
vendored
@@ -27,6 +27,7 @@ into:
|
||||
|
||||
- Only a certain whitelist of properties are inspected. Currently, that whitelist is `['composes']` alone.
|
||||
- An extend-import has the following format:
|
||||
|
||||
```
|
||||
composes: className [... className] from "path/to/file.css";
|
||||
```
|
||||
@@ -37,14 +38,14 @@ composes: className [... className] from "path/to/file.css";
|
||||
|
||||
```css
|
||||
.aa {
|
||||
composes: b from './b.css';
|
||||
composes: c from './c.css';
|
||||
composes: b from "./b.css";
|
||||
composes: c from "./c.css";
|
||||
}
|
||||
|
||||
.bb {
|
||||
/* "b.css" should be before "c.css" in this case */
|
||||
composes: c from './c.css';
|
||||
composes: b from './b.css';
|
||||
composes: c from "./c.css";
|
||||
composes: b from "./b.css";
|
||||
}
|
||||
```
|
||||
|
||||
@@ -57,13 +58,8 @@ npm test
|
||||
|
||||
[](https://travis-ci.org/css-modules/postcss-modules-extract-imports)
|
||||
|
||||
* Lines: [](https://coveralls.io/r/css-modules/postcss-modules-extract-imports?branch=master)
|
||||
* Statements: [](http://codecov.io/github/css-modules/postcss-modules-extract-imports?branch=master)
|
||||
|
||||
## Development
|
||||
|
||||
- `npm watch` will watch `src` for changes and rebuild
|
||||
- `npm autotest` will watch `src` and `test` for changes and retest
|
||||
- Lines: [](https://coveralls.io/r/css-modules/postcss-modules-extract-imports?branch=master)
|
||||
- Statements: [](http://codecov.io/github/css-modules/postcss-modules-extract-imports?branch=master)
|
||||
|
||||
## License
|
||||
|
||||
@@ -76,4 +72,5 @@ ISC
|
||||
- Guy Bedford
|
||||
|
||||
---
|
||||
|
||||
Glen Maddern, 2015.
|
||||
|
||||
60
node_modules/postcss-modules-extract-imports/package.json
generated
vendored
60
node_modules/postcss-modules-extract-imports/package.json
generated
vendored
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"postcss-modules-extract-imports@2.0.0",
|
||||
"postcss-modules-extract-imports@3.0.0",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "postcss-modules-extract-imports@2.0.0",
|
||||
"_id": "postcss-modules-extract-imports@2.0.0",
|
||||
"_from": "postcss-modules-extract-imports@3.0.0",
|
||||
"_id": "postcss-modules-extract-imports@3.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-gYcZoa4doyX5gyRGsBE27rSTzX4=",
|
||||
"_integrity": "sha1-zaHwR8CugMl9vijD52pDuIAldB0=",
|
||||
"_location": "/postcss-modules-extract-imports",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "postcss-modules-extract-imports@2.0.0",
|
||||
"raw": "postcss-modules-extract-imports@3.0.0",
|
||||
"name": "postcss-modules-extract-imports",
|
||||
"escapedName": "postcss-modules-extract-imports",
|
||||
"rawSpec": "2.0.0",
|
||||
"rawSpec": "3.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.0"
|
||||
"fetchSpec": "3.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/postcss-modules"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/postcss-modules-extract-imports/-/postcss-modules-extract-imports-2.0.0.tgz",
|
||||
"_spec": "2.0.0",
|
||||
"_resolved": "http://192.168.250.101:4873/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz",
|
||||
"_spec": "3.0.0",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "Glen Maddern"
|
||||
@@ -34,20 +34,19 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/css-modules/postcss-modules-extract-imports/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"postcss": "^7.0.5"
|
||||
},
|
||||
"description": "A CSS Modules transform to extract local aliases for inline imports",
|
||||
"devDependencies": {
|
||||
"codecov.io": "^0.1.2",
|
||||
"coveralls": "^2.11.2",
|
||||
"husky": "^0.13.3",
|
||||
"jest": "^20.0.3",
|
||||
"lint-staged": "^3.4.2",
|
||||
"prettier": "^1.3.1"
|
||||
"coveralls": "^3.1.0",
|
||||
"eslint": "^7.10.0",
|
||||
"eslint-config-prettier": "^6.12.0",
|
||||
"husky": "^4.3.0",
|
||||
"jest": "^26.5.2",
|
||||
"lint-staged": "^10.4.0",
|
||||
"postcss": "^8.1.1",
|
||||
"prettier": "^2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
"node": "^10 || ^12 || >= 14"
|
||||
},
|
||||
"files": [
|
||||
"src"
|
||||
@@ -59,22 +58,25 @@
|
||||
"plugin"
|
||||
],
|
||||
"license": "ISC",
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"prettier --single-quote --no-semi --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "src/index.js",
|
||||
"name": "postcss-modules-extract-imports",
|
||||
"peerDependencies": {
|
||||
"postcss": "^8.1.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/css-modules/postcss-modules-extract-imports.git"
|
||||
},
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"prepublish": "yarn run test",
|
||||
"test": "jest --coverage"
|
||||
"eslint": "eslint --ignore-path .gitignore .",
|
||||
"lint": "yarn eslint && yarn prettier",
|
||||
"prepublishOnly": "yarn test",
|
||||
"pretest": "yarn lint",
|
||||
"prettier": "prettier -l --ignore-path .gitignore . \"!test/test-cases\"",
|
||||
"test": "yarn test:coverage",
|
||||
"test:coverage": "jest --coverage --collectCoverageFrom=\"src/**/*\"",
|
||||
"test:only": "jest",
|
||||
"test:watch": "jest --watch"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
"version": "3.0.0"
|
||||
}
|
||||
|
||||
272
node_modules/postcss-modules-extract-imports/src/index.js
generated
vendored
272
node_modules/postcss-modules-extract-imports/src/index.js
generated
vendored
@@ -1,20 +1,9 @@
|
||||
const postcss = require('postcss')
|
||||
const topologicalSort = require('./topologicalSort')
|
||||
const topologicalSort = require("./topologicalSort");
|
||||
|
||||
const declWhitelist = ['composes']
|
||||
const declFilter = new RegExp(`^(${declWhitelist.join('|')})$`)
|
||||
const matchImports = /^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)'|(global))$/
|
||||
const icssImport = /^:import\((?:"([^"]+)"|'([^']+)')\)/
|
||||
const matchImports = /^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)'|(global))$/;
|
||||
const icssImport = /^:import\((?:"([^"]+)"|'([^']+)')\)/;
|
||||
|
||||
const VISITED_MARKER = 1
|
||||
|
||||
function createParentName(rule, root) {
|
||||
return `__${root.index(rule.parent)}_${rule.selector}`
|
||||
}
|
||||
|
||||
function serializeImports(imports) {
|
||||
return imports.map(importPath => '`' + importPath + '`').join(', ')
|
||||
}
|
||||
const VISITED_MARKER = 1;
|
||||
|
||||
/**
|
||||
* :import('G') {}
|
||||
@@ -38,143 +27,174 @@ function serializeImports(imports) {
|
||||
* }
|
||||
*/
|
||||
function addImportToGraph(importId, parentId, graph, visited) {
|
||||
const siblingsId = parentId + '_' + 'siblings'
|
||||
const visitedId = parentId + '_' + importId
|
||||
const siblingsId = parentId + "_" + "siblings";
|
||||
const visitedId = parentId + "_" + importId;
|
||||
|
||||
if (visited[visitedId] !== VISITED_MARKER) {
|
||||
if (!Array.isArray(visited[siblingsId])) visited[siblingsId] = []
|
||||
if (!Array.isArray(visited[siblingsId])) {
|
||||
visited[siblingsId] = [];
|
||||
}
|
||||
|
||||
const siblings = visited[siblingsId]
|
||||
const siblings = visited[siblingsId];
|
||||
|
||||
if (Array.isArray(graph[importId]))
|
||||
graph[importId] = graph[importId].concat(siblings)
|
||||
else graph[importId] = siblings.slice()
|
||||
if (Array.isArray(graph[importId])) {
|
||||
graph[importId] = graph[importId].concat(siblings);
|
||||
} else {
|
||||
graph[importId] = siblings.slice();
|
||||
}
|
||||
|
||||
visited[visitedId] = VISITED_MARKER
|
||||
siblings.push(importId)
|
||||
visited[visitedId] = VISITED_MARKER;
|
||||
|
||||
siblings.push(importId);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = postcss.plugin('modules-extract-imports', function(
|
||||
options = {}
|
||||
) {
|
||||
const failOnWrongOrder = options.failOnWrongOrder
|
||||
|
||||
return css => {
|
||||
const graph = {}
|
||||
const visited = {}
|
||||
|
||||
const existingImports = {}
|
||||
const importDecls = {}
|
||||
const imports = {}
|
||||
|
||||
let importIndex = 0
|
||||
|
||||
const createImportedName = typeof options.createImportedName !== 'function'
|
||||
module.exports = (options = {}) => {
|
||||
let importIndex = 0;
|
||||
const createImportedName =
|
||||
typeof options.createImportedName !== "function"
|
||||
? (importName /*, path*/) =>
|
||||
`i__imported_${importName.replace(/\W/g, '_')}_${importIndex++}`
|
||||
: options.createImportedName
|
||||
`i__imported_${importName.replace(/\W/g, "_")}_${importIndex++}`
|
||||
: options.createImportedName;
|
||||
const failOnWrongOrder = options.failOnWrongOrder;
|
||||
|
||||
// Check the existing imports order and save refs
|
||||
css.walkRules(rule => {
|
||||
const matches = icssImport.exec(rule.selector)
|
||||
return {
|
||||
postcssPlugin: "postcss-modules-extract-imports",
|
||||
prepare() {
|
||||
const graph = {};
|
||||
const visited = {};
|
||||
const existingImports = {};
|
||||
const importDecls = {};
|
||||
const imports = {};
|
||||
|
||||
if (matches) {
|
||||
const [, /*match*/ doubleQuotePath, singleQuotePath] = matches
|
||||
const importPath = doubleQuotePath || singleQuotePath
|
||||
return {
|
||||
Once(root, postcss) {
|
||||
// Check the existing imports order and save refs
|
||||
root.walkRules((rule) => {
|
||||
const matches = icssImport.exec(rule.selector);
|
||||
|
||||
addImportToGraph(importPath, 'root', graph, visited)
|
||||
if (matches) {
|
||||
const [, /*match*/ doubleQuotePath, singleQuotePath] = matches;
|
||||
const importPath = doubleQuotePath || singleQuotePath;
|
||||
|
||||
existingImports[importPath] = rule
|
||||
}
|
||||
})
|
||||
addImportToGraph(importPath, "root", graph, visited);
|
||||
|
||||
// Find any declaration that supports imports
|
||||
css.walkDecls(declFilter, decl => {
|
||||
let matches = decl.value.match(matchImports)
|
||||
let tmpSymbols
|
||||
existingImports[importPath] = rule;
|
||||
}
|
||||
});
|
||||
|
||||
if (matches) {
|
||||
let [
|
||||
,
|
||||
/*match*/ symbols,
|
||||
doubleQuotePath,
|
||||
singleQuotePath,
|
||||
global
|
||||
] = matches
|
||||
root.walkDecls(/^composes$/, (declaration) => {
|
||||
const matches = declaration.value.match(matchImports);
|
||||
|
||||
if (global) {
|
||||
// Composing globals simply means changing these classes to wrap them in global(name)
|
||||
tmpSymbols = symbols.split(/\s+/).map(s => `global(${s})`)
|
||||
} else {
|
||||
const importPath = doubleQuotePath || singleQuotePath
|
||||
const parentRule = createParentName(decl.parent, css)
|
||||
|
||||
addImportToGraph(importPath, parentRule, graph, visited)
|
||||
|
||||
importDecls[importPath] = decl
|
||||
imports[importPath] = imports[importPath] || {}
|
||||
|
||||
tmpSymbols = symbols.split(/\s+/).map(s => {
|
||||
if (!imports[importPath][s]) {
|
||||
imports[importPath][s] = createImportedName(s, importPath)
|
||||
if (!matches) {
|
||||
return;
|
||||
}
|
||||
|
||||
return imports[importPath][s]
|
||||
})
|
||||
}
|
||||
let tmpSymbols;
|
||||
let [
|
||||
,
|
||||
/*match*/ symbols,
|
||||
doubleQuotePath,
|
||||
singleQuotePath,
|
||||
global,
|
||||
] = matches;
|
||||
|
||||
decl.value = tmpSymbols.join(' ')
|
||||
}
|
||||
})
|
||||
if (global) {
|
||||
// Composing globals simply means changing these classes to wrap them in global(name)
|
||||
tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
|
||||
} else {
|
||||
const importPath = doubleQuotePath || singleQuotePath;
|
||||
|
||||
const importsOrder = topologicalSort(graph, failOnWrongOrder)
|
||||
let parent = declaration.parent;
|
||||
let parentIndexes = "";
|
||||
|
||||
if (importsOrder instanceof Error) {
|
||||
const importPath = importsOrder.nodes.find(importPath =>
|
||||
importDecls.hasOwnProperty(importPath)
|
||||
)
|
||||
const decl = importDecls[importPath]
|
||||
while (parent.type !== "root") {
|
||||
parentIndexes =
|
||||
parent.parent.index(parent) + "_" + parentIndexes;
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
const errMsg =
|
||||
'Failed to resolve order of composed modules ' +
|
||||
serializeImports(importsOrder.nodes) +
|
||||
'.'
|
||||
const { selector } = declaration.parent;
|
||||
const parentRule = `_${parentIndexes}${selector}`;
|
||||
|
||||
throw decl.error(errMsg, {
|
||||
plugin: 'modules-extract-imports',
|
||||
word: 'composes'
|
||||
})
|
||||
}
|
||||
addImportToGraph(importPath, parentRule, graph, visited);
|
||||
|
||||
let lastImportRule
|
||||
importsOrder.forEach(path => {
|
||||
const importedSymbols = imports[path]
|
||||
let rule = existingImports[path]
|
||||
importDecls[importPath] = declaration;
|
||||
imports[importPath] = imports[importPath] || {};
|
||||
|
||||
if (!rule && importedSymbols) {
|
||||
rule = postcss.rule({
|
||||
selector: `:import("${path}")`,
|
||||
raws: { after: '\n' }
|
||||
})
|
||||
tmpSymbols = symbols.split(/\s+/).map((s) => {
|
||||
if (!imports[importPath][s]) {
|
||||
imports[importPath][s] = createImportedName(s, importPath);
|
||||
}
|
||||
|
||||
if (lastImportRule) css.insertAfter(lastImportRule, rule)
|
||||
else css.prepend(rule)
|
||||
}
|
||||
return imports[importPath][s];
|
||||
});
|
||||
}
|
||||
|
||||
lastImportRule = rule
|
||||
declaration.value = tmpSymbols.join(" ");
|
||||
});
|
||||
|
||||
if (!importedSymbols) return
|
||||
const importsOrder = topologicalSort(graph, failOnWrongOrder);
|
||||
|
||||
Object.keys(importedSymbols).forEach(importedSymbol => {
|
||||
rule.append(
|
||||
postcss.decl({
|
||||
value: importedSymbol,
|
||||
prop: importedSymbols[importedSymbol],
|
||||
raws: { before: '\n ' }
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
if (importsOrder instanceof Error) {
|
||||
const importPath = importsOrder.nodes.find((importPath) =>
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
importDecls.hasOwnProperty(importPath)
|
||||
);
|
||||
const decl = importDecls[importPath];
|
||||
|
||||
throw decl.error(
|
||||
"Failed to resolve order of composed modules " +
|
||||
importsOrder.nodes
|
||||
.map((importPath) => "`" + importPath + "`")
|
||||
.join(", ") +
|
||||
".",
|
||||
{
|
||||
plugin: "postcss-modules-extract-imports",
|
||||
word: "composes",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
let lastImportRule;
|
||||
|
||||
importsOrder.forEach((path) => {
|
||||
const importedSymbols = imports[path];
|
||||
let rule = existingImports[path];
|
||||
|
||||
if (!rule && importedSymbols) {
|
||||
rule = postcss.rule({
|
||||
selector: `:import("${path}")`,
|
||||
raws: { after: "\n" },
|
||||
});
|
||||
|
||||
if (lastImportRule) {
|
||||
root.insertAfter(lastImportRule, rule);
|
||||
} else {
|
||||
root.prepend(rule);
|
||||
}
|
||||
}
|
||||
|
||||
lastImportRule = rule;
|
||||
|
||||
if (!importedSymbols) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(importedSymbols).forEach((importedSymbol) => {
|
||||
rule.append(
|
||||
postcss.decl({
|
||||
value: importedSymbol,
|
||||
prop: importedSymbols[importedSymbol],
|
||||
raws: { before: "\n " },
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.postcss = true;
|
||||
|
||||
66
node_modules/postcss-modules-extract-imports/src/topologicalSort.js
generated
vendored
66
node_modules/postcss-modules-extract-imports/src/topologicalSort.js
generated
vendored
@@ -1,54 +1,66 @@
|
||||
const PERMANENT_MARKER = 2
|
||||
const TEMPORARY_MARKER = 1
|
||||
const PERMANENT_MARKER = 2;
|
||||
const TEMPORARY_MARKER = 1;
|
||||
|
||||
function createError(node, graph) {
|
||||
const er = new Error("Nondeterministic import's order")
|
||||
const er = new Error("Nondeterministic import's order");
|
||||
|
||||
const related = graph[node]
|
||||
const related = graph[node];
|
||||
const relatedNode = related.find(
|
||||
relatedNode => graph[relatedNode].indexOf(node) > -1
|
||||
)
|
||||
(relatedNode) => graph[relatedNode].indexOf(node) > -1
|
||||
);
|
||||
|
||||
er.nodes = [node, relatedNode]
|
||||
er.nodes = [node, relatedNode];
|
||||
|
||||
return er
|
||||
return er;
|
||||
}
|
||||
|
||||
function walkGraph(node, graph, state, result, strict) {
|
||||
if (state[node] === PERMANENT_MARKER) return
|
||||
if (state[node] === TEMPORARY_MARKER) {
|
||||
if (strict) return createError(node, graph)
|
||||
return
|
||||
if (state[node] === PERMANENT_MARKER) {
|
||||
return;
|
||||
}
|
||||
|
||||
state[node] = TEMPORARY_MARKER
|
||||
if (state[node] === TEMPORARY_MARKER) {
|
||||
if (strict) {
|
||||
return createError(node, graph);
|
||||
}
|
||||
|
||||
const children = graph[node]
|
||||
const length = children.length
|
||||
return;
|
||||
}
|
||||
|
||||
state[node] = TEMPORARY_MARKER;
|
||||
|
||||
const children = graph[node];
|
||||
const length = children.length;
|
||||
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const er = walkGraph(children[i], graph, state, result, strict)
|
||||
if (er instanceof Error) return er
|
||||
const error = walkGraph(children[i], graph, state, result, strict);
|
||||
|
||||
if (error instanceof Error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
state[node] = PERMANENT_MARKER
|
||||
state[node] = PERMANENT_MARKER;
|
||||
|
||||
result.push(node)
|
||||
result.push(node);
|
||||
}
|
||||
|
||||
function topologicalSort(graph, strict) {
|
||||
const result = []
|
||||
const state = {}
|
||||
const result = [];
|
||||
const state = {};
|
||||
|
||||
const nodes = Object.keys(graph)
|
||||
const length = nodes.length
|
||||
const nodes = Object.keys(graph);
|
||||
const length = nodes.length;
|
||||
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const er = walkGraph(nodes[i], graph, state, result, strict)
|
||||
if (er instanceof Error) return er
|
||||
const er = walkGraph(nodes[i], graph, state, result, strict);
|
||||
|
||||
if (er instanceof Error) {
|
||||
return er;
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = topologicalSort
|
||||
module.exports = topologicalSort;
|
||||
|
||||
Reference in New Issue
Block a user