import * as streams from "web-streams-polyfill"; /* * These imports use weird names bc otherwise we'll run into naming conflicts with * the declarations below. */ import * as cnsole from "./src/console"; import * as ev from "./src/event/request"; import * as ftch from "./src/fetch/function"; import * as hdrs from "./src/http/headers"; import * as req from "./src/http/request"; import * as res from "./src/http/response"; import * as io from "./src/io/io"; import * as dec from "./src/text/decoding"; import * as enc from "./src/text/encoding"; import * as url from "./src/types/url"; /* * We use this type of "double declaration" below to inject a constant and a type * into the global scope. * * Both are necessary to make expressions work like: * * `const decoder: TextDecoder = new TextDecoder();` * ^^^^^^^^^^^ ^^^^^^^^^^^ * uses type uses const */ declare global { /** * The type of an edge handler function. * * Takes as parameter a descriptor of the incoming HTTP request. * * @param ev A descriptor of the incoming HTTP request. */ type EdgeHandler = (ev: ev.RequestEvent) => void; const console: typeof cnsole.console; type EventRequest = ev.EventRequest; type RequestEvent = ev.RequestEvent; type RequestMeta = ev.RequestMeta; type Location = ev.Location; type LocationData = ev.LocationData; type UserContext = ev.UserContext; const fetch: typeof ftch.fetch; type FetchError = ftch.FetchError; const FetchError: typeof ftch.FetchError; type HeadersInit = hdrs.HeadersInit; type Headers = hdrs.Headers; const Headers: typeof hdrs.Headers; type HttpBody = req.HttpBody; type Method = req.Method; type RedirectPolicy = req.RedirectPolicy; type RequestInit = req.RequestInit; type Request = req.Request; const Request: typeof req.Request; type ResponseInit = res.ResponseInit; type Response = res.Response; const Response: typeof res.Response; type TextDecoderOptions = dec.TextDecoderOptions; type DecodeOptions = dec.DecodeOptions; type TextDecoder = dec.TextDecoder; const TextDecoder: typeof dec.TextDecoder; type TextEncoder = enc.TextEncoder; const TextEncoder: typeof enc.TextEncoder; type URL = url.URL; const URL: typeof url.URL; type URLSearchParams = url.URLSearchParams; const URSearchParams: typeof url.URLSearchParams; // Type Definitions type AbortSignal = streams.AbortSignal; type QueuingStrategy = streams.QueuingStrategy; type QueuingStrategyInit = streams.QueuingStrategyInit; type ReadableStreamAsyncIterator = streams.ReadableStreamAsyncIterator; type ReadableStreamBYOBReadResult = streams.ReadableStreamBYOBReadResult; type ReadableStreamDefaultReadResult = streams.ReadableStreamDefaultReadResult; type ReadableStreamIteratorOptions = streams.ReadableStreamIteratorOptions; type ReadableWritablePair = streams.ReadableWritablePair; type StreamPipeOptions = streams.StreamPipeOptions; type Transformer = streams.Transformer; type TransformerFlushCallback = streams.TransformerFlushCallback; type TransformerStartCallback = streams.TransformerStartCallback; type TransformerTransformCallback = streams.TransformerTransformCallback< I, O >; type UnderlyingByteSource = streams.UnderlyingByteSource; type UnderlyingByteSourcePullCallback = streams.UnderlyingByteSourcePullCallback; type UnderlyingByteSourceStartCallback = streams.UnderlyingByteSourceStartCallback; type UnderlyingSink = streams.UnderlyingSink; type UnderlyingSinkAbortCallback = streams.UnderlyingSinkAbortCallback; type UnderlyingSinkCloseCallback = streams.UnderlyingSinkCloseCallback; type UnderlyingSinkStartCallback = streams.UnderlyingSinkStartCallback; type UnderlyingSinkWriteCallback = streams.UnderlyingSinkWriteCallback; type UnderlyingSource = streams.UnderlyingSource; type UnderlyingSourceCancelCallback = streams.UnderlyingSourceCancelCallback; type UnderlyingSourcePullCallback = streams.UnderlyingSourcePullCallback; type UnderlyingSourceStartCallback = streams.UnderlyingSourceStartCallback; // Classes type ByteLengthQueuingStrategy = streams.ByteLengthQueuingStrategy; const ByteLengthQueuingStrategy: typeof streams.ByteLengthQueuingStrategy; type CountQueuingStrategy = streams.CountQueuingStrategy; const CountQueuingStrategy: typeof streams.CountQueuingStrategy; type ReadableByteStreamController = streams.ReadableByteStreamController; const ReadableByteStreamController: typeof streams.ReadableByteStreamController; type ReadableStream = streams.ReadableStream; const ReadableStream: typeof streams.ReadableStream; type ReadableStreamBYOBReader = streams.ReadableStreamBYOBReader; const ReadableStreamBYOBReader: typeof streams.ReadableStreamBYOBReader; type ReadableStreamBYOBRequest = streams.ReadableStreamBYOBRequest; const ReadableStreamBYOBRequest: typeof streams.ReadableStreamBYOBRequest; type ReadableStreamDefaultController = streams.ReadableStreamDefaultController; const ReadableStreamDefaultController: typeof streams.ReadableStreamDefaultController; type ReadableStreamDefaultReader = streams.ReadableStreamDefaultReader; const ReadableStreamDefaultReader: typeof streams.ReadableStreamDefaultReader; type TransformStream = streams.TransformStream; const TransformStream: typeof streams.TransformStream; type TransformStreamDefaultController = streams.TransformStreamDefaultController; const TransformStreamDefaultController: typeof streams.TransformStreamDefaultController; type WritableStream = streams.WritableStream; const WritableStream: typeof streams.WritableStream; type WritableStreamDefaultController = streams.WritableStreamDefaultController; const WritableStreamDefaultController: typeof streams.WritableStreamDefaultController; type WritableStreamDefaultWriter = streams.WritableStreamDefaultWriter; const WritableStreamDefaultWriter: typeof streams.WritableStreamDefaultWriter; }