-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #40415 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
- Loading branch information
Showing
4 changed files
with
177 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { owner_symbol } from './symbols'; | ||
|
||
declare namespace InternalAsyncWrapBinding { | ||
interface Resource { | ||
[owner_symbol]?: PublicResource; | ||
} | ||
type PublicResource = object; | ||
|
||
type EmitHook = (asyncId: number) => void; | ||
|
||
type PromiseHook = (promise: Promise<unknown>, parent: Promise<unknown>) => void; | ||
|
||
interface Providers { | ||
NONE: 0; | ||
DIRHANDLE: 1; | ||
DNSCHANNEL: 2; | ||
ELDHISTOGRAM: 3; | ||
FILEHANDLE: 4; | ||
FILEHANDLECLOSEREQ: 5; | ||
FIXEDSIZEBLOBCOPY: 6; | ||
FSEVENTWRAP: 7; | ||
FSREQCALLBACK: 8; | ||
FSREQPROMISE: 9; | ||
GETADDRINFOREQWRAP: 10; | ||
GETNAMEINFOREQWRAP: 11; | ||
HEAPSNAPSHOT: 12; | ||
HTTP2SESSION: 13; | ||
HTTP2STREAM: 14; | ||
HTTP2PING: 15; | ||
HTTP2SETTINGS: 16; | ||
HTTPINCOMINGMESSAGE: 17; | ||
HTTPCLIENTREQUEST: 18; | ||
JSSTREAM: 19; | ||
JSUDPWRAP: 20; | ||
MESSAGEPORT: 21; | ||
PIPECONNECTWRAP: 22; | ||
PIPESERVERWRAP: 23; | ||
PIPEWRAP: 24; | ||
PROCESSWRAP: 25; | ||
PROMISE: 26; | ||
QUERYWRAP: 27; | ||
SHUTDOWNWRAP: 28; | ||
SIGNALWRAP: 29; | ||
STATWATCHER: 30; | ||
STREAMPIPE: 31; | ||
TCPCONNECTWRAP: 32; | ||
TCPSERVERWRAP: 33; | ||
TCPWRAP: 34; | ||
TTYWRAP: 35; | ||
UDPSENDWRAP: 36; | ||
UDPWRAP: 37; | ||
SIGINTWATCHDOG: 38; | ||
WORKER: 39; | ||
WORKERHEAPSNAPSHOT: 40; | ||
WRITEWRAP: 41; | ||
ZLIB: 42; | ||
CHECKPRIMEREQUEST: 43; | ||
PBKDF2REQUEST: 44; | ||
KEYPAIRGENREQUEST: 45; | ||
KEYGENREQUEST: 46; | ||
KEYEXPORTREQUEST: 47; | ||
CIPHERREQUEST: 48; | ||
DERIVEBITSREQUEST: 49; | ||
HASHREQUEST: 50; | ||
RANDOMBYTESREQUEST: 51; | ||
RANDOMPRIMEREQUEST: 52; | ||
SCRYPTREQUEST: 53; | ||
SIGNREQUEST: 54; | ||
TLSWRAP: 55; | ||
VERIFYREQUEST: 56; | ||
INSPECTORJSBINDING: 57; | ||
} | ||
} | ||
|
||
declare function InternalBinding(binding: 'async_wrap'): { | ||
setupHooks(): { | ||
init: ( | ||
asyncId: number, | ||
type: keyof InternalAsyncWrapBinding.Providers, | ||
triggerAsyncId: number, | ||
resource: InternalAsyncWrapBinding.Resource, | ||
) => void; | ||
before: InternalAsyncWrapBinding.EmitHook; | ||
after: InternalAsyncWrapBinding.EmitHook; | ||
destroy: InternalAsyncWrapBinding.EmitHook; | ||
promise_resolve: InternalAsyncWrapBinding.EmitHook; | ||
}; | ||
setCallbackTrampoline( | ||
callback: ( | ||
asyncId: number, | ||
resource: InternalAsyncWrapBinding.Resource, | ||
cb: ( | ||
cb: (...args: any[]) => boolean | undefined, | ||
...args: any[] | ||
) => boolean | undefined, | ||
...args: any[] | ||
) => boolean | undefined | ||
): void; | ||
pushAsyncContext(asyncId: number, triggerAsyncId: number): void; | ||
popAsyncContext(asyncId: number): boolean; | ||
executionAsyncResource(index: number): InternalAsyncWrapBinding.PublicResource | null; | ||
clearAsyncIdStack(): void; | ||
queueDestroyAsyncId(asyncId: number): void; | ||
setPromiseHooks( | ||
initHook: ((promise: Promise<unknown>, parent?: Promise<unknown>) => void) | undefined, | ||
promiseBeforeHook: InternalAsyncWrapBinding.PromiseHook | undefined, | ||
promiseAfterHook: InternalAsyncWrapBinding.PromiseHook | undefined, | ||
promiseResolveHook: InternalAsyncWrapBinding.PromiseHook | undefined | ||
): void; | ||
registerDestroyHook(promise: Promise<unknown>, asyncId: number, destroyed: { destroyed: boolean }): void; | ||
async_hook_fields: Uint32Array; | ||
async_id_fields: Float64Array; | ||
async_ids_stack: Float64Array; | ||
execution_async_resources: InternalAsyncWrapBinding.Resource[]; | ||
constants: { | ||
kInit: 0; | ||
kBefore: 1; | ||
kAfter: 2; | ||
kDestroy: 3; | ||
kPromiseResolve: 4; | ||
kTotals: 5; | ||
kCheck: 6; | ||
kStackLength: 7; | ||
kUsesExecutionAsyncResource: 8; | ||
|
||
kExecutionAsyncId: 0; | ||
kTriggerAsyncId: 1; | ||
kAsyncIdCounter: 2; | ||
kDefaultTriggerAsyncId: 3; | ||
}; | ||
Providers: InternalAsyncWrapBinding.Providers; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
declare namespace InternalBlobBinding { | ||
interface BlobHandle { | ||
slice(start: number, end: number): BlobHandle; | ||
} | ||
|
||
class FixedSizeBlobCopyJob { | ||
constructor(handle: BlobHandle); | ||
run(): ArrayBuffer | undefined; | ||
ondone: (err: unknown, res?: ArrayBuffer) => void; | ||
} | ||
} | ||
|
||
declare function InternalBinding(binding: 'blob'): { | ||
createBlob(sources: Array<Uint8Array | InternalBlobBinding.BlobHandle>, length: number): InternalBlobBinding.BlobHandle; | ||
FixedSizeBlobCopyJob: typeof InternalBlobBinding.FixedSizeBlobCopyJob; | ||
getDataObject(id: string): [handle: InternalBlobBinding.BlobHandle | undefined, length: number, type: string] | undefined; | ||
storeDataObject(id: string, handle: InternalBlobBinding.BlobHandle, size: number, type: string): void; | ||
revokeDataObject(id: string): void; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
declare namespace InternalSymbolsBinding { | ||
const async_id_symbol: unique symbol; | ||
const handle_onclose_symbol: unique symbol; | ||
const no_message_symbol: unique symbol; | ||
const messaging_deserialize_symbol: unique symbol; | ||
const messaging_transfer_symbol: unique symbol; | ||
const messaging_clone_symbol: unique symbol; | ||
const messaging_transfer_list_symbol: unique symbol; | ||
const oninit_symbol: unique symbol; | ||
const owner_symbol: unique symbol; | ||
const onpskexchange_symbol: unique symbol; | ||
const trigger_async_id_symbol: unique symbol; | ||
} | ||
export const async_id_symbol: unique symbol; | ||
export const handle_onclose_symbol: unique symbol; | ||
export const no_message_symbol: unique symbol; | ||
export const messaging_deserialize_symbol: unique symbol; | ||
export const messaging_transfer_symbol: unique symbol; | ||
export const messaging_clone_symbol: unique symbol; | ||
export const messaging_transfer_list_symbol: unique symbol; | ||
export const oninit_symbol: unique symbol; | ||
export const owner_symbol: unique symbol; | ||
export const onpskexchange_symbol: unique symbol; | ||
export const trigger_async_id_symbol: unique symbol; | ||
|
||
declare function InternalBinding(binding: 'symbols'): { | ||
async_id_symbol: typeof InternalSymbolsBinding.async_id_symbol; | ||
handle_onclose_symbol: typeof InternalSymbolsBinding.handle_onclose_symbol; | ||
no_message_symbol: typeof InternalSymbolsBinding.no_message_symbol; | ||
messaging_deserialize_symbol: typeof InternalSymbolsBinding.messaging_deserialize_symbol; | ||
messaging_transfer_symbol: typeof InternalSymbolsBinding.messaging_transfer_symbol; | ||
messaging_clone_symbol: typeof InternalSymbolsBinding.messaging_clone_symbol; | ||
messaging_transfer_list_symbol: typeof InternalSymbolsBinding.messaging_transfer_list_symbol; | ||
oninit_symbol: typeof InternalSymbolsBinding.oninit_symbol; | ||
owner_symbol: typeof InternalSymbolsBinding.owner_symbol; | ||
onpskexchange_symbol: typeof InternalSymbolsBinding.onpskexchange_symbol; | ||
trigger_async_id_symbol: typeof InternalSymbolsBinding.trigger_async_id_symbol; | ||
async_id_symbol: typeof async_id_symbol; | ||
handle_onclose_symbol: typeof handle_onclose_symbol; | ||
no_message_symbol: typeof no_message_symbol; | ||
messaging_deserialize_symbol: typeof messaging_deserialize_symbol; | ||
messaging_transfer_symbol: typeof messaging_transfer_symbol; | ||
messaging_clone_symbol: typeof messaging_clone_symbol; | ||
messaging_transfer_list_symbol: typeof messaging_transfer_list_symbol; | ||
oninit_symbol: typeof oninit_symbol; | ||
owner_symbol: typeof owner_symbol; | ||
onpskexchange_symbol: typeof onpskexchange_symbol; | ||
trigger_async_id_symbol: typeof trigger_async_id_symbol; | ||
}; |