API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classInlineWorker
Runs a worker from a JavaScript source string instead of a separate script file, and owns the lifetime of the object URL that makes that possible. The intended source is the string emitted by the `?worker` import of `@codexo/exojs-build`, which inlines a TypeScript worker module and its imports as one classic script. Nothing about this class requires that build step, though: any self-contained classic-script source works. ```ts import workerSource from './generator.worker.ts?worker'; const worker = new InlineWorker(workerSource, { name: 'generator' }); worker.worker.onmessage = (event) => console.log(event.data); worker.postMessage(42); ``` There is no message protocol here: worker is the real `Worker`, so `onmessage`, `onerror`, `addEventListener` and structured clone behave exactly as they do without this class. postMessage is a convenience that additionally rejects use after destroy. The source runs as a **classic** script, so it cannot use `import`. Emitted `?worker` sources already satisfy this. A page whose Content-Security-Policy omits `blob:` from `worker-src` (or `child-src`/`default-src` as the fallback) blocks the construction; the error thrown by the constructor names that cause.
import { InlineWorker } from '@codexo/exojs'Runs a worker from a JavaScript source string instead of a separate script file, and owns the lifetime of the object URL that makes that possible.
The intended source is the string emitted by the `?worker` import of `@codexo/exojs-build`, which inlines a TypeScript worker module and its imports as one classic script. Nothing about this class requires that build step, though: any self-contained classic-script source works.
```ts import workerSource from './generator.worker.ts?worker';
const worker = new InlineWorker(workerSource, { name: 'generator' });
worker.worker.onmessage = (event) => console.log(event.data); worker.postMessage(42); ```
There is no message protocol here: worker is the real `Worker`, so `onmessage`, `onerror`, `addEventListener` and structured clone behave exactly as they do without this class. postMessage is a convenience that additionally rejects use after destroy.
The source runs as a **classic** script, so it cannot use `import`. Emitted `?worker` sources already satisfy this.
A page whose Content-Security-Policy omits `blob:` from `worker-src` (or `child-src`/`default-src` as the fallback) blocks the construction; the error thrown by the constructor names that cause.
new(source: string, options: InlineWorkerOptionsOptions for InlineWorker.): InlineWorkerdestroy(): voidpostMessage(message: unknown, transfer?: readonly Transferable[]): voidworker: Workerdestroyed: boolean