///
import { Awaitable } from '@miniflare/shared';
import { BeforeSetupResult } from '@miniflare/shared';
import { Blob as Blob_2 } from 'buffer';
import { BodyInit } from 'undici';
import { CompatibilityFlag } from '@miniflare/shared';
import { Context } from '@miniflare/shared';
import { Dispatcher } from 'undici';
import { FormData } from 'undici';
import { Headers } from 'undici';
import { HeadersInit } from 'undici';
import http from 'http';
import { Log } from '@miniflare/shared';
import { MessageBatch } from '@miniflare/shared';
import { MiniflareError } from '@miniflare/shared';
import { MockAgent } from 'undici';
import { ModuleRule } from '@miniflare/shared';
import { Mount } from '@miniflare/shared';
import { Options } from '@miniflare/shared';
import { Plugin } from '@miniflare/shared';
import { PluginContext } from '@miniflare/shared';
import { PluginSignatures } from '@miniflare/shared';
import { ProcessedModuleRule } from '@miniflare/shared';
import { QueueBroker } from '@miniflare/queues';
import { ReadableStream } from 'stream/web';
import { Request as Request_2 } from 'undici';
import { RequestCache } from 'undici';
import { RequestCredentials } from 'undici';
import { RequestDestination } from 'undici';
import { RequestInfo as RequestInfo_2 } from 'undici';
import { RequestInit as RequestInit_2 } from 'undici';
import { RequestMode } from 'undici';
import { RequestRedirect } from 'undici';
import { Response as Response_2 } from 'undici';
import { ResponseInit as ResponseInit_2 } from 'undici';
import { ResponseRedirectStatus } from 'undici';
import { ResponseType } from 'undici';
import { ScriptRunner } from '@miniflare/shared';
import { SetupResult } from '@miniflare/shared';
import { Storage } from '@miniflare/shared';
import { StorageFactory } from '@miniflare/shared';
import { ThrowingEventTarget } from '@miniflare/shared';
import { TransformStream } from 'stream/web';
import { TransformStreamDefaultController } from 'stream/web';
import { TypedEventListener } from '@miniflare/shared';
import { TypedEventTarget } from '@miniflare/shared';
import { URL as URL_2 } from 'url';
import { UsageModel } from '@miniflare/shared';
import { webcrypto } from 'crypto';
import type { WebSocket as WebSocket_2 } from '@miniflare/web-sockets';
import { WranglerConfig } from '@miniflare/shared';
import { WritableStream } from 'stream/web';
declare const AbortSignal_2: {
new (): AbortSignal;
prototype: AbortSignal;
};
export { AbortSignal_2 as AbortSignal }
export declare type ArrayBufferViewConstructor = typeof Int8Array | typeof Uint8Array | typeof Uint8ClampedArray | typeof Int16Array | typeof Uint16Array | typeof Int32Array | typeof Uint32Array | typeof Float32Array | typeof Float64Array | typeof DataView;
declare function atob_2(input: string): string;
export { atob_2 as atob }
export declare interface BasicImageTransformations {
width?: number;
height?: number;
fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
gravity?: "left" | "right" | "top" | "bottom" | "center" | BasicImageTransformationsGravityCoordinates;
background?: string;
rotate?: 0 | 90 | 180 | 270 | 360;
}
export declare interface BasicImageTransformationsGravityCoordinates {
x: number;
y: number;
}
export declare interface BindingsOptions {
envPath?: boolean | string;
envPathDefaultFallback?: boolean;
bindings?: Record;
globals?: Record;
wasmBindings?: Record;
textBlobBindings?: Record;
dataBlobBindings?: Record;
serviceBindings?: ServiceBindingsOptions;
}
export declare class BindingsPlugin extends Plugin implements BindingsOptions {
#private;
envPath?: boolean | string;
[kWranglerBindings]?: Record;
envPathDefaultFallback?: boolean;
bindings?: Record;
globals?: Record;
wasmBindings?: Record;
textBlobBindings?: Record;
dataBlobBindings?: Record;
serviceBindings?: ServiceBindingsOptions;
constructor(ctx: PluginContext, options?: BindingsOptions);
setup(): Promise;
beforeReload(): void;
reload(bindings: Context, moduleExports: Context, mounts: Map): void;
dispose(): void;
}
export declare class Body {
/* Excluded from this release type: [_kInner] */
[kInputGated]: boolean;
[kFormDataFiles]: boolean;
[kCloned]: boolean;
[kBodyStream]?: ReadableStream;
constructor(inner: Inner);
[inspect](): Inner;
get headers(): Headers;
get body(): ReadableStream | null;
get bodyUsed(): boolean;
arrayBuffer(): Promise;
blob(): Promise;
formData(): Promise;
json(): Promise;
text(): Promise;
}
export { BodyInit }
declare function btoa_2(input: string): string;
export { btoa_2 as btoa }
export declare class BuildError extends MiniflareError {
}
export declare interface BuildOptions {
buildCommand?: string;
buildBasePath?: string;
buildWatchPaths?: string[];
}
export declare class BuildPlugin extends Plugin implements BuildOptions {
buildCommand?: string;
buildBasePath?: string;
buildWatchPaths?: string[];
constructor(ctx: PluginContext, options?: BuildOptions);
beforeSetup(): Awaitable;
}
/* Excluded from this release type: _buildUnknownProtocolWarning */
export declare class CompressionStream extends TransformStream {
constructor(format: "gzip" | "deflate");
}
/* Excluded from this release type: _CoreMount */
export declare interface CoreOptions {
script?: string;
scriptPath?: string;
rootPath?: string;
packagePath?: boolean | string;
wranglerConfigPath?: boolean | string;
wranglerConfigEnv?: string;
modules?: boolean;
modulesRules?: ModuleRule[];
compatibilityDate?: string;
compatibilityFlags?: CompatibilityFlag[];
usageModel?: "bundled" | "unbound";
upstream?: string;
watch?: boolean;
debug?: boolean;
verbose?: boolean;
updateCheck?: boolean;
repl?: boolean;
mounts?: Record;
name?: string;
routes?: string[];
logUnhandledRejections?: boolean;
fetchMock?: MockAgent;
globalAsyncIO?: boolean;
globalTimers?: boolean;
globalRandom?: boolean;
actualTime?: boolean;
inaccurateCpu?: boolean;
}
export declare class CorePlugin extends Plugin implements CoreOptions {
#private;
script?: string;
scriptPath?: string;
wranglerConfigPath?: boolean | string;
wranglerConfigEnv?: string;
packagePath?: boolean | string;
modules?: boolean;
modulesRules?: ModuleRule[];
compatibilityDate?: string;
compatibilityFlags?: CompatibilityFlag[];
usageModel?: "bundled" | "unbound";
upstream?: string;
watch?: boolean;
debug?: boolean;
verbose?: boolean;
updateCheck?: boolean;
repl?: boolean;
rootPath?: string;
mounts?: Record;
name?: string;
routes?: string[];
logUnhandledRejections?: boolean;
fetchMock?: MockAgent;
globalAsyncIO?: boolean;
globalTimers?: boolean;
globalRandom?: boolean;
actualTime?: boolean;
inaccurateCpu?: boolean;
readonly processedModuleRules: ProcessedModuleRule[];
readonly upstreamURL?: URL_2;
constructor(ctx: PluginContext, options?: CoreOptions);
setup(): Promise;
}
export declare type CorePluginSignatures = PluginSignatures & {
CorePlugin: typeof CorePlugin;
};
export declare function createCompatFetch({ log, compat, globalAsyncIO, }: Pick, inner?: typeof fetch): typeof fetch;
export declare function createCrypto(blockGlobalRandom?: boolean): WorkerCrypto;
export declare function createDate(actualTime?: boolean): typeof Date;
export declare function createFetchMock(): MockAgent;
export declare function createTimer(func: TimerFunction, blockGlobalTimers?: boolean): TimerFunction;
declare const CryptoKey_2: webcrypto.CryptoKeyConstructor;
export { CryptoKey_2 as CryptoKey }
export declare class DecompressionStream extends TransformStream {
constructor(format: "gzip" | "deflate");
}
/* Excluded from this release type: _deepEqual */
export declare class DigestStream extends WritableStream {
readonly digest: Promise;
constructor(algorithm: webcrypto.AlgorithmIdentifier);
}
export declare const DOM_EXCEPTION_NAMES: {
IndexSizeError: number;
DOMStringSizeError: number;
HierarchyRequestError: number;
WrongDocumentError: number;
InvalidCharacterError: number;
NoDataAllowedError: number;
NoModificationAllowedError: number;
NotFoundError: number;
NotSupportedError: number;
InUseAttributeError: number;
InvalidStateError: number;
SyntaxError: number;
InvalidModificationError: number;
NamespaceError: number;
InvalidAccessError: number;
ValidationError: number;
TypeMismatchError: number;
SecurityError: number;
NetworkError: number;
AbortError: number;
URLMismatchError: number;
QuotaExceededError: number;
TimeoutError: number;
InvalidNodeTypeError: number;
DataCloneError: number;
};
export declare class DOMException extends Error {
readonly name: keyof typeof DOM_EXCEPTION_NAMES | string;
static readonly INDEX_SIZE_ERR = 1;
static readonly DOMSTRING_SIZE_ERR = 2;
static readonly HIERARCHY_REQUEST_ERR = 3;
static readonly WRONG_DOCUMENT_ERR = 4;
static readonly INVALID_CHARACTER_ERR = 5;
static readonly NO_DATA_ALLOWED_ERR = 6;
static readonly NO_MODIFICATION_ALLOWED_ERR = 7;
static readonly NOT_FOUND_ERR = 8;
static readonly NOT_SUPPORTED_ERR = 9;
static readonly INUSE_ATTRIBUTE_ERR = 10;
static readonly INVALID_STATE_ERR = 11;
static readonly SYNTAX_ERR = 12;
static readonly INVALID_MODIFICATION_ERR = 13;
static readonly NAMESPACE_ERR = 14;
static readonly INVALID_ACCESS_ERR = 15;
static readonly VALIDATION_ERR = 16;
static readonly TYPE_MISMATCH_ERR = 17;
static readonly SECURITY_ERR = 18;
static readonly NETWORK_ERR = 19;
static readonly ABORT_ERR = 20;
static readonly URL_MISMATCH_ERR = 21;
static readonly QUOTA_EXCEEDED_ERR = 22;
static readonly TIMEOUT_ERR = 23;
static readonly INVALID_NODE_TYPE_ERR = 24;
static readonly DATA_CLONE_ERR = 25;
constructor(message?: string, name?: keyof typeof DOM_EXCEPTION_NAMES | string);
get code(): number;
}
export declare class ExecutionContext {
#private;
constructor(event: FetchEvent | ScheduledEvent | QueueEvent);
passThroughOnException(): void;
waitUntil(promise: Awaitable): void;
}
export declare function fetch(this: Dispatcher | unknown, input: RequestInfo, init?: RequestInit): Promise;
export declare class Fetcher {
#private;
constructor(service: string | FetcherFetch, getServiceFetch: (name: string) => Promise, defaultUsageModel?: UsageModel);
fetch(input: RequestInfo, init?: RequestInit): Promise;
}
export declare type FetcherFetch = (request: Request) => Awaitable;
export declare interface FetcherFetchWithUsageModel {
fetch: FetcherFetch;
usageModel?: UsageModel;
}
export declare class FetchError extends MiniflareError {
}
export declare type FetchErrorCode = "ERR_RESPONSE_TYPE" | "ERR_NO_UPSTREAM" | "ERR_NO_HANDLER" | "ERR_NO_RESPONSE";
export declare class FetchEvent extends Event {
readonly request: Request;
[kResponse]?: Promise;
[kPassThrough]: boolean;
readonly [kWaitUntil]: Promise[];
[kSent]: boolean;
constructor(type: "fetch", init: {
request: Request;
});
respondWith(response: Awaitable): void;
passThroughOnException(): void;
waitUntil(promise: Awaitable): void;
}
export declare class FixedLengthStream extends IdentityTransformStream {
#private;
constructor(expectedLength: number);
[kTransformHook]: (chunk: Uint8Array, controller: TransformStreamDefaultController) => boolean;
[kFlushHook]: (controller: TransformStreamDefaultController) => void;
}
/* Excluded from this release type: _getBodyLength */
export declare function getRangeResponse(requestRangeHeader: string, responseStatus: number, responseHeaders: Headers, responseBody: Uint8Array): Response;
/* Excluded from this release type: _getURLList */
export { Headers }
/* Excluded from this release type: _headersFromIncomingRequest */
export { HeadersInit }
export declare type HRTime = [seconds: number, nanoseconds: number];
export declare class IdentityTransformStream extends TransformStream {
#private;
[kTransformHook]?: (chunk: Uint8Array, controller: TransformStreamDefaultController) => boolean;
[kFlushHook]?: (controller: TransformStreamDefaultController) => void;
constructor();
get readable(): ReadableStream;
}
export declare interface IncomingRequestCfProperties {
asn: number;
botManagement?: IncomingRequestCfPropertiesBotManagement;
city?: string;
clientAcceptEncoding?: string;
clientTcpRtt: number;
clientTrustScore?: number;
colo: string;
continent?: string;
country: string;
httpProtocol: string;
latitude?: string;
longitude?: string;
metroCode?: string;
postalCode?: string;
region?: string;
regionCode?: string;
requestPriority: string;
timezone?: string;
tlsVersion: string;
tlsCipher: string;
tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth;
}
export declare interface IncomingRequestCfPropertiesBotManagement {
score: number;
staticResource: boolean;
verifiedBot: boolean;
}
export declare interface IncomingRequestCfPropertiesTLSClientAuth {
certIssuerDNLegacy: string;
certIssuerDN: string;
certPresented: "0" | "1";
certSubjectDNLegacy: string;
certSubjectDN: string;
certNotBefore: string;
certNotAfter: string;
certSerial: string;
certFingerprintSHA1: string;
certVerified: string;
}
declare const inspect: unique symbol;
/* Excluded from this release type: _isBodyStream */
/* Excluded from this release type: _isByteStream */
/* Excluded from this release type: _isDisturbedStream */
/* Excluded from this release type: _isFixedLengthStream */
export declare const kAddModuleFetchListener: unique symbol;
export declare const kAddModuleQueueListener: unique symbol;
export declare const kAddModuleScheduledListener: unique symbol;
declare const kBodyStream: unique symbol;
declare const kCloned: unique symbol;
export declare const kDispatchFetch: unique symbol;
export declare const kDispatchQueue: unique symbol;
export declare const kDispatchScheduled: unique symbol;
export declare const kDispose: unique symbol;
declare const kFlushHook: unique symbol;
declare const kFormDataFiles: unique symbol;
/* Excluded from this release type: _kInner */
declare const kInputGated: unique symbol;
/* Excluded from this release type: _kLoopHeader */
declare const kParentSharedCache: unique symbol;
declare const kPassThrough: unique symbol;
declare const kResponse: unique symbol;
declare const kSent: unique symbol;
declare const kTransformHook: unique symbol;
export declare const kWaitUntil: unique symbol;
declare const kWaitUntil_2: unique symbol;
declare const kWranglerBindings: unique symbol;
export declare function logResponse(log: Log, { start, startCpu, method, url, status, waitUntil, }: {
start: HRTime;
startCpu?: NodeJS.CpuUsage;
method: string;
url: string;
status?: number;
waitUntil?: Promise;
}): Promise;
export declare class MiniflareCore extends TypedEventTarget> {
#private;
constructor(plugins: Plugins, ctx: MiniflareCoreContext, options?: MiniflareCoreOptions);
get log(): Log;
reload(): Promise;
setOptions(options: MiniflareCoreOptions, dispatchReloadEvent?: boolean): Promise;
getPluginStorage(name: keyof Plugins): StorageFactory;
getPlugins(): Promise>;
getGlobalScope(): Promise;
getBindings(): Promise;
getModuleExports(): Promise;
getMount(name: string): Promise>;
dispatchFetch(input: RequestInfo, init?: RequestInit): Promise>;
[kDispatchFetch](request: Request, proxy: boolean): Promise>;
dispatchScheduled(scheduledTime?: number, cron?: string, url?: string | URL_2): Promise;
dispatchQueue(batch: MessageBatch): Promise;
dispose(): Promise;
}
export declare interface MiniflareCoreContext {
log: Log;
storageFactory: StorageFactory;
queueBroker: QueueBroker;
scriptRunner?: ScriptRunner;
scriptRequired?: boolean;
scriptRunForModuleExports?: boolean;
/* Excluded from this release type: [kParentSharedCache] */
}
export declare class MiniflareCoreError extends MiniflareError {
}
export declare type MiniflareCoreErrorCode = "ERR_NO_SCRIPT" | "ERR_MOUNT_NO_NAME" | "ERR_MOUNT_NESTED" | "ERR_MOUNT" | "ERR_MOUNT_NAME_MISMATCH" | "ERR_SERVICE_NOT_MOUNTED" | "ERR_SERVICE_NO_NAME" | "ERR_SERVICE_NAME_MISMATCH" | "ERR_INVALID_UPSTREAM";
export declare type MiniflareCoreEventMap = {
reload: ReloadEvent;
};
export declare type MiniflareCoreOptions = Omit, "mounts"> & {
mounts?: Record, "mounts">>;
};
export declare type ModuleFetchListener = (request: Request, env: Context, ctx: ExecutionContext) => Response | Promise;
export declare type ModuleQueueListener = (batch: MessageBatch, env: Context, ctx: ExecutionContext) => any;
export declare type ModuleScheduledListener = (controller: ScheduledController, env: Context, ctx: ExecutionContext) => any;
export declare class Navigator {
readonly userAgent = "Cloudflare-Workers";
}
/**
* Parses an HTTP `Range` header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range),
* returning either:
* - `undefined` indicating the range is unsatisfiable
* - An empty array indicating the entire response should be returned
* - A non-empty array of inclusive ranges of the response to return
*/
export declare function parseRanges(rangeHeader: string, length: number): [start: number, end: number][] | undefined;
export declare type PluginInstances = {
[K in keyof Plugins]: InstanceType;
};
export declare class PluginStorageFactory implements StorageFactory {
private readonly inner;
private readonly defaultPersistRoot;
private readonly pluginName;
constructor(inner: StorageFactory, pluginName: string, defaultPersistRoot?: string);
storage(namespace: string, persist?: boolean | string): Storage;
dispose(): Awaitable;
}
/* Excluded from this release type: _populateBuildConfig */
export declare class PromiseRejectionEvent extends Event {
readonly promise: Promise;
readonly reason?: any;
constructor(type: "unhandledrejection" | "rejectionhandled", init: {
promise: Promise;
reason?: any;
});
}
export declare class QueueEvent extends Event {
readonly batch: MessageBatch;
readonly [kWaitUntil]: Promise[];
constructor(type: "queue", init: {
batch: MessageBatch;
});
waitUntil(promise: Promise): void;
}
export declare class ReloadEvent extends Event {
readonly plugins: PluginInstances;
readonly initial: boolean;
constructor(type: "reload", init: {
plugins: PluginInstances;
initial: boolean;
});
}
export declare class Request extends Body {
#private;
constructor(input: RequestInfo, init?: RequestInit);
clone(): Request;
get method(): string;
get url(): string;
get redirect(): RequestRedirect;
get signal(): AbortSignal;
get cf(): IncomingRequestCfProperties | RequestInitCfProperties | undefined;
get context(): never;
get mode(): never;
get credentials(): never;
get integrity(): never;
get cache(): never;
}
export { RequestCache }
export { RequestCredentials }
export { RequestDestination }
export declare type RequestInfo = RequestInfo_2 | Request;
export declare interface RequestInit extends RequestInit_2 {
cf?: IncomingRequestCfProperties | RequestInitCfProperties;
}
export declare interface RequestInitCfProperties {
cacheEverything?: boolean;
cacheKey?: string;
cacheTtl?: number;
cacheTtlByStatus?: Record;
scrapeShield?: boolean;
apps?: boolean;
image?: RequestInitCfPropertiesImage;
minify?: RequestInitCfPropertiesImageMinify;
mirage?: boolean;
resolveOverride?: string;
}
export declare interface RequestInitCfPropertiesImage extends BasicImageTransformations {
dpr?: number;
quality?: number;
format?: "avif" | "webp" | "json";
metadata?: "keep" | "copyright" | "none";
draw?: RequestInitCfPropertiesImageDraw[];
}
export declare interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
url: string;
opacity?: number;
repeat?: true | "x" | "y";
top?: number;
left?: number;
bottom?: number;
right?: number;
}
export declare interface RequestInitCfPropertiesImageMinify {
javascript?: boolean;
css?: boolean;
html?: boolean;
}
export { RequestMode }
export { RequestRedirect }
export declare class Response extends Body {
#private;
static redirect(url: string | URL_2, status?: ResponseRedirectStatus): Response;
static json(data: any, init?: ResponseInit): Response;
[kWaitUntil_2]?: Promise;
constructor(body?: BodyInit, init?: ResponseInit | Response | Response_2);
clone(): Response;
get encodeBody(): "automatic" | "manual";
get webSocket(): WebSocket_2 | undefined;
waitUntil(): Promise;
get status(): number;
get statusText(): string;
get ok(): boolean;
get redirected(): boolean;
get url(): string;
get type(): never;
get useFinalUrl(): never;
}
export declare interface ResponseInit extends ResponseInit_2 {
readonly encodeBody?: "automatic" | "manual";
readonly webSocket?: WebSocket_2;
}
export { ResponseRedirectStatus }
export { ResponseType }
export declare interface Route {
target: string;
route: string;
protocol?: string;
allowHostnamePrefix: boolean;
hostname: string;
path: string;
allowPathSuffix: boolean;
}
export declare class Router {
routes: Route[];
update(allRoutes: Map): void;
match(url: URL_2): string | null;
}
export declare class RouterError extends MiniflareError {
}
export declare type RouterErrorCode = "ERR_QUERY_STRING" | "ERR_INFIX_WILDCARD";
export declare class ScheduledController {
readonly scheduledTime: number;
readonly cron: string;
constructor(scheduledTime: number, cron: string);
}
export declare class ScheduledEvent extends Event {
readonly scheduledTime: number;
readonly cron: string;
readonly [kWaitUntil]: Promise[];
constructor(type: "scheduled", init: {
scheduledTime: number;
cron: string;
});
waitUntil(promise: Promise): void;
}
export declare class Scheduler {
#private;
constructor(blockGlobalTimers?: boolean);
wait(ms?: number, options?: SchedulerWaitOptions): Promise;
}
export declare interface SchedulerWaitOptions {
signal?: AbortSignal;
}
export declare type ServiceBindingsOptions = Record;
export declare class ServiceWorkerGlobalScope extends WorkerGlobalScope {
#private;
readonly global: this;
readonly self: this;
constructor(log: Log, globals: Context, bindings: Context, modules?: boolean, logUnhandledRejections?: boolean);
addEventListener: (type: Type, listener: TypedEventListener | null, options?: boolean | AddEventListenerOptions | undefined) => void;
removeEventListener: (type: Type, listener: TypedEventListener | null, options?: boolean | EventListenerOptions | undefined) => void;
[kAddModuleFetchListener](listener: ModuleFetchListener): void;
[kAddModuleScheduledListener](listener: ModuleScheduledListener): void;
[kAddModuleQueueListener](listener: ModuleQueueListener): void;
[kDispatchFetch](request: Request, proxy?: boolean): Promise>;
[kDispatchScheduled](scheduledTime?: number, cron?: string): Promise;
[kDispatchQueue](batch: MessageBatch): Promise;
[kDispose](): void;
}
export declare type TimerFunction = (callback: (...args: Args) => void, ms?: number, ...args: Args) => Return;
/* Excluded from this release type: _urlFromRequestInput */
export declare function waitUntilAll(promises: Promise[]): Promise;
export declare function withImmutableHeaders(body: Body): Body;
export declare function withInputGating>(body: Inner): Inner;
export declare function withStringFormDataFiles>(body: Inner): Inner;
export declare function withWaitUntil(res: Response | Response_2, waitUntil: Promise): Response;
export declare type WorkerCrypto = typeof webcrypto & {
DigestStream: typeof DigestStream;
};
export declare class WorkerGlobalScope extends ThrowingEventTarget {
}
export declare type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
scheduled: ScheduledEvent;
queue: QueueEvent;
unhandledrejection: PromiseRejectionEvent;
rejectionhandled: PromiseRejectionEvent;
};
export { }