blank project

This commit is contained in:
root
2025-10-17 20:17:33 +00:00
commit 14b2d53e8e
9366 changed files with 1515019 additions and 0 deletions

15
node_modules/@astrojs/internal-helpers/dist/fs.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import type { PathLike } from 'node:fs';
export declare function writeJson<T>(path: PathLike, data: T): Promise<void>;
export declare function removeDir(dir: PathLike): Promise<void>;
export declare function emptyDir(dir: PathLike): Promise<void>;
export declare function getFilesFromFolder(dir: URL): Promise<URL[]>;
/**
* Copies files into a folder keeping the folder structure intact.
* The resulting file tree will start at the common ancestor.
*
* @param {URL[]} files A list of files to copy (absolute path).
* @param {URL} outDir Destination folder where to copy the files to (absolute path).
* @param {URL[]} [exclude] A list of files to exclude (absolute path).
* @returns {Promise<string>} The common ancestor of the copied files.
*/
export declare function copyFilesToFolder(files: URL[], outDir: URL, exclude?: URL[]): Promise<string>;

66
node_modules/@astrojs/internal-helpers/dist/fs.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
import { existsSync } from "node:fs";
import * as fs from "node:fs/promises";
import nodePath from "node:path";
import { fileURLToPath } from "node:url";
async function writeJson(path, data) {
await fs.writeFile(path, JSON.stringify(data, null, " "), { encoding: "utf-8" });
}
async function removeDir(dir) {
await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 });
}
async function emptyDir(dir) {
await removeDir(dir);
await fs.mkdir(dir, { recursive: true });
}
async function getFilesFromFolder(dir) {
const data = await fs.readdir(dir, { withFileTypes: true });
let files = [];
for (const item of data) {
if (item.isDirectory()) {
const moreFiles = await getFilesFromFolder(new URL(`./${item.name}/`, dir));
files = files.concat(moreFiles);
} else {
files.push(new URL(`./${item.name}`, dir));
}
}
return files;
}
async function copyFilesToFolder(files, outDir, exclude = []) {
const excludeList = exclude.map((url) => fileURLToPath(url));
const fileList = files.map((url) => fileURLToPath(url)).filter((f) => !excludeList.includes(f));
if (files.length === 0) throw new Error("No files found to copy");
let commonAncestor = nodePath.dirname(fileList[0]);
for (const file of fileList.slice(1)) {
while (!file.startsWith(commonAncestor)) {
commonAncestor = nodePath.dirname(commonAncestor);
}
}
for (const origin of fileList) {
const dest = new URL(nodePath.relative(commonAncestor, origin), outDir);
const realpath = await fs.realpath(origin);
const isSymlink = realpath !== origin;
const isDir = (await fs.stat(origin)).isDirectory();
if (isDir && !isSymlink) {
await fs.mkdir(new URL("..", dest), { recursive: true });
} else {
await fs.mkdir(new URL(".", dest), { recursive: true });
}
if (isSymlink) {
const realdest = fileURLToPath(new URL(nodePath.relative(commonAncestor, realpath), outDir));
const target = nodePath.relative(fileURLToPath(new URL(".", dest)), realdest);
if (!existsSync(dest)) {
await fs.symlink(target, dest, isDir ? "dir" : "file");
}
} else if (!isDir) {
await fs.copyFile(origin, dest);
}
}
return commonAncestor;
}
export {
copyFilesToFolder,
emptyDir,
getFilesFromFolder,
removeDir,
writeJson
};

