Commit e18ae3f6 authored by Spark's avatar Spark
Browse files

node_modules remove

parent 8503f806
declare module 'util' {
import * as types from 'util/types';
export interface InspectOptions extends NodeJS.InspectOptions { }
export type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module';
export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string;
export interface InspectOptionsStylized extends InspectOptions {
stylize(text: string, styleType: Style): string;
}
export function format(format?: any, ...param: any[]): string;
export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
/** @deprecated since v0.11.3 - use a third party module instead. */
export function log(string: string): void;
export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
export function inspect(object: any, options: InspectOptions): string;
export namespace inspect {
let colors: NodeJS.Dict<[number, number]>;
let styles: {
[K in Style]: string
};
let defaultOptions: InspectOptions;
/**
* Allows changing inspect settings from the repl.
*/
let replDefaults: InspectOptions;
const custom: unique symbol;
}
/** @deprecated since v4.0.0 - use `Array.isArray()` instead. */
export function isArray(object: any): object is any[];
/** @deprecated since v4.0.0 - use `util.types.isRegExp()` instead. */
export function isRegExp(object: any): object is RegExp;
/** @deprecated since v4.0.0 - use `util.types.isDate()` instead. */
export function isDate(object: any): object is Date;
/** @deprecated since v4.0.0 - use `util.types.isNativeError()` instead. */
export function isError(object: any): object is Error;
export function inherits(constructor: any, superConstructor: any): void;
export function debuglog(key: string): (msg: string, ...param: any[]) => void;
/** @deprecated since v4.0.0 - use `typeof value === 'boolean'` instead. */
export function isBoolean(object: any): object is boolean;
/** @deprecated since v4.0.0 - use `Buffer.isBuffer()` instead. */
export function isBuffer(object: any): object is Buffer;
/** @deprecated since v4.0.0 - use `typeof value === 'function'` instead. */
export function isFunction(object: any): boolean;
/** @deprecated since v4.0.0 - use `value === null` instead. */
export function isNull(object: any): object is null;
/** @deprecated since v4.0.0 - use `value === null || value === undefined` instead. */
export function isNullOrUndefined(object: any): object is null | undefined;
/** @deprecated since v4.0.0 - use `typeof value === 'number'` instead. */
export function isNumber(object: any): object is number;
/** @deprecated since v4.0.0 - use `value !== null && typeof value === 'object'` instead. */
export function isObject(object: any): boolean;
/** @deprecated since v4.0.0 - use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead. */
export function isPrimitive(object: any): boolean;
/** @deprecated since v4.0.0 - use `typeof value === 'string'` instead. */
export function isString(object: any): object is string;
/** @deprecated since v4.0.0 - use `typeof value === 'symbol'` instead. */
export function isSymbol(object: any): object is symbol;
/** @deprecated since v4.0.0 - use `value === undefined` instead. */
export function isUndefined(object: any): object is undefined;
export function deprecate<T extends Function>(fn: T, message: string, code?: string): T;
export function isDeepStrictEqual(val1: any, val2: any): boolean;
export function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<TResult>(fn: () => Promise<TResult>): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1>(fn: (arg1: T1) => Promise<void>): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, TResult>(fn: (arg1: T1) => Promise<TResult>): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2>(fn: (arg1: T1, arg2: T2) => Promise<void>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2) => Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
export function callbackify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, T4, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, T5>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, T4, T5, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, T5, T6>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
export interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
__promisify__: TCustom;
}
export interface CustomPromisifySymbol<TCustom extends Function> extends Function {
[promisify.custom]: TCustom;
}
export type CustomPromisify<TCustom extends Function> = CustomPromisifySymbol<TCustom> | CustomPromisifyLegacy<TCustom>;
export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
export function promisify<TResult>(fn: (callback: (err: any, result: TResult) => void) => void): () => Promise<TResult>;
export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
export function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void):
(arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void):
(arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify(fn: Function): Function;
export namespace promisify {
const custom: unique symbol;
}
export class TextDecoder {
readonly encoding: string;
readonly fatal: boolean;
readonly ignoreBOM: boolean;
constructor(
encoding?: string,
options?: { fatal?: boolean; ignoreBOM?: boolean }
);
decode(
input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
options?: { stream?: boolean }
): string;
}
export interface EncodeIntoResult {
/**
* The read Unicode code units of input.
*/
read: number;
/**
* The written UTF-8 bytes of output.
*/
written: number;
}
export { types };
export class TextEncoder {
readonly encoding: string;
encode(input?: string): Uint8Array;
encodeInto(input: string, output: Uint8Array): EncodeIntoResult;
}
}
declare module 'util/types' {
function isAnyArrayBuffer(object: any): object is ArrayBufferLike;
function isArgumentsObject(object: any): object is IArguments;
function isArrayBuffer(object: any): object is ArrayBuffer;
function isArrayBufferView(object: any): object is NodeJS.ArrayBufferView;
function isAsyncFunction(object: any): boolean;
function isBigInt64Array(value: any): value is BigInt64Array;
function isBigUint64Array(value: any): value is BigUint64Array;
function isBooleanObject(object: any): object is Boolean;
function isBoxedPrimitive(object: any): object is String | Number | BigInt | Boolean | Symbol;
function isDataView(object: any): object is DataView;
function isDate(object: any): object is Date;
function isExternal(object: any): boolean;
function isFloat32Array(object: any): object is Float32Array;
function isFloat64Array(object: any): object is Float64Array;
function isGeneratorFunction(object: any): object is GeneratorFunction;
function isGeneratorObject(object: any): object is Generator;
function isInt8Array(object: any): object is Int8Array;
function isInt16Array(object: any): object is Int16Array;
function isInt32Array(object: any): object is Int32Array;
function isMap<T>(
object: T | {},
): object is T extends ReadonlyMap<any, any>
? unknown extends T
? never
: ReadonlyMap<any, any>
: Map<any, any>;
function isMapIterator(object: any): boolean;
function isModuleNamespaceObject(value: any): boolean;
function isNativeError(object: any): object is Error;
function isNumberObject(object: any): object is Number;
function isPromise(object: any): object is Promise<any>;
function isProxy(object: any): boolean;
function isRegExp(object: any): object is RegExp;
function isSet<T>(
object: T | {},
): object is T extends ReadonlySet<any>
? unknown extends T
? never
: ReadonlySet<any>
: Set<any>;
function isSetIterator(object: any): boolean;
function isSharedArrayBuffer(object: any): object is SharedArrayBuffer;
function isStringObject(object: any): object is String;
function isSymbolObject(object: any): object is Symbol;
function isTypedArray(object: any): object is NodeJS.TypedArray;
function isUint8Array(object: any): object is Uint8Array;
function isUint8ClampedArray(object: any): object is Uint8ClampedArray;
function isUint16Array(object: any): object is Uint16Array;
function isUint32Array(object: any): object is Uint32Array;
function isWeakMap(object: any): object is WeakMap<any, any>;
function isWeakSet(object: any): object is WeakSet<any>;
}
declare module 'v8' {
import { Readable } from 'stream';
interface HeapSpaceInfo {
space_name: string;
space_size: number;
space_used_size: number;
space_available_size: number;
physical_space_size: number;
}
// ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
type DoesZapCodeSpaceFlag = 0 | 1;
interface HeapInfo {
total_heap_size: number;
total_heap_size_executable: number;
total_physical_size: number;
total_available_size: number;
used_heap_size: number;
heap_size_limit: number;
malloced_memory: number;
peak_malloced_memory: number;
does_zap_garbage: DoesZapCodeSpaceFlag;
number_of_native_contexts: number;
number_of_detached_contexts: number;
}
interface HeapCodeStatistics {
code_and_metadata_size: number;
bytecode_and_metadata_size: number;
external_script_source_size: number;
}
/**
* Returns an integer representing a "version tag" derived from the V8 version, command line flags and detected CPU features.
* This is useful for determining whether a vm.Script cachedData buffer is compatible with this instance of V8.
*/
function cachedDataVersionTag(): number;
function getHeapStatistics(): HeapInfo;
function getHeapSpaceStatistics(): HeapSpaceInfo[];
function setFlagsFromString(flags: string): void;
/**
* Generates a snapshot of the current V8 heap and returns a Readable
* Stream that may be used to read the JSON serialized representation.
* This conversation was marked as resolved by joyeecheung
* This JSON stream format is intended to be used with tools such as
* Chrome DevTools. The JSON schema is undocumented and specific to the
* V8 engine, and may change from one version of V8 to the next.
*/
function getHeapSnapshot(): Readable;
/**
*
* @param fileName The file path where the V8 heap snapshot is to be
* saved. If not specified, a file name with the pattern
* `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
* generated, where `{pid}` will be the PID of the Node.js process,
* `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from
* the main Node.js thread or the id of a worker thread.
*/
function writeHeapSnapshot(fileName?: string): string;
function getHeapCodeStatistics(): HeapCodeStatistics;
class Serializer {
/**
* Writes out a header, which includes the serialization format version.
*/
writeHeader(): void;
/**
* Serializes a JavaScript value and adds the serialized representation to the internal buffer.
* This throws an error if value cannot be serialized.
*/
writeValue(val: any): boolean;
/**
* Returns the stored internal buffer.
* This serializer should not be used once the buffer is released.
* Calling this method results in undefined behavior if a previous write has failed.
*/
releaseBuffer(): Buffer;
/**
* Marks an ArrayBuffer as having its contents transferred out of band.\
* Pass the corresponding ArrayBuffer in the deserializing context to deserializer.transferArrayBuffer().
*/
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
/**
* Write a raw 32-bit unsigned integer.
*/
writeUint32(value: number): void;
/**
* Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
*/
writeUint64(hi: number, lo: number): void;
/**
* Write a JS number value.
*/
writeDouble(value: number): void;
/**
* Write raw bytes into the serializer’s internal buffer.
* The deserializer will require a way to compute the length of the buffer.
*/
writeRawBytes(buffer: NodeJS.TypedArray): void;
}
/**
* A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
* and only stores the part of their underlying `ArrayBuffers` that they are referring to.
*/
class DefaultSerializer extends Serializer {
}
class Deserializer {
constructor(data: NodeJS.TypedArray);
/**
* Reads and validates a header (including the format version).
* May, for example, reject an invalid or unsupported wire format.
* In that case, an Error is thrown.
*/
readHeader(): boolean;
/**
* Deserializes a JavaScript value from the buffer and returns it.
*/
readValue(): any;
/**
* Marks an ArrayBuffer as having its contents transferred out of band.
* Pass the corresponding `ArrayBuffer` in the serializing context to serializer.transferArrayBuffer()
* (or return the id from serializer._getSharedArrayBufferId() in the case of SharedArrayBuffers).
*/
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
/**
* Reads the underlying wire format version.
* Likely mostly to be useful to legacy code reading old wire format versions.
* May not be called before .readHeader().
*/
getWireFormatVersion(): number;
/**
* Read a raw 32-bit unsigned integer and return it.
*/
readUint32(): number;
/**
* Read a raw 64-bit unsigned integer and return it as an array [hi, lo] with two 32-bit unsigned integer entries.
*/
readUint64(): [number, number];
/**
* Read a JS number value.
*/
readDouble(): number;
/**
* Read raw bytes from the deserializer’s internal buffer.
* The length parameter must correspond to the length of the buffer that was passed to serializer.writeRawBytes().
*/
readRawBytes(length: number): Buffer;
}
/**
* A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
* and only stores the part of their underlying `ArrayBuffers` that they are referring to.
*/
class DefaultDeserializer extends Deserializer {
}
/**
* Uses a `DefaultSerializer` to serialize value into a buffer.
*/
function serialize(value: any): Buffer;
/**
* Uses a `DefaultDeserializer` with default options to read a JS value from a buffer.
*/
function deserialize(data: NodeJS.TypedArray): any;
/**
* Begins writing coverage report based on the `NODE_V8_COVERAGE` env var.
* Noop is the env var is not set.
*/
function takeCoverage(): void;
/**
* Stops writing coverage report.
*/
function stopCoverage(): void;
}
declare module 'vm' {
interface Context extends NodeJS.Dict<any> { }
interface BaseOptions {
/**
* Specifies the filename used in stack traces produced by this script.
* Default: `''`.
*/
filename?: string;
/**
* Specifies the line number offset that is displayed in stack traces produced by this script.
* Default: `0`.
*/
lineOffset?: number;
/**
* Specifies the column number offset that is displayed in stack traces produced by this script.
* @default 0
*/
columnOffset?: number;
}
interface ScriptOptions extends BaseOptions {
displayErrors?: boolean;
timeout?: number;
cachedData?: Buffer;
/** @deprecated in favor of `script.createCachedData()` */
produceCachedData?: boolean;
}
interface RunningScriptOptions extends BaseOptions {
/**
* When `true`, if an `Error` occurs while compiling the `code`, the line of code causing the error is attached to the stack trace.
* Default: `true`.
*/
displayErrors?: boolean;
/**
* Specifies the number of milliseconds to execute code before terminating execution.
* If execution is terminated, an `Error` will be thrown. This value must be a strictly positive integer.
*/
timeout?: number;
/**
* If `true`, the execution will be terminated when `SIGINT` (Ctrl+C) is received.
* Existing handlers for the event that have been attached via `process.on('SIGINT')` will be disabled during script execution, but will continue to work after that.
* If execution is terminated, an `Error` will be thrown.
* Default: `false`.
*/
breakOnSigint?: boolean;
/**
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
*/
microtaskMode?: 'afterEvaluate';
}
interface CompileFunctionOptions extends BaseOptions {
/**
* Provides an optional data with V8's code cache data for the supplied source.
*/
cachedData?: Buffer;
/**
* Specifies whether to produce new cache data.
* Default: `false`,
*/
produceCachedData?: boolean;
/**
* The sandbox/context in which the said function should be compiled in.
*/
parsingContext?: Context;
/**
* An array containing a collection of context extensions (objects wrapping the current scope) to be applied while compiling
*/
contextExtensions?: Object[];
}
interface CreateContextOptions {
/**
* Human-readable name of the newly created context.
* @default 'VM Context i' Where i is an ascending numerical index of the created context.
*/
name?: string;
/**
* Corresponds to the newly created context for display purposes.
* The origin should be formatted like a `URL`, but with only the scheme, host, and port (if necessary),
* like the value of the `url.origin` property of a URL object.
* Most notably, this string should omit the trailing slash, as that denotes a path.
* @default ''
*/
origin?: string;
codeGeneration?: {
/**
* If set to false any calls to eval or function constructors (Function, GeneratorFunction, etc)
* will throw an EvalError.
* @default true
*/
strings?: boolean;
/**
* If set to false any attempt to compile a WebAssembly module will throw a WebAssembly.CompileError.
* @default true
*/
wasm?: boolean;
};
/**
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
*/
microtaskMode?: 'afterEvaluate';
}
type MeasureMemoryMode = 'summary' | 'detailed';
interface MeasureMemoryOptions {
/**
* @default 'summary'
*/
mode?: MeasureMemoryMode;
context?: Context;
}
interface MemoryMeasurement {
total: {
jsMemoryEstimate: number;
jsMemoryRange: [number, number];
};
}
class Script {
constructor(code: string, options?: ScriptOptions);
runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any;
runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any;
runInThisContext(options?: RunningScriptOptions): any;
createCachedData(): Buffer;
cachedDataRejected?: boolean;
}
function createContext(sandbox?: Context, options?: CreateContextOptions): Context;
function isContext(sandbox: Context): boolean;
function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions | string): any;
function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions | string): any;
function runInThisContext(code: string, options?: RunningScriptOptions | string): any;
function compileFunction(code: string, params?: ReadonlyArray<string>, options?: CompileFunctionOptions): Function;
/**
* Measure the memory known to V8 and used by the current execution context or a specified context.
*
* The format of the object that the returned Promise may resolve with is
* specific to the V8 engine and may change from one version of V8 to the next.
*
* The returned result is different from the statistics returned by
* `v8.getHeapSpaceStatistics()` in that `vm.measureMemory()` measures
* the memory reachable by V8 from a specific context, while
* `v8.getHeapSpaceStatistics()` measures the memory used by an instance
* of V8 engine, which can switch among multiple contexts that reference
* objects in the heap of one engine.
*
* @experimental
*/
function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
}
declare module 'wasi' {
interface WASIOptions {
/**
* An array of strings that the WebAssembly application will
* see as command line arguments. The first argument is the virtual path to the
* WASI command itself.
*/
args?: string[];
/**
* An object similar to `process.env` that the WebAssembly
* application will see as its environment.
*/
env?: object;
/**
* This object represents the WebAssembly application's
* sandbox directory structure. The string keys of `preopens` are treated as
* directories within the sandbox. The corresponding values in `preopens` are
* the real paths to those directories on the host machine.
*/
preopens?: NodeJS.Dict<string>;
/**
* By default, WASI applications terminate the Node.js
* process via the `__wasi_proc_exit()` function. Setting this option to `true`
* causes `wasi.start()` to return the exit code rather than terminate the
* process.
* @default false
*/
returnOnExit?: boolean;
/**
* The file descriptor used as standard input in the WebAssembly application.
* @default 0
*/
stdin?: number;
/**
* The file descriptor used as standard output in the WebAssembly application.
* @default 1
*/
stdout?: number;
/**
* The file descriptor used as standard error in the WebAssembly application.
* @default 2
*/
stderr?: number;
}
class WASI {
constructor(options?: WASIOptions);
/**
*
* Attempt to begin execution of `instance` by invoking its `_start()` export.
* If `instance` does not contain a `_start()` export, then `start()` attempts to
* invoke the `__wasi_unstable_reactor_start()` export. If neither of those exports
* is present on `instance`, then `start()` does nothing.
*
* `start()` requires that `instance` exports a `WebAssembly.Memory` named
* `memory`. If `instance` does not have a `memory` export an exception is thrown.
*
* If `start()` is called more than once, an exception is thrown.
*/
start(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
/**
* Attempt to initialize `instance` as a WASI reactor by invoking its `_initialize()` export, if it is present.
* If `instance` contains a `_start()` export, then an exception is thrown.
*
* `start()` requires that `instance` exports a `WebAssembly.Memory` named
* `memory`. If `instance` does not have a `memory` export an exception is thrown.
*
* If `initialize()` is called more than once, an exception is thrown.
*/
initialize(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
/**
* Is an object that implements the WASI system call API. This object
* should be passed as the `wasi_snapshot_preview1` import during the instantiation of a
* `WebAssembly.Instance`.
*/
readonly wasiImport: NodeJS.Dict<any>; // TODO: Narrow to DOM types
}
}
declare module 'worker_threads' {
import { Blob } from 'node:buffer';
import { Context } from 'vm';
import { EventEmitter } from 'events';
import { EventLoopUtilityFunction } from 'perf_hooks';
import { FileHandle } from 'fs/promises';
import { Readable, Writable } from 'stream';
import { URL } from 'url';
import { X509Certificate } from 'crypto';
const isMainThread: boolean;
const parentPort: null | MessagePort;
const resourceLimits: ResourceLimits;
const SHARE_ENV: unique symbol;
const threadId: number;
const workerData: any;
class MessageChannel {
readonly port1: MessagePort;
readonly port2: MessagePort;
}
interface WorkerPerformance {
eventLoopUtilization: EventLoopUtilityFunction;
}
type TransferListItem = ArrayBuffer | MessagePort | FileHandle | X509Certificate | Blob;
class MessagePort extends EventEmitter {
close(): void;
postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
ref(): void;
unref(): void;
start(): void;
addListener(event: "close", listener: () => void): this;
addListener(event: "message", listener: (value: any) => void): this;
addListener(event: "messageerror", listener: (error: Error) => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "close"): boolean;
emit(event: "message", value: any): boolean;
emit(event: "messageerror", error: Error): boolean;
emit(event: string | symbol, ...args: any[]): boolean;
on(event: "close", listener: () => void): this;
on(event: "message", listener: (value: any) => void): this;
on(event: "messageerror", listener: (error: Error) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: "close", listener: () => void): this;
once(event: "message", listener: (value: any) => void): this;
once(event: "messageerror", listener: (error: Error) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "message", listener: (value: any) => void): this;
prependListener(event: "messageerror", listener: (error: Error) => void): this;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "message", listener: (value: any) => void): this;
prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: "close", listener: () => void): this;
removeListener(event: "message", listener: (value: any) => void): this;
removeListener(event: "messageerror", listener: (error: Error) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
off(event: "close", listener: () => void): this;
off(event: "message", listener: (value: any) => void): this;
off(event: "messageerror", listener: (error: Error) => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
}
interface WorkerOptions {
/**
* List of arguments which would be stringified and appended to
* `process.argv` in the worker. This is mostly similar to the `workerData`
* but the values will be available on the global `process.argv` as if they
* were passed as CLI options to the script.
*/
argv?: any[];
env?: NodeJS.Dict<string> | typeof SHARE_ENV;
eval?: boolean;
workerData?: any;
stdin?: boolean;
stdout?: boolean;
stderr?: boolean;
execArgv?: string[];
resourceLimits?: ResourceLimits;
/**
* Additional data to send in the first worker message.
*/
transferList?: TransferListItem[];
/**
* @default true
*/
trackUnmanagedFds?: boolean;
}
interface ResourceLimits {
/**
* The maximum size of a heap space for recently created objects.
*/
maxYoungGenerationSizeMb?: number;
/**
* The maximum size of the main heap in MB.
*/
maxOldGenerationSizeMb?: number;
/**
* The size of a pre-allocated memory range used for generated code.
*/
codeRangeSizeMb?: number;
/**
* The default maximum stack size for the thread. Small values may lead to unusable Worker instances.
* @default 4
*/
stackSizeMb?: number;
}
class Worker extends EventEmitter {
readonly stdin: Writable | null;
readonly stdout: Readable;
readonly stderr: Readable;
readonly threadId: number;
readonly resourceLimits?: ResourceLimits;
readonly performance: WorkerPerformance;
/**
* @param filename The path to the Worker’s main script or module.
* Must be either an absolute path or a relative path (i.e. relative to the current working directory) starting with ./ or ../,
* or a WHATWG URL object using file: protocol. If options.eval is true, this is a string containing JavaScript code rather than a path.
*/
constructor(filename: string | URL, options?: WorkerOptions);
postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
ref(): void;
unref(): void;
/**
* Stop all JavaScript execution in the worker thread as soon as possible.
* Returns a Promise for the exit code that is fulfilled when the `exit` event is emitted.
*/
terminate(): Promise<number>;
/**
* Returns a readable stream for a V8 snapshot of the current state of the Worker.
* See `v8.getHeapSnapshot()` for more details.
*
* If the Worker thread is no longer running, which may occur before the
* `'exit'` event is emitted, the returned `Promise` will be rejected
* immediately with an `ERR_WORKER_NOT_RUNNING` error
*/
getHeapSnapshot(): Promise<Readable>;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "exit", listener: (exitCode: number) => void): this;
addListener(event: "message", listener: (value: any) => void): this;
addListener(event: "messageerror", listener: (error: Error) => void): this;
addListener(event: "online", listener: () => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "error", err: Error): boolean;
emit(event: "exit", exitCode: number): boolean;
emit(event: "message", value: any): boolean;
emit(event: "messageerror", error: Error): boolean;
emit(event: "online"): boolean;
emit(event: string | symbol, ...args: any[]): boolean;
on(event: "error", listener: (err: Error) => void): this;
on(event: "exit", listener: (exitCode: number) => void): this;
on(event: "message", listener: (value: any) => void): this;
on(event: "messageerror", listener: (error: Error) => void): this;
on(event: "online", listener: () => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "exit", listener: (exitCode: number) => void): this;
once(event: "message", listener: (value: any) => void): this;
once(event: "messageerror", listener: (error: Error) => void): this;
once(event: "online", listener: () => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "exit", listener: (exitCode: number) => void): this;
prependListener(event: "message", listener: (value: any) => void): this;
prependListener(event: "messageerror", listener: (error: Error) => void): this;
prependListener(event: "online", listener: () => void): this;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "exit", listener: (exitCode: number) => void): this;
prependOnceListener(event: "message", listener: (value: any) => void): this;
prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
prependOnceListener(event: "online", listener: () => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: "exit", listener: (exitCode: number) => void): this;
removeListener(event: "message", listener: (value: any) => void): this;
removeListener(event: "messageerror", listener: (error: Error) => void): this;
removeListener(event: "online", listener: () => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
off(event: "error", listener: (err: Error) => void): this;
off(event: "exit", listener: (exitCode: number) => void): this;
off(event: "message", listener: (value: any) => void): this;
off(event: "messageerror", listener: (error: Error) => void): this;
off(event: "online", listener: () => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
}
interface BroadcastChannel extends NodeJS.RefCounted {}
/**
* See https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
*/
class BroadcastChannel {
readonly name: string;
onmessage: (message: unknown) => void;
onmessageerror: (message: unknown) => void;
constructor(name: string);
close(): void;
postMessage(message: unknown): void;
}
/**
* Mark an object as not transferable.
* If `object` occurs in the transfer list of a `port.postMessage()` call, it will be ignored.
*
* In particular, this makes sense for objects that can be cloned, rather than transferred,
* and which are used by other objects on the sending side. For example, Node.js marks
* the `ArrayBuffer`s it uses for its Buffer pool with this.
*
* This operation cannot be undone.
*/
function markAsUntransferable(object: object): void;
/**
* Transfer a `MessagePort` to a different `vm` Context. The original `port`
* object will be rendered unusable, and the returned `MessagePort` instance will
* take its place.
*
* The returned `MessagePort` will be an object in the target context, and will
* inherit from its global `Object` class. Objects passed to the
* `port.onmessage()` listener will also be created in the target context
* and inherit from its global `Object` class.
*
* However, the created `MessagePort` will no longer inherit from
* `EventEmitter`, and only `port.onmessage()` can be used to receive
* events using it.
*/
function moveMessagePortToContext(port: MessagePort, context: Context): MessagePort;
/**
* Receive a single message from a given `MessagePort`. If no message is available,
* `undefined` is returned, otherwise an object with a single `message` property
* that contains the message payload, corresponding to the oldest message in the
* `MessagePort`’s queue.
*/
function receiveMessageOnPort(port: MessagePort): { message: any } | undefined;
type Serializable = string | object | number | boolean | bigint;
/**
* @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
* @experimental
*/
function getEnvironmentData(key: Serializable): Serializable;
/**
* @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
* @param value Any arbitrary, cloneable JavaScript value that will be cloned
* and passed automatically to all new `Worker` instances. If `value` is passed
* as `undefined`, any previously set value for the `key` will be deleted.
* @experimental
*/
function setEnvironmentData(key: Serializable, value: Serializable): void;
}
declare module 'zlib' {
import * as stream from 'stream';
interface ZlibOptions {
/**
* @default constants.Z_NO_FLUSH
*/
flush?: number;
/**
* @default constants.Z_FINISH
*/
finishFlush?: number;
/**
* @default 16*1024
*/
chunkSize?: number;
windowBits?: number;
level?: number; // compression only
memLevel?: number; // compression only
strategy?: number; // compression only
dictionary?: NodeJS.ArrayBufferView | ArrayBuffer; // deflate/inflate only, empty dictionary by default
info?: boolean;
maxOutputLength?: number;
}
interface BrotliOptions {
/**
* @default constants.BROTLI_OPERATION_PROCESS
*/
flush?: number;
/**
* @default constants.BROTLI_OPERATION_FINISH
*/
finishFlush?: number;
/**
* @default 16*1024
*/
chunkSize?: number;
params?: {
/**
* Each key is a `constants.BROTLI_*` constant.
*/
[key: number]: boolean | number;
};
maxOutputLength?: number;
}
interface Zlib {
/** @deprecated Use bytesWritten instead. */
readonly bytesRead: number;
readonly bytesWritten: number;
shell?: boolean | string;
close(callback?: () => void): void;
flush(kind?: number, callback?: () => void): void;
flush(callback?: () => void): void;
}
interface ZlibParams {
params(level: number, strategy: number, callback: () => void): void;
}
interface ZlibReset {
reset(): void;
}
interface BrotliCompress extends stream.Transform, Zlib { }
interface BrotliDecompress extends stream.Transform, Zlib { }
interface Gzip extends stream.Transform, Zlib { }
interface Gunzip extends stream.Transform, Zlib { }
interface Deflate extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
interface Inflate extends stream.Transform, Zlib, ZlibReset { }
interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
interface InflateRaw extends stream.Transform, Zlib, ZlibReset { }
interface Unzip extends stream.Transform, Zlib { }
function createBrotliCompress(options?: BrotliOptions): BrotliCompress;
function createBrotliDecompress(options?: BrotliOptions): BrotliDecompress;
function createGzip(options?: ZlibOptions): Gzip;
function createGunzip(options?: ZlibOptions): Gunzip;
function createDeflate(options?: ZlibOptions): Deflate;
function createInflate(options?: ZlibOptions): Inflate;
function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
function createInflateRaw(options?: ZlibOptions): InflateRaw;
function createUnzip(options?: ZlibOptions): Unzip;
type InputType = string | ArrayBuffer | NodeJS.ArrayBufferView;
type CompressCallback = (error: Error | null, result: Buffer) => void;
function brotliCompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
function brotliCompress(buf: InputType, callback: CompressCallback): void;
namespace brotliCompress {
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
}
function brotliCompressSync(buf: InputType, options?: BrotliOptions): Buffer;
function brotliDecompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
function brotliDecompress(buf: InputType, callback: CompressCallback): void;
namespace brotliDecompress {
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
}
function brotliDecompressSync(buf: InputType, options?: BrotliOptions): Buffer;
function deflate(buf: InputType, callback: CompressCallback): void;
function deflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
namespace deflate {
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
}
function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
function deflateRaw(buf: InputType, callback: CompressCallback): void;
function deflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
namespace deflateRaw {
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
}
function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
function gzip(buf: InputType, callback: CompressCallback): void;
function gzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
namespace gzip {
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
}
function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
function gunzip(buf: InputType, callback: CompressCallback): void;
function gunzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
namespace gunzip {
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
}
function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
function inflate(buf: InputType, callback: CompressCallback): void;
function inflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
namespace inflate {
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
}
function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
function inflateRaw(buf: InputType, callback: CompressCallback): void;
function inflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
namespace inflateRaw {
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
}
function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
function unzip(buf: InputType, callback: CompressCallback): void;
function unzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
namespace unzip {
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
}
function unzipSync(buf: InputType, options?: ZlibOptions): Buffer;
namespace constants {
const BROTLI_DECODE: number;
const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number;
const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: number;
const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: number;
const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: number;
const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: number;
const BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: number;
const BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: number;
const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: number;
const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: number;
const BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: number;
const BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: number;
const BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: number;
const BROTLI_DECODER_ERROR_FORMAT_DISTANCE: number;
const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: number;
const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: number;
const BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: number;
const BROTLI_DECODER_ERROR_FORMAT_PADDING_1: number;
const BROTLI_DECODER_ERROR_FORMAT_PADDING_2: number;
const BROTLI_DECODER_ERROR_FORMAT_RESERVED: number;
const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: number;
const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: number;
const BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: number;
const BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: number;
const BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: number;
const BROTLI_DECODER_ERROR_UNREACHABLE: number;
const BROTLI_DECODER_NEEDS_MORE_INPUT: number;
const BROTLI_DECODER_NEEDS_MORE_OUTPUT: number;
const BROTLI_DECODER_NO_ERROR: number;
const BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: number;
const BROTLI_DECODER_PARAM_LARGE_WINDOW: number;
const BROTLI_DECODER_RESULT_ERROR: number;
const BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: number;
const BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: number;
const BROTLI_DECODER_RESULT_SUCCESS: number;
const BROTLI_DECODER_SUCCESS: number;
const BROTLI_DEFAULT_MODE: number;
const BROTLI_DEFAULT_QUALITY: number;
const BROTLI_DEFAULT_WINDOW: number;
const BROTLI_ENCODE: number;
const BROTLI_LARGE_MAX_WINDOW_BITS: number;
const BROTLI_MAX_INPUT_BLOCK_BITS: number;
const BROTLI_MAX_QUALITY: number;
const BROTLI_MAX_WINDOW_BITS: number;
const BROTLI_MIN_INPUT_BLOCK_BITS: number;
const BROTLI_MIN_QUALITY: number;
const BROTLI_MIN_WINDOW_BITS: number;
const BROTLI_MODE_FONT: number;
const BROTLI_MODE_GENERIC: number;
const BROTLI_MODE_TEXT: number;
const BROTLI_OPERATION_EMIT_METADATA: number;
const BROTLI_OPERATION_FINISH: number;
const BROTLI_OPERATION_FLUSH: number;
const BROTLI_OPERATION_PROCESS: number;
const BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: number;
const BROTLI_PARAM_LARGE_WINDOW: number;
const BROTLI_PARAM_LGBLOCK: number;
const BROTLI_PARAM_LGWIN: number;
const BROTLI_PARAM_MODE: number;
const BROTLI_PARAM_NDIRECT: number;
const BROTLI_PARAM_NPOSTFIX: number;
const BROTLI_PARAM_QUALITY: number;
const BROTLI_PARAM_SIZE_HINT: number;
const DEFLATE: number;
const DEFLATERAW: number;
const GUNZIP: number;
const GZIP: number;
const INFLATE: number;
const INFLATERAW: number;
const UNZIP: number;
// Allowed flush values.
const Z_NO_FLUSH: number;
const Z_PARTIAL_FLUSH: number;
const Z_SYNC_FLUSH: number;
const Z_FULL_FLUSH: number;
const Z_FINISH: number;
const Z_BLOCK: number;
const Z_TREES: number;
// Return codes for the compression/decompression functions.
// Negative values are errors, positive values are used for special but normal events.
const Z_OK: number;
const Z_STREAM_END: number;
const Z_NEED_DICT: number;
const Z_ERRNO: number;
const Z_STREAM_ERROR: number;
const Z_DATA_ERROR: number;
const Z_MEM_ERROR: number;
const Z_BUF_ERROR: number;
const Z_VERSION_ERROR: number;
// Compression levels.
const Z_NO_COMPRESSION: number;
const Z_BEST_SPEED: number;
const Z_BEST_COMPRESSION: number;
const Z_DEFAULT_COMPRESSION: number;
// Compression strategy.
const Z_FILTERED: number;
const Z_HUFFMAN_ONLY: number;
const Z_RLE: number;
const Z_FIXED: number;
const Z_DEFAULT_STRATEGY: number;
const Z_DEFAULT_WINDOWBITS: number;
const Z_MIN_WINDOWBITS: number;
const Z_MAX_WINDOWBITS: number;
const Z_MIN_CHUNK: number;
const Z_MAX_CHUNK: number;
const Z_DEFAULT_CHUNK: number;
const Z_MIN_MEMLEVEL: number;
const Z_MAX_MEMLEVEL: number;
const Z_DEFAULT_MEMLEVEL: number;
const Z_MIN_LEVEL: number;
const Z_MAX_LEVEL: number;
const Z_DEFAULT_LEVEL: number;
const ZLIB_VERNUM: number;
}
// Allowed flush values.
/** @deprecated Use `constants.Z_NO_FLUSH` */
const Z_NO_FLUSH: number;
/** @deprecated Use `constants.Z_PARTIAL_FLUSH` */
const Z_PARTIAL_FLUSH: number;
/** @deprecated Use `constants.Z_SYNC_FLUSH` */
const Z_SYNC_FLUSH: number;
/** @deprecated Use `constants.Z_FULL_FLUSH` */
const Z_FULL_FLUSH: number;
/** @deprecated Use `constants.Z_FINISH` */
const Z_FINISH: number;
/** @deprecated Use `constants.Z_BLOCK` */
const Z_BLOCK: number;
/** @deprecated Use `constants.Z_TREES` */
const Z_TREES: number;
// Return codes for the compression/decompression functions.
// Negative values are errors, positive values are used for special but normal events.
/** @deprecated Use `constants.Z_OK` */
const Z_OK: number;
/** @deprecated Use `constants.Z_STREAM_END` */
const Z_STREAM_END: number;
/** @deprecated Use `constants.Z_NEED_DICT` */
const Z_NEED_DICT: number;
/** @deprecated Use `constants.Z_ERRNO` */
const Z_ERRNO: number;
/** @deprecated Use `constants.Z_STREAM_ERROR` */
const Z_STREAM_ERROR: number;
/** @deprecated Use `constants.Z_DATA_ERROR` */
const Z_DATA_ERROR: number;
/** @deprecated Use `constants.Z_MEM_ERROR` */
const Z_MEM_ERROR: number;
/** @deprecated Use `constants.Z_BUF_ERROR` */
const Z_BUF_ERROR: number;
/** @deprecated Use `constants.Z_VERSION_ERROR` */
const Z_VERSION_ERROR: number;
// Compression levels.
/** @deprecated Use `constants.Z_NO_COMPRESSION` */
const Z_NO_COMPRESSION: number;
/** @deprecated Use `constants.Z_BEST_SPEED` */
const Z_BEST_SPEED: number;
/** @deprecated Use `constants.Z_BEST_COMPRESSION` */
const Z_BEST_COMPRESSION: number;
/** @deprecated Use `constants.Z_DEFAULT_COMPRESSION` */
const Z_DEFAULT_COMPRESSION: number;
// Compression strategy.
/** @deprecated Use `constants.Z_FILTERED` */
const Z_FILTERED: number;
/** @deprecated Use `constants.Z_HUFFMAN_ONLY` */
const Z_HUFFMAN_ONLY: number;
/** @deprecated Use `constants.Z_RLE` */
const Z_RLE: number;
/** @deprecated Use `constants.Z_FIXED` */
const Z_FIXED: number;
/** @deprecated Use `constants.Z_DEFAULT_STRATEGY` */
const Z_DEFAULT_STRATEGY: number;
/** @deprecated */
const Z_BINARY: number;
/** @deprecated */
const Z_TEXT: number;
/** @deprecated */
const Z_ASCII: number;
/** @deprecated */
const Z_UNKNOWN: number;
/** @deprecated */
const Z_DEFLATED: number;
}
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/prop-types`
# Summary
This package contains type definitions for prop-types (https://github.com/reactjs/prop-types).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/prop-types
Additional Details
* Last updated: Tue, 24 Sep 2019 20:14:29 GMT
* Dependencies: none
* Global values: none
# Credits
These definitions were written by DovydasNavickas <https://github.com/DovydasNavickas>, Ferdy Budhidharma <https://github.com/ferdaber>, and Sebastian Silbermann <https://github.com/eps1lon>.
// Type definitions for prop-types 15.7
// Project: https://github.com/reactjs/prop-types, https://facebook.github.io/react
// Definitions by: DovydasNavickas <https://github.com/DovydasNavickas>
// Ferdy Budhidharma <https://github.com/ferdaber>
// Sebastian Silbermann <https://github.com/eps1lon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
export type ReactComponentLike =
| string
| ((props: any, context?: any) => any)
| (new (props: any, context?: any) => any);
export interface ReactElementLike {
type: ReactComponentLike;
props: any;
key: string | number | null;
}
export interface ReactNodeArray extends Array<ReactNodeLike> {}
export type ReactNodeLike =
| {}
| ReactElementLike
| ReactNodeArray
| string
| number
| boolean
| null
| undefined;
export const nominalTypeHack: unique symbol;
export type IsOptional<T> = undefined extends T ? true : false;
export type RequiredKeys<V> = { [K in keyof V]-?: Exclude<V[K], undefined> extends Validator<infer T> ? IsOptional<T> extends true ? never : K : never }[keyof V];
export type OptionalKeys<V> = Exclude<keyof V, RequiredKeys<V>>;
export type InferPropsInner<V> = { [K in keyof V]-?: InferType<V[K]>; };
export interface Validator<T> {
(props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string): Error | null;
[nominalTypeHack]?: {
type: T;
};
}
export interface Requireable<T> extends Validator<T | undefined | null> {
isRequired: Validator<NonNullable<T>>;
}
export type ValidationMap<T> = { [K in keyof T]?: Validator<T[K]> };
export type InferType<V> = V extends Validator<infer T> ? T : any;
export type InferProps<V> =
& InferPropsInner<Pick<V, RequiredKeys<V>>>
& Partial<InferPropsInner<Pick<V, OptionalKeys<V>>>>;
export const any: Requireable<any>;
export const array: Requireable<any[]>;
export const bool: Requireable<boolean>;
export const func: Requireable<(...args: any[]) => any>;
export const number: Requireable<number>;
export const object: Requireable<object>;
export const string: Requireable<string>;
export const node: Requireable<ReactNodeLike>;
export const element: Requireable<ReactElementLike>;
export const symbol: Requireable<symbol>;
export const elementType: Requireable<ReactComponentLike>;
export function instanceOf<T>(expectedClass: new (...args: any[]) => T): Requireable<T>;
export function oneOf<T>(types: ReadonlyArray<T>): Requireable<T>;
export function oneOfType<T extends Validator<any>>(types: T[]): Requireable<NonNullable<InferType<T>>>;
export function arrayOf<T>(type: Validator<T>): Requireable<T[]>;
export function objectOf<T>(type: Validator<T>): Requireable<{ [K in keyof any]: T; }>;
export function shape<P extends ValidationMap<any>>(type: P): Requireable<InferProps<P>>;
export function exact<P extends ValidationMap<any>>(type: P): Requireable<Required<InferProps<P>>>;
/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
*
* @param typeSpecs Map of name to a ReactPropType
* @param values Runtime values that need to be type-checked
* @param location e.g. "prop", "context", "child context"
* @param componentName Name of the component for error messages
* @param getStack Returns the component stack
*/
export function checkPropTypes(typeSpecs: any, values: any, location: string, componentName: string, getStack?: () => any): void;
/**
* Only available if NODE_ENV=production
*/
export function resetWarningCache(): void;
{
"name": "@types/prop-types",
"version": "15.7.3",
"description": "TypeScript definitions for prop-types",
"license": "MIT",
"contributors": [
{
"name": "DovydasNavickas",
"url": "https://github.com/DovydasNavickas",
"githubUsername": "DovydasNavickas"
},
{
"name": "Ferdy Budhidharma",
"url": "https://github.com/ferdaber",
"githubUsername": "ferdaber"
},
{
"name": "Sebastian Silbermann",
"url": "https://github.com/eps1lon",
"githubUsername": "eps1lon"
}
],
"main": "",
"types": "index",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/prop-types"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "09cbaa49bc0d7139a168388028da20f8772c641a1e83848ef2cdcd0f91c7ee79",
"typeScriptVersion": "2.8"
}
\ No newline at end of file
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/react-dom`
# Summary
This package contains type definitions for React (react-dom) (https://reactjs.org).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom.
### Additional Details
* Last updated: Fri, 18 Jun 2021 06:01:13 GMT
* Dependencies: [@types/react](https://npmjs.com/package/@types/react)
* Global values: `ReactDOM`, `ReactDOMNodeStream`, `ReactDOMServer`
# Credits
These definitions were written by [Asana](https://asana.com), [AssureSign](http://www.assuresign.com), [Microsoft](https://microsoft.com), [MartynasZilinskas](https://github.com/MartynasZilinskas), [Josh Rutherford](https://github.com/theruther4d), [Jessica Franco](https://github.com/Jessidhia), and [Sebastian Silbermann](https://github.com/eps1lon).
/**
* These are types for things that are present in the `experimental` builds of React but not yet
* on a stable build.
*
* Once they are promoted to stable they can just be moved to the main index file.
*
* To load the types declared here in an actual project, there are three ways. The easiest one,
* if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
* is to add `"react-dom/experimental"` to the `"types"` array.
*
* Alternatively, a specific import syntax can to be used from a typescript file.
* This module does not exist in reality, which is why the {} is important:
*
* ```ts
* import {} from 'react-dom/experimental'
* ```
*
* It is also possible to include it through a triple-slash reference:
*
* ```ts
* /// <reference types="react-dom/experimental" />
* ```
*
* Either the import or the reference only needs to appear once, anywhere in the project.
*/
// See https://github.com/facebook/react/blob/master/packages/react-dom/src/client/ReactDOM.js to see how the exports are declared,
// and https://github.com/facebook/react/blob/master/packages/shared/ReactFeatureFlags.js to verify which APIs are
// flagged experimental or not. Experimental APIs will be tagged with `__EXPERIMENTAL__`.
import React = require('react');
import ReactDOM = require('./next');
export {};
declare module '.' {
function unstable_flushControlled(callback: () => void): void;
// enableSelectiveHydration feature
/**
* @see https://github.com/facebook/react/commit/3a2b5f148d450c69aab67f055fc441d294c23518
*/
function unstable_scheduleHydration(target: Element | Document | DocumentFragment | Comment): void;
}
// Type definitions for React (react-dom) 17.0
// Project: https://reactjs.org
// Definitions by: Asana <https://asana.com>
// AssureSign <http://www.assuresign.com>
// Microsoft <https://microsoft.com>
// MartynasZilinskas <https://github.com/MartynasZilinskas>
// Josh Rutherford <https://github.com/theruther4d>
// Jessica Franco <https://github.com/Jessidhia>
// Sebastian Silbermann <https://github.com/eps1lon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// NOTE: Users of the upcoming React 18 release should add a reference
// to 'react-dom/next' in their project. See next.d.ts's top comment
// for reference and documentation on how exactly to do it.
// NOTE: Users of the `experimental` builds of React should add a reference
// to 'react-dom/experimental' in their project. See experimental.d.ts's top comment
// for reference and documentation on how exactly to do it.
export as namespace ReactDOM;
import {
ReactInstance, Component, ComponentState,
ReactElement, SFCElement, CElement,
DOMAttributes, DOMElement, ReactNode, ReactPortal
} from 'react';
export function findDOMNode(instance: ReactInstance | null | undefined): Element | null | Text;
export function unmountComponentAtNode(container: Element | DocumentFragment): boolean;
export function createPortal(children: ReactNode, container: Element, key?: null | string): ReactPortal;
export const version: string;
export const render: Renderer;
export const hydrate: Renderer;
export function flushSync<R>(fn: () => R): R;
export function flushSync<A, R>(fn: (a: A) => R, a: A): R;
export function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
export function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
export function unstable_batchedUpdates(callback: () => any): void;
export function unstable_renderSubtreeIntoContainer<T extends Element>(
parentComponent: Component<any>,
element: DOMElement<DOMAttributes<T>, T>,
container: Element,
callback?: (element: T) => any): T;
export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
parentComponent: Component<any>,
element: CElement<P, T>,
container: Element,
callback?: (component: T) => any): T;
export function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any>,
element: ReactElement<P>,
container: Element,
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
export type Container = Element | Document | DocumentFragment;
export interface Renderer {
// Deprecated(render): The return value is deprecated.
// In future releases the render function's return type will be void.
<T extends Element>(
element: DOMElement<DOMAttributes<T>, T>,
container: Container| null,
callback?: () => void
): T;
(
element: Array<DOMElement<DOMAttributes<any>, any>>,
container: Container| null,
callback?: () => void
): Element;
(
element: SFCElement<any> | Array<SFCElement<any>>,
container: Container| null,
callback?: () => void
): void;
<P, T extends Component<P, ComponentState>>(
element: CElement<P, T>,
container: Container| null,
callback?: () => void
): T;
(
element: Array<CElement<any, Component<any, ComponentState>>>,
container: Container| null,
callback?: () => void
): Component<any, ComponentState>;
<P>(
element: ReactElement<P>,
container: Container| null,
callback?: () => void
): Component<P, ComponentState> | Element | void;
(
element: ReactElement[],
container: Container| null,
callback?: () => void
): Component<any, ComponentState> | Element | void;
}
/**
* These are types for things that are present in the upcoming React 18 release.
*
* Once React 18 is released they can just be moved to the main index file.
*
* To load the types declared here in an actual project, there are three ways. The easiest one,
* if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
* is to add `"react-dom/next"` to the `"types"` array.
*
* Alternatively, a specific import syntax can to be used from a typescript file.
* This module does not exist in reality, which is why the {} is important:
*
* ```ts
* import {} from 'react-dom/next'
* ```
*
* It is also possible to include it through a triple-slash reference:
*
* ```ts
* /// <reference types="react-dom/next" />
* ```
*
* Either the import or the reference only needs to appear once, anywhere in the project.
*/
// See https://github.com/facebook/react/blob/master/packages/react-dom/src/client/ReactDOM.js to see how the exports are declared,
import React = require('react');
import ReactDOM = require('.');
export {};
declare module '.' {
interface HydrationOptions {
onHydrated?(suspenseInstance: Comment): void;
onDeleted?(suspenseInstance: Comment): void;
}
interface RootOptions {
/**
* @deprecated Use `hydrateRoot(container)` instead
*/
hydrate?: boolean;
/**
* @deprecated Use `hydrateRoot(container, hydrateOptions)` instead
*/
hydrationOptions?: HydrationOptions;
}
interface Root {
render(children: React.ReactChild | React.ReactNodeArray): void;
unmount(): void;
}
/**
* Replaces `ReactDOM.render` when the `.render` method is called and enables Concurrent Mode.
*
* @see https://reactjs.org/docs/concurrent-mode-reference.html#createroot
*/
function createRoot(container: Element | Document | DocumentFragment | Comment, options?: RootOptions): Root;
function hydrateRoot(container: Element | Document | DocumentFragment | Comment, options?: HydrationOptions): Root;
}
import { ReactElement } from 'react';
/**
* Render a ReactElement to its initial HTML. This should only be used on the
* server.
* See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostream
*/
export function renderToStream(element: ReactElement): any;
/**
* Similar to renderToStream, except this doesn't create extra DOM attributes
* such as data-react-id that React uses internally.
* See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostaticstream
*/
export function renderToStaticStream(element: ReactElement): any;
export const version: string;
export as namespace ReactDOMNodeStream;
{
"name": "@types/react-dom",
"version": "17.0.8",
"description": "TypeScript definitions for React (react-dom)",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom",
"license": "MIT",
"contributors": [
{
"name": "Asana",
"url": "https://asana.com"
},
{
"name": "AssureSign",
"url": "http://www.assuresign.com"
},
{
"name": "Microsoft",
"url": "https://microsoft.com"
},
{
"name": "MartynasZilinskas",
"url": "https://github.com/MartynasZilinskas",
"githubUsername": "MartynasZilinskas"
},
{
"name": "Josh Rutherford",
"url": "https://github.com/theruther4d",
"githubUsername": "theruther4d"
},
{
"name": "Jessica Franco",
"url": "https://github.com/Jessidhia",
"githubUsername": "Jessidhia"
},
{
"name": "Sebastian Silbermann",
"url": "https://github.com/eps1lon",
"githubUsername": "eps1lon"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/react-dom"
},
"scripts": {},
"dependencies": {
"@types/react": "*"
},
"typesPublisherContentHash": "4cc8842db00c8a8ee4a599dde279d26456cf4f53e7c086e2b7ce575e9286f620",
"typeScriptVersion": "3.6"
}
\ No newline at end of file
// forward declarations
declare global {
namespace NodeJS {
// tslint:disable-next-line:no-empty-interface
interface ReadableStream {}
}
}
import { ReactElement } from 'react';
/**
* Render a React element to its initial HTML. This should only be used on the server.
* React will return an HTML string. You can use this method to generate HTML on the server
* and send the markup down on the initial request for faster page loads and to allow search
* engines to crawl your pages for SEO purposes.
*
* If you call `ReactDOM.hydrate()` on a node that already has this server-rendered markup,
* React will preserve it and only attach event handlers, allowing you
* to have a very performant first-load experience.
*/
export function renderToString(element: ReactElement): string;
/**
* Render a React element to its initial HTML. Returns a Readable stream that outputs
* an HTML string. The HTML output by this stream is exactly equal to what
* `ReactDOMServer.renderToString()` would return.
*/
export function renderToNodeStream(element: ReactElement): NodeJS.ReadableStream;
/**
* Similar to `renderToString`, except this doesn't create extra DOM attributes
* such as `data-reactid`, that React uses internally. This is useful if you want
* to use React as a simple static page generator, as stripping away the extra
* attributes can save lots of bytes.
*/
export function renderToStaticMarkup(element: ReactElement): string;
/**
* Similar to `renderToNodeStream`, except this doesn't create extra DOM attributes
* such as `data-reactid`, that React uses internally. The HTML output by this stream
* is exactly equal to what `ReactDOMServer.renderToStaticMarkup()` would return.
*/
export function renderToStaticNodeStream(element: ReactElement): NodeJS.ReadableStream;
export const version: string;
export as namespace ReactDOMServer;
import {
AbstractView, Component, ComponentClass,
ReactElement, ReactInstance, ClassType,
DOMElement, SFCElement, CElement,
ReactHTMLElement, DOMAttributes, SFC
} from 'react';
import * as ReactTestUtils from ".";
export {};
export interface OptionalEventProperties {
bubbles?: boolean;
cancelable?: boolean;
currentTarget?: EventTarget;
defaultPrevented?: boolean;
eventPhase?: number;
isTrusted?: boolean;
nativeEvent?: Event;
preventDefault?(): void;
stopPropagation?(): void;
target?: EventTarget;
timeStamp?: Date;
type?: string;
}
export interface SyntheticEventData extends OptionalEventProperties {
altKey?: boolean;
button?: number;
buttons?: number;
clientX?: number;
clientY?: number;
changedTouches?: TouchList;
charCode?: number;
clipboardData?: DataTransfer;
ctrlKey?: boolean;
deltaMode?: number;
deltaX?: number;
deltaY?: number;
deltaZ?: number;
detail?: number;
getModifierState?(key: string): boolean;
key?: string;
keyCode?: number;
locale?: string;
location?: number;
metaKey?: boolean;
pageX?: number;
pageY?: number;
relatedTarget?: EventTarget;
repeat?: boolean;
screenX?: number;
screenY?: number;
shiftKey?: boolean;
targetTouches?: TouchList;
touches?: TouchList;
view?: AbstractView;
which?: number;
}
export type EventSimulator = (element: Element | Component<any>, eventData?: SyntheticEventData) => void;
export interface MockedComponentClass {
new (props: any): any;
}
export interface ShallowRenderer {
/**
* After `shallowRenderer.render()` has been called, returns shallowly rendered output.
*/
getRenderOutput<E extends ReactElement>(): E;
/**
* Similar to `ReactDOM.render` but it doesn't require DOM and only renders a single level deep.
*/
render(element: ReactElement, context?: any): void;
unmount(): void;
}
/**
* Simulate an event dispatch on a DOM node with optional `eventData` event data.
* `Simulate` has a method for every event that React understands.
*/
export namespace Simulate {
const abort: EventSimulator;
const animationEnd: EventSimulator;
const animationIteration: EventSimulator;
const animationStart: EventSimulator;
const blur: EventSimulator;
const canPlay: EventSimulator;
const canPlayThrough: EventSimulator;
const change: EventSimulator;
const click: EventSimulator;
const compositionEnd: EventSimulator;
const compositionStart: EventSimulator;
const compositionUpdate: EventSimulator;
const contextMenu: EventSimulator;
const copy: EventSimulator;
const cut: EventSimulator;
const doubleClick: EventSimulator;
const drag: EventSimulator;
const dragEnd: EventSimulator;
const dragEnter: EventSimulator;
const dragExit: EventSimulator;
const dragLeave: EventSimulator;
const dragOver: EventSimulator;
const dragStart: EventSimulator;
const drop: EventSimulator;
const durationChange: EventSimulator;
const emptied: EventSimulator;
const encrypted: EventSimulator;
const ended: EventSimulator;
const error: EventSimulator;
const focus: EventSimulator;
const input: EventSimulator;
const invalid: EventSimulator;
const keyDown: EventSimulator;
const keyPress: EventSimulator;
const keyUp: EventSimulator;
const load: EventSimulator;
const loadStart: EventSimulator;
const loadedData: EventSimulator;
const loadedMetadata: EventSimulator;
const mouseDown: EventSimulator;
const mouseEnter: EventSimulator;
const mouseLeave: EventSimulator;
const mouseMove: EventSimulator;
const mouseOut: EventSimulator;
const mouseOver: EventSimulator;
const mouseUp: EventSimulator;
const paste: EventSimulator;
const pause: EventSimulator;
const play: EventSimulator;
const playing: EventSimulator;
const progress: EventSimulator;
const rateChange: EventSimulator;
const scroll: EventSimulator;
const seeked: EventSimulator;
const seeking: EventSimulator;
const select: EventSimulator;
const stalled: EventSimulator;
const submit: EventSimulator;
const suspend: EventSimulator;
const timeUpdate: EventSimulator;
const touchCancel: EventSimulator;
const touchEnd: EventSimulator;
const touchMove: EventSimulator;
const touchStart: EventSimulator;
const transitionEnd: EventSimulator;
const volumeChange: EventSimulator;
const waiting: EventSimulator;
const wheel: EventSimulator;
}
/**
* Render a React element into a detached DOM node in the document. __This function requires a DOM__.
*/
export function renderIntoDocument<T extends Element>(
element: DOMElement<any, T>): T;
export function renderIntoDocument(
element: SFCElement<any>): void;
// If we replace `P` with `any` in this overload, then some tests fail because
// calls to `renderIntoDocument` choose the last overload on the
// subtype-relation pass and get an undesirably broad return type. Using `P`
// allows this overload to match on the subtype-relation pass.
export function renderIntoDocument<P, T extends Component<P>>(
element: CElement<P, T>): T;
export function renderIntoDocument<P>(
element: ReactElement<P>): Component<P> | Element | void;
/**
* Pass a mocked component module to this method to augment it with useful methods that allow it to
* be used as a dummy React component. Instead of rendering as usual, the component will become
* a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
*/
export function mockComponent(
mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils;
/**
* Returns `true` if `element` is any React element.
*/
export function isElement(element: any): boolean;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
*/
export function isElementOfType<T extends HTMLElement>(
element: ReactElement, type: string): element is ReactHTMLElement<T>;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
*/
export function isElementOfType<P extends DOMAttributes<{}>, T extends Element>(
element: ReactElement, type: string): element is DOMElement<P, T>;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
*/
export function isElementOfType<P>(
element: ReactElement, type: SFC<P>): element is SFCElement<P>;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
*/
export function isElementOfType<P, T extends Component<P>, C extends ComponentClass<P>>(
element: ReactElement, type: ClassType<P, T, C>): element is CElement<P, T>;
/**
* Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
*/
export function isDOMComponent(instance: ReactInstance): instance is Element;
/**
* Returns `true` if `instance` is a user-defined component, such as a class or a function.
*/
export function isCompositeComponent(instance: ReactInstance): instance is Component<any>;
/**
* Returns `true` if `instance` is a component whose type is of a React `componentClass`.
*/
export function isCompositeComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
instance: ReactInstance, type: ClassType<any, T, C>): boolean;
/**
* Traverse all components in `tree` and accumulate all components where
* `test(component)` is `true`. This is not that useful on its own, but it's used
* as a primitive for other test utils.
*/
export function findAllInRenderedTree(
root: Component<any>,
fn: (i: ReactInstance) => boolean): ReactInstance[];
/**
* Finds all DOM elements of components in the rendered tree that are
* DOM components with the class name matching `className`.
*/
export function scryRenderedDOMComponentsWithClass(
root: Component<any>,
className: string): Element[];
/**
* Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result,
* and returns that one result, or throws exception if there is any other
* number of matches besides one.
*/
export function findRenderedDOMComponentWithClass(
root: Component<any>,
className: string): Element;
/**
* Finds all DOM elements of components in the rendered tree that are
* DOM components with the tag name matching `tagName`.
*/
export function scryRenderedDOMComponentsWithTag(
root: Component<any>,
tagName: string): Element[];
/**
* Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result,
* and returns that one result, or throws exception if there is any other
* number of matches besides one.
*/
export function findRenderedDOMComponentWithTag(
root: Component<any>,
tagName: string): Element;
/**
* Finds all instances of components with type equal to `componentClass`.
*/
export function scryRenderedComponentsWithType<T extends Component<any>, C extends ComponentClass<any>>(
root: Component<any>,
type: ClassType<any, T, C>): T[];
/**
* Same as `scryRenderedComponentsWithType()` but expects there to be one result
* and returns that one result, or throws exception if there is any other
* number of matches besides one.
*/
export function findRenderedComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
root: Component<any>,
type: ClassType<any, T, C>): T;
/**
* Call this in your tests to create a shallow renderer.
*/
export function createRenderer(): ShallowRenderer;
/**
* Wrap any code rendering and triggering updates to your components into `act()` calls.
*
* Ensures that the behavior in your tests matches what happens in the browser
* more closely by executing pending `useEffect`s before returning. This also
* reduces the amount of re-renders done.
*
* @param callback A synchronous, void callback that will execute as a single, complete React commit.
*
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
*/
// NOTES
// - the order of these signatures matters - typescript will check the signatures in source order.
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
// `strictNullChecks: false`.
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
declare const UNDEFINED_VOID_ONLY: unique symbol;
// tslint:disable-next-line: void-return
type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
export function act(callback: () => Promise<void>): Promise<undefined>;
export function act(callback: () => VoidOrUndefinedOnly): void;
// Intentionally doesn't extend PromiseLike<never>.
// Ideally this should be as hard to accidentally use as possible.
export interface DebugPromiseLike {
// the actual then() in here is 0-ary, but that doesn't count as a PromiseLike.
then(onfulfilled: (value: never) => never, onrejected: (reason: never) => never): never;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment