vite 6.2.6 → 6.2.7
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/node/chunks/{dep-CEj2138F.js → dep-CtglLrfJ.js} +1 -1
- package/dist/node/chunks/{dep-BXMtZB7a.js → dep-Cyy1mE-y.js} +1 -1
- package/dist/node/chunks/{dep-Bid9ssRr.js → dep-DbCvTk3B.js} +80 -32
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +1 -3
- package/dist/node/index.js +2 -2
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-DbCvTk3B.js';
|
2
2
|
import require$$0$2 from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -40977,8 +40977,11 @@ function sirv (dir, opts={}) {
|
|
40977
40977
|
}
|
40978
40978
|
|
40979
40979
|
const knownJavascriptExtensionRE = /\.(?:[tj]sx?|[cm][tj]s)$/;
|
40980
|
+
const ERR_DENIED_FILE = "ERR_DENIED_FILE";
|
40980
40981
|
const sirvOptions = ({
|
40981
|
-
|
40982
|
+
config,
|
40983
|
+
getHeaders,
|
40984
|
+
disableFsServeCheck
|
40982
40985
|
}) => {
|
40983
40986
|
return {
|
40984
40987
|
dev: true,
|
@@ -40994,6 +40997,19 @@ const sirvOptions = ({
|
|
40994
40997
|
res.setHeader(name, headers[name]);
|
40995
40998
|
}
|
40996
40999
|
}
|
41000
|
+
},
|
41001
|
+
shouldServe: disableFsServeCheck ? void 0 : (filePath) => {
|
41002
|
+
const servingAccessResult = checkLoadingAccess(config, filePath);
|
41003
|
+
if (servingAccessResult === "denied") {
|
41004
|
+
const error = new Error("denied access");
|
41005
|
+
error.code = ERR_DENIED_FILE;
|
41006
|
+
error.path = filePath;
|
41007
|
+
throw error;
|
41008
|
+
}
|
41009
|
+
if (servingAccessResult === "fallback") {
|
41010
|
+
return false;
|
41011
|
+
}
|
41012
|
+
return true;
|
40997
41013
|
}
|
40998
41014
|
};
|
40999
41015
|
};
|
@@ -41002,7 +41018,9 @@ function servePublicMiddleware(server, publicFiles) {
|
|
41002
41018
|
const serve = sirv(
|
41003
41019
|
dir,
|
41004
41020
|
sirvOptions({
|
41005
|
-
|
41021
|
+
config: server.config,
|
41022
|
+
getHeaders: () => server.config.server.headers,
|
41023
|
+
disableFsServeCheck: true
|
41006
41024
|
})
|
41007
41025
|
);
|
41008
41026
|
const toFilePath = (url) => {
|
@@ -41028,6 +41046,7 @@ function serveStaticMiddleware(server) {
|
|
41028
41046
|
const serve = sirv(
|
41029
41047
|
dir,
|
41030
41048
|
sirvOptions({
|
41049
|
+
config: server.config,
|
41031
41050
|
getHeaders: () => server.config.server.headers
|
41032
41051
|
})
|
41033
41052
|
);
|
@@ -41058,38 +41077,46 @@ function serveStaticMiddleware(server) {
|
|
41058
41077
|
if (resolvedPathname.endsWith("/") && fileUrl[fileUrl.length - 1] !== "/") {
|
41059
41078
|
fileUrl = withTrailingSlash(fileUrl);
|
41060
41079
|
}
|
41061
|
-
if (!ensureServingAccess(fileUrl, server, res, next)) {
|
41062
|
-
return;
|
41063
|
-
}
|
41064
41080
|
if (redirectedPathname) {
|
41065
41081
|
url.pathname = encodeURI(redirectedPathname);
|
41066
41082
|
req.url = url.href.slice(url.origin.length);
|
41067
41083
|
}
|
41068
|
-
|
41084
|
+
try {
|
41085
|
+
serve(req, res, next);
|
41086
|
+
} catch (e) {
|
41087
|
+
if (e && "code" in e && e.code === ERR_DENIED_FILE) {
|
41088
|
+
respondWithAccessDenied(e.path, server, res);
|
41089
|
+
return;
|
41090
|
+
}
|
41091
|
+
throw e;
|
41092
|
+
}
|
41069
41093
|
};
|
41070
41094
|
}
|
41071
41095
|
function serveRawFsMiddleware(server) {
|
41072
41096
|
const serveFromRoot = sirv(
|
41073
41097
|
"/",
|
41074
|
-
sirvOptions({
|
41098
|
+
sirvOptions({
|
41099
|
+
config: server.config,
|
41100
|
+
getHeaders: () => server.config.server.headers
|
41101
|
+
})
|
41075
41102
|
);
|
41076
41103
|
return function viteServeRawFsMiddleware(req, res, next) {
|
41077
41104
|
if (req.url.startsWith(FS_PREFIX)) {
|
41078
41105
|
const url = new URL(req.url, "http://example.com");
|
41079
41106
|
const pathname = decodeURI(url.pathname);
|
41080
|
-
if (!ensureServingAccess(
|
41081
|
-
slash$1(path$d.resolve(fsPathFromId(pathname))),
|
41082
|
-
server,
|
41083
|
-
res,
|
41084
|
-
next
|
41085
|
-
)) {
|
41086
|
-
return;
|
41087
|
-
}
|
41088
41107
|
let newPathname = pathname.slice(FS_PREFIX.length);
|
41089
41108
|
if (isWindows$3) newPathname = newPathname.replace(/^[A-Z]:/i, "");
|
41090
41109
|
url.pathname = encodeURI(newPathname);
|
41091
41110
|
req.url = url.href.slice(url.origin.length);
|
41092
|
-
|
41111
|
+
try {
|
41112
|
+
serveFromRoot(req, res, next);
|
41113
|
+
} catch (e) {
|
41114
|
+
if (e && "code" in e && e.code === ERR_DENIED_FILE) {
|
41115
|
+
respondWithAccessDenied(e.path, server, res);
|
41116
|
+
return;
|
41117
|
+
}
|
41118
|
+
throw e;
|
41119
|
+
}
|
41093
41120
|
} else {
|
41094
41121
|
next();
|
41095
41122
|
}
|
@@ -41113,25 +41140,35 @@ function isFileLoadingAllowed(config, filePath) {
|
|
41113
41140
|
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
|
41114
41141
|
return false;
|
41115
41142
|
}
|
41116
|
-
function
|
41143
|
+
function checkLoadingAccess(config, path2) {
|
41144
|
+
if (isFileLoadingAllowed(config, slash$1(path2))) {
|
41145
|
+
return "allowed";
|
41146
|
+
}
|
41147
|
+
if (isFileReadable(path2)) {
|
41148
|
+
return "denied";
|
41149
|
+
}
|
41150
|
+
return "fallback";
|
41151
|
+
}
|
41152
|
+
function checkServingAccess(url, server) {
|
41117
41153
|
if (isFileServingAllowed(url, server)) {
|
41118
|
-
return
|
41154
|
+
return "allowed";
|
41119
41155
|
}
|
41120
41156
|
if (isFileReadable(cleanUrl(url))) {
|
41121
|
-
|
41122
|
-
|
41157
|
+
return "denied";
|
41158
|
+
}
|
41159
|
+
return "fallback";
|
41160
|
+
}
|
41161
|
+
function respondWithAccessDenied(url, server, res) {
|
41162
|
+
const urlMessage = `The request url "${url}" is outside of Vite serving allow list.`;
|
41163
|
+
const hintMessage = `
|
41123
41164
|
${server.config.server.fs.allow.map((i) => `- ${i}`).join("\n")}
|
41124
41165
|
|
41125
41166
|
Refer to docs https://vite.dev/config/server-options.html#server-fs-allow for configurations and more details.`;
|
41126
|
-
|
41127
|
-
|
41128
|
-
|
41129
|
-
|
41130
|
-
|
41131
|
-
} else {
|
41132
|
-
next();
|
41133
|
-
}
|
41134
|
-
return false;
|
41167
|
+
server.config.logger.error(urlMessage);
|
41168
|
+
server.config.logger.warnOnce(hintMessage + "\n");
|
41169
|
+
res.statusCode = 403;
|
41170
|
+
res.write(renderRestrictedErrorHTML(urlMessage + "\n" + hintMessage));
|
41171
|
+
res.end();
|
41135
41172
|
}
|
41136
41173
|
function renderRestrictedErrorHTML(msg) {
|
41137
41174
|
const html = String.raw;
|
@@ -42691,7 +42728,18 @@ const rawRE = /[?&]raw\b/;
|
|
42691
42728
|
const inlineRE$2 = /[?&]inline\b/;
|
42692
42729
|
const svgRE = /\.svg\b/;
|
42693
42730
|
function deniedServingAccessForTransform(url, server, res, next) {
|
42694
|
-
|
42731
|
+
if (rawRE.test(url) || urlRE.test(url) || inlineRE$2.test(url) || svgRE.test(url)) {
|
42732
|
+
const servingAccessResult = checkServingAccess(url, server);
|
42733
|
+
if (servingAccessResult === "denied") {
|
42734
|
+
respondWithAccessDenied(url, server, res);
|
42735
|
+
return true;
|
42736
|
+
}
|
42737
|
+
if (servingAccessResult === "fallback") {
|
42738
|
+
next();
|
42739
|
+
return true;
|
42740
|
+
}
|
42741
|
+
}
|
42742
|
+
return false;
|
42695
42743
|
}
|
42696
42744
|
function cachedTransformMiddleware(server) {
|
42697
42745
|
return function viteCachedTransformMiddleware(req, res, next) {
|
@@ -49273,8 +49321,8 @@ function createCachedImport(imp) {
|
|
49273
49321
|
return cached;
|
49274
49322
|
};
|
49275
49323
|
}
|
49276
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
49277
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
49324
|
+
const importPostcssImport = createCachedImport(() => import('./dep-Cyy1mE-y.js').then(function (n) { return n.i; }));
|
49325
|
+
const importPostcssModules = createCachedImport(() => import('./dep-CtglLrfJ.js').then(function (n) { return n.i; }));
|
49278
49326
|
const importPostcss = createCachedImport(() => import('postcss'));
|
49279
49327
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
49280
49328
|
let alwaysFakeWorkerWorkerControllerCache;
|
package/dist/node/cli.js
CHANGED
@@ -2,7 +2,7 @@ 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 { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-DbCvTk3B.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -745,7 +745,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
745
745
|
`[boolean] force the optimizer to ignore the cache and re-bundle`
|
746
746
|
).action(async (root, options) => {
|
747
747
|
filterDuplicateOptions(options);
|
748
|
-
const { createServer } = await import('./chunks/dep-
|
748
|
+
const { createServer } = await import('./chunks/dep-DbCvTk3B.js').then(function (n) { return n.S; });
|
749
749
|
try {
|
750
750
|
const server = await createServer({
|
751
751
|
root,
|
@@ -840,7 +840,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
840
840
|
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
|
841
841
|
async (root, options) => {
|
842
842
|
filterDuplicateOptions(options);
|
843
|
-
const { createBuilder } = await import('./chunks/dep-
|
843
|
+
const { createBuilder } = await import('./chunks/dep-DbCvTk3B.js').then(function (n) { return n.T; });
|
844
844
|
const buildOptions = cleanGlobalCLIOptions(
|
845
845
|
cleanBuilderCLIOptions(options)
|
846
846
|
);
|
@@ -879,7 +879,7 @@ cli.command(
|
|
879
879
|
).action(
|
880
880
|
async (root, options) => {
|
881
881
|
filterDuplicateOptions(options);
|
882
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
882
|
+
const { optimizeDeps } = await import('./chunks/dep-DbCvTk3B.js').then(function (n) { return n.R; });
|
883
883
|
try {
|
884
884
|
const config = await resolveConfig(
|
885
885
|
{
|
@@ -906,7 +906,7 @@ ${e.stack}`),
|
|
906
906
|
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(
|
907
907
|
async (root, options) => {
|
908
908
|
filterDuplicateOptions(options);
|
909
|
-
const { preview } = await import('./chunks/dep-
|
909
|
+
const { preview } = await import('./chunks/dep-DbCvTk3B.js').then(function (n) { return n.U; });
|
910
910
|
try {
|
911
911
|
const server = await preview({
|
912
912
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -4167,11 +4167,9 @@ declare function searchForWorkspaceRoot(current: string, root?: string): string;
|
|
4167
4167
|
|
4168
4168
|
/**
|
4169
4169
|
* Check if the url is allowed to be served, via the `server.fs` config.
|
4170
|
+
* @deprecated Use the `isFileLoadingAllowed` function instead.
|
4170
4171
|
*/
|
4171
4172
|
declare function isFileServingAllowed(config: ResolvedConfig, url: string): boolean;
|
4172
|
-
/**
|
4173
|
-
* @deprecated Use the `isFileServingAllowed(config, url)` signature instead.
|
4174
|
-
*/
|
4175
4173
|
declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
|
4176
4174
|
declare function isFileLoadingAllowed(config: ResolvedConfig, filePath: string): boolean;
|
4177
4175
|
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { a as arraify, i as isInNodeModules } from './chunks/dep-
|
3
|
-
export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { a as arraify, i as isInNodeModules } from './chunks/dep-DbCvTk3B.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-DbCvTk3B.js';
|
4
4
|
export { defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import 'node:fs';
|