39
node_modules/@astrojs/internal-helpers/dist/path.d.ts generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/**
* A set of common path utilities commonly used through the Astro core and integration
* projects. These do things like ensure a forward slash prepends paths.
*/
export declare function appendExtension(path: string, extension: string): string;
export declare function appendForwardSlash(path: string): string;
export declare function prependForwardSlash(path: string): string;
export declare function collapseDuplicateSlashes(path: string): string;
export declare const MANY_TRAILING_SLASHES: RegExp;
export declare function collapseDuplicateTrailingSlashes(path: string, trailingSlash: boolean): string;
export declare function removeTrailingForwardSlash(path: string): string;
export declare function removeLeadingForwardSlash(path: string): string;
export declare function removeLeadingForwardSlashWindows(path: string): string;
export declare function trimSlashes(path: string): string;
export declare function startsWithForwardSlash(path: string): boolean;
export declare function startsWithDotDotSlash(path: string): boolean;
export declare function startsWithDotSlash(path: string): boolean;
export declare function isRelativePath(path: string): boolean;
export declare function isAbsolutePath(path: string): boolean;
export declare function isInternalPath(path: string): boolean;
export declare function joinPaths(...paths: (string | undefined)[]): string;
export declare function removeFileExtension(path: string): string;
export declare function removeQueryString(path: string): string;
/**
* Checks whether the path is considered a remote path.
* Remote means untrusted in this context, so anything that isn't a straightforward
* local path is considered remote.
*
* @param src
*/
export declare function isRemotePath(src: string): boolean;
/**
* Checks if parentPath is a parent directory of childPath.
*/
export declare function isParentDirectory(parentPath: string, childPath: string): boolean;
export declare function slash(path: string): string;
export declare function fileExtension(path: string): string;
export declare function removeBase(path: string, base: string): string;
export declare function hasFileExtension(path: string): boolean;

196
node_modules/@astrojs/internal-helpers/dist/path.js generated vendored Normal file
View File

@@ -0,0 +1,196 @@
function appendExtension(path, extension) {
return path + "." + extension;
}
function appendForwardSlash(path) {
return path.endsWith("/") ? path : path + "/";
}
function prependForwardSlash(path) {
return path[0] === "/" ? path : "/" + path;
}
function collapseDuplicateSlashes(path) {
return path.replace(/(?<!:)\/{2,}/g, "/");
}
const MANY_TRAILING_SLASHES = /\/{2,}$/g;
function collapseDuplicateTrailingSlashes(path, trailingSlash) {
if (!path) {
return path;
}
return path.replace(MANY_TRAILING_SLASHES, trailingSlash ? "/" : "") || "/";
}
function removeTrailingForwardSlash(path) {
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
}
function removeLeadingForwardSlash(path) {
return path.startsWith("/") ? path.substring(1) : path;
}
function removeLeadingForwardSlashWindows(path) {
return path.startsWith("/") && path[2] === ":" ? path.substring(1) : path;
}
function trimSlashes(path) {
return path.replace(/^\/|\/$/g, "");
}
function startsWithForwardSlash(path) {
return path[0] === "/";
}
function startsWithDotDotSlash(path) {
const c1 = path[0];
const c2 = path[1];
const c3 = path[2];
return c1 === "." && c2 === "." && c3 === "/";
}
function startsWithDotSlash(path) {
const c1 = path[0];
const c2 = path[1];
return c1 === "." && c2 === "/";
}
function isRelativePath(path) {
return startsWithDotDotSlash(path) || startsWithDotSlash(path);
}
function isAbsolutePath(path) {
return startsWithForwardSlash(path) || /^[a-zA-Z]:/.test(path);
}
function isString(path) {
return typeof path === "string" || path instanceof String;
}
const INTERNAL_PREFIXES = /* @__PURE__ */ new Set(["/_", "/@", "/.", "//"]);
const JUST_SLASHES = /^\/{2,}$/;
function isInternalPath(path) {
return INTERNAL_PREFIXES.has(path.slice(0, 2)) && !JUST_SLASHES.test(path);
}
function joinPaths(...paths) {
return paths.filter(isString).map((path, i) => {
if (i === 0) {
return removeTrailingForwardSlash(path);
} else if (i === paths.length - 1) {
return removeLeadingForwardSlash(path);
} else {
return trimSlashes(path);
}
}).join("/");
}
function removeFileExtension(path) {
let idx = path.lastIndexOf(".");
return idx === -1 ? path : path.slice(0, idx);
}
function removeQueryString(path) {
const index = path.lastIndexOf("?");
return index > 0 ? path.substring(0, index) : path;
}
function isRemotePath(src) {
if (!src) return false;
const trimmed = src.trim();
if (!trimmed) return false;
let decoded = trimmed;
let previousDecoded = "";
let maxIterations = 10;
while (decoded !== previousDecoded && maxIterations > 0) {
previousDecoded = decoded;
try {
decoded = decodeURIComponent(decoded);
} catch {
break;
}
maxIterations--;
}
if (/^[a-zA-Z]:/.test(decoded)) {
return false;
}
if (decoded[0] === "/" && decoded[1] !== "/" && decoded[1] !== "\\") {
return false;
}
if (decoded[0] === "\\") {
return true;
}
if (decoded.startsWith("//")) {
return true;
}
try {
const url = new URL(decoded, "http://n");
if (url.username || url.password) {
return true;
}
if (decoded.includes("@") && !url.pathname.includes("@") && !url.search.includes("@")) {
return true;
}
if (url.origin !== "http://n") {
const protocol = url.protocol.toLowerCase();
if (protocol === "file:") {
return false;
}
return true;
}
if (URL.canParse(decoded)) {
return true;
}
return false;
} catch {
return true;
}
}
function isParentDirectory(parentPath, childPath) {
if (!parentPath || !childPath) {
return false;
}
if (parentPath.includes("://") || childPath.includes("://")) {
return false;
}
if (isRemotePath(parentPath) || isRemotePath(childPath)) {
return false;
}
if (parentPath.includes("..") || childPath.includes("..")) {
return false;
}
if (parentPath.includes("\0") || childPath.includes("\0")) {
return false;
}
const normalizedParent = appendForwardSlash(slash(parentPath).toLowerCase());
const normalizedChild = slash(childPath).toLowerCase();
if (normalizedParent === normalizedChild || normalizedParent === normalizedChild + "/") {
return false;
}
return normalizedChild.startsWith(normalizedParent);
}
function slash(path) {
return path.replace(/\\/g, "/");
}
function fileExtension(path) {
const ext = path.split(".").pop();
return ext !== path ? `.${ext}` : "";
}
function removeBase(path, base) {
if (path.startsWith(base)) {
return path.slice(removeTrailingForwardSlash(base).length);
}
return path;
}
const WITH_FILE_EXT = /\/[^/]+\.\w+$/;
function hasFileExtension(path) {
return WITH_FILE_EXT.test(path);
}
export {
MANY_TRAILING_SLASHES,
appendExtension,
appendForwardSlash,
collapseDuplicateSlashes,
collapseDuplicateTrailingSlashes,
fileExtension,
hasFileExtension,
isAbsolutePath,
isInternalPath,
isParentDirectory,
isRelativePath,
isRemotePath,
joinPaths,
prependForwardSlash,
removeBase,
removeFileExtension,
removeLeadingForwardSlash,
removeLeadingForwardSlashWindows,
removeQueryString,
removeTrailingForwardSlash,
slash,
startsWithDotDotSlash,
startsWithDotSlash,
startsWithForwardSlash,
trimSlashes
};

