UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

54 lines 2.24 kB
export interface LoaderContext { resourcePath: string; addDependency(dependency: string): void; emitFile?(name: string, content: string): void; } export interface ExternalsProviderInfo { fileName: string; content: string; relativePath: string; } /** * Creates a relative import path from source file to target file */ declare function createRelativePath(fromFile: string, toFile: string): string; /** * Creates a structured path for generated externals files based on the source file location * Example: app/components/checkbox/demos/basic/index.ts -> generated/demo-externals/app/components/checkbox/demos/basic.tsx */ declare function createGeneratedFilePath(resourcePath: string, projectRoot: string): Promise<{ filePath: string; relativePath: string; }>; /** * Determines the appropriate build directory for temporary files * to avoid checking generated files into source control. */ declare function getBuildDirectory(resourcePath: string): Promise<string>; /** * Finds the project root by looking for 'app' directory or common project markers */ declare function findProjectRoot(startPath: string): Promise<string>; /** * Ensures that the generated demo externals directory is added to .gitignore * to prevent accidentally committing these generated files. */ declare function ensureGitignoreEntry(projectRoot: string): Promise<void>; /** * Emits an externals provider file using the best available method: * 1. Use emitFile if available (webpack) * 2. Fall back to structured filesystem writing to generated/demo-externals/ (turbopack/other bundlers) * * @param loaderContext - The loader context with emitFile capability * @param externalsProviderInfo - The externals provider file information * @returns The import path to use for the generated file */ export declare function emitExternalsProvider(loaderContext: LoaderContext, externalsProviderInfo: ExternalsProviderInfo): Promise<string>; export declare const testHelpers: { createRelativePath: typeof createRelativePath; createGeneratedFilePath: typeof createGeneratedFilePath; getBuildDirectory: typeof getBuildDirectory; findProjectRoot: typeof findProjectRoot; ensureGitignoreEntry: typeof ensureGitignoreEntry; }; export {};