import * as esbuild from "esbuild"; //#region src/build/types.d.ts interface BuildLog { readonly message: string; readonly file?: string; } type BuildResult = { readonly entry: string; readonly outdir: string; readonly warnings: BuildLog[]; /** * duration is the duration of the build in milliseconds. */ readonly duration: number; } | { readonly error: BuildLog; }; /** * BuildContext is context passed to the build function. * * It is the implementors responsibility to handle `watch` * and to appropriately call `onStart` and `onEnd`. */ interface BuildContext { readonly entry: string; readonly outdir: string; readonly cwd: string; readonly dev?: boolean; readonly watch?: boolean; readonly signal?: AbortSignal; readonly onStart: () => void; readonly onResult: (result: BuildResult) => void; } //#endregion //#region src/build/esbuild.d.ts /** * setEsbuildInstance allows consumers to provide their own esbuild instance. * This is useful for bundled environments (like Electron) where dynamic imports * might not resolve correctly. */ declare function setEsbuildInstance(instance: typeof esbuild): void; declare function buildWithEsbuild(options?: esbuild.BuildOptions): (context: BuildContext) => Promise; //#endregion //#region src/build/index.d.ts interface Config { /** * entry is the path to the entry point of the agent. * Defaults to `src/agent.ts` or `agent.ts` in the current working directory. */ entry?: string; /** * outdir is the directory to write the build output to. * Defaults to `.blink/build` in the current working directory. */ outdir?: string; /** * build is invoked when the build starts. * This is triggered by `blink dev` or `blink build`. * * By default, this uses the `buildWithEsbuild` function. * * @param context - The build context. * @returns * @example * ```ts * import { defineConfig } from "blink/build"; * * export default defineConfig({ * entry: "src/agent.ts", * outdir: "dist", * build: ({ entry, outdir, watch, onStart, onEnd }) => { * await onStart(); * // ... perform build ... * await onEnd({ * entry: "dist/agent.js", * outdir: "dist", * warnings: [], * }); * } * }) * ``` */ build?: (context: BuildContext) => Promise; } type ResolvedConfig = Required; /** * defineConfig is a helper function for typing the config object. * * @param config - The config object. * @returns The config object. * @example * ```ts * import { defineConfig } from "blink/build"; * * export default defineConfig({ * entry: "src/agent.ts", * outdir: "dist", * build: ({ entry, outdir, onBuildStart, onBuildEnd }) => { * * } * }) */ declare function defineConfig(config?: Config): Config; /** * resolveConfig resolves the Blink config for a given directory. * * @param directory - The directory to resolve the config for. * @returns The resolved config. */ declare function resolveConfig(directory: string): ResolvedConfig; //#endregion export { BuildContext, BuildLog, BuildResult, Config, ResolvedConfig, buildWithEsbuild, defineConfig, resolveConfig, setEsbuildInstance };