View File

@@ -0,0 +1,62 @@
export type RemotePattern = {
hostname?: string;
pathname?: string;
protocol?: string;
port?: string;
};
/**
* Evaluates whether a given URL matches the specified remote pattern based on protocol, hostname, port, and pathname.
*
* @param {URL} url - The URL object to be matched against the remote pattern.
* @param {RemotePattern} remotePattern - The remote pattern object containing the protocol, hostname, port, and pathname to match.
* @return {boolean} Returns `true` if the URL matches the given remote pattern; otherwise, `false`.
*/
export declare function matchPattern(url: URL, remotePattern: RemotePattern): boolean;
/**
* Checks if the given URL's port matches the specified port. If no port is provided, it returns `true`.
*
* @param {URL} url - The URL object whose port will be checked.
* @param {string} [port=] - The port to match against the URL's port. Optional.
* @return {boolean} Returns `true` if the URL's port matches the specified port or if no port is provided; otherwise, `false`.
*/
export declare function matchPort(url: URL, port?: string): boolean;
/**
* Compares the protocol of the provided URL with a specified protocol.
*
* @param {URL} url - The URL object whose protocol needs to be checked.
* @param {string} [protocol] - The protocol to compare against, without the trailing colon. If not provided, the method will always return `true`.
* @return {boolean} Returns `true` if the protocol matches or if no protocol is specified; otherwise, `false`.
*/
export declare function matchProtocol(url: URL, protocol?: string): boolean;
/**
* Matches a given URL's hostname against a specified hostname, with optional support for wildcard patterns.
*
* @param {URL} url - The URL object whose hostname is to be matched.
* @param {string} [hostname] - The hostname to match against. Supports wildcard patterns if `allowWildcard` is `true`.
* @param {boolean} [allowWildcard=false] - Indicates whether wildcard patterns in the `hostname` parameter are allowed.
* @return {boolean} - Returns `true` if the URL's hostname matches the given hostname criteria; otherwise, `false`.
*/
export declare function matchHostname(url: URL, hostname?: string, allowWildcard?: boolean): boolean;
/**
* Matches a given URL's pathname against a specified pattern, with optional support for wildcards.
*
* @param {URL} url - The URL object containing the pathname to be matched.
* @param {string} [pathname] - The pathname pattern to match the URL against.
* @param {boolean} [allowWildcard=false] - Determines whether wildcard matching is allowed.
* @return {boolean} - Returns `true` if the URL's pathname matches the specified pattern; otherwise, `false`.
*/
export declare function matchPathname(url: URL, pathname?: string, allowWildcard?: boolean): boolean;
/**
* Determines whether a given remote resource, identified by its source URL,
* is allowed based on specified domains and remote patterns.
*
* @param {string} src - The source URL of the remote resource to be validated.
* @param {Object} options - The configuration options for domain and pattern matching.
* @param {string[]} options.domains - A list of allowed domain names.
* @param {RemotePattern[]} options.remotePatterns - A list of allowed remote patterns for matching.
* @return {boolean} Returns `true` if the source URL matches any of the specified domains or remote patterns; otherwise, `false`.
*/
export declare function isRemoteAllowed(src: string, { domains, remotePatterns, }: {
domains: string[];
remotePatterns: RemotePattern[];
}): boolean;

