osra 0.5.8 → 0.6.1
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 +4 -4
- package/build/connections/bidirectional.d.ts +6 -1
- package/build/index.js +505 -460
- package/build/index.js.map +1 -1
- package/build/revivables/fallbacks.d.ts +9 -2
- package/build/revivables/index.d.ts +6 -2
- package/build/types.d.ts +5 -5
- package/build/utils/event-channel.d.ts +0 -1
- package/package.json +5 -5
- package/build/revivables/blob.d.ts +0 -17
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ osra is a zero-runtime-dependency TypeScript RPC library that connects two JavaS
|
|
|
9
9
|
|
|
10
10
|
- **Zero runtime dependencies**: one ESM module
|
|
11
11
|
- **Symmetric API**: both sides call `expose()`; either side can pass functions, both can call
|
|
12
|
-
- **Deep type support**: functions, promises, async generators, `ReadableStream`/`WritableStream`, `MessagePort`, `AbortSignal`, `Error` subclasses, `
|
|
12
|
+
- **Deep type support**: functions, promises, async generators, `ReadableStream`/`WritableStream`, `MessagePort`, `AbortSignal`, `Error` subclasses, `File`/`FileList`, `Request`/`Response`, `Map`/`Set`, typed arrays, `BigInt`, `Symbol`, …
|
|
13
13
|
- **JSON-mode degradation**: the same value types work over text-only transports (WebSocket, extension messaging); `Date`, `Map`, typed arrays, even `NaN`/`±Infinity` survive
|
|
14
14
|
- **`identity()`** for reference-preserving sends, **`transfer()`** for zero-copy moves
|
|
15
15
|
- **Strict TypeScript**: `Remote<T>` maps your API type across the wire; a compile-time `Capable` check rejects non-serializable values with the offending path pinpointed
|
|
@@ -103,11 +103,11 @@ Transports are either **structured-clone** (Worker, Window, MessagePort, SharedW
|
|
|
103
103
|
| `WritableStream` | ✅ | ✅ | write/close/abort with acks; sink errors reject the writer |
|
|
104
104
|
| `MessagePort` | ✅ | ✅ | revives as a real `MessagePort` on both transport kinds |
|
|
105
105
|
| `AbortSignal` | ✅ | ✅ | abort and reason propagate |
|
|
106
|
-
| `
|
|
106
|
+
| `File` / `FileList` | ✅ | ❌ | revive as themselves via structured clone (clone transports only); `Blob` is **not** supported |
|
|
107
107
|
| `Request` / `Response` / `Headers` | ✅ | ✅ | streamed bodies; `Request.signal` propagates; `Response.url`/`redirected` restored; opaque status-0 revives as `Response.error()` |
|
|
108
108
|
| `Event` / `CustomEvent` | ✅ | ✅ | subclass fields beyond `detail` are dropped |
|
|
109
109
|
| `EventTarget` | ✅ | ✅ | revives as a listener-only façade: `add`/`removeEventListener` proxy to the source; you can't dispatch through it |
|
|
110
|
-
| Other structured-clonables (`
|
|
110
|
+
| Other structured-clonables (`ImageData`, `DOMRect`, `CryptoKey`, …) | ✅ | ❌ | pass through structured clone untouched |
|
|
111
111
|
| Transfer-only host objects (`OffscreenCanvas`, `MediaStreamTrack`, `RTCDataChannel`, …) | ✅ | ❌ | always moved to the peer |
|
|
112
112
|
| `ImageBitmap`, `VideoFrame`, `AudioData` | ✅ | ❌ | copied by structured clone; wrap in `transfer()` to move |
|
|
113
113
|
| `WeakMap` / `WeakSet`, other unclonables | ❌ | ❌ | coerce to `{}` at runtime, rejected at compile time |
|
|
@@ -284,7 +284,7 @@ controller.abort(new Error('shutting down'))
|
|
|
284
284
|
|
|
285
285
|
## TypeScript
|
|
286
286
|
|
|
287
|
-
`Remote<T>` is what the other side sees: functions become `(...args) => Promise<Awaited<R>>`,
|
|
287
|
+
`Remote<T>` is what the other side sees: functions become `(...args) => Promise<Awaited<R>>`, containers map recursively, platform objects revive as themselves.
|
|
288
288
|
|
|
289
289
|
`expose()` validates the value you pass at compile time against `Capable`, the union of everything serializable for the inferred transport (narrower on JSON transports). Failures pinpoint the offending path:
|
|
290
290
|
|
|
@@ -23,7 +23,7 @@ export type ConnectionRevivableContext<TModules extends readonly RevivableModule
|
|
|
23
23
|
revivableModules: TModules;
|
|
24
24
|
eventTarget: MessageEventTarget<TModules>;
|
|
25
25
|
};
|
|
26
|
-
export declare const startBidirectionalConnection: <TModules extends readonly RevivableModule[] = readonly [typeof import("../revivables/transfer.js"), typeof import("../revivables/identity.js"), typeof import("../revivables/array-buffer.js"), typeof import("../revivables/date.js"), typeof import("../revivables/headers.js"), typeof import("../revivables/error.js"), typeof import("../revivables/typed-array.js"), typeof import("../revivables/
|
|
26
|
+
export declare const startBidirectionalConnection: <TModules extends readonly RevivableModule[] = readonly [typeof import("../revivables/transfer.js"), typeof import("../revivables/identity.js"), typeof import("../revivables/array-buffer.js"), typeof import("../revivables/date.js"), typeof import("../revivables/headers.js"), typeof import("../revivables/error.js"), typeof import("../revivables/typed-array.js"), typeof import("../revivables/promise.js"), typeof import("../revivables/function.js"), typeof import("../revivables/message-port.js"), typeof import("../revivables/readable-stream.js"), typeof import("../revivables/writable-stream.js"), typeof import("../revivables/abort-signal.js"), typeof import("../revivables/response.js"), typeof import("../revivables/request.js"), typeof import("../revivables/map.js"), typeof import("../revivables/set.js"), typeof import("../revivables/bigint.js"), typeof import("../revivables/symbol.js"), typeof import("../revivables/event.js"), typeof import("../revivables/async-iterator.js"), {
|
|
27
27
|
readonly type: 'nonFiniteNumber';
|
|
28
28
|
readonly isType: (value: unknown) => value is number;
|
|
29
29
|
readonly box: (value: number, context: import("../index.js").RevivableContext<any>) => import("../revivables/json-primitives.js").BoxedNonFiniteNumber | number;
|
|
@@ -45,6 +45,11 @@ export declare const startBidirectionalConnection: <TModules extends readonly Re
|
|
|
45
45
|
readonly isType: (value: unknown) => value is import("../revivables/fallbacks.js").Transferable;
|
|
46
46
|
readonly box: (value: import("../revivables/fallbacks.js").Transferable, _context: import("../index.js").RevivableContext<any>) => import("../revivables/fallbacks.js").Transferable;
|
|
47
47
|
readonly revive: (value: import("../revivables/fallbacks.js").BoxedTransferable, _context: import("../index.js").RevivableContext<any>) => import("../revivables/fallbacks.js").Transferable;
|
|
48
|
+
}, {
|
|
49
|
+
readonly type: 'blobGuard';
|
|
50
|
+
readonly isType: (value: unknown) => value is never;
|
|
51
|
+
readonly box: (value: never, context: import("../index.js").RevivableContext<any>) => Blob;
|
|
52
|
+
readonly revive: (value: import("../revivables/fallbacks.js").BoxedBlobGuard, _context: import("../index.js").RevivableContext<any>) => Blob;
|
|
48
53
|
}, typeof import("../revivables/event-target.js"), {
|
|
49
54
|
readonly type: 'unclonable';
|
|
50
55
|
readonly isType: (value: unknown) => value is never;
|