import {ResolvedNavItemWithLink} from '../../shared/index.js' export declare function createSymbol(name: string): symbol /** * Bounding rect of a trigger element. * * 触发元素的包围盒。 */ export interface PreviewRect { top: number left: number right: number bottom: number width: number height: number } /** * Size of an element or of the viewport. * * 元素或视口尺寸。 */ export interface PreviewSize { width: number height: number } /** * Options of the positioning algorithm. * * 定位算法的配置。 */ export interface PreviewPositionOptions { /** * Gap between the anchor and the card * * 卡片与链接之间的间距 */ offset?: number /** * Min gap between the card and the viewport edge * * 卡片与视口边缘的最小间距 */ margin?: number } /** * Resolved fixed position of the card. * * 计算出的卡片 fixed 定位。 */ export interface PreviewPosition { top: number left: number placement: 'top' | 'bottom' } /** * Normalize a route path into a comparable preview key. * Mirrors `node/features/linkPreview/key.ts`. * * 将路由路径序列化为可比较的预览键。 * 与 `node/features/linkPreview/key.ts` 保持一致。 * * @param pathname - Route path / 路由路径 */ export declare function normalizePreviewPath(pathname: string): string /** * Strip the site base prefix from a pathname. * * 去除站点 `base` 前缀(用前缀切片而不是正则)。 * * @param pathname - Absolute pathname / 绝对路径 * @param base - Site base / 站点 base */ export declare function stripBase(pathname: string, base: string): string /** * Resolve the preview key of an anchor href (pure, unit-testable). * * 由 `href` 解析预览键:剥离 base,标准化路径,并在以下情况 * 返回 `null`:锚点链接、外部协议、外站链接、当前页链接。 * * 相对路径按当前页面路由解析,与点击链接时的浏览器行为一致。 * * @param href - Raw `href` attribute / 链接的 `href` 属性值 * @param base - Site base / 站点 base * @param currentKey - Normalized key of the current page / 当前页的归一化键 * @param selfOrigin - `location.origin` / 当前站点 origin */ export declare function resolveAnchorKey( href: string | null | undefined, base: string, currentKey: string, selfOrigin: string, ): string | null /** * Resolve the fixed position of the preview card. * * 计算预览卡片的 fixed 定位:默认在链接下方,空间不足时翻转到上方, * 水平方向裁剪到视口内。 * * @param anchor - Bounding rect of the trigger / 触发链接的包围盒 * @param card - Size of the card / 卡片尺寸 * @param viewport - Size of the viewport / 视口尺寸 * @param options - Positioning options / 定位配置 */ export declare function resolvePreviewPosition( anchor: PreviewRect, card: PreviewSize, viewport: PreviewSize, options?: PreviewPositionOptions, ): PreviewPosition /** * Convert a DOMRect into a plain rect object. * * 将 DOMRect 转换为普通对象。 * * @param rect - DOM rect / DOM 包围盒 */ export declare function toPreviewRect( rect: | DOMRect | { top: number left: number right: number bottom: number width: number height: number }, ): PreviewRect /** * Minimal shape required to resolve a post's sticky priority. * * 解析文章置顶优先级所需的最小结构。 */ interface StickyPost { sticky?: boolean | number } /** * Resolve the numeric priority of a post's `sticky` frontmatter value. * * - `true` → `Number.MAX_SAFE_INTEGER`, so a plain `sticky: true` always ranks * above any number. * - A finite positive number → the number itself (larger ranks first). * - Anything else (`false`, `undefined`, `0`, negative or non-finite numbers) → `0`, * which means "not sticky". * * Normalizing to a single comparable number keeps the sort total and stable when * `true` and numbers are mixed, and makes `sticky: 0` behave as "not sticky". * * 解析文章 `sticky` frontmatter 的数值优先级。 * * - `true` → `Number.MAX_SAFE_INTEGER`,使 `sticky: true` 始终排在任意数字之前; * - 有限正数 → 数值本身(越大越靠前); * - 其他(`false`、`undefined`、`0`、负数或非有限数)→ `0`,表示不置顶。 * * 统一归一化为可比较的数值,可以在 `true` 与数字混用时保持排序完整且稳定, * 并让 `sticky: 0` 表现为不置顶。 */ export declare function resolveSticky(sticky: boolean | number | undefined | null): number /** * Sort posts by sticky priority (descending) without mutating the input. * * Sticky posts are moved to the front, ordered by descending priority; the * remaining posts keep their original relative order. Because * `Array.prototype.sort` is stable, posts sharing the same priority preserve * the order they were provided in. * * Note that the sorted list is paginated afterwards, so sticky posts are only * pinned on the first page. * * 按置顶优先级降序排列文章,且不修改入参。 * * 置顶文章被移动到最前并按优先级降序排列,其余文章保持原有相对顺序。由于 * `Array.prototype.sort` 是稳定的,优先级相同的文章会保持传入顺序。 * * 注意:排序后的列表会再进行分页切片,因此置顶文章仅在第 1 页置顶。 */ export declare function sortPostsBySticky(posts: readonly T[]): T[] /** * Supported repository types * Represents the type of code hosting platform * * 支持的仓库类型 * 表示代码托管平台的类型 */ export type RepoType = 'GitHub' | 'GitLab' | 'Gitee' | 'Bitbucket' | null /** * Resolve the repository type from a repository URL * Detects the platform based on URL patterns * * 从仓库 URL 解析仓库类型 * 基于 URL 模式检测平台 * * @param repo - Repository URL or path / 仓库 URL 或路径 * @returns The detected repository type or null if unknown / 检测到的仓库类型,如果未知则返回 null */ export declare function resolveRepoType(repo: string): RepoType /** * Edit link patterns for different repository platforms * Maps repository types to their respective edit URL patterns * * 不同仓库平台的编辑链接模式 * 将仓库类型映射到各自的编辑 URL 模式 */ export declare const editLinkPatterns: Record, string> /** * Resolve the complete edit link URL for a file * Generates an edit link based on repository configuration and file path * * 解析文件的完整编辑链接 URL * 根据仓库配置和文件路径生成编辑链接 * * @param params - Parameters object / 参数对象 * @param params.docsRepo - Repository URL / 仓库 URL * @param params.docsBranch - Branch name / 分支名称 * @param params.docsDir - Documentation directory / 文档目录 * @param params.filePathRelative - Relative file path / 相对文件路径 * @param params.editLinkPattern - Custom edit link pattern / 自定义编辑链接模式 * @returns The complete edit link URL or null / 完整的编辑链接 URL,如果无法生成则返回 null */ export declare function resolveEditLink({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }: { docsRepo: string docsBranch: string docsDir: string filePathRelative: string | undefined editLinkPattern?: string }): string | null /** * Resolve NavLink props from string * Converts a link string to a resolved navigation item with metadata * * 从字符串解析 NavLink 属性 * 将链接字符串转换为带有元数据的解析导航项 * * @param link - The link string to resolve / 要解析的链接字符串 * @returns Resolved navigation item with link, text, icon and badge / 解析后的导航项,包含链接、文本、图标和徽章 * @example * - Input: '/README.md' * - Output: { text: 'Home', link: '/' } */ export declare function resolveNavLink(link: string): ResolvedNavItemWithLink /** * Normalize a link by combining base and link * Handles absolute links and protocol links correctly * * 通过组合 base 和 link 来规范化链接 * 正确处理绝对链接和协议链接 * * @param base - Base URL / 基础 URL * @param link - Link to normalize / 要规范化的链接 * @returns Normalized link / 规范化后的链接 */ export declare function normalizeLink(base?: string, link?: string): string /** * Normalize a prefix by ensuring it ends with a slash * * 规范化前缀,确保它以斜杠结尾 * * @param base - Base URL / 基础 URL * @param link - Link to normalize / 要规范化的链接 * @returns Normalized prefix with trailing slash / 带有尾部斜杠的规范化前缀 */ export declare function normalizePrefix(base: string, link?: string): string /** * Regular expression to match external URLs * * 匹配外部 URL 的正则表达式 */ export declare const EXTERNAL_URL_RE: RegExp /** * Regular expression to match pathname protocol * * 匹配 pathname 协议的正则表达式 */ export declare const PATHNAME_PROTOCOL_RE: RegExp /** * Regular expression to match hash * * 匹配哈希值的正则表达式 */ export declare const HASH_RE: RegExp /** * Regular expression to match file extension * * 匹配文件扩展名的正则表达式 */ export declare const EXT_RE: RegExp /** * Whether running in browser * * 是否在浏览器中运行 */ export declare const inBrowser: boolean /** * Convert value to array * * 将值转换为数组 * * @param value - Value to convert, can be single value or array / 要转换的值,可以是单个值或数组 * @returns Array containing the value(s) / 包含值的数组 */ export declare function toArray(value: T | T[]): T[] /** * Check if the current path matches the given match path * Supports both exact matching and regex matching * * 检查当前路径是否匹配给定的匹配路径 * 支持精确匹配和正则匹配 * * @param currentPath - Current path to check / 要检查的当前路径 * @param matchPath - Path pattern to match against / 要匹配的路径模式 * @param asRegex - Whether to treat matchPath as regex / 是否将 matchPath 视为正则表达式 * @returns True if paths match / 如果路径匹配则返回 true */ export declare function isActive( currentPath: string, matchPath?: string, asRegex?: boolean, ): boolean /** * Normalize a path by removing hash and file extension * * 通过移除哈希值和文件扩展名来规范化路径 * * @param path - Path to normalize / 要规范化的路径 * @returns Normalized path / 规范化后的路径 */ export declare function normalize(path: string): string /** * Convert a numeric value to CSS unit string * Adds 'px' suffix if the value is a plain number * * 将数值转换为 CSS 单位字符串 * 如果值是纯数字则添加 'px' 后缀 * * @param value - Value to convert, can be number or string with unit / 要转换的值,可以是数字或带单位的字符串 * @returns CSS unit string / CSS 单位字符串 */ export declare function numToUnit(value?: string | number): string /** * Check if a value is a CSS gradient * * 检查值是否为 CSS 渐变 * * @param value - Value to check / 要检查的值 * @returns True if value is a gradient / 如果值是渐变则返回 true */ export declare function isGradient(value: string): boolean /** * Get the absolute top position of an element * Accounts for fixed positioned ancestors * * 获取元素的绝对顶部位置 * 考虑固定定位的祖先元素 * * @param element - Element to measure / 要测量的元素 * @returns Absolute top position or NaN / 绝对顶部位置或 NaN */ export declare function getAbsoluteTop(element: HTMLElement): number export declare function stripHtmlTags(input: string): string export {}