reactor-effect-client 0.7.1 → 0.8.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.
- package/NOTICE +7 -2
- package/README.md +103 -141
- package/dist/Coordinator.d.ts +382 -0
- package/dist/Coordinator.d.ts.map +1 -0
- package/dist/Coordinator.js +732 -0
- package/dist/Coordinator.js.map +1 -0
- package/dist/H3.d.ts +159 -0
- package/dist/H3.d.ts.map +1 -0
- package/dist/H3.js +21 -0
- package/dist/H3.js.map +1 -0
- package/dist/H3Source.d.ts +93 -0
- package/dist/H3Source.d.ts.map +1 -0
- package/dist/H3Source.js +401 -0
- package/dist/H3Source.js.map +1 -0
- package/dist/LocalSource.d.ts +68 -0
- package/dist/LocalSource.d.ts.map +1 -0
- package/dist/LocalSource.js +354 -0
- package/dist/LocalSource.js.map +1 -0
- package/dist/Media.d.ts +106 -0
- package/dist/Media.d.ts.map +1 -0
- package/dist/Media.js +16 -0
- package/dist/Media.js.map +1 -0
- package/dist/Peer.d.ts +134 -0
- package/dist/Peer.d.ts.map +1 -0
- package/dist/Peer.js +57 -0
- package/dist/Peer.js.map +1 -0
- package/dist/Playout.d.ts +724 -0
- package/dist/Playout.d.ts.map +1 -0
- package/dist/Playout.js +28 -0
- package/dist/Playout.js.map +1 -0
- package/dist/Reactor.d.ts +135 -0
- package/dist/Reactor.d.ts.map +1 -0
- package/dist/Reactor.js +158 -0
- package/dist/Reactor.js.map +1 -0
- package/dist/ReactorError.d.ts +331 -0
- package/dist/ReactorError.d.ts.map +1 -0
- package/dist/ReactorError.js +316 -0
- package/dist/ReactorError.js.map +1 -0
- package/dist/ReactorTest.d.ts +383 -0
- package/dist/ReactorTest.d.ts.map +1 -0
- package/dist/ReactorTest.js +317 -0
- package/dist/ReactorTest.js.map +1 -0
- package/dist/Session.d.ts +314 -0
- package/dist/Session.d.ts.map +1 -0
- package/dist/Session.js +51 -0
- package/dist/Session.js.map +1 -0
- package/dist/index.d.ts +12 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/internal/correlator.d.ts +46 -0
- package/dist/internal/correlator.d.ts.map +1 -0
- package/dist/internal/correlator.js +150 -0
- package/dist/internal/correlator.js.map +1 -0
- package/dist/internal/deadline.d.ts +24 -0
- package/dist/internal/deadline.d.ts.map +1 -0
- package/dist/internal/deadline.js +44 -0
- package/dist/internal/deadline.js.map +1 -0
- package/dist/{h3/_internal/contracts.d.ts → internal/h3/commands.d.ts} +39 -33
- package/dist/internal/h3/commands.d.ts.map +1 -0
- package/dist/internal/h3/commands.js +128 -0
- package/dist/internal/h3/commands.js.map +1 -0
- package/dist/{h3 → internal/h3}/messages.d.ts +16 -11
- package/dist/internal/h3/messages.d.ts.map +1 -0
- package/dist/{h3 → internal/h3}/messages.js +19 -31
- package/dist/internal/h3/messages.js.map +1 -0
- package/dist/internal/h3/operations.d.ts +145 -0
- package/dist/internal/h3/operations.d.ts.map +1 -0
- package/dist/internal/h3/operations.js +284 -0
- package/dist/internal/h3/operations.js.map +1 -0
- package/dist/{h3 → internal/h3}/profile.d.ts +63 -65
- package/dist/internal/h3/profile.d.ts.map +1 -0
- package/dist/{h3 → internal/h3}/profile.js +39 -39
- package/dist/internal/h3/profile.js.map +1 -0
- package/dist/internal/h3/provider.d.ts +14 -0
- package/dist/internal/h3/provider.d.ts.map +1 -0
- package/dist/internal/h3/provider.js +672 -0
- package/dist/internal/h3/provider.js.map +1 -0
- package/dist/internal/h3/references.d.ts +68 -0
- package/dist/internal/h3/references.d.ts.map +1 -0
- package/dist/internal/h3/references.js +339 -0
- package/dist/internal/h3/references.js.map +1 -0
- package/dist/internal/h3/request.d.ts +56 -0
- package/dist/internal/h3/request.d.ts.map +1 -0
- package/dist/internal/h3/request.js +70 -0
- package/dist/internal/h3/request.js.map +1 -0
- package/dist/internal/h3/state.d.ts +120 -0
- package/dist/internal/h3/state.d.ts.map +1 -0
- package/dist/internal/h3/state.js +270 -0
- package/dist/internal/h3/state.js.map +1 -0
- package/dist/{Submission.d.ts → internal/h3/submission.d.ts} +1 -3
- package/dist/internal/h3/submission.d.ts.map +1 -0
- package/dist/{Submission.js → internal/h3/submission.js} +1 -9
- package/dist/internal/h3/submission.js.map +1 -0
- package/dist/internal/hub.d.ts +32 -0
- package/dist/internal/hub.d.ts.map +1 -0
- package/dist/internal/hub.js +92 -0
- package/dist/internal/hub.js.map +1 -0
- package/dist/internal/playout/errors.d.ts +51 -0
- package/dist/internal/playout/errors.d.ts.map +1 -0
- package/dist/internal/playout/errors.js +40 -0
- package/dist/internal/playout/errors.js.map +1 -0
- package/dist/internal/playout/policy.d.ts +559 -0
- package/dist/internal/playout/policy.d.ts.map +1 -0
- package/dist/internal/playout/policy.js +2338 -0
- package/dist/internal/playout/policy.js.map +1 -0
- package/dist/internal/playout/runtime.d.ts +28 -0
- package/dist/internal/playout/runtime.d.ts.map +1 -0
- package/dist/internal/playout/runtime.js +766 -0
- package/dist/internal/playout/runtime.js.map +1 -0
- package/dist/internal/playout/tag.d.ts +14 -0
- package/dist/internal/playout/tag.d.ts.map +1 -0
- package/dist/internal/playout/tag.js +43 -0
- package/dist/internal/playout/tag.js.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/common_pb.d.ts +55 -0
- package/dist/internal/proto/reactor_wire/v1/common_pb.d.ts.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/common_pb.js +42 -0
- package/dist/internal/proto/reactor_wire/v1/common_pb.js.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/control_pb.d.ts +160 -0
- package/dist/internal/proto/reactor_wire/v1/control_pb.d.ts.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/control_pb.js +21 -0
- package/dist/internal/proto/reactor_wire/v1/control_pb.js.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/data_pb.d.ts +89 -0
- package/dist/internal/proto/reactor_wire/v1/data_pb.d.ts.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/data_pb.js +20 -0
- package/dist/internal/proto/reactor_wire/v1/data_pb.js.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/model_pb.d.ts +85 -0
- package/dist/internal/proto/reactor_wire/v1/model_pb.d.ts.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/model_pb.js +24 -0
- package/dist/internal/proto/reactor_wire/v1/model_pb.js.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/platform_pb.d.ts +190 -0
- package/dist/internal/proto/reactor_wire/v1/platform_pb.d.ts.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/platform_pb.js +54 -0
- package/dist/internal/proto/reactor_wire/v1/platform_pb.js.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/track_pb.d.ts +88 -0
- package/dist/internal/proto/reactor_wire/v1/track_pb.d.ts.map +1 -0
- package/dist/internal/proto/reactor_wire/v1/track_pb.js +33 -0
- package/dist/internal/proto/reactor_wire/v1/track_pb.js.map +1 -0
- package/dist/internal/queue.d.ts +4 -0
- package/dist/internal/queue.d.ts.map +1 -0
- package/dist/{_internal → internal}/queue.js +0 -9
- package/dist/internal/queue.js.map +1 -0
- package/dist/internal/reactorTest/coordinator.d.ts +5 -0
- package/dist/internal/reactorTest/coordinator.d.ts.map +1 -0
- package/dist/internal/reactorTest/coordinator.js +178 -0
- package/dist/internal/reactorTest/coordinator.js.map +1 -0
- package/dist/internal/reactorTest/faults.d.ts +172 -0
- package/dist/internal/reactorTest/faults.d.ts.map +1 -0
- package/dist/internal/reactorTest/faults.js +23 -0
- package/dist/internal/reactorTest/faults.js.map +1 -0
- package/dist/internal/reactorTest/h3.d.ts +431 -0
- package/dist/internal/reactorTest/h3.d.ts.map +1 -0
- package/dist/internal/reactorTest/h3.js +625 -0
- package/dist/internal/reactorTest/h3.js.map +1 -0
- package/dist/internal/reactorTest/media.d.ts +22 -0
- package/dist/internal/reactorTest/media.d.ts.map +1 -0
- package/dist/internal/reactorTest/media.js +34 -0
- package/dist/internal/reactorTest/media.js.map +1 -0
- package/dist/internal/reactorTest/peer.d.ts +318 -0
- package/dist/internal/reactorTest/peer.d.ts.map +1 -0
- package/dist/internal/reactorTest/peer.js +206 -0
- package/dist/internal/reactorTest/peer.js.map +1 -0
- package/dist/internal/reactorTest/playout.d.ts +34 -0
- package/dist/internal/reactorTest/playout.d.ts.map +1 -0
- package/dist/internal/reactorTest/playout.js +340 -0
- package/dist/internal/reactorTest/playout.js.map +1 -0
- package/dist/internal/reactorTest/references.d.ts +25 -0
- package/dist/internal/reactorTest/references.d.ts.map +1 -0
- package/dist/{testing/Png.js → internal/reactorTest/references.js} +50 -12
- package/dist/internal/reactorTest/references.js.map +1 -0
- package/dist/internal/reactorTest/sessions.d.ts +364 -0
- package/dist/internal/reactorTest/sessions.d.ts.map +1 -0
- package/dist/internal/reactorTest/sessions.js +592 -0
- package/dist/internal/reactorTest/sessions.js.map +1 -0
- package/dist/internal/reactorTest/timing.d.ts +13 -0
- package/dist/internal/reactorTest/timing.d.ts.map +1 -0
- package/dist/internal/reactorTest/timing.js +20 -0
- package/dist/internal/reactorTest/timing.js.map +1 -0
- package/dist/internal/recording.d.ts +52 -0
- package/dist/internal/recording.d.ts.map +1 -0
- package/dist/internal/recording.js +141 -0
- package/dist/internal/recording.js.map +1 -0
- package/dist/internal/session/connect.d.ts +34 -0
- package/dist/internal/session/connect.d.ts.map +1 -0
- package/dist/internal/session/connect.js +502 -0
- package/dist/internal/session/connect.js.map +1 -0
- package/dist/internal/session/generation.d.ts +35 -0
- package/dist/internal/session/generation.d.ts.map +1 -0
- package/dist/internal/session/generation.js +185 -0
- package/dist/internal/session/generation.js.map +1 -0
- package/dist/internal/session/ice.d.ts +23 -0
- package/dist/internal/session/ice.d.ts.map +1 -0
- package/dist/internal/session/ice.js +57 -0
- package/dist/internal/session/ice.js.map +1 -0
- package/dist/internal/session/inbound.d.ts +50 -0
- package/dist/internal/session/inbound.d.ts.map +1 -0
- package/dist/internal/session/inbound.js +202 -0
- package/dist/internal/session/inbound.js.map +1 -0
- package/dist/internal/session/model.d.ts +163 -0
- package/dist/internal/session/model.d.ts.map +1 -0
- package/dist/internal/session/model.js +78 -0
- package/dist/internal/session/model.js.map +1 -0
- package/dist/internal/session/requests.d.ts +71 -0
- package/dist/internal/session/requests.d.ts.map +1 -0
- package/dist/internal/session/requests.js +240 -0
- package/dist/internal/session/requests.js.map +1 -0
- package/dist/internal/session/tracks.d.ts +21 -0
- package/dist/internal/session/tracks.d.ts.map +1 -0
- package/dist/internal/session/tracks.js +166 -0
- package/dist/internal/session/tracks.js.map +1 -0
- package/dist/internal/session/upload.d.ts +21 -0
- package/dist/internal/session/upload.d.ts.map +1 -0
- package/dist/internal/session/upload.js +68 -0
- package/dist/internal/session/upload.js.map +1 -0
- package/dist/internal/session.d.ts +66 -0
- package/dist/internal/session.d.ts.map +1 -0
- package/dist/internal/session.js +280 -0
- package/dist/internal/session.js.map +1 -0
- package/dist/{stats.d.ts → internal/stats.d.ts} +30 -16
- package/dist/internal/stats.d.ts.map +1 -0
- package/dist/internal/stats.js +201 -0
- package/dist/internal/stats.js.map +1 -0
- package/dist/internal/token.d.ts +22 -0
- package/dist/internal/token.d.ts.map +1 -0
- package/dist/internal/token.js +65 -0
- package/dist/internal/token.js.map +1 -0
- package/dist/internal/wire.d.ts +37 -0
- package/dist/internal/wire.d.ts.map +1 -0
- package/dist/internal/wire.js +49 -0
- package/dist/internal/wire.js.map +1 -0
- package/notices/bufbuild-protobuf-LICENSE +201 -0
- package/package.json +17 -38
- package/dist/FetchHttp.d.ts +0 -9
- package/dist/FetchHttp.d.ts.map +0 -1
- package/dist/FetchHttp.js +0 -63
- package/dist/FetchHttp.js.map +0 -1
- package/dist/PeerFactory.d.ts +0 -26
- package/dist/PeerFactory.d.ts.map +0 -1
- package/dist/PeerFactory.js +0 -4
- package/dist/PeerFactory.js.map +0 -1
- package/dist/PeerTypes.d.ts +0 -64
- package/dist/PeerTypes.d.ts.map +0 -1
- package/dist/PeerTypes.js +0 -2
- package/dist/PeerTypes.js.map +0 -1
- package/dist/Sequence.d.ts +0 -85
- package/dist/Sequence.d.ts.map +0 -1
- package/dist/Sequence.js +0 -210
- package/dist/Sequence.js.map +0 -1
- package/dist/SessionTypes.d.ts +0 -312
- package/dist/SessionTypes.d.ts.map +0 -1
- package/dist/SessionTypes.js +0 -19
- package/dist/SessionTypes.js.map +0 -1
- package/dist/Submission.d.ts.map +0 -1
- package/dist/Submission.js.map +0 -1
- package/dist/_internal/queue.d.ts +0 -6
- package/dist/_internal/queue.d.ts.map +0 -1
- package/dist/_internal/queue.js.map +0 -1
- package/dist/bytes.d.ts +0 -6
- package/dist/bytes.d.ts.map +0 -1
- package/dist/bytes.js +0 -32
- package/dist/bytes.js.map +0 -1
- package/dist/contract.d.ts +0 -149
- package/dist/contract.d.ts.map +0 -1
- package/dist/contract.js +0 -119
- package/dist/contract.js.map +0 -1
- package/dist/coordinator/_internal/client.d.ts +0 -215
- package/dist/coordinator/_internal/client.d.ts.map +0 -1
- package/dist/coordinator/_internal/client.js +0 -563
- package/dist/coordinator/_internal/client.js.map +0 -1
- package/dist/coordinator/_internal/recording.d.ts +0 -31
- package/dist/coordinator/_internal/recording.d.ts.map +0 -1
- package/dist/coordinator/_internal/recording.js +0 -123
- package/dist/coordinator/_internal/recording.js.map +0 -1
- package/dist/coordinator/_internal/response.d.ts +0 -15
- package/dist/coordinator/_internal/response.d.ts.map +0 -1
- package/dist/coordinator/_internal/response.js +0 -55
- package/dist/coordinator/_internal/response.js.map +0 -1
- package/dist/coordinator/_internal/schemas.d.ts +0 -73
- package/dist/coordinator/_internal/schemas.d.ts.map +0 -1
- package/dist/coordinator/_internal/schemas.js +0 -200
- package/dist/coordinator/_internal/schemas.js.map +0 -1
- package/dist/coordinator/index.d.ts +0 -40
- package/dist/coordinator/index.d.ts.map +0 -1
- package/dist/coordinator/index.js +0 -21
- package/dist/coordinator/index.js.map +0 -1
- package/dist/correlation.d.ts +0 -47
- package/dist/correlation.d.ts.map +0 -1
- package/dist/correlation.js +0 -131
- package/dist/correlation.js.map +0 -1
- package/dist/duration.d.ts +0 -27
- package/dist/duration.d.ts.map +0 -1
- package/dist/duration.js +0 -47
- package/dist/duration.js.map +0 -1
- package/dist/errors.d.ts +0 -1303
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -745
- package/dist/errors.js.map +0 -1
- package/dist/h3/_internal/client.d.ts +0 -9
- package/dist/h3/_internal/client.d.ts.map +0 -1
- package/dist/h3/_internal/client.js +0 -652
- package/dist/h3/_internal/client.js.map +0 -1
- package/dist/h3/_internal/contracts.d.ts.map +0 -1
- package/dist/h3/_internal/contracts.js +0 -123
- package/dist/h3/_internal/contracts.js.map +0 -1
- package/dist/h3/_internal/deployment.d.ts +0 -8
- package/dist/h3/_internal/deployment.d.ts.map +0 -1
- package/dist/h3/_internal/deployment.js +0 -149
- package/dist/h3/_internal/deployment.js.map +0 -1
- package/dist/h3/_internal/evidence.d.ts +0 -17
- package/dist/h3/_internal/evidence.d.ts.map +0 -1
- package/dist/h3/_internal/evidence.js +0 -48
- package/dist/h3/_internal/evidence.js.map +0 -1
- package/dist/h3/_internal/operations.d.ts +0 -58
- package/dist/h3/_internal/operations.d.ts.map +0 -1
- package/dist/h3/_internal/operations.js +0 -268
- package/dist/h3/_internal/operations.js.map +0 -1
- package/dist/h3/_internal/references.d.ts +0 -24
- package/dist/h3/_internal/references.d.ts.map +0 -1
- package/dist/h3/_internal/references.js +0 -309
- package/dist/h3/_internal/references.js.map +0 -1
- package/dist/h3/_internal/request.d.ts +0 -21
- package/dist/h3/_internal/request.d.ts.map +0 -1
- package/dist/h3/_internal/request.js +0 -97
- package/dist/h3/_internal/request.js.map +0 -1
- package/dist/h3/_internal/retained.d.ts +0 -22
- package/dist/h3/_internal/retained.d.ts.map +0 -1
- package/dist/h3/_internal/retained.js +0 -89
- package/dist/h3/_internal/retained.js.map +0 -1
- package/dist/h3/_internal/state.d.ts +0 -44
- package/dist/h3/_internal/state.d.ts.map +0 -1
- package/dist/h3/_internal/state.js +0 -283
- package/dist/h3/_internal/state.js.map +0 -1
- package/dist/h3/index.d.ts +0 -10
- package/dist/h3/index.d.ts.map +0 -1
- package/dist/h3/index.js +0 -7
- package/dist/h3/index.js.map +0 -1
- package/dist/h3/messages.d.ts.map +0 -1
- package/dist/h3/messages.js.map +0 -1
- package/dist/h3/profile.d.ts.map +0 -1
- package/dist/h3/profile.js.map +0 -1
- package/dist/h3/types.d.ts +0 -291
- package/dist/h3/types.d.ts.map +0 -1
- package/dist/h3/types.js +0 -2
- package/dist/h3/types.js.map +0 -1
- package/dist/host.d.ts +0 -26
- package/dist/host.d.ts.map +0 -1
- package/dist/host.js +0 -20
- package/dist/host.js.map +0 -1
- package/dist/json.d.ts +0 -25
- package/dist/json.d.ts.map +0 -1
- package/dist/json.js +0 -143
- package/dist/json.js.map +0 -1
- package/dist/media-stream.d.ts +0 -10
- package/dist/media-stream.d.ts.map +0 -1
- package/dist/media-stream.js +0 -18
- package/dist/media-stream.js.map +0 -1
- package/dist/observation.d.ts +0 -38
- package/dist/observation.d.ts.map +0 -1
- package/dist/observation.js +0 -113
- package/dist/observation.js.map +0 -1
- package/dist/orchestration/elapsed.d.ts +0 -9
- package/dist/orchestration/elapsed.d.ts.map +0 -1
- package/dist/orchestration/elapsed.js +0 -8
- package/dist/orchestration/elapsed.js.map +0 -1
- package/dist/orchestration/h3-source.d.ts +0 -58
- package/dist/orchestration/h3-source.d.ts.map +0 -1
- package/dist/orchestration/h3-source.js +0 -362
- package/dist/orchestration/h3-source.js.map +0 -1
- package/dist/orchestration/index.d.ts +0 -17
- package/dist/orchestration/index.d.ts.map +0 -1
- package/dist/orchestration/index.js +0 -12
- package/dist/orchestration/index.js.map +0 -1
- package/dist/orchestration/media-buffer.d.ts +0 -32
- package/dist/orchestration/media-buffer.d.ts.map +0 -1
- package/dist/orchestration/media-buffer.js +0 -94
- package/dist/orchestration/media-buffer.js.map +0 -1
- package/dist/orchestration/open-h3.d.ts +0 -101
- package/dist/orchestration/open-h3.d.ts.map +0 -1
- package/dist/orchestration/open-h3.js +0 -127
- package/dist/orchestration/open-h3.js.map +0 -1
- package/dist/orchestration/queries.d.ts +0 -10
- package/dist/orchestration/queries.d.ts.map +0 -1
- package/dist/orchestration/queries.js +0 -43
- package/dist/orchestration/queries.js.map +0 -1
- package/dist/orchestration/references.d.ts +0 -18
- package/dist/orchestration/references.d.ts.map +0 -1
- package/dist/orchestration/references.js +0 -79
- package/dist/orchestration/references.js.map +0 -1
- package/dist/orchestration/renewal-state.d.ts +0 -84
- package/dist/orchestration/renewal-state.d.ts.map +0 -1
- package/dist/orchestration/renewal-state.js +0 -95
- package/dist/orchestration/renewal-state.js.map +0 -1
- package/dist/orchestration/renewal.d.ts +0 -103
- package/dist/orchestration/renewal.d.ts.map +0 -1
- package/dist/orchestration/renewal.js +0 -1099
- package/dist/orchestration/renewal.js.map +0 -1
- package/dist/orchestration/request.d.ts +0 -65
- package/dist/orchestration/request.d.ts.map +0 -1
- package/dist/orchestration/request.js +0 -134
- package/dist/orchestration/request.js.map +0 -1
- package/dist/orchestration/retention.d.ts +0 -100
- package/dist/orchestration/retention.d.ts.map +0 -1
- package/dist/orchestration/retention.js +0 -134
- package/dist/orchestration/retention.js.map +0 -1
- package/dist/orchestration/routing.d.ts +0 -21
- package/dist/orchestration/routing.d.ts.map +0 -1
- package/dist/orchestration/routing.js +0 -93
- package/dist/orchestration/routing.js.map +0 -1
- package/dist/orchestration/scheduler-key.d.ts +0 -14
- package/dist/orchestration/scheduler-key.d.ts.map +0 -1
- package/dist/orchestration/scheduler-key.js +0 -62
- package/dist/orchestration/scheduler-key.js.map +0 -1
- package/dist/orchestration/scheduler-policy.d.ts +0 -246
- package/dist/orchestration/scheduler-policy.d.ts.map +0 -1
- package/dist/orchestration/scheduler-policy.js +0 -668
- package/dist/orchestration/scheduler-policy.js.map +0 -1
- package/dist/orchestration/scheduler.d.ts +0 -393
- package/dist/orchestration/scheduler.d.ts.map +0 -1
- package/dist/orchestration/scheduler.js +0 -2621
- package/dist/orchestration/scheduler.js.map +0 -1
- package/dist/orchestration/source-slot.d.ts +0 -124
- package/dist/orchestration/source-slot.d.ts.map +0 -1
- package/dist/orchestration/source-slot.js +0 -348
- package/dist/orchestration/source-slot.js.map +0 -1
- package/dist/orchestration/types.d.ts +0 -1462
- package/dist/orchestration/types.d.ts.map +0 -1
- package/dist/orchestration/types.js +0 -135
- package/dist/orchestration/types.js.map +0 -1
- package/dist/protobuf.d.ts +0 -63
- package/dist/protobuf.d.ts.map +0 -1
- package/dist/protobuf.js +0 -252
- package/dist/protobuf.js.map +0 -1
- package/dist/session/_internal/acquire.d.ts +0 -21
- package/dist/session/_internal/acquire.d.ts.map +0 -1
- package/dist/session/_internal/acquire.js +0 -168
- package/dist/session/_internal/acquire.js.map +0 -1
- package/dist/session/_internal/cleanup.d.ts +0 -19
- package/dist/session/_internal/cleanup.d.ts.map +0 -1
- package/dist/session/_internal/cleanup.js +0 -102
- package/dist/session/_internal/cleanup.js.map +0 -1
- package/dist/session/_internal/lifecycle.d.ts +0 -67
- package/dist/session/_internal/lifecycle.d.ts.map +0 -1
- package/dist/session/_internal/lifecycle.js +0 -142
- package/dist/session/_internal/lifecycle.js.map +0 -1
- package/dist/session/_internal/remote.d.ts +0 -28
- package/dist/session/_internal/remote.d.ts.map +0 -1
- package/dist/session/_internal/remote.js +0 -71
- package/dist/session/_internal/remote.js.map +0 -1
- package/dist/session/_internal/uploads.d.ts +0 -7
- package/dist/session/_internal/uploads.d.ts.map +0 -1
- package/dist/session/_internal/uploads.js +0 -31
- package/dist/session/_internal/uploads.js.map +0 -1
- package/dist/session/commands.d.ts +0 -2
- package/dist/session/commands.d.ts.map +0 -1
- package/dist/session/commands.js +0 -2
- package/dist/session/commands.js.map +0 -1
- package/dist/session/files.d.ts +0 -21
- package/dist/session/files.d.ts.map +0 -1
- package/dist/session/files.js +0 -49
- package/dist/session/files.js.map +0 -1
- package/dist/session/index.d.ts +0 -84
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js +0 -16
- package/dist/session/index.js.map +0 -1
- package/dist/session/media.d.ts +0 -114
- package/dist/session/media.d.ts.map +0 -1
- package/dist/session/media.js +0 -2
- package/dist/session/media.js.map +0 -1
- package/dist/session/recorder.d.ts +0 -24
- package/dist/session/recorder.d.ts.map +0 -1
- package/dist/session/recorder.js +0 -19
- package/dist/session/recorder.js.map +0 -1
- package/dist/session.d.ts +0 -105
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -976
- package/dist/session.js.map +0 -1
- package/dist/simulation/_internal/source.d.ts +0 -12
- package/dist/simulation/_internal/source.d.ts.map +0 -1
- package/dist/simulation/_internal/source.js +0 -513
- package/dist/simulation/_internal/source.js.map +0 -1
- package/dist/simulation/index.d.ts +0 -13
- package/dist/simulation/index.d.ts.map +0 -1
- package/dist/simulation/index.js +0 -12
- package/dist/simulation/index.js.map +0 -1
- package/dist/simulation/types.d.ts +0 -39
- package/dist/simulation/types.d.ts.map +0 -1
- package/dist/simulation/types.js +0 -2
- package/dist/simulation/types.js.map +0 -1
- package/dist/stats.d.ts.map +0 -1
- package/dist/stats.js +0 -205
- package/dist/stats.js.map +0 -1
- package/dist/testing/Faults.d.ts +0 -4
- package/dist/testing/Faults.d.ts.map +0 -1
- package/dist/testing/Faults.js +0 -7
- package/dist/testing/Faults.js.map +0 -1
- package/dist/testing/Png.d.ts +0 -3
- package/dist/testing/Png.d.ts.map +0 -1
- package/dist/testing/Png.js.map +0 -1
- package/dist/testing/Wav.d.ts +0 -14
- package/dist/testing/Wav.d.ts.map +0 -1
- package/dist/testing/Wav.js +0 -37
- package/dist/testing/Wav.js.map +0 -1
- package/dist/testing/index.d.ts +0 -5
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -4
- package/dist/testing/index.js.map +0 -1
- package/dist/wire.d.ts +0 -7
- package/dist/wire.d.ts.map +0 -1
- package/dist/wire.generated.d.ts +0 -305
- package/dist/wire.generated.d.ts.map +0 -1
- package/dist/wire.generated.js +0 -1257
- package/dist/wire.generated.js.map +0 -1
- package/dist/wire.js +0 -5
- package/dist/wire.js.map +0 -1
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A playout `Source` rendered in this process instead of by Reactor: one build
|
|
3
|
+
* slot and a playout queue with H3's autoplay semantics, driven by the
|
|
4
|
+
* application's renderer. `build` makes each clip's value and `present` plays
|
|
5
|
+
* it. It costs nothing, and its session is unending unless given a `lifetime`,
|
|
6
|
+
* so it serves locally rendered material (speech, stills) and demos.
|
|
7
|
+
*
|
|
8
|
+
* Its events keep the order the playout relies on. Each change goes out with
|
|
9
|
+
* the events it implies as one step, in the order the changes happen, and a
|
|
10
|
+
* clip's `Started`, `Ended` or `Failed` comes before the `State` that shows it.
|
|
11
|
+
* So once `enqueue` returns, every `State` lists the clip until its `Ended` or
|
|
12
|
+
* `Failed`, or until it is removed, and none lists it after.
|
|
13
|
+
*
|
|
14
|
+
* A clip's `build` and `present` run in a scope the clip owns. The scope
|
|
15
|
+
* closes once the clip leaves the source: it ended, failed, was stopped or
|
|
16
|
+
* removed, or the source closed. Its finalizers release what the hooks made,
|
|
17
|
+
* which stays usable until then, and they run in full once they start.
|
|
18
|
+
*
|
|
19
|
+
* A hook that fails with the application's own error fails that clip alone:
|
|
20
|
+
* `Failed` with the library's `message`, and the error itself, pretty-printed,
|
|
21
|
+
* in `provider`. A hook that dies or throws, or a finalizer that fails, is a
|
|
22
|
+
* bug the source cannot recover from: the source stops, `events` dies with
|
|
23
|
+
* that defect for every reader, and the playout replaces the session.
|
|
24
|
+
*/
|
|
25
|
+
import * as Arr from "effect/Array";
|
|
26
|
+
import * as Cause from "effect/Cause";
|
|
27
|
+
import * as Deferred from "effect/Deferred";
|
|
28
|
+
import * as Duration from "effect/Duration";
|
|
29
|
+
import * as Effect from "effect/Effect";
|
|
30
|
+
import * as Exit from "effect/Exit";
|
|
31
|
+
import * as Fiber from "effect/Fiber";
|
|
32
|
+
import * as Option from "effect/Option";
|
|
33
|
+
import * as Predicate from "effect/Predicate";
|
|
34
|
+
import * as PubSub from "effect/PubSub";
|
|
35
|
+
import * as Random from "effect/Random";
|
|
36
|
+
import * as Redacted from "effect/Redacted";
|
|
37
|
+
import * as Scope from "effect/Scope";
|
|
38
|
+
import * as Semaphore from "effect/Semaphore";
|
|
39
|
+
import * as Stream from "effect/Stream";
|
|
40
|
+
import * as SubscriptionRef from "effect/SubscriptionRef";
|
|
41
|
+
import * as Deadline from "./internal/deadline.js";
|
|
42
|
+
import { requestSeconds } from "./internal/h3/profile.js";
|
|
43
|
+
import { noAcquisition } from "./Reactor.js";
|
|
44
|
+
import { CommandFailure, ReactorError } from "./ReactorError.js";
|
|
45
|
+
const clipOf = (value) => ({
|
|
46
|
+
clipId: value.clipId,
|
|
47
|
+
request: value.request,
|
|
48
|
+
tag: value.tag,
|
|
49
|
+
seconds: value.seconds,
|
|
50
|
+
});
|
|
51
|
+
const sourceClip = (value) => ({
|
|
52
|
+
clipId: value.clipId,
|
|
53
|
+
tag: value.tag,
|
|
54
|
+
seconds: value.seconds,
|
|
55
|
+
});
|
|
56
|
+
const view = (local) => ({
|
|
57
|
+
available: true,
|
|
58
|
+
building: local.building.map(sourceClip),
|
|
59
|
+
ready: local.ready.map(sourceClip),
|
|
60
|
+
playing: local.playing === undefined ? undefined : sourceClip(local.playing.clip),
|
|
61
|
+
continuable: [],
|
|
62
|
+
});
|
|
63
|
+
/** What plays once nothing does: the clip asked for, else with autoplay on the queue's head. */
|
|
64
|
+
const nextToPlay = (local) => {
|
|
65
|
+
if (local.playing !== undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
if (local.play !== undefined)
|
|
68
|
+
return local.ready.find((value) => value.clipId === local.play);
|
|
69
|
+
return local.autoplay ? local.ready[0] : undefined;
|
|
70
|
+
};
|
|
71
|
+
const refused = (operation, message) => CommandFailure.from(ReactorError.fromCode("InvalidState", message), {
|
|
72
|
+
operation,
|
|
73
|
+
outcome: "not-submitted",
|
|
74
|
+
});
|
|
75
|
+
const invalid = (message) => ReactorError.fromCode("InvalidInput", message, { outcome: "not-submitted" });
|
|
76
|
+
/** A hook's failure, in its own words, for `Failed`'s `provider`. */
|
|
77
|
+
const words = (cause) => cause.pipe(Cause.pretty, Redacted.make);
|
|
78
|
+
/** A clip without a presentation plays for its length. */
|
|
79
|
+
const played = (clip) => Effect.sleep(Duration.seconds(clip.seconds));
|
|
80
|
+
/**
|
|
81
|
+
* Closes a clip's scope, uninterruptibly: a scope counts as closed before its
|
|
82
|
+
* finalizers run, so an interruption would skip the rest of them for good.
|
|
83
|
+
*/
|
|
84
|
+
const release = (scope, exit) => Effect.uninterruptible(Scope.close(scope, exit));
|
|
85
|
+
const make = Effect.fnUntraced(function* (build, present, lifetimeInput) {
|
|
86
|
+
const lifetime = lifetimeInput === undefined
|
|
87
|
+
? Duration.infinity
|
|
88
|
+
: yield* Deadline.decode("LocalSource lifetime")(lifetimeInput);
|
|
89
|
+
if (Duration.isZero(lifetime))
|
|
90
|
+
return yield* invalid("LocalSource lifetime must be positive");
|
|
91
|
+
const hex = (yield* Random.nextIntBetween(0, Number.MAX_SAFE_INTEGER)).toString(16);
|
|
92
|
+
const sessionId = `local-${hex.padStart(14, "0")}`;
|
|
93
|
+
// What the source owns lives in a sequential scope of its own, which the caller's scope closes
|
|
94
|
+
// as one, whatever its own order: its finalizers run in the reverse of the order they are made
|
|
95
|
+
// in below, so the source stops, then its fibers end with their presentations, and only then
|
|
96
|
+
// are the clips released.
|
|
97
|
+
const owned = yield* Scope.fork(yield* Effect.scope, "sequential");
|
|
98
|
+
const clips = yield* Scope.fork(owned);
|
|
99
|
+
const lock = yield* Semaphore.make(1);
|
|
100
|
+
const state = yield* SubscriptionRef.make({
|
|
101
|
+
enqueued: 0,
|
|
102
|
+
building: [],
|
|
103
|
+
ready: [],
|
|
104
|
+
playing: undefined,
|
|
105
|
+
autoplay: false,
|
|
106
|
+
play: undefined,
|
|
107
|
+
popped: new Set(),
|
|
108
|
+
lost: undefined,
|
|
109
|
+
});
|
|
110
|
+
const hub = yield* PubSub.unbounded();
|
|
111
|
+
/** Done once the source stops, lost or closed: the build slot and playback end, and so does a `stop`. */
|
|
112
|
+
const stopped = yield* Deferred.make();
|
|
113
|
+
const video = yield* PubSub.sliding(256);
|
|
114
|
+
const audio = yield* PubSub.sliding(512);
|
|
115
|
+
const sink = {
|
|
116
|
+
video: (frame) => Effect.asVoid(PubSub.publish(video, frame)),
|
|
117
|
+
audio: (frame) => Effect.asVoid(PubSub.publish(audio, frame)),
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Makes one change: `step` gives its result, the next state and the events
|
|
121
|
+
* it implies, which go out with the `State` after them before any other
|
|
122
|
+
* change. An interruption waits for the change to finish, so what readers
|
|
123
|
+
* see never runs ahead of the state.
|
|
124
|
+
*/
|
|
125
|
+
const modify = (step) => lock.withPermit(Effect.uninterruptible(Effect.gen(function* () {
|
|
126
|
+
const local = yield* SubscriptionRef.get(state);
|
|
127
|
+
const [result, next, events = []] = step(local);
|
|
128
|
+
if (next === local)
|
|
129
|
+
return result;
|
|
130
|
+
yield* PubSub.publish(hub, Arr.append(events, { _tag: "State", state: view(next) }));
|
|
131
|
+
yield* SubscriptionRef.set(state, next);
|
|
132
|
+
return result;
|
|
133
|
+
})));
|
|
134
|
+
/**
|
|
135
|
+
* Loses the session for good: `events` dies after everything published
|
|
136
|
+
* before, and the source stops. Of the cause, only the defects go out:
|
|
137
|
+
* `events` can fail with the library's errors but not the application's, and
|
|
138
|
+
* an interruption inside a hook is not one of `events`. A cause without a
|
|
139
|
+
* defect, such as a finalizer's own interruption, goes out as the defect
|
|
140
|
+
* Effect squashes it to.
|
|
141
|
+
*/
|
|
142
|
+
const lose = (cause) => lock.withPermit(Effect.uninterruptible(Effect.gen(function* () {
|
|
143
|
+
const local = yield* SubscriptionRef.get(state);
|
|
144
|
+
if (local.lost !== undefined)
|
|
145
|
+
return;
|
|
146
|
+
const dies = cause.reasons.filter(Cause.isDieReason);
|
|
147
|
+
const lost = dies.length > 0 ? Cause.fromReasons(dies) : cause.pipe(Cause.squash, Cause.die);
|
|
148
|
+
yield* PubSub.publish(hub, Exit.failCause(lost));
|
|
149
|
+
yield* SubscriptionRef.set(state, { ...local, lost });
|
|
150
|
+
yield* Deferred.succeed(stopped, undefined);
|
|
151
|
+
})));
|
|
152
|
+
/** The first value `pick` finds in the state, now or once it changes. */
|
|
153
|
+
const first = (pick) => SubscriptionRef.changes(state).pipe(Stream.map(pick), Stream.filter(Predicate.isNotUndefined), Stream.runHead, Effect.map(Option.getOrThrow));
|
|
154
|
+
/**
|
|
155
|
+
* `effect`, where any failure loses the session. Its fiber's own
|
|
156
|
+
* interruption is not one: Effect runs no handler for it.
|
|
157
|
+
*/
|
|
158
|
+
const guard = (effect) => Effect.catchCause(effect, lose);
|
|
159
|
+
/** Runs `loop` until it is interrupted; a failure in it, a hook's defect included, loses the session. */
|
|
160
|
+
const keep = (loop) => loop.pipe(Effect.forever, guard, Effect.forkIn(owned));
|
|
161
|
+
const without = (clipId) => (values) => values.filter((value) => value.clipId !== clipId);
|
|
162
|
+
// One build slot: the head of the building queue builds, then waits Ready unless it was removed.
|
|
163
|
+
const building = yield* keep(Effect.gen(function* () {
|
|
164
|
+
const next = yield* first((local) => local.building[0]);
|
|
165
|
+
const scope = yield* Scope.fork(clips);
|
|
166
|
+
const built = yield* Effect.suspend(() => build(next)).pipe(Scope.provide(scope), Effect.exit);
|
|
167
|
+
if (Exit.isFailure(built) && Cause.hasDies(built.cause))
|
|
168
|
+
return yield* Effect.failCause(built.cause);
|
|
169
|
+
const leaves = (local) => ({
|
|
170
|
+
...local,
|
|
171
|
+
building: without(next.clipId)(local.building),
|
|
172
|
+
popped: new Set([...local.popped].filter((id) => id !== next.clipId)),
|
|
173
|
+
});
|
|
174
|
+
/** Fails the clip; a removed one leaves without a failure, as it would have without its build. */
|
|
175
|
+
const fails = (message, provider) => Effect.andThen(modify((local) => [
|
|
176
|
+
undefined,
|
|
177
|
+
leaves(local),
|
|
178
|
+
local.popped.has(next.clipId)
|
|
179
|
+
? []
|
|
180
|
+
: [{ _tag: "Failed", clip: sourceClip(next), message, provider }],
|
|
181
|
+
]), release(scope, built));
|
|
182
|
+
if (Exit.isFailure(built))
|
|
183
|
+
return yield* fails("the local build failed", words(built.cause));
|
|
184
|
+
const seconds = built.value.seconds ?? next.seconds;
|
|
185
|
+
if (!(Number.isFinite(seconds) && seconds > 0))
|
|
186
|
+
return yield* fails("the local build gave a length that is not a positive, finite number of seconds", Redacted.make(String(seconds)));
|
|
187
|
+
const ready = { ...next, seconds, value: built.value.value, scope };
|
|
188
|
+
const popped = yield* modify((local) => local.popped.has(next.clipId)
|
|
189
|
+
? [true, leaves(local)]
|
|
190
|
+
: [false, { ...leaves(local), ready: [...local.ready, ready] }]);
|
|
191
|
+
if (popped)
|
|
192
|
+
yield* release(scope, Exit.void);
|
|
193
|
+
}));
|
|
194
|
+
// Playback: a clip plays once nothing else does, as `nextToPlay` picks it.
|
|
195
|
+
const playback = yield* keep(Effect.gen(function* () {
|
|
196
|
+
yield* first(nextToPlay);
|
|
197
|
+
const stop = yield* Deferred.make();
|
|
198
|
+
const clip = yield* modify((local) => {
|
|
199
|
+
const next = nextToPlay(local);
|
|
200
|
+
if (next === undefined)
|
|
201
|
+
return [undefined, local];
|
|
202
|
+
return [
|
|
203
|
+
next,
|
|
204
|
+
{
|
|
205
|
+
...local,
|
|
206
|
+
ready: without(next.clipId)(local.ready),
|
|
207
|
+
playing: { clip: next, stop },
|
|
208
|
+
play: undefined,
|
|
209
|
+
},
|
|
210
|
+
[{ _tag: "Started", clip: sourceClip(next) }],
|
|
211
|
+
];
|
|
212
|
+
});
|
|
213
|
+
if (clip === undefined)
|
|
214
|
+
return;
|
|
215
|
+
const presentation = yield* Effect.suspend(() => present(clipOf(clip), clip.value, sink)).pipe(Scope.provide(clip.scope), Effect.forkChild());
|
|
216
|
+
const stopping = yield* Effect.raceFirst(Effect.as(Fiber.await(presentation), false), Effect.as(Deferred.await(stop), true));
|
|
217
|
+
// A stopped presentation is interrupted and waited for, so a defect as it stops still counts.
|
|
218
|
+
if (stopping)
|
|
219
|
+
yield* Fiber.interrupt(presentation);
|
|
220
|
+
const presented = yield* Fiber.await(presentation);
|
|
221
|
+
if (Exit.isFailure(presented) && Cause.hasDies(presented.cause))
|
|
222
|
+
return yield* Effect.failCause(presented.cause);
|
|
223
|
+
const ended = stopping || Exit.isSuccess(presented)
|
|
224
|
+
? {
|
|
225
|
+
_tag: "Ended",
|
|
226
|
+
clip: sourceClip(clip),
|
|
227
|
+
termination: stopping ? "stopped" : "finished",
|
|
228
|
+
}
|
|
229
|
+
: {
|
|
230
|
+
_tag: "Failed",
|
|
231
|
+
clip: sourceClip(clip),
|
|
232
|
+
message: "the local presentation failed",
|
|
233
|
+
provider: words(presented.cause),
|
|
234
|
+
};
|
|
235
|
+
yield* modify((local) => [undefined, { ...local, playing: undefined }, [ended]]);
|
|
236
|
+
yield* release(clip.scope, presented);
|
|
237
|
+
}));
|
|
238
|
+
// Once the source stops, the build slot and playback end, and a presentation stops with its
|
|
239
|
+
// playback. The fibers are interrupted rather than raced against the signal: in Effect
|
|
240
|
+
// 4.0.0-rc.117, a race whose own fiber is interrupted while that fiber is running can leave the
|
|
241
|
+
// losing side running, unwaited.
|
|
242
|
+
yield* Deferred.await(stopped).pipe(Effect.andThen(Fiber.interruptAll([building, playback])), Effect.forkIn(owned));
|
|
243
|
+
// Made last, so it runs first as the source closes: a `stop` waiting on playback returns.
|
|
244
|
+
yield* Scope.addFinalizer(owned, Deferred.succeed(stopped, undefined));
|
|
245
|
+
const source = {
|
|
246
|
+
sessionId,
|
|
247
|
+
lifetime,
|
|
248
|
+
events: Stream.unwrap(lock.withPermit(Effect.gen(function* () {
|
|
249
|
+
// Subscribed and read under the lock, so the first State is the one every later event follows.
|
|
250
|
+
const subscription = yield* PubSub.subscribe(hub);
|
|
251
|
+
const local = yield* SubscriptionRef.get(state);
|
|
252
|
+
const current = Stream.succeed({ _tag: "State", state: view(local) });
|
|
253
|
+
return Stream.concat(current, local.lost === undefined
|
|
254
|
+
? subscription.pipe(Stream.fromSubscription, Stream.flattenTake)
|
|
255
|
+
: Stream.failCause(local.lost));
|
|
256
|
+
}))),
|
|
257
|
+
enqueue: (request, tag, _continueFrom) => modify((local) => {
|
|
258
|
+
const clip = {
|
|
259
|
+
clipId: `${sessionId}-clip-${String(local.enqueued + 1)}`,
|
|
260
|
+
request,
|
|
261
|
+
tag,
|
|
262
|
+
seconds: request.seconds ?? requestSeconds.min,
|
|
263
|
+
};
|
|
264
|
+
return [
|
|
265
|
+
clip.clipId,
|
|
266
|
+
{ ...local, enqueued: local.enqueued + 1, building: [...local.building, clip] },
|
|
267
|
+
];
|
|
268
|
+
}),
|
|
269
|
+
remove: (clipId) => Effect.gen(function* () {
|
|
270
|
+
const removal = yield* modify((local) => {
|
|
271
|
+
if (local.playing?.clip.clipId === clipId)
|
|
272
|
+
return [{ _tag: "Refused", message: "the clip is playing" }, local];
|
|
273
|
+
const ready = local.ready.find((value) => value.clipId === clipId);
|
|
274
|
+
if (ready !== undefined)
|
|
275
|
+
return [
|
|
276
|
+
{ _tag: "Released", clip: ready },
|
|
277
|
+
{
|
|
278
|
+
...local,
|
|
279
|
+
ready: without(clipId)(local.ready),
|
|
280
|
+
play: local.play === clipId ? undefined : local.play,
|
|
281
|
+
},
|
|
282
|
+
];
|
|
283
|
+
const index = local.building.findIndex((value) => value.clipId === clipId);
|
|
284
|
+
if (index < 0)
|
|
285
|
+
return [{ _tag: "Refused", message: "no such clip" }, local];
|
|
286
|
+
// A removed build in flight keeps the slot until it finishes; its clip leaves then.
|
|
287
|
+
return [
|
|
288
|
+
{ _tag: "Popped" },
|
|
289
|
+
index === 0
|
|
290
|
+
? { ...local, popped: new Set(local.popped).add(clipId) }
|
|
291
|
+
: { ...local, building: without(clipId)(local.building) },
|
|
292
|
+
];
|
|
293
|
+
});
|
|
294
|
+
switch (removal._tag) {
|
|
295
|
+
case "Refused":
|
|
296
|
+
return yield* refused("pop", removal.message);
|
|
297
|
+
case "Released":
|
|
298
|
+
// A finalizer that fails is the renderer's bug, and loses the session as a hook's would.
|
|
299
|
+
return yield* guard(release(removal.clip.scope, Exit.void));
|
|
300
|
+
case "Popped":
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
}),
|
|
304
|
+
move: (clipId, position) => modify((local) => {
|
|
305
|
+
const moved = local.ready.find((other) => other.clipId === clipId);
|
|
306
|
+
if (moved === undefined)
|
|
307
|
+
return [undefined, local];
|
|
308
|
+
const rest = without(clipId)(local.ready);
|
|
309
|
+
return [
|
|
310
|
+
undefined,
|
|
311
|
+
{ ...local, ready: [...rest.slice(0, position), moved, ...rest.slice(position)] },
|
|
312
|
+
];
|
|
313
|
+
}),
|
|
314
|
+
setAutoplay: (enabled) => modify((local) => local.autoplay === enabled
|
|
315
|
+
? [undefined, local]
|
|
316
|
+
: [undefined, { ...local, autoplay: enabled }]),
|
|
317
|
+
stop: (clipId) => Effect.gen(function* () {
|
|
318
|
+
const playing = (yield* SubscriptionRef.get(state)).playing;
|
|
319
|
+
if (playing?.clip.clipId !== clipId)
|
|
320
|
+
return;
|
|
321
|
+
yield* Deferred.succeed(playing.stop, undefined);
|
|
322
|
+
// It has ended once playback takes it off, after its `Ended` went out, or once the
|
|
323
|
+
// source stopped, lost or closed, when nothing plays any more.
|
|
324
|
+
yield* Effect.raceFirst(first((local) => (local.playing?.clip.clipId === clipId ? undefined : true)), Deferred.await(stopped));
|
|
325
|
+
}),
|
|
326
|
+
play: (clipId) => Effect.flatMap(modify((local) => {
|
|
327
|
+
if (local.playing !== undefined)
|
|
328
|
+
return ["a clip is playing", local];
|
|
329
|
+
if (!local.ready.some((value) => value.clipId === clipId))
|
|
330
|
+
return ["no Ready clip has this id", local];
|
|
331
|
+
return [undefined, { ...local, play: clipId }];
|
|
332
|
+
}), (refusal) => (refusal === undefined ? Effect.void : Effect.fail(refused("play", refusal)))),
|
|
333
|
+
video: Stream.fromPubSub(video),
|
|
334
|
+
audio: Stream.fromPubSub(audio),
|
|
335
|
+
close: Effect.succeed(noAcquisition),
|
|
336
|
+
};
|
|
337
|
+
return source;
|
|
338
|
+
});
|
|
339
|
+
/**
|
|
340
|
+
* A local source in the caller's scope, whose hooks run with the services the
|
|
341
|
+
* caller has. Closing the scope stops the source, waits for its presentation
|
|
342
|
+
* to stop, then releases every clip. It fails with `InvalidInput` for a
|
|
343
|
+
* `lifetime` that is not a positive, finite duration, or a `buildRatio` that
|
|
344
|
+
* is negative or not finite.
|
|
345
|
+
*/
|
|
346
|
+
export const open = (options) => {
|
|
347
|
+
if (options?.build !== undefined)
|
|
348
|
+
return make(options.build, options.present ?? played, options.lifetime);
|
|
349
|
+
const ratio = options?.buildRatio ?? 0;
|
|
350
|
+
if (!(Number.isFinite(ratio) && ratio >= 0))
|
|
351
|
+
return Effect.fail(invalid("LocalSource buildRatio must be a finite number, not negative"));
|
|
352
|
+
return make((clip) => Effect.as(Effect.sleep(Duration.seconds(clip.seconds * ratio)), { value: undefined }), played, options?.lifetime);
|
|
353
|
+
};
|
|
354
|
+
//# sourceMappingURL=LocalSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalSource.js","sourceRoot":"","sources":["../src/LocalSource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK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AAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAC/F,MAAM,EACN,OAAO,EAAE,QAAQ,CAClB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/Media.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media a connected session carries: owned decoded frames from a native or
|
|
3
|
+
* simulated host, or platform tracks from a browser. Every value here belongs
|
|
4
|
+
* to one connection generation; a reconnect produces new ones.
|
|
5
|
+
*/
|
|
6
|
+
import type * as Effect from "effect/Effect";
|
|
7
|
+
import type * as Scope from "effect/Scope";
|
|
8
|
+
import * as Stream from "effect/Stream";
|
|
9
|
+
import type { Track } from "./Coordinator.js";
|
|
10
|
+
import type { MediaTrack } from "./Peer.js";
|
|
11
|
+
import type { ReactorError } from "./ReactorError.js";
|
|
12
|
+
/** Four bytes per pixel, rows packed without padding, in this channel order. */
|
|
13
|
+
export type VideoFormat = "BGRA" | "RGBA";
|
|
14
|
+
/**
|
|
15
|
+
* One decoded video frame. Every reader of a track receives the same frame and
|
|
16
|
+
* buffers, so treat them as read-only and copy before changing them.
|
|
17
|
+
*/
|
|
18
|
+
export interface VideoFrame {
|
|
19
|
+
readonly _tag: "VideoFrame";
|
|
20
|
+
readonly track: string;
|
|
21
|
+
readonly width: number;
|
|
22
|
+
readonly height: number;
|
|
23
|
+
/** Zero means the sender supplied no frame identity. */
|
|
24
|
+
readonly frameId: bigint;
|
|
25
|
+
/** Sender-clock microseconds; zero means absent. */
|
|
26
|
+
readonly timestampMicros: bigint;
|
|
27
|
+
/**
|
|
28
|
+
* The frame's admission sequence on its track in this generation, from 0,
|
|
29
|
+
* taken before any bounded queue could drop it: a gap is the count the host
|
|
30
|
+
* dropped there. `recorder` makes the gaps explicit.
|
|
31
|
+
*/
|
|
32
|
+
readonly sequence: bigint;
|
|
33
|
+
readonly format: VideoFormat;
|
|
34
|
+
/** `width * height * 4` owned bytes: the whole of an `ArrayBuffer` of their own. */
|
|
35
|
+
readonly data: Uint8Array<ArrayBuffer>;
|
|
36
|
+
readonly metadata: Uint8Array<ArrayBuffer>;
|
|
37
|
+
}
|
|
38
|
+
/** One block of decoded audio, shared read-only across a track's readers. */
|
|
39
|
+
export interface AudioFrame {
|
|
40
|
+
readonly _tag: "AudioFrame";
|
|
41
|
+
readonly track: string;
|
|
42
|
+
readonly sampleRate: number;
|
|
43
|
+
readonly channels: number;
|
|
44
|
+
readonly sequence: bigint;
|
|
45
|
+
/** Owned, interleaved signed 16-bit PCM in an `ArrayBuffer` of its own. */
|
|
46
|
+
readonly samples: Int16Array<ArrayBuffer>;
|
|
47
|
+
}
|
|
48
|
+
/** Transport pressure observed in one connection generation. */
|
|
49
|
+
export interface MediaPressure {
|
|
50
|
+
readonly closed: boolean;
|
|
51
|
+
readonly queuedControl: number;
|
|
52
|
+
readonly queuedVideo: number;
|
|
53
|
+
readonly queuedAudio: number;
|
|
54
|
+
readonly queuedBytes: number;
|
|
55
|
+
readonly droppedVideo: bigint;
|
|
56
|
+
readonly droppedAudio: bigint;
|
|
57
|
+
readonly pendingRequests: number;
|
|
58
|
+
readonly deliveredVideo: bigint;
|
|
59
|
+
readonly deliveredAudio: bigint;
|
|
60
|
+
/** Readers that fell behind their bound, failed with `Overflow` and missed the rest. */
|
|
61
|
+
readonly readerOverflows: bigint;
|
|
62
|
+
}
|
|
63
|
+
interface Generation {
|
|
64
|
+
readonly generation: bigint;
|
|
65
|
+
readonly tracks: ReadonlyArray<Track>;
|
|
66
|
+
/** Fails when this generation ends. */
|
|
67
|
+
readonly retired: Effect.Effect<never, ReactorError>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A generation's decoded media. Read a track directly to record it (a reader
|
|
71
|
+
* that falls behind fails with `Overflow`), or keep the newest frame for a
|
|
72
|
+
* preview with `Stream.buffer({ capacity: 1, strategy: "sliding" })`.
|
|
73
|
+
*/
|
|
74
|
+
export interface DecodedMedia extends Generation {
|
|
75
|
+
readonly video: (name: string) => Stream.Stream<VideoFrame, ReactorError>;
|
|
76
|
+
readonly audio: (name: string) => Stream.Stream<AudioFrame, ReactorError>;
|
|
77
|
+
readonly pressure: Effect.Effect<MediaPressure, ReactorError>;
|
|
78
|
+
}
|
|
79
|
+
/** A generation's platform tracks: leases of received tracks and publication of sent ones. */
|
|
80
|
+
export interface TrackMedia extends Generation {
|
|
81
|
+
readonly track: (name: string) => Effect.Effect<MediaTrack, ReactorError, Scope.Scope>;
|
|
82
|
+
readonly publish: (name: string, source: MediaTrack) => Effect.Effect<void, ReactorError>;
|
|
83
|
+
readonly unpublish: (name: string) => Effect.Effect<void, ReactorError>;
|
|
84
|
+
readonly setTrackActive: (name: string, active: boolean) => Effect.Effect<void, ReactorError>;
|
|
85
|
+
readonly setMaxBitrate: (name: string, bitsPerSecond: number) => Effect.Effect<void, ReactorError>;
|
|
86
|
+
}
|
|
87
|
+
/** A recorder's view of one track: each frame, and each run the host dropped, in place. */
|
|
88
|
+
export type Recorded<F> = {
|
|
89
|
+
readonly _tag: "Frame";
|
|
90
|
+
readonly frame: F;
|
|
91
|
+
} | {
|
|
92
|
+
readonly _tag: "Lost";
|
|
93
|
+
/** The sequence of the last frame received before the loss. */
|
|
94
|
+
readonly after: bigint;
|
|
95
|
+
readonly count: bigint;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Every frame a track delivers, with a `Lost` element wherever the host dropped
|
|
99
|
+
* frames between two it delivered. The view starts at the first frame
|
|
100
|
+
* received, and a sequence that goes back starts a new run (a new generation).
|
|
101
|
+
*/
|
|
102
|
+
export declare const recorder: <F extends {
|
|
103
|
+
readonly sequence: bigint;
|
|
104
|
+
}, E, R>(frames: Stream.Stream<F, E, R>) => Stream.Stream<Recorded<F>, E, R>;
|
|
105
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,QAAQ,GAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EAAE,CAAC,UAC5D,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAc/B,CAAC"}
|
package/dist/Media.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as Stream from "effect/Stream";
|
|
2
|
+
/**
|
|
3
|
+
* Every frame a track delivers, with a `Lost` element wherever the host dropped
|
|
4
|
+
* frames between two it delivered. The view starts at the first frame
|
|
5
|
+
* received, and a sequence that goes back starts a new run (a new generation).
|
|
6
|
+
*/
|
|
7
|
+
export const recorder = (frames) => frames.pipe(Stream.mapAccum(() => undefined, (last, frame) => {
|
|
8
|
+
const received = { _tag: "Frame", frame };
|
|
9
|
+
if (last === undefined || frame.sequence <= last || frame.sequence === last + 1n)
|
|
10
|
+
return [frame.sequence, [received]];
|
|
11
|
+
return [
|
|
12
|
+
frame.sequence,
|
|
13
|
+
[{ _tag: "Lost", after: last, count: frame.sequence - last - 1n }, received],
|
|
14
|
+
];
|
|
15
|
+
}));
|
|
16
|
+
//# sourceMappingURL=Media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Media.js","sourceRoot":"","sources":["../src/Media.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAoGxC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,MAA8B,EACI,EAAE,CACpC,MAAM,CAAC,IAAI,CACT,MAAM,CAAC,QAAQ,CACb,GAAuB,EAAE,CAAC,SAAS,EACnC,CAAC,IAAI,EAAE,KAAK,EAAiD,EAAE;IAC7D,MAAM,QAAQ,GAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACvD,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,GAAG,EAAE;QAC9E,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtC,OAAO;QACL,KAAK,CAAC,QAAQ;QACd,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,EAAE,EAAE,QAAQ,CAAC;KAC7E,CAAC;AACJ,CAAC,CACF,CACF,CAAC"}
|
package/dist/Peer.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import type * as Scope from "effect/Scope";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
6
|
+
import type { IceServer, Track } from "./Coordinator.js";
|
|
7
|
+
import type { AudioFrame, MediaPressure, VideoFrame } from "./Media.js";
|
|
8
|
+
import { ReactorError } from "./ReactorError.js";
|
|
9
|
+
export declare const DataChannel: Schema.Literals<readonly ["control", "data"]>;
|
|
10
|
+
export type DataChannel = typeof DataChannel.Type;
|
|
11
|
+
export declare const PeerState: Schema.Literals<readonly ["new", "connecting", "connected", "disconnected", "failed", "closed"]>;
|
|
12
|
+
export type PeerState = typeof PeerState.Type;
|
|
13
|
+
/** What a host reports about its connection, in the order it happened. */
|
|
14
|
+
export declare const PeerEvent: Schema.Union<readonly [Schema.Struct<{
|
|
15
|
+
readonly type: Schema.Literal<"state">;
|
|
16
|
+
readonly state: Schema.Literals<readonly ["new", "connecting", "connected", "disconnected", "failed", "closed"]>;
|
|
17
|
+
}>, Schema.Struct<{
|
|
18
|
+
readonly type: Schema.Literal<"channel">;
|
|
19
|
+
readonly channel: Schema.Literals<readonly ["control", "data"]>;
|
|
20
|
+
readonly open: Schema.Boolean;
|
|
21
|
+
}>, Schema.Struct<{
|
|
22
|
+
readonly type: Schema.Literal<"message">;
|
|
23
|
+
readonly channel: Schema.Literals<readonly ["control", "data"]>;
|
|
24
|
+
readonly bytes: Schema.Uint8Array;
|
|
25
|
+
}>, Schema.Struct<{
|
|
26
|
+
readonly type: Schema.Literal<"ice">;
|
|
27
|
+
readonly candidate: Schema.optionalKey<Schema.Struct<{
|
|
28
|
+
readonly candidate: Schema.String;
|
|
29
|
+
readonly sdp_mid: Schema.optionalKey<Schema.String>;
|
|
30
|
+
readonly sdp_mline_index: Schema.optionalKey<Schema.Int>;
|
|
31
|
+
}>>;
|
|
32
|
+
}>, Schema.Struct<{
|
|
33
|
+
readonly type: Schema.Literal<"track">;
|
|
34
|
+
readonly name: Schema.String;
|
|
35
|
+
readonly mid: Schema.String;
|
|
36
|
+
}>, Schema.Struct<{
|
|
37
|
+
readonly type: Schema.Literal<"decoded">;
|
|
38
|
+
readonly kind: Schema.Literals<readonly ["video", "audio"]>;
|
|
39
|
+
readonly name: Schema.String;
|
|
40
|
+
readonly mid: Schema.String;
|
|
41
|
+
}>, Schema.Struct<{
|
|
42
|
+
readonly type: Schema.Literal<"error">;
|
|
43
|
+
readonly error: typeof ReactorError;
|
|
44
|
+
}>]>;
|
|
45
|
+
export type PeerEvent = typeof PeerEvent.Type;
|
|
46
|
+
/** An offer and the media section each declared track was given. */
|
|
47
|
+
export declare const Prepared: Schema.Struct<{
|
|
48
|
+
readonly sdp: Schema.String;
|
|
49
|
+
readonly mapping: Schema.$Array<Schema.Struct<{
|
|
50
|
+
readonly name: Schema.NonEmptyString;
|
|
51
|
+
readonly kind: Schema.Literals<readonly ["audio", "video"]>;
|
|
52
|
+
readonly direction: Schema.Literals<readonly ["recvonly", "sendonly"]>;
|
|
53
|
+
readonly mid: Schema.String;
|
|
54
|
+
}>>;
|
|
55
|
+
}>;
|
|
56
|
+
export type Prepared = typeof Prepared.Type;
|
|
57
|
+
/** The lifetime contract of a browser media track, without DOM types. */
|
|
58
|
+
export interface MediaTrack {
|
|
59
|
+
readonly kind: string;
|
|
60
|
+
readonly readyState: "live" | "ended";
|
|
61
|
+
clone(): MediaTrack;
|
|
62
|
+
stop(): void;
|
|
63
|
+
}
|
|
64
|
+
/** What a host does with media: owned decoded frames, or the platform's own tracks. */
|
|
65
|
+
export type PeerMedia = {
|
|
66
|
+
readonly _tag: "Decoded";
|
|
67
|
+
/** One track's frames; the session fences them to the generation that negotiated it. */
|
|
68
|
+
readonly video: (name: string) => Stream.Stream<VideoFrame, ReactorError>;
|
|
69
|
+
readonly audio: (name: string) => Stream.Stream<AudioFrame, ReactorError>;
|
|
70
|
+
readonly pressure: Effect.Effect<MediaPressure, ReactorError>;
|
|
71
|
+
} | {
|
|
72
|
+
readonly _tag: "Tracks";
|
|
73
|
+
/** A clone of a received track, stopped when the scope closes. */
|
|
74
|
+
readonly lease: (name: string) => Effect.Effect<MediaTrack, ReactorError, Scope.Scope>;
|
|
75
|
+
/** Attach `track` (a session-owned clone) to a send-only track, or detach with null. */
|
|
76
|
+
readonly replace: (name: string, track: MediaTrack | null) => Effect.Effect<void, ReactorError>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* How a decoded host delivers one received track. Every reader gets every
|
|
80
|
+
* frame; a reader that falls behind its bounds fails with `Overflow`, and is
|
|
81
|
+
* counted in `overflows`, rather than holding up the host or silently skipping
|
|
82
|
+
* frames. A reader that starts after the feed ended sees the same end.
|
|
83
|
+
*/
|
|
84
|
+
export interface TrackFeed<A> {
|
|
85
|
+
readonly publish: (frame: A) => Effect.Effect<void>;
|
|
86
|
+
/** A new reader each time the stream runs. */
|
|
87
|
+
readonly stream: Stream.Stream<A, ReactorError>;
|
|
88
|
+
readonly end: Effect.Effect<void>;
|
|
89
|
+
readonly fail: (error: ReactorError) => Effect.Effect<void>;
|
|
90
|
+
/** Readers that fell behind and failed; a host reports it as `readerOverflows`. */
|
|
91
|
+
readonly overflows: Effect.Effect<bigint>;
|
|
92
|
+
}
|
|
93
|
+
/** A track's feed, each reader holding at most `capacity` frames and `maxBytes` of them. */
|
|
94
|
+
export declare const trackFeed: <A>(bounds: {
|
|
95
|
+
readonly capacity: number;
|
|
96
|
+
readonly maxBytes: number;
|
|
97
|
+
readonly bytes: (frame: A) => number;
|
|
98
|
+
}) => Effect.Effect<TrackFeed<A>>;
|
|
99
|
+
/** One connection generation's transport. */
|
|
100
|
+
export interface Peer {
|
|
101
|
+
readonly media: PeerMedia;
|
|
102
|
+
/**
|
|
103
|
+
* Gathers and returns the offer. The host calls `emit` for every later event,
|
|
104
|
+
* synchronously and without waiting: platform peers are callback-driven, so
|
|
105
|
+
* this is the host boundary, and the session buffers what it receives.
|
|
106
|
+
*/
|
|
107
|
+
readonly prepare: (servers: ReadonlyArray<IceServer>, tracks: ReadonlyArray<Track>, emit: (event: PeerEvent) => void) => Effect.Effect<Prepared, ReactorError, Scope.Scope>;
|
|
108
|
+
readonly answer: (sdp: string) => Effect.Effect<void, ReactorError>;
|
|
109
|
+
/** Local submission; never a Reactor reply. */
|
|
110
|
+
readonly send: (channel: DataChannel, bytes: Uint8Array<ArrayBuffer>) => Effect.Effect<void, ReactorError>;
|
|
111
|
+
readonly direction: (name: string, active: boolean) => Effect.Effect<void, ReactorError>;
|
|
112
|
+
readonly maxBitrate: (name: string, bitsPerSecond: number) => Effect.Effect<void, ReactorError>;
|
|
113
|
+
readonly stats: Effect.Effect<ReadonlyArray<unknown>, ReactorError>;
|
|
114
|
+
/**
|
|
115
|
+
* Fences the transport at once, so nothing is emitted or sent after it.
|
|
116
|
+
* The factory's scope then shuts the host down within its own bound.
|
|
117
|
+
*/
|
|
118
|
+
readonly close: Effect.Effect<void>;
|
|
119
|
+
}
|
|
120
|
+
declare const PeerFactory_base: Context.ServiceClass<PeerFactory, "reactor-effect-client/Peer/PeerFactory", {
|
|
121
|
+
/**
|
|
122
|
+
* Fails when the host cannot make a peer now, such as while a native
|
|
123
|
+
* owner join is still outstanding. It runs before every allocation, so no
|
|
124
|
+
* paid session is allocated for a peer that cannot be made.
|
|
125
|
+
*/
|
|
126
|
+
readonly check: Effect.Effect<void, ReactorError>;
|
|
127
|
+
/** A fresh peer for one connection generation; closing the scope shuts it down. */
|
|
128
|
+
readonly make: Effect.Effect<Peer, ReactorError, Scope.Scope>;
|
|
129
|
+
}>;
|
|
130
|
+
/** A host's transport capability. Building its layer is the host's preflight. */
|
|
131
|
+
export declare class PeerFactory extends PeerFactory_base {
|
|
132
|
+
}
|
|
133
|
+
export {};
|
|
134
|
+
//# sourceMappingURL=Peer.d.ts.map
|