// WARNING: if you change this file, do the same changes in zenid-worker.ts and zenid-worker-st.js export enum ActionType { Init = 'init', // Start the worker initialization Call = 'call', // Call any exported WASM function universally Terminate = 'terminate', // Terminate the worker } // --- Incoming Message Interfaces --- export class WorkerInitAction { readonly action = ActionType.Init; } // --- Incoming Message Interfaces --- export class WorkerTerminateAction { readonly action = ActionType.Terminate; } export class WorkerCallAction { readonly action = ActionType.Call; constructor( public id: number | string, public functionName: string, public params: any[], public transferables?: ArrayBuffer[] ) {} } // Union type for incoming actions export type WorkerIncomingAction = WorkerInitAction | WorkerCallAction | WorkerTerminateAction; // --- Outgoing Message Interfaces --- export enum WorkerResponseType { Result = 'result', // Result of a successful 'Call' Error = 'error', // Error occurred during initialization or processing Initialized = 'initialized', // Worker setup complete, WASM runtime ready in proxied thread Log = 'log', // For sending log messages } export interface WorkerResponse { type: WorkerResponseType; id?: number | string; // For call results or errors result?: any; // For successful call results logMessage?: string; // For log messages logLevel?: number; // For log messages functionName?: string; // For error messages error?: string; // For error messages }