@livekit/rtc-node 0.13.3 → 0.13.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/dist/data_streams/index.cjs +25 -0
- package/dist/data_streams/index.cjs.map +1 -0
- package/dist/data_streams/index.d.cts +11 -0
- package/dist/data_streams/index.d.ts +11 -0
- package/dist/data_streams/index.d.ts.map +1 -0
- package/dist/data_streams/index.js +3 -0
- package/dist/data_streams/index.js.map +1 -0
- package/dist/data_streams/stream_reader.cjs +141 -0
- package/dist/data_streams/stream_reader.cjs.map +1 -0
- package/dist/data_streams/stream_reader.d.cts +10 -0
- package/dist/data_streams/stream_reader.d.ts +10 -0
- package/dist/data_streams/stream_reader.d.ts.map +1 -0
- package/dist/data_streams/stream_reader.js +116 -0
- package/dist/data_streams/stream_reader.js.map +1 -0
- package/dist/data_streams/stream_writer.cjs +51 -0
- package/dist/data_streams/stream_writer.cjs.map +1 -0
- package/dist/data_streams/stream_writer.d.cts +26 -0
- package/dist/data_streams/stream_writer.d.ts +26 -0
- package/dist/data_streams/stream_writer.d.ts.map +1 -0
- package/dist/data_streams/stream_writer.js +26 -0
- package/dist/data_streams/stream_writer.js.map +1 -0
- package/dist/data_streams/types.cjs +17 -0
- package/dist/data_streams/types.cjs.map +1 -0
- package/dist/data_streams/types.d.cts +10 -0
- package/dist/data_streams/types.d.ts +10 -0
- package/dist/data_streams/types.d.ts.map +1 -0
- package/dist/data_streams/types.js +1 -0
- package/dist/data_streams/types.js.map +1 -0
- package/dist/index.cjs +7 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/log.cjs +42 -0
- package/dist/log.cjs.map +1 -0
- package/dist/log.d.cts +7 -0
- package/dist/log.d.ts +7 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +18 -0
- package/dist/log.js.map +1 -0
- package/dist/napi/native.d.cjs.map +1 -1
- package/dist/napi/native.d.ts +5 -5
- package/dist/native.d.ts +5 -5
- package/dist/participant.cjs +249 -16
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +40 -6
- package/dist/participant.d.ts +40 -6
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +252 -5
- package/dist/participant.js.map +1 -1
- package/dist/proto/ffi_pb.cjs +14 -3
- package/dist/proto/ffi_pb.cjs.map +1 -1
- package/dist/proto/ffi_pb.d.cts +81 -7
- package/dist/proto/ffi_pb.d.ts +81 -7
- package/dist/proto/ffi_pb.d.ts.map +1 -1
- package/dist/proto/ffi_pb.js +15 -4
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/room_pb.cjs +488 -30
- package/dist/proto/room_pb.cjs.map +1 -1
- package/dist/proto/room_pb.d.cts +412 -50
- package/dist/proto/room_pb.d.ts +412 -50
- package/dist/proto/room_pb.d.ts.map +1 -1
- package/dist/proto/room_pb.js +471 -29
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/proto/video_frame_pb.cjs.map +1 -1
- package/dist/proto/video_frame_pb.d.cts +3 -0
- package/dist/proto/video_frame_pb.d.ts +3 -0
- package/dist/proto/video_frame_pb.d.ts.map +1 -1
- package/dist/proto/video_frame_pb.js.map +1 -1
- package/dist/room.cjs +121 -0
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +17 -2
- package/dist/room.d.ts +17 -2
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +122 -0
- package/dist/room.js.map +1 -1
- package/dist/types-B28ZM-Ci.d.cts +88 -0
- package/dist/types-BDnbvXeD.d.ts +88 -0
- package/dist/utils.cjs +61 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +7 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +35 -0
- package/dist/utils.js.map +1 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/video_frame.cjs +2 -0
- package/dist/video_frame.cjs.map +1 -1
- package/dist/video_frame.d.ts.map +1 -1
- package/dist/video_frame.js +2 -0
- package/dist/video_frame.js.map +1 -1
- package/package.json +9 -7
- package/src/data_streams/index.ts +7 -0
- package/src/data_streams/stream_reader.ts +159 -0
- package/src/data_streams/stream_writer.ts +36 -0
- package/src/data_streams/types.ts +55 -0
- package/src/index.ts +1 -0
- package/src/log.ts +25 -0
- package/src/napi/native.d.ts +5 -5
- package/src/participant.ts +337 -29
- package/src/proto/ffi_pb.ts +86 -1
- package/src/proto/room_pb.ts +788 -68
- package/src/proto/video_frame_pb.ts +3 -0
- package/src/room.ts +141 -0
- package/src/utils.test.ts +51 -0
- package/src/utils.ts +42 -0
- package/src/version.ts +1 -1
- package/src/video_frame.ts +2 -0
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { Room, RoomEvent, ConnectError, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { Participant, RemoteParticipant, LocalParticipant } from './participant.js';\nexport {\n Track,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n type AudioTrack,\n} from './track.js';\nexport { VideoFrame } from './video_frame.js';\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioStream } from './audio_stream.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\nexport { AudioSource } from './audio_source.js';\nexport { VideoSource } from './video_source.js';\nexport {\n TrackPublication,\n RemoteTrackPublication,\n LocalTrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport { E2EEManager, KeyProvider, FrameCryptor } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport {\n ConnectionQuality,\n IceServer,\n IceTransportType,\n DataPacketKind,\n ContinualGatheringPolicy,\n TrackPublishOptions,\n ConnectionState,\n} from './proto/room_pb.js';\nexport { RpcError, type RpcInvocationData, type PerformRpcParams } from './rpc.js';\nexport { EncryptionType, EncryptionState } from './proto/e2ee_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoRotation, VideoCodec } from './proto/video_frame_pb.js';\nexport { ParticipantKind } from './proto/participant_pb.js';\nexport { dispose } from './ffi_client.js';\nexport type { ChatMessage } from './types.js';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { Room, RoomEvent, ConnectError, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { Participant, RemoteParticipant, LocalParticipant } from './participant.js';\nexport {\n Track,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n type AudioTrack,\n} from './track.js';\nexport { VideoFrame } from './video_frame.js';\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioStream } from './audio_stream.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\nexport { AudioSource } from './audio_source.js';\nexport { VideoSource } from './video_source.js';\nexport {\n TrackPublication,\n RemoteTrackPublication,\n LocalTrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport { E2EEManager, KeyProvider, FrameCryptor } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport * from './data_streams/index.js';\nexport {\n ConnectionQuality,\n IceServer,\n IceTransportType,\n DataPacketKind,\n ContinualGatheringPolicy,\n TrackPublishOptions,\n ConnectionState,\n} from './proto/room_pb.js';\nexport { RpcError, type RpcInvocationData, type PerformRpcParams } from './rpc.js';\nexport { EncryptionType, EncryptionState } from './proto/e2ee_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoRotation, VideoCodec } from './proto/video_frame_pb.js';\nexport { ParticipantKind } from './proto/participant_pb.js';\nexport { dispose } from './ffi_client.js';\nexport type { ChatMessage } from './types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAuF;AACvF,yBAAiE;AACjE,mBAUO;AACP,yBAA2B;AAC3B,yBAA+C;AAC/C,0BAA4B;AAC5B,6BAAsD;AACtD,0BAAkD;AAClD,0BAA4B;AAC5B,0BAA4B;AAC5B,+BAIO;AAEP,kBAAuD;AAEvD,0BAAc,oCAhCd;AAiCA,qBAQO;AACP,iBAAwE;AACxE,qBAAgD;AAChD,sBAAoD;AACpD,4BAA2D;AAC3D,4BAAgC;AAChC,wBAAwB;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -11,6 +11,8 @@ export { VideoSource } from './video_source.cjs';
|
|
|
11
11
|
export { LocalTrackPublication, RemoteTrackPublication, TrackPublication } from './track_publication.cjs';
|
|
12
12
|
export { Transcription, TranscriptionSegment } from './transcription.cjs';
|
|
13
13
|
export { E2EEManager, E2EEOptions, FrameCryptor, KeyProvider, KeyProviderOptions } from './e2ee.cjs';
|
|
14
|
+
export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, B as ByteStreamReader, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions, T as TextStreamReader } from './types-B28ZM-Ci.cjs';
|
|
15
|
+
export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.cjs';
|
|
14
16
|
export { ConnectionQuality, ConnectionState, ContinualGatheringPolicy, DataPacketKind, IceServer, IceTransportType, TrackPublishOptions } from './proto/room_pb.cjs';
|
|
15
17
|
export { PerformRpcParams, RpcError, RpcInvocationData } from './rpc.cjs';
|
|
16
18
|
export { EncryptionState, EncryptionType } from './proto/e2ee_pb.cjs';
|
|
@@ -20,9 +22,11 @@ export { ParticipantKind } from './proto/participant_pb.cjs';
|
|
|
20
22
|
export { livekitDispose as dispose } from './napi/native.d.cjs';
|
|
21
23
|
export { ChatMessage } from './types.cjs';
|
|
22
24
|
import '@livekit/typed-emitter';
|
|
25
|
+
import 'node:fs';
|
|
23
26
|
import './proto/audio_frame_pb.cjs';
|
|
24
27
|
import '@bufbuild/protobuf';
|
|
25
28
|
import './proto/handle_pb.cjs';
|
|
26
29
|
import '@livekit/mutex';
|
|
30
|
+
import 'node:stream/web';
|
|
27
31
|
import './proto/stats_pb.cjs';
|
|
28
32
|
import './proto/rpc_pb.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export { VideoSource } from './video_source.js';
|
|
|
11
11
|
export { LocalTrackPublication, RemoteTrackPublication, TrackPublication } from './track_publication.js';
|
|
12
12
|
export { Transcription, TranscriptionSegment } from './transcription.js';
|
|
13
13
|
export { E2EEManager, E2EEOptions, FrameCryptor, KeyProvider, KeyProviderOptions } from './e2ee.js';
|
|
14
|
+
export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, B as ByteStreamReader, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions, T as TextStreamReader } from './types-BDnbvXeD.js';
|
|
15
|
+
export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.js';
|
|
14
16
|
export { ConnectionQuality, ConnectionState, ContinualGatheringPolicy, DataPacketKind, IceServer, IceTransportType, TrackPublishOptions } from './proto/room_pb.js';
|
|
15
17
|
export { PerformRpcParams, RpcError, RpcInvocationData } from './rpc.js';
|
|
16
18
|
export { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';
|
|
@@ -20,9 +22,11 @@ export { ParticipantKind } from './proto/participant_pb.js';
|
|
|
20
22
|
export { livekitDispose as dispose } from './napi/native.d.js';
|
|
21
23
|
export { ChatMessage } from './types.js';
|
|
22
24
|
import '@livekit/typed-emitter';
|
|
25
|
+
import 'node:fs';
|
|
23
26
|
import './proto/audio_frame_pb.js';
|
|
24
27
|
import '@bufbuild/protobuf';
|
|
25
28
|
import './proto/handle_pb.js';
|
|
26
29
|
import '@livekit/mutex';
|
|
30
|
+
import 'node:stream/web';
|
|
27
31
|
import './proto/stats_pb.js';
|
|
28
32
|
import './proto/rpc_pb.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { Room, RoomEvent, ConnectError, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { Participant, RemoteParticipant, LocalParticipant } from './participant.js';\nexport {\n Track,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n type AudioTrack,\n} from './track.js';\nexport { VideoFrame } from './video_frame.js';\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioStream } from './audio_stream.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\nexport { AudioSource } from './audio_source.js';\nexport { VideoSource } from './video_source.js';\nexport {\n TrackPublication,\n RemoteTrackPublication,\n LocalTrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport { E2EEManager, KeyProvider, FrameCryptor } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport {\n ConnectionQuality,\n IceServer,\n IceTransportType,\n DataPacketKind,\n ContinualGatheringPolicy,\n TrackPublishOptions,\n ConnectionState,\n} from './proto/room_pb.js';\nexport { RpcError, type RpcInvocationData, type PerformRpcParams } from './rpc.js';\nexport { EncryptionType, EncryptionState } from './proto/e2ee_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoRotation, VideoCodec } from './proto/video_frame_pb.js';\nexport { ParticipantKind } from './proto/participant_pb.js';\nexport { dispose } from './ffi_client.js';\nexport type { ChatMessage } from './types.js';\n"],"mappings":"AAIA,SAAS,MAAM,WAAW,oBAA6D;AACvF,SAAS,aAAa,mBAAmB,wBAAwB;AACjE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB;AAC3B,SAAS,YAAY,0BAA0B;AAC/C,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,6BAA6B;AACtD,SAAS,mBAAyC;AAClD,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,aAAa,aAAa,oBAAoB;AAEvD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAA+D;AACxE,SAAS,gBAAgB,uBAAuB;AAChD,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,iBAAiB,eAAe,kBAAkB;AAC3D,SAAS,uBAAuB;AAChC,SAAS,eAAe;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { Room, RoomEvent, ConnectError, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { Participant, RemoteParticipant, LocalParticipant } from './participant.js';\nexport {\n Track,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n type AudioTrack,\n} from './track.js';\nexport { VideoFrame } from './video_frame.js';\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioStream } from './audio_stream.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\nexport { AudioSource } from './audio_source.js';\nexport { VideoSource } from './video_source.js';\nexport {\n TrackPublication,\n RemoteTrackPublication,\n LocalTrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport { E2EEManager, KeyProvider, FrameCryptor } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport * from './data_streams/index.js';\nexport {\n ConnectionQuality,\n IceServer,\n IceTransportType,\n DataPacketKind,\n ContinualGatheringPolicy,\n TrackPublishOptions,\n ConnectionState,\n} from './proto/room_pb.js';\nexport { RpcError, type RpcInvocationData, type PerformRpcParams } from './rpc.js';\nexport { EncryptionType, EncryptionState } from './proto/e2ee_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoRotation, VideoCodec } from './proto/video_frame_pb.js';\nexport { ParticipantKind } from './proto/participant_pb.js';\nexport { dispose } from './ffi_client.js';\nexport type { ChatMessage } from './types.js';\n"],"mappings":"AAIA,SAAS,MAAM,WAAW,oBAA6D;AACvF,SAAS,aAAa,mBAAmB,wBAAwB;AACjE;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB;AAC3B,SAAS,YAAY,0BAA0B;AAC/C,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,6BAA6B;AACtD,SAAS,mBAAyC;AAClD,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,aAAa,aAAa,oBAAoB;AAEvD,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAA+D;AACxE,SAAS,gBAAgB,uBAAuB;AAChD,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,iBAAiB,eAAe,kBAAkB;AAC3D,SAAS,uBAAuB;AAChC,SAAS,eAAe;","names":[]}
|
package/dist/log.cjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var log_exports = {};
|
|
20
|
+
__export(log_exports, {
|
|
21
|
+
log: () => log
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(log_exports);
|
|
24
|
+
var import_pino = require("pino");
|
|
25
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
26
|
+
const defaultOptions = { name: "lk-rtc" };
|
|
27
|
+
const devOptions = {
|
|
28
|
+
...defaultOptions,
|
|
29
|
+
transport: {
|
|
30
|
+
target: "pino-pretty",
|
|
31
|
+
options: {
|
|
32
|
+
colorize: true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const log = (0, import_pino.pino)(isProduction ? defaultOptions : devOptions);
|
|
37
|
+
log.level = isProduction ? "info" : "debug";
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
log
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=log.cjs.map
|
package/dist/log.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/log.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { LevelWithSilent, LoggerOptions } from 'pino';\nimport { pino } from 'pino';\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\nconst defaultOptions: LoggerOptions = { name: 'lk-rtc' };\n\nconst devOptions: LoggerOptions = {\n ...defaultOptions,\n transport: {\n target: 'pino-pretty',\n options: {\n colorize: true,\n },\n },\n};\n\nconst log = pino(isProduction ? defaultOptions : devOptions);\nlog.level = isProduction ? 'info' : 'debug';\n\nexport type LogLevel = LevelWithSilent;\nexport { log };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAqB;AAErB,MAAM,eAAe,QAAQ,IAAI,aAAa;AAE9C,MAAM,iBAAgC,EAAE,MAAM,SAAS;AAEvD,MAAM,aAA4B;AAAA,EAChC,GAAG;AAAA,EACH,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,MAAM,UAAM,kBAAK,eAAe,iBAAiB,UAAU;AAC3D,IAAI,QAAQ,eAAe,SAAS;","names":[]}
|
package/dist/log.d.cts
ADDED
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,MAAM,CAAC;AAiB3D,QAAA,MAAM,GAAG,uCAAmD,CAAC;AAG7D,MAAM,MAAM,QAAQ,GAAG,eAAe,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { pino } from "pino";
|
|
2
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
3
|
+
const defaultOptions = { name: "lk-rtc" };
|
|
4
|
+
const devOptions = {
|
|
5
|
+
...defaultOptions,
|
|
6
|
+
transport: {
|
|
7
|
+
target: "pino-pretty",
|
|
8
|
+
options: {
|
|
9
|
+
colorize: true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const log = pino(isProduction ? defaultOptions : devOptions);
|
|
14
|
+
log.level = isProduction ? "info" : "debug";
|
|
15
|
+
export {
|
|
16
|
+
log
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=log.js.map
|
package/dist/log.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/log.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { LevelWithSilent, LoggerOptions } from 'pino';\nimport { pino } from 'pino';\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\nconst defaultOptions: LoggerOptions = { name: 'lk-rtc' };\n\nconst devOptions: LoggerOptions = {\n ...defaultOptions,\n transport: {\n target: 'pino-pretty',\n options: {\n colorize: true,\n },\n },\n};\n\nconst log = pino(isProduction ? defaultOptions : devOptions);\nlog.level = isProduction ? 'info' : 'debug';\n\nexport type LogLevel = LevelWithSilent;\nexport { log };\n"],"mappings":"AAIA,SAAS,YAAY;AAErB,MAAM,eAAe,QAAQ,IAAI,aAAa;AAE9C,MAAM,iBAAgC,EAAE,MAAM,SAAS;AAEvD,MAAM,aAA4B;AAAA,EAChC,GAAG;AAAA,EACH,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,MAAM,MAAM,KAAK,eAAe,iBAAiB,UAAU;AAC3D,IAAI,QAAQ,eAAe,SAAS;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/napi/native.d.ts"],"sourcesContent":["/* tslint:disable */\n/* eslint-disable */\n\n/* auto-generated by NAPI-RS */\n\nexport function livekitInitialize(\n callback: (data: Uint8Array) => void,\n captureLogs: boolean,\n sdkVersion: string,\n): void;\nexport function livekitFfiRequest(data: Uint8Array): Uint8Array;\nexport function livekitRetrievePtr(handle: Uint8Array): bigint;\nexport function livekitCopyBuffer(ptr: bigint, len: number): Uint8Array;\nexport function livekitDispose(): Promise<void>;\nexport declare class FfiHandle {\n constructor(handle: bigint);\n dispose(): void;\n get handle(): bigint;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/napi/native.d.ts"],"sourcesContent":["/* tslint:disable */\n/* eslint-disable */\n\n/* auto-generated by NAPI-RS */\n\nexport declare function livekitInitialize(\n callback: (data: Uint8Array) => void,\n captureLogs: boolean,\n sdkVersion: string,\n): void;\nexport declare function livekitFfiRequest(data: Uint8Array): Uint8Array;\nexport declare function livekitRetrievePtr(handle: Uint8Array): bigint;\nexport declare function livekitCopyBuffer(ptr: bigint, len: number): Uint8Array;\nexport declare function livekitDispose(): Promise<void>;\nexport declare class FfiHandle {\n constructor(handle: bigint);\n dispose(): void;\n get handle(): bigint;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/napi/native.d.ts
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
export function livekitInitialize(
|
|
6
|
+
export declare function livekitInitialize(
|
|
7
7
|
callback: (data: Uint8Array) => void,
|
|
8
8
|
captureLogs: boolean,
|
|
9
9
|
sdkVersion: string,
|
|
10
10
|
): void;
|
|
11
|
-
export function livekitFfiRequest(data: Uint8Array): Uint8Array;
|
|
12
|
-
export function livekitRetrievePtr(handle: Uint8Array): bigint;
|
|
13
|
-
export function livekitCopyBuffer(ptr: bigint, len: number): Uint8Array;
|
|
14
|
-
export function livekitDispose(): Promise<void>;
|
|
11
|
+
export declare function livekitFfiRequest(data: Uint8Array): Uint8Array;
|
|
12
|
+
export declare function livekitRetrievePtr(handle: Uint8Array): bigint;
|
|
13
|
+
export declare function livekitCopyBuffer(ptr: bigint, len: number): Uint8Array;
|
|
14
|
+
export declare function livekitDispose(): Promise<void>;
|
|
15
15
|
export declare class FfiHandle {
|
|
16
16
|
constructor(handle: bigint);
|
|
17
17
|
dispose(): void;
|
package/dist/native.d.ts
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
export function livekitInitialize(
|
|
6
|
+
export declare function livekitInitialize(
|
|
7
7
|
callback: (data: Uint8Array) => void,
|
|
8
8
|
captureLogs: boolean,
|
|
9
9
|
sdkVersion: string,
|
|
10
10
|
): void;
|
|
11
|
-
export function livekitFfiRequest(data: Uint8Array): Uint8Array;
|
|
12
|
-
export function livekitRetrievePtr(handle: Uint8Array): bigint;
|
|
13
|
-
export function livekitCopyBuffer(ptr: bigint, len: number): Uint8Array;
|
|
14
|
-
export function livekitDispose(): Promise<void>;
|
|
11
|
+
export declare function livekitFfiRequest(data: Uint8Array): Uint8Array;
|
|
12
|
+
export declare function livekitRetrievePtr(handle: Uint8Array): bigint;
|
|
13
|
+
export declare function livekitCopyBuffer(ptr: bigint, len: number): Uint8Array;
|
|
14
|
+
export declare function livekitDispose(): Promise<void>;
|
|
15
15
|
export declare class FfiHandle {
|
|
16
16
|
constructor(handle: bigint);
|
|
17
17
|
dispose(): void;
|
package/dist/participant.cjs
CHANGED
|
@@ -23,13 +23,20 @@ __export(participant_exports, {
|
|
|
23
23
|
RemoteParticipant: () => RemoteParticipant
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(participant_exports);
|
|
26
|
+
var import_mutex = require("@livekit/mutex");
|
|
27
|
+
var import_promises = require("node:fs/promises");
|
|
28
|
+
var import_data_streams = require("./data_streams/index.cjs");
|
|
26
29
|
var import_ffi_client = require("./ffi_client.cjs");
|
|
30
|
+
var import_log = require("./log.cjs");
|
|
27
31
|
var import_participant_pb = require("./proto/participant_pb.cjs");
|
|
28
32
|
var import_room_pb = require("./proto/room_pb.cjs");
|
|
29
33
|
var import_room_pb2 = require("./proto/room_pb.cjs");
|
|
34
|
+
var import_room_pb3 = require("./proto/room_pb.cjs");
|
|
30
35
|
var import_rpc_pb = require("./proto/rpc_pb.cjs");
|
|
31
36
|
var import_rpc = require("./rpc.cjs");
|
|
32
37
|
var import_track_publication = require("./track_publication.cjs");
|
|
38
|
+
var import_utils = require("./utils.cjs");
|
|
39
|
+
const STREAM_CHUNK_SIZE = 15e3;
|
|
33
40
|
class Participant {
|
|
34
41
|
constructor(owned_info) {
|
|
35
42
|
this.trackPublications = /* @__PURE__ */ new Map();
|
|
@@ -43,16 +50,16 @@ class Participant {
|
|
|
43
50
|
return this.info.name;
|
|
44
51
|
}
|
|
45
52
|
get identity() {
|
|
46
|
-
return this.info.identity;
|
|
53
|
+
return this.info.identity ?? "";
|
|
47
54
|
}
|
|
48
55
|
get metadata() {
|
|
49
|
-
return this.info.metadata;
|
|
56
|
+
return this.info.metadata ?? "";
|
|
50
57
|
}
|
|
51
58
|
get attributes() {
|
|
52
|
-
return this.info.attributes;
|
|
59
|
+
return this.info.attributes ?? {};
|
|
53
60
|
}
|
|
54
61
|
get kind() {
|
|
55
|
-
return this.info.kind;
|
|
62
|
+
return this.info.kind ?? import_participant_pb.ParticipantKind.STANDARD;
|
|
56
63
|
}
|
|
57
64
|
get disconnectReason() {
|
|
58
65
|
if (this.info.disconnectReason === import_participant_pb.DisconnectReason.UNKNOWN_REASON) {
|
|
@@ -68,7 +75,7 @@ class LocalParticipant extends Participant {
|
|
|
68
75
|
this.trackPublications = /* @__PURE__ */ new Map();
|
|
69
76
|
}
|
|
70
77
|
async publishData(data, options) {
|
|
71
|
-
const req = new
|
|
78
|
+
const req = new import_room_pb3.PublishDataRequest({
|
|
72
79
|
localParticipantHandle: this.ffi_handle.handle,
|
|
73
80
|
dataPtr: import_ffi_client.FfiClient.instance.retrievePtr(data),
|
|
74
81
|
dataLen: BigInt(data.byteLength),
|
|
@@ -87,7 +94,7 @@ class LocalParticipant extends Participant {
|
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
async publishDtmf(code, digit) {
|
|
90
|
-
const req = new
|
|
97
|
+
const req = new import_room_pb3.PublishSipDtmfRequest({
|
|
91
98
|
localParticipantHandle: this.ffi_handle.handle,
|
|
92
99
|
code,
|
|
93
100
|
digit
|
|
@@ -103,11 +110,11 @@ class LocalParticipant extends Participant {
|
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
async publishTranscription(transcription) {
|
|
106
|
-
const req = new
|
|
113
|
+
const req = new import_room_pb3.PublishTranscriptionRequest({
|
|
107
114
|
localParticipantHandle: this.ffi_handle.handle,
|
|
108
115
|
participantIdentity: transcription.participantIdentity,
|
|
109
116
|
segments: transcription.segments.map(
|
|
110
|
-
(s) => new
|
|
117
|
+
(s) => new import_room_pb3.TranscriptionSegment({
|
|
111
118
|
id: s.id,
|
|
112
119
|
text: s.text,
|
|
113
120
|
startTime: s.startTime,
|
|
@@ -129,7 +136,7 @@ class LocalParticipant extends Participant {
|
|
|
129
136
|
}
|
|
130
137
|
}
|
|
131
138
|
async updateMetadata(metadata) {
|
|
132
|
-
const req = new
|
|
139
|
+
const req = new import_room_pb3.SetLocalMetadataRequest({
|
|
133
140
|
localParticipantHandle: this.ffi_handle.handle,
|
|
134
141
|
metadata
|
|
135
142
|
});
|
|
@@ -140,6 +147,232 @@ class LocalParticipant extends Participant {
|
|
|
140
147
|
return ev.message.case == "setLocalMetadata" && ev.message.value.asyncId == res.asyncId;
|
|
141
148
|
});
|
|
142
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns a `StreamWriter` instance that allows to write individual chunks of text to a stream.
|
|
152
|
+
* Well suited for TTS and/or streaming LLM output. If you want to simply send a text then use sendText() instead
|
|
153
|
+
*/
|
|
154
|
+
async streamText(options) {
|
|
155
|
+
const senderIdentity = this.identity;
|
|
156
|
+
const streamId = (options == null ? void 0 : options.streamId) ?? crypto.randomUUID();
|
|
157
|
+
const destinationIdentities = options == null ? void 0 : options.destinationIdentities;
|
|
158
|
+
const info = {
|
|
159
|
+
streamId,
|
|
160
|
+
mimeType: "text/plain",
|
|
161
|
+
topic: (options == null ? void 0 : options.topic) ?? "",
|
|
162
|
+
timestamp: Date.now()
|
|
163
|
+
};
|
|
164
|
+
const headerReq = new import_room_pb.SendStreamHeaderRequest({
|
|
165
|
+
senderIdentity,
|
|
166
|
+
destinationIdentities,
|
|
167
|
+
localParticipantHandle: this.ffi_handle.handle,
|
|
168
|
+
header: new import_room_pb.DataStream_Header({
|
|
169
|
+
streamId,
|
|
170
|
+
mimeType: info.mimeType,
|
|
171
|
+
topic: info.topic,
|
|
172
|
+
timestamp: (0, import_utils.numberToBigInt)(info.timestamp),
|
|
173
|
+
attributes: options == null ? void 0 : options.attributes,
|
|
174
|
+
contentHeader: {
|
|
175
|
+
case: "textHeader",
|
|
176
|
+
value: new import_room_pb.DataStream_TextHeader({
|
|
177
|
+
operationType: import_room_pb.DataStream_OperationType.CREATE,
|
|
178
|
+
version: 0,
|
|
179
|
+
replyToStreamId: "",
|
|
180
|
+
generated: false
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
await this.sendStreamHeader(headerReq);
|
|
186
|
+
let nextChunkId = 0;
|
|
187
|
+
const localHandle = this.ffi_handle.handle;
|
|
188
|
+
const sendTrailer = this.sendStreamTrailer;
|
|
189
|
+
const sendChunk = this.sendStreamChunk;
|
|
190
|
+
const writableStream = new WritableStream({
|
|
191
|
+
// Implement the sink
|
|
192
|
+
async write(text) {
|
|
193
|
+
for (const textByteChunk of (0, import_utils.splitUtf8)(text, STREAM_CHUNK_SIZE)) {
|
|
194
|
+
const chunkRequest = new import_room_pb.SendStreamChunkRequest({
|
|
195
|
+
senderIdentity,
|
|
196
|
+
localParticipantHandle: localHandle,
|
|
197
|
+
destinationIdentities,
|
|
198
|
+
chunk: new import_room_pb.DataStream_Chunk({
|
|
199
|
+
content: textByteChunk,
|
|
200
|
+
streamId,
|
|
201
|
+
chunkIndex: (0, import_utils.numberToBigInt)(nextChunkId)
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
await sendChunk(chunkRequest);
|
|
205
|
+
nextChunkId += 1;
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
async close() {
|
|
209
|
+
const trailerReq = new import_room_pb.SendStreamTrailerRequest({
|
|
210
|
+
senderIdentity,
|
|
211
|
+
localParticipantHandle: localHandle,
|
|
212
|
+
destinationIdentities,
|
|
213
|
+
trailer: new import_room_pb.DataStream_Trailer({
|
|
214
|
+
streamId,
|
|
215
|
+
reason: ""
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
await sendTrailer(trailerReq);
|
|
219
|
+
},
|
|
220
|
+
abort(err) {
|
|
221
|
+
import_log.log.error("Sink error:", err);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
const writer = new import_data_streams.TextStreamWriter(writableStream, info);
|
|
225
|
+
return writer;
|
|
226
|
+
}
|
|
227
|
+
async sendText(text, options) {
|
|
228
|
+
const writer = await this.streamText(options);
|
|
229
|
+
await writer.write(text);
|
|
230
|
+
await writer.close();
|
|
231
|
+
return writer.info;
|
|
232
|
+
}
|
|
233
|
+
async streamBytes(options) {
|
|
234
|
+
const senderIdentity = this.identity;
|
|
235
|
+
const streamId = (options == null ? void 0 : options.streamId) ?? crypto.randomUUID();
|
|
236
|
+
const destinationIdentities = options == null ? void 0 : options.destinationIdentities;
|
|
237
|
+
const info = {
|
|
238
|
+
streamId,
|
|
239
|
+
mimeType: (options == null ? void 0 : options.mimeType) ?? "application/octet-stream",
|
|
240
|
+
topic: (options == null ? void 0 : options.topic) ?? "",
|
|
241
|
+
timestamp: Date.now(),
|
|
242
|
+
attributes: options == null ? void 0 : options.attributes,
|
|
243
|
+
totalSize: options == null ? void 0 : options.totalSize,
|
|
244
|
+
name: (options == null ? void 0 : options.name) ?? "unknown"
|
|
245
|
+
};
|
|
246
|
+
const headerReq = new import_room_pb.SendStreamHeaderRequest({
|
|
247
|
+
senderIdentity,
|
|
248
|
+
destinationIdentities,
|
|
249
|
+
localParticipantHandle: this.ffi_handle.handle,
|
|
250
|
+
header: new import_room_pb.DataStream_Header({
|
|
251
|
+
streamId,
|
|
252
|
+
mimeType: info.mimeType,
|
|
253
|
+
topic: info.topic,
|
|
254
|
+
timestamp: (0, import_utils.numberToBigInt)(info.timestamp),
|
|
255
|
+
attributes: info.attributes,
|
|
256
|
+
totalLength: (0, import_utils.numberToBigInt)(info.totalSize),
|
|
257
|
+
contentHeader: {
|
|
258
|
+
case: "byteHeader",
|
|
259
|
+
value: new import_room_pb.DataStream_ByteHeader({
|
|
260
|
+
name: info.name
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
});
|
|
265
|
+
await this.sendStreamHeader(headerReq);
|
|
266
|
+
let chunkId = 0;
|
|
267
|
+
const localHandle = this.ffi_handle.handle;
|
|
268
|
+
const sendTrailer = this.sendStreamTrailer;
|
|
269
|
+
const sendChunk = this.sendStreamChunk;
|
|
270
|
+
const writeMutex = new import_mutex.Mutex();
|
|
271
|
+
const writableStream = new WritableStream({
|
|
272
|
+
async write(chunk) {
|
|
273
|
+
const unlock = await writeMutex.lock();
|
|
274
|
+
let byteOffset = 0;
|
|
275
|
+
try {
|
|
276
|
+
while (byteOffset < chunk.byteLength) {
|
|
277
|
+
const subChunk = chunk.slice(byteOffset, byteOffset + STREAM_CHUNK_SIZE);
|
|
278
|
+
const chunkRequest = new import_room_pb.SendStreamChunkRequest({
|
|
279
|
+
senderIdentity,
|
|
280
|
+
localParticipantHandle: localHandle,
|
|
281
|
+
destinationIdentities,
|
|
282
|
+
chunk: new import_room_pb.DataStream_Chunk({
|
|
283
|
+
content: subChunk,
|
|
284
|
+
streamId,
|
|
285
|
+
chunkIndex: (0, import_utils.numberToBigInt)(chunkId)
|
|
286
|
+
})
|
|
287
|
+
});
|
|
288
|
+
await sendChunk(chunkRequest);
|
|
289
|
+
chunkId += 1;
|
|
290
|
+
byteOffset += subChunk.byteLength;
|
|
291
|
+
}
|
|
292
|
+
} finally {
|
|
293
|
+
unlock();
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
async close() {
|
|
297
|
+
const trailerReq = new import_room_pb.SendStreamTrailerRequest({
|
|
298
|
+
senderIdentity,
|
|
299
|
+
localParticipantHandle: localHandle,
|
|
300
|
+
destinationIdentities,
|
|
301
|
+
trailer: new import_room_pb.DataStream_Trailer({
|
|
302
|
+
streamId,
|
|
303
|
+
reason: ""
|
|
304
|
+
})
|
|
305
|
+
});
|
|
306
|
+
await sendTrailer(trailerReq);
|
|
307
|
+
},
|
|
308
|
+
abort(err) {
|
|
309
|
+
import_log.log.error("Sink error:", err);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
const byteWriter = new import_data_streams.ByteStreamWriter(writableStream, info);
|
|
313
|
+
return byteWriter;
|
|
314
|
+
}
|
|
315
|
+
/** Sends a file provided as PathLike to specified recipients */
|
|
316
|
+
async sendFile(path, options) {
|
|
317
|
+
const fileStats = await (0, import_promises.stat)(path);
|
|
318
|
+
const file = await (0, import_promises.open)(path);
|
|
319
|
+
try {
|
|
320
|
+
const stream = file.readableWebStream({ type: "bytes" });
|
|
321
|
+
const streamId = crypto.randomUUID();
|
|
322
|
+
const destinationIdentities = options == null ? void 0 : options.destinationIdentities;
|
|
323
|
+
const writer = await this.streamBytes({
|
|
324
|
+
streamId,
|
|
325
|
+
name: options == null ? void 0 : options.name,
|
|
326
|
+
totalSize: fileStats.size,
|
|
327
|
+
destinationIdentities,
|
|
328
|
+
topic: options == null ? void 0 : options.topic,
|
|
329
|
+
mimeType: options == null ? void 0 : options.mimeType,
|
|
330
|
+
attributes: options == null ? void 0 : options.attributes
|
|
331
|
+
});
|
|
332
|
+
for await (const chunk of stream) {
|
|
333
|
+
await writer.write(chunk);
|
|
334
|
+
}
|
|
335
|
+
await writer.close();
|
|
336
|
+
} finally {
|
|
337
|
+
await file.close();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
async sendStreamHeader(req) {
|
|
341
|
+
const type = "sendStreamHeader";
|
|
342
|
+
const res = import_ffi_client.FfiClient.instance.request({
|
|
343
|
+
message: { case: type, value: req }
|
|
344
|
+
});
|
|
345
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor((ev) => {
|
|
346
|
+
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
347
|
+
});
|
|
348
|
+
if (cb.error) {
|
|
349
|
+
throw new Error(cb.error);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async sendStreamChunk(req) {
|
|
353
|
+
const type = "sendStreamChunk";
|
|
354
|
+
const res = import_ffi_client.FfiClient.instance.request({
|
|
355
|
+
message: { case: type, value: req }
|
|
356
|
+
});
|
|
357
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor((ev) => {
|
|
358
|
+
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
359
|
+
});
|
|
360
|
+
if (cb.error) {
|
|
361
|
+
throw new Error(cb.error);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
async sendStreamTrailer(req) {
|
|
365
|
+
const type = "sendStreamTrailer";
|
|
366
|
+
const res = import_ffi_client.FfiClient.instance.request({
|
|
367
|
+
message: { case: type, value: req }
|
|
368
|
+
});
|
|
369
|
+
const cb = await import_ffi_client.FfiClient.instance.waitFor((ev) => {
|
|
370
|
+
return ev.message.case == type && ev.message.value.asyncId == res.asyncId;
|
|
371
|
+
});
|
|
372
|
+
if (cb.error) {
|
|
373
|
+
throw new Error(cb.error);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
143
376
|
/**
|
|
144
377
|
* Sends a chat message to participants in the room
|
|
145
378
|
*
|
|
@@ -149,7 +382,7 @@ class LocalParticipant extends Participant {
|
|
|
149
382
|
*
|
|
150
383
|
*/
|
|
151
384
|
async sendChatMessage(text, destinationIdentities, senderIdentity) {
|
|
152
|
-
const req = new
|
|
385
|
+
const req = new import_room_pb3.SendChatMessageRequest({
|
|
153
386
|
localParticipantHandle: this.ffi_handle.handle,
|
|
154
387
|
message: text,
|
|
155
388
|
destinationIdentities,
|
|
@@ -179,10 +412,10 @@ class LocalParticipant extends Participant {
|
|
|
179
412
|
* @experimental
|
|
180
413
|
*/
|
|
181
414
|
async editChatMessage(editText, originalMessage, destinationIdentities, senderIdentity) {
|
|
182
|
-
const req = new
|
|
415
|
+
const req = new import_room_pb3.EditChatMessageRequest({
|
|
183
416
|
localParticipantHandle: this.ffi_handle.handle,
|
|
184
417
|
editText,
|
|
185
|
-
originalMessage: new
|
|
418
|
+
originalMessage: new import_room_pb2.ChatMessage({
|
|
186
419
|
...originalMessage,
|
|
187
420
|
timestamp: BigInt(originalMessage.timestamp),
|
|
188
421
|
editTimestamp: originalMessage.editTimestamp ? BigInt(originalMessage.editTimestamp) : void 0
|
|
@@ -211,7 +444,7 @@ class LocalParticipant extends Participant {
|
|
|
211
444
|
}
|
|
212
445
|
}
|
|
213
446
|
async updateName(name) {
|
|
214
|
-
const req = new
|
|
447
|
+
const req = new import_room_pb3.SetLocalNameRequest({
|
|
215
448
|
localParticipantHandle: this.ffi_handle.handle,
|
|
216
449
|
name
|
|
217
450
|
});
|
|
@@ -223,7 +456,7 @@ class LocalParticipant extends Participant {
|
|
|
223
456
|
});
|
|
224
457
|
}
|
|
225
458
|
async setAttributes(attributes) {
|
|
226
|
-
const req = new
|
|
459
|
+
const req = new import_room_pb3.SetLocalAttributesRequest({
|
|
227
460
|
localParticipantHandle: this.ffi_handle.handle,
|
|
228
461
|
attributes: Object.entries(attributes).map(([key, value]) => ({ key, value }))
|
|
229
462
|
});
|
|
@@ -235,7 +468,7 @@ class LocalParticipant extends Participant {
|
|
|
235
468
|
});
|
|
236
469
|
}
|
|
237
470
|
async publishTrack(track, options) {
|
|
238
|
-
const req = new
|
|
471
|
+
const req = new import_room_pb3.PublishTrackRequest({
|
|
239
472
|
localParticipantHandle: this.ffi_handle.handle,
|
|
240
473
|
trackHandle: track.ffi_handle.handle,
|
|
241
474
|
options
|
|
@@ -258,7 +491,7 @@ class LocalParticipant extends Participant {
|
|
|
258
491
|
}
|
|
259
492
|
}
|
|
260
493
|
async unpublishTrack(trackSid, stopOnUnpublish) {
|
|
261
|
-
const req = new
|
|
494
|
+
const req = new import_room_pb3.UnpublishTrackRequest({
|
|
262
495
|
localParticipantHandle: this.ffi_handle.handle,
|
|
263
496
|
trackSid,
|
|
264
497
|
stopOnUnpublish: stopOnUnpublish ?? true
|