reactor-effect-native 0.2.0 → 0.3.0-rc.0

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.
Files changed (63) hide show
  1. package/Dockerfile +4 -2
  2. package/README.md +90 -15
  3. package/dist/_internal/bridge.d.ts +70 -14
  4. package/dist/_internal/bridge.d.ts.map +1 -1
  5. package/dist/_internal/bridge.js +290 -145
  6. package/dist/_internal/bridge.js.map +1 -1
  7. package/dist/_internal/isolated/child.d.ts +2 -0
  8. package/dist/_internal/isolated/child.d.ts.map +1 -0
  9. package/dist/_internal/isolated/child.js +176 -0
  10. package/dist/_internal/isolated/child.js.map +1 -0
  11. package/dist/_internal/isolated/host.d.ts +147 -0
  12. package/dist/_internal/isolated/host.d.ts.map +1 -0
  13. package/dist/_internal/isolated/host.js +645 -0
  14. package/dist/_internal/isolated/host.js.map +1 -0
  15. package/dist/_internal/isolated/protocol.d.ts +399 -0
  16. package/dist/_internal/isolated/protocol.d.ts.map +1 -0
  17. package/dist/_internal/isolated/protocol.js +250 -0
  18. package/dist/_internal/isolated/protocol.js.map +1 -0
  19. package/dist/_internal/peer.d.ts +68 -13
  20. package/dist/_internal/peer.d.ts.map +1 -1
  21. package/dist/_internal/peer.js +233 -157
  22. package/dist/_internal/peer.js.map +1 -1
  23. package/dist/index.d.ts +19 -10
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +37 -33
  26. package/dist/index.js.map +1 -1
  27. package/dist/isolated.d.ts +25 -0
  28. package/dist/isolated.d.ts.map +1 -0
  29. package/dist/isolated.js +39 -0
  30. package/dist/isolated.js.map +1 -0
  31. package/lib/darwin-arm64/libreactor_effect_native.dylib +0 -0
  32. package/lib/darwin-arm64/native-identity.json +4 -3
  33. package/lib/linux-x64/libreactor_effect_native.so +0 -0
  34. package/lib/linux-x64/native-identity.json +4 -3
  35. package/package.json +7 -3
  36. package/rust/Cargo.toml +108 -2
  37. package/rust/build.rs +253 -114
  38. package/rust/clippy.toml +7 -0
  39. package/rust/include/reactor_effect_native.h +101 -42
  40. package/rust/src/abi.rs +258 -0
  41. package/rust/src/error.rs +149 -0
  42. package/rust/src/ffi/memory.rs +256 -0
  43. package/rust/src/ffi/tests.rs +719 -0
  44. package/rust/src/ffi.rs +474 -0
  45. package/rust/src/lib.rs +36 -2341
  46. package/rust/src/peer/callbacks.rs +145 -0
  47. package/rust/src/peer/media.rs +221 -0
  48. package/rust/src/peer/owner/tests.rs +188 -0
  49. package/rust/src/peer/owner.rs +353 -0
  50. package/rust/src/peer/shared.rs +323 -0
  51. package/rust/src/peer/tests.rs +513 -0
  52. package/rust/src/peer.rs +189 -0
  53. package/rust/src/protocol/event.rs +238 -0
  54. package/rust/src/protocol/request.rs +347 -0
  55. package/rust/src/protocol/stats.rs +356 -0
  56. package/rust/src/protocol.rs +71 -0
  57. package/rust/src/sync/gate.rs +159 -0
  58. package/rust/src/sync/notifier.rs +136 -0
  59. package/rust/src/sync/queue.rs +384 -0
  60. package/rust/src/sync.rs +20 -0
  61. package/rust/src/test_support.rs +99 -0
  62. package/rust-toolchain.toml +7 -0
  63. package/scripts/stage.mjs +41 -1
