node/lib
Joyee Cheung ce8f085d26
sea: support embedding assets
With this patch:

Users can now include assets by adding a key-path dictionary
to the configuration as the `assets` field. At build time, Node.js
would read the assets from the specified paths and bundle them into
the preparation blob. In the generated executable, users can retrieve
the assets using the `sea.getAsset()` and `sea.getAssetAsBlob()` API.

```json
{
  "main": "/path/to/bundled/script.js",
  "output": "/path/to/write/the/generated/blob.blob",
  "assets": {
    "a.jpg": "/path/to/a.jpg",
    "b.txt": "/path/to/b.txt"
  }
}
```

The single-executable application can access the assets as follows:

```cjs
const { getAsset } = require('node:sea');
// Returns a copy of the data in an ArrayBuffer
const image = getAsset('a.jpg');
// Returns a string decoded from the asset as UTF8.
const text = getAsset('b.txt', 'utf8');
// Returns a Blob containing the asset.
const blob = getAssetAsBlob('a.jpg');
```

Drive-by: update the  documentation to include a section dedicated
to the injected main script and refer to it as "injected main
script" instead of "injected module" because it's a script, not
a module.

PR-URL: https://github.com/nodejs/node/pull/50960
Refs: https://github.com/nodejs/single-executable/issues/68
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2024-02-02 15:25:34 +01:00
..
assert
dns
fs
inspector
internal sea: support embedding assets 2024-02-02 15:25:34 +01:00
path
readline
stream
test test_runner: adds built in lcov reporter 2023-10-25 12:11:32 +00:00
timers
util
_http_agent.js lib: remove deprecated string methods 2023-11-11 15:44:16 +00:00
_http_client.js http: do not override user-provided options object 2023-12-19 09:55:21 +00:00
_http_common.js
_http_incoming.js
_http_outgoing.js http: handle multi-value content-disposition header 2023-12-11 08:41:23 +00:00
_http_server.js http: remove misleading warning 2023-12-21 20:09:01 +00:00
_stream_duplex.js
_stream_passthrough.js
_stream_readable.js
_stream_transform.js
_stream_wrap.js
_stream_writable.js
_tls_common.js
_tls_wrap.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
.eslintrc.yaml lib: expose default prepareStackTrace 2023-12-21 16:56:35 +00:00
assert.js lib: fix assert shows diff messages in ESM and CJS 2023-11-11 14:24:56 +00:00
async_hooks.js
buffer.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
child_process.js typings: update JSDoc for cwd in child_process 2023-08-08 15:32:31 +08:00
cluster.js
console.js
constants.js
crypto.js crypto: move createCipher and createDecipher to eol 2023-12-15 14:00:52 +00:00
dgram.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
diagnostics_channel.js doc: correct tracingChannel.traceCallback() 2023-12-08 21:01:23 +00:00
dns.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
domain.js lib: implement WeakReference on top of JS WeakRef 2023-08-16 18:45:07 +02:00
events.js stream: pre-allocate _events 2023-10-29 16:29:59 +00:00
fs.js fs: update jsdoc for filehandle.createWriteStream and appendFile 2024-01-20 15:55:00 +00:00
http2.js http2: add server handshake utility 2024-01-12 16:09:48 +00:00
http.js lib: update params in jsdoc for HTTPRequestOptions 2023-09-29 13:14:24 +02:00
https.js lib: update params in jsdoc for HTTPRequestOptions 2023-09-29 13:14:24 +02:00
inspector.js inspector: use private fields instead of symbols 2023-11-19 22:35:19 +00:00
module.js
net.js net: add connection attempt events 2023-12-21 10:43:15 +00:00
os.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
path.js
perf_hooks.js
process.js
punycode.js
querystring.js
readline.js
repl.js repl: fix NO_COLORS env var is ignored 2024-01-31 06:44:33 +00:00
sea.js sea: support embedding assets 2024-02-02 15:25:34 +01:00
stream.js errors: improve performance of instantiation 2023-09-28 09:57:38 +00:00
string_decoder.js
sys.js
test.js
timers.js timers: export timers.promises 2023-12-23 10:23:43 +00:00
tls.js
trace_events.js trace_events: use private fields instead of symbols for Tracing 2023-12-28 23:20:22 +00:00
tty.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
url.js url: validate pathToFileURL(path) argument as string 2023-08-31 20:35:04 +08:00
util.js src: add process.loadEnvFile and util.parseEnv 2024-01-23 18:46:26 +00:00
v8.js
vm.js vm: support using the default loader to handle dynamic import() 2024-02-01 11:45:42 +00:00
wasi.js
worker_threads.js
zlib.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00