solid-primitives
solid-primitives copied to clipboard
fix(workers): export missing types from definitions
Hey all, this is my first PR to solid which is very exciting!
- Closes #594
- Is there anything to reconsider or change in here?
types.d.ts wasn't part of the entry point index.ts during the bundling process.
By importing and exporting the types from index.d.ts via index.ts, it will now bundle these types in the declaration file.
Here's the compiled types file in the relative dist directory:
import { Accessor, Setter } from 'solid-js';
type WorkerSignal = number;
type WorkerCallbacks = Map<string, [succes: Function, error: Function]>;
type WorkerMessage = {
type: WorkerSignal;
id?: string;
error?: string;
method?: string;
signal?: string | number;
result?: string;
params?: any;
};
type WorkerExports = [
worker: Worker,
start: () => void,
stop: () => void,
exports?: Set<string>,
];
interface PostMessageOptions {
transfer?: any[] | undefined;
}
/**
* Creates a very basic WebWorker based on provided code.
*
* @param Functions A set of functions to expose via the worker.
* @param options Web worker options to control the instance.
* @returns An array with worker, start and stop methods
*/
declare function createWorker(...args: (Function | object)[]): WorkerExports;
/**
* Creates a worker pool that round-robins work between worker sets.
*
* @param number Amount of workers to establish in the pool.
* @param Functions A set of functions to expose via the worker.
* @param options Web worker options to control the instance.
* @returns An array with worker, start and stop methods
*/
declare const createWorkerPool: (concurrency?: number, ...args: (Function | object)[]) => WorkerExports;
type WorkerInstruction = {
func: Function;
input?: Accessor<any>;
output?: Setter<any>;
concurrency?: number;
};
/**
* Creates a complex worker that reads inputs and provides outputs.
*
* @param args An instruction list of controls for the worker.
* @returns Basic start and stop functions
*/
declare const createSignaledWorker: (...args: WorkerInstruction[]) => [start: () => void, stop: () => void];
export { type PostMessageOptions, type WorkerCallbacks, type WorkerExports, type WorkerInstruction, type WorkerMessage, type WorkerSignal, createSignaledWorker, createWorker, createWorkerPool };
🦋 Changeset detected
Latest commit: a4bb7013931bfe58f7f495260d2ccf82c43ff1b3
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @solid-primitives/workers | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR