Area restrita - Questionario
This commit is contained in:
+41
-70
@@ -6212,21 +6212,6 @@ const buildEsbuildPlugin = () => {
|
||||
}
|
||||
};
|
||||
};
|
||||
const destructuringBugRE = /^(safari|ios)(\d+)(?:\.(\d+))?$/;
|
||||
function needsDestructuringSupportedWorkaround(target) {
|
||||
if (!target) return false;
|
||||
const targets = Array.isArray(target) ? target : [target];
|
||||
for (const t$1 of targets) {
|
||||
const match = destructuringBugRE.exec(t$1);
|
||||
if (!match) continue;
|
||||
const major = Number(match[2]);
|
||||
if (major < 10) continue;
|
||||
if (major < 14) return true;
|
||||
if (major > 14) continue;
|
||||
if ((match[3] ? Number(match[3]) : 0) < (match[1] === "safari" ? 1 : 5)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function resolveEsbuildTranspileOptions(config$2, format$3) {
|
||||
const target = config$2.build.target;
|
||||
const minify = config$2.build.minify === "esbuild";
|
||||
@@ -6240,7 +6225,6 @@ function resolveEsbuildTranspileOptions(config$2, format$3) {
|
||||
format: rollupToEsbuildFormatMap[format$3],
|
||||
supported: {
|
||||
...defaultEsbuildSupported,
|
||||
...needsDestructuringSupportedWorkaround(target) ? { destructuring: true } : null,
|
||||
...esbuildOptions.supported
|
||||
}
|
||||
};
|
||||
@@ -8934,8 +8918,7 @@ function optimizedDepsPlugin() {
|
||||
if (this.environment.depsOptimizer?.isOptimizedDepFile(id)) return id;
|
||||
},
|
||||
async load(id) {
|
||||
const environment = this.environment;
|
||||
const depsOptimizer = environment.depsOptimizer;
|
||||
const depsOptimizer = this.environment.depsOptimizer;
|
||||
if (depsOptimizer?.isOptimizedDepFile(id)) {
|
||||
const metadata = depsOptimizer.metadata;
|
||||
const file = cleanUrl(id);
|
||||
@@ -8943,7 +8926,7 @@ function optimizedDepsPlugin() {
|
||||
const browserHash = versionMatch ? versionMatch[1].split("=")[1] : void 0;
|
||||
const info = optimizedDepInfoFromFile(metadata, file);
|
||||
if (info) {
|
||||
if (browserHash && info.browserHash !== browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
||||
if (browserHash && info.browserHash !== browserHash) throwOutdatedRequest(id);
|
||||
try {
|
||||
await info.processing;
|
||||
} catch {
|
||||
@@ -8952,14 +8935,14 @@ function optimizedDepsPlugin() {
|
||||
const newMetadata = depsOptimizer.metadata;
|
||||
if (metadata !== newMetadata) {
|
||||
const currentInfo = optimizedDepInfoFromFile(newMetadata, file);
|
||||
if (info.browserHash !== currentInfo?.browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
||||
if (info.browserHash !== currentInfo?.browserHash) throwOutdatedRequest(id);
|
||||
}
|
||||
}
|
||||
debug$15?.(`load ${import_picocolors$29.default.cyan(file)}`);
|
||||
try {
|
||||
return await fsp.readFile(file, "utf-8");
|
||||
} catch {
|
||||
if (browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
||||
if (browserHash) throwOutdatedRequest(id);
|
||||
throwFileNotFoundInOptimizedDep(id);
|
||||
}
|
||||
}
|
||||
@@ -22568,7 +22551,7 @@ const ERR_DENIED_ID = "ERR_DENIED_ID";
|
||||
const debugLoad = createDebugger("vite:load");
|
||||
const debugTransform = createDebugger("vite:transform");
|
||||
const debugCache$1 = createDebugger("vite:cache");
|
||||
function transformRequest(environment, url$3, options$1) {
|
||||
function transformRequest(environment, url$3, options$1 = {}) {
|
||||
if (environment._closing && environment.config.dev.recoverable) throwClosedServerError();
|
||||
const timestamp = monotonicDateNow();
|
||||
url$3 = removeTimestampQuery(url$3);
|
||||
@@ -22632,7 +22615,7 @@ async function loadAndTransform(environment, id, url$3, options$1, timestamp, mo
|
||||
const { config: config$2, pluginContainer, logger } = environment;
|
||||
const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url$3, config$2.root) : "";
|
||||
const moduleGraph = environment.moduleGraph;
|
||||
if (!options$1.skipFsCheck && id[0] !== "\0" && isServerAccessDeniedForTransform(config$2, id)) {
|
||||
if (options$1.allowId && !options$1.allowId(id)) {
|
||||
const err$2 = /* @__PURE__ */ new Error(`Denied ID ${id}`);
|
||||
err$2.code = ERR_DENIED_ID;
|
||||
err$2.id = id;
|
||||
@@ -22644,7 +22627,7 @@ async function loadAndTransform(environment, id, url$3, options$1, timestamp, mo
|
||||
const loadResult = await pluginContainer.load(id);
|
||||
if (loadResult == null) {
|
||||
const file = cleanUrl(id);
|
||||
if (options$1.skipFsCheck || isFileLoadingAllowed(environment.getTopLevelConfig(), slash(file))) {
|
||||
if (environment.config.consumer === "server" || isFileLoadingAllowed(environment.getTopLevelConfig(), slash(file))) {
|
||||
try {
|
||||
code = await fsp.readFile(file, "utf-8");
|
||||
debugLoad?.(`${timeFrom(loadStart)} [fs] ${prettyUrl}`);
|
||||
@@ -24470,7 +24453,7 @@ const rawRE$1 = /[?&]raw\b/;
|
||||
const inlineRE$2 = /[?&]inline\b/;
|
||||
const svgRE = /\.svg\b/;
|
||||
function isServerAccessDeniedForTransform(config$2, id) {
|
||||
if (rawRE$1.test(id) || urlRE$1.test(id) || inlineRE$2.test(id) || svgRE.test(id)) return checkLoadingAccess(config$2, cleanUrl(id)) !== "allowed" || checkLoadingAccess(config$2, id) !== "allowed";
|
||||
if (rawRE$1.test(id) || urlRE$1.test(id) || inlineRE$2.test(id) || svgRE.test(id)) return checkLoadingAccess(config$2, id) !== "allowed";
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
@@ -24516,35 +24499,31 @@ function transformMiddleware(server) {
|
||||
}
|
||||
const withoutQuery = cleanUrl(url$3);
|
||||
try {
|
||||
if (withoutQuery.endsWith(".map")) {
|
||||
const depsOptimizer = environment.depsOptimizer;
|
||||
if (depsOptimizer?.isOptimizedDepUrl(url$3)) {
|
||||
const sourcemapPath = url$3.startsWith(FS_PREFIX) ? fsPathFromId(url$3) : normalizePath(path.resolve(server.config.root, url$3.slice(1)));
|
||||
if (!depsOptimizer.isOptimizedDepFile(sourcemapPath)) return next();
|
||||
try {
|
||||
const map$1 = JSON.parse(await fsp.readFile(sourcemapPath, "utf-8"));
|
||||
applySourcemapIgnoreList(map$1, sourcemapPath, server.config.server.sourcemapIgnoreList, server.config.logger);
|
||||
return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
|
||||
} catch {
|
||||
const dummySourceMap = {
|
||||
version: 3,
|
||||
file: sourcemapPath.replace(/\.map$/, ""),
|
||||
sources: [],
|
||||
sourcesContent: [],
|
||||
names: [],
|
||||
mappings: ";;;;;;;;;"
|
||||
};
|
||||
return send(req$4, res, JSON.stringify(dummySourceMap), "json", {
|
||||
cacheControl: "no-cache",
|
||||
headers: server.config.server.headers
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const originalUrl = url$3.replace(/\.map($|\?)/, "$1");
|
||||
const map$1 = (await environment.moduleGraph.getModuleByUrl(originalUrl))?.transformResult?.map;
|
||||
if (map$1) return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
|
||||
else return next();
|
||||
if (withoutQuery.endsWith(".map")) if (environment.depsOptimizer?.isOptimizedDepUrl(url$3)) {
|
||||
const sourcemapPath = url$3.startsWith(FS_PREFIX) ? fsPathFromId(url$3) : normalizePath(path.resolve(server.config.root, url$3.slice(1)));
|
||||
try {
|
||||
const map$1 = JSON.parse(await fsp.readFile(sourcemapPath, "utf-8"));
|
||||
applySourcemapIgnoreList(map$1, sourcemapPath, server.config.server.sourcemapIgnoreList, server.config.logger);
|
||||
return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
|
||||
} catch {
|
||||
const dummySourceMap = {
|
||||
version: 3,
|
||||
file: sourcemapPath.replace(/\.map$/, ""),
|
||||
sources: [],
|
||||
sourcesContent: [],
|
||||
names: [],
|
||||
mappings: ";;;;;;;;;"
|
||||
};
|
||||
return send(req$4, res, JSON.stringify(dummySourceMap), "json", {
|
||||
cacheControl: "no-cache",
|
||||
headers: server.config.server.headers
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const originalUrl = url$3.replace(/\.map($|\?)/, "$1");
|
||||
const map$1 = (await environment.moduleGraph.getModuleByUrl(originalUrl))?.transformResult?.map;
|
||||
if (map$1) return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
|
||||
else return next();
|
||||
}
|
||||
if (publicDirInRoot && url$3.startsWith(publicPath)) warnAboutExplicitPublicPathInUrl(url$3);
|
||||
if (req$4.headers["sec-fetch-dest"] === "script" || isJSRequest(url$3) || isImportRequest(url$3) || isCSSRequest(url$3) || isHTMLProxy(url$3)) {
|
||||
@@ -24559,7 +24538,9 @@ function transformMiddleware(server) {
|
||||
return res.end();
|
||||
}
|
||||
}
|
||||
const result = await environment.transformRequest(url$3);
|
||||
const result = await environment.transformRequest(url$3, { allowId(id) {
|
||||
return id[0] === "\0" || !isServerAccessDeniedForTransform(server.config, id);
|
||||
} });
|
||||
if (result) {
|
||||
const depsOptimizer = environment.depsOptimizer;
|
||||
const type = isDirectCSSRequest(url$3) ? "css" : "js";
|
||||
@@ -24609,8 +24590,7 @@ function transformMiddleware(server) {
|
||||
if (e$1?.code === ERR_LOAD_URL) return next();
|
||||
if (e$1?.code === ERR_DENIED_ID) {
|
||||
const id = e$1.id;
|
||||
let servingAccessResult = checkLoadingAccess(server.config, cleanUrl(id));
|
||||
if (servingAccessResult === "allowed") servingAccessResult = checkLoadingAccess(server.config, id);
|
||||
const servingAccessResult = checkLoadingAccess(server.config, id);
|
||||
if (servingAccessResult === "denied") {
|
||||
respondWithAccessDenied(id, server, res);
|
||||
return true;
|
||||
@@ -26345,7 +26325,6 @@ function createServerHotChannel() {
|
||||
const innerEmitter = new EventEmitter();
|
||||
const outsideEmitter = new EventEmitter();
|
||||
return {
|
||||
skipFsCheck: true,
|
||||
send(payload) {
|
||||
outsideEmitter.emit("send", payload);
|
||||
},
|
||||
@@ -34761,10 +34740,6 @@ var DevEnvironment = class extends BaseEnvironment {
|
||||
* @internal
|
||||
*/
|
||||
_remoteRunnerOptions;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_skipFsCheck;
|
||||
get pluginContainer() {
|
||||
if (!this._pluginContainer) throw new Error(`${this.name} environment.pluginContainer called before initialized`);
|
||||
return this._pluginContainer;
|
||||
@@ -34802,11 +34777,9 @@ var DevEnvironment = class extends BaseEnvironment {
|
||||
this.moduleGraph = new EnvironmentModuleGraph(name, (url$3) => this.pluginContainer.resolveId(url$3, void 0));
|
||||
this._crawlEndFinder = setupOnCrawlEnd();
|
||||
this._remoteRunnerOptions = context.remoteRunner ?? {};
|
||||
this._skipFsCheck = !!(context.transport && !(isWebSocketServer in context.transport) && context.transport.skipFsCheck);
|
||||
this.hot = context.transport ? isWebSocketServer in context.transport ? context.transport : normalizeHotChannel(context.transport, context.hot) : normalizeHotChannel({}, context.hot);
|
||||
this.hot.setInvokeHandler({
|
||||
fetchModule: (id, importer, options$2) => {
|
||||
if (context.disableFetchModule) throw new Error("fetchModule is disabled in this environment");
|
||||
return this.fetchModule(id, importer, options$2);
|
||||
},
|
||||
getBuiltins: async () => {
|
||||
@@ -34857,12 +34830,12 @@ var DevEnvironment = class extends BaseEnvironment {
|
||||
async reloadModule(module$1) {
|
||||
if (this.config.server.hmr !== false && module$1.file) updateModules(this, module$1.file, [module$1], monotonicDateNow());
|
||||
}
|
||||
transformRequest(url$3) {
|
||||
return transformRequest(this, url$3, { skipFsCheck: this._skipFsCheck });
|
||||
transformRequest(url$3, options$1) {
|
||||
return transformRequest(this, url$3, options$1);
|
||||
}
|
||||
async warmupRequest(url$3) {
|
||||
try {
|
||||
await transformRequest(this, url$3, { skipFsCheck: true });
|
||||
await this.transformRequest(url$3);
|
||||
} catch (e$1) {
|
||||
if (e$1?.code === ERR_OUTDATED_OPTIMIZED_DEP || e$1?.code === ERR_CLOSED_SERVER) return;
|
||||
this.logger.error(buildErrorMessage(e$1, [`Pre-transform error: ${e$1.message}`], false), {
|
||||
@@ -35244,8 +35217,7 @@ function defineConfig(config$2) {
|
||||
function defaultCreateClientDevEnvironment(name, config$2, context) {
|
||||
return new DevEnvironment(name, config$2, {
|
||||
hot: true,
|
||||
transport: context.ws,
|
||||
disableFetchModule: true
|
||||
transport: context.ws
|
||||
});
|
||||
}
|
||||
function defaultCreateDevEnvironment(name, config$2) {
|
||||
@@ -35312,8 +35284,7 @@ const configDefaults = Object.freeze({
|
||||
extensions: [],
|
||||
disabled: "build",
|
||||
holdUntilCrawlEnd: true,
|
||||
force: false,
|
||||
ignoreOutdatedRequests: false
|
||||
force: false
|
||||
},
|
||||
ssr: ssrConfigDefaults,
|
||||
environments: {},
|
||||
|
||||
Reference in New Issue
Block a user