@computekit/core 0.1.2 → 0.1.3

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.
@@ -1,145 +0,0 @@
1
- /**
2
- * ComputeKit Core Types
3
- * Type definitions for the WASM + Worker toolkit
4
- */
5
- /** Configuration options for ComputeKit */
6
- interface ComputeKitOptions {
7
- /** Maximum number of workers in the pool (default: navigator.hardwareConcurrency || 4) */
8
- maxWorkers?: number;
9
- /** Timeout for compute operations in milliseconds (default: 30000) */
10
- timeout?: number;
11
- /** Enable debug logging (default: false) */
12
- debug?: boolean;
13
- /** Custom path to worker script */
14
- workerPath?: string;
15
- /** Whether to use SharedArrayBuffer when available (default: true) */
16
- useSharedMemory?: boolean;
17
- /** Remote scripts to load in workers via importScripts */
18
- remoteDependencies?: string[];
19
- }
20
- /** Options for individual compute operations */
21
- interface ComputeOptions {
22
- /** Timeout for this specific operation (overrides global) */
23
- timeout?: number;
24
- /** Transfer these ArrayBuffers to the worker (improves performance) */
25
- transfer?: ArrayBuffer[];
26
- /** Priority level for scheduling (0-10, higher = more priority) */
27
- priority?: number;
28
- /** Abort signal to cancel the operation */
29
- signal?: AbortSignal;
30
- /** Progress callback for long-running operations */
31
- onProgress?: (progress: ComputeProgress) => void;
32
- }
33
- /** Progress information for compute operations */
34
- interface ComputeProgress {
35
- /** Progress percentage (0-100) */
36
- percent: number;
37
- /** Current step/phase name */
38
- phase?: string;
39
- /** Estimated time remaining in milliseconds */
40
- estimatedTimeRemaining?: number;
41
- /** Any additional data from the compute function */
42
- data?: unknown;
43
- }
44
- /** Result wrapper with metadata */
45
- interface ComputeResult<T> {
46
- /** The computed result */
47
- data: T;
48
- /** Time taken in milliseconds */
49
- duration: number;
50
- /** Whether the result came from cache */
51
- cached: boolean;
52
- /** Worker ID that processed this */
53
- workerId: string;
54
- }
55
- /** Function definition for registration */
56
- interface ComputeFunction<TInput = unknown, TOutput = unknown> {
57
- /** The compute function implementation */
58
- fn: (input: TInput) => TOutput | Promise<TOutput>;
59
- /** Optional WASM module to load */
60
- wasmModule?: WebAssembly.Module | ArrayBuffer | string;
61
- /** Whether this function supports progress reporting */
62
- supportsProgress?: boolean;
63
- }
64
- /** WASM module configuration */
65
- interface WasmModuleConfig {
66
- /** Path to the WASM file or base64 encoded WASM */
67
- source: string | ArrayBuffer;
68
- /** Imports to provide to the WASM module */
69
- imports?: WebAssembly.Imports;
70
- /** Memory configuration */
71
- memory?: {
72
- initial: number;
73
- maximum?: number;
74
- shared?: boolean;
75
- };
76
- }
77
- /** Worker state */
78
- type WorkerState = 'idle' | 'busy' | 'error' | 'terminated';
79
- /** Worker info */
80
- interface WorkerInfo {
81
- id: string;
82
- state: WorkerState;
83
- currentTask?: string;
84
- tasksCompleted: number;
85
- errors: number;
86
- createdAt: number;
87
- lastActiveAt: number;
88
- }
89
- /** Pool statistics */
90
- interface PoolStats {
91
- workers: WorkerInfo[];
92
- totalWorkers: number;
93
- activeWorkers: number;
94
- idleWorkers: number;
95
- queueLength: number;
96
- tasksCompleted: number;
97
- tasksFailed: number;
98
- averageTaskDuration: number;
99
- }
100
- /** Event data for worker:created */
101
- interface WorkerCreatedEvent {
102
- info: WorkerInfo;
103
- }
104
- /** Event data for worker:terminated */
105
- interface WorkerTerminatedEvent {
106
- info: WorkerInfo;
107
- }
108
- /** Event data for worker:error */
109
- interface WorkerErrorEvent {
110
- error: Error;
111
- info: WorkerInfo;
112
- }
113
- /** Event data for task:start */
114
- interface TaskStartEvent {
115
- taskId: string;
116
- functionName: string;
117
- }
118
- /** Event data for task:complete */
119
- interface TaskCompleteEvent {
120
- taskId: string;
121
- duration: number;
122
- }
123
- /** Event data for task:error */
124
- interface TaskErrorEvent {
125
- taskId: string;
126
- error: Error;
127
- }
128
- /** Event data for task:progress */
129
- interface TaskProgressEvent {
130
- taskId: string;
131
- progress: ComputeProgress;
132
- }
133
- /** Events emitted by ComputeKit */
134
- type ComputeKitEvents = {
135
- 'worker:created': WorkerCreatedEvent;
136
- 'worker:terminated': WorkerTerminatedEvent;
137
- 'worker:error': WorkerErrorEvent;
138
- 'task:start': TaskStartEvent;
139
- 'task:complete': TaskCompleteEvent;
140
- 'task:error': TaskErrorEvent;
141
- 'task:progress': TaskProgressEvent;
142
- [key: string]: unknown;
143
- };
144
-
145
- export type { ComputeKitOptions as C, PoolStats as P, WasmModuleConfig as W, ComputeOptions as a, ComputeKitEvents as b, ComputeResult as c, ComputeProgress as d, ComputeFunction as e, WorkerInfo as f };