type SingleArgmumentFunction = (arg: TArg) => TResult; type DoubleArgmumentFunction = (arg: TArg, options: TOptions) => TResult; type WorkerFunction any> = Worker & { __workerType?: TWorker; }; type WorkerFunctionLoader any> = () => WorkerFunction; /** * Create a Worker factory * * This function is only a type guard helper */ declare const createWorkerFactory: | DoubleArgmumentFunction>(loader: WorkerFunctionLoader) => WorkerFunctionLoader; /** * useWorkerMemo uses a worker to computate a value and memorizes it * * If the worker argument is undefined / null the hook will wait for a valid loader * * @example * ```tsx * const workerLoader = createWorkerFactory( * () => new Worker(new URL('./worker.ts', import.meta.url)) * ); * * const MyComponent = () => { * const calculatedValue = useWorkerMemo(workerLoader, 42); * return ( * {calculatedValue} * ); * } * ``` */ declare function useWorkerMemo(workerLoader: WorkerFunctionLoader>, input: TArg): undefined | Awaited; /** * useWorkerMemo uses a worker to computate a value and memorizes it * * If the worker argument is undefined / null the hook will wait for a valid loader * * @example * ```tsx * const workerLoader = typeof window !== "undefined" && createWorkerFactory( * () => new Worker(new URL('./worker.ts', import.meta.url)) * ); * * const MyComponent = () => { * const calculatedValue = useWorkerMemo(workerLoader, 42); * return ( * {calculatedValue} * ); * } * ``` */ declare function useWorkerMemo(workerLoader: WorkerFunctionLoader> | TFalsy, input: TArg): Awaited | TFalsy | undefined; /** * useWorkerMemo uses a worker to computate a value and memorizes it * * If the worker argument is undefined / null the hook will wait for a valid loader * * The init argument will be passed to initialize the worker * * @example * ```tsx * const workerLoader = typeof window !== "undefined" && createWorkerFactory( * () => new Worker(new URL('./worker.ts', import.meta.url)) * ); * * // The worker will be called with the given payload initialy * const workerConfig = { foo: 'baz' }; * * const MyComponent = () => { * const calculatedValue = useWorkerMemo(workerLoader, 42, workerConfig); * return ( * {calculatedValue} * ); * } * ``` */ declare function useWorkerMemo(workerLoader: WorkerFunctionLoader>, input: TArg, init: TInit): undefined | Awaited; /** * useWorkerMemo uses a worker to computate a value and memorizes it * * If the worker argument is undefined / null the hook will wait for a valid loader * * The init argument will be passed to initialize the worker * * @example * ```tsx * const workerLoader = createWorkerFactory( * () => new Worker(new URL('./worker.ts', import.meta.url)) * ); * * // The worker will be called with the given payload initialy * const workerConfig = { foo: 'baz' }; * * const MyComponent = () => { * const calculatedValue = useWorkerMemo(workerLoader, 42, workerConfig); * return ( * {calculatedValue} * ); * } * ``` */ declare function useWorkerMemo(workerLoader: WorkerFunctionLoader> | TFalsy, input: TArg, init: TInit): undefined | Awaited | TFalsy; export { SingleArgmumentFunction, WorkerFunctionLoader, createWorkerFactory, useWorkerMemo };