import type { LixPlugin } from "../plugin/lix-plugin.js";
import { Kysely } from "kysely";
import { type LixDatabaseSchema } from "../database/schema.js";
import type { LixKeyValue } from "../key-value/schema-definition.js";
import type { NewStateByVersion } from "../engine/entity-views/types.js";
import type { LixAccount } from "../account/schema-definition.js";
import { type LixHooks } from "../hooks/create-hooks.js";
import { createObserve } from "../observe/create-observe.js";
import type { LixEngine } from "../engine/boot.js";
import type { LixEnvironment } from "../environment/api.js";
export type Lix = {
    db: Kysely<LixDatabaseSchema>;
    plugin: {
        getAll: () => Promise<LixPlugin[]>;
    };
    /**
     * Hooks for listening to database lifecycle events.
     *
     * Allows registering callbacks that fire at specific points
     * in Lix's execution, such as when state changes are committed.
     */
    hooks: LixHooks;
    /**
     * Closes the lix instance and its storage.
     */
    close: () => Promise<void>;
    observe: ReturnType<typeof createObserve>;
    /**
     * Calls a named engine function and returns its result.
     *
     * Preferred entrypoint for invoking engine functions.
     */
    call: (name: string, args?: unknown) => Promise<unknown>;
    /**
     * Serialises the Lix into a {@link Blob}.
     *
     * Use this helper to persist the current state to disk or send it to a
     * server. By convention, persisted Lix files use the `.lix` extension.
     *
     * @example Persist to disk in Node
     *
     * ```ts
     * import { writeFile } from "node:fs/promises";
     * const blob = await lix.toBlob();
     * await writeFile("repo.lix", Buffer.from(await blob.arrayBuffer()));
     * ```
     *
     * @example Trigger a browser download
     *
     * ```ts
     * const blob = await lix.toBlob();
     * const url = URL.createObjectURL(blob);
     * const a = document.createElement("a");
     * a.href = url;
     * a.download = "repo.lix";
     * a.click();
     * URL.revokeObjectURL(url);
     * ```
     */
    toBlob: () => Promise<Blob>;
    /**
     * In‑process engine context bound to the live database.
     *
     * When Lix runs in‑process (same thread as the database),
     * `engine` is available and tests can directly call helpers
     * that accept `{ engine }`.
     *
     * When Lix runs out‑of‑process (for example inside a Worker), the engine
     * is not accessible from the main thread and will be `undefined`. In those
     * environments, use `lix.call` to invoke engine functions across the
     * boundary.
     *
     * Guidance:
     * - Prefer `lix.db` for normal queries and `lix.call` for engine
     *   operations. Reserve `lix.engine` for unit tests or internal SDK code
     *   that explicitly requires in‑process access alongside the database.
     * - Do not rely on `lix.engine` in application/business logic, since it
     *   may be `undefined` in worker/remote environments.
     *
     * Unit test in the same process
     *
     * @example
     *
     * ```ts
     * test("example test", async () => {
     *   // InMemory environment runs in the same process (in‑process engine).
     *   const lix = await openLix({
     *      environment: new InMemoryenvironment()
     *   });
     *   executeSync({
     *     engine: lix.engine!,
     *     data: [...],
     *   });
     * });
     * ```
     *
     * Worker/remote environment – prefer router calls
     *
     * @example
     * ```ts
     * await lix.call("lix_insert_transaction_state", { timestamp, data });
     * ```
     */
    engine?: LixEngine;
};
/**
 * Opens a Lix instance.
 *
 * Creates an in-memory database by default. If a blob is provided,
 * the database is initialized with that data. If a database is provided,
 * uses that database directly.
 *
 * @example
 * ```ts
 * // In-memory (default)
 * const lix = await openLix({})
 *
 * // From existing data
 * const lix = await openLix({ blob: existingLixFile })
 *
 * // With custom storage adapter
 * import { MyCustomStorage } from "./my-custom-storage.js"
 * const lix = await openLix({
 *   storage: new MyCustomStorage()
 * })
 * ```
 */
export declare function openLix(args: {
    /**
     * The account that is opening this lix.
     *
     * Lix will automatically set the active account to the provided account.
     *
     * @example
     *   const account = localStorage.getItem("account")
     *   const lix = await openLix({ account })
     */
    account?: LixAccount;
    /**
     * Lix file data to initialize the database with.
     */
    blob?: Blob;
    environment?: LixEnvironment;
    /**
     * Provide plugin instances directly (in-process environments only).
     *
     * Use this when executing in the same thread as the engine, e.g. tests or
     * scripts running with {@link InMemoryEnvironment}. Plugins supplied this
     * way are not transferable across worker boundaries.
     *
     * Prefer {@link providePluginsRaw} when the environment can access bundled
     * plugin source (for example via `?raw` import). Raw strings load on the
     * target thread and work in both workers and main-thread contexts, but are
     * usually unavailable in unit tests.
     *
     * @example
     * ```ts
     * const lix = await openLix({
     *   providePlugins: [jsonPlugin]
     * })
     * ```
     */
    providePlugins?: LixPlugin[];
    /**
     * Provide plugins as stringified ESM modules.
     *
     * This is the portable format for worker or cross-thread environments where
     * functions cannot be structured cloned. Each string is evaluated via
     * {@link loadPluginFromString} inside the target environment.
     *
     * @example
     * ```ts
     * const jsonPlugin = await fetch("/plugins/json.js").then((res) => res.text());
     * const lix = await openLix({ providePluginsRaw: [jsonPlugin] });
     * ```
     */
    providePluginsRaw?: string[];
    /**
     * Set the key values when opening the lix.
     *
     * The `lixcol_version_id` defaults to the active version.
     *
     * @example
     *   const lix = await openLix({ keyValues: [{ key: "lix_sync", value: "false" }] })
     */
    keyValues?: NewStateByVersion<LixKeyValue>[];
}): Promise<Lix>;
/**
 * Get all used file extensions.
 */
export declare function usedFileExtensions(db: Kysely<LixDatabaseSchema>): Promise<any>;
//# sourceMappingURL=open-lix.d.ts.map