@scriptc/compiler 0.3.5 → 0.3.6

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 (181) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +278 -32
  2. package/dist/backend/llvm/dyn.js +31 -1
  3. package/dist/backend/llvm/dyn.js.map +1 -1
  4. package/dist/backend/llvm/emitter.d.ts +45 -1
  5. package/dist/backend/llvm/emitter.js +412 -104
  6. package/dist/backend/llvm/emitter.js.map +1 -1
  7. package/dist/backend/llvm/expr-dispatch.js +1 -0
  8. package/dist/backend/llvm/expr-dispatch.js.map +1 -1
  9. package/dist/backend/llvm/expr-dynamic.js +25 -1
  10. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  11. package/dist/backend/llvm/expr-primitives.d.ts +1 -1
  12. package/dist/backend/llvm/expr-primitives.js +11 -0
  13. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  14. package/dist/backend/llvm/lib-dispatch.js +28 -1
  15. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  16. package/dist/backend/llvm/lib-filesystem.js +61 -1
  17. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  18. package/dist/backend/llvm/lib-network.js +21 -3
  19. package/dist/backend/llvm/lib-network.js.map +1 -1
  20. package/dist/backend/llvm/lib-process.js +10 -0
  21. package/dist/backend/llvm/lib-process.js.map +1 -1
  22. package/dist/backend/llvm/lib-shared.js +43 -0
  23. package/dist/backend/llvm/lib-shared.js.map +1 -1
  24. package/dist/backend/llvm/lib-test.js +16 -3
  25. package/dist/backend/llvm/lib-test.js.map +1 -1
  26. package/dist/backend/llvm/nullable-unions.d.ts +6 -3
  27. package/dist/backend/llvm/nullable-unions.js +2 -0
  28. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  29. package/dist/backend/llvm/record-results.d.ts +1 -1
  30. package/dist/backend/llvm/record-results.js +2 -2
  31. package/dist/backend/llvm/record-results.js.map +1 -1
  32. package/dist/backend/llvm/reference-writes.js +1 -0
  33. package/dist/backend/llvm/reference-writes.js.map +1 -1
  34. package/dist/backend/llvm/shapes.d.ts +3 -0
  35. package/dist/backend/llvm/shapes.js +5 -0
  36. package/dist/backend/llvm/shapes.js.map +1 -1
  37. package/dist/backend/llvm/speculative-integers.d.ts +74 -0
  38. package/dist/backend/llvm/speculative-integers.js +571 -0
  39. package/dist/backend/llvm/speculative-integers.js.map +1 -0
  40. package/dist/backend/llvm/speculative-integers.test.d.ts +1 -0
  41. package/dist/backend/llvm/speculative-integers.test.js +148 -0
  42. package/dist/backend/llvm/speculative-integers.test.js.map +1 -0
  43. package/dist/backend/may-throw.js +2 -0
  44. package/dist/backend/may-throw.js.map +1 -1
  45. package/dist/backend/native/executable.js +3 -0
  46. package/dist/backend/native/executable.js.map +1 -1
  47. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  48. package/dist/backend/native/runtime-inputs.js +1 -0
  49. package/dist/backend/native/runtime-inputs.js.map +1 -1
  50. package/dist/backend/runtime-pack.d.ts +7 -3
  51. package/dist/backend/runtime-pack.js +12 -6
  52. package/dist/backend/runtime-pack.js.map +1 -1
  53. package/dist/backend/runtime-pack.test.js +15 -6
  54. package/dist/backend/runtime-pack.test.js.map +1 -1
  55. package/dist/contracts/check.js +1 -0
  56. package/dist/contracts/check.js.map +1 -1
  57. package/dist/coverage/surface-manifest.js +3 -3
  58. package/dist/coverage/surface-manifest.js.map +1 -1
  59. package/dist/diagnostics/diagnostic.d.ts +1 -1
  60. package/dist/diagnostics/diagnostic.js +6 -2
  61. package/dist/diagnostics/diagnostic.js.map +1 -1
  62. package/dist/frontend/lowering/builtin-calls.js +10 -0
  63. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  64. package/dist/frontend/lowering/builtins/callable-aliases.js +31 -3
  65. package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
  66. package/dist/frontend/lowering/builtins/compression.d.ts +9 -0
  67. package/dist/frontend/lowering/builtins/compression.js +145 -30
  68. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  69. package/dist/frontend/lowering/builtins/crypto.js +12 -1
  70. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  71. package/dist/frontend/lowering/builtins/errors.js +5 -3
  72. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  73. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +4 -0
  74. package/dist/frontend/lowering/builtins/filesystem-calls.js +11 -0
  75. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  76. package/dist/frontend/lowering/builtins/filesystem.d.ts +8 -0
  77. package/dist/frontend/lowering/builtins/filesystem.js +139 -2
  78. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  79. package/dist/frontend/lowering/builtins/hash-stream.d.ts +12 -0
  80. package/dist/frontend/lowering/builtins/hash-stream.js +80 -0
  81. package/dist/frontend/lowering/builtins/hash-stream.js.map +1 -0
  82. package/dist/frontend/lowering/builtins/module-calls.js +13 -3
  83. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  84. package/dist/frontend/lowering/builtins/process.js +9 -2
  85. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  86. package/dist/frontend/lowering/builtins/readline.d.ts +45 -13
  87. package/dist/frontend/lowering/builtins/readline.js +812 -47
  88. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  89. package/dist/frontend/lowering/builtins/workers.d.ts +4 -0
  90. package/dist/frontend/lowering/builtins/workers.js +58 -0
  91. package/dist/frontend/lowering/builtins/workers.js.map +1 -1
  92. package/dist/frontend/lowering/class-protocols.d.ts +55 -0
  93. package/dist/frontend/lowering/class-protocols.js +735 -0
  94. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  95. package/dist/frontend/lowering/containers/array-from-async.d.ts +18 -0
  96. package/dist/frontend/lowering/containers/array-from-async.js +282 -0
  97. package/dist/frontend/lowering/containers/array-from-async.js.map +1 -0
  98. package/dist/frontend/lowering/containers/collection-grouping.js +2 -1
  99. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  100. package/dist/frontend/lowering/containers/collection-methods.js +27 -23
  101. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  102. package/dist/frontend/lowering/divergences.js +188 -15
  103. package/dist/frontend/lowering/divergences.js.map +1 -1
  104. package/dist/frontend/lowering/lower-calls.js +71 -22
  105. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  106. package/dist/frontend/lowering/lower-classes.js +39 -1
  107. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  108. package/dist/frontend/lowering/lower-event-emitter.js +10 -1
  109. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  110. package/dist/frontend/lowering/lower-exprs.js +107 -13
  111. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  112. package/dist/frontend/lowering/lower-inspect.js +23 -3
  113. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  114. package/dist/frontend/lowering/lower-mock.d.ts +11 -1
  115. package/dist/frontend/lowering/lower-mock.js +377 -61
  116. package/dist/frontend/lowering/lower-mock.js.map +1 -1
  117. package/dist/frontend/lowering/lower-modules.js +1 -0
  118. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  119. package/dist/frontend/lowering/lower-server.js +161 -16
  120. package/dist/frontend/lowering/lower-server.js.map +1 -1
  121. package/dist/frontend/lowering/lower-stmts.js +48 -7
  122. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  123. package/dist/frontend/lowering/lower-stream.d.ts +1 -3
  124. package/dist/frontend/lowering/lower-stream.js +317 -20
  125. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  126. package/dist/frontend/lowering/lower-test.js +147 -48
  127. package/dist/frontend/lowering/lower-test.js.map +1 -1
  128. package/dist/frontend/lowering/lowerer.d.ts +10 -0
  129. package/dist/frontend/lowering/lowerer.js +8 -0
  130. package/dist/frontend/lowering/lowerer.js.map +1 -1
  131. package/dist/frontend/lowering/null-prototype.d.ts +13 -0
  132. package/dist/frontend/lowering/null-prototype.js +33 -0
  133. package/dist/frontend/lowering/null-prototype.js.map +1 -0
  134. package/dist/frontend/lowering/surfaces.d.ts +3 -3
  135. package/dist/frontend/lowering/surfaces.js +27 -5
  136. package/dist/frontend/lowering/surfaces.js.map +1 -1
  137. package/dist/frontend/mock-shapes.d.ts +5 -0
  138. package/dist/frontend/mock-shapes.js +27 -2
  139. package/dist/frontend/mock-shapes.js.map +1 -1
  140. package/dist/frontend/program.js +5 -4
  141. package/dist/frontend/program.js.map +1 -1
  142. package/dist/frontend/type-mapper.js +95 -4
  143. package/dist/frontend/type-mapper.js.map +1 -1
  144. package/dist/index.js +18 -8
  145. package/dist/index.js.map +1 -1
  146. package/dist/ir/builtin-effects.js +36 -0
  147. package/dist/ir/builtin-effects.js.map +1 -1
  148. package/dist/ir/builtin-signatures.d.ts +1 -1
  149. package/dist/ir/builtin-signatures.js +167 -6
  150. package/dist/ir/builtin-signatures.js.map +1 -1
  151. package/dist/ir/function-references.test.js +1 -0
  152. package/dist/ir/function-references.test.js.map +1 -1
  153. package/dist/ir/int32-slots.js +22 -0
  154. package/dist/ir/int32-slots.js.map +1 -1
  155. package/dist/ir/int32-slots.test.js +28 -0
  156. package/dist/ir/int32-slots.test.js.map +1 -1
  157. package/dist/ir/integer-loop-facts.d.ts +14 -6
  158. package/dist/ir/integer-loop-facts.js +119 -35
  159. package/dist/ir/integer-loop-facts.js.map +1 -1
  160. package/dist/ir/integer-ranges.js +1 -5
  161. package/dist/ir/integer-ranges.js.map +1 -1
  162. package/dist/ir/integer-ranges.test.js +60 -0
  163. package/dist/ir/integer-ranges.test.js.map +1 -1
  164. package/dist/ir/ir.d.ts +13 -0
  165. package/dist/ir/ir.js +4 -0
  166. package/dist/ir/ir.js.map +1 -1
  167. package/dist/ir/runtime-features.d.ts +3 -1
  168. package/dist/ir/runtime-features.js +96 -6
  169. package/dist/ir/runtime-features.js.map +1 -1
  170. package/dist/ir/runtime-features.test.js +62 -0
  171. package/dist/ir/runtime-features.test.js.map +1 -1
  172. package/dist/ir/traverse.js +4 -0
  173. package/dist/ir/traverse.js.map +1 -1
  174. package/dist/ir/validate.js +45 -3
  175. package/dist/ir/validate.js.map +1 -1
  176. package/dist/ir/validate.test.js +38 -0
  177. package/dist/ir/validate.test.js.map +1 -1
  178. package/dist/library/ir-policy.js +5 -0
  179. package/dist/library/ir-policy.js.map +1 -1
  180. package/package.json +20 -20
  181. package/surface-manifest.json +31 -19
