webevm 0.0.0 → 0.5.0

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 (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +674 -0
  3. package/dist/engine.d.ts +69 -0
  4. package/dist/engine.d.ts.map +1 -0
  5. package/dist/engine.js +269 -0
  6. package/dist/engine.js.map +1 -0
  7. package/dist/index.d.ts +12 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +21 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/intrinsic-gas.d.ts +149 -0
  12. package/dist/intrinsic-gas.d.ts.map +1 -0
  13. package/dist/intrinsic-gas.js +94 -0
  14. package/dist/intrinsic-gas.js.map +1 -0
  15. package/dist/node.d.ts +3 -0
  16. package/dist/node.d.ts.map +1 -0
  17. package/dist/node.js +1743 -0
  18. package/dist/node.js.map +1 -0
  19. package/dist/persistence.d.ts +22 -0
  20. package/dist/persistence.d.ts.map +1 -0
  21. package/dist/persistence.js +54 -0
  22. package/dist/persistence.js.map +1 -0
  23. package/dist/revm-state-store.d.ts +89 -0
  24. package/dist/revm-state-store.d.ts.map +1 -0
  25. package/dist/revm-state-store.js +394 -0
  26. package/dist/revm-state-store.js.map +1 -0
  27. package/dist/revm.d.ts +124 -0
  28. package/dist/revm.d.ts.map +1 -0
  29. package/dist/revm.js +657 -0
  30. package/dist/revm.js.map +1 -0
  31. package/dist/sender-recovery.d.ts +78 -0
  32. package/dist/sender-recovery.d.ts.map +1 -0
  33. package/dist/sender-recovery.js +53 -0
  34. package/dist/sender-recovery.js.map +1 -0
  35. package/dist/state-manager.d.ts +327 -0
  36. package/dist/state-manager.d.ts.map +1 -0
  37. package/dist/state-manager.js +439 -0
  38. package/dist/state-manager.js.map +1 -0
  39. package/dist/storage-keys.d.ts +21 -0
  40. package/dist/storage-keys.d.ts.map +1 -0
  41. package/dist/storage-keys.js +113 -0
  42. package/dist/storage-keys.js.map +1 -0
  43. package/dist/types.d.ts +680 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +12 -0
  46. package/dist/types.js.map +1 -0
  47. package/dist/worker-client.d.ts +21 -0
  48. package/dist/worker-client.d.ts.map +1 -0
  49. package/dist/worker-client.js +77 -0
  50. package/dist/worker-client.js.map +1 -0
  51. package/dist/worker-entry.d.ts +32 -0
  52. package/dist/worker-entry.d.ts.map +1 -0
  53. package/dist/worker-entry.js +29 -0
  54. package/dist/worker-entry.js.map +1 -0
  55. package/dist/worker-host.d.ts +75 -0
  56. package/dist/worker-host.d.ts.map +1 -0
  57. package/dist/worker-host.js +188 -0
  58. package/dist/worker-host.js.map +1 -0
  59. package/package.json +90 -2
  60. package/src/engine.ts +300 -0
  61. package/src/index.ts +46 -0
  62. package/src/intrinsic-gas.ts +191 -0
  63. package/src/node.ts +1959 -0
  64. package/src/persistence.ts +80 -0
  65. package/src/revm-state-store.ts +455 -0
  66. package/src/revm.ts +809 -0
  67. package/src/sender-recovery.ts +142 -0
  68. package/src/state-manager.ts +531 -0
  69. package/src/storage-keys.ts +150 -0
  70. package/src/types.ts +701 -0
  71. package/src/worker-client.ts +112 -0
  72. package/src/worker-entry.ts +31 -0
  73. package/src/worker-host.ts +232 -0
@@ -0,0 +1,112 @@
1
+ /**
2
+ * worker-client.ts — the OPTIONAL main-thread side. Wraps a Worker (running
3
+ * ./worker-entry.ts) over comlink and returns the SAME `{ request, mine,
4
+ * dumpState, loadState, ... }` shape as `createNode()`. So `createNode()` (main
5
+ * thread) and `createWorkerNode()` (Worker) are interchangeable one-liners and
6
+ * the consumer never hand-rolls the comlink plumbing.
7
+ */
8
+ import {wrap, proxy} from 'comlink';
9
+ // The api TYPE, from the module that defines it rather than from the one that
10
+ // exposes it: this client drives ANY worker exposing it, including a consumer's
11
+ // own `exposeNode({createEngine})` module. Type-only, so nothing is imported at
12
+ // runtime and no `expose()` side effect is dragged onto the main thread.
13
+ import type {NodeWorkerApi} from './worker-host.js';
14
+ import type {
15
+ NodeOptions,
16
+ SlimNode,
17
+ RequestArguments,
18
+ SerializedState,
19
+ } from './types.js';
20
+
21
+ export interface WorkerNodeOptions extends NodeOptions {
22
+ /**
23
+ * A Worker already pointing at this package's worker-entry, or at a module of
24
+ * your own that called `exposeNode()` (`webevm/worker-host`), which is the
25
+ * shape for a Worker that builds its own engine. Consumers create it themselves
26
+ * so the bundler controls chunking:
27
+ * new Worker(new URL('webevm/worker-entry', import.meta.url),
28
+ * {type: 'module'})
29
+ */
30
+ worker: Worker;
31
+ /**
32
+ * NOT AVAILABLE ON THIS PATH, and typed `never` so it is a compile error
33
+ * rather than a runtime surprise (it is also refused at runtime, for JS
34
+ * consumers). See the refusal in {@link createWorkerNode} for why, and for the
35
+ * supported way to run a non-default engine inside a Worker.
36
+ */
37
+ engine?: never;
38
+ }
39
+
40
+ export async function createWorkerNode(
41
+ opts: WorkerNodeOptions,
42
+ ): Promise<SlimNode> {
43
+ const {worker, ...nodeOptions} = opts;
44
+ // AN ENGINE CANNOT CROSS THIS BOUNDARY, and says so. `WorkerNodeOptions`
45
+ // extends `NodeOptions`, so `engine` is structurally in scope here, but these
46
+ // options are STRUCTURED-CLONED into the Worker and an `Engine` is a
47
+ // function-bearing object: comlink would throw an opaque `DataCloneError` from
48
+ // deep inside its own postMessage, which is exactly the plausible-looking
49
+ // failure this package's honest-edge convention exists to prevent. Cloning
50
+ // could not work in principle either — an engine holds live state (a wasm
51
+ // instance, a binding to the node's state manager) that belongs to the thread
52
+ // that built it.
53
+ //
54
+ // The supported shape is to build the engine INSIDE the worker, in your own
55
+ // worker module, and expose the node from there:
56
+ //
57
+ // // my-worker.ts
58
+ // import {exposeNode} from 'webevm/worker-host';
59
+ // import {createRevmEngine} from 'webevm/revm';
60
+ // import wasm from 'revm-wasm/revm.wasm';
61
+ // exposeNode({createEngine: () => createRevmEngine({wasm})});
62
+ //
63
+ // `exposeNode` supplies the node and the proxy; the ENGINE is yours, built on
64
+ // the thread that will use it. This package deliberately does not build it for
65
+ // you, because that would mean the core naming engines by string and importing them,
66
+ // which is precisely what ADR 0006 refuses (a JS-only consumer would pay for
67
+ // revm).
68
+ if ((nodeOptions as NodeOptions).engine !== undefined) {
69
+ throw new Error(
70
+ "webevm/worker-client: `engine` is not supported by createWorkerNode(). The node's options are structured-cloned into the Worker and an Engine is a function-bearing object, so it cannot be cloned across the thread boundary (comlink would report only a DataCloneError). " +
71
+ 'Build the engine INSIDE the Worker instead: write your own worker module that calls exposeNode({createEngine: () => createRevmEngine({wasm})}) from webevm/worker-host, which exposes the node for you, then drive it with the same client code. ' +
72
+ 'Or run the engine on the main thread with createNode().',
73
+ );
74
+ }
75
+ const api = wrap<NodeWorkerApi>(worker);
76
+ const remote = await api.createNode(nodeOptions);
77
+ // stateMode/senderMode/engine are plain values on the node; over comlink
78
+ // they read as promises.
79
+ //
80
+ // NO `as any` HERE, and that is load-bearing. The remote is a `SlimNode` (the
81
+ // one proxy in ./worker-host.ts is typed as one), so these three reads are
82
+ // CHECKED: `senderMode` was silently absent from that proxy for a month, and
83
+ // what hid it from the compiler was the cast that used to be on this line.
84
+ const stateMode = await remote.stateMode;
85
+ const senderMode = await remote.senderMode;
86
+ const engineInfo = await remote.engine;
87
+
88
+ return {
89
+ request: (args: RequestArguments) => remote.request(args),
90
+ mine: () => remote.mine(),
91
+ dumpState: () => remote.dumpState(),
92
+ loadState: (s: SerializedState) => remote.loadState(s),
93
+ stateMode,
94
+ senderMode,
95
+ engine: engineInfo,
96
+ getStateRoot: () => remote.getStateRoot(),
97
+ onNewHead(cb) {
98
+ // The callback must cross the thread boundary as a comlink proxy.
99
+ let unsub: (() => void) | undefined;
100
+ void remote.onNewHead(proxy(cb)).then((u) => {
101
+ unsub = u;
102
+ });
103
+ return () => {
104
+ void unsub?.();
105
+ };
106
+ },
107
+ async dispose() {
108
+ await remote.dispose();
109
+ worker.terminate();
110
+ },
111
+ };
112
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * worker-entry.ts: the OPTIONAL Worker side, AS A WORKER ENTRY POINT. The
3
+ * package's node api, exposed the moment this module is imported. That import-time
4
+ * `expose()` is the whole of what this file adds, and it is what makes the common
5
+ * case a one-liner:
6
+ *
7
+ * new Worker(new URL('webevm/worker-entry', import.meta.url),
8
+ * {type: 'module'});
9
+ *
10
+ * Pair it with `createWorkerNode()` (see ./worker-client.ts) on the main thread.
11
+ *
12
+ * THE NODE API ITSELF LIVES IN ./worker-host.ts, with no side effect, because a
13
+ * side effect cannot be imported: a consumer whose worker must build something
14
+ * first (an ENGINE, which cannot cross the boundary) used to hand-copy the
15
+ * `SlimNode` proxy, since importing THIS module would have exposed the default api
16
+ * on their thread. They call `exposeNode()` from `webevm/worker-host`
17
+ * instead, and the proxy exists in exactly one place.
18
+ *
19
+ * Why the split exists at all: heavy pure-JS EVM compute can hang the browser main
20
+ * thread. Moving the node into a Worker fixes that, but it's the consumer's
21
+ * CHOICE. The same `createNode()` runs fine on the main thread too.
22
+ */
23
+ import {exposeNode, type NodeWorkerApi} from './worker-host.js';
24
+
25
+ /**
26
+ * The exposed api. Kept exported (and exposed at import time) because consumers
27
+ * import this module for exactly that: nothing here changed when the proxy moved.
28
+ */
29
+ export const workerApi = exposeNode();
30
+
31
+ export type WorkerApi = NodeWorkerApi;
@@ -0,0 +1,232 @@
1
+ /**
2
+ * worker-host.ts: THE WORKER SIDE OF THE NODE, minus the side effect: the ONE
3
+ * `SlimNode` proxy that crosses a comlink boundary, and the two ways to put it on
4
+ * a thread. `./worker-entry.ts` is this module plus an import-time `expose()`;
5
+ * a consumer whose Worker must build something first (an ENGINE) calls
6
+ * {@link exposeNode} from their own worker module instead.
7
+ *
8
+ * WHY IT IS A SEPARATE MODULE. `worker-entry` calls `expose()` at MODULE SCOPE,
9
+ * which is what makes `new Worker(new URL('webevm/worker-entry', ...))`
10
+ * a one-liner, and also what makes it unusable as a library: importing it to
11
+ * reuse the proxy would expose the DEFAULT api on the importing thread, so
12
+ * consumers hand-copied the proxy block instead. There were three copies of it
13
+ * (this package's, this repo's example, and every consumer's), each able to drop a
14
+ * field independently. That is not hypothetical: `senderMode` was missing from
15
+ * one of them for a month, reading as `undefined` on a property typed
16
+ * `'recover' | 'trusted'`. Now there is one copy, here.
17
+ *
18
+ * AND IT IS THE COMPILER THAT KEEPS IT COMPLETE. {@link nodeProxy}'s literal is
19
+ * typed `Required<SlimNode>`, so a field ADDED to `SlimNode` later fails to build
20
+ * here rather than reading as `undefined` on the far side of a thread boundary;
21
+ * the client (`./worker-client.ts`) reads those fields off the remote with no
22
+ * `as any` in the way, so the type is load-bearing on both ends. That covers a
23
+ * future field structurally, which is the property enumerating today's fields
24
+ * cannot have. `Required<>` is what extends it to an OPTIONAL member: a bare
25
+ * `SlimNode` annotation does not DEMAND one, so an optional field added later
26
+ * would compile while missing here. The runtime parity check that backs this up
27
+ * (`test/helpers/worker-roundtrip.ts`) cannot be widened the same way and says so
28
+ * itself: it enumerates the keys of a reference node INSTANCE, and an optional
29
+ * field that instance does not carry is invisible to it.
30
+ *
31
+ * A MISUSE OF {@link WorkerHostOptions.createEngine} IS A VALUE, NEVER A THROW,
32
+ * and that ordering is the whole of why: `expose()` registers comlink's message
33
+ * listener, so a module that throws BEFORE reaching it answers the main thread
34
+ * nothing at all and `createWorkerNode()` stays pending forever. The refusal is
35
+ * therefore recorded here, reported on this thread immediately, and re-thrown
36
+ * from `createNode()` where it crosses the boundary as a rejection the caller can
37
+ * read. Both threads say something; neither is left guessing.
38
+ * `docs/spikes/a-bad-createengine-hangs-the-main-thread-instead-of-rejecting/decisions.md`.
39
+ *
40
+ * WHAT THIS MODULE DOES NOT DO: name an engine. The core imports no engine and
41
+ * resolves no engine name (`docs/adr/0006-the-engine-is-an-injected-object-not-a-named-string.md`),
42
+ * so an engine reaches a node here exactly as it does on the main thread, as an
43
+ * object the CONSUMER built, on the thread that will use it. This module never
44
+ * mentions `webevm/revm`, and a JS-only consumer's bundle is unmoved by
45
+ * its existence.
46
+ */
47
+ import {expose, proxy} from 'comlink';
48
+ import {createNode} from './node.js';
49
+ import type {Engine, NodeOptions, SlimNode} from './types.js';
50
+
51
+ /**
52
+ * Builds the {@link Engine} for ONE node, on the thread that will run it.
53
+ *
54
+ * A FUNCTION, not a built engine, for two reasons that are both structural.
55
+ * Building an engine is ASYNC (`createRevmEngine()` compiles wasm), and this way
56
+ * the await belongs to `createNode()`'s own await instead of to the consumer's
57
+ * module top level. And one engine instance serves ONE node (`connect()` binds it
58
+ * to that node's state manager, and handing a connected engine to a second
59
+ * `createNode()` throws), so an engine VALUE here would work once and then fail
60
+ * the second time this worker was asked for a node.
61
+ */
62
+ export type EngineSupplier = () => Engine | Promise<Engine>;
63
+
64
+ /** What the WORKER thread decides. Everything else is the main thread's. */
65
+ export interface WorkerHostOptions {
66
+ /**
67
+ * Build this node's engine on THIS thread. Omit it for the default
68
+ * `@ethereumjs/evm` engine (what `worker-entry` does).
69
+ *
70
+ * Called ONCE PER `createNode()`, so each node gets its own engine instance:
71
+ *
72
+ * exposeNode({createEngine: () => createRevmEngine({wasm})});
73
+ *
74
+ * `createEngine`, not `engine`, deliberately: `NodeOptions.engine` is an
75
+ * `Engine` everywhere else in this package, and one name meaning "an engine"
76
+ * in one place and "a function that makes one" in another is how the wrong
77
+ * value gets passed. The main thread's options are untouched by this: they
78
+ * still travel through `createWorkerNode()` as they always did, and an engine
79
+ * still cannot come from there (see `./worker-client.ts`'s refusal).
80
+ */
81
+ createEngine?: EngineSupplier;
82
+ }
83
+
84
+ /**
85
+ * THE ONE `SlimNode` PROXY. Comlink cannot pass the node itself (its methods are
86
+ * functions and its subscription hands back another one), so this is the node's
87
+ * public surface rendered for the boundary.
88
+ *
89
+ * TYPED `Required<SlimNode>` ON PURPOSE, and that annotation is the mechanism
90
+ * rather than documentation: every member of `SlimNode` must be here or this does
91
+ * not compile, today and for every field added later, INCLUDING an optional one
92
+ * (which a bare `SlimNode` annotation would let through, since it demands only
93
+ * the required members). `SlimNode` has no optional members today, so this costs
94
+ * nothing now and stops the one thing the guarantee otherwise missed. The plain
95
+ * values (`stateMode`, `senderMode`, `engine`) clone across as-is; the client
96
+ * reads them off the remote as promises.
97
+ */
98
+ function nodeProxy(node: SlimNode): SlimNode {
99
+ const forwarded: Required<SlimNode> = {
100
+ request: (args) => node.request(args),
101
+ mine: () => node.mine(),
102
+ dumpState: () => node.dumpState(),
103
+ loadState: (state) => node.loadState(state),
104
+ getStateRoot: () => node.getStateRoot(),
105
+ stateMode: node.stateMode,
106
+ senderMode: node.senderMode,
107
+ engine: node.engine,
108
+ // newHeads over comlink: the callback arrives as a comlink proxy, and the
109
+ // unsubscribe going back must be marked as one too, or it clones as `{}`.
110
+ onNewHead: (cb) => proxy(node.onNewHead(cb)),
111
+ dispose: () => node.dispose(),
112
+ };
113
+ return forwarded;
114
+ }
115
+
116
+ /**
117
+ * The comlink API a Worker exposes: `createNode(options)` with the SAME options
118
+ * `createNode()` takes on the main thread, returning the node as a proxy.
119
+ *
120
+ * Use {@link exposeNode} unless you are composing this into a larger exposed API
121
+ * of your own; this is the same object `worker-entry` exposes.
122
+ */
123
+ export function createNodeWorkerApi(hostOptions: WorkerHostOptions = {}) {
124
+ const {createEngine} = hostOptions;
125
+ // THE REFUSAL IS A VALUE. Passing the ENGINE (or the promise of one) where its
126
+ // FACTORY belongs is the one plausible mistake at this seam, and it is refused
127
+ // with a real message rather than left to become a `TypeError` from inside
128
+ // `createNode`. What it must NOT do is throw from here: this function runs while
129
+ // the worker module is still evaluating, so a throw means `expose()` never runs,
130
+ // the worker registers no message listener, and an awaited `createWorkerNode()`
131
+ // on the main thread never settles at all. Recorded here, said out loud here,
132
+ // and thrown where a caller can catch it.
133
+ const refusal = engineSupplierRefusal(createEngine);
134
+ // THE EARLY SIGNAL, on the thread the mistake was written on and at the moment
135
+ // it was made: a developer with the worker console open reads it before anybody
136
+ // asks for a node. It is not the only one, precisely because a bundled app's
137
+ // worker console is easy to miss.
138
+ if (refusal !== undefined) console.error(refusal);
139
+ return {
140
+ async createNode(options: NodeOptions) {
141
+ // THE LATE SIGNAL, and the one the CALLER gets: comlink carries a thrown
142
+ // error back as a rejection, so the main thread's `await createWorkerNode()`
143
+ // fails with this text instead of hanging.
144
+ if (refusal !== undefined) throw new Error(refusal);
145
+ // The main thread's options pass through UNCHANGED; the engine, and only
146
+ // the engine, is this thread's.
147
+ const node = await createNode(
148
+ createEngine ? {...options, engine: await createEngine()} : options,
149
+ );
150
+ return proxy(nodeProxy(node));
151
+ },
152
+ };
153
+ }
154
+
155
+ /**
156
+ * The message for a `createEngine` that is not a factory, or `undefined` when it
157
+ * is one (`undefined` itself being the default engine, not a mistake).
158
+ *
159
+ * TWO MESSAGES, because there are two mistakes and only one of them is "you
160
+ * passed the wrong kind of thing". A THENABLE means the consumer CALLED the
161
+ * factory here (`createEngine: createRevmEngine({wasm})`, one arrow away from
162
+ * right), and telling them that value "must be a function" describes a value they
163
+ * can see is nearly correct. So the promise case names itself and shows both
164
+ * forms; the other case is a consumer holding a built engine, who needs to know
165
+ * this thread builds one PER NODE.
166
+ */
167
+ function engineSupplierRefusal(createEngine: unknown): string | undefined {
168
+ if (createEngine === undefined || typeof createEngine === 'function') {
169
+ return undefined;
170
+ }
171
+ const why =
172
+ 'It is called ONCE PER createNode(), because one engine instance serves one node (connect() binds it to the state of the node it is given to).';
173
+ if (typeof (createEngine as {then?: unknown} | null)?.then === 'function') {
174
+ return (
175
+ 'webevm/worker-host: `createEngine` must be a FUNCTION that builds an engine on this thread, and it was given a PROMISE of one: the factory was CALLED here instead of being passed. ' +
176
+ 'Write `{createEngine: () => createRevmEngine({wasm})}`, not `{createEngine: createRevmEngine({wasm})}`. ' +
177
+ "Do not reach for `{createEngine: await createRevmEngine({wasm})}` either: a top-level `await` in a worker module can lose the main thread's first message, which hangs it for a different reason this package cannot fix. " +
178
+ why
179
+ );
180
+ }
181
+ return (
182
+ `webevm/worker-host: \`createEngine\` must be a FUNCTION that builds an engine on this thread, not an engine (received ${describe(createEngine)}). ` +
183
+ 'Pass `{createEngine: () => createRevmEngine({wasm})}`, i.e. a function that returns the engine, rather than an engine you built already. ' +
184
+ why
185
+ );
186
+ }
187
+
188
+ /** What was passed, in one word a reader can match against their own code. */
189
+ function describe(value: unknown): string {
190
+ if (value === null) return 'null';
191
+ if (Array.isArray(value)) return 'an array';
192
+ const kind = typeof value;
193
+ return `${kind === 'object' ? 'an' : 'a'} ${kind}`;
194
+ }
195
+
196
+ /** The api {@link exposeNode} exposes, i.e. what a client should `wrap<>()`. */
197
+ export type NodeWorkerApi = ReturnType<typeof createNodeWorkerApi>;
198
+
199
+ /**
200
+ * Expose a node factory on THIS thread. This is the whole of a consumer's worker module:
201
+ *
202
+ * // my-worker.ts
203
+ * import {exposeNode} from 'webevm/worker-host';
204
+ * import {createRevmEngine} from 'webevm/revm';
205
+ * import wasm from 'revm-wasm/revm.wasm';
206
+ *
207
+ * exposeNode({createEngine: () => createRevmEngine({wasm})});
208
+ *
209
+ * The main thread then drives it with the ordinary client, unchanged:
210
+ * `createWorkerNode({worker, chainId, ...})`. Call it ONCE per thread: comlink's
211
+ * `expose()` adds a message listener, so two of them answer the same message
212
+ * twice.
213
+ *
214
+ * DO NOT `await` ANYTHING AT THIS MODULE'S TOP LEVEL BEFORE CALLING IT. A worker
215
+ * module that awaits something slower than a microtask (fetching wasm, opening a
216
+ * database) before `exposeNode()` can LOSE the main thread's first message, and
217
+ * then `createWorkerNode()` never settles. Measured on Chromium and WebKit
218
+ * (`work/notes/observations/a-top-level-await-in-a-worker-module-loses-the-first-message.md`).
219
+ * Nothing here can fix it: there is no listener to register until this call runs.
220
+ * The recipe above is safe because `() => createRevmEngine({wasm})` is
221
+ * SYNCHRONOUS at module scope: the factory defers the await into `createNode()`,
222
+ * which is one of the reasons `createEngine` is a function. If you must await
223
+ * something first, do it INSIDE `createEngine` (or inside a wrapper it calls),
224
+ * not above this line.
225
+ *
226
+ * Returns the exposed api, so `export const myApi = exposeNode(...)` is one line.
227
+ */
228
+ export function exposeNode(hostOptions: WorkerHostOptions = {}): NodeWorkerApi {
229
+ const api = createNodeWorkerApi(hostOptions);
230
+ expose(api);
231
+ return api;
232
+ }