63
node_modules/@astrojs/internal-helpers/dist/remote.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
function matchPattern(url, remotePattern) {
return matchProtocol(url, remotePattern.protocol) && matchHostname(url, remotePattern.hostname, true) && matchPort(url, remotePattern.port) && matchPathname(url, remotePattern.pathname, true);
}
function matchPort(url, port) {
return !port || port === url.port;
}
function matchProtocol(url, protocol) {
return !protocol || protocol === url.protocol.slice(0, -1);
}
function matchHostname(url, hostname, allowWildcard = false) {
if (!hostname) {
return true;
} else if (!allowWildcard || !hostname.startsWith("*")) {
return hostname === url.hostname;
} else if (hostname.startsWith("**.")) {
const slicedHostname = hostname.slice(2);
return slicedHostname !== url.hostname && url.hostname.endsWith(slicedHostname);
} else if (hostname.startsWith("*.")) {
const slicedHostname = hostname.slice(1);
const additionalSubdomains = url.hostname.replace(slicedHostname, "").split(".").filter(Boolean);
return additionalSubdomains.length === 1;
}
return false;
}
function matchPathname(url, pathname, allowWildcard = false) {
if (!pathname) {
return true;
} else if (!allowWildcard || !pathname.endsWith("*")) {
return pathname === url.pathname;
} else if (pathname.endsWith("/**")) {
const slicedPathname = pathname.slice(0, -2);
return slicedPathname !== url.pathname && url.pathname.startsWith(slicedPathname);
} else if (pathname.endsWith("/*")) {
const slicedPathname = pathname.slice(0, -1);
const additionalPathChunks = url.pathname.replace(slicedPathname, "").split("/").filter(Boolean);
return additionalPathChunks.length === 1;
}
return false;
}
function isRemoteAllowed(src, {
domains,
remotePatterns
}) {
if (!URL.canParse(src)) {
return false;
}
const url = new URL(src);
if (url.protocol === "data:") {
return true;
}
if (!["http:", "https:"].includes(url.protocol)) {
return false;
}
return domains.some((domain) => matchHostname(url, domain)) || remotePatterns.some((remotePattern) => matchPattern(url, remotePattern));
}
export {
isRemoteAllowed,
matchHostname,
matchPathname,
matchPattern,
matchPort,
matchProtocol
};