@xentobias/worker-rpc 1.0.2 → 1.0.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.
- package/package.json +1 -1
- package/dist/channel.d.ts +0 -55
- package/dist/channel.d.ts.map +0 -1
- package/dist/serialize.d.ts +0 -37
- package/dist/serialize.d.ts.map +0 -1
package/package.json
CHANGED
package/dist/channel.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worker RPC - Channel Module
|
|
3
|
-
* Direct worker-to-worker communication without routing through main thread
|
|
4
|
-
*/
|
|
5
|
-
import { Endpoint } from "./endpoint";
|
|
6
|
-
import { type MessageTarget, type EndpointOptions, type RemoteObject } from "./types";
|
|
7
|
-
/** Unique identifier for workers */
|
|
8
|
-
export type WorkerId = string;
|
|
9
|
-
/** Worker registry for managing direct channels */
|
|
10
|
-
export interface WorkerRegistry {
|
|
11
|
-
/** Register a worker with an ID */
|
|
12
|
-
register(id: WorkerId, worker: MessageTarget): void;
|
|
13
|
-
/** Unregister a worker */
|
|
14
|
-
unregister(id: WorkerId): void;
|
|
15
|
-
/** Get a direct channel to another worker */
|
|
16
|
-
getChannel<T extends object>(targetId: WorkerId): Promise<RemoteObject<T>>;
|
|
17
|
-
/** Release all channels */
|
|
18
|
-
releaseAll(): void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create a worker registry for the main thread
|
|
22
|
-
* This allows workers to establish direct communication channels
|
|
23
|
-
*/
|
|
24
|
-
export declare function createRegistry(): WorkerRegistry;
|
|
25
|
-
/**
|
|
26
|
-
* Create a direct channel from within a worker to another worker
|
|
27
|
-
* This bypasses the main thread for all subsequent communication
|
|
28
|
-
*/
|
|
29
|
-
export declare function createWorkerChannel<T extends object>(mainThreadEndpoint: Endpoint, targetWorkerId: WorkerId, options?: EndpointOptions): Promise<RemoteObject<T>>;
|
|
30
|
-
/**
|
|
31
|
-
* Accept a channel connection from another worker
|
|
32
|
-
* Call this in the worker that receives the channel request
|
|
33
|
-
*/
|
|
34
|
-
export declare function acceptChannel<T extends object>(port: MessagePort, api: T, options?: EndpointOptions): RemoteObject<T>;
|
|
35
|
-
/**
|
|
36
|
-
* Set up a worker to handle incoming channel requests
|
|
37
|
-
*/
|
|
38
|
-
export declare function setupChannelHandler(mainThread: MessageTarget, getApi: () => object, options?: EndpointOptions): void;
|
|
39
|
-
/**
|
|
40
|
-
* Peer-to-peer channel utilities
|
|
41
|
-
*/
|
|
42
|
-
export declare class PeerChannel<T extends object> {
|
|
43
|
-
private endpoint;
|
|
44
|
-
private remote;
|
|
45
|
-
constructor(port: MessagePort, localApi: object, options?: EndpointOptions);
|
|
46
|
-
/** Get the remote API proxy */
|
|
47
|
-
getRemote(): RemoteObject<T>;
|
|
48
|
-
/** Release this channel */
|
|
49
|
-
release(): void;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Create a pair of connected peer channels for testing or in-process communication
|
|
53
|
-
*/
|
|
54
|
-
export declare function createPeerPair<A extends object, B extends object>(apiA: A, apiB: B, options?: EndpointOptions): [RemoteObject<B>, RemoteObject<A>];
|
|
55
|
-
//# sourceMappingURL=channel.d.ts.map
|
package/dist/channel.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAkB,MAAM,YAAY,CAAC;AAEtD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,SAAS,CAAC;AAEjB,oCAAoC;AACpC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,mDAAmD;AACnD,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IACpD,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AAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,eAAe,GACxB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAapC"}
|
package/dist/serialize.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worker RPC - Serialization Module
|
|
3
|
-
* Minimal serialization - only handles Error objects for name/stack preservation
|
|
4
|
-
* All other data passes through structured clone directly
|
|
5
|
-
*/
|
|
6
|
-
/** Serialized error for transmission */
|
|
7
|
-
export interface SerializedError {
|
|
8
|
-
/** Error message */
|
|
9
|
-
e: string;
|
|
10
|
-
/** Error name (e.g., "TypeError") */
|
|
11
|
-
n: string;
|
|
12
|
-
/** Error stack trace */
|
|
13
|
-
s?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Serialize an Error object for transmission
|
|
17
|
-
* Preserves name and stack which structured clone doesn't handle well
|
|
18
|
-
*/
|
|
19
|
-
export declare function serializeError(error: Error): SerializedError;
|
|
20
|
-
/**
|
|
21
|
-
* Deserialize an error from transmission
|
|
22
|
-
* Reconstructs the Error with proper name and stack
|
|
23
|
-
*/
|
|
24
|
-
export declare function deserializeError(data: SerializedError): Error;
|
|
25
|
-
/**
|
|
26
|
-
* Check if a value is a function
|
|
27
|
-
*/
|
|
28
|
-
export declare function isFunction(value: unknown): value is Function;
|
|
29
|
-
/**
|
|
30
|
-
* Check if a value is a MessagePort
|
|
31
|
-
*/
|
|
32
|
-
export declare function isMessagePort(value: unknown): value is MessagePort;
|
|
33
|
-
/**
|
|
34
|
-
* Check if a value is transferable (ArrayBuffer or MessagePort)
|
|
35
|
-
*/
|
|
36
|
-
export declare function isTransferable(value: unknown): value is Transferable;
|
|
37
|
-
//# sourceMappingURL=serialize.d.ts.map
|
package/dist/serialize.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,oBAAoB;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,wBAAwB;IACxB,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAM5D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,KAAK,CAO7D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAKlE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAKpE"}
|