UNPKG

2.56 kBTypeScriptView Raw
1/// <reference types="node" />
2import type { Range, RangeOptions } from '@umijs/utils/compiled/semver';
3import Cache from 'file-system-cache';
4import type { RunLoaderOption as InternalRunLoaderOption, RunLoaderResult } from '../compiled/loader-runner';
5export type * from '../compiled/loader-runner';
6export { getContext } from '../compiled/loader-runner';
7/**
8 * get route path from file-system path
9 */
10export declare function getFileIdFromFsPath(fsPath: string): string;
11/**
12 * get range lines of markdown file
13 */
14export declare const getFileRangeLines: (content: string, range: string) => string;
15/**
16 * get file content by regular expression
17 * @param content source file content
18 * @param regexp regular expression string
19 * @param filePath source file path
20 */
21export declare const getFileContentByRegExp: (content: string, regexp: string, filePath: string) => string;
22/**
23 * parse frontmatter from code string,
24 * also supports html/xml comments
25 */
26export declare function parseCodeFrontmatter(raw: string): {
27 code: string;
28 frontmatter: Record<string, any> | null;
29};
30declare const caches: Record<string, ReturnType<typeof Cache>>;
31export declare function _setFSCacheDir(dir: string): void;
32export declare function getCache(ns: string): (typeof caches)['0'];
33/**
34 * try to get father config
35 */
36export declare function tryFatherBuildConfigs(cwd: string): Promise<any[]>;
37/**
38 * get root dir for monorepo project
39 */
40export declare function getProjectRoot(cwd: string): string;
41/**
42 *
43 * transform component into webpack chunkName
44 * @export
45 * @param {string} component component path
46 * @param {string} [cwdPath] current root path
47 * @return {*} {string}
48 */
49export declare function componentToChunkName(component: string, cwdPath?: string): string;
50export declare function generateMetaChunkName(path: string, cwd: string, locales?: string[]): string;
51/**
52 * generate hash for string
53 */
54export declare function getContentHash(content: string, length?: number): string;
55export type RunLoaderOption = Partial<InternalRunLoaderOption>;
56export declare function runLoaders(options: RunLoaderOption): Promise<RunLoaderResult>;
57export declare function runLoaders(options: RunLoaderOption, callback: undefined): Promise<RunLoaderResult>;
58export declare function runLoaders(options: RunLoaderOption, callback: (err: NodeJS.ErrnoException | null, result: RunLoaderResult) => any): void;
59/**
60 * check if version is in range
61 */
62export declare function isVersionInRange(version: string, range: string | Range, options?: RangeOptions): boolean;