@@ -0,0 +1,250 @@
1
+ /**
2
+ * The private contract between an isolated native peer and its child process:
3
+ * one Effect RPC group mirroring the `Peer` contract, over the child's IPC
4
+ * channel. The worker protocols encode every message with Schema's JSON codec,
5
+ * so the byte-carrying fields are declarations that structured clone passes on
6
+ * as they are, where `Schema.Uint8Array` would become Base64 text.
7
+ *
8
+ * Failures cross as a plain record and are rebuilt as `ReactorError` in the
9
+ * parent: the Native reason's backend text is Redacted, which refuses JSON
10
+ * encoding, and it stays Redacted on each side of the channel.
11
+ */
12
+ import * as Predicate from "effect/Predicate";
13
+ import * as Redacted from "effect/Redacted";
14
+ import * as Schema from "effect/Schema";
15
+ import * as Rpc from "effect/unstable/rpc/Rpc";
16
+ import * as RpcGroup from "effect/unstable/rpc/RpcGroup";
17
+ import { ErrorCode, IceFailed, Mapping, Native, ReactorError, Track, TransportFailed, } from "reactor-effect-client";
18
+ /** A value structured clone carries unchanged, checked by its guard on each side. */
19
+ const cloned = (is, expected) => Schema.declare(is, { expected, toCodecJson: () => undefined });
20
+ const Bytes = cloned((u) => u instanceof Uint8Array, "Uint8Array");
21
+ const Samples = cloned((u) => u instanceof Int16Array, "Int16Array");
22
+ /** Statistics records hold bigint counters, which structured clone keeps. */
23
+ const Records = cloned((u) => Array.isArray(u), "statistics array");
24
+ const Outcome = Schema.Literals(["not-submitted", "unknown", "replied"]);
25
+ /** A `ReactorError` as it crosses the channel: its reason fields and dispatch evidence. */
26
+ export const WireFailure = Schema.Struct({
27
+ code: ErrorCode,
28
+ message: Schema.String,
29
+ operation: Schema.optionalKey(Schema.String),
30
+ outcome: Schema.optionalKey(Outcome),
31
+ status: Schema.optionalKey(Schema.Int),
32
+ backendMessage: Schema.optionalKey(Schema.String),
33
+ channel: Schema.optionalKey(Schema.String),
34
+ pairs: Schema.optionalKey(Schema.Int),
35
+ candidateTypes: Schema.optionalKey(Schema.Array(Schema.String)),
36
+ });
37
+ const Channel = Schema.Literals(["control", "data"]);
38
+ const WireEvent = Schema.Union([
39
+ Schema.Struct({
40
+ type: Schema.Literal("state"),
41
+ state: Schema.Literals(["new", "connecting", "connected", "disconnected", "failed", "closed"]),
42
+ }),
43
+ Schema.Struct({ type: Schema.Literal("channel"), channel: Channel, open: Schema.Boolean }),
44
+ Schema.Struct({ type: Schema.Literal("message"), channel: Channel, bytes: Bytes }),
45
+ Schema.Struct({
46
+ type: Schema.Literal("ice"),
47
+ candidate: Schema.optionalKey(Schema.Struct({
48
+ candidate: Schema.String,
49
+ sdp_mid: Schema.optionalKey(Schema.String),
50
+ sdp_mline_index: Schema.optionalKey(Schema.Int),
51
+ })),
52
+ }),
53
+ Schema.Struct({ type: Schema.Literal("track"), name: Schema.String, mid: Schema.String }),
54
+ Schema.Struct({
55
+ type: Schema.Literal("decoded"),
56
+ kind: Schema.Literals(["video", "audio"]),
57
+ name: Schema.String,
58
+ mid: Schema.String,
59
+ }),
60
+ Schema.Struct({ type: Schema.Literal("error"), error: WireFailure }),
61
+ ]);
62
+ /** The prepare stream: the offer first, then the child's peer events in order. */
63
+ export const PrepareItem = Schema.Union([
64
+ Schema.TaggedStruct("Prepared", { sdp: Schema.String, mapping: Schema.Array(Mapping) }),
65
+ Schema.TaggedStruct("Event", { event: WireEvent }),
66
+ ]);
67
+ /** A frame's admission sequence, stamped natively before any queue could drop it. */
68
+ const Sequence = Schema.BigInt.check(Schema.isGreaterThanOrEqualToBigInt(0n));
69
+ export const WireVideo = Schema.Struct({
70
+ width: Schema.Int,
71
+ height: Schema.Int,
72
+ frameId: Schema.BigInt,
73
+ timestampMicros: Schema.BigInt,
74
+ sequence: Sequence,
75
+ data: Bytes,
76
+ metadata: Bytes,
77
+ });
78
+ export const WireAudio = Schema.Struct({
79
+ sampleRate: Schema.Int,
80
+ channels: Schema.Int,
81
+ sequence: Sequence,
82
+ samples: Samples,
83
+ });
84
+ const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
85
+ const Total = Schema.BigInt.check(Schema.isGreaterThanOrEqualToBigInt(0n));
86
+ /** The child's transport pressure, with its own readers' overflows. */
87
+ export const WirePressure = Schema.Struct({
88
+ closed: Schema.Boolean,
89
+ queuedControl: Count,
90
+ queuedVideo: Count,
91
+ queuedAudio: Count,
92
+ queuedBytes: Count,
93
+ droppedVideo: Total,
94
+ droppedAudio: Total,
95
+ pendingRequests: Count,
96
+ deliveredVideo: Total,
97
+ deliveredAudio: Total,
98
+ readerOverflows: Total,
99
+ });
100
+ const IceServer = Schema.Struct({
101
+ urls: Schema.Array(Schema.String),
102
+ username: Schema.String,
103
+ credential: Schema.String,
104
+ });
105
+ /**
106
+ * One child per peer. `Open` loads and verifies the library and creates the
107
+ * child's native peer; `Shutdown` closes and joins it. Every other RPC is one
108
+ * `Peer` operation, and `Video`/`Audio` open a track's frame stream.
109
+ */
110
+ export class IsolatedRpcs extends RpcGroup.make(Rpc.make("Open", {
111
+ payload: { libraryPath: Schema.optionalKey(Schema.String) },
112
+ error: WireFailure,
113
+ }), Rpc.make("Prepare", {
114
+ payload: { servers: Schema.Array(IceServer), tracks: Schema.Array(Track) },
115
+ success: PrepareItem,
116
+ error: WireFailure,
117
+ stream: true,
118
+ }), Rpc.make("Answer", { payload: { sdp: Schema.String }, error: WireFailure }), Rpc.make("Send", { payload: { channel: Channel, bytes: Bytes }, error: WireFailure }), Rpc.make("Direction", {
119
+ payload: { name: Schema.String, active: Schema.Boolean },
120
+ error: WireFailure,
121
+ }), Rpc.make("Replace", { payload: { name: Schema.String }, error: WireFailure }), Rpc.make("MaxBitrate", {
122
+ // The child's peer rejects a value out of range, a non-finite one
123
+ // included, as the in-process host does, so it must reach the child.
124
+ // @effect-diagnostics-next-line schemaNumber:off
125
+ payload: { name: Schema.String, bitsPerSecond: Schema.Number },
126
+ error: WireFailure,
127
+ }), Rpc.make("Stats", { success: Records, error: WireFailure }), Rpc.make("Snapshot", { success: WirePressure, error: WireFailure }), Rpc.make("Video", {
128
+ payload: { name: Schema.String },
129
+ success: WireVideo,
130
+ error: WireFailure,
131
+ stream: true,
132
+ }), Rpc.make("Audio", {
133
+ payload: { name: Schema.String },
134
+ success: WireAudio,
135
+ error: WireFailure,
136
+ stream: true,
137
+ }), Rpc.make("Shutdown", { error: WireFailure })) {
138
+ }
139
+ const nativeDetail = (detail) => {
140
+ if (!Predicate.isObject(detail))
141
+ return {};
142
+ return {
143
+ ...(typeof detail.status === "number" && Number.isSafeInteger(detail.status)
144
+ ? { status: detail.status }
145
+ : {}),
146
+ ...(Redacted.isRedacted(detail.backendMessage) &&
147
+ typeof Redacted.value(detail.backendMessage) === "string"
148
+ ? { backendMessage: Redacted.value(detail.backendMessage) }
149
+ : {}),
150
+ ...(typeof detail.channel === "string" ? { channel: detail.channel } : {}),
151
+ };
152
+ };
153
+ /**
154
+ * A failure as the child sends it. Only the evidence the native host itself
155
+ * attaches crosses: its failure class and backend text; any other `detail` is
156
+ * the child's own diagnostic and stays there.
157
+ */
158
+ export const toWire = (error) => {
159
+ const { reason, context } = error;
160
+ const base = {
161
+ code: reason._tag,
162
+ message: reason.message,
163
+ ...(context.operation === undefined ? {} : { operation: context.operation }),
164
+ ...(context.outcome === undefined ? {} : { outcome: context.outcome }),
165
+ };
166
+ switch (reason._tag) {
167
+ case "Native":
168
+ return {
169
+ ...base,
170
+ ...nativeDetail(context.detail),
171
+ ...(reason.status === undefined ? {} : { status: reason.status }),
172
+ ...(reason.backendMessage === undefined
173
+ ? {}
174
+ : { backendMessage: Redacted.value(reason.backendMessage) }),
175
+ };
176
+ case "IceFailed":
177
+ return { ...base, pairs: reason.pairs, candidateTypes: reason.candidateTypes };
178
+ case "TransportFailed":
179
+ return { ...base, pairs: reason.pairs };
180
+ default:
181
+ return { ...base, ...nativeDetail(context.detail) };
182
+ }
183
+ };
184
+ /** The parent's `ReactorError` for a failure the child sent, as the in-process host raises it. */
185
+ export const fromWire = (wire) => {
186
+ const context = {
187
+ ...(wire.operation === undefined ? {} : { operation: wire.operation }),
188
+ ...(wire.outcome === undefined ? {} : { outcome: wire.outcome }),
189
+ };
190
+ const backendMessage = wire.backendMessage === undefined ? undefined : Redacted.make(wire.backendMessage);
191
+ const channel = wire.channel === undefined ? {} : { channel: wire.channel };
192
+ switch (wire.code) {
193
+ case "Native":
194
+ return new ReactorError({
195
+ reason: new Native({
196
+ message: wire.message,
197
+ ...(wire.status === undefined ? {} : { status: wire.status }),
198
+ ...(backendMessage === undefined ? {} : { backendMessage }),
199
+ }),
200
+ context: wire.channel === undefined ? context : { ...context, detail: channel },
201
+ });
202
+ case "IceFailed":
203
+ return new ReactorError({
204
+ reason: new IceFailed({
205
+ message: wire.message,
206
+ pairs: wire.pairs ?? 0,
207
+ candidateTypes: wire.candidateTypes ?? [],
208
+ }),
209
+ context,
210
+ });
211
+ case "TransportFailed":
212
+ return new ReactorError({
213
+ reason: new TransportFailed({ message: wire.message, pairs: wire.pairs ?? 0 }),
214
+ context,
215
+ });
216
+ case "ClipEnded":
217
+ // Only an H3 provider raises it, from clip evidence no native peer has.
218
+ return ReactorError.fromCode("Protocol", "isolated native child sent a clip failure", context);
219
+ default:
220
+ return ReactorError.fromCode(wire.code, wire.message, wire.status === undefined
221
+ ? context
222
+ : { ...context, detail: { status: wire.status, backendMessage, ...channel } });
223
+ }
224
+ };
225
+ /** A peer event as the child sends it. */
226
+ export const eventToWire = (event) => {
227
+ switch (event.type) {
228
+ case "error":
229
+ return { type: "error", error: toWire(event.error) };
230
+ case "message":
231
+ return { ...event, bytes: event.bytes };
232
+ default:
233
+ return event;
234
+ }
235
+ };
236
+ /** A peer event as the parent delivers it. */
237
+ export const eventFromWire = (event) => {
238
+ switch (event.type) {
239
+ case "message":
240
+ return { type: "message", channel: event.channel, bytes: exact(event.bytes) };
241
+ case "error":
242
+ return { type: "error", error: fromWire(event.error) };
243
+ default:
244
+ return event;
245
+ }
246
+ };
247
+ export function exact(view) {
248
+ return view.byteOffset === 0 && view.byteLength === view.buffer.byteLength ? view : view.slice();
249
+ }
250
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/_internal/isolated/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAC/C,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AACzD,OAAO,EACL,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,YAAY,EACZ,KAAK,EACL,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAI/B,qFAAqF;AACrF,MAAM,MAAM,GAAG,CAAI,EAA0B,EAAE,QAAgB,EAAE,EAAE,CACj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EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAgC,EAAE,CAAC;QACrE;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAgB,EAAa,EAAE;IAC3D,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAChF,KAAK,OAAO;YACV,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAUF,MAAM,UAAU,KAAK,CACnB,IAAuD;IAEvD,OAAO,IAAI,CAAC,UAAU,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AACnG,CAAC"}
@@ -1,57 +1,112 @@
1
+ import * as Duration from "effect/Duration";
1
2
  import * as Effect from "effect/Effect";
