/** * Loader-free engine core: loading, encoding, and the synchronous one-shot * API. Pure except the explicitly-documented loader registration; no imports * from the entries, the worker client, or the plugin builders — so the worker * scripts can bundle this file alone. */ import { SvgoError } from "./errors.js"; import { isPluginName, PluginName } from "./plugin.js"; import type { Config, OptimizeResult, PluginDescriptor, PluginInput, WasmExports, WasmLoader } from "./types.js"; export type { Config, OptimizeResult, PluginDescriptor, PluginInput }; export { SvgoError }; export type { SvgoErrorKind } from "./errors.js"; export { isPluginName }; /** Engine session: references exports through their current buffer. */ export interface EngineSession { exports: WasmExports; encodeInput(value: string): { ptr: number; len: number; }; readString(ptr: number, len: number): string; free(ptr: number, len: number): void; } /** * Read the (outPtr, outLen, status) triple after a call and consume any * engine-allocated output, returning the decoded output. */ export interface ConsumedResult { ok: boolean; text: string; } export declare function consumeResult(session: EngineSession, outPtr: number): ConsumedResult; /** Override the URL `readDefaultWasm` resolves from (fetch or fs). */ export declare function setDefaultUrl(url: string | URL): void; /** Change how wasm bytes are supplied (`fetch`, `fs`, a cache…). */ export declare function setWasmLoader(loader: WasmLoader | null): void; /** Fetch the default wasm URL (set via `load()`/`loadUrl()` or entries). */ export declare function readDefaultWasm(): Promise; /** Fetch `url` and return the wasm bytes. */ export declare function fetchWasmBytes(url: string | URL): Promise; /** Instantiate the module with a known-shape exports object. */ export declare function instantiateWasmEngine(bytes: Uint8Array): EngineSession; export declare function isLoaded(): boolean; /** Grab the loaded session, throwing a usage error when missing. */ export declare function acquire(): EngineSession; /** Normalize the svgo-flavored `plugins` shorthand before encoding. */ export declare function normalizeConfig(config: Config): Record; /** * Register the loaded wasm bytes globally so later `optimize()` calls skip * the (async) load. Any previous module is released first. */ export declare function load(source: ArrayBuffer | Uint8Array): Promise; /** * Load from an explicit URL (`fetch` in browsers, `fs` or `fetch` in Node). */ export declare function loadUrl(url: string | URL): Promise; /** Release the loaded module; also terminates an idle worker, if any. */ export declare function reset(): void; export declare function registerWorkerTeardown(teardown: () => void): void; /** * Synchronously optimize with an already-loaded module. Use `reset()` between * explicit program phases, or `load(new ArrayBuffer(0))`-style disposal. */ export declare function optimizeSync(svg: string, config?: Config | null): OptimizeResult; /** * The resolvable plugin names, read synchronously from an already-loaded * module. Prefer the async `plugins()`. */ export declare function pluginsSync(): PluginName[]; /** * One plugin entry, e.g. for hand-built `Config.plugins` lists: * `plugins: [plugin(PluginName.RemoveViewBox, { removeFromDefs: true })]`. */ export declare function plugin(name: PluginInput, params?: Record): PluginDescriptor; /** Run exactly the named plugins (no preset). */ export declare function only(...names: PluginInput[]): PluginDescriptor[]; /** The default preset, explicitly. */ export declare function preset(): PluginDescriptor[]; /** The default preset minus the named plugins (the svgo way to opt out). */ export declare function drop(...names: PluginInput[]): PluginDescriptor[]; //# sourceMappingURL=core.d.ts.map