typenative 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.github/workflows/ci.yml +2 -0
  2. package/CHANGELOG.md +201 -0
  3. package/CONTRIBUTION.md +1 -1
  4. package/bin/cli.js +1 -0
  5. package/bin/go/bridge.js +74 -14
  6. package/bin/go/convert.js +48 -0
  7. package/bin/go/metadata.js +13 -4
  8. package/bin/go/overrides.js +4 -6
  9. package/bin/go/stdlib.generated.js +2 -0
  10. package/bin/index.js +117 -0
  11. package/bin/main.js +1 -0
  12. package/bin/node/child_process.js +51 -3
  13. package/bin/node/cluster.js +41 -3
  14. package/bin/node/core.js +1 -1
  15. package/bin/node/crypto.js +205 -4
  16. package/bin/node/dgram.js +230 -6
  17. package/bin/node/dns.js +470 -7
  18. package/bin/node/errno_tables.js +445 -0
  19. package/bin/node/fs.js +21 -14
  20. package/bin/node/http.js +128 -30
  21. package/bin/node/http2.js +4 -1
  22. package/bin/node/module_v8.js +142 -0
  23. package/bin/node/net.js +9 -6
  24. package/bin/node/process.js +242 -0
  25. package/bin/node/readline.js +271 -0
  26. package/bin/node/registry.js +2 -1
  27. package/bin/node/sqlite.js +60 -12
  28. package/bin/node/stream.js +139 -7
  29. package/bin/node/test.js +311 -19
  30. package/bin/node/url.js +23 -5
  31. package/bin/node/util.js +18 -1
  32. package/bin/node/util_extra.js +6 -30
  33. package/bin/node/worker_threads.js +79 -19
  34. package/bin/transpiler.js +4019 -497
  35. package/bin/typecheck-node.js +1 -0
  36. package/bin/version.js +1 -1
  37. package/conformance.md +1025 -884
  38. package/examples/README.md +5 -5
  39. package/examples/json-server/README.md +31 -29
  40. package/examples/json-server/bench.mjs +130 -38
  41. package/package.json +1 -1
  42. package/types/typenative-go.d.ts +23 -0
  43. package/types/typenative-npm.d.ts +169 -5
  44. package/types/typenative.d.ts +185 -11
@@ -8,7 +8,7 @@ Node vs TypeNative on the same workload and a README documenting the results.
8
8
  |----------------------------------------------|--------------------------------------------------------------------------|--------------------------------------------------|
9
9
  | [hello-world](hello-world/) | `console.log`, `process.argv`, template literals | **7.0x faster startup** (14.7 ms vs 103.5 ms) |
10
10
  | [fibonacci](fibonacci/) | Recursion, `perf_hooks` timing, CPU-bound number crunching | **1.9x faster compute** (50.2 ms vs 94.8 ms) |
11
- | [json-server](json-server/) | `node:http` web server with GET + POST JSON routes, zero dependencies | Node **1.5x higher HTTP throughput** (honest!) |
11
+ | [json-server](json-server/) | `node:http` web server with GET + POST JSON routes, zero dependencies | **1.3x higher HTTP throughput** (17.8k vs 13.4k GET req/s) |
12
12
 
13
13
  \* Windows 11 Pro, AMD Ryzen 5 5500U, Node v24.19.0, Go 1.26.0, TypeNative
14
14
  0.4.0. See each example's README for full methodology and numbers.
@@ -48,7 +48,7 @@ cd examples/fibonacci && node bench.mjs 35 15
48
48
  cd examples/json-server && node bench.mjs
