@ricsam/isolate-client 0.1.14 → 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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Types for the isolate client.
3
3
  */
4
- import type { RunTestsResult, TestResult as ProtocolTestResult, TestInfo as ProtocolTestInfo, TestError as ProtocolTestError, TestEvent as ProtocolTestEvent, SuiteInfo as ProtocolSuiteInfo, SuiteResult as ProtocolSuiteResult, CollectedData as ProtocolCollectedData, ConsoleEntry as ProtocolConsoleEntry, PlaywrightEvent as ProtocolPlaywrightEvent, CustomFunctionType, EvalOptions as ProtocolEvalOptions, TestEnvironmentOptions as ProtocolTestEnvironmentOptions, PlaywrightOptions as ProtocolPlaywrightOptions, BaseRuntimeOptions, ConsoleCallbacks, FetchCallback, FileSystemCallbacks, ModuleLoaderCallback, CustomFunction, CustomAsyncGeneratorFunction, CustomFunctionDefinition, CustomFunctions, DispatchOptions } from "@ricsam/isolate-protocol";
4
+ import type { RunTestsResult, TestResult as ProtocolTestResult, TestInfo as ProtocolTestInfo, TestError as ProtocolTestError, TestEvent as ProtocolTestEvent, SuiteInfo as ProtocolSuiteInfo, SuiteResult as ProtocolSuiteResult, CollectedData as ProtocolCollectedData, ConsoleEntry as ProtocolConsoleEntry, PlaywrightEvent as ProtocolPlaywrightEvent, CustomFunctionType, EvalOptions as ProtocolEvalOptions, TestEnvironmentOptions as ProtocolTestEnvironmentOptions, PlaywrightOptions as ProtocolPlaywrightOptions, BaseRuntimeOptions, ConsoleCallbacks, FetchCallback, WebSocketCallback, FileSystemCallbacks, ModuleLoaderCallback, ModuleLoaderResult, CustomFunction, CustomAsyncGeneratorFunction, CustomFunctionDefinition, CustomFunctions, DispatchOptions } from "@ricsam/isolate-protocol";
5
5
  export type RunResults = RunTestsResult;
6
6
  export type TestResult = ProtocolTestResult;
7
7
  export type TestInfo = ProtocolTestInfo;
@@ -15,7 +15,7 @@ export type PlaywrightEvent = ProtocolPlaywrightEvent;
15
15
  export type EvalOptions = ProtocolEvalOptions;
16
16
  export type TestEnvironmentOptions = ProtocolTestEnvironmentOptions;
17
17
  export type PlaywrightOptions = ProtocolPlaywrightOptions;
18
- export type { ConsoleCallbacks, FetchCallback, FileSystemCallbacks, ModuleLoaderCallback, CustomFunction, CustomAsyncGeneratorFunction, CustomFunctionDefinition, CustomFunctions, CustomFunctionType, DispatchOptions, };
18
+ export type { ConsoleCallbacks, FetchCallback, WebSocketCallback, FileSystemCallbacks, ModuleLoaderCallback, ModuleLoaderResult, CustomFunction, CustomAsyncGeneratorFunction, CustomFunctionDefinition, CustomFunctions, CustomFunctionType, DispatchOptions, };
19
19
  /**
20
20
  * Options for connecting to the daemon.
21
21
  */
@@ -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.
@@ -130,10 +132,6 @@ export interface RemoteConsoleHandle {
130
132
  export interface RemoteRuntime {
131
133
  /** Unique runtime identifier */
132
134
  readonly id: string;
133
- /**
134
- * @deprecated Use id instead
135
- */
136
- readonly isolateId: string;
137
135
  /** True if runtime was reused from namespace pool */
138
136
  readonly reused?: boolean;
139
137
  /** Fetch handle - access to fetch/serve operations */
@@ -150,13 +148,22 @@ export interface RemoteRuntime {
150
148
  * Execute code as ES module in the isolate.
151
149
  * Supports top-level await.
152
150
  * @param code - The code to execute
153
- * @param filename - Optional filename for stack traces
151
+ * @param filenameOrOptions - Optional filename or eval options
152
+ */
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
154
159
  */
155
- eval(code: string, filename?: string): Promise<void>;
160
+ on(event: string, callback: (payload: unknown) => void): () => void;
156
161
  /**
157
- * @deprecated Use the new signature: eval(code: string, filename?: string)
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)
158
165
  */
159
- eval(code: string, options?: EvalOptions): Promise<void>;
166
+ emit(event: string, payload: unknown): void;
160
167
  /** Dispose the runtime */
161
168
  dispose(): Promise<void>;
162
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/isolate-client",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "main": "./dist/cjs/index.cjs",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "exports": {