@ricsam/isolate-client 0.1.15 → 0.1.16

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.
@@ -59,6 +59,8 @@ export interface DaemonConnection {
59
59
  export interface RuntimeOptions<T extends Record<string, any[]> = Record<string, unknown[]>> extends BaseRuntimeOptions<T> {
60
60
  /** File system callback handlers */
61
61
  fs?: FileSystemCallbacks;
62
+ /** Register callback for WebSocket commands from isolate at runtime creation time */
63
+ onWebSocketCommand?: (cmd: WebSocketCommand) => void;
62
64
  }
63
65
  /**
64
66
  * WebSocket upgrade request info.
@@ -149,6 +151,19 @@ export interface RemoteRuntime {
149
151
  * @param filenameOrOptions - Optional filename or eval options
150
152
  */
151
153
  eval(code: string, filenameOrOptions?: string | EvalOptions): Promise<void>;
154
+ /**
155
+ * Listen for events emitted from isolate code (via __emit).
156
+ * @param event - The event name to listen for
157
+ * @param callback - Called when the event is received
158
+ * @returns Unsubscribe function
159
+ */
160
+ on(event: string, callback: (payload: unknown) => void): () => void;
161
+ /**
162
+ * Emit an event to the isolate (received via __on in isolate code).
163
+ * @param event - The event name
164
+ * @param payload - The event payload (must be JSON-serializable)
165
+ */
166
+ emit(event: string, payload: unknown): void;
152
167
  /** Dispose the runtime */
153
168
  dispose(): Promise<void>;
154
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/isolate-client",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "main": "./dist/cjs/index.cjs",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "exports": {