vite 6.0.0-beta.0 → 6.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +66 -1010
- package/README.md +4 -4
- package/bin/vite.js +5 -0
- package/client.d.ts +10 -0
- package/dist/client/client.mjs +344 -105
- package/dist/node/chunks/{dep-IQS-Za7F.js → dep-3RmXg9uo.js} +0 -8
- package/dist/node/chunks/{dep-CSD_20z-.js → dep-Ck0pJQmh.js} +4 -175
- package/dist/node/chunks/{dep-Bv1xMYNy.js → dep-DiRA7B7B.js} +15754 -30473
- package/dist/node/chunks/{dep-D-7KCb9p.js → dep-DnSxfB-q.js} +704 -443
- package/dist/node/chunks/{dep-D9t7igss.js → dep-ifLmJA8Z.js} +286 -127
- package/dist/node/cli.js +21 -37
- package/dist/node/constants.js +19 -11
- package/dist/node/index.d.ts +1649 -1602
- package/dist/node/index.js +13 -153
- package/dist/node/module-runner.d.ts +154 -141
- package/dist/node/module-runner.js +374 -221
- package/dist/node-cjs/publicUtils.cjs +363 -184
- package/index.cjs +35 -3
- package/index.d.cts +1 -1
- package/package.json +44 -33
- package/types/hmrPayload.d.ts +5 -0
- package/types/internal/cssPreprocessorOptions.d.ts +63 -0
- package/types/internal/lightningcssOptions.d.ts +18 -0
@@ -1,19 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import require$$
|
1
|
+
import { O as commonjsGlobal, N as getDefaultExportFromCjs } from './dep-DiRA7B7B.js';
|
2
|
+
import require$$0$2 from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
5
5
|
import require$$3 from 'crypto';
|
6
|
-
import require$$
|
7
|
-
import { l as lib } from './dep-
|
6
|
+
import require$$1 from 'util';
|
7
|
+
import { l as lib } from './dep-3RmXg9uo.js';
|
8
8
|
|
9
|
-
import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
|
10
|
-
import { dirname as __cjs_dirname } from 'node:path';
|
11
|
-
import { createRequire as __cjs_createRequire } from 'node:module';
|
12
|
-
|
13
|
-
const __filename = __cjs_fileURLToPath(import.meta.url);
|
14
|
-
const __dirname = __cjs_dirname(__filename);
|
15
|
-
const require = __cjs_createRequire(import.meta.url);
|
16
|
-
const __require = require;
|
17
9
|
function _mergeNamespaces(n, m) {
|
18
10
|
for (var i = 0; i < m.length; i++) {
|
19
11
|
var e = m[i];
|
@@ -1327,54 +1319,63 @@ src$3.exports = (options = {}) => {
|
|
1327
1319
|
});
|
1328
1320
|
|
1329
1321
|
root.walkDecls(/^composes$/, (declaration) => {
|
1330
|
-
const
|
1322
|
+
const multiple = declaration.value.split(",");
|
1323
|
+
const values = [];
|
1331
1324
|
|
1332
|
-
|
1333
|
-
|
1334
|
-
}
|
1325
|
+
multiple.forEach((value) => {
|
1326
|
+
const matches = value.trim().match(matchImports$1);
|
1335
1327
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
,
|
1339
|
-
/*match*/ symbols,
|
1340
|
-
doubleQuotePath,
|
1341
|
-
singleQuotePath,
|
1342
|
-
global,
|
1343
|
-
] = matches;
|
1344
|
-
|
1345
|
-
if (global) {
|
1346
|
-
// Composing globals simply means changing these classes to wrap them in global(name)
|
1347
|
-
tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
|
1348
|
-
} else {
|
1349
|
-
const importPath = doubleQuotePath || singleQuotePath;
|
1350
|
-
|
1351
|
-
let parent = declaration.parent;
|
1352
|
-
let parentIndexes = "";
|
1328
|
+
if (!matches) {
|
1329
|
+
values.push(value);
|
1353
1330
|
|
1354
|
-
|
1355
|
-
parentIndexes =
|
1356
|
-
parent.parent.index(parent) + "_" + parentIndexes;
|
1357
|
-
parent = parent.parent;
|
1331
|
+
return;
|
1358
1332
|
}
|
1359
1333
|
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1334
|
+
let tmpSymbols;
|
1335
|
+
let [
|
1336
|
+
,
|
1337
|
+
/*match*/ symbols,
|
1338
|
+
doubleQuotePath,
|
1339
|
+
singleQuotePath,
|
1340
|
+
global,
|
1341
|
+
] = matches;
|
1342
|
+
|
1343
|
+
if (global) {
|
1344
|
+
// Composing globals simply means changing these classes to wrap them in global(name)
|
1345
|
+
tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
|
1346
|
+
} else {
|
1347
|
+
const importPath = doubleQuotePath || singleQuotePath;
|
1364
1348
|
|
1365
|
-
|
1366
|
-
|
1349
|
+
let parent = declaration.parent;
|
1350
|
+
let parentIndexes = "";
|
1367
1351
|
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1352
|
+
while (parent.type !== "root") {
|
1353
|
+
parentIndexes =
|
1354
|
+
parent.parent.index(parent) + "_" + parentIndexes;
|
1355
|
+
parent = parent.parent;
|
1371
1356
|
}
|
1372
1357
|
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1358
|
+
const { selector } = declaration.parent;
|
1359
|
+
const parentRule = `_${parentIndexes}${selector}`;
|
1360
|
+
|
1361
|
+
addImportToGraph(importPath, parentRule, graph, visited);
|
1362
|
+
|
1363
|
+
importDecls[importPath] = declaration;
|
1364
|
+
imports[importPath] = imports[importPath] || {};
|
1365
|
+
|
1366
|
+
tmpSymbols = symbols.split(/\s+/).map((s) => {
|
1367
|
+
if (!imports[importPath][s]) {
|
1368
|
+
imports[importPath][s] = createImportedName(s, importPath);
|
1369
|
+
}
|
1376
1370
|
|
1377
|
-
|
1371
|
+
return imports[importPath][s];
|
1372
|
+
});
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
values.push(tmpSymbols.join(" "));
|
1376
|
+
});
|
1377
|
+
|
1378
|
+
declaration.value = values.join(", ");
|
1378
1379
|
});
|
1379
1380
|
|
1380
1381
|
const importsOrder = topologicalSort(graph, failOnWrongOrder);
|
@@ -2026,12 +2027,17 @@ function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
|
|
2026
2027
|
digestType === "base49" ||
|
2027
2028
|
digestType === "base52" ||
|
2028
2029
|
digestType === "base58" ||
|
2029
|
-
digestType === "base62"
|
2030
|
+
digestType === "base62" ||
|
2031
|
+
digestType === "base64safe"
|
2030
2032
|
) {
|
2031
|
-
return encodeBufferToBase(
|
2032
|
-
|
2033
|
-
|
2033
|
+
return encodeBufferToBase(
|
2034
|
+
hash.digest(),
|
2035
|
+
digestType === "base64safe" ? 64 : digestType.substr(4),
|
2036
|
+
maxLength
|
2037
|
+
);
|
2034
2038
|
}
|
2039
|
+
|
2040
|
+
return hash.digest(digestType || "hex").substr(0, maxLength);
|
2035
2041
|
}
|
2036
2042
|
|
2037
2043
|
var getHashDigest_1 = getHashDigest$1;
|
@@ -2087,9 +2093,10 @@ function interpolateName$1(loaderContext, name, options = {}) {
|
|
2087
2093
|
directory = resourcePath.replace(/\\/g, "/").replace(/\.\.(\/)?/g, "_$1");
|
2088
2094
|
}
|
2089
2095
|
|
2090
|
-
if (directory.length
|
2096
|
+
if (directory.length <= 1) {
|
2091
2097
|
directory = "";
|
2092
|
-
} else
|
2098
|
+
} else {
|
2099
|
+
// directory.length > 1
|
2093
2100
|
folder = path$1.basename(directory);
|
2094
2101
|
}
|
2095
2102
|
}
|
@@ -2112,7 +2119,7 @@ function interpolateName$1(loaderContext, name, options = {}) {
|
|
2112
2119
|
// `hash` and `contenthash` are same in `loader-utils` context
|
2113
2120
|
// let's keep `hash` for backward compatibility
|
2114
2121
|
.replace(
|
2115
|
-
/\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
|
2122
|
+
/\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*(?:safe)?))?(?::(\d+))?\]/gi,
|
2116
2123
|
(all, hashType, digestType, maxLength) =>
|
2117
2124
|
getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
|
2118
2125
|
);
|
@@ -3393,7 +3400,7 @@ var attribute$1 = {};
|
|
3393
3400
|
* For Node.js, simply re-export the core `util.deprecate` function.
|
3394
3401
|
*/
|
3395
3402
|
|
3396
|
-
var node = require$$
|
3403
|
+
var node = require$$1.deprecate;
|
3397
3404
|
|
3398
3405
|
(function (exports) {
|
3399
3406
|
|
@@ -4743,7 +4750,7 @@ tokenTypes.combinator = combinator$1;
|
|
4743
4750
|
}
|
4744
4751
|
// We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
|
4745
4752
|
var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
|
4746
|
-
if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
|
4753
|
+
if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
|
4747
4754
|
var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
|
4748
4755
|
if (nodes.length > 0) {
|
4749
4756
|
var last = this.current.last;
|
@@ -5767,9 +5774,19 @@ function localizeNode(rule, mode, localAliasMap) {
|
|
5767
5774
|
hasLocals: false,
|
5768
5775
|
explicit: context.explicit,
|
5769
5776
|
};
|
5770
|
-
newNodes = node.map((childNode) =>
|
5771
|
-
|
5772
|
-
|
5777
|
+
newNodes = node.map((childNode) => {
|
5778
|
+
const newContext = {
|
5779
|
+
...childContext,
|
5780
|
+
enforceNoSpacing: false,
|
5781
|
+
};
|
5782
|
+
|
5783
|
+
const result = transform(childNode, newContext);
|
5784
|
+
|
5785
|
+
childContext.global = newContext.global;
|
5786
|
+
childContext.hasLocals = newContext.hasLocals;
|
5787
|
+
|
5788
|
+
return result;
|
5789
|
+
});
|
5773
5790
|
|
5774
5791
|
node = node.clone();
|
5775
5792
|
node.nodes = normalizeNodeArray(newNodes);
|
@@ -5838,6 +5855,11 @@ function localizeNode(rule, mode, localAliasMap) {
|
|
5838
5855
|
|
5839
5856
|
break;
|
5840
5857
|
}
|
5858
|
+
case "nesting": {
|
5859
|
+
if (node.value === "&") {
|
5860
|
+
context.hasLocals = true;
|
5861
|
+
}
|
5862
|
+
}
|
5841
5863
|
}
|
5842
5864
|
|
5843
5865
|
context.lastWasSpacing = false;
|
@@ -5910,19 +5932,34 @@ function localizeDeclNode(node, context) {
|
|
5910
5932
|
return node;
|
5911
5933
|
}
|
5912
5934
|
|
5913
|
-
|
5914
|
-
|
5915
|
-
|
5916
|
-
|
5917
|
-
|
5918
|
-
|
5919
|
-
|
5920
|
-
|
5935
|
+
// `none` is special value, other is global values
|
5936
|
+
const specialKeywords = [
|
5937
|
+
"none",
|
5938
|
+
"inherit",
|
5939
|
+
"initial",
|
5940
|
+
"revert",
|
5941
|
+
"revert-layer",
|
5942
|
+
"unset",
|
5943
|
+
];
|
5921
5944
|
|
5922
5945
|
function localizeDeclarationValues(localize, declaration, context) {
|
5923
5946
|
const valueNodes = valueParser(declaration.value);
|
5924
5947
|
|
5925
5948
|
valueNodes.walk((node, index, nodes) => {
|
5949
|
+
if (
|
5950
|
+
node.type === "function" &&
|
5951
|
+
(node.value.toLowerCase() === "var" || node.value.toLowerCase() === "env")
|
5952
|
+
) {
|
5953
|
+
return false;
|
5954
|
+
}
|
5955
|
+
|
5956
|
+
if (
|
5957
|
+
node.type === "word" &&
|
5958
|
+
specialKeywords.includes(node.value.toLowerCase())
|
5959
|
+
) {
|
5960
|
+
return;
|
5961
|
+
}
|
5962
|
+
|
5926
5963
|
const subContext = {
|
5927
5964
|
options: context.options,
|
5928
5965
|
global: context.global,
|
@@ -5939,57 +5976,80 @@ function localizeDeclaration(declaration, context) {
|
|
5939
5976
|
const isAnimation = /animation$/i.test(declaration.prop);
|
5940
5977
|
|
5941
5978
|
if (isAnimation) {
|
5942
|
-
|
5979
|
+
// letter
|
5980
|
+
// An uppercase letter or a lowercase letter.
|
5981
|
+
//
|
5982
|
+
// ident-start code point
|
5983
|
+
// A letter, a non-ASCII code point, or U+005F LOW LINE (_).
|
5984
|
+
//
|
5985
|
+
// ident code point
|
5986
|
+
// An ident-start code point, a digit, or U+002D HYPHEN-MINUS (-).
|
5987
|
+
|
5988
|
+
// We don't validate `hex digits`, because we don't need it, it is work of linters.
|
5989
|
+
const validIdent =
|
5990
|
+
/^-?([a-z\u0080-\uFFFF_]|(\\[^\r\n\f])|-(?![0-9]))((\\[^\r\n\f])|[a-z\u0080-\uFFFF_0-9-])*$/i;
|
5943
5991
|
|
5944
5992
|
/*
|
5945
5993
|
The spec defines some keywords that you can use to describe properties such as the timing
|
5946
5994
|
function. These are still valid animation names, so as long as there is a property that accepts
|
5947
5995
|
a keyword, it is given priority. Only when all the properties that can take a keyword are
|
5948
5996
|
exhausted can the animation name be set to the keyword. I.e.
|
5949
|
-
|
5997
|
+
|
5950
5998
|
animation: infinite infinite;
|
5951
|
-
|
5999
|
+
|
5952
6000
|
The animation will repeat an infinite number of times from the first argument, and will have an
|
5953
6001
|
animation name of infinite from the second.
|
5954
6002
|
*/
|
5955
6003
|
const animationKeywords = {
|
6004
|
+
// animation-direction
|
6005
|
+
$normal: 1,
|
6006
|
+
$reverse: 1,
|
5956
6007
|
$alternate: 1,
|
5957
6008
|
"$alternate-reverse": 1,
|
6009
|
+
// animation-fill-mode
|
6010
|
+
$forwards: 1,
|
5958
6011
|
$backwards: 1,
|
5959
6012
|
$both: 1,
|
6013
|
+
// animation-iteration-count
|
6014
|
+
$infinite: 1,
|
6015
|
+
// animation-play-state
|
6016
|
+
$paused: 1,
|
6017
|
+
$running: 1,
|
6018
|
+
// animation-timing-function
|
5960
6019
|
$ease: 1,
|
5961
6020
|
"$ease-in": 1,
|
5962
|
-
"$ease-in-out": 1,
|
5963
6021
|
"$ease-out": 1,
|
5964
|
-
$
|
5965
|
-
$infinite: 1,
|
6022
|
+
"$ease-in-out": 1,
|
5966
6023
|
$linear: 1,
|
5967
|
-
$none: Infinity, // No matter how many times you write none, it will never be an animation name
|
5968
|
-
$normal: 1,
|
5969
|
-
$paused: 1,
|
5970
|
-
$reverse: 1,
|
5971
|
-
$running: 1,
|
5972
6024
|
"$step-end": 1,
|
5973
6025
|
"$step-start": 1,
|
6026
|
+
// Special
|
6027
|
+
$none: Infinity, // No matter how many times you write none, it will never be an animation name
|
6028
|
+
// Global values
|
5974
6029
|
$initial: Infinity,
|
5975
6030
|
$inherit: Infinity,
|
5976
6031
|
$unset: Infinity,
|
6032
|
+
$revert: Infinity,
|
6033
|
+
"$revert-layer": Infinity,
|
5977
6034
|
};
|
5978
6035
|
let parsedAnimationKeywords = {};
|
5979
|
-
let stepsFunctionNode = null;
|
5980
6036
|
const valueNodes = valueParser(declaration.value).walk((node) => {
|
5981
|
-
|
6037
|
+
// If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh.
|
5982
6038
|
if (node.type === "div") {
|
5983
6039
|
parsedAnimationKeywords = {};
|
6040
|
+
|
6041
|
+
return;
|
6042
|
+
}
|
6043
|
+
// Do not handle nested functions
|
6044
|
+
else if (node.type === "function") {
|
6045
|
+
return false;
|
5984
6046
|
}
|
5985
|
-
|
5986
|
-
|
6047
|
+
// Ignore all except word
|
6048
|
+
else if (node.type !== "word") {
|
6049
|
+
return;
|
5987
6050
|
}
|
5988
|
-
|
5989
|
-
|
5990
|
-
!isWordAFunctionArgument(node, stepsFunctionNode)
|
5991
|
-
? node.value.toLowerCase()
|
5992
|
-
: null;
|
6051
|
+
|
6052
|
+
const value = node.type === "word" ? node.value.toLowerCase() : null;
|
5993
6053
|
|
5994
6054
|
let shouldParseAnimationName = false;
|
5995
6055
|
|
@@ -6014,6 +6074,7 @@ function localizeDeclaration(declaration, context) {
|
|
6014
6074
|
localizeNextItem: shouldParseAnimationName && !context.global,
|
6015
6075
|
localAliasMap: context.localAliasMap,
|
6016
6076
|
};
|
6077
|
+
|
6017
6078
|
return localizeDeclNode(node, subContext);
|
6018
6079
|
});
|
6019
6080
|
|
@@ -6088,10 +6149,12 @@ src$2.exports = (options = {}) => {
|
|
6088
6149
|
} else if (localMatch) {
|
6089
6150
|
atRule.params = localMatch[0];
|
6090
6151
|
globalKeyframes = false;
|
6091
|
-
} else if (
|
6092
|
-
|
6093
|
-
|
6094
|
-
|
6152
|
+
} else if (
|
6153
|
+
atRule.params &&
|
6154
|
+
!globalMode &&
|
6155
|
+
!localAliasMap.has(atRule.params)
|
6156
|
+
) {
|
6157
|
+
atRule.params = ":local(" + atRule.params + ")";
|
6095
6158
|
}
|
6096
6159
|
|
6097
6160
|
atRule.walkDecls((declaration) => {
|
@@ -6101,6 +6164,44 @@ src$2.exports = (options = {}) => {
|
|
6101
6164
|
global: globalKeyframes,
|
6102
6165
|
});
|
6103
6166
|
});
|
6167
|
+
} else if (/scope$/i.test(atRule.name)) {
|
6168
|
+
if (atRule.params) {
|
6169
|
+
atRule.params = atRule.params
|
6170
|
+
.split("to")
|
6171
|
+
.map((item) => {
|
6172
|
+
const selector = item.trim().slice(1, -1).trim();
|
6173
|
+
const context = localizeNode(
|
6174
|
+
selector,
|
6175
|
+
options.mode,
|
6176
|
+
localAliasMap
|
6177
|
+
);
|
6178
|
+
|
6179
|
+
context.options = options;
|
6180
|
+
context.localAliasMap = localAliasMap;
|
6181
|
+
|
6182
|
+
if (pureMode && context.hasPureGlobals) {
|
6183
|
+
throw atRule.error(
|
6184
|
+
'Selector in at-rule"' +
|
6185
|
+
selector +
|
6186
|
+
'" is not pure ' +
|
6187
|
+
"(pure selectors must contain at least one local class or id)"
|
6188
|
+
);
|
6189
|
+
}
|
6190
|
+
|
6191
|
+
return `(${context.selector})`;
|
6192
|
+
})
|
6193
|
+
.join(" to ");
|
6194
|
+
}
|
6195
|
+
|
6196
|
+
atRule.nodes.forEach((declaration) => {
|
6197
|
+
if (declaration.type === "decl") {
|
6198
|
+
localizeDeclaration(declaration, {
|
6199
|
+
localAliasMap,
|
6200
|
+
options: options,
|
6201
|
+
global: globalMode,
|
6202
|
+
});
|
6203
|
+
}
|
6204
|
+
});
|
6104
6205
|
} else if (atRule.nodes) {
|
6105
6206
|
atRule.nodes.forEach((declaration) => {
|
6106
6207
|
if (declaration.type === "decl") {
|
@@ -6160,7 +6261,23 @@ const selectorParser = distExports;
|
|
6160
6261
|
|
6161
6262
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
6162
6263
|
|
6163
|
-
function
|
6264
|
+
function isNestedRule(rule) {
|
6265
|
+
if (!rule.parent || rule.parent.type === "root") {
|
6266
|
+
return false;
|
6267
|
+
}
|
6268
|
+
|
6269
|
+
if (rule.parent.type === "rule") {
|
6270
|
+
return true;
|
6271
|
+
}
|
6272
|
+
|
6273
|
+
return isNestedRule(rule.parent);
|
6274
|
+
}
|
6275
|
+
|
6276
|
+
function getSingleLocalNamesForComposes(root, rule) {
|
6277
|
+
if (isNestedRule(rule)) {
|
6278
|
+
throw new Error(`composition is not allowed in nested rule \n\n${rule}`);
|
6279
|
+
}
|
6280
|
+
|
6164
6281
|
return root.nodes.map((node) => {
|
6165
6282
|
if (node.type !== "selector" || node.nodes.length !== 1) {
|
6166
6283
|
throw new Error(
|
@@ -6247,17 +6364,19 @@ const plugin = (options = {}) => {
|
|
6247
6364
|
Once(root, { rule }) {
|
6248
6365
|
const exports = Object.create(null);
|
6249
6366
|
|
6250
|
-
function exportScopedName(name, rawName) {
|
6367
|
+
function exportScopedName(name, rawName, node) {
|
6251
6368
|
const scopedName = generateScopedName(
|
6252
6369
|
rawName ? rawName : name,
|
6253
6370
|
root.source.input.from,
|
6254
|
-
root.source.input.css
|
6371
|
+
root.source.input.css,
|
6372
|
+
node
|
6255
6373
|
);
|
6256
6374
|
const exportEntry = generateExportEntry(
|
6257
6375
|
rawName ? rawName : name,
|
6258
6376
|
scopedName,
|
6259
6377
|
root.source.input.from,
|
6260
|
-
root.source.input.css
|
6378
|
+
root.source.input.css,
|
6379
|
+
node
|
6261
6380
|
);
|
6262
6381
|
const { key, value } = exportEntry;
|
6263
6382
|
|
@@ -6273,23 +6392,35 @@ const plugin = (options = {}) => {
|
|
6273
6392
|
function localizeNode(node) {
|
6274
6393
|
switch (node.type) {
|
6275
6394
|
case "selector":
|
6276
|
-
node.nodes = node.map(localizeNode);
|
6395
|
+
node.nodes = node.map((item) => localizeNode(item));
|
6277
6396
|
return node;
|
6278
6397
|
case "class":
|
6279
6398
|
return selectorParser.className({
|
6280
6399
|
value: exportScopedName(
|
6281
6400
|
node.value,
|
6282
|
-
node.raws && node.raws.value ? node.raws.value : null
|
6401
|
+
node.raws && node.raws.value ? node.raws.value : null,
|
6402
|
+
node
|
6283
6403
|
),
|
6284
6404
|
});
|
6285
6405
|
case "id": {
|
6286
6406
|
return selectorParser.id({
|
6287
6407
|
value: exportScopedName(
|
6288
6408
|
node.value,
|
6289
|
-
node.raws && node.raws.value ? node.raws.value : null
|
6409
|
+
node.raws && node.raws.value ? node.raws.value : null,
|
6410
|
+
node
|
6290
6411
|
),
|
6291
6412
|
});
|
6292
6413
|
}
|
6414
|
+
case "attribute": {
|
6415
|
+
if (node.attribute === "class" && node.operator === "=") {
|
6416
|
+
return selectorParser.attribute({
|
6417
|
+
attribute: node.attribute,
|
6418
|
+
operator: node.operator,
|
6419
|
+
quoteMark: "'",
|
6420
|
+
value: exportScopedName(node.value, null, null),
|
6421
|
+
});
|
6422
|
+
}
|
6423
|
+
}
|
6293
6424
|
}
|
6294
6425
|
|
6295
6426
|
throw new Error(
|
@@ -6306,7 +6437,7 @@ const plugin = (options = {}) => {
|
|
6306
6437
|
}
|
6307
6438
|
|
6308
6439
|
const selector = localizeNode(node.first);
|
6309
|
-
// move the spaces that were around the
|
6440
|
+
// move the spaces that were around the pseudo selector to the first
|
6310
6441
|
// non-container node
|
6311
6442
|
selector.first.spaces = node.spaces;
|
6312
6443
|
|
@@ -6328,7 +6459,7 @@ const plugin = (options = {}) => {
|
|
6328
6459
|
/* falls through */
|
6329
6460
|
case "root":
|
6330
6461
|
case "selector": {
|
6331
|
-
node.each(traverseNode);
|
6462
|
+
node.each((item) => traverseNode(item));
|
6332
6463
|
break;
|
6333
6464
|
}
|
6334
6465
|
case "id":
|
@@ -6356,32 +6487,39 @@ const plugin = (options = {}) => {
|
|
6356
6487
|
|
6357
6488
|
rule.selector = traverseNode(parsedSelector.clone()).toString();
|
6358
6489
|
|
6359
|
-
rule.walkDecls(
|
6360
|
-
const localNames = getSingleLocalNamesForComposes(
|
6361
|
-
|
6490
|
+
rule.walkDecls(/^(composes|compose-with)$/i, (decl) => {
|
6491
|
+
const localNames = getSingleLocalNamesForComposes(
|
6492
|
+
parsedSelector,
|
6493
|
+
decl.parent
|
6494
|
+
);
|
6495
|
+
const multiple = decl.value.split(",");
|
6362
6496
|
|
6363
|
-
|
6364
|
-
const
|
6497
|
+
multiple.forEach((value) => {
|
6498
|
+
const classes = value.trim().split(/\s+/);
|
6365
6499
|
|
6366
|
-
|
6367
|
-
|
6368
|
-
|
6369
|
-
|
6370
|
-
|
6371
|
-
|
6372
|
-
exports[exportedName].push(className);
|
6373
|
-
});
|
6374
|
-
} else if (hasOwnProperty.call(exports, className)) {
|
6375
|
-
localNames.forEach((exportedName) => {
|
6376
|
-
exports[className].forEach((item) => {
|
6377
|
-
exports[exportedName].push(item);
|
6500
|
+
classes.forEach((className) => {
|
6501
|
+
const global = /^global\(([^)]+)\)$/.exec(className);
|
6502
|
+
|
6503
|
+
if (global) {
|
6504
|
+
localNames.forEach((exportedName) => {
|
6505
|
+
exports[exportedName].push(global[1]);
|
6378
6506
|
});
|
6379
|
-
})
|
6380
|
-
|
6381
|
-
|
6382
|
-
|
6383
|
-
)
|
6384
|
-
|
6507
|
+
} else if (hasOwnProperty.call(importedNames, className)) {
|
6508
|
+
localNames.forEach((exportedName) => {
|
6509
|
+
exports[exportedName].push(className);
|
6510
|
+
});
|
6511
|
+
} else if (hasOwnProperty.call(exports, className)) {
|
6512
|
+
localNames.forEach((exportedName) => {
|
6513
|
+
exports[className].forEach((item) => {
|
6514
|
+
exports[exportedName].push(item);
|
6515
|
+
});
|
6516
|
+
});
|
6517
|
+
} else {
|
6518
|
+
throw decl.error(
|
6519
|
+
`referenced class name "${className}" in ${decl.prop} not found`
|
6520
|
+
);
|
6521
|
+
}
|
6522
|
+
});
|
6385
6523
|
});
|
6386
6524
|
|
6387
6525
|
decl.remove();
|
@@ -6433,6 +6571,27 @@ const plugin = (options = {}) => {
|
|
6433
6571
|
atRule.params = exportScopedName(localMatch[1]);
|
6434
6572
|
});
|
6435
6573
|
|
6574
|
+
root.walkAtRules(/scope$/i, (atRule) => {
|
6575
|
+
if (atRule.params) {
|
6576
|
+
atRule.params = atRule.params
|
6577
|
+
.split("to")
|
6578
|
+
.map((item) => {
|
6579
|
+
const selector = item.trim().slice(1, -1).trim();
|
6580
|
+
|
6581
|
+
const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(selector);
|
6582
|
+
|
6583
|
+
if (!localMatch) {
|
6584
|
+
return `(${selector})`;
|
6585
|
+
}
|
6586
|
+
|
6587
|
+
let parsedSelector = selectorParser().astSync(selector);
|
6588
|
+
|
6589
|
+
return `(${traverseNode(parsedSelector).toString()})`;
|
6590
|
+
})
|
6591
|
+
.join(" to ");
|
6592
|
+
}
|
6593
|
+
});
|
6594
|
+
|
6436
6595
|
// If we found any :locals, insert an :export rule
|
6437
6596
|
const exportedNames = Object.keys(exports);
|
6438
6597
|
|
@@ -6816,7 +6975,7 @@ function makePlugin(opts) {
|
|
6816
6975
|
};
|
6817
6976
|
}
|
6818
6977
|
|
6819
|
-
var _fs = require$$
|
6978
|
+
var _fs = require$$0$2;
|
6820
6979
|
|
6821
6980
|
var _fs2 = fs;
|
6822
6981
|
|