2
3
  import type * as Scope from "effect/Scope";
3
4
  import { ReactorError } from "reactor-effect-client";
4
5
  import type { Track } from "reactor-effect-client";
5
6
  import type { AudioFrame, Channel, IceServer, MediaPressure, MediaTrack, Peer, PeerEvent, Prepared, RawMedia, VideoFrame } from "reactor-effect-client/host";
6
- import { type NativePacket } from "./bridge.js";
7
- declare const validateNativeTracks: (tracks: readonly Track[]) => void;
7
+ import { type NativeAudio, type NativePacket, type NativeVideo } from "./bridge.js";
8
+ /**
9
+ * How long closing a peer waits for its native owner join. A healthy join under
10
+ * real libwebrtc took 13-62 ms in the media load tests on Node and Bun, which
11
+ * require it under 2 s; the default leaves five times that bound.
12
+ */
13
+ export declare const defaultShutdownTimeout: Duration.Duration;
14
+ export declare const validateNativeTracks: (tracks: readonly Track[]) => void;
8
15
  declare const parsePrepared: (value: unknown) => Prepared;
16
+ export declare const iceServers: (servers: readonly IceServer[]) => readonly {
17
+ readonly urls: readonly string[];
18
+ readonly username: string;
19
+ readonly credential: string;
20
+ }[];
9
21
  declare const parseEvent: (packet: NativePacket) => PeerEvent;
