import type { Configuration } from 'webpack'; import { colors } from './utils/log'; import type { Log } from './utils/log'; import type { CreatePageInput } from './Pages'; import { Pages } from './Pages'; import { BrowserApi } from './BrowserApi'; import { Transformers } from './Transformers'; import { Compiler } from './Compiler'; import { hooks } from './hooks'; import { VueRenderer } from './vue-renderer'; import type { ValidatedSaberConfig } from './utils/validateConfig'; export interface SaberConstructorOptions { cwd?: string; verbose?: boolean; dev?: boolean; inspectWebpack?: boolean; } export interface SaberOptions { cwd: string; verbose?: boolean; dev?: boolean; inspectWebpack?: boolean; progress?: boolean; } export interface SiteConfig { /** Apply to tag */ lang: string; [k: string]: any; } export interface ThemeConfig { [k: string]: any; } /** * A Saber plugin */ export interface SaberPlugin { /** * The name of the plugin */ name: string; /** * The callback function that will be called when applying the plugin * @param api The Saber instance context * @param options The plugin options * @returns `void` or `Promise` */ apply: (api: Saber, options: any) => void | Promise; filterPlugins?: (plugins: ResolvedSaberPlugin[], options?: any) => ResolvedSaberPlugin[]; } export interface SaberConfigPlugin { resolve: string; options?: { [k: string]: any; }; } export interface ResolvedSaberPlugin extends SaberPlugin { location: string; options?: any; } export interface WebpackContext { type: 'client' | 'server'; [k: string]: any; } export type PageType = 'page' | 'post'; export interface Permalinks { /** * Permalink format for normal pages * @default `/:slug.html` */ page?: string; /** * Permalink format for posts * @default `/posts/:slug.html` */ post?: string; } export interface SaberConfig { /** The path or name of your theme */ theme?: string; siteConfig?: SiteConfig; themeConfig?: object; locales?: { [localePath: string]: { siteConfig?: SiteConfig; themeConfig?: ThemeConfig; }; }; /** * Customize permalink format based on page types (page or post) */ permalinks?: Permalinks | ((page: CreatePageInput) => Permalinks); /** Build configurations */ build?: { /** * The path to output generated files * Defaul to `./public` */ outDir?: string; /** * The root path where your website is localed * Default to `/` */ publicUrl?: string; /** * Extract CSS into standalone files * Default to `false` */ extractCSS?: boolean; /** * Toggle sourcemap for CSS * Default to `false` */ cssSourceMap?: boolean; /** * Options for CSS loaders */ loaderOptions?: { /** sass-loader */ sass?: any; /** less-loader */ less?: any; /** stylus-loader */ stylus?: any; /** css-loader */ css?: any; /** postcss-loader */ postcss?: any; }; /** * Toggle cache for webpack * Default to `true` */ cache?: boolean; /** * Compile pages on demand * @beta */ lazy?: boolean; }; server?: { host?: string; port?: number; }; plugins?: Array; markdown?: { /** The path to a module or npm package name that slugifies the markdown headers. */ slugify?: string; /** * Options for the internal markdown-it plugin for generating markdown headings and heading anchors. */ headings?: { /** * Inject markdown headings as `page.markdownHeadings` * @default `true` */ markdownHeadings?: boolean; /** * Generating permalinks * @default `false` */ permalink?: boolean; permalinkComponent?: string; /** * Inject permalink before heading text. * @default `true` */ permalinkBefore?: string; /** * The permalink symbol. * @default `'#'` */ permalinkSymbol?: string; }; /** * Show line numbers in code blocks * @default `false` */ lineNumbers?: boolean; /** markdown-it plugins */ plugins?: MarkdownPlugin[]; /** markdown-it options */ options?: { [k: string]: any; }; }; template?: { /** * Whether to open external links in new tab. * @default `true` */ openLinkInNewTab?: boolean; /** * A set of plugins that are used to transform Vue template. */ plugins?: any[]; }; } export interface MarkdownPlugin { resolve: string; options?: { [k: string]: any; }; } export declare class Saber { opts: SaberOptions; initialConfig: SaberConfig; config: ValidatedSaberConfig; pages: Pages; browserApi: BrowserApi; log: Log; colors: typeof colors; utils: any; hooks: typeof hooks; transformers: Transformers; runtimePolyfills: Set; compilers: { [k: string]: Compiler; }; renderer: VueRenderer; pkg: { path?: string; data: { [k: string]: any; }; }; configDir?: string; configPath?: string; theme: string; actualServerPort?: number; constructor(opts?: SaberConstructorOptions, config?: SaberConfig); loadConfig(configFiles?: string[]): { config: ValidatedSaberConfig; configPath: string | undefined; }; setConfig(config: ValidatedSaberConfig, configPath?: string): void; get dev(): boolean; get lazy(): boolean; /** * Load plugins */ prepare(): Promise; applyPlugin(plugin: SaberPlugin, options?: any, pluginLocation?: string): Promise; getUserPlugins(): ResolvedSaberPlugin[]; resolveCache(...args: string[]): string; resolveCwd(...args: string[]): string; resolveOwnDir(...args: string[]): string; resolveOutDir(...args: string[]): string; /** * Get Webpack Config * * @param {WebpackContext} opts Webpack context * @returns {Promise} Webpack configuration */ getWebpackConfig(opts: WebpackContext): Promise; run(): Promise; build(options?: { skipCompilation?: boolean; }): Promise; serve(): Promise; serveOutDir(): Promise; hasDependency(name: string): boolean; getDependencies(): string[]; /** * Resolve a module from the Saber project's local node_modules * @param {string}name The name of the module * @returns {string | undefined} The path to the module or `undefined` if not found */ localResolve(name: string): string | undefined; localRequire(name: string): any; } /** * Create a Saber instance * @param {SaberConstructorOptions}opts Saber constructor options * @param {SaberConfig}config Saber config * @returns {Saber} The Saber instance */ export declare function createSaber(opts?: SaberConstructorOptions, config?: SaberConfig): Saber;