typings: improve internal binding types · nodejs/node@76bc4d6 · GitHub
Skip to content

Commit 76bc4d6

Browse files
targosRafaelGSS
authored andcommitted
typings: improve internal binding types
- Add typings for `async_context_frame`, `icu`, and `sea` bindings - Add a few missing exports on other bindings - Add a few missing primordials PR-URL: #59176 Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 244d0c3 commit 76bc4d6

9 files changed

Lines changed: 72 additions & 1 deletion

File tree

typings/globals.d.ts

Lines changed: 7 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface AsyncContextFrameBinding {
2+
getContinuationPreservedEmbedderData(): unknown,
3+
setContinuationPreservedEmbedderData(frame: unknown): void,
4+
}

typings/internalBinding/constants.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ export interface ConstantsBinding {
287287
BROTLI_ENCODE: 9;
288288
ZSTD_COMPRESS: 10;
289289
ZSTD_DECOMPRESS: 11;
290+
ZSTD_e_continue: 0;
291+
ZSTD_e_flush: 1;
292+
ZSTD_e_end: 2;
290293
Z_MIN_WINDOWBITS: 8;
291294
Z_MAX_WINDOWBITS: 15;
292295
Z_DEFAULT_WINDOWBITS: 15;

typings/internalBinding/http_parser.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ declare namespace InternalHttpParserBinding {
22
type Buffer = Uint8Array;
33
type Stream = object;
44

5+
class ConnectionsList {
6+
constructor();
7+
8+
all(): HTTPParser[];
9+
idle(): HTTPParser[];
10+
active(): HTTPParser[];
11+
expired(): HTTPParser[];
12+
}
13+
514
class HTTPParser {
615
static REQUEST: 1;
716
static RESPONSE: 2;
@@ -40,6 +49,8 @@ declare namespace InternalHttpParserBinding {
4049
}
4150

4251
export interface HttpParserBinding {
43-
methods: string[];
52+
ConnectionsList: typeof InternalHttpParserBinding.ConnectionsList;
4453
HTTPParser: typeof InternalHttpParserBinding.HTTPParser;
54+
allMethods: string[];
55+
methods: string[];
4556
}

typings/internalBinding/icu.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export interface ICUBinding {
2+
Converter: object;
3+
decode(
4+
converter: object,
5+
input: ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
6+
flags: number,
7+
fromEncoding: string,
8+
): string;
9+
getConverter(label: string, flags: number): object | undefined;
10+
getStringWidth(value: string, ambiguousAsFullWidth?: boolean, expandEmojiSequence?: boolean): number;
11+
hasConverter(label: string): boolean;
12+
icuErrName(status: number): string;
13+
transcode(
14+
input: ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
15+
fromEncoding: string,
16+
toEncoding: string,
17+
): Buffer | number;
18+
}

typings/internalBinding/sea.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface SeaBinding {
2+
getAsset(key: string): ArrayBuffer | undefined;
3+
isExperimentalSeaWarningNeeded(): boolean;
4+
isSea(): boolean;
5+
}

typings/internalBinding/symbols.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const async_id_symbol: unique symbol;
22
export const handle_onclose_symbol: unique symbol;
3+
export const imported_cjs_symbol: unique symbol;
34
export const no_message_symbol: unique symbol;
45
export const messaging_deserialize_symbol: unique symbol;
56
export const messaging_transfer_symbol: unique symbol;
@@ -13,6 +14,7 @@ export const trigger_async_id_symbol: unique symbol;
1314
export interface SymbolsBinding {
1415
async_id_symbol: typeof async_id_symbol;
1516
handle_onclose_symbol: typeof handle_onclose_symbol;
17+
imported_cjs_symbol: typeof imported_cjs_symbol;
1618
no_message_symbol: typeof no_message_symbol;
1719
messaging_deserialize_symbol: typeof messaging_deserialize_symbol;
1820
messaging_transfer_symbol: typeof messaging_transfer_symbol;

typings/internalBinding/util.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,22 @@ export interface UtilBinding {
4646
parseEnv(content: string): Record<string, string>;
4747
styleText(format: Array<string> | string, text: string): string;
4848
isInsideNodeModules(frameLimit: number, defaultValue: unknown): boolean;
49+
50+
constants: {
51+
kPending: 0;
52+
kFulfilled: 1;
53+
kRejected: 2;
54+
kExiting: 0;
55+
kExitCode: 1;
56+
kHasExitCode: 2;
57+
ALL_PROPERTIES: 0;
58+
ONLY_WRITABLE: 1;
59+
ONLY_ENUMERABLE: 2;
60+
ONLY_CONFIGURABLE: 4;
61+
SKIP_STRINGS: 8;
62+
SKIP_SYMBOLS: 16;
63+
kDisallowCloneAndTransfer: 0;
64+
kTransferable: 1;
65+
kCloneable: 2;
66+
};
4967
}

typings/primordials.d.ts

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)