Skip to content

Commit b4194ff

Browse files
Mesteerytargos
authored andcommitted
typings: add more bindings typings
PR-URL: #40415 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent c104f5a commit b4194ff

File tree

4 files changed

+177
-26
lines changed

4 files changed

+177
-26
lines changed

tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"include": ["lib","doc"],
3-
"exclude": ["src","tools","out"],
2+
"include": ["lib", "doc"],
3+
"exclude": ["src", "tools", "out"],
44
"files": [
5+
"./typings/internalBinding/async_wrap.d.ts",
6+
"./typings/internalBinding/blob.d.ts",
57
"./typings/internalBinding/config.d.ts",
68
"./typings/internalBinding/constants.d.ts",
79
"./typings/internalBinding/fs.d.ts",
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import { owner_symbol } from './symbols';
2+
3+
declare 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+
75+
declare 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(promise: Promise<unknown>, 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+
};

typings/internalBinding/blob.d.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
declare namespace InternalBlobBinding {
2+
interface BlobHandle {
3+
slice(start: number, end: number): BlobHandle;
4+
}
5+
6+
class FixedSizeBlobCopyJob {
7+
constructor(handle: BlobHandle);
8+
run(): ArrayBuffer | undefined;
9+
ondone: (err: unknown, res?: ArrayBuffer) => void;
10+
}
11+
}
12+
13+
declare function InternalBinding(binding: 'blob'): {
14+
createBlob(sources: Array<Uint8Array | InternalBlobBinding.BlobHandle>, length: number): InternalBlobBinding.BlobHandle;
15+
FixedSizeBlobCopyJob: typeof InternalBlobBinding.FixedSizeBlobCopyJob;
16+
getDataObject(id: string): [handle: InternalBlobBinding.BlobHandle | undefined, length: number, type: string] | undefined;
17+
storeDataObject(id: string, handle: InternalBlobBinding.BlobHandle, size: number, type: string): void;
18+
revokeDataObject(id: string): void;
19+
};

typings/internalBinding/symbols.d.ts

+22-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
declare namespace InternalSymbolsBinding {
2-
const async_id_symbol: unique symbol;
3-
const handle_onclose_symbol: unique symbol;
4-
const no_message_symbol: unique symbol;
5-
const messaging_deserialize_symbol: unique symbol;
6-
const messaging_transfer_symbol: unique symbol;
7-
const messaging_clone_symbol: unique symbol;
8-
const messaging_transfer_list_symbol: unique symbol;
9-
const oninit_symbol: unique symbol;
10-
const owner_symbol: unique symbol;
11-
const onpskexchange_symbol: unique symbol;
12-
const trigger_async_id_symbol: unique symbol;
13-
}
1+
export const async_id_symbol: unique symbol;
2+
export const handle_onclose_symbol: unique symbol;
3+
export const no_message_symbol: unique symbol;
4+
export const messaging_deserialize_symbol: unique symbol;
5+
export const messaging_transfer_symbol: unique symbol;
6+
export const messaging_clone_symbol: unique symbol;
7+
export const messaging_transfer_list_symbol: unique symbol;
8+
export const oninit_symbol: unique symbol;
9+
export const owner_symbol: unique symbol;
10+
export const onpskexchange_symbol: unique symbol;
11+
export const trigger_async_id_symbol: unique symbol;
1412

1513
declare function InternalBinding(binding: 'symbols'): {
16-
async_id_symbol: typeof InternalSymbolsBinding.async_id_symbol;
17-
handle_onclose_symbol: typeof InternalSymbolsBinding.handle_onclose_symbol;
18-
no_message_symbol: typeof InternalSymbolsBinding.no_message_symbol;
19-
messaging_deserialize_symbol: typeof InternalSymbolsBinding.messaging_deserialize_symbol;
20-
messaging_transfer_symbol: typeof InternalSymbolsBinding.messaging_transfer_symbol;
21-
messaging_clone_symbol: typeof InternalSymbolsBinding.messaging_clone_symbol;
22-
messaging_transfer_list_symbol: typeof InternalSymbolsBinding.messaging_transfer_list_symbol;
23-
oninit_symbol: typeof InternalSymbolsBinding.oninit_symbol;
24-
owner_symbol: typeof InternalSymbolsBinding.owner_symbol;
25-
onpskexchange_symbol: typeof InternalSymbolsBinding.onpskexchange_symbol;
26-
trigger_async_id_symbol: typeof InternalSymbolsBinding.trigger_async_id_symbol;
14+
async_id_symbol: typeof async_id_symbol;
15+
handle_onclose_symbol: typeof handle_onclose_symbol;
16+
no_message_symbol: typeof no_message_symbol;
17+
messaging_deserialize_symbol: typeof messaging_deserialize_symbol;
18+
messaging_transfer_symbol: typeof messaging_transfer_symbol;
19+
messaging_clone_symbol: typeof messaging_clone_symbol;
20+
messaging_transfer_list_symbol: typeof messaging_transfer_list_symbol;
21+
oninit_symbol: typeof oninit_symbol;
22+
owner_symbol: typeof owner_symbol;
23+
onpskexchange_symbol: typeof onpskexchange_symbol;
24+
trigger_async_id_symbol: typeof trigger_async_id_symbol;
2725
};

0 commit comments

Comments
 (0)