mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-30 07:14:39 +08:00
Without @types/node, every program loaded scriptc-node-fallback.d.ts whole: the console and process globals and 47 Node modules, about 8,100 lines, parsed, bound and checked in every cold build whether or not the program imported them. - The fallback file keeps the globals and the modules they name (console, readline, readline/promises, perf_hooks, tty). Every other module, under both spellings, has its own file in ambient/node-fallback/, which references the files of the modules its declarations name. - A module's file joins the program when one of the program's files names the module in a string literal: imports, requires, import types and JSDoc types all name modules that way. The entry is read before the first program; the program-root discovery passes add modules that other files name. Files are read as tsgo reads them, and the TypeScript libraries and scriptc's own declarations are skipped. - The checks that recognized the fallback file by its path recognize every fallback file.
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
/// <reference path="./http.d.ts" />
|
|
|
|
/* node:https — http over the TLS transport (scr_tls.c).
|
|
* createServer({ cert, key }, handler) is the http server behind a
|
|
* handshake; request/get are the http client with port 443 default and
|
|
* the local-CA knobs: `ca` (PEM string/Buffer) replaces the trust
|
|
* anchors, rejectUnauthorized: false disables verification (the
|
|
* self-signed probe shape). With neither, /etc/ssl/cert.pem stands in
|
|
* for Node's bundled roots. */
|
|
declare module "https" {
|
|
import { Server } from "http";
|
|
import { Agent, ClientRequest, IncomingMessage, ServerResponse } from "http";
|
|
export { Agent, Server };
|
|
/* Node's keepAlive global agent for requests without an agent option. */
|
|
export const globalAgent: Agent;
|
|
export interface ServerOptions {
|
|
cert: string | Uint8Array;
|
|
key: string | Uint8Array;
|
|
/* The options-record stance (see http.RequestOptions). */
|
|
[option: string]: unknown;
|
|
}
|
|
export interface RequestOptions {
|
|
hostname?: string;
|
|
host?: string;
|
|
port?: number;
|
|
path?: string;
|
|
method?: string;
|
|
timeout?: number;
|
|
headers?: { [name: string]: string };
|
|
rejectUnauthorized?: boolean;
|
|
ca?: string | Uint8Array;
|
|
agent?: Agent | boolean | null;
|
|
/* Aborting destroys the request with an AbortError. */
|
|
signal?: AbortSignal;
|
|
socketPath?: string;
|
|
/* The options-record stance (see http.RequestOptions). */
|
|
[option: string]: unknown;
|
|
}
|
|
export function createServer(
|
|
options: ServerOptions,
|
|
requestListener: (req: IncomingMessage, res: ServerResponse) => void,
|
|
): Server;
|
|
/* One signature with a union first parameter, for the request-fn
|
|
* ternary's sake (see the http block). A URL target takes no options,
|
|
* which means Node's defaults — the certificate is verified against
|
|
* the default trust anchors. */
|
|
export function request(
|
|
target: RequestOptions | string | URL,
|
|
callback?: (res: IncomingMessage) => void,
|
|
): ClientRequest;
|
|
export function get(
|
|
target: RequestOptions | string | URL,
|
|
callback?: (res: IncomingMessage) => void,
|
|
): ClientRequest;
|
|
}
|
|
|
|
declare module "node:https" {
|
|
export * from "https";
|
|
}
|