@@ -299,7 +299,7 @@ declare var process: {
299
299
  stdout: import("tty").WriteStream;
300
300
  stderr: import("tty").WriteStream;
301
301
  /* The stdin stream, the piped-input slice: the TTY probe, the
302
- * data/end/error events (on and once — a 'data' listener keeps the
302
+ * data/end/error events and readline's 'keypress' (on and once — a 'data' listener keeps the
303
303
  * event loop alive until EOF, like Node's flowing stdin), destroy()
304
304
  * (full teardown: nothing fires after, the loop stops waiting), and
305
305
  * async iteration (`for await (const chunk of process.stdin)` — chunks
@@ -310,9 +310,18 @@ declare var process: {
310
310
  on(event: "data", listener: (chunk: Uint8Array) => void): void;
311
311
  on(event: "end", listener: () => void): void;
312
312
  on(event: "error", listener: (err: Error) => void): void;
313
+ /* readline.emitKeypressEvents(process.stdin)'s keys */
314
+ on(
315
+ event: "keypress",
316
+ listener: (str: string | undefined, key: import("readline").Key) => void,
317
+ ): void;
313
318
  once(event: "data", listener: (chunk: Uint8Array) => void): void;
314
319
  once(event: "end", listener: () => void): void;
315
320
  once(event: "error", listener: (err: Error) => void): void;
321
+ once(
322
+ event: "keypress",
323
+ listener: (str: string | undefined, key: import("readline").Key) => void,
324
+ ): void;
316
325
  destroy(): void;
317
326
  setEncoding(encoding: "utf8"): void;
318
327
  /* Termios raw mode on a TTY stdin (libuv's UV_TTY_MODE_RAW, the mode
@@ -1251,6 +1260,45 @@ declare module "node:fs" {
1251
1260
  path: string | Uint8Array | URL,
1252
1261
  type?: string | null,
1253
1262
  ): void;
1263
+ /* fs.cpSync / fs.cp: copies a file, symlink or (with recursive) a
1264
+ * directory tree. filter decides per path; the callback and promise
1265
+ * forms complete the copy before reporting. */
1266
+ export interface CopySyncOptions {
1267
+ dereference?: boolean;
1268
+ errorOnExist?: boolean;
1269
+ filter?: (source: string, destination: string) => boolean;
1270
+ force?: boolean;
1271
+ mode?: number;
1272
+ preserveTimestamps?: boolean;
1273
+ recursive?: boolean;
1274
+ verbatimSymlinks?: boolean;
1275
+ }
1276
+ export interface CopyOptions {
1277
+ dereference?: boolean;
1278
+ errorOnExist?: boolean;
1279
+ filter?: (source: string, destination: string) => boolean | Promise<boolean>;
1280
+ force?: boolean;
1281
+ mode?: number;
1282
+ preserveTimestamps?: boolean;
1283
+ recursive?: boolean;
1284
+ verbatimSymlinks?: boolean;
1285
+ }
1286
+ export function cpSync(
1287
+ source: string | URL,
1288
+ destination: string | URL,
1289
+ options?: CopySyncOptions,
1290
+ ): void;
1291
+ export function cp(
1292
+ source: string | URL,
1293
+ destination: string | URL,
1294
+ callback: (err: NodeJS.ErrnoException | null) => void,
1295
+ ): void;
1296
+ export function cp(
1297
+ source: string | URL,
1298
+ destination: string | URL,
1299
+ options: CopyOptions,
1300
+ callback: (err: NodeJS.ErrnoException | null) => void,
1301
+ ): void;
1254
1302
  export function symlink(
1255
1303
  target: string | Uint8Array | URL,
1256
1304
  path: string | Uint8Array | URL,
@@ -1441,6 +1489,9 @@ declare module "node:fs" {
1441
1489
  readonly O_NONBLOCK: number;
1442
1490
  readonly O_TRUNC: number;
1443
1491
  readonly O_APPEND: number;
1492
+ readonly COPYFILE_EXCL: number;
1493
+ readonly COPYFILE_FICLONE: number;
1494
+ readonly COPYFILE_FICLONE_FORCE: number;
1444
1495
  };
1445
1496
  /* A stat(2) snapshot (statSync follows symlinks, lstatSync does not —
1446
1497
  * Node's split) — immutable; the supported surface is exactly these
@@ -1474,8 +1525,37 @@ declare module "node:fs" {
1474
1525
  readonly ctime: Date;
1475
1526
  readonly birthtime: Date;
1476
1527
  }
1477
- export function statSync(path: string): Stats;
1478
- export function lstatSync(path: string): Stats;
1528
+ /* throwIfNoEntry: false answers undefined for a missing entry (ENOENT or
1529
+ * ENOTDIR) instead of throwing. BigIntStats (bigint: true) has no
1530
+ * lowering. */
1531
+ export interface StatSyncOptions {
1532
+ bigint?: boolean;
1533
+ throwIfNoEntry?: boolean;
1534
+ }
1535
+ export function statSync(path: string, options?: undefined): Stats;
1536
+ export function statSync(
1537
+ path: string,
1538
+ options: StatSyncOptions & { bigint?: false; throwIfNoEntry: false },
1539
+ ): Stats | undefined;
1540
+ export function statSync(
1541
+ path: string,
1542
+ options: StatSyncOptions & { bigint?: false; throwIfNoEntry?: true },
1543
+ ): Stats;
1544
+ /* bigint: true type-checks so the lowering can name it as unsupported. */
1545
+ export function statSync(path: string, options: StatSyncOptions & { bigint: true }): Stats;
1546
+ export function statSync(path: string, options: StatSyncOptions): Stats | undefined;
1547
+ export function lstatSync(path: string, options?: undefined): Stats;
1548
+ export function lstatSync(
1549
+ path: string,
1550
+ options: StatSyncOptions & { bigint?: false; throwIfNoEntry: false },
1551
+ ): Stats | undefined;
1552
+ export function lstatSync(
1553
+ path: string,
1554
+ options: StatSyncOptions & { bigint?: false; throwIfNoEntry?: true },
1555
+ ): Stats;
1556
+ /* bigint: true type-checks so the lowering can name it as unsupported. */
1557
+ export function lstatSync(path: string, options: StatSyncOptions & { bigint: true }): Stats;
1558
+ export function lstatSync(path: string, options: StatSyncOptions): Stats | undefined;
1479
1559
  /* The fd pair behind spawn's fd-stdio form: openSync(path, flags) →
1480
1560
  * the raw fd. Numeric flags use an inline OR of the O_* constants. */
1481
1561
  export function openSync(path: string, flags: string): number;
@@ -1760,6 +1840,11 @@ declare module "fs/promises" {
1760
1840
  path: string | Uint8Array | URL,
1761
1841
  type?: string | null,
1762
1842
  ): Promise<void>;
1843
+ export function cp(
1844
+ source: string | URL,
1845
+ destination: string | URL,
1846
+ options?: import("node:fs").CopyOptions,
1847
+ ): Promise<void>;
1763
1848
  export function readlink(
1764
1849
  path: string | Uint8Array | URL,
1765
1850
  options: "buffer" | { encoding: "buffer" },
@@ -2376,6 +2461,7 @@ declare module "node:url" {
2376
2461
 
2377
2462
  /* node:crypto: the static hashing/MAC/random/key-derivation utility slice. */
2378
2463
  declare module "crypto" {
2464
+ import { Transform } from "stream";
2379
2465
  export type KeyObjectType = "secret" | "public" | "private";
2380
2466
  export interface JsonWebKey {
2381
2467
  kty?: string;
@@ -2418,14 +2504,16 @@ declare module "crypto" {
2418
2504
  export interface HashOptions {
2419
2505
  outputLength?: number | undefined;
2420
2506
  }
2421
- export interface Hash {
2507
+ /* Hash and Hmac are Transforms: written chunks update the digest, which
2508
+ * the readable side delivers once the writable side ends. */
2509
+ export interface Hash extends Transform {
2422
2510
  copy(options?: HashOptions): Hash;
2423
2511
  update(data: string | ArrayBufferView): Hash;
2424
2512
  update(data: string, inputEncoding: Encoding): Hash;
2425
2513
  digest(): Buffer;
2426
2514
  digest(encoding: BinaryToTextEncoding): string;
2427
2515
  }
2428
- export interface Hmac {
2516
+ export interface Hmac extends Transform {
2429
2517
  update(data: string | ArrayBufferView): Hmac;
2430
2518
  update(data: string, inputEncoding: Encoding): Hmac;
2431
2519
  digest(): Buffer;
@@ -3033,6 +3121,12 @@ declare module "util" {
3033
3121
  export type TextDecoder = globalThis.TextDecoder;
3034
3122
  export var TextEncoder: typeof globalThis.TextEncoder;
3035
3123
  export var TextDecoder: typeof globalThis.TextDecoder;
3124
+ /* stream.pipeline's (...streams: unknown[]) => unknown is assignable to
3125
+ * every other target's parameter type, so its overload comes first; no
3126
+ * other target is assignable to it. */
3127
+ export function promisify(
3128
+ fn: typeof import("node:stream").pipeline,
3129
+ ): typeof import("node:stream/promises").pipeline;
3036
3130
  export function promisify(
3037
3131
  fn: typeof import("node:fs").readFile,
3038
3132
  ): (path: string, encoding: "utf8" | "utf-8") => Promise<string>;
@@ -3051,6 +3145,12 @@ declare module "util" {
3051
3145
  windowsHide?: boolean;
3052
3146
  },
3053
3147
  ) => Promise<{ stdout: string; stderr: string }>;
3148
+ export function promisify(
3149
+ fn: typeof globalThis.setTimeout,
3150
+ ): typeof import("node:timers/promises").setTimeout;
3151
+ export function promisify(
3152
+ fn: typeof globalThis.setImmediate,
3153
+ ): typeof import("node:timers/promises").setImmediate;
3054
3154
  export function promisify(fn: typeof import("node:child_process").exec): (
3055
3155
  command: string,
3056
3156
  options?: {
@@ -3063,6 +3163,14 @@ declare module "util" {
3063
3163
  windowsHide?: boolean;
3064
3164
  },
3065
3165
  ) => Promise<{ stdout: string; stderr: string }>;
3166
+ /* The zlib callback one-shots (deflate, inflate, deflateRaw, inflateRaw,
3167
+ * gzip, gunzip, unzip) share one type. */
3168
+ export function promisify(
3169
+ fn: typeof import("node:zlib").gzip,
3170
+ ): (data: string | Uint8Array, options?: import("node:zlib").ZlibOptions) => Promise<Buffer>;
3171
+ export function promisify(
3172
+ fn: typeof import("node:stream").finished,
3173
+ ): typeof import("node:stream/promises").finished;
3066
3174
  /* Declared surface without full lowering (the type-level tolerance
3067
3175
  * story: guarded/diagnostic-path code must TYPECHECK; a reached use
3068
3176
  * without a lowering fences at its site). inspect's options carry the
@@ -3249,8 +3357,9 @@ declare module "node:test" {
3249
3357
  function after(fn: HookFn): void;
3250
3358
  function beforeEach(fn: HookFn): void;
3251
3359
  function afterEach(fn: HookFn): void;
3252
- /* The mock function surface: mock.fn and t.mock.fn, with the calls log
3253
- * and the implementation controls on fn.mock. */
3360
+ /* The mock function surface: mock.fn, mock.method and their t.mock
3361
+ * twins, the tracker's restoreAll and reset, and the calls log and the
3362
+ * implementation controls on fn.mock. */
3254
3363
  interface MockFunctionCall<
3255
3364
  F extends Function,
3256
3365
  ReturnType = F extends (...args: any) => infer T ? T : unknown,
@@ -3270,17 +3379,35 @@ declare module "node:test" {
3270
3379
  restore(): void;
3271
3380
  }
3272
3381
  type Mock<F extends Function> = F & { mock: MockFunctionContext<F> };
3382
+ interface MockFunctionOptions {
3383
+ times?: number;
3384
+ }
3385
+ type FunctionPropertyNames<T> = {
3386
+ [K in keyof T]: T[K] extends Function ? K : never;
3387
+ }[keyof T];
3273
3388
  interface MockTracker {
3274
3389
  fn<F extends Function = (...args: any[]) => undefined>(original?: F): Mock<F>;
3275
3390
  fn<F extends Function = (...args: any[]) => undefined, Implementation extends Function = F>(
3276
3391
  original?: F,
3277
3392
  implementation?: Implementation,
3278
3393
  ): Mock<F | Implementation>;
3279
- method<MockedObject extends object>(
3394
+ method<MockedObject extends object, MethodName extends FunctionPropertyNames<MockedObject>>(
3280
3395
  object: MockedObject,
3281
- methodName: keyof MockedObject,
3282
- implementation?: Function,
3283
- ): Mock<Function>;
3396
+ methodName: MethodName,
3397
+ options?: MockFunctionOptions,
3398
+ ): MockedObject[MethodName] extends Function ? Mock<MockedObject[MethodName]> : never;
3399
+ method<
3400
+ MockedObject extends object,
3401
+ MethodName extends FunctionPropertyNames<MockedObject>,
3402
+ Implementation extends Function,
3403
+ >(
3404
+ object: MockedObject,
3405
+ methodName: MethodName,
3406
+ implementation: Implementation,
3407
+ options?: MockFunctionOptions,
3408
+ ): MockedObject[MethodName] extends Function
3409
+ ? Mock<MockedObject[MethodName] | Implementation>
3410
+ : never;
3284
3411
  reset(): void;
3285
3412
  restoreAll(): void;
3286
3413
  }
@@ -3523,10 +3650,31 @@ declare module "node:querystring" {
3523
3650
  * on("close", cb). An open interface keeps the process alive until
3524
3651
  * close()/EOF, Node's semantics; lines split on \n and \r\n. */
3525
3652
  declare module "readline" {
3526
- /* The non-terminal Interface over process.stdin or a stream input
3527
- * (scr_readline.c). Listener registrations are statements: chaining
3528
- * on()/once() results has no lowering. */
3653
+ /* The Interface over process.stdin or a stream input (scr_readline.c;
3654
+ * terminal mode in scr_readline_tty.c). Listener registrations are
3655
+ * statements: chaining on()/once() results has no lowering. */
3656
+ export interface Key {
3657
+ sequence?: string;
3658
+ name?: string;
3659
+ ctrl?: boolean;
3660
+ meta?: boolean;
3661
+ shift?: boolean;
3662
+ }
3529
3663
  export interface Interface extends Disposable {
3664
+ /* terminal says whether the interface edits lines as a terminal;
3665
+ * line and cursor are the terminal's (line is '' otherwise). history
3666
+ * is the history option itself (or the interface's own empty array);
3667
+ * a terminal records the lines it reads. */
3668
+ readonly terminal: boolean;
3669
+ readonly line: string;
3670
+ readonly cursor: number;
3671
+ getCursorPos(): CursorPos;
3672
+ history: string[];
3673
+ readonly historySize: number;
3674
+ readonly historyIndex: number;
3675
+ readonly crlfDelay: number;
3676
+ readonly tabSize: number;
3677
+ readonly escapeCodeTimeout: number;
3530
3678
  question(query: string, callback: (answer: string) => void): void;
3531
3679
  close(): void;
3532
3680
  pause(): this;
@@ -3534,16 +3682,28 @@ declare module "readline" {
3534
3682
  prompt(preserveCursor?: boolean): void;
3535
3683
  setPrompt(prompt: string): void;
3536
3684
  getPrompt(): string;
3537
- write(data: string): void;
3685
+ write(data: string | null | undefined, key?: Key): void;
3538
3686
  on(event: "line", listener: (input: string) => void): this;
3539
- on(event: "close" | "pause" | "resume", listener: () => void): this;
3687
+ on(
3688
+ event: "close" | "pause" | "resume" | "SIGINT" | "SIGTSTP" | "SIGCONT",
3689
+ listener: () => void,
3690
+ ): this;
3540
3691
  on(event: "error", listener: (err: Error) => void): this;
3692
+ on(event: "history", listener: (history: string[]) => void): this;
3541
3693
  once(event: "line", listener: (input: string) => void): this;
3542
- once(event: "close" | "pause" | "resume", listener: () => void): this;
3694
+ once(
3695
+ event: "close" | "pause" | "resume" | "SIGINT" | "SIGTSTP" | "SIGCONT",
3696
+ listener: () => void,
3697
+ ): this;
3543
3698
  once(event: "error", listener: (err: Error) => void): this;
3699
+ once(event: "history", listener: (history: string[]) => void): this;
3544
3700
  addListener(event: "line", listener: (input: string) => void): this;
3545
- addListener(event: "close" | "pause" | "resume", listener: () => void): this;
3701
+ addListener(
3702
+ event: "close" | "pause" | "resume" | "SIGINT" | "SIGTSTP" | "SIGCONT",
3703
+ listener: () => void,
3704
+ ): this;
3546
3705
  addListener(event: "error", listener: (err: Error) => void): this;
3706
+ addListener(event: "history", listener: (history: string[]) => void): this;
3547
3707
  [Symbol.asyncIterator](): AsyncIterableIterator<string>;
3548
3708
  [Symbol.dispose](): void;
3549
3709
  }
@@ -3553,26 +3713,83 @@ declare module "readline" {
3553
3713
  terminal?: boolean;
3554
3714
  /* Node's crlfDelay: a \n arriving within this many ms (at least 100)
3555
3715
  * after a line ended by \r is dropped. completer and the history
3556
- * knobs fence by name (no interactive terminal). The options-record
3716
+ * options are validated and kept; a terminal interface uses them.
3717
+ * The options-record
3557
3718
  * stance (see http.RequestOptions) admits every key; the walk
3558
3719
  * decides. */
3559
3720
  crlfDelay?: number;
3560
3721
  completer?: unknown;
3561
3722
  signal?: AbortSignal;
3723
+ history?: string[];
3724
+ historySize?: number;
3725
+ removeHistoryDuplicates?: boolean;
3726
+ tabSize?: number;
3727
+ escapeCodeTimeout?: number;
3562
3728
  [option: string]: unknown;
3563
3729
  }
3564
3730
  export function createInterface(options: ReadLineOptions): Interface;
3565
- export function createInterface(input: unknown, output?: unknown): Interface;
3731
+ export function createInterface(
3732
+ input: unknown,
3733
+ output?: unknown,
3734
+ completer?: unknown,
3735
+ terminal?: boolean,
3736
+ ): Interface;
3737
+ export interface CursorPos {
3738
+ rows: number;
3739
+ cols: number;
3740
+ }
3741
+ /* The escape-sequence helpers over process.stdout, process.stderr, a
3742
+ * writable stream, or null/undefined (nothing is written). */
3743
+ export function cursorTo(stream: unknown, x: number, y?: number, callback?: () => void): boolean;
3744
+ export function cursorTo(stream: unknown, x: number, callback: () => void): boolean;
3745
+ export function moveCursor(
3746
+ stream: unknown,
3747
+ dx: number,
3748
+ dy: number,
3749
+ callback?: () => void,
3750
+ ): boolean;
3751
+ export function clearLine(stream: unknown, dir: -1 | 0 | 1, callback?: () => void): boolean;
3752
+ export function clearScreenDown(stream: unknown, callback?: () => void): boolean;
3753
+ /* 'keypress' events (str, key) on process.stdin or a readable stream */
3754
+ export function emitKeypressEvents(stream: unknown, readlineInterface?: unknown): void;
3755
+ /* the same object as node:readline/promises */
3756
+ export const promises: typeof import("node:readline/promises");
3566
3757
  }
3567
3758
  declare module "node:readline" {
3568
3759
  export * from "readline";
3569
3760
  }
3570
3761
  declare module "readline/promises" {
3571
- import { ReadLineOptions } from "readline";
3762
+ import { CursorPos, Key, ReadLineOptions } from "readline";
3763
+ /* The escape-sequence builder over process.stdout, process.stderr or a
3764
+ * writable stream: actions queue until commit(), or are written on the
3765
+ * next tick with autoCommit. */
3766
+ export class Readline {
3767
+ constructor(stream: unknown, options?: { autoCommit?: boolean });
3768
+ clearLine(dir: -1 | 0 | 1): this;
3769
+ clearScreenDown(): this;
3770
+ commit(): Promise<void>;
3771
+ cursorTo(x: number, y?: number): this;
3772
+ moveCursor(dx: number, dy: number): this;
3773
+ rollback(): this;
3774
+ }
3572
3775
  /* The readline Interface with the promise question: it resolves with
3573
3776
  * the next line, rejects with an AbortError when options.signal aborts,
3574
3777
  * and with ERR_USE_AFTER_CLOSE after close(). */
3575
3778
  export interface Interface extends Disposable {
3779
+ /* terminal says whether the interface edits lines as a terminal;
3780
+ * line and cursor are the terminal's (line is '' otherwise). history
3781
+ * is the history option itself (or the interface's own empty array);
3782
+ * a terminal records the lines it reads. */
3783
+ readonly terminal: boolean;
3784
+ readonly line: string;
3785
+ readonly cursor: number;
3786
+ getCursorPos(): CursorPos;
3787
+ history: string[];
3788
+ readonly historySize: number;
3789
+ readonly historyIndex: number;
3790
+ readonly crlfDelay: number;
3791
+ readonly tabSize: number;
3792
+ readonly escapeCodeTimeout: number;
3576
3793
  question(query: string, options?: { signal?: AbortSignal }): Promise<string>;
3577
3794
  close(): void;
3578
3795
  pause(): this;
@@ -3580,21 +3797,38 @@ declare module "readline/promises" {
3580
3797
  prompt(preserveCursor?: boolean): void;
3581
3798
  setPrompt(prompt: string): void;
3582
3799
  getPrompt(): string;
3583
- write(data: string): void;
3800
+ write(data: string | null | undefined, key?: Key): void;
3584
3801
  on(event: "line", listener: (input: string) => void): this;
3585
- on(event: "close" | "pause" | "resume", listener: () => void): this;
3802
+ on(
3803
+ event: "close" | "pause" | "resume" | "SIGINT" | "SIGTSTP" | "SIGCONT",
3804
+ listener: () => void,
3805
+ ): this;
3586
3806
  on(event: "error", listener: (err: Error) => void): this;
3807
+ on(event: "history", listener: (history: string[]) => void): this;
3587
3808
  once(event: "line", listener: (input: string) => void): this;
3588
- once(event: "close" | "pause" | "resume", listener: () => void): this;
3809
+ once(
3810
+ event: "close" | "pause" | "resume" | "SIGINT" | "SIGTSTP" | "SIGCONT",
3811
+ listener: () => void,
3812
+ ): this;
3589
3813
  once(event: "error", listener: (err: Error) => void): this;
3814
+ once(event: "history", listener: (history: string[]) => void): this;
3590
3815
  addListener(event: "line", listener: (input: string) => void): this;
3591
- addListener(event: "close" | "pause" | "resume", listener: () => void): this;
3816
+ addListener(
3817
+ event: "close" | "pause" | "resume" | "SIGINT" | "SIGTSTP" | "SIGCONT",
3818
+ listener: () => void,
3819
+ ): this;
3592
3820
  addListener(event: "error", listener: (err: Error) => void): this;
3821
+ addListener(event: "history", listener: (history: string[]) => void): this;
3593
3822
  [Symbol.asyncIterator](): AsyncIterableIterator<string>;
3594
3823
  [Symbol.dispose](): void;
3595
3824
  }
3596
3825
  export function createInterface(options: ReadLineOptions): Interface;
3597
- export function createInterface(input: unknown, output?: unknown): Interface;
3826
+ export function createInterface(
3827
+ input: unknown,
3828
+ output?: unknown,
3829
+ completer?: unknown,
3830
+ terminal?: boolean,
3831
+ ): Interface;
3598
3832
  }
3599
3833
  declare module "node:readline/promises" {
3600
3834
  export * from "readline/promises";
@@ -4161,7 +4395,7 @@ declare module "net" {
4161
4395
  /* http.createServer(handler)'s event twin (a no-parser net server
4162
4396
  * never fires it, like Node). */
4163
4397
  on(
4164
- event: "request",
4398
+ event: "request" | "checkContinue" | "checkExpectation",
4165
4399
  listener: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => void,
4166
4400
  ): void;
4167
4401
  /* addListener IS on (Node aliases them) — the suite spells both. */
@@ -4175,7 +4409,7 @@ declare module "net" {
4175
4409
  listener: (req: import("http").IncomingMessage, socket: Socket, head: Buffer) => void,
4176
4410
  ): void;
4177
4411
  addListener(
4178
- event: "request",
4412
+ event: "request" | "checkContinue" | "checkExpectation",
4179
4413
  listener: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => void,
4180
4414
  ): void;
4181
4415
  once(event: "connection" | "secureConnection", listener: (socket: Socket) => void): void;
@@ -4188,7 +4422,7 @@ declare module "net" {
4188
4422
  listener: (req: import("http").IncomingMessage, socket: Socket, head: Buffer) => void,
4189
4423
  ): void;
4190
4424
  once(
4191
- event: "request",
4425
+ event: "request" | "checkContinue" | "checkExpectation",
4192
4426
  listener: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => void,
4193
4427
  ): void;
4194
4428
  }
@@ -4309,6 +4543,7 @@ declare module "http" {
4309
4543
  requireHostHeader?: boolean;
4310
4544
  joinDuplicateHeaders?: boolean;
4311
4545
  keepAliveTimeoutBuffer?: number;
4546
+ maxHeaderSize?: number;
4312
4547
  [option: string]: unknown;
4313
4548
  }
4314
4549
  /* The outgoing-header shape, @types/node's matrix: numbers format via
@@ -4428,6 +4663,8 @@ declare module "http" {
4428
4663
  * Agent VALUE threads through (getName-keyed maxSockets accounting
4429
4664
  * over one-dial-per-request connections). */
4430
4665
  agent?: Agent | boolean | null;
4666
+ /* Aborting destroys the request with an AbortError. */
4667
+ signal?: AbortSignal;
4431
4668
  /* The options-record stance: Node ignores an options record's
4432
4669
  * unknown keys, so every key typechecks here — the option WALK in
4433
4670
  * the lowering decides per key (lower, fence by name, or drop
@@ -4509,7 +4746,7 @@ declare module "http" {
4509
4746
  setTimeout(timeout: number, callback?: () => void): this;
4510
4747
  write(data: string | Uint8Array): void;
4511
4748
  end(data?: string | Uint8Array): void;
4512
- destroy(): void;
4749
+ destroy(error?: Error): void;
4513
4750
  abort(): void;
4514
4751
  on(event: "response", listener: (res: IncomingMessage) => void): void;
4515
4752
  on(event: "socket", listener: (socket: Socket) => void): void;
@@ -4517,7 +4754,7 @@ declare module "http" {
4517
4754
  event: "upgrade",
4518
4755
  listener: (res: IncomingMessage, socket: Socket, head: Buffer) => void,
4519
4756
  ): void;
4520
- on(event: "timeout" | "close" | "finish" | "abort", listener: () => void): void;
4757
+ on(event: "timeout" | "close" | "finish" | "abort" | "continue", listener: () => void): void;
4521
4758
  on(event: "error", listener: (err: Error) => void): void;
4522
4759
  /* addListener IS on (Node aliases them) — the suite spells both. */
4523
4760
  addListener(event: "response", listener: (res: IncomingMessage) => void): void;
@@ -4534,7 +4771,7 @@ declare module "http" {
4534
4771
  event: "upgrade",
4535
4772
  listener: (res: IncomingMessage, socket: Socket, head: Buffer) => void,
4536
4773
  ): void;
4537
- once(event: "timeout" | "close" | "finish" | "abort", listener: () => void): void;
4774
+ once(event: "timeout" | "close" | "finish" | "abort" | "continue", listener: () => void): void;
4538
4775
  once(event: "error", listener: (err: Error) => void): void;
4539
4776
  }
4540
4777
  export function createServer(
@@ -4697,6 +4934,8 @@ declare module "https" {
4697
4934
  rejectUnauthorized?: boolean;
4698
4935
  ca?: string | Uint8Array;
4699
4936
  agent?: Agent | boolean | null;
4937
+ /* Aborting destroys the request with an AbortError. */
4938
+ signal?: AbortSignal;
4700
4939
  /* The options-record stance (see http.RequestOptions). */
4701
4940
  [option: string]: unknown;
4702
4941
  }
@@ -5572,6 +5811,13 @@ declare module "worker_threads" {
5572
5811
  removeAllListeners(event?: string): this;
5573
5812
  listenerCount(event: string, listener?: (...args: any[]) => void): number;
5574
5813
  }
5814
+ /* Two entangled ports; a port moves to another thread through a
5815
+ * postMessage or workerData transferList. */
5816
+ export class MessageChannel {
5817
+ readonly port1: MessagePort;
5818
+ readonly port2: MessagePort;
5819
+ }
5820
+ export function receiveMessageOnPort(port: MessagePort): { message: any } | undefined;
5575
5821
  export const parentPort: MessagePort | null;
5576
5822
  export const workerData: any;
5577
5823
  }
@@ -9,7 +9,7 @@ import { dynDesc, streamTypedRefEligible } from "../../ir/analysis.js";
9
9
  import { mangleRecordNew, mangleRecordStruct } from "../mangle.js";
10
10
  import { BlockBuilder } from "./blocks.js";
11
11
  import { llvmCommentText } from "./common.js";
12
- import { arrNewCall, elemAccess, llFieldType, releaseSym, traceAdapter, traceArg, vAdapters, } from "./shapes.js";
12
+ import { arrNewCall, elemAccess, llFieldType, mapFlagsOffset, releaseSym, traceAdapter, traceArg, vAdapters, } from "./shapes.js";
13
13
  import { LlvmUnsupportedError } from "./unsupported.js";
14
14
  import { recordMayKeepSource, recordSourceFieldOrder } from "./record-sources.js";
15
15
  /** Whether to-dyn of a record shape keeps the record itself: an empty shape
@@ -1570,6 +1570,17 @@ export class LlDyn {
1570
1570
  const ovf = B.tmp();
1571
1571
  B.line(`${ovfp} = getelementptr inbounds %${struct}, ptr %r0, i64 0, i32 ${shape.fields.length + 1}`);
1572
1572
  B.line(`${ovf} = load ptr, ptr ${ovfp} ; overflow map`);
1573
+ if (shape.fields.length === 0) {
1574
+ // Object.create(null)'s dictionary keeps its null prototype:
1575
+ // ScrDyn.null_proto becomes SCR_MAP_NULL_PROTO.
1576
+ const npp = B.tmp();
1577
+ const np = B.tmp();
1578
+ const flagsp = B.tmp();
1579
+ B.line(`${npp} = getelementptr inbounds i8, ptr %d, i64 ${this.abiOffset(13, 9)} ; ->null_proto`);
1580
+ B.line(`${np} = load i8, ptr ${npp}`);
1581
+ B.line(`${flagsp} = getelementptr inbounds i8, ptr ${ovf}, i64 ${mapFlagsOffset(host.sizeType)}`);
1582
+ B.line(`store i8 ${np}, ptr ${flagsp}`);
1583
+ }
1573
1584
  const n = this.lenOf(B, "%d");
1574
1585
  const entries = this.itemsOf(B, "%d");
1575
1586
  this.i64Loop(B, "dcv", n, (i, brNext) => {
@@ -2130,6 +2141,25 @@ export class LlDyn {
2130
2141
  host.declare(`declare ptr @scr_dyn_new_obj_with_identity(ptr, ptr, ptr)`);
2131
2142
  B.line(`${d} = call ptr @scr_dyn_new_obj_with_identity(ptr %v, ptr ${rc.retain}, ptr @${sourceAccessor.name})`);
2132
2143
  }
2144
+ else if (shape.indexValue && shape.fields.length === 0) {
2145
+ // A pure index-signature record keeps a null prototype
2146
+ // (SCR_MAP_NULL_PROTO on its overflow map; Object.groupBy).
2147
+ host.declare(`declare ptr @scr_dyn_new_obj()`);
2148
+ host.declare(`declare ptr @scr_dyn_new_obj_null_proto()`);
2149
+ const ovfp = B.tmp();
2150
+ const ovf = B.tmp();
2151
+ const flagsp = B.tmp();
2152
+ const flags = B.tmp();
2153
+ const np = B.tmp();
2154
+ const alloc = B.tmp();
2155
+ B.line(`${ovfp} = getelementptr inbounds %${struct}, ptr %v, i64 0, i32 1`);
2156
+ B.line(`${ovf} = load ptr, ptr ${ovfp} ; overflow map`);
2157
+ B.line(`${flagsp} = getelementptr inbounds i8, ptr ${ovf}, i64 ${mapFlagsOffset(host.sizeType)}`);
2158
+ B.line(`${flags} = load i8, ptr ${flagsp}`);
2159
+ B.line(`${np} = icmp ne i8 ${flags}, 0`);
2160
+ B.line(`${alloc} = select i1 ${np}, ptr @scr_dyn_new_obj_null_proto, ptr @scr_dyn_new_obj`);
2161
+ B.line(`${d} = call ptr ${alloc}()`);
2162
+ }
2133
2163
  else {
2134
2164
  host.declare(`declare ptr @scr_dyn_new_obj()`);
2135
2165
  B.line(`${d} = call ptr @scr_dyn_new_obj()`);