10
- declare const parseVideo: (packet: NativePacket) => VideoFrame;
11
- declare const parseAudio: (packet: NativePacket) => AudioFrame;
12
- declare const parseSnapshot: (value: unknown) => MediaPressure;
22
+ declare const videoFrame: (tracks: readonly Track[], taken: NativeVideo) => VideoFrame;
23
+ declare const audioFrame: (tracks: readonly Track[], taken: NativeAudio) => AudioFrame;
24
+ /** The native snapshot's transport counters; the host adds its own reader overflows. */
25
+ declare const parseSnapshot: (value: unknown) => Omit<MediaPressure, "readerOverflows">;
13
26
  declare const statsValue: (value: unknown) => unknown;
27
+ /**
28
+ * Classify a failed connection from its candidate pairs. reactor-webrtc does
29
+ * not report ICE connection state, but a pair that succeeded or was nominated
30
+ * shows ICE worked and the DTLS/SCTP transport above it failed.
31
+ */
32
+ declare const connectionFailure: (stats: readonly unknown[]) => ReactorError;
14
33
  export declare class NativePeer implements Peer {
34
+ private readonly shutdownTimeout;
15
35
  readonly nativeTracks = false;
16
36
  readonly rawMedia: RawMedia;
17
37
  private readonly bridge;
18
38
  private readonly video;
19
39
  private readonly audio;
20
40
  private readonly incoming;
41
+ private tracks;
42
+ private readonly wakeEvents;
43
+ private readonly wakeVideo;
44
+ private readonly wakeAudio;
21
45
  private emit;
22
46
  private closed;
23
47
  private failureEmitted;
24
48
  private failure;
25
- constructor(libraryPath: string);
49
+ constructor(libraryPath: string, shutdownTimeout?: Duration.Input);
26
50
  private requireIncoming;
51
+ /** Readers failed for falling behind, across this peer's video and audio tracks. */
52
+ private readerOverflows;
27
53
  private videoFeed;
28
54
  private audioFeed;
29
55
  private fail;
30
- private pumpEvents;
31
- private pumpVideo;
32
- private pumpAudio;
56
+ /** The native readiness callback, on the JavaScript thread: it only wakes pumps. */
57
+ private wake;
58
+ /**
59
+ * Drain one native queue with synchronous takes whenever readiness wakes
60
+ * it. Yielding after every item lets observers run between emits, so a
61
+ * backlog released by a stalled event loop reaches bounded observation
62
+ * queues at their readers' pace rather than all at once. Yielding once per
63
+ * batch of half a subscriber's capacity overflowed an observation queue on
64
+ * Bun under CPU contention, so each item costs one event-loop turn.
65
+ */
66
+ private pump;
67
+ /**
68
+ * Deliver one event; false once the queue is empty or closed. A failed
69
+ * connection is classified here before the pump takes another event, so its
70
+ * classification decides the error; later events describe the same teardown.
71
+ */
72
+ private get stepEvent();
73
+ private get stepVideo();
74
+ private get stepAudio();
75
+ /**
76
+ * Report a failed connection as IceFailed or TransportFailed rather than a
77
+ * bare state. The statistics read runs in the events pump, so the connection
78
+ * scope owns it and its deadline runs on the fiber's Clock.
79
+ */
80
+ private get classify();
33
81
  prepare(servers: readonly IceServer[], tracks: readonly Track[], emit: (event: PeerEvent) => void): Effect.Effect<Prepared, ReactorError, Scope.Scope>;
34
82
  answer(sdp: string): Effect.Effect<void, ReactorError>;
35
83
  send(channel: Channel, bytes: Uint8Array<ArrayBuffer>): Effect.Effect<void, ReactorError>;
36
84
  direction(name: string, active: boolean): Effect.Effect<void, ReactorError>;
37
85
  maxBitrate(name: string, bitsPerSecond: number): Effect.Effect<void, ReactorError>;
38
- stats(): Effect.Effect<readonly unknown[], ReactorError>;
86
+ get stats(): Effect.Effect<readonly unknown[], ReactorError>;
39
87
  private mediaSnapshot;
40
88
  lease(): MediaTrack;
41
89
  release(): void;
42
90
  replace(): Effect.Effect<void, ReactorError>;
43
91
  close(): void;
44
- shutdown(): Effect.Effect<void, ReactorError>;
92
+ /**
93
+ * Close, then wait for the native owner join. Only the wait is bounded: the
94
+ * deadline races the interruptible wait inside the uninterruptible region, so
95
+ * expiry stops waiting while the join keeps the handle and callback, and the
96
+ * bridge is retained until the join completes.
97
+ */
98
+ get shutdown(): Effect.Effect<void, ReactorError>;
45
99
  }
