full site update
This commit is contained in:
40
node_modules/astro/dist/core/util.js
generated
vendored
40
node_modules/astro/dist/core/util.js
generated
vendored
@@ -1,8 +1,9 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { hasSpecialQueries } from "../vite-plugin-utils/index.js";
|
||||
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./constants.js";
|
||||
import { removeTrailingForwardSlash, slash } from "./path.js";
|
||||
import { removeQueryString, removeTrailingForwardSlash, slash } from "./path.js";
|
||||
function isObject(value) {
|
||||
return typeof value === "object" && value != null;
|
||||
}
|
||||
@@ -10,9 +11,13 @@ function isURL(value) {
|
||||
return Object.prototype.toString.call(value) === "[object URL]";
|
||||
}
|
||||
function isMarkdownFile(fileId, option) {
|
||||
if (hasSpecialQueries(fileId)) {
|
||||
return false;
|
||||
}
|
||||
const id = removeQueryString(fileId);
|
||||
const _suffix = option?.suffix ?? "";
|
||||
for (let markdownFileExtension of SUPPORTED_MARKDOWN_FILE_EXTENSIONS) {
|
||||
if (fileId.endsWith(`${markdownFileExtension}${_suffix}`)) return true;
|
||||
if (id.endsWith(`${markdownFileExtension}${_suffix}`)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -25,8 +30,8 @@ function padMultilineString(source, n = 2) {
|
||||
`);
|
||||
}
|
||||
const STATUS_CODE_PAGES = /* @__PURE__ */ new Set(["/404", "/500"]);
|
||||
function getOutputFilename(astroConfig, name, type) {
|
||||
if (type === "endpoint") {
|
||||
function getOutputFilename(astroConfig, name, routeData) {
|
||||
if (routeData.type === "endpoint") {
|
||||
return name;
|
||||
}
|
||||
if (name === "/" || name === "") {
|
||||
@@ -35,6 +40,9 @@ function getOutputFilename(astroConfig, name, type) {
|
||||
if (astroConfig.build.format === "file" || STATUS_CODE_PAGES.has(name)) {
|
||||
return `${removeTrailingForwardSlash(name || "index")}.html`;
|
||||
}
|
||||
if (astroConfig.build.format === "preserve" && !routeData.isIndex) {
|
||||
return `${removeTrailingForwardSlash(name || "index")}.html`;
|
||||
}
|
||||
return path.posix.join(name, "index.html");
|
||||
}
|
||||
function parseNpmName(spec) {
|
||||
@@ -59,9 +67,13 @@ function viteID(filePath) {
|
||||
}
|
||||
const VALID_ID_PREFIX = `/@id/`;
|
||||
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
||||
const NULL_BYTE_REGEX = /^\0/;
|
||||
function unwrapId(id) {
|
||||
return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, "\0") : id;
|
||||
}
|
||||
function wrapId(id) {
|
||||
return id.replace(NULL_BYTE_REGEX, `${VALID_ID_PREFIX}${NULL_BYTE_PLACEHOLDER}`);
|
||||
}
|
||||
function resolvePages(config) {
|
||||
return new URL("./pages", config.srcDir);
|
||||
}
|
||||
@@ -72,7 +84,8 @@ function isInPagesDir(file, config) {
|
||||
function isInjectedRoute(file, settings) {
|
||||
let fileURL = file.toString();
|
||||
for (const route of settings.resolvedInjectedRoutes) {
|
||||
if (route.resolvedEntryPoint && fileURL === route.resolvedEntryPoint.toString()) return true;
|
||||
if (route.resolvedEntryPoint && removeQueryString(fileURL) === removeQueryString(route.resolvedEntryPoint.toString()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -103,16 +116,6 @@ function isEndpoint(file, settings) {
|
||||
if (!isPublicRoute(file, settings.config)) return false;
|
||||
return !endsWithPageExt(file, settings) && !file.toString().includes("?astro");
|
||||
}
|
||||
function isServerLikeOutput(config) {
|
||||
return config.output === "server" || config.output === "hybrid";
|
||||
}
|
||||
function isModeServerWithNoAdapter(settings) {
|
||||
return isServerLikeOutput(settings.config) && !settings.adapter;
|
||||
}
|
||||
function isContentCollectionsCacheEnabled(config) {
|
||||
return config.experimental.contentCollectionCache && // contentCollectionsCache is an SSG only feature
|
||||
!isServerLikeOutput(config);
|
||||
}
|
||||
function resolveJsToTs(filePath) {
|
||||
if (filePath.endsWith(".jsx") && !fs.existsSync(filePath)) {
|
||||
const tryPath = filePath.slice(0, -4) + ".tsx";
|
||||
@@ -128,23 +131,20 @@ function ensureProcessNodeEnv(defaultNodeEnv) {
|
||||
}
|
||||
}
|
||||
export {
|
||||
NULL_BYTE_PLACEHOLDER,
|
||||
VALID_ID_PREFIX,
|
||||
arraify,
|
||||
ensureProcessNodeEnv,
|
||||
getOutputFilename,
|
||||
isContentCollectionsCacheEnabled,
|
||||
isEndpoint,
|
||||
isMarkdownFile,
|
||||
isModeServerWithNoAdapter,
|
||||
isObject,
|
||||
isPage,
|
||||
isServerLikeOutput,
|
||||
isURL,
|
||||
padMultilineString,
|
||||
parseNpmName,
|
||||
resolveJsToTs,
|
||||
resolvePages,
|
||||
unwrapId,
|
||||
viteID
|
||||
viteID,
|
||||
wrapId
|
||||
};
|
||||
|
Reference in New Issue
Block a user