1import { owner_symbol } from './symbols'; 2 3declare namespace InternalAsyncWrapBinding { 4 interface Resource { 5 [owner_symbol]?: PublicResource; 6 } 7 type PublicResource = object; 8 9 type EmitHook = (asyncId: number) => void; 10 11 type PromiseHook = (promise: Promise<unknown>, parent: Promise<unknown>) => void; 12 13 interface Providers { 14 NONE: 0; 15 DIRHANDLE: 1; 16 DNSCHANNEL: 2; 17 ELDHISTOGRAM: 3; 18 FILEHANDLE: 4; 19 FILEHANDLECLOSEREQ: 5; 20 FIXEDSIZEBLOBCOPY: 6; 21 FSEVENTWRAP: 7; 22 FSREQCALLBACK: 8; 23 FSREQPROMISE: 9; 24 GETADDRINFOREQWRAP: 10; 25 GETNAMEINFOREQWRAP: 11; 26 HEAPSNAPSHOT: 12; 27 HTTP2SESSION: 13; 28 HTTP2STREAM: 14; 29 HTTP2PING: 15; 30 HTTP2SETTINGS: 16; 31 HTTPINCOMINGMESSAGE: 17; 32 HTTPCLIENTREQUEST: 18; 33 JSSTREAM: 19; 34 JSUDPWRAP: 20; 35 MESSAGEPORT: 21; 36 PIPECONNECTWRAP: 22; 37 PIPESERVERWRAP: 23; 38 PIPEWRAP: 24; 39 PROCESSWRAP: 25; 40 PROMISE: 26; 41 QUERYWRAP: 27; 42 SHUTDOWNWRAP: 28; 43 SIGNALWRAP: 29; 44 STATWATCHER: 30; 45 STREAMPIPE: 31; 46 TCPCONNECTWRAP: 32; 47 TCPSERVERWRAP: 33; 48 TCPWRAP: 34; 49 TTYWRAP: 35; 50 UDPSENDWRAP: 36; 51 UDPWRAP: 37; 52 SIGINTWATCHDOG: 38; 53 WORKER: 39; 54 WORKERHEAPSNAPSHOT: 40; 55 WRITEWRAP: 41; 56 ZLIB: 42; 57 CHECKPRIMEREQUEST: 43; 58 PBKDF2REQUEST: 44; 59 KEYPAIRGENREQUEST: 45; 60 KEYGENREQUEST: 46; 61 KEYEXPORTREQUEST: 47; 62 CIPHERREQUEST: 48; 63 DERIVEBITSREQUEST: 49; 64 HASHREQUEST: 50; 65 RANDOMBYTESREQUEST: 51; 66 RANDOMPRIMEREQUEST: 52; 67 SCRYPTREQUEST: 53; 68 SIGNREQUEST: 54; 69 TLSWRAP: 55; 70 VERIFYREQUEST: 56; 71 INSPECTORJSBINDING: 57; 72 } 73} 74 75declare function InternalBinding(binding: 'async_wrap'): { 76 setupHooks(): { 77 init: ( 78 asyncId: number, 79 type: keyof InternalAsyncWrapBinding.Providers, 80 triggerAsyncId: number, 81 resource: InternalAsyncWrapBinding.Resource, 82 ) => void; 83 before: InternalAsyncWrapBinding.EmitHook; 84 after: InternalAsyncWrapBinding.EmitHook; 85 destroy: InternalAsyncWrapBinding.EmitHook; 86 promise_resolve: InternalAsyncWrapBinding.EmitHook; 87 }; 88 setCallbackTrampoline( 89 callback: ( 90 asyncId: number, 91 resource: InternalAsyncWrapBinding.Resource, 92 cb: ( 93 cb: (...args: any[]) => boolean | undefined, 94 ...args: any[] 95 ) => boolean | undefined, 96 ...args: any[] 97 ) => boolean | undefined 98 ): void; 99 pushAsyncContext(asyncId: number, triggerAsyncId: number): void; 100 popAsyncContext(asyncId: number): boolean; 101 executionAsyncResource(index: number): InternalAsyncWrapBinding.PublicResource | null; 102 clearAsyncIdStack(): void; 103 queueDestroyAsyncId(asyncId: number): void; 104 setPromiseHooks( 105 initHook: ((promise: Promise<unknown>, parent?: Promise<unknown>) => void) | undefined, 106 promiseBeforeHook: InternalAsyncWrapBinding.PromiseHook | undefined, 107 promiseAfterHook: InternalAsyncWrapBinding.PromiseHook | undefined, 108 promiseResolveHook: InternalAsyncWrapBinding.PromiseHook | undefined 109 ): void; 110 registerDestroyHook(resource: object, asyncId: number, destroyed?: { destroyed: boolean }): void; 111 async_hook_fields: Uint32Array; 112 async_id_fields: Float64Array; 113 async_ids_stack: Float64Array; 114 execution_async_resources: InternalAsyncWrapBinding.Resource[]; 115 constants: { 116 kInit: 0; 117 kBefore: 1; 118 kAfter: 2; 119 kDestroy: 3; 120 kPromiseResolve: 4; 121 kTotals: 5; 122 kCheck: 6; 123 kStackLength: 7; 124 kUsesExecutionAsyncResource: 8; 125 126 kExecutionAsyncId: 0; 127 kTriggerAsyncId: 1; 128 kAsyncIdCounter: 2; 129 kDefaultTriggerAsyncId: 3; 130 }; 131 Providers: InternalAsyncWrapBinding.Providers; 132}; 133