import * as miniflare0 from "miniflare";
import { LegacyWorkerOptions, Miniflare, Request, Response, V4ModuleRule } from "miniflare";
import { z } from "zod";
import { PoolRunnerInitializer, TestProject, Vite, Vitest } from "vitest/node";
import { ProvidedContext } from "vitest";

//#region src/pool/config.d.ts
declare const WorkersPoolOptionsSchema: z.ZodObject<{
  main: z.ZodOptional<z.ZodString>;
  remoteBindings: z.ZodDefault<z.ZodBoolean>;
  verbose: z.ZodOptional<z.ZodBoolean>;
  additionalExports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"WorkerEntrypoint">, z.ZodLiteral<"DurableObject">, z.ZodLiteral<"WorkflowEntrypoint">]>>>;
  miniflare: z.ZodOptional<z.ZodObject<{
    workers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
  }, z.core.$loose>>;
  wrangler: z.ZodOptional<z.ZodObject<{
    configPath: z.ZodOptional<z.ZodString>;
    environment: z.ZodOptional<z.ZodString>;
  }, z.core.$strip>>;
}, z.core.$strip>;
type CompatibleWorkerOptions = LegacyWorkerOptions & {
  /** @deprecated Use `cacheAPI` instead. */
  cache?: LegacyWorkerOptions["cacheAPI"];
};
type SourcelessWorkerOptions = Omit<CompatibleWorkerOptions, "script" | "scriptPath" | "modules" | "modulesRoot"> & {
  modulesRules?: V4ModuleRule[];
};
type WorkersPoolOptions = z.input<typeof WorkersPoolOptionsSchema> & {
  miniflare?: SourcelessWorkerOptions & {
    workers?: CompatibleWorkerOptions[];
  };
};
type WorkersPoolOptionsWithDefines = WorkersPoolOptions & {
  defines?: Record<string, string>;
  moduleRules?: V4ModuleRule[];
};
//#endregion
//#region src/pool/plugin.d.ts
type ProvidedContextKeys = keyof ProvidedContext & string;
declare const explicitInjectTypeArgumentRequired: unique symbol;
type ExplicitInjectTypeArgumentRequired = {
  readonly [explicitInjectTypeArgumentRequired]: never;
};
type WorkerPoolOptionsContextInject = [ProvidedContextKeys] extends [never] ? <T = unknown>(key: string) => T : {
  <K extends ProvidedContextKeys>(key: K): ProvidedContext[K];
  <T = ExplicitInjectTypeArgumentRequired>(key: string & (T extends ExplicitInjectTypeArgumentRequired ? never : unknown)): T;
};
interface WorkerPoolOptionsContext {
  /**
   * Access values provided by `globalSetup()` (e.g. ports of servers started
   * during setup) for use in Miniflare options (e.g. bindings, upstream,
   * hyperdrives, ...).
   *
   * Known `ProvidedContext` keys preserve Vitest's inference and key checking
   * when the consuming project's augmentation is visible. Use an explicit type
   * argument for keys provided at runtime but not declared in `ProvidedContext`.
   * If pnpm resolves a separate Vitest copy and the keys collapse to `never`,
   * fall back to the wider inject signature instead.
   */
  inject: WorkerPoolOptionsContextInject;
}
declare function cloudflareTest(options: WorkersPoolOptions | ((ctx: WorkerPoolOptionsContext) => Promise<WorkersPoolOptions> | WorkersPoolOptions)): Vite.Plugin;
//#endregion
//#region src/pool/pool.d.ts
declare function cloudflarePool(poolOptions: WorkersPoolOptions | ((ctx: WorkerPoolOptionsContext) => Promise<WorkersPoolOptions> | WorkersPoolOptions)): PoolRunnerInitializer;
//#endregion
//#region src/shared/d1.d.ts
type D1Migration = {
  name: string;
  queries: string[];
};
//#endregion
//#region src/pool/d1.d.ts
/**
 * Reads all migrations in `migrationsPath`, ordered by migration number.
 * Each migration will have its contents split into an array of SQL queries.
 */
declare function readD1Migrations(migrationsPath: string): Promise<D1Migration[]>;
//#endregion
//#region src/pool/pages.d.ts
declare function poolWorkerStarted(): void;
declare function poolWorkerStopped(): void;
declare function buildPagesASSETSBinding(assetsPath: string): Promise<(request: Request) => Promise<Response>>;
//#endregion
//#region src/pool/index.d.ts
declare function structuredSerializableStringify(value: unknown): string;
declare function structuredSerializableParse(value: string): unknown;
declare function getRunnerName(project: TestProject, testFile?: string): string;
interface DurableObjectDesignator {
  className: string;
  scriptName?: string;
  unsafeUniqueKey?: string;
}
/**
 * Returns a map of Durable Objects bindings' bound names to the designators of
 * the objects they point to.
 */
declare function getDurableObjectDesignators(options: WorkersPoolOptions): Map<string, DurableObjectDesignator>;
declare function getProjectMiniflare(ctx: Vitest, project: TestProject, poolOptions: WorkersPoolOptionsWithDefines, main: string | undefined): Promise<Miniflare>;
declare function maybeGetResolvedMainPath(project: TestProject, options: WorkersPoolOptionsWithDefines): string | undefined;
declare function connectToMiniflareSocket(mf: Miniflare, workerName: string): Promise<miniflare0.WebSocket>;
declare function assertCompatibleVitestVersion(ctx: Vitest): void;
//#endregion
export { type D1Migration, assertCompatibleVitestVersion, buildPagesASSETSBinding, cloudflarePool, cloudflareTest, connectToMiniflareSocket, getDurableObjectDesignators, getProjectMiniflare, getRunnerName, maybeGetResolvedMainPath, poolWorkerStarted, poolWorkerStopped, readD1Migrations, structuredSerializableParse, structuredSerializableStringify };
//# sourceMappingURL=index.d.mts.map