mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 13:09:21 +01:00
lib: fix internalBinding
typings
PR-URL: https://github.com/nodejs/node/pull/49742 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
parent
c0b4208fb9
commit
da7962fd4d
@ -174,9 +174,9 @@ const experimentalModuleList = new SafeSet();
|
||||
};
|
||||
}
|
||||
|
||||
// Set up internalBinding() in the closure.
|
||||
/**
|
||||
* @type {InternalBinding}
|
||||
* Set up internalBinding() in the closure.
|
||||
* @type {import('typings/globals').internalBinding}
|
||||
*/
|
||||
let internalBinding;
|
||||
{
|
||||
|
@ -2,22 +2,6 @@
|
||||
"include": ["lib", "doc"],
|
||||
"exclude": ["src", "tools", "out"],
|
||||
"files": [
|
||||
"./typings/internalBinding/async_wrap.d.ts",
|
||||
"./typings/internalBinding/blob.d.ts",
|
||||
"./typings/internalBinding/config.d.ts",
|
||||
"./typings/internalBinding/constants.d.ts",
|
||||
"./typings/internalBinding/fs.d.ts",
|
||||
"./typings/internalBinding/http_parser.d.ts",
|
||||
"./typings/internalBinding/messaging.d.ts",
|
||||
"./typings/internalBinding/options.d.ts",
|
||||
"./typings/internalBinding/os.d.ts",
|
||||
"./typings/internalBinding/serdes.d.ts",
|
||||
"./typings/internalBinding/symbols.d.ts",
|
||||
"./typings/internalBinding/timers.d.ts",
|
||||
"./typings/internalBinding/types.d.ts",
|
||||
"./typings/internalBinding/url.d.ts",
|
||||
"./typings/internalBinding/util.d.ts",
|
||||
"./typings/internalBinding/worker.d.ts",
|
||||
"./typings/globals.d.ts",
|
||||
"./typings/primordials.d.ts"
|
||||
],
|
||||
@ -25,7 +9,7 @@
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
"noEmit": true,
|
||||
"lib": ["ESNext"],
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"target": "ESNext",
|
||||
"module": "CommonJS",
|
||||
"baseUrl": ".",
|
||||
|
48
typings/globals.d.ts
vendored
48
typings/globals.d.ts
vendored
@ -1,3 +1,20 @@
|
||||
import {AsyncWrapBinding} from "./internalBinding/async_wrap";
|
||||
import {BlobBinding} from "./internalBinding/blob";
|
||||
import {ConfigBinding} from "./internalBinding/config";
|
||||
import {ConstantsBinding} from "./internalBinding/constants";
|
||||
import {HttpParserBinding} from "./internalBinding/http_parser";
|
||||
import {FsBinding} from "./internalBinding/fs";
|
||||
import {MessagingBinding} from "./internalBinding/messaging";
|
||||
import {OptionsBinding} from "./internalBinding/options";
|
||||
import {OSBinding} from "./internalBinding/os";
|
||||
import {SerdesBinding} from "./internalBinding/serdes";
|
||||
import {SymbolsBinding} from "./internalBinding/symbols";
|
||||
import {TimersBinding} from "./internalBinding/timers";
|
||||
import {TypesBinding} from "./internalBinding/types";
|
||||
import {URLBinding} from "./internalBinding/url";
|
||||
import {UtilBinding} from "./internalBinding/util";
|
||||
import {WorkerBinding} from "./internalBinding/worker";
|
||||
|
||||
declare type TypedArray =
|
||||
| Uint8Array
|
||||
| Uint8ClampedArray
|
||||
@ -10,3 +27,34 @@ declare type TypedArray =
|
||||
| Float64Array
|
||||
| BigUint64Array
|
||||
| BigInt64Array;
|
||||
|
||||
interface InternalBindingMap {
|
||||
async_wrap: AsyncWrapBinding;
|
||||
blob: BlobBinding;
|
||||
config: ConfigBinding;
|
||||
constants: ConstantsBinding;
|
||||
fs: FsBinding;
|
||||
http_parser: HttpParserBinding;
|
||||
messaging: MessagingBinding;
|
||||
options: OptionsBinding;
|
||||
os: OSBinding;
|
||||
serdes: SerdesBinding;
|
||||
symbols: SymbolsBinding;
|
||||
timers: TimersBinding;
|
||||
types: TypesBinding;
|
||||
url: URLBinding;
|
||||
util: UtilBinding;
|
||||
worker: WorkerBinding;
|
||||
}
|
||||
|
||||
type InternalBindingKeys = keyof InternalBindingMap;
|
||||
|
||||
declare function internalBinding<T extends InternalBindingKeys>(binding: T): InternalBindingMap[T]
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
internalBinding<T extends InternalBindingKeys>(binding: T): InternalBindingMap[T]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
typings/internalBinding/async_wrap.d.ts
vendored
4
typings/internalBinding/async_wrap.d.ts
vendored
@ -72,7 +72,7 @@ declare namespace InternalAsyncWrapBinding {
|
||||
}
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'async_wrap'): {
|
||||
export interface AsyncWrapBinding {
|
||||
setupHooks(): {
|
||||
init: (
|
||||
asyncId: number,
|
||||
@ -129,4 +129,4 @@ declare function InternalBinding(binding: 'async_wrap'): {
|
||||
kDefaultTriggerAsyncId: 3;
|
||||
};
|
||||
Providers: InternalAsyncWrapBinding.Providers;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/blob.d.ts
vendored
4
typings/internalBinding/blob.d.ts
vendored
@ -10,10 +10,10 @@ declare namespace InternalBlobBinding {
|
||||
}
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'blob'): {
|
||||
export interface BlobBinding {
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/config.d.ts
vendored
4
typings/internalBinding/config.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
declare function InternalBinding(binding: 'config'): {
|
||||
export interface ConfigBinding {
|
||||
isDebugBuild: boolean;
|
||||
hasOpenSSL: boolean;
|
||||
fipsMode: boolean;
|
||||
@ -9,4 +9,4 @@ declare function InternalBinding(binding: 'config'): {
|
||||
noBrowserGlobals: boolean;
|
||||
bits: number;
|
||||
hasDtrace: boolean;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/constants.d.ts
vendored
4
typings/internalBinding/constants.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
declare function InternalBinding(binding: 'constants'): {
|
||||
export interface ConstantsBinding {
|
||||
os: {
|
||||
UV_UDP_REUSEADDR: 4;
|
||||
dlopen: {
|
||||
@ -382,4 +382,4 @@ declare function InternalBinding(binding: 'constants'): {
|
||||
TRACE_EVENT_PHASE_LEAVE_CONTEXT: 41;
|
||||
TRACE_EVENT_PHASE_LINK_IDS: 61;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
8
typings/internalBinding/fs.d.ts
vendored
8
typings/internalBinding/fs.d.ts
vendored
@ -109,7 +109,7 @@ declare namespace InternalFSBinding {
|
||||
|
||||
function internalModuleReadJSON(path: string): [] | [string, boolean];
|
||||
function internalModuleStat(path: string): number;
|
||||
|
||||
|
||||
function lchown(path: string, uid: number, gid: number, req: FSReqCallback): void;
|
||||
function lchown(path: string, uid: number, gid: number, req: undefined, ctx: FSSyncContext): void;
|
||||
function lchown(path: string, uid: number, gid: number, usePromises: typeof kUsePromises): Promise<void>;
|
||||
@ -198,7 +198,7 @@ declare namespace InternalFSBinding {
|
||||
function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, req: FSReqCallback): void;
|
||||
function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, req: undefined, ctx: FSSyncContext): void;
|
||||
function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, usePromises: typeof kUsePromises): Promise<void>;
|
||||
|
||||
|
||||
function unlink(path: string, req: FSReqCallback): void;
|
||||
function unlink(path: string, req: undefined, ctx: FSSyncContext): void;
|
||||
function unlink(path: string, usePromises: typeof kUsePromises): Promise<void>;
|
||||
@ -220,7 +220,7 @@ declare namespace InternalFSBinding {
|
||||
function writeString(fd: number, value: string, pos: unknown, encoding: unknown, usePromises: typeof kUsePromises): Promise<number>;
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'fs'): {
|
||||
export interface FsBinding {
|
||||
FSReqCallback: typeof InternalFSBinding.FSReqCallback;
|
||||
|
||||
FileHandle: typeof InternalFSBinding.FileHandle;
|
||||
@ -269,4 +269,4 @@ declare function InternalBinding(binding: 'fs'): {
|
||||
writeBuffer: typeof InternalFSBinding.writeBuffer;
|
||||
writeBuffers: typeof InternalFSBinding.writeBuffers;
|
||||
writeString: typeof InternalFSBinding.writeString;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/http_parser.d.ts
vendored
4
typings/internalBinding/http_parser.d.ts
vendored
@ -39,7 +39,7 @@ declare namespace InternalHttpParserBinding {
|
||||
}
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'http_parser'): {
|
||||
export interface HttpParserBinding {
|
||||
methods: string[];
|
||||
HTTPParser: typeof InternalHttpParserBinding.HTTPParser;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/messaging.d.ts
vendored
4
typings/internalBinding/messaging.d.ts
vendored
@ -17,7 +17,7 @@ declare namespace InternalMessagingBinding {
|
||||
}
|
||||
|
||||
|
||||
declare function InternalBinding(binding: 'messaging'): {
|
||||
export interface MessagingBinding {
|
||||
DOMException: typeof import('internal/per_context/domexception').DOMException;
|
||||
MessageChannel: typeof InternalMessagingBinding.MessageChannel;
|
||||
MessagePort: typeof InternalMessagingBinding.MessagePort;
|
||||
@ -29,4 +29,4 @@ declare function InternalBinding(binding: 'messaging'): {
|
||||
moveMessagePortToContext(port: typeof InternalMessagingBinding.MessagePort, context: any): typeof InternalMessagingBinding.MessagePort;
|
||||
setDeserializerCreateObjectFunction(func: (deserializeInfo: string) => any): void;
|
||||
broadcastChannel(name: string): typeof InternalMessagingBinding.MessagePort;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/options.d.ts
vendored
4
typings/internalBinding/options.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
declare function InternalBinding(binding: 'options'): {
|
||||
export interface OptionsBinding {
|
||||
getOptions(): {
|
||||
options: Map<
|
||||
string,
|
||||
@ -32,4 +32,4 @@ declare function InternalBinding(binding: 'options'): {
|
||||
kHostPort: 6;
|
||||
kStringList: 7;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/os.d.ts
vendored
4
typings/internalBinding/os.d.ts
vendored
@ -2,7 +2,7 @@ declare namespace InternalOSBinding {
|
||||
type OSContext = {};
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'os'): {
|
||||
export interface OSBinding {
|
||||
getHostname(ctx: InternalOSBinding.OSContext): string | undefined;
|
||||
getLoadAvg(array: Float64Array): void;
|
||||
getUptime(): number;
|
||||
@ -22,4 +22,4 @@ declare function InternalBinding(binding: 'os'): {
|
||||
getPriority(pid: number, ctx: InternalOSBinding.OSContext): number | undefined;
|
||||
getOSInformation(ctx: InternalOSBinding.OSContext): [sysname: string, version: string, release: string];
|
||||
isBigEndian: boolean;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/serdes.d.ts
vendored
4
typings/internalBinding/serdes.d.ts
vendored
@ -30,7 +30,7 @@ declare namespace InternalSerdesBinding {
|
||||
}
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'serdes'): {
|
||||
export interface SerdesBinding {
|
||||
Serializer: typeof InternalSerdesBinding.Serializer;
|
||||
Deserializer: typeof InternalSerdesBinding.Deserializer;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/symbols.d.ts
vendored
4
typings/internalBinding/symbols.d.ts
vendored
@ -10,7 +10,7 @@ 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'): {
|
||||
export interface SymbolsBinding {
|
||||
async_id_symbol: typeof async_id_symbol;
|
||||
handle_onclose_symbol: typeof handle_onclose_symbol;
|
||||
no_message_symbol: typeof no_message_symbol;
|
||||
@ -22,4 +22,4 @@ declare function InternalBinding(binding: 'symbols'): {
|
||||
owner_symbol: typeof owner_symbol;
|
||||
onpskexchange_symbol: typeof onpskexchange_symbol;
|
||||
trigger_async_id_symbol: typeof trigger_async_id_symbol;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/timers.d.ts
vendored
4
typings/internalBinding/timers.d.ts
vendored
@ -1,8 +1,8 @@
|
||||
declare function InternalBinding(binding: 'timers'): {
|
||||
export interface TimersBinding {
|
||||
getLibuvNow(): number;
|
||||
setupTimers(immediateCallback: () => void, timersCallback: (now: number) => void): void;
|
||||
scheduleTimer(msecs: number): void;
|
||||
toggleTimerRef(value: boolean): void;
|
||||
toggleImmediateRef(value: boolean): void;
|
||||
immediateInfo: Uint32Array;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/types.d.ts
vendored
4
typings/internalBinding/types.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
declare function InternalBinding(binding: 'types'): {
|
||||
export interface TypesBinding {
|
||||
isAsyncFunction(value: unknown): value is (...args: unknown[]) => Promise<unknown>;
|
||||
isGeneratorFunction(value: unknown): value is GeneratorFunction;
|
||||
isAnyArrayBuffer(value: unknown): value is (ArrayBuffer | SharedArrayBuffer);
|
||||
@ -23,4 +23,4 @@ declare function InternalBinding(binding: 'types'): {
|
||||
isNumberObject: (value: unknown) => value is Number;
|
||||
isBooleanObject: (value: unknown) => value is Boolean,
|
||||
isBigIntObject: (value: unknown) => value is BigInt;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/url.d.ts
vendored
4
typings/internalBinding/url.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import type { urlUpdateActions } from 'internal/url'
|
||||
|
||||
declare function InternalBinding(binding: 'url'): {
|
||||
export interface URLBinding {
|
||||
urlComponents: Uint32Array;
|
||||
|
||||
domainToASCII(input: string): string;
|
||||
@ -9,4 +9,4 @@ declare function InternalBinding(binding: 'url'): {
|
||||
format(input: string, fragment?: boolean, unicode?: boolean, search?: boolean, auth?: boolean): string;
|
||||
parse(input: string, base?: string): string | false;
|
||||
update(input: string, actionType: typeof urlUpdateActions, value: string): string | false;
|
||||
};
|
||||
}
|
||||
|
4
typings/internalBinding/util.d.ts
vendored
4
typings/internalBinding/util.d.ts
vendored
@ -7,7 +7,7 @@ declare namespace InternalUtilBinding {
|
||||
}
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'util'): {
|
||||
export interface UtilBinding {
|
||||
// PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES, defined in src/env_properties.h
|
||||
arrow_message_private_symbol: 1;
|
||||
contextify_context_private_symbol: 2;
|
||||
@ -44,4 +44,4 @@ declare function InternalBinding(binding: 'util'): {
|
||||
WeakReference: typeof InternalUtilBinding.WeakReference;
|
||||
guessHandleType(fd: number): 'TCP' | 'TTY' | 'UDP' | 'FILE' | 'PIPE' | 'UNKNOWN';
|
||||
toUSVString(str: string, start: number): string;
|
||||
};
|
||||
}
|
||||
|
6
typings/internalBinding/worker.d.ts
vendored
6
typings/internalBinding/worker.d.ts
vendored
@ -1,3 +1,5 @@
|
||||
import { InternalMessagingBinding } from './messaging';
|
||||
|
||||
declare namespace InternalWorkerBinding {
|
||||
class Worker {
|
||||
constructor(
|
||||
@ -18,7 +20,7 @@ declare namespace InternalWorkerBinding {
|
||||
}
|
||||
}
|
||||
|
||||
declare function InternalBinding(binding: 'worker'): {
|
||||
export interface WorkerBinding {
|
||||
Worker: typeof InternalWorkerBinding.Worker;
|
||||
getEnvMessagePort(): InternalMessagingBinding.MessagePort;
|
||||
threadId: number;
|
||||
@ -30,4 +32,4 @@ declare function InternalBinding(binding: 'worker'): {
|
||||
kCodeRangeSizeMb: number;
|
||||
kStackSizeMb: number;
|
||||
kTotalResourceLimitCount: number;
|
||||
};
|
||||
}
|
||||
|
9
typings/primordials.d.ts
vendored
9
typings/primordials.d.ts
vendored
@ -203,7 +203,6 @@ declare namespace primordials {
|
||||
export const DatePrototypeToTimeString: UncurryThis<typeof Date.prototype.toTimeString>
|
||||
export const DatePrototypeToISOString: UncurryThis<typeof Date.prototype.toISOString>
|
||||
export const DatePrototypeToUTCString: UncurryThis<typeof Date.prototype.toUTCString>
|
||||
export const DatePrototypeToGMTString: UncurryThis<typeof Date.prototype.toGMTString>
|
||||
export const DatePrototypeGetDate: UncurryThis<typeof Date.prototype.getDate>
|
||||
export const DatePrototypeSetDate: UncurryThis<typeof Date.prototype.setDate>
|
||||
export const DatePrototypeGetDay: UncurryThis<typeof Date.prototype.getDay>
|
||||
@ -238,8 +237,6 @@ declare namespace primordials {
|
||||
export const DatePrototypeGetUTCSeconds: UncurryThis<typeof Date.prototype.getUTCSeconds>
|
||||
export const DatePrototypeSetUTCSeconds: UncurryThis<typeof Date.prototype.setUTCSeconds>
|
||||
export const DatePrototypeValueOf: UncurryThis<typeof Date.prototype.valueOf>
|
||||
export const DatePrototypeGetYear: UncurryThis<typeof Date.prototype.getYear>
|
||||
export const DatePrototypeSetYear: UncurryThis<typeof Date.prototype.setYear>
|
||||
export const DatePrototypeToJSON: UncurryThis<typeof Date.prototype.toJSON>
|
||||
export const DatePrototypeToLocaleString: UncurryThis<typeof Date.prototype.toLocaleString>
|
||||
export const DatePrototypeToLocaleDateString: UncurryThis<typeof Date.prototype.toLocaleDateString>
|
||||
@ -247,8 +244,8 @@ declare namespace primordials {
|
||||
export const DatePrototypeSymbolToPrimitive: UncurryMethod<typeof Date.prototype, typeof Symbol.toPrimitive>;
|
||||
export import Error = globalThis.Error;
|
||||
export const ErrorPrototype: typeof Error.prototype
|
||||
// @ts-ignore
|
||||
export const ErrorCaptureStackTrace: typeof Error.captureStackTrace
|
||||
export const ErrorStackTraceLimit: typeof Error.stackTraceLimit
|
||||
export const ErrorPrototypeToString: UncurryThis<typeof Error.prototype.toString>
|
||||
export import EvalError = globalThis.EvalError;
|
||||
export const EvalErrorPrototype: typeof EvalError.prototype
|
||||
@ -332,11 +329,7 @@ declare namespace primordials {
|
||||
export const ObjectEntries: typeof Object.entries
|
||||
export const ObjectFromEntries: typeof Object.fromEntries
|
||||
export const ObjectValues: typeof Object.values
|
||||
export const ObjectPrototype__defineGetter__: UncurryThis<typeof Object.prototype.__defineGetter__>
|
||||
export const ObjectPrototype__defineSetter__: UncurryThis<typeof Object.prototype.__defineSetter__>
|
||||
export const ObjectPrototypeHasOwnProperty: UncurryThis<typeof Object.prototype.hasOwnProperty>
|
||||
export const ObjectPrototype__lookupGetter__: UncurryThis<typeof Object.prototype.__lookupGetter__>
|
||||
export const ObjectPrototype__lookupSetter__: UncurryThis<typeof Object.prototype.__lookupSetter__>
|
||||
export const ObjectPrototypeIsPrototypeOf: UncurryThis<typeof Object.prototype.isPrototypeOf>
|
||||
export const ObjectPrototypePropertyIsEnumerable: UncurryThis<typeof Object.prototype.propertyIsEnumerable>
|
||||
export const ObjectPrototypeToString: UncurryThis<typeof Object.prototype.toString>
|
||||
|
Loading…
Reference in New Issue
Block a user