49
49
  ```
50
50
 
51
- The json-server harness also shows where Node is still ahead: its V8 +
52
- `node:http` stack out-serves the compiled binary ~1.5x on I/O-bound HTTP
53
- throughput, while TypeNative wins process startup (~7x) and CPU-bound
54
- compute (~2x). The READMEs report what was measured, not what flatters.
51
+ Across the three, TypeNative wins process startup (~7x), CPU-bound compute
52
+ (~2x) and HTTP throughput (~1.3x, with lower median latency). The READMEs
53
+ report what was measured, including run-to-run variation and how each load
54
+ was generated.
@@ -51,7 +51,9 @@ server.listen(3000, '127.0.0.1');
51
51
  | `/todos` | POST | Create a todo: `{ "title": "..." }` → 201 |
52
52
  | anything else | * | `404` with a JSON error |
53
53
 
54
- Invalid JSON or a missing `title` returns `400` with a JSON error.
54
+ A missing `title` returns `400` with a JSON error. (The example keeps
55
+ `JSON.parse` unguarded, so invalid JSON throws — under Node and the compiled
56
+ binary alike, an uncaught throw ends the process.)
55
57
 
56
58
  ## Run it
57
59
 
@@ -91,35 +93,35 @@ curl -s -w "%{http_code}" -X POST -d '{}' http://127.0.0.1:3000/todos # 400
91
93
  Reproduce with `node bench.mjs [gets=20000] [posts=10000]`. The script
92
94
  compiles `main.ts` with the TypeNative CLI, starts the server under each
93
95
  runtime, seeds 50 todos, and drives load over keep-alive connections at
94
- concurrency 16 with a Node.js `node:http` client (identical client for both).
95
- It measures requests/second plus p50/p99 latency per request for
96
- `GET /todos` (20,000 requests, ~50-item JSON response) and `POST /todos`
97
- (10,000 requests).
96
+ concurrency 16 (identical client for both). It measures requests/second plus
97
+ p50/p99 latency per request for `GET /todos` (20,000 requests, ~50-item JSON
98
+ response) and `POST /todos` (10,000 requests).
99
+
100
+ The load generator is built to stay out of the way, like `wrk` or
101
+ `autocannon`: 8 worker threads × 2 raw keep-alive sockets send prebuilt
102
+ request bytes and read each response just far enough to find its end. A
103
+ plain `node:http` client tops out around 8–11k req/s on this machine, so
104
+ with it both servers would simply tie at the client's limit.
98
105
 
99
106
  **Environment:** Windows 11 Pro, AMD Ryzen 5 5500U, Node v24.19.0, Go 1.26.0,
100
- TypeNative 0.4.0, default (non-`--release`) build. Re-run variation is about
101
- ±5%.
107
+ TypeNative 0.4.0, default (non-`--release`) build, client and server on the
108
+ same machine. Re-run variation is about ±10%; across runs TypeNative was
109
+ 1.2–1.3x Node on GET and 1.2–1.4x on POST.
102
110
 
103
- | Runtime | Endpoint | req/s | p50 (ms) | p99 (ms) |
111
+ | Runtime | Endpoint | req/s | p50 (ms) | p99 (ms) |
104
112
  |------------|-------------|-------:|---------:|---------:|
105
- | Node.js | GET /todos | 7709 | 1.87 | 6.05 |
106
- | TypeNative | GET /todos | 4834 | 3.08 | 6.60 |
107
- | Node.js | POST /todos | 9244 | 1.57 | 3.97 |
108
- | TypeNative | POST /todos | 6141 | 2.46 | 4.55 |
109
-
110
- **Node.js serves ~1.5x more requests per second** on this workload. That is
111
- the honest result, and it is worth understanding: V8 and Node's `node:http`
112
- have been tuned for exactly this I/O-bound pattern for over a decade, while
113
- TypeNative re-implements the request lifecycle (event emission, stream
114
- callbacks, per-request closures) on top of Go's `net/http`, and that
115
- translation still has overhead. Tail latency (p99) is comparable for both.
116
-
117
- Where the compiled binary wins is everything *around* the steady-state loop:
118
- it starts in ~15 ms instead of ~100 ms, it is a single 9.7 MB executable with
119
- zero dependencies — `scp` it to a server and run it, no Node install, no
120
- `node_modules` — and CPU-heavy work inside a handler runs ~2x faster (see the
121
- [fibonacci example](../fibonacci/README.md)).
122
-
123
- Takeaway: for I/O-bound HTTP services Node remains the throughput king today;
124
- choose TypeNative when startup time, deployment simplicity, or CPU-bound
125
- handler work dominates.
113
+ | Node.js | GET /todos | 13379 | 1.02 | 3.03 |
114
+ | TypeNative | GET /todos | 17794 | 0.66 | 1.87 |
115
+ | Node.js | POST /todos | 15405 | 0.94 | 2.17 |
116
+ | TypeNative | POST /todos | 19581 | 0.60 | 2.32 |
117
+
118
+ **TypeNative serves ~1.3x more requests per second**, with lower median
119
+ latency on both routes. JavaScript still runs one thing at a time, as in
120
+ Node, but the compiled server spreads everything around it — socket reads
121
+ and writes, HTTP parsing — across Go's `net/http` goroutines, and runs the
122
+ handler right on the request's goroutine whenever the event loop is free.
123
+
124
+ On top of that, the binary starts in ~15 ms instead of ~100 ms and is a
125
+ single 9.7 MB executable with zero dependencies — `scp` it to a server and
126
+ run it, no Node install, no `node_modules` — and CPU-heavy work inside a
127
+ handler runs ~2x faster (see the [fibonacci example](../fibonacci/README.md)).
@@ -11,20 +11,127 @@
11
11
  // - GET /todos 20,000 requests (a ~50-item JSON list per response)
12
12
  // - POST /todos 10,000 requests (create a todo)
13
13
  //
14
+ // The client is built to stay out of the way, like wrk or autocannon: worker
15
+ // threads (8 x 2 connections) send prebuilt request bytes over raw keep-alive
16
+ // sockets and read each response only far enough to find its end. A plain
17
+ // node:http client tops out at ~8-11k req/s on its own here, which would
18
+ // measure the client rather than the servers.
19
+ //
14
20
  // Usage: node bench.mjs [gets=20000] [posts=10000]
15
21
 
16
22
  import { spawn, spawnSync } from 'node:child_process';
17
- import http from 'node:http';
23
+ import net from 'node:net';
18
24
  import fs from 'node:fs';
19
25
  import path from 'node:path';
20
26
  import { fileURLToPath } from 'node:url';
27
+ import { Worker, isMainThread, parentPort, workerData } from 'node:worker_threads';
28
+
29
+ const WORKERS = 8;
30
+ const CONNECTIONS_PER_WORKER = 2;
31
+ const CONCURRENCY = WORKERS * CONNECTIONS_PER_WORKER;
32
+
33
+ // The complete response at the start of buf: { status, length } (null while
34
+ // more bytes are needed). Bodies end by Content-Length or chunked encoding.
35
+ function parseResponse(buf) {
36
+ const headEnd = buf.indexOf('\r\n\r\n');
37
+ if (headEnd < 0) return null;
38
+ const head = buf.toString('latin1', 0, headEnd);
39
+ const status = Number(head.slice(9, 12));
40
+ const bodyStart = headEnd + 4;
41
+ const contentLength = /\r\ncontent-length:\s*(\d+)/i.exec(head);
42
+ if (contentLength) {
43
+ const end = bodyStart + Number(contentLength[1]);
44
+ return buf.length >= end ? { status, length: end } : null;
45
+ }
46
+ if (/\r\ntransfer-encoding:\s*chunked/i.test(head)) {
47
+ for (let at = bodyStart; ; ) {
48
+ const lineEnd = buf.indexOf('\r\n', at);
49
+ if (lineEnd < 0) return null;
50
+ const size = parseInt(buf.toString('latin1', at, lineEnd), 16);
51
+ const next = lineEnd + 2 + size + 2;
52
+ if (buf.length < next) return null;
53
+ if (size === 0) return { status, length: next };
54
+ at = next;
55
+ }
56
+ }
57
+ return { status, length: bodyStart };
58
+ }
59
+
60
+ // A keep-alive connection with one request in flight at a time;
61
+ // send(bytes) resolves with the response status
62
+ function connect(host, port) {
63
+ return new Promise((resolve, reject) => {
64
+ let buffered = Buffer.alloc(0);
65
+ let pending = null;
66
+ const socket = net.connect(port, host, () => resolve(connection));
67
+ socket.setNoDelay(true);
68
+ const connection = {
69
+ send: (bytes) =>
70
+ new Promise((onStatus, onError) => {
71
+ pending = { onStatus, onError };
72
+ socket.write(bytes);
73
+ }),
74
+ close: () => socket.destroy(),
75
+ };
76
+ socket.on('data', (chunk) => {
77
+ buffered = buffered.length > 0 ? Buffer.concat([buffered, chunk]) : chunk;
78
+ const response = parseResponse(buffered);
79
+ if (response && pending) {
80
+ buffered = buffered.subarray(response.length);
81
+ const { onStatus } = pending;
82
+ pending = null;
83
+ onStatus(response.status);
84
+ }
85
+ });
86
+ socket.on('error', (err) => (pending ? pending.onError(err) : reject(err)));
87
+ });
88
+ }
89
+
90
+ // Worker thread: sends its share of one phase's requests over its own
91
+ // connections, then returns each request's latency
92
+ async function runWorker({ base, method, reqPath, body, total }) {
93
+ const target = new URL(base);
94
+ const request = Buffer.from(
95
+ `${method} ${reqPath} HTTP/1.1\r\nHost: ${target.host}\r\n` +
96
+ (body ? `Content-Type: application/json\r\nContent-Length: ${Buffer.byteLength(body)}\r\n` : '') +
97
+ `\r\n${body ?? ''}`
98
+ );
99
+ const latencies = new Float64Array(total);
100
+ let dispatched = 0;
101
+ const connections = await Promise.all(
102
+ Array.from({ length: CONNECTIONS_PER_WORKER }, () => connect(target.hostname, Number(target.port)))
103
+ );
104
+
105
+ // Wait for the go signal so every worker starts at once
106
+ await new Promise((resolve) => parentPort.once('message', resolve));
107
+ await Promise.all(
108
+ connections.map(async (connection) => {
109
+ for (;;) {
110
+ const index = dispatched;
111
+ dispatched += 1;
112
+ if (index >= total) return;
113
+ const start = performance.now();
114
+ const status = await connection.send(request);
115
+ latencies[index] = performance.now() - start;
116
+ if (status !== 200 && status !== 201) throw new Error(`${method} ${reqPath} -> ${status}`);
117
+ }
118
+ })
119
+ );
120
+ for (const connection of connections) connection.close();
121
+ parentPort.postMessage(latencies, [latencies.buffer]);
122
+ }
123
+
124
+ if (!isMainThread) {
125
+ parentPort.postMessage('ready');
126
+ await runWorker(workerData);
127
+ process.exit(0);
128
+ }
21
129
 
22
130
  const here = path.dirname(fileURLToPath(import.meta.url));
23
131
  const repoRoot = path.resolve(here, '..', '..');
24
132
  const cli = path.join(repoRoot, 'bin', 'cli.js');
25
133
  const GET_REQUESTS = Number(process.argv[2] ?? '20000') || 20000;
26
134
  const POST_REQUESTS = Number(process.argv[3] ?? '10000') || 10000;
27
- const CONCURRENCY = 16;
28
135
  const SEEDED = 50;
29
136
  const exeName = process.platform === 'win32' ? 'server.exe' : 'server';
30
137
  const exePath = path.join(here, 'dist', exeName);
@@ -74,48 +181,33 @@ async function seed(base) {
74
181
  }
75
182
  }
76
183
 
77
- // One load phase over keep-alive connections; returns req/s and latencies.
184
+ // One load phase spread over the worker threads; returns req/s and latencies.
78
185
  async function benchPhase(base, { method, reqPath, body, total }) {
79
- const agent = new http.Agent({ keepAlive: true, maxSockets: CONCURRENCY });
80
- const latencies = new Float64Array(total);
81
- let dispatched = 0;
82
- const target = new URL(base);
83
- const headers = body
84
- ? { 'content-type': 'application/json', 'content-length': Buffer.byteLength(body) }
85
- : {};
86
-
87
- const request = () =>
88
- new Promise((resolve, reject) => {
89
- const req = http.request(
90
- { host: target.hostname, port: target.port, method, path: reqPath, agent, headers },
91
- (res) => {
92
- res.resume();
93
- res.on('end', () => {
94
- if (res.statusCode === 200 || res.statusCode === 201) resolve();
95
- else reject(new Error(`${method} ${reqPath} -> ${res.statusCode}`));
96
- });
97
- }
98
- );
99
- req.on('error', reject);
100
- req.end(body);
186
+ const workers = Array.from({ length: WORKERS }, (_, i) => {
187
+ const share = Math.floor(total / WORKERS) + (i < total % WORKERS ? 1 : 0);
188
+ return new Worker(fileURLToPath(import.meta.url), {
189
+ workerData: { base, method, reqPath, body, total: share },
101
190
  });
191
+ });
192
+ const finished = workers.map(
193
+ (worker) =>
194
+ new Promise((resolve, reject) => {
195
+ worker.on('message', (message) => {
196
+ if (message !== 'ready') resolve(message);
197
+ });
198
+ worker.on('error', reject);
199
+ })
200
+ );
201
+ await Promise.all(
202
+ workers.map((worker) => new Promise((resolve) => worker.once('message', resolve)))
203
+ );
102
204
 
103
205
  const t0 = performance.now();
104
- const workers = Array.from({ length: CONCURRENCY }, async () => {
105
- for (;;) {
106
- const index = dispatched;
107
- dispatched += 1;
108
- if (index >= total) return;
109
- const start = performance.now();
110
- await request();
111
- latencies[index] = performance.now() - start;
112
- }
113
- });
114
- await Promise.all(workers);
206
+ for (const worker of workers) worker.postMessage('go');
207
+ const results = await Promise.all(finished);
115
208
  const elapsedSec = (performance.now() - t0) / 1000;
116
- agent.destroy();
117
209
 
118
- const sorted = Array.from(latencies).sort((a, b) => a - b);
210
+ const sorted = results.flatMap((latencies) => Array.from(latencies)).sort((a, b) => a - b);
119
211
  return {
120
212
  rps: total / elapsedSec,
121
213
  p50: sorted[Math.floor(total * 0.5)],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typenative",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Build native applications using Typescript.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5753,6 +5753,21 @@ declare module 'go:debug/plan9obj' {
5753
5753
  export const ErrNoSymbols: import('go:builtin').GoError;
5754
5754
  }
5755
5755
 
5756
+ declare module 'go:embed' {
5757
+ export class FS {
5758
+ constructor(init?: Partial<FS>);
5759
+ Open(name: string): import('go:io/fs').File;
5760
+ ReadDir(name: string): import('go:io/fs').DirEntry[];
5761
+ ReadFile(name: string): Uint8Array;
5762
+ }
5763
+ // Compile-time embedding (//go:embed): only as a top-level const initializer.
5764
+ // Paths are relative to this file and must stay inside the entry file's directory.
5765
+ export function string(path: string): string;
5766
+ export function bytes(path: string): Uint8Array;
5767
+ // Go embed patterns: files, directories, globs, an 'all:' prefix for dotfiles
5768
+ export function files(...patterns: string[]): FS;
5769
+ }
5770
+
5756
5771
  declare module 'go:encoding' {
5757
5772
  export interface BinaryAppender {
5758
5773
  AppendBinary(b: Uint8Array | number[] | null): Uint8Array;
@@ -12526,6 +12541,14 @@ declare module 'go:runtime' {
12526
12541
  export const MemProfileRate: number;
12527
12542
  }
12528
12543
 
12544
+ declare module 'go:runtime/coverage' {
12545
+ export function ClearCounters(): import('go:builtin').GoError;
12546
+ export function WriteCounters(w: import('go:io').Writer | null): import('go:builtin').GoError;
12547
+ export function WriteCountersDir(dir: string): import('go:builtin').GoError;
12548
+ export function WriteMeta(w: import('go:io').Writer | null): import('go:builtin').GoError;
12549
+ export function WriteMetaDir(dir: string): import('go:builtin').GoError;
12550
+ }
12551
+
12529
12552
  declare module 'go:runtime/debug' {
12530
12553
  export class BuildInfo {
12531
12554
  constructor(init?: Partial<BuildInfo>);
@@ -609,16 +609,18 @@ declare module 'node:assert/strict' {
609
609
  }
610
610
 
611
611
  declare module 'node:crypto' {
612
+ import { Transform } from 'node:stream';
612
613
  namespace crypto {
613
614
  type BinaryLike = string | Uint8Array;
614
615
  type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex' | 'binary';
615
- interface Hash {
616
+ /** Hash / Hmac are also Transform streams: write, then read or pipe the digest */
617
+ interface Hash extends Transform {
616
618
  update(data: BinaryLike, inputEncoding?: BufferEncoding): Hash;
617
619
  digest(): Buffer;
618
620
  digest(encoding: BinaryToTextEncoding | BufferEncoding): string;
619
621
  copy(): Hash;
620
622
  }
621
- interface Hmac {
623
+ interface Hmac extends Transform {
622
624
  update(data: BinaryLike, inputEncoding?: BufferEncoding): Hmac;
623
625
  digest(): Buffer;
624
626
  digest(encoding: BinaryToTextEncoding | BufferEncoding): string;
@@ -1564,6 +1566,8 @@ declare module 'node:child_process' {
1564
1566
  shell?: boolean | string;
1565
1567
  stdio?: StdioOption | StdioOption[];
1566
1568
  input?: string | Uint8Array;
1569
+ /** spawn: run the child in its own session / process group, so it can outlive the parent (with unref()) */
1570
+ detached?: boolean;
1567
1571
  }
1568
1572
  interface ExecException extends Error {
1569
1573
  code?: number;
@@ -1594,6 +1598,9 @@ declare module 'node:child_process' {
1594
1598
  readonly spawnfile: string;
1595
1599
  readonly connected: boolean;
1596
1600
  kill(signal?: string | number): boolean;
1601
+ /** The parent no longer waits for the child */
1602
+ unref(): void;
1603
+ ref(): void;
1597
1604
  send(message: any, callback?: (error: Error | null) => void): boolean;
1598
1605
  disconnect(): void;
1599
1606
  }
@@ -1656,6 +1663,17 @@ declare module 'node:readline' {
1656
1663
  function moveCursor(stream: Writable, dx: number, dy: number, callback?: () => void): boolean;
1657
1664
  function clearLine(stream: Writable, dir: Direction, callback?: () => void): boolean;
1658
1665
  function clearScreenDown(stream: Writable, callback?: () => void): boolean;
1666
+ /** A decoded key ('keypress' events); missing fields are "" */
1667
+ interface Key {
1668
+ sequence?: string;
1669
+ name?: string;
1670
+ ctrl?: boolean;
1671
+ meta?: boolean;
1672
+ shift?: boolean;
1673
+ code?: string;
1674
+ }
1675
+ /** Makes the stream emit 'keypress' (str, key) events (str is "" for escape sequences) */
1676
+ function emitKeypressEvents(stream: Readable, readlineInterface?: Interface): void;
1659
1677
  const promises: typeof import('node:readline/promises');
1660
1678
  }
1661
1679
  export = readline;
@@ -1682,6 +1700,58 @@ declare module 'node:readline/promises' {
1682
1700
  export = promises;
1683
1701
  }
1684
1702
 
1703
+ declare module 'node:module' {
1704
+ namespace Module {
1705
+ /** Node's built-in module names (without the node:-only ones such as node:test) */
1706
+ const builtinModules: string[];
1707
+ /** Whether the specifier names a built-in module ('fs', 'node:fs', 'node:test') */
1708
+ function isBuiltin(moduleName: string): boolean;
1709
+ interface Require {
1710
+ /** require('./data.json'): JSON files only, read at compile time */
1711
+ (id: string): any;
1712
+ }
1713
+ /** const require = createRequire(import.meta.url): its require() loads JSON files */
1714
+ function createRequire(path: string | URL): Require;
1715
+ }
1716
+ export = Module;
1717
+ }
1718
+
1719
+ declare module 'node:v8' {
1720
+ namespace v8 {
1721
+ interface HeapInfo {
1722
+ total_heap_size: number;
1723
+ total_heap_size_executable: number;
1724
+ total_physical_size: number;
1725
+ total_available_size: number;
1726
+ used_heap_size: number;
1727
+ heap_size_limit: number;
1728
+ malloced_memory: number;
1729
+ peak_malloced_memory: number;
1730
+ does_zap_garbage: number;
1731
+ number_of_native_contexts: number;
1732
+ number_of_detached_contexts: number;
1733
+ total_global_handles_size: number;
1734
+ used_global_handles_size: number;
1735
+ external_memory: number;
1736
+ }
1737
+ /** From Go's runtime.MemStats; the limit is GOMEMLIMIT, else 4 GiB */
1738
+ function getHeapStatistics(): HeapInfo;
1739
+ /** The structured-clone codec workers use (not V8's wire format) */
1740
+ function serialize(value: any): Buffer;
1741
+ function deserialize(buffer: Uint8Array): any;
1742
+ }
1743
+ export = v8;
1744
+ }
1745
+
1746
+ declare module 'node:sea' {
1747
+ /** Always true: a TypeNative program is a single executable */
1748
+ export function isSea(): boolean;
1749
+ /** TypeNative binaries carry no assets yet: throws ERR_SINGLE_EXECUTABLE_APPLICATION_ASSET_NOT_FOUND */
1750
+ export function getAsset(key: string): ArrayBuffer;
1751
+ export function getAsset(key: string, encoding: string): string;
1752
+ export function getRawAsset(key: string): ArrayBuffer;
1753
+ }
1754
+
1685
1755
  declare module 'node:diagnostics_channel' {
1686
1756
  namespace diagnostics_channel {
1687
1757
  type ChannelListener = (message: unknown, name: string | symbol) => void;
@@ -1883,6 +1953,47 @@ declare module 'node:dns' {
1883
1953
  priority: number;
1884
1954
  weight: number;
1885
1955
  }
1956
+ interface RecordWithTtl {
1957
+ address: string;
1958
+ ttl: number;
1959
+ }
1960
+ interface ResolveWithTtlOptions {
1961
+ ttl: true;
1962
+ }
1963
+ interface SoaRecord {
1964
+ nsname: string;
1965
+ hostmaster: string;
1966
+ serial: number;
1967
+ refresh: number;
1968
+ retry: number;
1969
+ expire: number;
1970
+ minttl: number;
1971
+ }
1972
+ interface NaptrRecord {
1973
+ flags: string;
1974
+ service: string;
1975
+ regexp: string;
1976
+ replacement: string;
1977
+ order: number;
1978
+ preference: number;
1979
+ }
1980
+ interface CaaRecord {
1981
+ critical: number;
1982
+ issue?: string;
1983
+ issuewild?: string;
1984
+ iodef?: string;
1985
+ contactemail?: string;
1986
+ contactphone?: string;
1987
+ }
1988
+ type AnyRecord =
1989
+ | (RecordWithTtl & { type: 'A' | 'AAAA' })
1990
+ | { type: 'CNAME' | 'NS' | 'PTR'; value: string }
1991
+ | (MxRecord & { type: 'MX' })
1992
+ | (SoaRecord & { type: 'SOA' })
1993
+ | { type: 'TXT'; entries: string[] }
1994
+ | (SrvRecord & { type: 'SRV' })
1995
+ | (NaptrRecord & { type: 'NAPTR' })
1996
+ | (CaaRecord & { type: 'CAA' });
1886
1997
  function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
1887
1998
  function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
1888
1999
  function lookup(hostname: string, options: LookupOptions & { all: true }, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
@@ -1892,6 +2003,17 @@ declare module 'node:dns' {
1892
2003
  function resolve(hostname: string, rrtype: 'MX', callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
1893
2004
  function resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
1894
2005
  function resolve(hostname: string, rrtype: 'SRV', callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
2006
+ function resolve(hostname: string, rrtype: 'ANY', callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
2007
+ function resolve(hostname: string, rrtype: 'CAA', callback: (err: NodeJS.ErrnoException | null, addresses: CaaRecord[]) => void): void;
2008
+ function resolve(hostname: string, rrtype: 'NAPTR', callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
2009
+ function resolve(hostname: string, rrtype: 'SOA', callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
2010
+ function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
2011
+ function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
2012
+ function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
2013
+ function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
2014
+ function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
2015
+ function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
2016
+ function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
1895
2017
  function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
1896
2018
  function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
1897
2019
  function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
@@ -1905,6 +2027,7 @@ declare module 'node:dns' {
1905
2027
  function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
1906
2028
  interface ResolverOptions {
1907
2029
  timeout?: number;
2030
+ /** Rounds over the servers for record queries (default 4) */
1908
2031
  tries?: number;
1909
2032
  }
1910
2033
  class Resolver {
@@ -1918,6 +2041,17 @@ declare module 'node:dns' {
1918
2041
  resolve(hostname: string, rrtype: 'MX', callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
1919
2042
  resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
1920
2043
  resolve(hostname: string, rrtype: 'SRV', callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
2044
+ resolve(hostname: string, rrtype: 'ANY', callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
2045
+ resolve(hostname: string, rrtype: 'CAA', callback: (err: NodeJS.ErrnoException | null, addresses: CaaRecord[]) => void): void;
2046
+ resolve(hostname: string, rrtype: 'NAPTR', callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
2047
+ resolve(hostname: string, rrtype: 'SOA', callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
2048
+ resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
2049
+ resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
2050
+ resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
2051
+ resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
2052
+ resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
2053
+ resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
2054
+ resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
1921
2055
  resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
1922
2056
  resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
1923
2057
  resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
@@ -1935,7 +2069,7 @@ declare module 'node:dns' {
1935
2069
  }
1936
2070
 
1937
2071
  declare module 'node:dns/promises' {
1938
- import { LookupOptions, LookupAddress, MxRecord, SrvRecord, ResolverOptions } from 'node:dns';
2072
+ import { LookupOptions, LookupAddress, MxRecord, SrvRecord, ResolverOptions, RecordWithTtl, ResolveWithTtlOptions, SoaRecord, NaptrRecord, CaaRecord, AnyRecord } from 'node:dns';
1939
2073
  namespace dnsPromises {
1940
2074
  function lookup(hostname: string, options: LookupOptions & { all: true }): Promise<LookupAddress[]>;
1941
2075
  function lookup(hostname: string, options?: number | LookupOptions): Promise<LookupAddress>;
@@ -1943,6 +2077,17 @@ declare module 'node:dns/promises' {
1943
2077
  function resolve(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
1944
2078
  function resolve(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
1945
2079
  function resolve(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
2080
+ function resolve(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
2081
+ function resolve(hostname: string, rrtype: 'CAA'): Promise<CaaRecord[]>;
2082
+ function resolve(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
2083
+ function resolve(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
2084
+ function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
2085
+ function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
2086
+ function resolveAny(hostname: string): Promise<AnyRecord[]>;
2087
+ function resolveCaa(hostname: string): Promise<CaaRecord[]>;
2088
+ function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
2089
+ function resolvePtr(hostname: string): Promise<string[]>;
2090
+ function resolveSoa(hostname: string): Promise<SoaRecord>;
1946
2091
  function resolve4(hostname: string): Promise<string[]>;
1947
2092
  function resolve6(hostname: string): Promise<string[]>;
1948
2093
  function resolveCname(hostname: string): Promise<string[]>;
@@ -1964,6 +2109,17 @@ declare module 'node:dns/promises' {
1964
2109
  resolve(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
1965
2110
  resolve(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
1966
2111
  resolve(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
2112
+ resolve(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
2113
+ resolve(hostname: string, rrtype: 'CAA'): Promise<CaaRecord[]>;
2114
+ resolve(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
2115
+ resolve(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
2116
+ resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
2117
+ resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
2118
+ resolveAny(hostname: string): Promise<AnyRecord[]>;
2119
+ resolveCaa(hostname: string): Promise<CaaRecord[]>;
2120
+ resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
2121
+ resolvePtr(hostname: string): Promise<string[]>;
2122
+ resolveSoa(hostname: string): Promise<SoaRecord>;
1967
2123
  resolve4(hostname: string): Promise<string[]>;
1968
2124
  resolve6(hostname: string): Promise<string[]>;
1969
2125
  resolveCname(hostname: string): Promise<string[]>;
@@ -2028,6 +2184,8 @@ declare module 'node:http' {
2028
2184
  writeHead(statusCode: number, headers?: OutgoingHttpHeaders | string[]): this;
2029
2185
  writeContinue(): void;
2030
2186
  setTimeout(msecs: number, callback?: () => void): this;
2187
+ /** Trailing headers, sent after a chunked body (not with a Content-Length) */
2188
+ addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
2031
2189
  }
2032
2190
  class ClientRequest extends OutgoingMessage {
2033
2191
  readonly method: string;
@@ -2246,6 +2404,10 @@ declare module 'node:dgram' {
2246
2404
  setTTL(ttl: number): number;
2247
2405
  setMulticastTTL(ttl: number): number;
2248
2406
  setMulticastLoopback(flag: boolean): boolean;
2407
+ setMulticastInterface(multicastInterface: string): void;
2408
+ /** Joins a multicast group (an unbound socket binds first) */
2409
+ addMembership(multicastAddress: string, multicastInterface?: string): void;
2410
+ dropMembership(multicastAddress: string, multicastInterface?: string): void;
2249
2411
  setRecvBufferSize(size: number): void;
2250
2412
  setSendBufferSize(size: number): void;
2251
2413
  }
@@ -2551,8 +2713,8 @@ declare module 'node:sqlite' {
2551
2713
  allowUnknownNamedParameters?: boolean;
2552
2714
  }
2553
2715
  // SQLite runs as Wasm inside the program (github.com/ncruces/go-sqlite3):
2554
- // loadExtension, createSession / applyChangeset and serialize / deserialize
2555
- // throw
2716
+ // loadExtension and createSession / applyChangeset throw; serialize /
2717
+ // deserialize go through a temporary file
2556
2718
  class DatabaseSync {
2557
2719
  constructor(path: string | Uint8Array | URL, options?: DatabaseSyncOptions);
2558
2720
  readonly isOpen: boolean;
@@ -2692,6 +2854,8 @@ declare module 'fs/promises' { import m = require('node:fs/promises'); export =
2692
2854
  declare module 'url' { import m = require('node:url'); export = m; }
2693
2855
  declare module 'querystring' { import m = require('node:querystring'); export = m; }
2694
2856
  declare module 'punycode' { import m = require('node:punycode'); export = m; }
2857
+ declare module 'module' { import m = require('node:module'); export = m; }
2858
+ declare module 'v8' { import m = require('node:v8'); export = m; }
2695
2859
  declare module 'string_decoder' { import m = require('node:string_decoder'); export = m; }
2696
2860
  declare module 'os' { import m = require('node:os'); export = m; }
2697
2861
  declare module 'process' { import m = require('node:process'); export = m; }