osra 0.5.3 → 0.5.5
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/README.md +31 -31
- package/build/connections/utils.d.ts +2 -2
- package/build/index.js +13 -6
- package/build/index.js.map +1 -1
- package/build/revivables/abort-signal.d.ts +1 -1
- package/build/revivables/identity.d.ts +1 -1
- package/build/revivables/transfer.d.ts +1 -1
- package/build/types.d.ts +1 -1
- package/build/utils/event-channel.d.ts +3 -1
- package/build/utils/gc-tracker.d.ts +1 -1
- package/build/utils/transport.d.ts +7 -2
- package/build/utils/type-guards.d.ts +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ type AbortMessage = {
|
|
|
9
9
|
export type BoxedAbortSignal = BoxBaseType<typeof type> & {
|
|
10
10
|
aborted: boolean;
|
|
11
11
|
reason?: Capable;
|
|
12
|
-
/** Absent when the signal was already aborted at box time
|
|
12
|
+
/** Absent when the signal was already aborted at box time - the reason
|
|
13
13
|
* rides the wrapper and no live channel is needed. */
|
|
14
14
|
port?: BoxedMessagePort<AbortMessage>;
|
|
15
15
|
};
|
|
@@ -20,7 +20,7 @@ export type BoxedIdentity<T extends Capable = Capable> = BoxBaseType<typeof type
|
|
|
20
20
|
};
|
|
21
21
|
/** Wrap a value so osra preserves reference identity across the RPC
|
|
22
22
|
* boundary. Idempotent; primitives pass through unchanged. Lies at the
|
|
23
|
-
* type level
|
|
23
|
+
* type level - runtime value is an IdentityWrapper<T> typed as T. */
|
|
24
24
|
export declare const identity: <T>(value: T) => T;
|
|
25
25
|
export declare const isType: (value: unknown) => value is IdentityWrapper;
|
|
26
26
|
export declare const box: <T extends Capable, TContext extends RevivableContext>(wrapper: IdentityWrapper<T>, context: TContext) => BoxedIdentity<T>;
|
|
@@ -14,7 +14,7 @@ export type BoxedTransfer<T extends Capable = Capable> = BoxBaseType<typeof type
|
|
|
14
14
|
/** Opt into transfer (move) semantics for a transferable value. Idempotent;
|
|
15
15
|
* non-transferable inputs pass through unchanged. Silently degrades to a
|
|
16
16
|
* copy when the platform/transport can't transfer the given type. Lies at
|
|
17
|
-
* the type level
|
|
17
|
+
* the type level - runtime value is a TransferWrapper<T> typed as T. */
|
|
18
18
|
export declare const transfer: <T>(value: T) => T;
|
|
19
19
|
export declare const isType: (value: unknown) => value is TransferWrapper;
|
|
20
20
|
export declare const box: <T extends Capable, TContext extends RevivableContext>(wrapper: TransferWrapper<T>, context: TContext) => BoxedTransfer<T>;
|
package/build/types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type Structurable = Jsonable
|
|
|
17
17
|
export type StructurableTransferable = Structurable | Transferable | {
|
|
18
18
|
[key: string]: StructurableTransferable;
|
|
19
19
|
} | Array<StructurableTransferable> | Map<StructurableTransferable, StructurableTransferable> | Set<StructurableTransferable>;
|
|
20
|
-
/** "Free" types in `Capable`
|
|
20
|
+
/** "Free" types in `Capable` - narrows to `Jsonable` on JSON transports so
|
|
21
21
|
* user code can't type a `Date`/`Blob`/etc. that JSON would silently coerce.
|
|
22
22
|
* Modules that DO support JSON (date, map, set, bigint, …) put their type
|
|
23
23
|
* back via `InferRevivables`. */
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TypedMessagePort, TypedMessagePortEventMap } from './typed-message-channel.js';
|
|
2
|
-
export declare class EventPort<T>
|
|
2
|
+
export declare class EventPort<T> {
|
|
3
|
+
private _listeners;
|
|
4
|
+
private _onceListeners;
|
|
3
5
|
addEventListener<K extends keyof TypedMessagePortEventMap<T> & string>(type: K, listener: ((event: TypedMessagePortEventMap<T>[K]) => void) | null, options?: boolean | AddEventListenerOptions): void;
|
|
4
6
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
|
|
5
7
|
removeEventListener<K extends keyof TypedMessagePortEventMap<T> & string>(type: K, listener: ((event: TypedMessagePortEventMap<T>[K]) => void) | null, options?: boolean | EventListenerOptions): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Run `cleanup` after `target` is garbage-collected. Returns a handle to
|
|
3
3
|
* cancel the tracking before that happens.
|
|
4
4
|
*
|
|
5
|
-
* Backed by a single shared FinalizationRegistry
|
|
5
|
+
* Backed by a single shared FinalizationRegistry - every revivable that
|
|
6
6
|
* needs FR semantics goes through this so the boilerplate (token,
|
|
7
7
|
* unregister, cycle-safety contract) lives in one place.
|
|
8
8
|
*
|
|
@@ -33,8 +33,13 @@ export type ReceiveJsonPlatformTransport = WebSocket | WebExtPort | WebExtOnConn
|
|
|
33
33
|
export type JsonPlatformTransport = {
|
|
34
34
|
isJson: true;
|
|
35
35
|
} | EmitJsonPlatformTransport | ReceiveJsonPlatformTransport;
|
|
36
|
-
export type
|
|
37
|
-
|
|
36
|
+
export type WorkerSelf = {
|
|
37
|
+
postMessage(...args: any[]): void;
|
|
38
|
+
addEventListener(type: string, listener: (event: any) => void): void;
|
|
39
|
+
removeEventListener(type: string, listener: (event: any) => void): void;
|
|
40
|
+
};
|
|
41
|
+
export type EmitPlatformTransport = EmitJsonPlatformTransport | Window | ServiceWorker | Worker | SharedWorker | MessagePort | WorkerSelf;
|
|
42
|
+
export type ReceivePlatformTransport = ReceiveJsonPlatformTransport | Window | ServiceWorkerContainer | Worker | SharedWorker | MessagePort | WorkerSelf;
|
|
38
43
|
export type PlatformTransport = EmitPlatformTransport | ReceivePlatformTransport;
|
|
39
44
|
export type EmitTransport = EmitPlatformTransport | CustomEmitTransport;
|
|
40
45
|
export type ReceiveTransport = ReceivePlatformTransport | CustomReceiveTransport;
|
|
@@ -37,7 +37,7 @@ type AnyConstructor = abstract new (...args: any[]) => unknown;
|
|
|
37
37
|
* Tolerates undefined entries (constructors missing on this platform). */
|
|
38
38
|
export declare const instanceOfAny: (value: unknown, ctors: readonly (AnyConstructor | undefined)[]) => boolean;
|
|
39
39
|
export declare const isSharedArrayBuffer: (value: unknown) => boolean;
|
|
40
|
-
/** @deprecated Renamed
|
|
40
|
+
/** @deprecated Renamed - this only ever checked SharedArrayBuffer, unlike
|
|
41
41
|
* the unrelated clonable fallback module. Use isSharedArrayBuffer. */
|
|
42
42
|
export declare const isClonable: (value: unknown) => boolean;
|
|
43
43
|
export declare const isTransferable: (value: unknown) => value is Transferable;
|