@orkestrel/sea 0.0.13 → 0.0.14

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.
@@ -3,13 +3,72 @@ import { EmitterHooks } from '@orkestrel/emitter';
3
3
  import { EmitterInterface } from '@orkestrel/emitter';
4
4
 
5
5
  /**
6
- * Align an ELF note component size to its four-byte boundary.
6
+ * Aligns an ELF note component size to its four-byte boundary.
7
7
  *
8
8
  * @param value - Component size to align
9
9
  * @returns The value rounded up to the next multiple of four
10
10
  */
11
11
  export declare function alignELFNoteSize(value: number): number;
12
12
 
13
+ /**
14
+ * Rounds a value up to the next multiple of an alignment boundary.
15
+ *
16
+ * @remarks
17
+ * The shared alignment leaf behind every binary-format writer in this package:
18
+ * PE section and file alignment, ELF note and page alignment, and Mach-O page
19
+ * alignment all round the same way. `alignment` must be a nonzero power of two
20
+ * ({@link isPowerOfTwo} is the guard the PE injector applies before using a
21
+ * value read out of a header as a divisor).
22
+ *
23
+ * @param value - Value to align
24
+ * @param alignment - Alignment boundary to round up to
25
+ * @returns The value rounded up to the next multiple of `alignment`
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * alignTo(10, 4) // 12
30
+ * alignTo(4096, 4096) // 4096 — already aligned
31
+ * ```
32
+ */
33
+ export declare function alignTo(value: number, alignment: number): number;
34
+
35
+ /**
36
+ * Appends a source file to a target file, streaming in fixed-size chunks.
37
+ *
38
+ * @remarks
39
+ * Reads `source` in `chunk`-sized reads and appends each chunk to `target`, so
40
+ * a multi-hundred-megabyte blob is never fully buffered. A read returning zero
41
+ * bytes ends the copy, which is the normal end-of-file signal for a source that
42
+ * shrank between the size read and the copy.
43
+ *
44
+ * @param target - Path of the file to append to
45
+ * @param source - Path of the file to append
46
+ * @param chunk - Read/append chunk size in bytes. Default: 4 MB.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * appendFile('dist/sea/app', 'dist/sea/sea-prep.blob')
51
+ * ```
52
+ */
53
+ export declare function appendFile(target: string, source: string, chunk?: number): void;
54
+
55
+ /**
56
+ * Holds one named asset's key, bytes, and compression state.
57
+ *
58
+ * @remarks
59
+ * `compressed` is inferred from a `.br` suffix on the key whenever the input
60
+ * leaves it unset, so a Brotli output registered under its own name reports itself
61
+ * correctly without the caller restating it.
62
+ *
63
+ * @param input - The asset's key, content bytes, and optional compression flag
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const asset = new Asset({ key: 'client.html.br', content: compressedBuffer })
68
+ * asset.key // 'client.html.br'
69
+ * asset.compressed // true
70
+ * ```
71
+ */
13
72
  export declare class Asset implements AssetInterface {
14
73
  readonly key: string;
15
74
  readonly content: ArrayBuffer;
@@ -18,7 +77,7 @@ export declare class Asset implements AssetInterface {
18
77
  }
19
78
 
20
79
  /**
21
- * Minimal data needed to create an {@link AssetInterface}.
80
+ * Holds the minimal data needed to create an {@link AssetInterface}.
22
81
  *
23
82
  * @remarks
24
83
  * `key` — the asset's lookup key (e.g. `"client.html.br"`).
@@ -33,7 +92,7 @@ export declare interface AssetInput {
33
92
  }
34
93
 
35
94
  /**
36
- * A single named asset wrapping its key, content buffer, and compression flag.
95
+ * Represents a single named asset wrapping its key, content buffer, and compression flag.
37
96
  */
38
97
  export declare interface AssetInterface {
39
98
  readonly key: string;
@@ -41,6 +100,29 @@ export declare interface AssetInterface {
41
100
  readonly compressed: boolean;
42
101
  }
43
102
 
103
+ /**
104
+ * Collects named assets from a SEA blob or from disk and serves them by key.
105
+ *
106
+ * @remarks
107
+ * Construction registers every asset embedded in the running SEA blob, so an
108
+ * executable built by this package reaches its assets without touching the
109
+ * filesystem. Outside SEA mode that step registers nothing, and `load()` reads
110
+ * the paths `options.assets` configures instead.
111
+ *
112
+ * @param options - Asset manager options: the project root, the key→path mapping
113
+ * `load()` reads, and the event hooks
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const manager = new AssetManager({
118
+ * root: process.cwd(),
119
+ * assets: { 'client.html.br': 'dist/client/client.html.br' },
120
+ * })
121
+ * manager.load()
122
+ * manager.asset('client.html.br')
123
+ * manager.destroy()
124
+ * ```
125
+ */
44
126
  export declare class AssetManager implements AssetManagerInterface {
45
127
  #private;
46
128
  constructor(options?: AssetManagerOptions);
@@ -49,13 +131,13 @@ export declare class AssetManager implements AssetManagerInterface {
49
131
  asset(key: string): AssetInterface | undefined;
50
132
  assets(): readonly AssetInterface[];
51
133
  keys(): readonly string[];
52
- register(input: AssetInput | AssetInput[]): void;
134
+ register(input: AssetInput | readonly AssetInput[]): void;
53
135
  load(): void;
54
136
  clear(): void;
55
137
  destroy(): void;
56
138
  }
57
139
 
58
- /** Events emitted by an {@link AssetManagerInterface}. */
140
+ /** Lists the events emitted by an {@link AssetManagerInterface}. */
59
141
  export declare type AssetManagerEventMap = {
60
142
  readonly register: readonly [asset: AssetInterface];
61
143
  readonly load: readonly [keys: readonly string[]];
@@ -64,11 +146,11 @@ export declare type AssetManagerEventMap = {
64
146
  };
65
147
 
66
148
  /**
67
- * Named asset collection with SEA and disk loading.
149
+ * Represents a named asset collection with SEA and disk loading.
68
150
  *
69
151
  * @remarks
70
152
  * In SEA mode, embedded assets are loaded automatically at construction.
71
- * Outside SEA, `load()` reads client assets from disk.
153
+ * Outside SEA, `load()` reads the paths `assets` configures from disk.
72
154
  */
73
155
  export declare interface AssetManagerInterface {
74
156
  readonly emitter: EmitterInterface<AssetManagerEventMap>;
@@ -76,29 +158,59 @@ export declare interface AssetManagerInterface {
76
158
  asset(key: string): AssetInterface | undefined;
77
159
  assets(): readonly AssetInterface[];
78
160
  keys(): readonly string[];
79
- register(input: AssetInput | AssetInput[]): void;
161
+ register(input: AssetInput | readonly AssetInput[]): void;
80
162
  load(): void;
81
163
  clear(): void;
82
164
  destroy(): void;
83
165
  }
84
166
 
85
167
  /**
86
- * Options for creating an {@link AssetManagerInterface}.
168
+ * Configures the creation of an {@link AssetManagerInterface}.
87
169
  *
88
170
  * @remarks
89
- * `root` — project root used to resolve on-disk client assets. Default: `process.cwd()`.
171
+ * `root` — project root used to resolve the configured `assets` paths. Default: `process.cwd()`.
172
+ * `assets` — key→path mapping for the assets `load()` reads from disk. Each path is
173
+ * relative to `root`. `load()` registers every path that exists under its key and
174
+ * emits one `error` for each configured path that is missing.
90
175
  */
91
176
  export declare interface AssetManagerOptions {
92
177
  readonly on?: EmitterHooks<AssetManagerEventMap>;
93
178
  readonly error?: EmitterErrorHandler;
94
179
  readonly root?: string;
180
+ readonly assets?: Readonly<Record<string, string>>;
95
181
  }
96
182
 
97
- /** File extension indicating Brotli compression */
183
+ /** Names the file extension indicating Brotli compression */
98
184
  export declare const BROTLI_EXTENSION = ".br";
99
185
 
100
186
  /**
101
- * Build an ELF `PT_NOTE` entry's header bytes (namesz/descsz/type + padded
187
+ * Builds the Node.js `--experimental-sea-config` JSON object for a SEA blob.
188
+ *
189
+ * @remarks
190
+ * A pure leaf extracted from the SEA build orchestrator. The `mainFormat`
191
+ * field (`'commonjs' | 'module'`) exists only in Node >= 25.7 — for a `'cjs'`
192
+ * entry (the default) `mainFormat` is OMITTED entirely so the config still
193
+ * builds on older Node hosts where `'commonjs'` is already the implicit
194
+ * default; for an `'esm'` entry `mainFormat: 'module'` is set explicitly
195
+ * (this requires a Node >= 25.7 build host). Node also documents that
196
+ * `useSnapshot` is incompatible with an ESM entry — combining the two throws.
197
+ *
198
+ * @param entry - SEA entry point options
199
+ * @param blob - Absolute output path for the generated blob
200
+ * @param assets - Optional key→path mapping for embedded assets
201
+ * @param options - Optional blob behavior overrides (cache, snapshot)
202
+ * @returns the SEA config object, ready to be written to disk as JSON
203
+ * @throws SEAError with code `'BLOB'` when `useSnapshot` is combined with an ESM entry
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * const config = buildBlobConfig({ path: 'dist/bin/serve.cjs' }, 'dist/bin/sea-prep.blob', undefined)
208
+ * ```
209
+ */
210
+ export declare function buildBlobConfig(entry: SEAEntryOptions, blob: string, assets: Readonly<Record<string, string>> | undefined, options?: SEABlobOptions): Readonly<Record<string, unknown>>;
211
+
212
+ /**
213
+ * Builds an ELF `PT_NOTE` entry's header bytes (namesz/descsz/type + padded
102
214
  * name) for the SEA blob note, without the blob body itself.
103
215
  *
104
216
  * @remarks
@@ -117,42 +229,63 @@ export declare const BROTLI_EXTENSION = ".br";
117
229
  *
118
230
  * @example
119
231
  * ```ts
120
- * const { header, entryTotal } = buildELFNoteHeader('NODE_SEA_BLOB', 4096)
232
+ * const { header, total } = buildELFNoteHeader('NODE_SEA_BLOB', 4096)
121
233
  * ```
122
234
  */
123
- export declare function buildELFNoteHeader(resource: string, blobSize: number): {
124
- readonly header: Buffer;
125
- readonly entryTotal: number;
126
- };
235
+ export declare function buildELFNoteHeader(resource: string, blobSize: number): ELFNoteHeader;
127
236
 
128
- /** Asset key for the Brotli-compressed client HTML entry */
129
- export declare const CLIENT_ASSET_KEY_BR = "client.html.br";
130
-
131
- /** Asset key for the raw (uncompressed) client HTML entry */
132
- export declare const CLIENT_ASSET_KEY_RAW = "client.html";
237
+ /**
238
+ * Builds the `signtool sign` argv for signing a Windows executable.
239
+ *
240
+ * @remarks
241
+ * Requires EXACTLY ONE certificate source — `sign.file` (a `.pfx`/`.p12`
242
+ * file, paired with `sign.password` when present) XOR `sign.thumbprint` (a
243
+ * certificate already installed in the Windows store). When `sign.timestamp`
244
+ * is set it is parsed with the `URL` constructor and must be an `http:` or
245
+ * `https:` URL. The returned argv is passed directly to `executeShell` — never
246
+ * through a shell — so nothing in `sign` can be interpreted as a flag or
247
+ * injected into a command line. `sign.password` is NEVER included in a
248
+ * thrown error's message or `context`.
249
+ *
250
+ * @param sign - Windows signing options
251
+ * @param target - Absolute path to the executable to sign
252
+ * @returns The `signtool` argv, ready for `executeShell`
253
+ * @throws SEAError with code `'SIGN'` when neither `file` nor `thumbprint` is set
254
+ * @throws SEAError with code `'SIGN'` when both `file` and `thumbprint` are set
255
+ * @throws SEAError with code `'SIGN'` when `timestamp` is not a parseable http(s) URL
256
+ * @throws SEAError with code `'SIGN'` when `digest` is not `'sha1'`, `'sha256'`, `'sha384'`, or `'sha512'`
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * buildSignCommand({ thumbprint: 'AABBCCDDEEFF00112233445566778899AABBCCDD' }, 'dist/sea/app.exe')
261
+ * // ['signtool', 'sign', '/fd', 'sha256', '/sha1', 'AABBCCDDEEFF00112233445566778899AABBCCDD', 'dist/sea/app.exe']
262
+ * ```
263
+ */
264
+ export declare function buildSignCommand(sign: SEAWindowsSignOptions, target: string): readonly string[];
133
265
 
134
266
  /**
135
- * Compress all compressible files in a directory tree.
267
+ * Compresses all compressible files in a directory tree.
136
268
  *
137
269
  * @param directory - Absolute path to the directory
138
- * @param options - Compression options
270
+ * @param options - Brotli options (quality, mode)
139
271
  * @param progress - Optional callback invoked after each file is compressed
140
272
  * @returns Compression manifest with all results
141
273
  */
142
- export declare function compressDirectory(directory: string, options?: SEACompressionOptions, progress?: SEAProgressHandler): SEACompressionManifest;
274
+ export declare function compressDirectory(directory: string, options?: SEABrotliOptions, progress?: SEACompressionHandler): SEACompressionManifest;
143
275
 
144
276
  /**
145
- * Brotli-compress a single file, writing the output alongside it.
277
+ * Brotli-compresses a single file, writing the output alongside it.
146
278
  *
147
279
  * @param input - Absolute path to the source file
148
280
  * @param output - Absolute path for the compressed output
149
- * @param options - Compression options (quality, mode)
281
+ * @param options - Brotli options (quality, mode)
150
282
  * @returns Compression result with size comparison
283
+ * @throws SEAError with code `'OUTPUT'` when `output` is an existing symlink
151
284
  */
152
- export declare function compressFile(input: string, output: string, options?: SEACompressionOptions): SEACompressionResult;
285
+ export declare function compressFile(input: string, output: string, options?: SEABrotliOptions): SEACompressionResult;
153
286
 
154
287
  /**
155
- * Compute a size comparison between original and compressed byte counts.
288
+ * Computes a size comparison between original and compressed byte counts.
156
289
  *
157
290
  * @param original - Original byte count
158
291
  * @param compressed - Compressed byte count
@@ -161,7 +294,7 @@ export declare function compressFile(input: string, output: string, options?: SE
161
294
  export declare function computeSize(original: number, compressed: number): SEACompressionSize;
162
295
 
163
296
  /**
164
- * Copy a byte range from one open file descriptor to another, streaming in
297
+ * Copies a byte range from one open file descriptor to another, streaming in
165
298
  * fixed-size chunks instead of buffering the whole range in memory.
166
299
  *
167
300
  * @remarks
@@ -192,7 +325,7 @@ export declare function computeSize(original: number, compressed: number): SEACo
192
325
  export declare function copyRange(source: number, target: number, start: number, length: number, chunk?: number): void;
193
326
 
194
327
  /**
195
- * Create a single named asset.
328
+ * Creates a single named asset.
196
329
  *
197
330
  * @param input - Asset key, content, and optional compression flag
198
331
  * @returns a new `AssetInterface`
@@ -205,7 +338,7 @@ export declare function copyRange(source: number, target: number, start: number,
205
338
  export declare function createAsset(input: AssetInput): AssetInterface;
206
339
 
207
340
  /**
208
- * Create an asset manager for SEA-embedded or disk-loaded assets.
341
+ * Creates an asset manager for SEA-embedded or disk-loaded assets.
209
342
  *
210
343
  * @param options - Asset manager options (root, event hooks)
211
344
  * @returns a new `AssetManagerInterface`
@@ -219,33 +352,7 @@ export declare function createAsset(input: AssetInput): AssetInterface;
219
352
  export declare function createAssetManager(options?: AssetManagerOptions): AssetManagerInterface;
220
353
 
221
354
  /**
222
- * Build the Node.js `--experimental-sea-config` JSON object for a SEA blob.
223
- *
224
- * @remarks
225
- * A pure leaf extracted from the SEA build orchestrator. The `mainFormat`
226
- * field (`'commonjs' | 'module'`) exists only in Node >= 25.7 — for a `'cjs'`
227
- * entry (the default) `mainFormat` is OMITTED entirely so the config still
228
- * builds on older Node hosts where `'commonjs'` is already the implicit
229
- * default; for an `'esm'` entry `mainFormat: 'module'` is set explicitly
230
- * (this requires a Node >= 25.7 build host). Node also documents that
231
- * `useSnapshot` is incompatible with an ESM entry — combining the two throws.
232
- *
233
- * @param entry - SEA entry point options
234
- * @param blob - Absolute output path for the generated blob
235
- * @param assets - Optional key→path mapping for embedded assets
236
- * @param options - Optional blob behavior overrides (cache, snapshot)
237
- * @returns the SEA config object, ready to be written to disk as JSON
238
- * @throws SEAError with code `'BLOB'` when `useSnapshot` is combined with an ESM entry
239
- *
240
- * @example
241
- * ```ts
242
- * const config = createBlobConfig({ path: 'dist/bin/serve.cjs' }, 'dist/bin/sea-prep.blob', undefined)
243
- * ```
244
- */
245
- export declare function createBlobConfig(entry: SEAEntryOptions, blob: string, assets: Readonly<Record<string, string>> | undefined, options?: SEABlobOptions): Readonly<Record<string, unknown>>;
246
-
247
- /**
248
- * Create a cross-platform binary resource injector.
355
+ * Creates a cross-platform binary resource injector.
249
356
  *
250
357
  * Detects the executable format (PE, ELF, Mach-O) from the file header
251
358
  * and injects the blob using pure TypeScript file I/O — no WASM, no
@@ -268,74 +375,93 @@ export declare function createBlobConfig(entry: SEAEntryOptions, blob: string, a
268
375
  export declare function createInjector(options: InjectorOptions): InjectorInterface;
269
376
 
270
377
  /**
271
- * Create a new SEA build orchestrator.
378
+ * Creates a new SEA build orchestrator.
272
379
  *
273
380
  * @param options - SEA build options
274
381
  * @returns a new `SEAInterface`
275
382
  *
276
383
  * @example
277
384
  * ```ts
278
- * const seal = createSEA({
385
+ * const sea = createSEA({
279
386
  * name: 'orkestrel',
280
387
  * entry: { path: 'dist/bin/serve.cjs' },
281
388
  * output: 'dist/sea',
282
389
  * assets: { 'index.html.br': 'dist/client/index.html.br' },
283
390
  * compression: { paths: ['dist/client'] },
284
391
  * })
285
- * const result = await seal.execute()
392
+ * const result = await sea.execute()
286
393
  * ```
287
394
  */
288
395
  export declare function createSEA(options: SEAOptions): SEAInterface;
289
396
 
290
- /**
291
- * Build the `signtool sign` argv for signing a Windows executable.
292
- *
293
- * @remarks
294
- * Requires EXACTLY ONE certificate source — `sign.file` (a `.pfx`/`.p12`
295
- * file, paired with `sign.password` when present) XOR `sign.thumbprint` (a
296
- * certificate already installed in the Windows store). When `sign.timestamp`
297
- * is set it is parsed with the `URL` constructor and must be an `http:` or
298
- * `https:` URL. The returned argv is passed directly to `runShell` — never
299
- * through a shell — so nothing in `sign` can be interpreted as a flag or
300
- * injected into a command line. `sign.password` is NEVER included in a
301
- * thrown error's message or `context`.
302
- *
303
- * @param sign - Windows signing options
304
- * @param target - Absolute path to the executable to sign
305
- * @returns The `signtool` argv, ready for `runShell`
306
- * @throws SEAError with code `'SIGN'` when neither `file` nor `thumbprint` is set
307
- * @throws SEAError with code `'SIGN'` when both `file` and `thumbprint` are set
308
- * @throws SEAError with code `'SIGN'` when `timestamp` is not a parseable http(s) URL
309
- * @throws SEAError with code `'SIGN'` when `digest` is not `'sha1'`, `'sha256'`, `'sha384'`, or `'sha512'`
310
- *
311
- * @example
312
- * ```ts
313
- * createSignCommand({ thumbprint: 'AABBCCDDEEFF00112233445566778899AABBCCDD' }, 'dist/sea/app.exe')
314
- * // ['signtool', 'sign', '/fd', 'sha256', '/sha1', 'AABBCCDDEEFF00112233445566778899AABBCCDD', 'dist/sea/app.exe']
315
- * ```
316
- */
317
- export declare function createSignCommand(sign: SEAWindowsSignOptions, target: string): string[];
318
-
319
- /** Default SEA entry point module format when none is specified */
397
+ /** Names the default SEA entry point module format when none is specified */
320
398
  export declare const DEFAULT_ENTRY_FORMAT: SEAEntryFormat;
321
399
 
322
- /** Default Brotli compression quality level (maximum) */
400
+ /** Holds the default Brotli compression quality level (maximum) */
323
401
  export declare const DEFAULT_SEA_COMPRESSION_QUALITY = 11;
324
402
 
325
- /** ELF 64-bit class identifier */
403
+ /** Holds the ELF 64-bit class identifier */
326
404
  export declare const ELF_CLASS_64 = 2;
327
405
 
328
- /** ELF little-endian data encoding */
406
+ /** Holds the ELF little-endian data encoding */
329
407
  export declare const ELF_DATA_LSB = 1;
330
408
 
331
- /** ELF magic: 0x7F 'E' 'L' 'F' as a 32-bit big-endian value */
409
+ /** Holds the ELF magic, 0x7F 'E' 'L' 'F' as a 32-bit big-endian value */
332
410
  export declare const ELF_MAGIC = 2135247942;
333
411
 
334
- /** ELF program header type: note segment */
412
+ /** Holds the page size an injected ELF segment is aligned to */
413
+ export declare const ELF_PAGE_SIZE = 4096;
414
+
415
+ /** Holds the ELF segment permission flag marking a segment readable */
416
+ export declare const ELF_PF_R = 4;
417
+
418
+ /** Holds the ELF program header type for a loadable segment */
419
+ export declare const ELF_PT_LOAD = 1;
420
+
421
+ /** Holds the ELF program header type for a note segment */
335
422
  export declare const ELF_PT_NOTE = 4;
336
423
 
424
+ /** Holds the ELF program header type for the program header table itself */
425
+ export declare const ELF_PT_PHDR = 6;
426
+
427
+ /**
428
+ * Holds an ELF `PT_NOTE` entry's header bytes and the on-disk size of the whole entry.
429
+ *
430
+ * @remarks
431
+ * `header` — the namesz/descsz/type words followed by the NUL-terminated,
432
+ * four-byte-padded note name.
433
+ * `total` — bytes the complete entry occupies on disk: `header` plus the
434
+ * four-byte-padded blob written after it.
435
+ */
436
+ export declare interface ELFNoteHeader {
437
+ readonly header: Buffer;
438
+ readonly total: number;
439
+ }
440
+
441
+ /**
442
+ * Holds one ELF64 program header entry.
443
+ *
444
+ * @remarks
445
+ * Transliterates the `Elf64_Phdr` structure of the ELF64 specification field for
446
+ * field, with the `p_` prefix dropped: `type` is `p_type`, `flags` is `p_flags`,
447
+ * `offset` is `p_offset`, `vaddr` is `p_vaddr`, `paddr` is `p_paddr`, `filesz` is
448
+ * `p_filesz`, `memsz` is `p_memsz`, and `align` is `p_align`. Every 64-bit field is
449
+ * carried as a `number` because an executable's offsets stay far inside the safe
450
+ * integer range.
451
+ */
452
+ export declare interface ELFProgramHeader {
453
+ readonly type: number;
454
+ readonly flags: number;
455
+ readonly offset: number;
456
+ readonly vaddr: number;
457
+ readonly paddr: number;
458
+ readonly filesz: number;
459
+ readonly memsz: number;
460
+ readonly align: number;
461
+ }
462
+
337
463
  /**
338
- * Assert that `path` (resolved against `base`) real-path-resolves to a
464
+ * Asserts that `path` (resolved against `base`) real-path-resolves to a
339
465
  * location inside `base`, defeating a symlink escape.
340
466
  *
341
467
  * @remarks
@@ -363,16 +489,17 @@ export declare const ELF_PT_NOTE = 4;
363
489
  export declare function ensureContained(base: string, path: string): string;
364
490
 
365
491
  /**
366
- * Assert that a path exists, throwing a coded {@link SEAError} if not.
492
+ * Asserts that a path exists, throwing a coded {@link SEAError} if not.
367
493
  *
368
494
  * @param path - Absolute or relative path to check
369
495
  * @param message - Error message when path is missing
370
496
  * @param code - Error code to throw with. Default: `'STATE'`.
497
+ * @throws SEAError with `code` (default `'STATE'`) when `path` does not exist
371
498
  */
372
499
  export declare function ensureExists(path: string, message: string, code?: SEAErrorCode): void;
373
500
 
374
501
  /**
375
- * Assert that an asset key is safe to use as a relative filesystem/archive key.
502
+ * Asserts that an asset key is safe to use as a relative filesystem/archive key.
376
503
  *
377
504
  * @remarks
378
505
  * Rejects an empty key, an absolute path, a key containing a backslash, a
@@ -392,7 +519,7 @@ export declare function ensureExists(path: string, message: string, code?: SEAEr
392
519
  export declare function ensureSafeKey(key: string): void;
393
520
 
394
521
  /**
395
- * Assert that `name` is a single safe path segment suitable as an output
522
+ * Asserts that `name` is a single safe path segment suitable as an output
396
523
  * executable base name.
397
524
  *
398
525
  * @remarks
@@ -413,12 +540,25 @@ export declare function ensureSafeKey(key: string): void;
413
540
  export declare function ensureSafeName(name: string): void;
414
541
 
415
542
  /**
416
- * Executable binary format detected from file header magic bytes.
543
+ * Names an executable binary format detected from file header magic bytes.
417
544
  */
418
545
  export declare type ExecutableFormat = 'pe' | 'elf' | 'macho';
419
546
 
420
547
  /**
421
- * Finalize a built executable by durably flushing it to disk and atomically
548
+ * Executes a command synchronously and returns stdout.
549
+ *
550
+ * @param command - Command to execute (first element is the binary)
551
+ * @param options - Shell options (cwd, env, timeout, signal)
552
+ * @returns stdout as a Buffer
553
+ * @throws SEAError with code `'STATE'` when `command` is empty
554
+ * @throws SEAError with code `'ABORT'` when `options.signal` is already aborted
555
+ * @throws SEAError with code `'TIMEOUT'` when the command exceeds `options.timeout`
556
+ * @throws ShellError when the command exits with non-zero status
557
+ */
558
+ export declare function executeShell(command: readonly string[], options?: SEAShellOptions): Buffer;
559
+
560
+ /**
561
+ * Finalizes a built executable by durably flushing it to disk and atomically
422
562
  * moving it into place.
423
563
  *
424
564
  * @remarks
@@ -440,13 +580,39 @@ export declare type ExecutableFormat = 'pe' | 'elf' | 'macho';
440
580
  export declare function finalizeExecutable(source: string, target: string): void;
441
581
 
442
582
  /**
443
- * Format a byte count as a human-readable string.
583
+ * Formats a byte count as a human-readable string.
444
584
  *
445
585
  * @param bytes - Byte count
446
586
  * @returns Formatted string (e.g. `"1.23 MB"`, `"456 KB"`)
447
587
  */
448
588
  export declare function formatSize(bytes: number): string;
449
589
 
590
+ /**
591
+ * Writes a named resource into a PE, ELF, or Mach-O executable in place.
592
+ *
593
+ * @remarks
594
+ * The format is detected from the file's magic bytes at construction, and each
595
+ * format takes its own strategy: PE adds an `RT_RCDATA` resource by rebuilding the
596
+ * resource directory, ELF appends a `PT_NOTE` segment carrying the blob as note
597
+ * data, and Mach-O appends an `LC_SEGMENT_64` load command with one section. The
598
+ * blob is streamed from disk in every case, so its size is bounded by the
599
+ * filesystem rather than by memory.
600
+ *
601
+ * @param options - Injector options: the target executable, the resource name, the
602
+ * blob path, and the optional sentinel fuse and Mach-O segment
603
+ *
604
+ * @example
605
+ * ```ts
606
+ * const injector = new Injector({
607
+ * executable: 'dist/sea/myapp.exe',
608
+ * resource: 'NODE_SEA_BLOB',
609
+ * blob: 'dist/sea/sea-prep.blob',
610
+ * fuse: 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2',
611
+ * })
612
+ * injector.format // 'pe' | 'elf' | 'macho'
613
+ * injector.inject()
614
+ * ```
615
+ */
450
616
  export declare class Injector implements InjectorInterface {
451
617
  #private;
452
618
  constructor(options: InjectorOptions);
@@ -455,21 +621,21 @@ export declare class Injector implements InjectorInterface {
455
621
  }
456
622
 
457
623
  /**
458
- * Cross-platform binary resource injector.
624
+ * Represents a cross-platform binary resource injector.
459
625
  *
460
626
  * @remarks
461
627
  * Injects arbitrary data into PE (Windows), ELF (Linux), and Mach-O (macOS)
462
628
  * executables using streaming file I/O. No WASM or external tools required.
463
629
  */
464
630
  export declare interface InjectorInterface {
465
- /** Detected executable format of the target binary. */
631
+ /** Holds the detected executable format of the target binary. */
466
632
  readonly format: ExecutableFormat;
467
- /** Inject the resource data into the executable. */
633
+ /** Injects the resource data into the executable. */
468
634
  inject(): void;
469
635
  }
470
636
 
471
637
  /**
472
- * Mach-O specific injector options.
638
+ * Configures Mach-O specific injector behavior.
473
639
  *
474
640
  * @remarks
475
641
  * `segment` — Mach-O segment name. Default: `"NODE_SEA"`.
@@ -479,7 +645,7 @@ export declare interface InjectorMachOOptions {
479
645
  }
480
646
 
481
647
  /**
482
- * Options for injecting a resource into an executable.
648
+ * Configures the injection of a resource into an executable.
483
649
  *
484
650
  * @remarks
485
651
  * `executable` — absolute path to the target executable.
@@ -499,50 +665,57 @@ export declare interface InjectorOptions {
499
665
  }
500
666
 
501
667
  /**
502
- * Check if a file should be Brotli-compressed based on its extension.
668
+ * Checks whether a file's extension is outside `SKIP_EXTENSIONS`, so Brotli
669
+ * compression applies to it.
503
670
  *
504
671
  * @param path - Path to the file
505
- * @returns True when the file type benefits from compression
672
+ * @returns True if the file type benefits from compression; false otherwise
506
673
  */
507
674
  export declare function isCompressible(path: string): boolean;
508
675
 
509
676
  /**
510
- * Check if a value is a valid {@link ExecutableFormat}.
677
+ * Checks if a value is a valid {@link ExecutableFormat}.
511
678
  *
512
679
  * @param value - Value to check
513
- * @returns True when value is `'pe'`, `'elf'`, or `'macho'`
680
+ * @returns True if value is `'pe'`, `'elf'`, or `'macho'`; false otherwise
681
+ *
682
+ * @example
683
+ * ```ts
684
+ * isExecutableFormat('elf') // true
685
+ * isExecutableFormat('coff') // false
686
+ * ```
514
687
  */
515
688
  export declare function isExecutableFormat(value: unknown): value is ExecutableFormat;
516
689
 
517
690
  /**
518
- * Check if a file is a Windows PE executable.
691
+ * Checks if a file is a Windows PE executable.
519
692
  *
520
693
  * @param path - Path to the file
521
- * @returns True when the file has a valid PE signature
694
+ * @returns True if the file has a valid PE signature; false otherwise
522
695
  */
523
696
  export declare function isPEExecutable(path: string): boolean;
524
697
 
525
698
  /**
526
- * Check if the current or specified platform is supported for SEA builds.
699
+ * Checks if the current or specified platform is supported for SEA builds.
527
700
  *
528
701
  * @param platform - Platform identifier to check
529
- * @returns True when the platform has a known configuration
702
+ * @returns True if the platform has a known configuration; false otherwise
530
703
  */
531
704
  export declare function isPlatformSupported(platform?: string): boolean;
532
705
 
533
706
  /**
534
- * Check whether a number is a nonzero power of two.
707
+ * Checks whether a number is a nonzero power of two.
535
708
  *
536
709
  * @param value - Number to check
537
- * @returns True when the value is a positive power of two
710
+ * @returns True if the value is a positive power of two; false otherwise
538
711
  */
539
712
  export declare function isPowerOfTwo(value: number): boolean;
540
713
 
541
714
  /**
542
- * Whether a value is a {@link SEAError}.
715
+ * Checks whether a value is a {@link SEAError}.
543
716
  *
544
717
  * @param value - The value to test
545
- * @returns `true` when `value` is a `SEAError`
718
+ * @returns True if `value` is a `SEAError`; false otherwise
546
719
  *
547
720
  * @example
548
721
  * ```ts
@@ -554,10 +727,10 @@ export declare function isPowerOfTwo(value: number): boolean;
554
727
  export declare function isSEAError(value: unknown): value is SEAError;
555
728
 
556
729
  /**
557
- * Whether a value is a {@link ShellError}.
730
+ * Checks whether a value is a {@link ShellError}.
558
731
  *
559
732
  * @param value - The value to test
560
- * @returns `true` when `value` is a `ShellError`
733
+ * @returns True if `value` is a `ShellError`; false otherwise
561
734
  *
562
735
  * @example
563
736
  * ```ts
@@ -568,14 +741,14 @@ export declare function isSEAError(value: unknown): value is SEAError;
568
741
  */
569
742
  export declare function isShellError(value: unknown): value is ShellError;
570
743
 
571
- /** Mach-O LC_SEGMENT_64 load command */
744
+ /** Holds the Mach-O LC_SEGMENT_64 load command */
572
745
  export declare const MACHO_LC_SEGMENT_64 = 25;
573
746
 
574
- /** Mach-O 64-bit magic (little-endian) */
747
+ /** Holds the Mach-O 64-bit magic (little-endian) */
575
748
  export declare const MACHO_MAGIC_64 = 4277009103;
576
749
 
577
750
  /**
578
- * Launch the system default browser at an http(s) URL.
751
+ * Launches the system default browser at an http(s) URL.
579
752
  *
580
753
  * @remarks
581
754
  * A best-effort launch for bundled local-UI apps: dispatches by
@@ -602,15 +775,7 @@ export declare const MACHO_MAGIC_64 = 4277009103;
602
775
  export declare function openBrowser(url: string): void;
603
776
 
604
777
  /**
605
- * Parse the PE header offset from a Windows executable.
606
- *
607
- * @param fd - Open file descriptor
608
- * @returns The offset to the PE signature
609
- */
610
- export declare function parsePEOffset(fd: number): number;
611
-
612
- /**
613
- * Patch the PE subsystem field in a Windows executable.
778
+ * Patches the PE subsystem field in a Windows executable.
614
779
  *
615
780
  * @param path - Path to the executable
616
781
  * @param subsystem - Numeric subsystem value (2 = GUI, 3 = Console)
@@ -618,7 +783,7 @@ export declare function parsePEOffset(fd: number): number;
618
783
  export declare function patchPESubsystem(path: string, subsystem: number): void;
619
784
 
620
785
  /**
621
- * Patch the sentinel fuse in a binary from `:0` to `:1`.
786
+ * Patches the sentinel fuse in a binary from `:0` to `:1`.
622
787
  *
623
788
  * Searches the file in 64 MB chunks with overlap to handle any file size.
624
789
  * The fuse signals to the Node.js runtime that a SEA blob is present.
@@ -627,67 +792,163 @@ export declare function patchPESubsystem(path: string, subsystem: number): void;
627
792
  *
628
793
  * @param executable - Absolute path to the executable
629
794
  * @param fuse - Sentinel fuse string (without the `:0` suffix)
795
+ * @throws SEAError with code `'FUSE'` when the fuse value cannot be read
796
+ * @throws SEAError with code `'FUSE'` when the fuse carries a value other than `:0` or `:1`
797
+ * @throws SEAError with code `'FUSE'` when the fuse is not found in the executable
630
798
  */
631
799
  export declare function patchSentinelFuse(executable: string, fuse: string): void;
632
800
 
633
- /** PE32 optional header magic */
801
+ /** Holds the PE32 optional header magic */
634
802
  export declare const PE32_MAGIC = 267;
635
803
 
636
- /** PE32+ (64-bit) optional header magic */
804
+ /** Holds the PE32+ (64-bit) optional header magic */
637
805
  export declare const PE32_PLUS_MAGIC = 523;
638
806
 
639
- /** DOS MZ header magic (first 2 bytes of a PE file) */
807
+ /** Holds the DOS MZ header magic (first 2 bytes of a PE file) */
640
808
  export declare const PE_MAGIC = 23117;
641
809
 
642
- /** Size of IMAGE_RESOURCE_DATA_ENTRY in bytes */
810
+ /** Holds the size of IMAGE_RESOURCE_DATA_ENTRY in bytes */
643
811
  export declare const PE_RESOURCE_DATA_ENTRY_SIZE = 16;
644
812
 
645
- /** Size of IMAGE_RESOURCE_DIRECTORY in bytes */
813
+ /** Holds the size of IMAGE_RESOURCE_DIRECTORY in bytes */
646
814
  export declare const PE_RESOURCE_DIR_SIZE = 16;
647
815
 
648
- /** Size of IMAGE_RESOURCE_DIRECTORY_ENTRY in bytes */
816
+ /** Holds the size of IMAGE_RESOURCE_DIRECTORY_ENTRY in bytes */
649
817
  export declare const PE_RESOURCE_ENTRY_SIZE = 8;
650
818
 
651
- /** High bit mask for resource name entry (indicates named vs integer ID) */
819
+ /** Holds the high bit mask for a resource name entry (indicates named vs integer ID) */
652
820
  export declare const PE_RESOURCE_NAME_FLAG = 2147483648;
653
821
 
654
- /** High bit mask for resource directory entry offset (indicates subdirectory) */
822
+ /** Holds the high bit mask for a resource directory entry offset (indicates subdirectory) */
655
823
  export declare const PE_RESOURCE_SUBDIR_FLAG = 2147483648;
656
824
 
657
- /** PE resource type: RT_RCDATA (raw data) */
825
+ /** Holds the PE resource type RT_RCDATA (raw data) */
658
826
  export declare const PE_RT_RCDATA = 10;
659
827
 
660
- /** Section contains initialized data */
828
+ /** Marks a section as containing initialized data */
661
829
  export declare const PE_SCN_INITIALIZED_DATA = 64;
662
830
 
663
- /** Section is readable */
831
+ /** Marks a section as readable */
664
832
  export declare const PE_SCN_MEM_READ = 1073741824;
665
833
 
666
- /** PE section header size in bytes */
834
+ /** Holds the PE section header size in bytes */
667
835
  export declare const PE_SECTION_HEADER_SIZE = 40;
668
836
 
669
- /** PE signature: "PE\0\0" as a 32-bit value */
837
+ /** Holds the PE signature, "PE\0\0" as a 32-bit value */
670
838
  export declare const PE_SIGNATURE = 17744;
671
839
 
672
840
  /**
673
- * Get the platform configuration for the current OS.
841
+ * Holds one language entry of a PE resource name directory.
674
842
  *
675
- * @param platform - Platform identifier. Default: `process.platform`.
676
- * @returns Platform configuration, or undefined if unsupported
843
+ * @remarks
844
+ * `leafIndex` addresses the {@link PEResourceLeaf} this entry's bytes come from,
845
+ * within the leaf list the injector gathered from the original executable. A
846
+ * `leafIndex` of `-1` marks the entry the injector is adding, whose bytes are
847
+ * streamed from the blob file rather than copied from an existing leaf.
848
+ */
849
+ export declare interface PEResourceEntry {
850
+ readonly language: number;
851
+ readonly codePage: number;
852
+ readonly leafIndex: number;
853
+ readonly dataSize: number;
854
+ }
855
+
856
+ /**
857
+ * Holds one leaf of a PE resource directory tree.
858
+ *
859
+ * @remarks
860
+ * Flattens the path a resource takes through the three directory levels of the PE
861
+ * `IMAGE_RESOURCE_DIRECTORY` tree — type, name, language — onto the
862
+ * `IMAGE_RESOURCE_DATA_ENTRY` it ends at. A level identifies its entry either by
863
+ * integer id or by name, so `typeId` and `nameId` carry the integer form and
864
+ * `typeName` and `nameName` the named form, whichever the entry used. `dataRVA` and
865
+ * `dataSize` are the data entry's `OffsetToData` and `Size` fields.
866
+ */
867
+ export declare interface PEResourceLeaf {
868
+ readonly typeId: number;
869
+ readonly typeName: string | undefined;
870
+ readonly nameId: number;
871
+ readonly nameName: string | undefined;
872
+ readonly language: number;
873
+ readonly codePage: number;
874
+ readonly dataRVA: number;
875
+ readonly dataSize: number;
876
+ }
877
+
878
+ /**
879
+ * Holds one PE section table entry.
880
+ *
881
+ * @remarks
882
+ * Transliterates the PE `IMAGE_SECTION_HEADER` structure: `name` is `Name` with its
883
+ * NUL padding stripped, `virtualSize` is `Misc.VirtualSize`, `virtualAddress` is
884
+ * `VirtualAddress`, `rawSize` is `SizeOfRawData`, `rawOffset` is
885
+ * `PointerToRawData`, and `characteristics` is `Characteristics`. `headerOffset` is
886
+ * not a header field: it records the file offset the entry was read from, so a
887
+ * later write lands on the same bytes.
888
+ */
889
+ export declare interface PESection {
890
+ readonly name: string;
891
+ readonly virtualSize: number;
892
+ readonly virtualAddress: number;
893
+ readonly rawSize: number;
894
+ readonly rawOffset: number;
895
+ readonly characteristics: number;
896
+ readonly headerOffset: number;
897
+ }
898
+
899
+ /**
900
+ * Reads the PE header offset from a Windows executable.
901
+ *
902
+ * @param fd - Open file descriptor
903
+ * @returns The offset to the PE signature
904
+ * @throws SEAError with code `'FORMAT'` when fewer than four bytes are readable at `0x3c`
677
905
  */
678
- export declare function platformConfig(platform?: string): SEAPlatform | undefined;
906
+ export declare function readPEOffset(fd: number): number;
679
907
 
680
908
  /**
681
- * Read a 16-bit unsigned integer from a file descriptor.
909
+ * Reads a 16-bit unsigned integer from a file descriptor.
682
910
  *
683
911
  * @param fd - Open file descriptor
684
912
  * @param offset - Byte offset to read from
685
913
  * @returns The 16-bit value
914
+ * @throws SEAError with code `'FORMAT'` when fewer than two bytes are readable at `offset`
686
915
  */
687
916
  export declare function readU16(fd: number, offset: number): number;
688
917
 
689
918
  /**
690
- * Redact password arguments from a shell command.
919
+ * Reads a 32-bit unsigned little-endian integer from a file descriptor.
920
+ *
921
+ * @param fd - Open file descriptor
922
+ * @param offset - Byte offset to read from
923
+ * @returns The 32-bit value
924
+ * @throws SEAError with code `'FORMAT'` when fewer than four bytes are readable at `offset`
925
+ *
926
+ * @example
927
+ * ```ts
928
+ * const fd = openSync('app.exe', 'r')
929
+ * readU32(fd, 0x3c) // the PE header offset
930
+ * ```
931
+ */
932
+ export declare function readU32(fd: number, offset: number): number;
933
+
934
+ /**
935
+ * Reads a 64-bit unsigned little-endian integer from a file descriptor.
936
+ *
937
+ * @param fd - Open file descriptor
938
+ * @param offset - Byte offset to read from
939
+ * @returns The 64-bit value, as a `bigint`
940
+ * @throws SEAError with code `'FORMAT'` when fewer than eight bytes are readable at `offset`
941
+ *
942
+ * @example
943
+ * ```ts
944
+ * const fd = openSync('app', 'r')
945
+ * readU64(fd, 32) // the ELF program header table offset
946
+ * ```
947
+ */
948
+ export declare function readU64(fd: number, offset: number): bigint;
949
+
950
+ /**
951
+ * Redacts password arguments from a shell command.
691
952
  *
692
953
  * @param command - Command arguments to redact
693
954
  * @returns A copy with values following password flags replaced by a marker
@@ -695,18 +956,37 @@ export declare function readU16(fd: number, offset: number): number;
695
956
  export declare function redactCommand(command: readonly string[]): readonly string[];
696
957
 
697
958
  /**
698
- * Run a command synchronously and return stdout.
959
+ * Resolves the effective platform configuration.
699
960
  *
700
- * @param command - Command to execute (first element is the binary)
701
- * @param options - Shell options (cwd, env, timeout, signal)
702
- * @returns stdout as a Buffer
703
- * @throws SEAError with code `'STATE'` when `command` is empty
704
- * @throws SEAError with code `'ABORT'` when `options.signal` is already aborted
705
- * @throws SEAError with code `'TIMEOUT'` when the command exceeds `options.timeout`
706
- * @throws ShellError when the command exits with non-zero status
961
+ * @param platform - Platform identifier. Default: `process.platform`.
962
+ * @returns Platform configuration, or undefined if unsupported
707
963
  */
708
- export declare function runShell(command: string[], options?: SEAShellOptions): Buffer;
964
+ export declare function resolvePlatform(platform?: string): SEAPlatform | undefined;
709
965
 
966
+ /**
967
+ * Runs a Node.js single executable application build to completion.
968
+ *
969
+ * @remarks
970
+ * `execute` compresses the configured directories, generates the SEA blob, copies
971
+ * the host Node binary, injects the blob with an {@link Injector}, signs the
972
+ * result where the platform supports it, and moves the finished executable into
973
+ * place atomically. Each stage reports on `emitter`, and every failure throws a
974
+ * coded `SEAError` after an `error` event carrying it.
975
+ *
976
+ * @param options - SEA build options: the output name, the entry point, the output
977
+ * directory, and the optional assets, compression, Windows, and blob settings
978
+ *
979
+ * @example
980
+ * ```ts
981
+ * const sea = new SEA({
982
+ * name: 'myapp',
983
+ * entry: { path: 'dist/server/serve.cjs' },
984
+ * output: 'dist/sea',
985
+ * })
986
+ * const result = await sea.execute()
987
+ * sea.destroy()
988
+ * ```
989
+ */
710
990
  export declare class SEA implements SEAInterface {
711
991
  #private;
712
992
  constructor(options: SEAOptions);
@@ -716,20 +996,20 @@ export declare class SEA implements SEAInterface {
716
996
  destroy(): void;
717
997
  }
718
998
 
719
- /** Resource name for the SEA blob in the executable */
999
+ /** Names the SEA blob resource in the executable */
720
1000
  export declare const SEA_BLOB_RESOURCE = "NODE_SEA_BLOB";
721
1001
 
722
1002
  /** Maps a {@link SEACompressionMode} to its numeric Brotli mode value */
723
1003
  export declare const SEA_COMPRESSION_MODE_VALUES: Readonly<Record<SEACompressionMode, number>>;
724
1004
 
725
- /** Platform-specific SEA build configurations */
1005
+ /** Holds the platform-specific SEA build configurations */
726
1006
  export declare const SEA_PLATFORMS: Readonly<Record<string, SEAPlatform>>;
727
1007
 
728
- /** SEA sentinel fuse value embedded in the Node.js binary */
1008
+ /** Holds the SEA sentinel fuse value embedded in the Node.js binary */
729
1009
  export declare const SEA_SENTINEL_FUSE = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
730
1010
 
731
1011
  /**
732
- * Options controlling generated SEA blob behavior.
1012
+ * Controls generated SEA blob behavior.
733
1013
  *
734
1014
  * @remarks
735
1015
  * `cache` — maps to the SEA config `useCodeCache`. Default: `true`.
@@ -741,7 +1021,24 @@ export declare interface SEABlobOptions {
741
1021
  }
742
1022
 
743
1023
  /**
744
- * Manifest summarizing all compressed assets.
1024
+ * Controls how Brotli encodes one file.
1025
+ *
1026
+ * @remarks
1027
+ * `mode` — Brotli mode. Default: `'generic'`.
1028
+ * `quality` — Brotli quality level (0–11). Default: 11.
1029
+ */
1030
+ export declare interface SEABrotliOptions {
1031
+ readonly mode?: SEACompressionMode;
1032
+ readonly quality?: number;
1033
+ }
1034
+
1035
+ /**
1036
+ * Describes the callback `compressDirectory` invokes after each file it compresses.
1037
+ */
1038
+ export declare type SEACompressionHandler = (result: SEACompressionResult) => void;
1039
+
1040
+ /**
1041
+ * Summarizes all compressed assets.
745
1042
  *
746
1043
  * @remarks
747
1044
  * Generated after a full directory compression pass.
@@ -752,7 +1049,7 @@ export declare interface SEACompressionManifest {
752
1049
  }
753
1050
 
754
1051
  /**
755
- * Brotli compression mode.
1052
+ * Names a Brotli compression mode.
756
1053
  *
757
1054
  * @remarks
758
1055
  * `generic` — general-purpose data (Brotli mode 0).
@@ -762,21 +1059,17 @@ export declare interface SEACompressionManifest {
762
1059
  export declare type SEACompressionMode = 'generic' | 'text' | 'font';
763
1060
 
764
1061
  /**
765
- * Options controlling Brotli compression of one or more directories.
1062
+ * Controls Brotli compression of one or more directories.
766
1063
  *
767
1064
  * @remarks
768
- * `paths` — directories (relative to `SEAOptions.root`) to compress.
769
- * `mode` — Brotli mode. Default: `'generic'`.
770
- * `quality` — Brotli quality level (0–11). Default: 11.
1065
+ * `paths` — directories (relative to `SEAOptions.root`) to compress.
771
1066
  */
772
- export declare interface SEACompressionOptions {
1067
+ export declare interface SEACompressionOptions extends SEABrotliOptions {
773
1068
  readonly paths: readonly string[];
774
- readonly mode?: SEACompressionMode;
775
- readonly quality?: number;
776
1069
  }
777
1070
 
778
1071
  /**
779
- * Result of compressing a single file.
1072
+ * Represents the result of compressing a single file.
780
1073
  *
781
1074
  * @remarks
782
1075
  * `input` — absolute path to the original file.
@@ -790,7 +1083,7 @@ export declare interface SEACompressionResult {
790
1083
  }
791
1084
 
792
1085
  /**
793
- * Size comparison between original and compressed data.
1086
+ * Represents a size comparison between original and compressed data.
794
1087
  */
795
1088
  export declare interface SEACompressionSize {
796
1089
  readonly original: number;
@@ -799,7 +1092,7 @@ export declare interface SEACompressionSize {
799
1092
  }
800
1093
 
801
1094
  /**
802
- * SEA entry point module format.
1095
+ * Names the SEA entry point module format.
803
1096
  *
804
1097
  * @remarks
805
1098
  * `cjs` — CommonJS entry (Node default).
@@ -808,7 +1101,7 @@ export declare interface SEACompressionSize {
808
1101
  export declare type SEAEntryFormat = 'cjs' | 'esm';
809
1102
 
810
1103
  /**
811
- * Options describing the SEA entry point.
1104
+ * Describes the SEA entry point.
812
1105
  *
813
1106
  * @remarks
814
1107
  * `path` — path to the entry point to embed.
@@ -820,7 +1113,7 @@ export declare interface SEAEntryOptions {
820
1113
  }
821
1114
 
822
1115
  /**
823
- * The coded base error for every failure raised by the seal build.
1116
+ * Represents the coded base error for every failure raised by the SEA build.
824
1117
  *
825
1118
  * @remarks
826
1119
  * Carries a machine-readable {@link SEAErrorCode} and optional `context`
@@ -829,7 +1122,7 @@ export declare interface SEAEntryOptions {
829
1122
  * @example
830
1123
  * ```ts
831
1124
  * try {
832
- * seal.execute()
1125
+ * sea.execute()
833
1126
  * } catch (error) {
834
1127
  * if (isSEAError(error)) {
835
1128
  * console.error(error.code, error.context)
@@ -844,7 +1137,7 @@ export declare class SEAError extends Error {
844
1137
  }
845
1138
 
846
1139
  /**
847
- * Machine-readable error code carried by every {@link SEAError}.
1140
+ * Names the machine-readable error code carried by every {@link SEAError}.
848
1141
  *
849
1142
  * @remarks
850
1143
  * `PLATFORM` — unsupported or misdetected platform.
@@ -853,6 +1146,8 @@ export declare class SEAError extends Error {
853
1146
  * `BLOB` — SEA blob generation failure.
854
1147
  * `FORMAT` — unrecognized executable binary format.
855
1148
  * `INJECT` — resource injection failure.
1149
+ * `ROOM` — host binary layout the injector cannot write into: no room for a new
1150
+ * section entry or load command, or a `__LINKEDIT` layout it does not support.
856
1151
  * `FUSE` — sentinel fuse patch failure.
857
1152
  * `SIGN` — code signing failure.
858
1153
  * `SHELL` — shell command exited non-zero.
@@ -862,9 +1157,9 @@ export declare class SEAError extends Error {
862
1157
  * `STATE` — invalid internal state or argument.
863
1158
  * `BROWSER` — invalid or unsupported URL passed to `openBrowser`.
864
1159
  */
865
- export declare type SEAErrorCode = 'PLATFORM' | 'ENTRY' | 'ASSET' | 'BLOB' | 'FORMAT' | 'INJECT' | 'FUSE' | 'SIGN' | 'SHELL' | 'TIMEOUT' | 'ABORT' | 'OUTPUT' | 'STATE' | 'BROWSER';
1160
+ export declare type SEAErrorCode = 'PLATFORM' | 'ENTRY' | 'ASSET' | 'BLOB' | 'FORMAT' | 'INJECT' | 'ROOM' | 'FUSE' | 'SIGN' | 'SHELL' | 'TIMEOUT' | 'ABORT' | 'OUTPUT' | 'STATE' | 'BROWSER';
866
1161
 
867
- /** Events emitted by a {@link SEAInterface}. */
1162
+ /** Lists the events emitted by a {@link SEAInterface}. */
868
1163
  export declare type SEAEventMap = {
869
1164
  readonly compress: readonly [compression: SEACompressionManifest | undefined];
870
1165
  readonly progress: readonly [progress: SEAProgress];
@@ -875,7 +1170,7 @@ export declare type SEAEventMap = {
875
1170
  };
876
1171
 
877
1172
  /**
878
- * SEA build orchestrator.
1173
+ * Represents a SEA build orchestrator.
879
1174
  *
880
1175
  * @remarks
881
1176
  * Compresses assets, generates the SEA blob, copies the Node binary,
@@ -889,7 +1184,7 @@ export declare interface SEAInterface {
889
1184
  }
890
1185
 
891
1186
  /**
892
- * Options for creating a SEA build.
1187
+ * Configures the creation of a SEA build.
893
1188
  *
894
1189
  * @remarks
895
1190
  * `name` — output executable name (no extension).
@@ -921,7 +1216,7 @@ export declare interface SEAOptions {
921
1216
  }
922
1217
 
923
1218
  /**
924
- * Platform-specific SEA build configuration.
1219
+ * Represents a platform-specific SEA build configuration.
925
1220
  *
926
1221
  * @remarks
927
1222
  * Describes the native Node binary and code signing commands.
@@ -934,7 +1229,7 @@ export declare interface SEAPlatform {
934
1229
  }
935
1230
 
936
1231
  /**
937
- * Progress reported while compressing a directory.
1232
+ * Represents the progress reported while compressing a directory.
938
1233
  *
939
1234
  * @remarks
940
1235
  * `path` — absolute path to the file just compressed.
@@ -948,12 +1243,7 @@ export declare interface SEAProgress {
948
1243
  }
949
1244
 
950
1245
  /**
951
- * Callback invoked by the framework after each file is compressed.
952
- */
953
- export declare type SEAProgressHandler = (result: SEACompressionResult) => void;
954
-
955
- /**
956
- * Result of a successful seal build.
1246
+ * Represents the result of a successful SEA build.
957
1247
  *
958
1248
  * @remarks
959
1249
  * `executable` — absolute path to the output binary.
@@ -978,7 +1268,7 @@ export declare interface SEAResult {
978
1268
  }
979
1269
 
980
1270
  /**
981
- * Options for running a shell command.
1271
+ * Configures the execution of a shell command.
982
1272
  *
983
1273
  * @remarks
984
1274
  * `cwd` — working directory. Default: `process.cwd()`.
@@ -992,12 +1282,12 @@ export declare interface SEAShellOptions {
992
1282
  }
993
1283
 
994
1284
  /**
995
- * Overall status of the seal build.
1285
+ * Names the overall status of the SEA build.
996
1286
  */
997
1287
  export declare type SEAStatus = 'idle' | 'active' | 'done' | 'error';
998
1288
 
999
1289
  /**
1000
- * Windows-specific SEA build options.
1290
+ * Configures Windows-specific SEA build behavior.
1001
1291
  *
1002
1292
  * @remarks
1003
1293
  * `terminal` — whether the built executable keeps a console window (PE
@@ -1009,7 +1299,7 @@ export declare type SEAStatus = 'idle' | 'active' | 'done' | 'error';
1009
1299
  * `sign` — Authenticode signing options. When present, the assembled
1010
1300
  * executable is signed with `signtool` (and verified) as the LAST content
1011
1301
  * mutation before the atomic finalize; when absent, the output is unsigned
1012
- * and `SEAResult.signed` is `false` (unchanged default behavior).
1302
+ * and `SEAResult.signed` is `false`.
1013
1303
  *
1014
1304
  * These options apply only when the build HOST is Windows — there is no
1015
1305
  * cross-compilation, so building on a non-Windows host ignores `windows.*`.
@@ -1020,7 +1310,7 @@ export declare interface SEAWindowsOptions {
1020
1310
  }
1021
1311
 
1022
1312
  /**
1023
- * Windows Authenticode signing options, passed through to `signtool`.
1313
+ * Describes the Windows Authenticode signing options passed through to `signtool`.
1024
1314
  *
1025
1315
  * @remarks
1026
1316
  * `file` — path to a `.pfx`/`.p12` certificate file (`signtool /f`).
@@ -1046,7 +1336,7 @@ export declare interface SEAWindowsSignOptions {
1046
1336
  }
1047
1337
 
1048
1338
  /**
1049
- * An error thrown when a shell command run via `runShell` exits non-zero.
1339
+ * Represents an error thrown when a shell command executed through `executeShell` exits non-zero.
1050
1340
  *
1051
1341
  * @remarks
1052
1342
  * Carries the captured `stdout` and `stderr` buffers from the failed process.
@@ -1056,7 +1346,7 @@ export declare interface SEAWindowsSignOptions {
1056
1346
  * @example
1057
1347
  * ```ts
1058
1348
  * try {
1059
- * runShell(['codesign', '--sign', '-', path])
1349
+ * executeShell(['codesign', '--sign', '-', path])
1060
1350
  * } catch (error) {
1061
1351
  * if (isShellError(error)) {
1062
1352
  * console.error(error.stderr.toString())
@@ -1070,11 +1360,11 @@ export declare class ShellError extends SEAError {
1070
1360
  constructor(message: string, stdout: Buffer, stderr: Buffer);
1071
1361
  }
1072
1362
 
1073
- /** File extensions that should NOT be Brotli-compressed */
1074
- export declare const SKIP_EXTENSIONS: Set<string>;
1363
+ /** Lists the file extensions Brotli compression skips */
1364
+ export declare const SKIP_EXTENSIONS: ReadonlySet<string>;
1075
1365
 
1076
1366
  /**
1077
- * Remove the Authenticode signature from a PE executable by zeroing
1367
+ * Removes the Authenticode signature from a PE executable by zeroing
1078
1368
  * the security directory entry in the optional header.
1079
1369
  *
1080
1370
  * @remarks
@@ -1091,7 +1381,25 @@ export declare const SKIP_EXTENSIONS: Set<string>;
1091
1381
  export declare function stripPESignature(path: string): void;
1092
1382
 
1093
1383
  /**
1094
- * Fsync a directory to durably persist a prior file rename/create within it.
1384
+ * Truncates a string at its first NUL character.
1385
+ *
1386
+ * @remarks
1387
+ * Binary name fields (PE section names, Mach-O segment and section names, ELF
1388
+ * note names) are fixed-width and NUL-padded, so the decoded string carries
1389
+ * trailing NUL characters that no comparison against a literal name matches.
1390
+ *
1391
+ * @param value - Decoded fixed-width name field
1392
+ * @returns The value up to, but excluding, its first NUL character
1393
+ *
1394
+ * @example
1395
+ * ```ts
1396
+ * stripTrailingNulls('.rsrc\0\0\0') // '.rsrc'
1397
+ * ```
1398
+ */
1399
+ export declare function stripTrailingNulls(value: string): string;
1400
+
1401
+ /**
1402
+ * Fsyncs a directory to durably persist a prior file rename/create within it.
1095
1403
  *
1096
1404
  * @remarks
1097
1405
  * A `rename`/`create` is only durable once its CONTAINING directory entry is
@@ -1116,7 +1424,7 @@ export declare function stripPESignature(path: string): void;
1116
1424
  export declare function syncDirectory(path: string): void;
1117
1425
 
1118
1426
  /**
1119
- * Recursively walk a directory and return all file paths.
1427
+ * Walks a directory recursively and returns all file paths.
1120
1428
  *
1121
1429
  * @param directory - Directory to walk
1122
1430
  * @param base - Base directory for relative path calculation
@@ -1124,14 +1432,14 @@ export declare function syncDirectory(path: string): void;
1124
1432
  */
1125
1433
  export declare function walkDirectory(directory: string, base?: string): readonly string[];
1126
1434
 
1127
- /** Windows PE subsystem value: console application */
1435
+ /** Holds the Windows PE subsystem value for a console application */
1128
1436
  export declare const WINDOWS_SUBSYSTEM_CONSOLE = 3;
1129
1437
 
1130
- /** Windows PE subsystem value: GUI application (no terminal window) */
1438
+ /** Holds the Windows PE subsystem value for a GUI application (no terminal window) */
1131
1439
  export declare const WINDOWS_SUBSYSTEM_GUI = 2;
1132
1440
 
1133
1441
  /**
1134
- * Write a 16-bit unsigned integer to a file descriptor.
1442
+ * Writes a 16-bit unsigned integer to a file descriptor.
1135
1443
  *
1136
1444
  * @param fd - Open file descriptor
1137
1445
  * @param offset - Byte offset to write at
@@ -1139,4 +1447,38 @@ export declare const WINDOWS_SUBSYSTEM_GUI = 2;
1139
1447
  */
1140
1448
  export declare function writeU16(fd: number, offset: number, value: number): void;
1141
1449
 
1450
+ /**
1451
+ * Writes a 32-bit unsigned little-endian integer to a file descriptor.
1452
+ *
1453
+ * @remarks
1454
+ * Coerces `value` with `>>> 0` before writing, so a negative or out-of-range
1455
+ * number lands as its unsigned 32-bit representation rather than throwing.
1456
+ *
1457
+ * @param fd - Open file descriptor
1458
+ * @param offset - Byte offset to write at
1459
+ * @param value - The 32-bit value to write
1460
+ *
1461
+ * @example
1462
+ * ```ts
1463
+ * const fd = openSync('app.exe', 'r+')
1464
+ * writeU32(fd, 0x3c, 0x100)
1465
+ * ```
1466
+ */
1467
+ export declare function writeU32(fd: number, offset: number, value: number): void;
1468
+
1469
+ /**
1470
+ * Writes a 64-bit unsigned little-endian integer to a file descriptor.
1471
+ *
1472
+ * @param fd - Open file descriptor
1473
+ * @param offset - Byte offset to write at
1474
+ * @param value - The 64-bit value to write
1475
+ *
1476
+ * @example
1477
+ * ```ts
1478
+ * const fd = openSync('app', 'r+')
1479
+ * writeU64(fd, 32, 8192n)
1480
+ * ```
1481
+ */
1482
+ export declare function writeU64(fd: number, offset: number, value: bigint): void;
1483
+
1142
1484
  export { }