vite 5.4.10 → 5.4.12
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/dist/client/client.mjs +5 -1
- package/dist/node/chunks/{dep-BASfdaBA.js → dep-B0RN4094.js} +267 -106
- package/dist/node/chunks/{dep-BWSbWtLw.js → dep-CjorC8P2.js} +174 -14
- package/dist/node/chunks/{dep-GkhNNjoY.js → dep-gXhP-2iO.js} +1 -1
- package/dist/node/cli.js +7 -6
- package/dist/node/index.d.ts +47 -0
- package/dist/node/index.js +4 -3
- package/package.json +1 -1
package/dist/client/client.mjs
CHANGED
@@ -500,6 +500,7 @@ const hmrPort = __HMR_PORT__;
|
|
500
500
|
const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${hmrPort || importMetaUrl.port}${__HMR_BASE__}`;
|
501
501
|
const directSocketHost = __HMR_DIRECT_TARGET__;
|
502
502
|
const base = __BASE__ || "/";
|
503
|
+
const wsToken = __WS_TOKEN__;
|
503
504
|
let socket;
|
504
505
|
try {
|
505
506
|
let fallback;
|
@@ -532,7 +533,10 @@ Check out your Vite / network configuration and https://vite.dev/config/server-o
|
|
532
533
|
console.error(`[vite] failed to connect to websocket (${error}). `);
|
533
534
|
}
|
534
535
|
function setupWebSocket(protocol, hostAndPath, onCloseWithoutOpen) {
|
535
|
-
const socket2 = new WebSocket(
|
536
|
+
const socket2 = new WebSocket(
|
537
|
+
`${protocol}://${hostAndPath}?token=${wsToken}`,
|
538
|
+
"vite-hmr"
|
539
|
+
);
|
536
540
|
let isOpened = false;
|
537
541
|
socket2.addEventListener(
|
538
542
|
"open",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-CjorC8P2.js';
|
2
2
|
import require$$0__default from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -1327,54 +1327,63 @@ src$3.exports = (options = {}) => {
|
|
1327
1327
|
});
|
1328
1328
|
|
1329
1329
|
root.walkDecls(/^composes$/, (declaration) => {
|
1330
|
-
const
|
1330
|
+
const multiple = declaration.value.split(",");
|
1331
|
+
const values = [];
|
1331
1332
|
|
1332
|
-
|
1333
|
-
|
1334
|
-
}
|
1333
|
+
multiple.forEach((value) => {
|
1334
|
+
const matches = value.trim().match(matchImports$1);
|
1335
1335
|
|
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;
|
1336
|
+
if (!matches) {
|
1337
|
+
values.push(value);
|
1350
1338
|
|
1351
|
-
|
1352
|
-
let parentIndexes = "";
|
1353
|
-
|
1354
|
-
while (parent.type !== "root") {
|
1355
|
-
parentIndexes =
|
1356
|
-
parent.parent.index(parent) + "_" + parentIndexes;
|
1357
|
-
parent = parent.parent;
|
1339
|
+
return;
|
1358
1340
|
}
|
1359
1341
|
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1342
|
+
let tmpSymbols;
|
1343
|
+
let [
|
1344
|
+
,
|
1345
|
+
/*match*/ symbols,
|
1346
|
+
doubleQuotePath,
|
1347
|
+
singleQuotePath,
|
1348
|
+
global,
|
1349
|
+
] = matches;
|
1350
|
+
|
1351
|
+
if (global) {
|
1352
|
+
// Composing globals simply means changing these classes to wrap them in global(name)
|
1353
|
+
tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
|
1354
|
+
} else {
|
1355
|
+
const importPath = doubleQuotePath || singleQuotePath;
|
1364
1356
|
|
1365
|
-
|
1366
|
-
|
1357
|
+
let parent = declaration.parent;
|
1358
|
+
let parentIndexes = "";
|
1367
1359
|
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1360
|
+
while (parent.type !== "root") {
|
1361
|
+
parentIndexes =
|
1362
|
+
parent.parent.index(parent) + "_" + parentIndexes;
|
1363
|
+
parent = parent.parent;
|
1371
1364
|
}
|
1372
1365
|
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1366
|
+
const { selector } = declaration.parent;
|
1367
|
+
const parentRule = `_${parentIndexes}${selector}`;
|
1368
|
+
|
1369
|
+
addImportToGraph(importPath, parentRule, graph, visited);
|
1370
|
+
|
1371
|
+
importDecls[importPath] = declaration;
|
1372
|
+
imports[importPath] = imports[importPath] || {};
|
1376
1373
|
|
1377
|
-
|
1374
|
+
tmpSymbols = symbols.split(/\s+/).map((s) => {
|
1375
|
+
if (!imports[importPath][s]) {
|
1376
|
+
imports[importPath][s] = createImportedName(s, importPath);
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
return imports[importPath][s];
|
1380
|
+
});
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
values.push(tmpSymbols.join(" "));
|
1384
|
+
});
|
1385
|
+
|
1386
|
+
declaration.value = values.join(", ");
|
1378
1387
|
});
|
1379
1388
|
|
1380
1389
|
const importsOrder = topologicalSort(graph, failOnWrongOrder);
|
@@ -5767,9 +5776,19 @@ function localizeNode(rule, mode, localAliasMap) {
|
|
5767
5776
|
hasLocals: false,
|
5768
5777
|
explicit: context.explicit,
|
5769
5778
|
};
|
5770
|
-
newNodes = node.map((childNode) =>
|
5771
|
-
|
5772
|
-
|
5779
|
+
newNodes = node.map((childNode) => {
|
5780
|
+
const newContext = {
|
5781
|
+
...childContext,
|
5782
|
+
enforceNoSpacing: false,
|
5783
|
+
};
|
5784
|
+
|
5785
|
+
const result = transform(childNode, newContext);
|
5786
|
+
|
5787
|
+
childContext.global = newContext.global;
|
5788
|
+
childContext.hasLocals = newContext.hasLocals;
|
5789
|
+
|
5790
|
+
return result;
|
5791
|
+
});
|
5773
5792
|
|
5774
5793
|
node = node.clone();
|
5775
5794
|
node.nodes = normalizeNodeArray(newNodes);
|
@@ -5838,6 +5857,11 @@ function localizeNode(rule, mode, localAliasMap) {
|
|
5838
5857
|
|
5839
5858
|
break;
|
5840
5859
|
}
|
5860
|
+
case "nesting": {
|
5861
|
+
if (node.value === "&") {
|
5862
|
+
context.hasLocals = true;
|
5863
|
+
}
|
5864
|
+
}
|
5841
5865
|
}
|
5842
5866
|
|
5843
5867
|
context.lastWasSpacing = false;
|
@@ -5910,19 +5934,34 @@ function localizeDeclNode(node, context) {
|
|
5910
5934
|
return node;
|
5911
5935
|
}
|
5912
5936
|
|
5913
|
-
|
5914
|
-
|
5915
|
-
|
5916
|
-
|
5917
|
-
|
5918
|
-
|
5919
|
-
|
5920
|
-
|
5937
|
+
// `none` is special value, other is global values
|
5938
|
+
const specialKeywords = [
|
5939
|
+
"none",
|
5940
|
+
"inherit",
|
5941
|
+
"initial",
|
5942
|
+
"revert",
|
5943
|
+
"revert-layer",
|
5944
|
+
"unset",
|
5945
|
+
];
|
5921
5946
|
|
5922
5947
|
function localizeDeclarationValues(localize, declaration, context) {
|
5923
5948
|
const valueNodes = valueParser(declaration.value);
|
5924
5949
|
|
5925
5950
|
valueNodes.walk((node, index, nodes) => {
|
5951
|
+
if (
|
5952
|
+
node.type === "function" &&
|
5953
|
+
(node.value.toLowerCase() === "var" || node.value.toLowerCase() === "env")
|
5954
|
+
) {
|
5955
|
+
return false;
|
5956
|
+
}
|
5957
|
+
|
5958
|
+
if (
|
5959
|
+
node.type === "word" &&
|
5960
|
+
specialKeywords.includes(node.value.toLowerCase())
|
5961
|
+
) {
|
5962
|
+
return;
|
5963
|
+
}
|
5964
|
+
|
5926
5965
|
const subContext = {
|
5927
5966
|
options: context.options,
|
5928
5967
|
global: context.global,
|
@@ -5939,57 +5978,80 @@ function localizeDeclaration(declaration, context) {
|
|
5939
5978
|
const isAnimation = /animation$/i.test(declaration.prop);
|
5940
5979
|
|
5941
5980
|
if (isAnimation) {
|
5942
|
-
|
5981
|
+
// letter
|
5982
|
+
// An uppercase letter or a lowercase letter.
|
5983
|
+
//
|
5984
|
+
// ident-start code point
|
5985
|
+
// A letter, a non-ASCII code point, or U+005F LOW LINE (_).
|
5986
|
+
//
|
5987
|
+
// ident code point
|
5988
|
+
// An ident-start code point, a digit, or U+002D HYPHEN-MINUS (-).
|
5989
|
+
|
5990
|
+
// We don't validate `hex digits`, because we don't need it, it is work of linters.
|
5991
|
+
const validIdent =
|
5992
|
+
/^-?([a-z\u0080-\uFFFF_]|(\\[^\r\n\f])|-(?![0-9]))((\\[^\r\n\f])|[a-z\u0080-\uFFFF_0-9-])*$/i;
|
5943
5993
|
|
5944
5994
|
/*
|
5945
5995
|
The spec defines some keywords that you can use to describe properties such as the timing
|
5946
5996
|
function. These are still valid animation names, so as long as there is a property that accepts
|
5947
5997
|
a keyword, it is given priority. Only when all the properties that can take a keyword are
|
5948
5998
|
exhausted can the animation name be set to the keyword. I.e.
|
5949
|
-
|
5999
|
+
|
5950
6000
|
animation: infinite infinite;
|
5951
|
-
|
6001
|
+
|
5952
6002
|
The animation will repeat an infinite number of times from the first argument, and will have an
|
5953
6003
|
animation name of infinite from the second.
|
5954
6004
|
*/
|
5955
6005
|
const animationKeywords = {
|
6006
|
+
// animation-direction
|
6007
|
+
$normal: 1,
|
6008
|
+
$reverse: 1,
|
5956
6009
|
$alternate: 1,
|
5957
6010
|
"$alternate-reverse": 1,
|
6011
|
+
// animation-fill-mode
|
6012
|
+
$forwards: 1,
|
5958
6013
|
$backwards: 1,
|
5959
6014
|
$both: 1,
|
6015
|
+
// animation-iteration-count
|
6016
|
+
$infinite: 1,
|
6017
|
+
// animation-play-state
|
6018
|
+
$paused: 1,
|
6019
|
+
$running: 1,
|
6020
|
+
// animation-timing-function
|
5960
6021
|
$ease: 1,
|
5961
6022
|
"$ease-in": 1,
|
5962
|
-
"$ease-in-out": 1,
|
5963
6023
|
"$ease-out": 1,
|
5964
|
-
$
|
5965
|
-
$infinite: 1,
|
6024
|
+
"$ease-in-out": 1,
|
5966
6025
|
$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
6026
|
"$step-end": 1,
|
5973
6027
|
"$step-start": 1,
|
6028
|
+
// Special
|
6029
|
+
$none: Infinity, // No matter how many times you write none, it will never be an animation name
|
6030
|
+
// Global values
|
5974
6031
|
$initial: Infinity,
|
5975
6032
|
$inherit: Infinity,
|
5976
6033
|
$unset: Infinity,
|
6034
|
+
$revert: Infinity,
|
6035
|
+
"$revert-layer": Infinity,
|
5977
6036
|
};
|
5978
6037
|
let parsedAnimationKeywords = {};
|
5979
|
-
let stepsFunctionNode = null;
|
5980
6038
|
const valueNodes = valueParser(declaration.value).walk((node) => {
|
5981
|
-
|
6039
|
+
// If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh.
|
5982
6040
|
if (node.type === "div") {
|
5983
6041
|
parsedAnimationKeywords = {};
|
6042
|
+
|
6043
|
+
return;
|
6044
|
+
}
|
6045
|
+
// Do not handle nested functions
|
6046
|
+
else if (node.type === "function") {
|
6047
|
+
return false;
|
5984
6048
|
}
|
5985
|
-
|
5986
|
-
|
6049
|
+
// Ignore all except word
|
6050
|
+
else if (node.type !== "word") {
|
6051
|
+
return;
|
5987
6052
|
}
|
5988
|
-
|
5989
|
-
|
5990
|
-
!isWordAFunctionArgument(node, stepsFunctionNode)
|
5991
|
-
? node.value.toLowerCase()
|
5992
|
-
: null;
|
6053
|
+
|
6054
|
+
const value = node.type === "word" ? node.value.toLowerCase() : null;
|
5993
6055
|
|
5994
6056
|
let shouldParseAnimationName = false;
|
5995
6057
|
|
@@ -6014,6 +6076,7 @@ function localizeDeclaration(declaration, context) {
|
|
6014
6076
|
localizeNextItem: shouldParseAnimationName && !context.global,
|
6015
6077
|
localAliasMap: context.localAliasMap,
|
6016
6078
|
};
|
6079
|
+
|
6017
6080
|
return localizeDeclNode(node, subContext);
|
6018
6081
|
});
|
6019
6082
|
|
@@ -6088,10 +6151,12 @@ src$2.exports = (options = {}) => {
|
|
6088
6151
|
} else if (localMatch) {
|
6089
6152
|
atRule.params = localMatch[0];
|
6090
6153
|
globalKeyframes = false;
|
6091
|
-
} else if (
|
6092
|
-
|
6093
|
-
|
6094
|
-
|
6154
|
+
} else if (
|
6155
|
+
atRule.params &&
|
6156
|
+
!globalMode &&
|
6157
|
+
!localAliasMap.has(atRule.params)
|
6158
|
+
) {
|
6159
|
+
atRule.params = ":local(" + atRule.params + ")";
|
6095
6160
|
}
|
6096
6161
|
|
6097
6162
|
atRule.walkDecls((declaration) => {
|
@@ -6101,6 +6166,44 @@ src$2.exports = (options = {}) => {
|
|
6101
6166
|
global: globalKeyframes,
|
6102
6167
|
});
|
6103
6168
|
});
|
6169
|
+
} else if (/scope$/i.test(atRule.name)) {
|
6170
|
+
if (atRule.params) {
|
6171
|
+
atRule.params = atRule.params
|
6172
|
+
.split("to")
|
6173
|
+
.map((item) => {
|
6174
|
+
const selector = item.trim().slice(1, -1).trim();
|
6175
|
+
const context = localizeNode(
|
6176
|
+
selector,
|
6177
|
+
options.mode,
|
6178
|
+
localAliasMap
|
6179
|
+
);
|
6180
|
+
|
6181
|
+
context.options = options;
|
6182
|
+
context.localAliasMap = localAliasMap;
|
6183
|
+
|
6184
|
+
if (pureMode && context.hasPureGlobals) {
|
6185
|
+
throw atRule.error(
|
6186
|
+
'Selector in at-rule"' +
|
6187
|
+
selector +
|
6188
|
+
'" is not pure ' +
|
6189
|
+
"(pure selectors must contain at least one local class or id)"
|
6190
|
+
);
|
6191
|
+
}
|
6192
|
+
|
6193
|
+
return `(${context.selector})`;
|
6194
|
+
})
|
6195
|
+
.join(" to ");
|
6196
|
+
}
|
6197
|
+
|
6198
|
+
atRule.nodes.forEach((declaration) => {
|
6199
|
+
if (declaration.type === "decl") {
|
6200
|
+
localizeDeclaration(declaration, {
|
6201
|
+
localAliasMap,
|
6202
|
+
options: options,
|
6203
|
+
global: globalMode,
|
6204
|
+
});
|
6205
|
+
}
|
6206
|
+
});
|
6104
6207
|
} else if (atRule.nodes) {
|
6105
6208
|
atRule.nodes.forEach((declaration) => {
|
6106
6209
|
if (declaration.type === "decl") {
|
@@ -6160,7 +6263,23 @@ const selectorParser = distExports;
|
|
6160
6263
|
|
6161
6264
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
6162
6265
|
|
6163
|
-
function
|
6266
|
+
function isNestedRule(rule) {
|
6267
|
+
if (!rule.parent || rule.parent.type === "root") {
|
6268
|
+
return false;
|
6269
|
+
}
|
6270
|
+
|
6271
|
+
if (rule.parent.type === "rule") {
|
6272
|
+
return true;
|
6273
|
+
}
|
6274
|
+
|
6275
|
+
return isNestedRule(rule.parent);
|
6276
|
+
}
|
6277
|
+
|
6278
|
+
function getSingleLocalNamesForComposes(root, rule) {
|
6279
|
+
if (isNestedRule(rule)) {
|
6280
|
+
throw new Error(`composition is not allowed in nested rule \n\n${rule}`);
|
6281
|
+
}
|
6282
|
+
|
6164
6283
|
return root.nodes.map((node) => {
|
6165
6284
|
if (node.type !== "selector" || node.nodes.length !== 1) {
|
6166
6285
|
throw new Error(
|
@@ -6247,17 +6366,19 @@ const plugin = (options = {}) => {
|
|
6247
6366
|
Once(root, { rule }) {
|
6248
6367
|
const exports = Object.create(null);
|
6249
6368
|
|
6250
|
-
function exportScopedName(name, rawName) {
|
6369
|
+
function exportScopedName(name, rawName, node) {
|
6251
6370
|
const scopedName = generateScopedName(
|
6252
6371
|
rawName ? rawName : name,
|
6253
6372
|
root.source.input.from,
|
6254
|
-
root.source.input.css
|
6373
|
+
root.source.input.css,
|
6374
|
+
node
|
6255
6375
|
);
|
6256
6376
|
const exportEntry = generateExportEntry(
|
6257
6377
|
rawName ? rawName : name,
|
6258
6378
|
scopedName,
|
6259
6379
|
root.source.input.from,
|
6260
|
-
root.source.input.css
|
6380
|
+
root.source.input.css,
|
6381
|
+
node
|
6261
6382
|
);
|
6262
6383
|
const { key, value } = exportEntry;
|
6263
6384
|
|
@@ -6273,23 +6394,35 @@ const plugin = (options = {}) => {
|
|
6273
6394
|
function localizeNode(node) {
|
6274
6395
|
switch (node.type) {
|
6275
6396
|
case "selector":
|
6276
|
-
node.nodes = node.map(localizeNode);
|
6397
|
+
node.nodes = node.map((item) => localizeNode(item));
|
6277
6398
|
return node;
|
6278
6399
|
case "class":
|
6279
6400
|
return selectorParser.className({
|
6280
6401
|
value: exportScopedName(
|
6281
6402
|
node.value,
|
6282
|
-
node.raws && node.raws.value ? node.raws.value : null
|
6403
|
+
node.raws && node.raws.value ? node.raws.value : null,
|
6404
|
+
node
|
6283
6405
|
),
|
6284
6406
|
});
|
6285
6407
|
case "id": {
|
6286
6408
|
return selectorParser.id({
|
6287
6409
|
value: exportScopedName(
|
6288
6410
|
node.value,
|
6289
|
-
node.raws && node.raws.value ? node.raws.value : null
|
6411
|
+
node.raws && node.raws.value ? node.raws.value : null,
|
6412
|
+
node
|
6290
6413
|
),
|
6291
6414
|
});
|
6292
6415
|
}
|
6416
|
+
case "attribute": {
|
6417
|
+
if (node.attribute === "class" && node.operator === "=") {
|
6418
|
+
return selectorParser.attribute({
|
6419
|
+
attribute: node.attribute,
|
6420
|
+
operator: node.operator,
|
6421
|
+
quoteMark: "'",
|
6422
|
+
value: exportScopedName(node.value, null, null),
|
6423
|
+
});
|
6424
|
+
}
|
6425
|
+
}
|
6293
6426
|
}
|
6294
6427
|
|
6295
6428
|
throw new Error(
|
@@ -6306,7 +6439,7 @@ const plugin = (options = {}) => {
|
|
6306
6439
|
}
|
6307
6440
|
|
6308
6441
|
const selector = localizeNode(node.first);
|
6309
|
-
// move the spaces that were around the
|
6442
|
+
// move the spaces that were around the pseudo selector to the first
|
6310
6443
|
// non-container node
|
6311
6444
|
selector.first.spaces = node.spaces;
|
6312
6445
|
|
@@ -6328,7 +6461,7 @@ const plugin = (options = {}) => {
|
|
6328
6461
|
/* falls through */
|
6329
6462
|
case "root":
|
6330
6463
|
case "selector": {
|
6331
|
-
node.each(traverseNode);
|
6464
|
+
node.each((item) => traverseNode(item));
|
6332
6465
|
break;
|
6333
6466
|
}
|
6334
6467
|
case "id":
|
@@ -6356,32 +6489,39 @@ const plugin = (options = {}) => {
|
|
6356
6489
|
|
6357
6490
|
rule.selector = traverseNode(parsedSelector.clone()).toString();
|
6358
6491
|
|
6359
|
-
rule.walkDecls(
|
6360
|
-
const localNames = getSingleLocalNamesForComposes(
|
6361
|
-
|
6492
|
+
rule.walkDecls(/^(composes|compose-with)$/i, (decl) => {
|
6493
|
+
const localNames = getSingleLocalNamesForComposes(
|
6494
|
+
parsedSelector,
|
6495
|
+
decl.parent
|
6496
|
+
);
|
6497
|
+
const multiple = decl.value.split(",");
|
6362
6498
|
|
6363
|
-
|
6364
|
-
const
|
6499
|
+
multiple.forEach((value) => {
|
6500
|
+
const classes = value.trim().split(/\s+/);
|
6365
6501
|
|
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);
|
6502
|
+
classes.forEach((className) => {
|
6503
|
+
const global = /^global\(([^)]+)\)$/.exec(className);
|
6504
|
+
|
6505
|
+
if (global) {
|
6506
|
+
localNames.forEach((exportedName) => {
|
6507
|
+
exports[exportedName].push(global[1]);
|
6378
6508
|
});
|
6379
|
-
})
|
6380
|
-
|
6381
|
-
|
6382
|
-
|
6383
|
-
)
|
6384
|
-
|
6509
|
+
} else if (hasOwnProperty.call(importedNames, className)) {
|
6510
|
+
localNames.forEach((exportedName) => {
|
6511
|
+
exports[exportedName].push(className);
|
6512
|
+
});
|
6513
|
+
} else if (hasOwnProperty.call(exports, className)) {
|
6514
|
+
localNames.forEach((exportedName) => {
|
6515
|
+
exports[className].forEach((item) => {
|
6516
|
+
exports[exportedName].push(item);
|
6517
|
+
});
|
6518
|
+
});
|
6519
|
+
} else {
|
6520
|
+
throw decl.error(
|
6521
|
+
`referenced class name "${className}" in ${decl.prop} not found`
|
6522
|
+
);
|
6523
|
+
}
|
6524
|
+
});
|
6385
6525
|
});
|
6386
6526
|
|
6387
6527
|
decl.remove();
|
@@ -6433,6 +6573,27 @@ const plugin = (options = {}) => {
|
|
6433
6573
|
atRule.params = exportScopedName(localMatch[1]);
|
6434
6574
|
});
|
6435
6575
|
|
6576
|
+
root.walkAtRules(/scope$/i, (atRule) => {
|
6577
|
+
if (atRule.params) {
|
6578
|
+
atRule.params = atRule.params
|
6579
|
+
.split("to")
|
6580
|
+
.map((item) => {
|
6581
|
+
const selector = item.trim().slice(1, -1).trim();
|
6582
|
+
|
6583
|
+
const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(selector);
|
6584
|
+
|
6585
|
+
if (!localMatch) {
|
6586
|
+
return `(${selector})`;
|
6587
|
+
}
|
6588
|
+
|
6589
|
+
let parsedSelector = selectorParser().astSync(selector);
|
6590
|
+
|
6591
|
+
return `(${traverseNode(parsedSelector).toString()})`;
|
6592
|
+
})
|
6593
|
+
.join(" to ");
|
6594
|
+
}
|
6595
|
+
});
|
6596
|
+
|
6436
6597
|
// If we found any :locals, insert an :export rule
|
6437
6598
|
const exportedNames = Object.keys(exports);
|
6438
6599
|
|
@@ -6,6 +6,7 @@ import { fileURLToPath, URL as URL$3, parse as parse$h, pathToFileURL } from 'no
|
|
6
6
|
import { promisify as promisify$4, format as format$2, inspect } from 'node:util';
|
7
7
|
import { performance as performance$1 } from 'node:perf_hooks';
|
8
8
|
import { createRequire as createRequire$1, builtinModules } from 'node:module';
|
9
|
+
import crypto$2, { createHash as createHash$2 } from 'node:crypto';
|
9
10
|
import require$$0$3 from 'tty';
|
10
11
|
import require$$0$4, { win32, posix, isAbsolute, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, sep as sep$1, normalize as normalize$1 } from 'path';
|
11
12
|
import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
|
@@ -27,7 +28,6 @@ import require$$0$6 from 'stream';
|
|
27
28
|
import require$$2 from 'os';
|
28
29
|
import require$$2$1 from 'child_process';
|
29
30
|
import os$5 from 'node:os';
|
30
|
-
import { createHash as createHash$2 } from 'node:crypto';
|
31
31
|
import { promises } from 'node:dns';
|
32
32
|
import require$$3$1 from 'crypto';
|
33
33
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
@@ -42,6 +42,7 @@ import zlib$1 from 'zlib';
|
|
42
42
|
import require$$0$a from 'buffer';
|
43
43
|
import require$$1$1 from 'https';
|
44
44
|
import require$$4$2 from 'tls';
|
45
|
+
import net$1 from 'node:net';
|
45
46
|
import require$$4$3 from 'assert';
|
46
47
|
import { gzip } from 'node:zlib';
|
47
48
|
|
@@ -36990,8 +36991,8 @@ function createCachedImport(imp) {
|
|
36990
36991
|
return cached;
|
36991
36992
|
};
|
36992
36993
|
}
|
36993
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
36994
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
36994
|
+
const importPostcssImport = createCachedImport(() => import('./dep-gXhP-2iO.js').then(function (n) { return n.i; }));
|
36995
|
+
const importPostcssModules = createCachedImport(() => import('./dep-B0RN4094.js').then(function (n) { return n.i; }));
|
36995
36996
|
const importPostcss = createCachedImport(() => import('postcss'));
|
36996
36997
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
36997
36998
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -47496,8 +47497,9 @@ function clientInjectionsPlugin(config) {
|
|
47496
47497
|
const hmrTimeoutReplacement = escapeReplacement(timeout);
|
47497
47498
|
const hmrEnableOverlayReplacement = escapeReplacement(overlay);
|
47498
47499
|
const hmrConfigNameReplacement = escapeReplacement(hmrConfigName);
|
47500
|
+
const wsTokenReplacement = escapeReplacement(config.webSocketToken);
|
47499
47501
|
injectConfigValues = (code) => {
|
47500
|
-
return code.replace(`__MODE__`, modeReplacement).replace(/__BASE__/g, baseReplacement).replace(`__DEFINES__`, definesReplacement).replace(`__SERVER_HOST__`, serverHostReplacement).replace(`__HMR_PROTOCOL__`, hmrProtocolReplacement).replace(`__HMR_HOSTNAME__`, hmrHostnameReplacement).replace(`__HMR_PORT__`, hmrPortReplacement).replace(`__HMR_DIRECT_TARGET__`, hmrDirectTargetReplacement).replace(`__HMR_BASE__`, hmrBaseReplacement).replace(`__HMR_TIMEOUT__`, hmrTimeoutReplacement).replace(`__HMR_ENABLE_OVERLAY__`, hmrEnableOverlayReplacement).replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement);
|
47502
|
+
return code.replace(`__MODE__`, modeReplacement).replace(/__BASE__/g, baseReplacement).replace(`__DEFINES__`, definesReplacement).replace(`__SERVER_HOST__`, serverHostReplacement).replace(`__HMR_PROTOCOL__`, hmrProtocolReplacement).replace(`__HMR_HOSTNAME__`, hmrHostnameReplacement).replace(`__HMR_PORT__`, hmrPortReplacement).replace(`__HMR_DIRECT_TARGET__`, hmrDirectTargetReplacement).replace(`__HMR_BASE__`, hmrBaseReplacement).replace(`__HMR_TIMEOUT__`, hmrTimeoutReplacement).replace(`__HMR_ENABLE_OVERLAY__`, hmrEnableOverlayReplacement).replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement).replace(`__WS_TOKEN__`, wsTokenReplacement);
|
47501
47503
|
};
|
47502
47504
|
},
|
47503
47505
|
async transform(code, id, options) {
|
@@ -59175,6 +59177,100 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
59175
59177
|
|
59176
59178
|
var WebSocketServerRaw_ = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);
|
59177
59179
|
|
59180
|
+
const allowedHostsCache = /* @__PURE__ */ new WeakMap();
|
59181
|
+
const isFileOrExtensionProtocolRE = /^(?:file|.+-extension):/i;
|
59182
|
+
function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions) {
|
59183
|
+
const list = [];
|
59184
|
+
if (typeof resolvedServerOptions.host === "string" && resolvedServerOptions.host) {
|
59185
|
+
list.push(resolvedServerOptions.host);
|
59186
|
+
}
|
59187
|
+
if (typeof resolvedServerOptions.hmr === "object" && resolvedServerOptions.hmr.host) {
|
59188
|
+
list.push(resolvedServerOptions.hmr.host);
|
59189
|
+
}
|
59190
|
+
if (typeof resolvedPreviewOptions.host === "string" && resolvedPreviewOptions.host) {
|
59191
|
+
list.push(resolvedPreviewOptions.host);
|
59192
|
+
}
|
59193
|
+
if (resolvedServerOptions.origin) {
|
59194
|
+
const serverOriginUrl = new URL(resolvedServerOptions.origin);
|
59195
|
+
list.push(serverOriginUrl.hostname);
|
59196
|
+
}
|
59197
|
+
return list;
|
59198
|
+
}
|
59199
|
+
function isHostAllowedWithoutCache(allowedHosts, additionalAllowedHosts, host) {
|
59200
|
+
if (isFileOrExtensionProtocolRE.test(host)) {
|
59201
|
+
return true;
|
59202
|
+
}
|
59203
|
+
const trimmedHost = host.trim();
|
59204
|
+
if (trimmedHost[0] === "[") {
|
59205
|
+
const endIpv6 = trimmedHost.indexOf("]");
|
59206
|
+
if (endIpv6 < 0) {
|
59207
|
+
return false;
|
59208
|
+
}
|
59209
|
+
return net$1.isIP(trimmedHost.slice(1, endIpv6)) === 6;
|
59210
|
+
}
|
59211
|
+
const colonPos = trimmedHost.indexOf(":");
|
59212
|
+
const hostname = colonPos === -1 ? trimmedHost : trimmedHost.slice(0, colonPos);
|
59213
|
+
if (net$1.isIP(hostname) === 4) {
|
59214
|
+
return true;
|
59215
|
+
}
|
59216
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost")) {
|
59217
|
+
return true;
|
59218
|
+
}
|
59219
|
+
for (const additionalAllowedHost of additionalAllowedHosts) {
|
59220
|
+
if (additionalAllowedHost === hostname) {
|
59221
|
+
return true;
|
59222
|
+
}
|
59223
|
+
}
|
59224
|
+
for (const allowedHost of allowedHosts) {
|
59225
|
+
if (allowedHost === hostname) {
|
59226
|
+
return true;
|
59227
|
+
}
|
59228
|
+
if (allowedHost[0] === "." && (allowedHost.slice(1) === hostname || hostname.endsWith(allowedHost))) {
|
59229
|
+
return true;
|
59230
|
+
}
|
59231
|
+
}
|
59232
|
+
return false;
|
59233
|
+
}
|
59234
|
+
function isHostAllowed(config, host) {
|
59235
|
+
if (config.server.allowedHosts === true) {
|
59236
|
+
return true;
|
59237
|
+
}
|
59238
|
+
if (!allowedHostsCache.has(config)) {
|
59239
|
+
allowedHostsCache.set(config, /* @__PURE__ */ new Set());
|
59240
|
+
}
|
59241
|
+
const allowedHosts = allowedHostsCache.get(config);
|
59242
|
+
if (allowedHosts.has(host)) {
|
59243
|
+
return true;
|
59244
|
+
}
|
59245
|
+
const result = isHostAllowedWithoutCache(
|
59246
|
+
config.server.allowedHosts ?? [],
|
59247
|
+
config.additionalAllowedHosts,
|
59248
|
+
host
|
59249
|
+
);
|
59250
|
+
if (result) {
|
59251
|
+
allowedHosts.add(host);
|
59252
|
+
}
|
59253
|
+
return result;
|
59254
|
+
}
|
59255
|
+
function hostCheckMiddleware(config) {
|
59256
|
+
return function viteHostCheckMiddleware(req, res, next) {
|
59257
|
+
const hostHeader = req.headers.host;
|
59258
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59259
|
+
const hostname = hostHeader?.replace(/:\d+$/, "");
|
59260
|
+
const hostnameWithQuotes = JSON.stringify(hostname);
|
59261
|
+
res.writeHead(403, {
|
59262
|
+
"Content-Type": "text/plain"
|
59263
|
+
});
|
59264
|
+
res.end(
|
59265
|
+
`Blocked request. This host (${hostnameWithQuotes}) is not allowed.
|
59266
|
+
To allow this host, add ${hostnameWithQuotes} to \`server.allowedHosts\` in vite.config.js.`
|
59267
|
+
);
|
59268
|
+
return;
|
59269
|
+
}
|
59270
|
+
return next();
|
59271
|
+
};
|
59272
|
+
}
|
59273
|
+
|
59178
59274
|
const WebSocketServerRaw = process.versions.bun ? (
|
59179
59275
|
// @ts-expect-error: Bun defines `import.meta.require`
|
59180
59276
|
import.meta.require("ws").WebSocketServer
|
@@ -59189,6 +59285,19 @@ const wsServerEvents = [
|
|
59189
59285
|
];
|
59190
59286
|
function noop$1() {
|
59191
59287
|
}
|
59288
|
+
function hasValidToken(config, url) {
|
59289
|
+
const token = url.searchParams.get("token");
|
59290
|
+
if (!token) return false;
|
59291
|
+
try {
|
59292
|
+
const isValidToken = crypto$2.timingSafeEqual(
|
59293
|
+
Buffer.from(token),
|
59294
|
+
Buffer.from(config.webSocketToken)
|
59295
|
+
);
|
59296
|
+
return isValidToken;
|
59297
|
+
} catch {
|
59298
|
+
}
|
59299
|
+
return false;
|
59300
|
+
}
|
59192
59301
|
function createWebSocketServer(server, config, httpsOptions) {
|
59193
59302
|
if (config.server.ws === false) {
|
59194
59303
|
return {
|
@@ -59204,7 +59313,6 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59204
59313
|
send: noop$1
|
59205
59314
|
};
|
59206
59315
|
}
|
59207
|
-
let wss;
|
59208
59316
|
let wsHttpServer = void 0;
|
59209
59317
|
const hmr = isObject$1(config.server.hmr) && config.server.hmr;
|
59210
59318
|
const hmrServer = hmr && hmr.server;
|
@@ -59216,18 +59324,37 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59216
59324
|
const clientsMap = /* @__PURE__ */ new WeakMap();
|
59217
59325
|
const port = hmrPort || 24678;
|
59218
59326
|
const host = hmr && hmr.host || void 0;
|
59327
|
+
const shouldHandle = (req) => {
|
59328
|
+
const hostHeader = req.headers.host;
|
59329
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59330
|
+
return false;
|
59331
|
+
}
|
59332
|
+
if (config.legacy?.skipWebSocketTokenCheck) {
|
59333
|
+
return true;
|
59334
|
+
}
|
59335
|
+
if (req.headers.origin) {
|
59336
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
59337
|
+
return hasValidToken(config, parsedUrl);
|
59338
|
+
}
|
59339
|
+
return true;
|
59340
|
+
};
|
59341
|
+
const handleUpgrade = (req, socket, head, _isPing) => {
|
59342
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
59343
|
+
wss.emit("connection", ws, req);
|
59344
|
+
});
|
59345
|
+
};
|
59346
|
+
const wss = new WebSocketServerRaw({ noServer: true });
|
59347
|
+
wss.shouldHandle = shouldHandle;
|
59219
59348
|
if (wsServer) {
|
59220
59349
|
let hmrBase = config.base;
|
59221
59350
|
const hmrPath = hmr ? hmr.path : void 0;
|
59222
59351
|
if (hmrPath) {
|
59223
59352
|
hmrBase = path$n.posix.join(hmrBase, hmrPath);
|
59224
59353
|
}
|
59225
|
-
wss = new WebSocketServerRaw({ noServer: true });
|
59226
59354
|
hmrServerWsListener = (req, socket, head) => {
|
59227
|
-
|
59228
|
-
|
59229
|
-
|
59230
|
-
});
|
59355
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
59356
|
+
if (req.headers["sec-websocket-protocol"] === HMR_HEADER && parsedUrl.pathname === hmrBase) {
|
59357
|
+
handleUpgrade(req, socket, head);
|
59231
59358
|
}
|
59232
59359
|
};
|
59233
59360
|
wsServer.on("upgrade", hmrServerWsListener);
|
@@ -59248,7 +59375,23 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59248
59375
|
} else {
|
59249
59376
|
wsHttpServer = createServer$3(route);
|
59250
59377
|
}
|
59251
|
-
|
59378
|
+
wsHttpServer.on("upgrade", (req, socket, head) => {
|
59379
|
+
handleUpgrade(req, socket, head);
|
59380
|
+
});
|
59381
|
+
wsHttpServer.on("error", (e) => {
|
59382
|
+
if (e.code === "EADDRINUSE") {
|
59383
|
+
config.logger.error(
|
59384
|
+
colors$1.red(`WebSocket server error: Port is already in use`),
|
59385
|
+
{ error: e }
|
59386
|
+
);
|
59387
|
+
} else {
|
59388
|
+
config.logger.error(
|
59389
|
+
colors$1.red(`WebSocket server error:
|
59390
|
+
${e.stack || e.message}`),
|
59391
|
+
{ error: e }
|
59392
|
+
);
|
59393
|
+
}
|
59394
|
+
});
|
59252
59395
|
}
|
59253
59396
|
wss.on("connection", (socket) => {
|
59254
59397
|
socket.on("message", (raw) => {
|
@@ -63083,9 +63226,13 @@ async function _createServer(inlineConfig = {}, options) {
|
|
63083
63226
|
middlewares.use(timeMiddleware(root));
|
63084
63227
|
}
|
63085
63228
|
const { cors } = serverConfig;
|
63086
|
-
if (cors !== false) {
|
63229
|
+
if (cors !== void 0 && cors !== false) {
|
63087
63230
|
middlewares.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
63088
63231
|
}
|
63232
|
+
const { allowedHosts } = serverConfig;
|
63233
|
+
if (allowedHosts !== true && !serverConfig.https) {
|
63234
|
+
middlewares.use(hostCheckMiddleware(config));
|
63235
|
+
}
|
63089
63236
|
middlewares.use(cachedTransformMiddleware(server));
|
63090
63237
|
const { proxy } = serverConfig;
|
63091
63238
|
if (proxy) {
|
@@ -65943,6 +66090,7 @@ function resolvePreviewOptions(preview2, server) {
|
|
65943
66090
|
port: preview2?.port,
|
65944
66091
|
strictPort: preview2?.strictPort ?? server.strictPort,
|
65945
66092
|
host: preview2?.host ?? server.host,
|
66093
|
+
allowedHosts: preview2?.allowedHosts ?? server.allowedHosts,
|
65946
66094
|
https: preview2?.https ?? server.https,
|
65947
66095
|
open: preview2?.open ?? server.open,
|
65948
66096
|
proxy: preview2?.proxy ?? server.proxy,
|
@@ -66010,9 +66158,13 @@ async function preview(inlineConfig = {}) {
|
|
66010
66158
|
postHooks.push(await hook(server));
|
66011
66159
|
}
|
66012
66160
|
const { cors } = config.preview;
|
66013
|
-
if (cors !== false) {
|
66161
|
+
if (cors !== void 0 && cors !== false) {
|
66014
66162
|
app.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
66015
66163
|
}
|
66164
|
+
const { allowedHosts } = config.preview;
|
66165
|
+
if (allowedHosts !== true && !config.preview.https) {
|
66166
|
+
app.use(hostCheckMiddleware(config));
|
66167
|
+
}
|
66016
66168
|
const { proxy } = config.preview;
|
66017
66169
|
if (proxy) {
|
66018
66170
|
app.use(proxyMiddleware(httpServer, proxy, config));
|
@@ -66329,6 +66481,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66329
66481
|
rollupOptions: config.worker?.rollupOptions || {}
|
66330
66482
|
};
|
66331
66483
|
const base = withTrailingSlash(resolvedBase);
|
66484
|
+
const preview = resolvePreviewOptions(config.preview, server);
|
66332
66485
|
resolved = {
|
66333
66486
|
configFile: configFile ? normalizePath$3(configFile) : void 0,
|
66334
66487
|
configFileDependencies: configFileDependencies.map(
|
@@ -66357,7 +66510,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66357
66510
|
},
|
66358
66511
|
server,
|
66359
66512
|
build: resolvedBuildOptions,
|
66360
|
-
preview
|
66513
|
+
preview,
|
66361
66514
|
envDir,
|
66362
66515
|
env: {
|
66363
66516
|
...userEnv,
|
@@ -66387,6 +66540,13 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66387
66540
|
hmrPartialAccept: false,
|
66388
66541
|
...config.experimental
|
66389
66542
|
},
|
66543
|
+
// random 72 bits (12 base64 chars)
|
66544
|
+
// at least 64bits is recommended
|
66545
|
+
// https://owasp.org/www-community/vulnerabilities/Insufficient_Session-ID_Length
|
66546
|
+
webSocketToken: Buffer.from(
|
66547
|
+
crypto$2.getRandomValues(new Uint8Array(9))
|
66548
|
+
).toString("base64url"),
|
66549
|
+
additionalAllowedHosts: getAdditionalAllowedHosts(server, preview),
|
66390
66550
|
getSortedPlugins: void 0,
|
66391
66551
|
getSortedPluginHooks: void 0
|
66392
66552
|
};
|
package/dist/node/cli.js
CHANGED
@@ -2,12 +2,13 @@ import path from 'node:path';
|
|
2
2
|
import fs__default from 'node:fs';
|
3
3
|
import { performance } from 'node:perf_hooks';
|
4
4
|
import { EventEmitter } from 'events';
|
5
|
-
import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-CjorC8P2.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
9
9
|
import 'node:util';
|
10
10
|
import 'node:module';
|
11
|
+
import 'node:crypto';
|
11
12
|
import 'tty';
|
12
13
|
import 'path';
|
13
14
|
import 'esbuild';
|
@@ -26,7 +27,6 @@ import 'stream';
|
|
26
27
|
import 'os';
|
27
28
|
import 'child_process';
|
28
29
|
import 'node:os';
|
29
|
-
import 'node:crypto';
|
30
30
|
import 'node:dns';
|
31
31
|
import 'crypto';
|
32
32
|
import 'module';
|
@@ -41,6 +41,7 @@ import 'zlib';
|
|
41
41
|
import 'buffer';
|
42
42
|
import 'https';
|
43
43
|
import 'tls';
|
44
|
+
import 'node:net';
|
44
45
|
import 'assert';
|
45
46
|
import 'node:zlib';
|
46
47
|
|
@@ -730,7 +731,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
730
731
|
`[boolean] force the optimizer to ignore the cache and re-bundle`
|
731
732
|
).action(async (root, options) => {
|
732
733
|
filterDuplicateOptions(options);
|
733
|
-
const { createServer } = await import('./chunks/dep-
|
734
|
+
const { createServer } = await import('./chunks/dep-CjorC8P2.js').then(function (n) { return n.E; });
|
734
735
|
try {
|
735
736
|
const server = await createServer({
|
736
737
|
root,
|
@@ -822,7 +823,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
822
823
|
`[boolean] force empty outDir when it's outside of root`
|
823
824
|
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
|
824
825
|
filterDuplicateOptions(options);
|
825
|
-
const { build } = await import('./chunks/dep-
|
826
|
+
const { build } = await import('./chunks/dep-CjorC8P2.js').then(function (n) { return n.F; });
|
826
827
|
const buildOptions = cleanOptions(options);
|
827
828
|
try {
|
828
829
|
await build({
|
@@ -851,7 +852,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
|
|
851
852
|
).action(
|
852
853
|
async (root, options) => {
|
853
854
|
filterDuplicateOptions(options);
|
854
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
855
|
+
const { optimizeDeps } = await import('./chunks/dep-CjorC8P2.js').then(function (n) { return n.D; });
|
855
856
|
try {
|
856
857
|
const config = await resolveConfig(
|
857
858
|
{
|
@@ -877,7 +878,7 @@ ${e.stack}`),
|
|
877
878
|
cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
|
878
879
|
async (root, options) => {
|
879
880
|
filterDuplicateOptions(options);
|
880
|
-
const { preview } = await import('./chunks/dep-
|
881
|
+
const { preview } = await import('./chunks/dep-CjorC8P2.js').then(function (n) { return n.G; });
|
881
882
|
try {
|
882
883
|
const server = await preview({
|
883
884
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -669,6 +669,18 @@ interface CommonServerOptions {
|
|
669
669
|
* Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
|
670
670
|
*/
|
671
671
|
host?: string | boolean;
|
672
|
+
/**
|
673
|
+
* The hostnames that Vite is allowed to respond to.
|
674
|
+
* `localhost` and subdomains under `.localhost` and all IP addresses are allowed by default.
|
675
|
+
* When using HTTPS, this check is skipped.
|
676
|
+
*
|
677
|
+
* If a string starts with `.`, it will allow that hostname without the `.` and all subdomains under the hostname.
|
678
|
+
* For example, `.example.com` will allow `example.com`, `foo.example.com`, and `foo.bar.example.com`.
|
679
|
+
*
|
680
|
+
* If set to `true`, the server is allowed to respond to requests for any hosts.
|
681
|
+
* This is not recommended as it will be vulnerable to DNS rebinding attacks.
|
682
|
+
*/
|
683
|
+
allowedHosts?: string[] | true;
|
672
684
|
/**
|
673
685
|
* Enable TLS + HTTP/2.
|
674
686
|
* Note: this downgrades to TLS only when the proxy option is also used.
|
@@ -704,8 +716,14 @@ interface CommonServerOptions {
|
|
704
716
|
/**
|
705
717
|
* Configure CORS for the dev server.
|
706
718
|
* Uses https://github.com/expressjs/cors.
|
719
|
+
*
|
720
|
+
* When enabling this option, **we recommend setting a specific value
|
721
|
+
* rather than `true`** to avoid exposing the source code to untrusted origins.
|
722
|
+
*
|
707
723
|
* Set to `true` to allow all methods from any origin, or configure separately
|
708
724
|
* using an object.
|
725
|
+
*
|
726
|
+
* @default false
|
709
727
|
*/
|
710
728
|
cors?: CorsOptions | boolean;
|
711
729
|
/**
|
@@ -717,6 +735,12 @@ interface CommonServerOptions {
|
|
717
735
|
* https://github.com/expressjs/cors#configuration-options
|
718
736
|
*/
|
719
737
|
interface CorsOptions {
|
738
|
+
/**
|
739
|
+
* Configures the Access-Control-Allow-Origin CORS header.
|
740
|
+
*
|
741
|
+
* **We recommend setting a specific value rather than
|
742
|
+
* `true`** to avoid exposing the source code to untrusted origins.
|
743
|
+
*/
|
720
744
|
origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
721
745
|
methods?: string | string[];
|
722
746
|
allowedHeaders?: string | string[];
|
@@ -3402,6 +3426,18 @@ interface LegacyOptions {
|
|
3402
3426
|
* https://github.com/vitejs/vite/discussions/14697.
|
3403
3427
|
*/
|
3404
3428
|
proxySsrExternalModules?: boolean;
|
3429
|
+
/**
|
3430
|
+
* In Vite 6.0.8 / 5.4.11 and below, WebSocket server was able to connect from any web pages. However,
|
3431
|
+
* that could be exploited by a malicious web page.
|
3432
|
+
*
|
3433
|
+
* In Vite 6.0.9+ / 5.4.12+, the WebSocket server now requires a token to connect from a web page.
|
3434
|
+
* But this may break some plugins and frameworks that connects to the WebSocket server
|
3435
|
+
* on their own. Enabling this option will make Vite skip the token check.
|
3436
|
+
*
|
3437
|
+
* **We do not recommend enabling this option unless you are sure that you are fine with
|
3438
|
+
* that security weakness.**
|
3439
|
+
*/
|
3440
|
+
skipWebSocketTokenCheck?: boolean;
|
3405
3441
|
}
|
3406
3442
|
interface ResolvedWorkerOptions {
|
3407
3443
|
format: 'es' | 'iife';
|
@@ -3443,6 +3479,17 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
|
|
3443
3479
|
worker: ResolvedWorkerOptions;
|
3444
3480
|
appType: AppType;
|
3445
3481
|
experimental: ExperimentalOptions;
|
3482
|
+
/**
|
3483
|
+
* The token to connect to the WebSocket server from browsers.
|
3484
|
+
*
|
3485
|
+
* We recommend using `import.meta.hot` rather than connecting
|
3486
|
+
* to the WebSocket server directly.
|
3487
|
+
* If you have a usecase that requires connecting to the WebSocket
|
3488
|
+
* server, please create an issue so that we can discuss.
|
3489
|
+
*
|
3490
|
+
* @deprecated
|
3491
|
+
*/
|
3492
|
+
webSocketToken: string;
|
3446
3493
|
} & PluginHookUtils>;
|
3447
3494
|
interface PluginHookUtils {
|
3448
3495
|
getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules, a as arraify } from './chunks/dep-
|
3
|
-
export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-CjorC8P2.js';
|
3
|
+
export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-CjorC8P2.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import { existsSync, readFileSync } from 'node:fs';
|
@@ -11,6 +11,7 @@ import 'node:url';
|
|
11
11
|
import 'node:util';
|
12
12
|
import 'node:perf_hooks';
|
13
13
|
import 'node:module';
|
14
|
+
import 'node:crypto';
|
14
15
|
import 'tty';
|
15
16
|
import 'path';
|
16
17
|
import 'fs';
|
@@ -29,7 +30,6 @@ import 'stream';
|
|
29
30
|
import 'os';
|
30
31
|
import 'child_process';
|
31
32
|
import 'node:os';
|
32
|
-
import 'node:crypto';
|
33
33
|
import 'node:dns';
|
34
34
|
import 'crypto';
|
35
35
|
import 'module';
|
@@ -43,6 +43,7 @@ import 'zlib';
|
|
43
43
|
import 'buffer';
|
44
44
|
import 'https';
|
45
45
|
import 'tls';
|
46
|
+
import 'node:net';
|
46
47
|
import 'assert';
|
47
48
|
import 'node:zlib';
|
48
49
|
|