46
100
  /** Internal test surface. This module is not a package export. */
47
101
  export declare const nativePeerTesting: Readonly<{
48
102
  parsePrepared: typeof parsePrepared;
49
103
  parseEvent: typeof parseEvent;
50
- parseVideo: typeof parseVideo;
51
- parseAudio: typeof parseAudio;
104
+ videoFrame: typeof videoFrame;
105
+ audioFrame: typeof audioFrame;
52
106
  parseSnapshot: typeof parseSnapshot;
53
107
  statsValue: typeof statsValue;
54
108
  validateNativeTracks: typeof validateNativeTracks;
109
+ connectionFailure: typeof connectionFailure;
55
110
  }>;
56
111
  export {};
57
112
  //# sourceMappingURL=peer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../src/_internal/peer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAa,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAW,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EAEP,SAAS,EACT,aAAa,EACb,UAAU,EACV,IAAI,EACJ,SAAS,EAET,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAKL,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAoBrB,QAAA,MAAM,oBAAoB,WAAY,SAAS,KAAK,EAAE,KAAG,IAcxD,CAAC;AA6CF,QAAA,MAAM,aAAa,UAAW,OAAO,KAAG,QAOvC,CAAC;AAkCF,QAAA,MAAM,UAAU,WAAY,YAAY,KAAG,SAiE1C,CAAC;AAEF,QAAA,MAAM,UAAU,WAAY,YAAY,KAAG,UAyB1C,CAAC;AAEF,QAAA,MAAM,U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