@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
122 lines (121 loc) • 3.53 kB
TypeScript
import { Fs } from '../fs/type';
export declare const PACKAGE_JSON_FILENAME = "package.json";
export declare const ComponentFolderWorkflows = "workflows";
export declare const ComponentFolderPrompts = "prompts";
export declare const ComponentFolderContent = "content";
export declare const ComponentFolderLayouts = "layouts";
export declare const ComponentFolderStatic = "static";
export declare const ComponentFolderAssets = "assets";
export declare const ComponentFolderI18n = "i18n";
export declare const ComponentFolders: readonly ["workflows", "prompts", "content", "layouts", "static", "assets", "i18n"];
export declare enum DownloadStatus {
PENDING = "pending",
DOWNLOADING = "downloading",
COMPLETED = "completed",
FAILED = "failed"
}
export declare class ModuleError extends Error {
code?: string | undefined;
constructor(message: string, code?: string | undefined);
}
export declare const ErrModuleNotFound: ModuleError;
export declare const ErrDownloadFailed: ModuleError;
export declare const ErrInvalidZipFile: ModuleError;
export declare const ErrMountFailed: ModuleError;
export interface Info {
osFs(): Fs;
projDir(): string;
moduleDir(): string;
moduleCacheDir(): string;
importPaths(): string[];
defaultLanguageKey(): string;
otherLanguageKeys(): string[];
getRelDir(name: string, langKey: string): string;
httpClient?(): HttpClient;
}
export interface Mount {
source(): string;
target(): string;
lang(): string;
}
export interface Module {
owner(): Module | null;
isProjectModule(): boolean;
mounts(): Mount[];
dir(): string;
path(): string;
}
export interface Modules {
proj(): Module;
all(): Module[];
isProjMod(mod: Module): boolean;
getSourceLang(source: string): [string, boolean];
}
export interface Import {
path: string;
url: string;
version?: string;
mounts?: MountConfig[];
}
export interface MountConfig {
sourcePath: string;
targetPath: string;
language?: string;
}
export interface ModuleConfig {
imports: Import[];
}
export interface DownloadConfig {
url: string;
timeout?: number;
retries?: number;
headers?: Record<string, string>;
}
export interface ModuleMetadata {
path: string;
version: string;
url: string;
dir: string;
downloadStatus: DownloadStatus;
downloadedAt?: Date;
size?: number;
checksum?: string;
}
export type DownloadProgressCallback = (progress: {
loaded: number;
total: number;
percentage: number;
}) => void;
export interface HttpClient {
download(url: string, targetPath: string, options?: {
onProgress?: DownloadProgressCallback;
headers?: Record<string, string>;
timeout?: number;
}): Promise<void>;
get(url: string, options?: {
headers?: Record<string, string>;
timeout?: number;
}): Promise<{
data: ArrayBuffer;
headers: Record<string, string>;
status: number;
}>;
}
export interface ZipExtractor {
extract(zipPath: string, targetDir: string): Promise<void>;
list(zipPath: string): Promise<string[]>;
}
export interface ModuleCache {
get(path: string): Promise<ModuleMetadata | null>;
set(path: string, metadata: ModuleMetadata): Promise<void>;
has(path: string): Promise<boolean>;
delete(path: string): Promise<void>;
clear(): Promise<void>;
}
export interface ThemeToml {
module?: {
imports?: {
path: string;
}[];
};
}