feat(frontend): add API client, layout, and routing
- Create Axios-based API client with sources, jobs, and dashboard endpoints - Add responsive Layout component with navigation sidebar - Set up React Router with Dashboard, Backups, and Settings routes - Configure TanStack Query provider with default options - Use lucide-react for navigation icons
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 James M Snell and the Piscina contributors
|
||||
|
||||
Piscina contributors listed at https://github.com/jasnell/piscina#the-team and
|
||||
in the README file.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
# Tinypool - the node.js worker pool 🧵
|
||||
|
||||
> Piscina: A fast, efficient Node.js Worker Thread Pool implementation
|
||||
|
||||
Tinypool is a fork of piscina. What we try to achieve in this library, is to eliminate some dependencies and features that our target users don't need (currently, our main user will be Vitest). Tinypool's install size (38KB) can then be smaller than Piscina's install size (6MB). If you need features like [utilization](https://github.com/piscinajs/piscina#property-utilization-readonly) or [NAPI](https://github.com/piscinajs/piscina#thread-priority-on-linux-systems), [Piscina](https://github.com/piscinajs/piscina) is a better choice for you. We think that Piscina is an amazing library, and we may try to upstream some of the dependencies optimization in this fork.
|
||||
|
||||
- ✅ Smaller install size, 38KB
|
||||
- ✅ Minimal
|
||||
- ✅ No dependencies
|
||||
- ✅ Physical cores instead of Logical cores with [physical-cpu-count](https://www.npmjs.com/package/physical-cpu-count)
|
||||
- ✅ Supports `worker_threads` and `child_process`
|
||||
- ❌ No utilization
|
||||
- ❌ No NAPI
|
||||
|
||||
- Written in TypeScript, and ESM support only. For Node.js 14.x and higher.
|
||||
|
||||
_In case you need more tiny libraries like tinypool or tinyspy, please consider submitting an [RFC](https://github.com/tinylibs/rfcs)_
|
||||
|
||||
## Docs
|
||||
Read **[full docs](https://github.com/tinylibs/tinypool#readme)** on GitHub.
|
||||
+1
@@ -0,0 +1 @@
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
declare function getHandler(filename: string, name: string): Promise<Function | null>;
|
||||
declare function throwInNextTick(error: Error): void;
|
||||
|
||||
export { getHandler, throwInNextTick };
|
||||
+1
@@ -0,0 +1 @@
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// src/entry/utils.ts
|
||||
import { pathToFileURL } from "url";
|
||||
var importESMCached;
|
||||
function getImportESM() {
|
||||
if (importESMCached === void 0) {
|
||||
importESMCached = new Function("specifier", "return import(specifier)");
|
||||
}
|
||||
return importESMCached;
|
||||
}
|
||||
var handlerCache = /* @__PURE__ */ new Map();
|
||||
async function getHandler(filename, name) {
|
||||
let handler = handlerCache.get(`${filename}/${name}`);
|
||||
if (handler !== void 0) {
|
||||
return handler;
|
||||
}
|
||||
try {
|
||||
const handlerModule = await import(filename);
|
||||
handler = typeof handlerModule.default !== "function" && handlerModule.default || handlerModule;
|
||||
if (typeof handler !== "function") {
|
||||
handler = await handler[name];
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
if (typeof handler !== "function") {
|
||||
handler = await getImportESM()(pathToFileURL(filename).href);
|
||||
if (typeof handler !== "function") {
|
||||
handler = await handler[name];
|
||||
}
|
||||
}
|
||||
if (typeof handler !== "function") {
|
||||
return null;
|
||||
}
|
||||
if (handlerCache.size > 1e3) {
|
||||
const [[key]] = handlerCache;
|
||||
handlerCache.delete(key);
|
||||
}
|
||||
handlerCache.set(`${filename}/${name}`, handler);
|
||||
return handler;
|
||||
}
|
||||
function throwInNextTick(error) {
|
||||
process.nextTick(() => {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
getHandler,
|
||||
throwInNextTick
|
||||
};
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// src/common.ts
|
||||
var kMovable = Symbol("Tinypool.kMovable");
|
||||
var kTransferable = Symbol.for("Tinypool.transferable");
|
||||
var kValue = Symbol.for("Tinypool.valueOf");
|
||||
var kQueueOptions = Symbol.for("Tinypool.queueOptions");
|
||||
function isTransferable(value) {
|
||||
return value != null && typeof value === "object" && kTransferable in value && kValue in value;
|
||||
}
|
||||
function isMovable(value) {
|
||||
return isTransferable(value) && value[kMovable] === true;
|
||||
}
|
||||
function markMovable(value) {
|
||||
Object.defineProperty(value, kMovable, {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: true
|
||||
});
|
||||
}
|
||||
function isTaskQueue(value) {
|
||||
return typeof value === "object" && value !== null && "size" in value && typeof value.shift === "function" && typeof value.remove === "function" && typeof value.push === "function";
|
||||
}
|
||||
var kRequestCountField = 0;
|
||||
var kResponseCountField = 1;
|
||||
var kFieldCount = 2;
|
||||
|
||||
export {
|
||||
kTransferable,
|
||||
kValue,
|
||||
kQueueOptions,
|
||||
isTransferable,
|
||||
isMovable,
|
||||
markMovable,
|
||||
isTaskQueue,
|
||||
kRequestCountField,
|
||||
kResponseCountField,
|
||||
kFieldCount
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// src/utils.ts
|
||||
function stdout() {
|
||||
return console._stdout || process.stdout || void 0;
|
||||
}
|
||||
function stderr() {
|
||||
return console._stderr || process.stderr || void 0;
|
||||
}
|
||||
|
||||
export {
|
||||
stdout,
|
||||
stderr
|
||||
};
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __publicField = (obj, key, value) => {
|
||||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
||||
return value;
|
||||
};
|
||||
var __accessCheck = (obj, member, msg) => {
|
||||
if (!member.has(obj))
|
||||
throw TypeError("Cannot " + msg);
|
||||
};
|
||||
var __privateGet = (obj, member, getter) => {
|
||||
__accessCheck(obj, member, "read from private field");
|
||||
return getter ? getter.call(obj) : member.get(obj);
|
||||
};
|
||||
var __privateAdd = (obj, member, value) => {
|
||||
if (member.has(obj))
|
||||
throw TypeError("Cannot add the same private member more than once");
|
||||
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
||||
};
|
||||
var __privateSet = (obj, member, value, setter) => {
|
||||
__accessCheck(obj, member, "write to private field");
|
||||
setter ? setter.call(obj, value) : member.set(obj, value);
|
||||
return value;
|
||||
};
|
||||
|
||||
// node_modules/.pnpm/tsup@5.12.9_@swc+core@1.2.204_typescript@4.3.5/node_modules/tsup/assets/esm_shims.js
|
||||
import { fileURLToPath } from "url";
|
||||
import path from "path";
|
||||
var getFilename = () => fileURLToPath(import.meta.url);
|
||||
var getDirname = () => path.dirname(getFilename());
|
||||
var __dirname = /* @__PURE__ */ getDirname();
|
||||
|
||||
export {
|
||||
__publicField,
|
||||
__privateGet,
|
||||
__privateAdd,
|
||||
__privateSet,
|
||||
__dirname
|
||||
};
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
import {
|
||||
stderr,
|
||||
stdout
|
||||
} from "../chunk-OECBSOR6.js";
|
||||
import {
|
||||
getHandler,
|
||||
throwInNextTick
|
||||
} from "../chunk-DSRZHYCS.js";
|
||||
import "../chunk-T6A5DJAH.js";
|
||||
|
||||
// src/entry/process.ts
|
||||
process.__tinypool_state__ = {
|
||||
isChildProcess: true,
|
||||
isTinypoolWorker: true,
|
||||
workerData: null,
|
||||
workerId: Number(process.env.TINYPOOL_WORKER_ID)
|
||||
};
|
||||
var memoryUsage = process.memoryUsage.bind(process);
|
||||
var send = process.send.bind(process);
|
||||
process.on("message", (message) => {
|
||||
if (!message || !message.__tinypool_worker_message__)
|
||||
return;
|
||||
if (message.source === "pool") {
|
||||
const { filename, name } = message;
|
||||
(async function() {
|
||||
if (filename !== null) {
|
||||
await getHandler(filename, name);
|
||||
}
|
||||
send({
|
||||
ready: true,
|
||||
source: "pool",
|
||||
__tinypool_worker_message__: true
|
||||
});
|
||||
})().catch(throwInNextTick);
|
||||
return;
|
||||
}
|
||||
if (message.source === "port") {
|
||||
return onMessage(message).catch(throwInNextTick);
|
||||
}
|
||||
throw new Error(`Unexpected TinypoolWorkerMessage ${JSON.stringify(message)}`);
|
||||
});
|
||||
async function onMessage(message) {
|
||||
const { taskId, task, filename, name } = message;
|
||||
let response;
|
||||
try {
|
||||
const handler = await getHandler(filename, name);
|
||||
if (handler === null) {
|
||||
throw new Error(`No handler function exported from ${filename}`);
|
||||
}
|
||||
const result = await handler(task);
|
||||
response = {
|
||||
source: "port",
|
||||
__tinypool_worker_message__: true,
|
||||
taskId,
|
||||
result,
|
||||
error: null,
|
||||
usedMemory: memoryUsage().heapUsed
|
||||
};
|
||||
if (stdout()?.writableLength > 0) {
|
||||
await new Promise((resolve) => process.stdout.write("", resolve));
|
||||
}
|
||||
if (stderr()?.writableLength > 0) {
|
||||
await new Promise((resolve) => process.stderr.write("", resolve));
|
||||
}
|
||||
} catch (error) {
|
||||
response = {
|
||||
source: "port",
|
||||
__tinypool_worker_message__: true,
|
||||
taskId,
|
||||
result: null,
|
||||
error: serializeError(error),
|
||||
usedMemory: memoryUsage().heapUsed
|
||||
};
|
||||
}
|
||||
send(response);
|
||||
}
|
||||
function serializeError(error) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
...error,
|
||||
name: error.name,
|
||||
stack: error.stack,
|
||||
message: error.message
|
||||
};
|
||||
}
|
||||
return String(error);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
import {
|
||||
getHandler,
|
||||
throwInNextTick
|
||||
} from "../chunk-DSRZHYCS.js";
|
||||
import "../chunk-T6A5DJAH.js";
|
||||
export {
|
||||
getHandler,
|
||||
throwInNextTick
|
||||
};
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
import {
|
||||
isMovable,
|
||||
kRequestCountField,
|
||||
kResponseCountField,
|
||||
kTransferable,
|
||||
kValue
|
||||
} from "../chunk-FJA3Y3DX.js";
|
||||
import {
|
||||
stderr,
|
||||
stdout
|
||||
} from "../chunk-OECBSOR6.js";
|
||||
import {
|
||||
getHandler,
|
||||
throwInNextTick
|
||||
} from "../chunk-DSRZHYCS.js";
|
||||
import "../chunk-T6A5DJAH.js";
|
||||
|
||||
// src/entry/worker.ts
|
||||
import {
|
||||
parentPort,
|
||||
receiveMessageOnPort,
|
||||
workerData as tinypoolData
|
||||
} from "worker_threads";
|
||||
var [tinypoolPrivateData, workerData] = tinypoolData;
|
||||
process.__tinypool_state__ = {
|
||||
isWorkerThread: true,
|
||||
isTinypoolWorker: true,
|
||||
workerData,
|
||||
workerId: tinypoolPrivateData.workerId
|
||||
};
|
||||
var memoryUsage = process.memoryUsage.bind(process);
|
||||
var useAtomics = process.env.PISCINA_DISABLE_ATOMICS !== "1";
|
||||
parentPort.on("message", (message) => {
|
||||
useAtomics = process.env.PISCINA_DISABLE_ATOMICS === "1" ? false : message.useAtomics;
|
||||
const { port, sharedBuffer, filename, name } = message;
|
||||
(async function() {
|
||||
if (filename !== null) {
|
||||
await getHandler(filename, name);
|
||||
}
|
||||
const readyMessage = { ready: true };
|
||||
parentPort.postMessage(readyMessage);
|
||||
port.on("message", onMessage.bind(null, port, sharedBuffer));
|
||||
atomicsWaitLoop(port, sharedBuffer);
|
||||
})().catch(throwInNextTick);
|
||||
});
|
||||
var currentTasks = 0;
|
||||
var lastSeenRequestCount = 0;
|
||||
function atomicsWaitLoop(port, sharedBuffer) {
|
||||
if (!useAtomics)
|
||||
return;
|
||||
while (currentTasks === 0) {
|
||||
Atomics.wait(sharedBuffer, kRequestCountField, lastSeenRequestCount);
|
||||
lastSeenRequestCount = Atomics.load(sharedBuffer, kRequestCountField);
|
||||
let entry;
|
||||
while ((entry = receiveMessageOnPort(port)) !== void 0) {
|
||||
onMessage(port, sharedBuffer, entry.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
function onMessage(port, sharedBuffer, message) {
|
||||
currentTasks++;
|
||||
const { taskId, task, filename, name } = message;
|
||||
(async function() {
|
||||
let response;
|
||||
let transferList = [];
|
||||
try {
|
||||
const handler = await getHandler(filename, name);
|
||||
if (handler === null) {
|
||||
throw new Error(`No handler function exported from ${filename}`);
|
||||
}
|
||||
let result = await handler(task);
|
||||
if (isMovable(result)) {
|
||||
transferList = transferList.concat(result[kTransferable]);
|
||||
result = result[kValue];
|
||||
}
|
||||
response = {
|
||||
taskId,
|
||||
result,
|
||||
error: null,
|
||||
usedMemory: memoryUsage().heapUsed
|
||||
};
|
||||
if (stdout()?.writableLength > 0) {
|
||||
await new Promise((resolve) => process.stdout.write("", resolve));
|
||||
}
|
||||
if (stderr()?.writableLength > 0) {
|
||||
await new Promise((resolve) => process.stderr.write("", resolve));
|
||||
}
|
||||
} catch (error) {
|
||||
response = {
|
||||
taskId,
|
||||
result: null,
|
||||
error,
|
||||
usedMemory: memoryUsage().heapUsed
|
||||
};
|
||||
}
|
||||
currentTasks--;
|
||||
port.postMessage(response, transferList);
|
||||
Atomics.add(sharedBuffer, kResponseCountField, 1);
|
||||
atomicsWaitLoop(port, sharedBuffer);
|
||||
})().catch(throwInNextTick);
|
||||
}
|
||||
+1050
File diff suppressed because it is too large
Load Diff
+216
@@ -0,0 +1,216 @@
|
||||
import { TransferListItem as TransferListItem$1, MessagePort } from 'worker_threads';
|
||||
import { EventEmitter } from 'events';
|
||||
import { AsyncResource } from 'async_hooks';
|
||||
|
||||
declare const kEventEmitter: unique symbol;
|
||||
declare const kAsyncResource: unique symbol;
|
||||
declare type EventEmitterOptions = typeof EventEmitter extends {
|
||||
new (options?: infer T): EventEmitter;
|
||||
} ? T : never;
|
||||
declare type AsyncResourceOptions = typeof AsyncResource extends {
|
||||
new (name: string, options?: infer T): AsyncResource;
|
||||
} ? T : never;
|
||||
declare type Options$1 = EventEmitterOptions & AsyncResourceOptions & {
|
||||
name?: string;
|
||||
};
|
||||
declare class EventEmitterReferencingAsyncResource extends AsyncResource {
|
||||
[kEventEmitter]: EventEmitter;
|
||||
constructor(ee: EventEmitter, type: string, options?: AsyncResourceOptions);
|
||||
get eventEmitter(): EventEmitter;
|
||||
}
|
||||
declare class EventEmitterAsyncResource extends EventEmitter {
|
||||
[kAsyncResource]: EventEmitterReferencingAsyncResource;
|
||||
constructor(options?: Options$1 | string);
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emitDestroy(): void;
|
||||
asyncId(): number;
|
||||
triggerAsyncId(): number;
|
||||
get asyncResource(): EventEmitterReferencingAsyncResource;
|
||||
static get EventEmitterAsyncResource(): typeof EventEmitterAsyncResource;
|
||||
}
|
||||
|
||||
/** Channel for communicating between main thread and workers */
|
||||
interface TinypoolChannel {
|
||||
/** Workers subscribing to messages */
|
||||
onMessage(callback: (message: any) => void): void;
|
||||
/** Called with worker's messages */
|
||||
postMessage(message: any): void;
|
||||
}
|
||||
interface TinypoolWorker {
|
||||
runtime: string;
|
||||
initialize(options: {
|
||||
env?: Record<string, string>;
|
||||
argv?: string[];
|
||||
execArgv?: string[];
|
||||
resourceLimits?: any;
|
||||
workerData: TinypoolData;
|
||||
trackUnmanagedFds?: boolean;
|
||||
}): void;
|
||||
terminate(): Promise<any>;
|
||||
postMessage(message: any, transferListItem?: TransferListItem$1[]): void;
|
||||
setChannel?: (channel: TinypoolChannel) => void;
|
||||
on(event: string, listener: (...args: any[]) => void): void;
|
||||
once(event: string, listener: (...args: any[]) => void): void;
|
||||
emit(event: string, ...data: any[]): void;
|
||||
ref?: () => void;
|
||||
unref?: () => void;
|
||||
threadId: number;
|
||||
}
|
||||
/**
|
||||
* Tinypool's internal messaging between main thread and workers.
|
||||
* - Utilizers can use `__tinypool_worker_message__` property to identify
|
||||
* these messages and ignore them.
|
||||
*/
|
||||
interface TinypoolWorkerMessage<T extends 'port' | 'pool' = 'port' | 'pool'> {
|
||||
__tinypool_worker_message__: true;
|
||||
source: T;
|
||||
}
|
||||
interface StartupMessage {
|
||||
filename: string | null;
|
||||
name: string;
|
||||
port: MessagePort;
|
||||
sharedBuffer: Int32Array;
|
||||
useAtomics: boolean;
|
||||
}
|
||||
interface RequestMessage {
|
||||
taskId: number;
|
||||
task: any;
|
||||
filename: string;
|
||||
name: string;
|
||||
}
|
||||
interface ReadyMessage {
|
||||
ready: true;
|
||||
}
|
||||
interface ResponseMessage {
|
||||
taskId: number;
|
||||
result: any;
|
||||
error: unknown | null;
|
||||
usedMemory: number;
|
||||
}
|
||||
interface TinypoolPrivateData {
|
||||
workerId: number;
|
||||
}
|
||||
declare type TinypoolData = [TinypoolPrivateData, any];
|
||||
declare const kTransferable: unique symbol;
|
||||
declare const kValue: unique symbol;
|
||||
declare const kQueueOptions: unique symbol;
|
||||
declare function isTransferable(value: any): boolean;
|
||||
declare function isMovable(value: any): boolean;
|
||||
declare function markMovable(value: object): void;
|
||||
interface Transferable {
|
||||
readonly [kTransferable]: object;
|
||||
readonly [kValue]: object;
|
||||
}
|
||||
interface Task {
|
||||
readonly [kQueueOptions]: object | null;
|
||||
cancel(): void;
|
||||
}
|
||||
interface TaskQueue {
|
||||
readonly size: number;
|
||||
shift(): Task | null;
|
||||
remove(task: Task): void;
|
||||
push(task: Task): void;
|
||||
cancel(): void;
|
||||
}
|
||||
declare function isTaskQueue(value: any): boolean;
|
||||
declare const kRequestCountField = 0;
|
||||
declare const kResponseCountField = 1;
|
||||
declare const kFieldCount = 2;
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface Process {
|
||||
__tinypool_state__: {
|
||||
isTinypoolWorker: boolean;
|
||||
isWorkerThread?: boolean;
|
||||
isChildProcess?: boolean;
|
||||
workerData: any;
|
||||
workerId: number;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
interface AbortSignalEventTargetAddOptions {
|
||||
once: boolean;
|
||||
}
|
||||
interface AbortSignalEventTarget {
|
||||
addEventListener: (name: 'abort', listener: () => void, options?: AbortSignalEventTargetAddOptions) => void;
|
||||
removeEventListener: (name: 'abort', listener: () => void) => void;
|
||||
aborted?: boolean;
|
||||
}
|
||||
interface AbortSignalEventEmitter {
|
||||
off: (name: 'abort', listener: () => void) => void;
|
||||
once: (name: 'abort', listener: () => void) => void;
|
||||
}
|
||||
declare type AbortSignalAny = AbortSignalEventTarget | AbortSignalEventEmitter;
|
||||
declare type ResourceLimits = Worker extends {
|
||||
resourceLimits?: infer T;
|
||||
} ? T : {};
|
||||
interface Options {
|
||||
filename?: string | null;
|
||||
runtime?: 'worker_threads' | 'child_process';
|
||||
name?: string;
|
||||
minThreads?: number;
|
||||
maxThreads?: number;
|
||||
idleTimeout?: number;
|
||||
terminateTimeout?: number;
|
||||
maxQueue?: number | 'auto';
|
||||
concurrentTasksPerWorker?: number;
|
||||
useAtomics?: boolean;
|
||||
resourceLimits?: ResourceLimits;
|
||||
maxMemoryLimitBeforeRecycle?: number;
|
||||
argv?: string[];
|
||||
execArgv?: string[];
|
||||
env?: Record<string, string>;
|
||||
workerData?: any;
|
||||
taskQueue?: TaskQueue;
|
||||
trackUnmanagedFds?: boolean;
|
||||
isolateWorkers?: boolean;
|
||||
}
|
||||
interface FilledOptions extends Options {
|
||||
filename: string | null;
|
||||
name: string;
|
||||
runtime: NonNullable<Options['runtime']>;
|
||||
minThreads: number;
|
||||
maxThreads: number;
|
||||
idleTimeout: number;
|
||||
maxQueue: number;
|
||||
concurrentTasksPerWorker: number;
|
||||
useAtomics: boolean;
|
||||
taskQueue: TaskQueue;
|
||||
}
|
||||
interface RunOptions {
|
||||
transferList?: TransferList;
|
||||
channel?: TinypoolChannel;
|
||||
filename?: string | null;
|
||||
signal?: AbortSignalAny | null;
|
||||
name?: string | null;
|
||||
runtime?: Options['runtime'];
|
||||
}
|
||||
declare type TransferList = MessagePort extends {
|
||||
postMessage(value: any, transferList: infer T): any;
|
||||
} ? T : never;
|
||||
declare type TransferListItem = TransferList extends (infer T)[] ? T : never;
|
||||
declare class Tinypool extends EventEmitterAsyncResource {
|
||||
#private;
|
||||
constructor(options?: Options);
|
||||
run(task: any, options?: RunOptions): Promise<any>;
|
||||
destroy(): Promise<void>;
|
||||
get options(): FilledOptions;
|
||||
get threads(): TinypoolWorker[];
|
||||
get queueSize(): number;
|
||||
cancelPendingTasks(): void;
|
||||
recycleWorkers(options?: Pick<Options, 'runtime'>): Promise<void>;
|
||||
get completed(): number;
|
||||
get duration(): number;
|
||||
static get isWorkerThread(): boolean;
|
||||
static get workerData(): any;
|
||||
static get version(): string;
|
||||
static move(val: Transferable | TransferListItem | ArrayBufferView | ArrayBuffer | MessagePort): MessagePort | ArrayBuffer | Transferable | ArrayBufferView;
|
||||
static get transferableSymbol(): symbol;
|
||||
static get valueSymbol(): symbol;
|
||||
static get queueOptionsSymbol(): symbol;
|
||||
}
|
||||
declare const _workerId: number;
|
||||
|
||||
export { Options, ReadyMessage, RequestMessage, ResponseMessage, StartupMessage, Task, TaskQueue, Tinypool, TinypoolChannel, TinypoolData, TinypoolPrivateData, TinypoolWorker, TinypoolWorkerMessage, Transferable, Tinypool as default, isMovable, isTaskQueue, isTransferable, kFieldCount, kQueueOptions, kRequestCountField, kResponseCountField, kTransferable, kValue, markMovable, _workerId as workerId };
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "tinypool",
|
||||
"version": "0.8.4",
|
||||
"description": "A minimal and tiny Node.js Worker Thread Pool implementation, a fork of piscina, but with fewer features",
|
||||
"type": "module",
|
||||
"main": "./dist/esm/index.js",
|
||||
"module": "./dist/esm/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**"
|
||||
],
|
||||
"packageManager": "pnpm@8.4.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tinylibs/tinypool.git"
|
||||
},
|
||||
"keywords": [
|
||||
"fast",
|
||||
"worker threads",
|
||||
"thread pool"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tinylibs/tinypool/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tinylibs/tinypool#readme",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user