@livekit/rtc-node 0.13.4 → 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.d.cts +1 -1
- package/dist/data_streams/index.d.ts +1 -1
- package/dist/data_streams/stream_reader.cjs +5 -9
- package/dist/data_streams/stream_reader.cjs.map +1 -1
- package/dist/data_streams/stream_reader.d.cts +1 -1
- package/dist/data_streams/stream_reader.d.ts +1 -1
- package/dist/data_streams/stream_reader.d.ts.map +1 -1
- package/dist/data_streams/stream_reader.js +5 -9
- package/dist/data_streams/stream_reader.js.map +1 -1
- package/dist/data_streams/stream_writer.cjs +2 -2
- package/dist/data_streams/stream_writer.cjs.map +1 -1
- package/dist/data_streams/stream_writer.d.cts +5 -5
- package/dist/data_streams/stream_writer.d.ts +5 -5
- package/dist/data_streams/stream_writer.d.ts.map +1 -1
- package/dist/data_streams/stream_writer.js +2 -2
- package/dist/data_streams/stream_writer.js.map +1 -1
- package/dist/data_streams/types.cjs.map +1 -1
- package/dist/data_streams/types.d.cts +1 -1
- package/dist/data_streams/types.d.ts +1 -1
- package/dist/data_streams/types.d.ts.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/participant.cjs +9 -20
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +1 -1
- package/dist/participant.d.ts +1 -1
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +9 -20
- package/dist/participant.js.map +1 -1
- package/dist/room.d.cts +1 -1
- package/dist/room.d.ts +1 -1
- package/dist/{types-BWsKf9LP.d.cts → types-B28ZM-Ci.d.cts} +3 -8
- package/dist/{types-Ca3IVRvo.d.ts → types-BDnbvXeD.d.ts} +3 -8
- package/dist/utils.cjs +15 -5
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -5
- package/dist/utils.js.map +1 -1
- 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/package.json +6 -6
- package/src/data_streams/stream_reader.ts +8 -15
- package/src/data_streams/stream_writer.ts +5 -5
- package/src/data_streams/types.ts +0 -6
- package/src/participant.ts +11 -25
- package/src/utils.test.ts +51 -0
- package/src/utils.ts +17 -8
- package/src/version.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as BaseStreamInfo,
|
|
1
|
+
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';
|
|
2
2
|
export { ByteStreamWriter, TextStreamWriter } from './stream_writer.cjs';
|
|
3
3
|
import '../proto/room_pb.cjs';
|
|
4
4
|
import '@bufbuild/protobuf';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as BaseStreamInfo,
|
|
1
|
+
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';
|
|
2
2
|
export { ByteStreamWriter, TextStreamWriter } from './stream_writer.js';
|
|
3
3
|
import '../proto/room_pb.js';
|
|
4
4
|
import '@bufbuild/protobuf';
|
|
@@ -111,11 +111,7 @@ class TextStreamReader extends BaseStreamReader {
|
|
|
111
111
|
this.handleChunkReceived(value);
|
|
112
112
|
return {
|
|
113
113
|
done: false,
|
|
114
|
-
value:
|
|
115
|
-
index: (0, import_utils.bigIntToNumber)(value.chunkIndex),
|
|
116
|
-
current: decoder.decode(value.content),
|
|
117
|
-
collected: Array.from(this.receivedChunks.values()).sort((a, b) => (0, import_utils.bigIntToNumber)(a.chunkIndex) - (0, import_utils.bigIntToNumber)(b.chunkIndex)).map((chunk) => decoder.decode(chunk.content)).join("")
|
|
118
|
-
}
|
|
114
|
+
value: decoder.decode(value.content)
|
|
119
115
|
};
|
|
120
116
|
}
|
|
121
117
|
} catch (error) {
|
|
@@ -130,11 +126,11 @@ class TextStreamReader extends BaseStreamReader {
|
|
|
130
126
|
};
|
|
131
127
|
}
|
|
132
128
|
async readAll() {
|
|
133
|
-
let
|
|
134
|
-
for await (const
|
|
135
|
-
|
|
129
|
+
let finalString = "";
|
|
130
|
+
for await (const chunk of this) {
|
|
131
|
+
finalString += chunk;
|
|
136
132
|
}
|
|
137
|
-
return
|
|
133
|
+
return finalString;
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
136
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ReadableStream } from 'node:stream/web';\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo,
|
|
1
|
+
{"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ReadableStream } from 'node:stream/web';\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nabstract class BaseStreamReader<T extends BaseStreamInfo> {\n protected reader: ReadableStream<DataStream_Chunk>;\n\n protected totalByteSize?: number;\n\n protected _info: T;\n\n protected bytesReceived: number;\n\n get info() {\n return this._info;\n }\n\n constructor(info: T, stream: ReadableStream<DataStream_Chunk>, totalByteSize?: number) {\n this.reader = stream;\n this.totalByteSize = totalByteSize;\n this._info = info;\n this.bytesReceived = 0;\n }\n\n protected abstract handleChunkReceived(chunk: DataStream_Chunk): void;\n\n onProgress?: (progress: number | undefined) => void;\n\n abstract readAll(): Promise<string | Array<Uint8Array>>;\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n this.bytesReceived += chunk.content!.byteLength;\n const currentProgress = this.totalByteSize\n ? this.bytesReceived / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n\n return {\n next: async (): Promise<IteratorResult<Uint8Array>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined as any };\n } else {\n this.handleChunkReceived(value);\n return { done: false, value: value.content! };\n }\n } catch (error) {\n log.error('error processing stream update', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<Uint8Array> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<Array<Uint8Array>> {\n const chunks: Set<Uint8Array> = new Set();\n for await (const chunk of this) {\n chunks.add(chunk);\n }\n return Array.from(chunks);\n }\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class TextStreamReader extends BaseStreamReader<TextStreamInfo> {\n private receivedChunks: Map<number, DataStream_Chunk>;\n\n /**\n * A TextStreamReader instance can be used as an AsyncIterator that returns the entire string\n * that has been received up to the current point in time.\n */\n constructor(\n info: TextStreamInfo,\n stream: ReadableStream<DataStream_Chunk>,\n totalChunkCount?: number,\n ) {\n super(info, stream, totalChunkCount);\n this.receivedChunks = new Map();\n }\n\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n const index = bigIntToNumber(chunk.chunkIndex!);\n const previousChunkAtIndex = this.receivedChunks.get(index!);\n if (previousChunkAtIndex && previousChunkAtIndex.version! > chunk.version!) {\n // we have a newer version already, dropping the old one\n return;\n }\n this.receivedChunks.set(index, chunk);\n const currentProgress = this.totalByteSize\n ? this.receivedChunks.size / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n /**\n * Async iterator implementation to allow usage of `for await...of` syntax.\n * Yields structured chunks from the stream.\n *\n */\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n const decoder = new TextDecoder();\n\n return {\n next: async (): Promise<IteratorResult<string>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined };\n } else {\n this.handleChunkReceived(value);\n return {\n done: false,\n value: decoder.decode(value.content!),\n };\n }\n } catch (error) {\n log.error('error processing stream update', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<string> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<string> {\n let finalString: string = '';\n for await (const chunk of this) {\n finalString += chunk;\n }\n return finalString;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAoB;AAEpB,mBAA+B;AAG/B,MAAe,iBAA2C;AAAA,EASxD,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,MAAS,QAA0C,eAAwB;AACrF,SAAK,SAAS;AACd,SAAK,gBAAgB;AACrB,SAAK,QAAQ;AACb,SAAK,gBAAgB;AAAA,EACvB;AAOF;AAKO,MAAM,yBAAyB,iBAAiC;AAAA,EAC3D,oBAAoB,OAAyB;AAxCzD;AAyCI,SAAK,iBAAiB,MAAM,QAAS;AACrC,UAAM,kBAAkB,KAAK,gBACzB,KAAK,gBAAgB,KAAK,gBAC1B;AACJ,eAAK,eAAL,8BAAkB;AAAA,EACpB;AAAA,EAEA,CAAC,OAAO,aAAa,IAAI;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;AAAA,EAOA,CAAC,OAAO,aAAa,IAAI;AACvB,UAAM,SAAS,KAAK,OAAO,UAAU;AACrC,UAAM,UAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM,YAA6C;AACjD,YAAI;AACF,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR,mBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,UACxC,OAAO;AACL,iBAAK,oBAAoB,KAAK;AAC9B,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,OAAO,QAAQ,OAAO,MAAM,OAAQ;AAAA,YACtC;AAAA,UACF;AAAA,QACF,SAAS,OAAO;AACd,yBAAI,MAAM,kCAAkC,KAAK;AACjD,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAAA,MACF;AAAA,MAEA,SAAiC;AAC/B,eAAO,YAAY;AACnB,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,UAA2B;AAC/B,QAAI,cAAsB;AAC1B,qBAAiB,SAAS,MAAM;AAC9B,qBAAe;AAAA,IACjB;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'node:stream/web';
|
|
2
2
|
import '../proto/room_pb.cjs';
|
|
3
|
-
export { B as ByteStreamReader, T as TextStreamReader } from '../types-
|
|
3
|
+
export { B as ByteStreamReader, T as TextStreamReader } from '../types-B28ZM-Ci.cjs';
|
|
4
4
|
import '@bufbuild/protobuf';
|
|
5
5
|
import '../proto/participant_pb.cjs';
|
|
6
6
|
import '../proto/handle_pb.cjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'node:stream/web';
|
|
2
2
|
import '../proto/room_pb.js';
|
|
3
|
-
export { B as ByteStreamReader, T as TextStreamReader } from '../types-
|
|
3
|
+
export { B as ByteStreamReader, T as TextStreamReader } from '../types-BDnbvXeD.js';
|
|
4
4
|
import '@bufbuild/protobuf';
|
|
5
5
|
import '../proto/participant_pb.js';
|
|
6
6
|
import '../proto/handle_pb.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream_reader.d.ts","sourceRoot":"","sources":["../../src/data_streams/stream_reader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"stream_reader.d.ts","sourceRoot":"","sources":["../../src/data_streams/stream_reader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjF,uBAAe,gBAAgB,CAAC,CAAC,SAAS,cAAc;IACtD,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAEnD,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEjC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;IAEnB,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC;IAEhC,IAAI,IAAI,MAEP;gBAEW,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,EAAE,MAAM;IAOrF,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAErE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAEpD,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;CACxD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,cAAc,CAAC;IACpE,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB;IAQrD,CAAC,MAAM,CAAC,aAAa,CAAC;oBAIF,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;kBAezC,cAAc,CAAC,UAAU,CAAC;;IAOlC,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;CAO5C;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,cAAc,CAAC;IACpE,OAAO,CAAC,cAAc,CAAgC;IAEtD;;;OAGG;gBAED,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,cAAc,CAAC,gBAAgB,CAAC,EACxC,eAAe,CAAC,EAAE,MAAM;IAM1B,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB;IAcrD;;;;OAIG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC;oBAKF,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;kBAkBrC,cAAc,CAAC,MAAM,CAAC;;IAO9B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAOjC"}
|
|
@@ -87,11 +87,7 @@ class TextStreamReader extends BaseStreamReader {
|
|
|
87
87
|
this.handleChunkReceived(value);
|
|
88
88
|
return {
|
|
89
89
|
done: false,
|
|
90
|
-
value:
|
|
91
|
-
index: bigIntToNumber(value.chunkIndex),
|
|
92
|
-
current: decoder.decode(value.content),
|
|
93
|
-
collected: Array.from(this.receivedChunks.values()).sort((a, b) => bigIntToNumber(a.chunkIndex) - bigIntToNumber(b.chunkIndex)).map((chunk) => decoder.decode(chunk.content)).join("")
|
|
94
|
-
}
|
|
90
|
+
value: decoder.decode(value.content)
|
|
95
91
|
};
|
|
96
92
|
}
|
|
97
93
|
} catch (error) {
|
|
@@ -106,11 +102,11 @@ class TextStreamReader extends BaseStreamReader {
|
|
|
106
102
|
};
|
|
107
103
|
}
|
|
108
104
|
async readAll() {
|
|
109
|
-
let
|
|
110
|
-
for await (const
|
|
111
|
-
|
|
105
|
+
let finalString = "";
|
|
106
|
+
for await (const chunk of this) {
|
|
107
|
+
finalString += chunk;
|
|
112
108
|
}
|
|
113
|
-
return
|
|
109
|
+
return finalString;
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
112
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ReadableStream } from 'node:stream/web';\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo,
|
|
1
|
+
{"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ReadableStream } from 'node:stream/web';\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nabstract class BaseStreamReader<T extends BaseStreamInfo> {\n protected reader: ReadableStream<DataStream_Chunk>;\n\n protected totalByteSize?: number;\n\n protected _info: T;\n\n protected bytesReceived: number;\n\n get info() {\n return this._info;\n }\n\n constructor(info: T, stream: ReadableStream<DataStream_Chunk>, totalByteSize?: number) {\n this.reader = stream;\n this.totalByteSize = totalByteSize;\n this._info = info;\n this.bytesReceived = 0;\n }\n\n protected abstract handleChunkReceived(chunk: DataStream_Chunk): void;\n\n onProgress?: (progress: number | undefined) => void;\n\n abstract readAll(): Promise<string | Array<Uint8Array>>;\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n this.bytesReceived += chunk.content!.byteLength;\n const currentProgress = this.totalByteSize\n ? this.bytesReceived / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n\n return {\n next: async (): Promise<IteratorResult<Uint8Array>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined as any };\n } else {\n this.handleChunkReceived(value);\n return { done: false, value: value.content! };\n }\n } catch (error) {\n log.error('error processing stream update', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<Uint8Array> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<Array<Uint8Array>> {\n const chunks: Set<Uint8Array> = new Set();\n for await (const chunk of this) {\n chunks.add(chunk);\n }\n return Array.from(chunks);\n }\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class TextStreamReader extends BaseStreamReader<TextStreamInfo> {\n private receivedChunks: Map<number, DataStream_Chunk>;\n\n /**\n * A TextStreamReader instance can be used as an AsyncIterator that returns the entire string\n * that has been received up to the current point in time.\n */\n constructor(\n info: TextStreamInfo,\n stream: ReadableStream<DataStream_Chunk>,\n totalChunkCount?: number,\n ) {\n super(info, stream, totalChunkCount);\n this.receivedChunks = new Map();\n }\n\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n const index = bigIntToNumber(chunk.chunkIndex!);\n const previousChunkAtIndex = this.receivedChunks.get(index!);\n if (previousChunkAtIndex && previousChunkAtIndex.version! > chunk.version!) {\n // we have a newer version already, dropping the old one\n return;\n }\n this.receivedChunks.set(index, chunk);\n const currentProgress = this.totalByteSize\n ? this.receivedChunks.size / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n /**\n * Async iterator implementation to allow usage of `for await...of` syntax.\n * Yields structured chunks from the stream.\n *\n */\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n const decoder = new TextDecoder();\n\n return {\n next: async (): Promise<IteratorResult<string>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined };\n } else {\n this.handleChunkReceived(value);\n return {\n done: false,\n value: decoder.decode(value.content!),\n };\n }\n } catch (error) {\n log.error('error processing stream update', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<string> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<string> {\n let finalString: string = '';\n for await (const chunk of this) {\n finalString += chunk;\n }\n return finalString;\n }\n}\n"],"mappings":"AAIA,SAAS,WAAW;AAEpB,SAAS,sBAAsB;AAG/B,MAAe,iBAA2C;AAAA,EASxD,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,MAAS,QAA0C,eAAwB;AACrF,SAAK,SAAS;AACd,SAAK,gBAAgB;AACrB,SAAK,QAAQ;AACb,SAAK,gBAAgB;AAAA,EACvB;AAOF;AAKO,MAAM,yBAAyB,iBAAiC;AAAA,EAC3D,oBAAoB,OAAyB;AAxCzD;AAyCI,SAAK,iBAAiB,MAAM,QAAS;AACrC,UAAM,kBAAkB,KAAK,gBACzB,KAAK,gBAAgB,KAAK,gBAC1B;AACJ,eAAK,eAAL,8BAAkB;AAAA,EACpB;AAAA,EAEA,CAAC,OAAO,aAAa,IAAI;AACvB,UAAM,SAAS,KAAK,OAAO,UAAU;AAErC,WAAO;AAAA,MACL,MAAM,YAAiD;AACrD,YAAI;AACF,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR,mBAAO,EAAE,MAAM,MAAM,OAAO,OAAiB;AAAA,UAC/C,OAAO;AACL,iBAAK,oBAAoB,KAAK;AAC9B,mBAAO,EAAE,MAAM,OAAO,OA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O;AACL,iBAAK,oBAAoB,KAAK;AAC9B,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,OAAO,QAAQ,OAAO,MAAM,OAAQ;AAAA,YACtC;AAAA,UACF;AAAA,QACF,SAAS,OAAO;AACd,cAAI,MAAM,kCAAkC,KAAK;AACjD,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAAA,MACF;AAAA,MAEA,SAAiC;AAC/B,eAAO,YAAY;AACnB,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,UAA2B;AAC/B,QAAI,cAAsB;AAC1B,qBAAiB,SAAS,MAAM;AAC9B,qBAAe;AAAA,IACjB;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -29,8 +29,8 @@ class BaseStreamWriter {
|
|
|
29
29
|
this.onClose = onClose;
|
|
30
30
|
this.info = info;
|
|
31
31
|
}
|
|
32
|
-
write(chunk
|
|
33
|
-
return this.defaultWriter.write(
|
|
32
|
+
write(chunk) {
|
|
33
|
+
return this.defaultWriter.write(chunk);
|
|
34
34
|
}
|
|
35
35
|
async close() {
|
|
36
36
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data_streams/stream_writer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { WritableStream } from 'node:stream/web';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nclass BaseStreamWriter<T, InfoType extends BaseStreamInfo> {\n protected writableStream: WritableStream<
|
|
1
|
+
{"version":3,"sources":["../../src/data_streams/stream_writer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { WritableStream } from 'node:stream/web';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nclass BaseStreamWriter<T, InfoType extends BaseStreamInfo> {\n protected writableStream: WritableStream<T>;\n\n protected defaultWriter: WritableStreamDefaultWriter<T>;\n\n protected onClose?: () => void;\n\n readonly info: InfoType;\n\n constructor(writableStream: WritableStream<T>, info: InfoType, onClose?: () => void) {\n this.writableStream = writableStream;\n this.defaultWriter = writableStream.getWriter();\n this.onClose = onClose;\n this.info = info;\n }\n\n write(chunk: T): Promise<void> {\n return this.defaultWriter.write(chunk);\n }\n\n async close() {\n await this.defaultWriter.close();\n this.defaultWriter.releaseLock();\n this.onClose?.();\n }\n}\n\nexport class TextStreamWriter extends BaseStreamWriter<string, TextStreamInfo> {}\n\nexport class ByteStreamWriter extends BaseStreamWriter<Uint8Array, ByteStreamInfo> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,MAAM,iBAAqD;AAAA,EASzD,YAAY,gBAAmC,MAAgB,SAAsB;AACnF,SAAK,iBAAiB;AACtB,SAAK,gBAAgB,eAAe,UAAU;AAC9C,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,MAAM,OAAyB;AAC7B,WAAO,KAAK,cAAc,MAAM,KAAK;AAAA,EACvC;AAAA,EAEA,MAAM,QAAQ;AA1BhB;AA2BI,UAAM,KAAK,cAAc,MAAM;AAC/B,SAAK,cAAc,YAAY;AAC/B,eAAK,YAAL;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,iBAAyC;AAAC;AAEzE,MAAM,yBAAyB,iBAA6C;AAAC;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BaseStreamInfo, c as TextStreamInfo, b as ByteStreamInfo } from '../types-
|
|
1
|
+
import { a as BaseStreamInfo, c as TextStreamInfo, b as ByteStreamInfo } from '../types-B28ZM-Ci.cjs';
|
|
2
2
|
import { WritableStream } from 'node:stream/web';
|
|
3
3
|
import '../proto/room_pb.cjs';
|
|
4
4
|
import '@bufbuild/protobuf';
|
|
@@ -10,12 +10,12 @@ import '../proto/e2ee_pb.cjs';
|
|
|
10
10
|
import '../proto/video_frame_pb.cjs';
|
|
11
11
|
|
|
12
12
|
declare class BaseStreamWriter<T, InfoType extends BaseStreamInfo> {
|
|
13
|
-
protected writableStream: WritableStream<
|
|
14
|
-
protected defaultWriter: WritableStreamDefaultWriter<
|
|
13
|
+
protected writableStream: WritableStream<T>;
|
|
14
|
+
protected defaultWriter: WritableStreamDefaultWriter<T>;
|
|
15
15
|
protected onClose?: () => void;
|
|
16
16
|
readonly info: InfoType;
|
|
17
|
-
constructor(writableStream: WritableStream<
|
|
18
|
-
write(chunk: T
|
|
17
|
+
constructor(writableStream: WritableStream<T>, info: InfoType, onClose?: () => void);
|
|
18
|
+
write(chunk: T): Promise<void>;
|
|
19
19
|
close(): Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
declare class TextStreamWriter extends BaseStreamWriter<string, TextStreamInfo> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BaseStreamInfo, c as TextStreamInfo, b as ByteStreamInfo } from '../types-
|
|
1
|
+
import { a as BaseStreamInfo, c as TextStreamInfo, b as ByteStreamInfo } from '../types-BDnbvXeD.js';
|
|
2
2
|
import { WritableStream } from 'node:stream/web';
|
|
3
3
|
import '../proto/room_pb.js';
|
|
4
4
|
import '@bufbuild/protobuf';
|
|
@@ -10,12 +10,12 @@ import '../proto/e2ee_pb.js';
|
|
|
10
10
|
import '../proto/video_frame_pb.js';
|
|
11
11
|
|
|
12
12
|
declare class BaseStreamWriter<T, InfoType extends BaseStreamInfo> {
|
|
13
|
-
protected writableStream: WritableStream<
|
|
14
|
-
protected defaultWriter: WritableStreamDefaultWriter<
|
|
13
|
+
protected writableStream: WritableStream<T>;
|
|
14
|
+
protected defaultWriter: WritableStreamDefaultWriter<T>;
|
|
15
15
|
protected onClose?: () => void;
|
|
16
16
|
readonly info: InfoType;
|
|
17
|
-
constructor(writableStream: WritableStream<
|
|
18
|
-
write(chunk: T
|
|
17
|
+
constructor(writableStream: WritableStream<T>, info: InfoType, onClose?: () => void);
|
|
18
|
+
write(chunk: T): Promise<void>;
|
|
19
19
|
close(): Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
declare class TextStreamWriter extends BaseStreamWriter<string, TextStreamInfo> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream_writer.d.ts","sourceRoot":"","sources":["../../src/data_streams/stream_writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjF,cAAM,gBAAgB,CAAC,CAAC,EAAE,QAAQ,SAAS,cAAc;IACvD,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"stream_writer.d.ts","sourceRoot":"","sources":["../../src/data_streams/stream_writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjF,cAAM,gBAAgB,CAAC,CAAC,EAAE,QAAQ,SAAS,cAAc;IACvD,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAE5C,SAAS,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC,CAAC,CAAC;IAExD,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAE/B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;gBAEZ,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI;IAOnF,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxB,KAAK;CAKZ;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC;CAAG;AAEjF,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,UAAU,EAAE,cAAc,CAAC;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data_streams/stream_writer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { WritableStream } from 'node:stream/web';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nclass BaseStreamWriter<T, InfoType extends BaseStreamInfo> {\n protected writableStream: WritableStream<
|
|
1
|
+
{"version":3,"sources":["../../src/data_streams/stream_writer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { WritableStream } from 'node:stream/web';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nclass BaseStreamWriter<T, InfoType extends BaseStreamInfo> {\n protected writableStream: WritableStream<T>;\n\n protected defaultWriter: WritableStreamDefaultWriter<T>;\n\n protected onClose?: () => void;\n\n readonly info: InfoType;\n\n constructor(writableStream: WritableStream<T>, info: InfoType, onClose?: () => void) {\n this.writableStream = writableStream;\n this.defaultWriter = writableStream.getWriter();\n this.onClose = onClose;\n this.info = info;\n }\n\n write(chunk: T): Promise<void> {\n return this.defaultWriter.write(chunk);\n }\n\n async close() {\n await this.defaultWriter.close();\n this.defaultWriter.releaseLock();\n this.onClose?.();\n }\n}\n\nexport class TextStreamWriter extends BaseStreamWriter<string, TextStreamInfo> {}\n\nexport class ByteStreamWriter extends BaseStreamWriter<Uint8Array, ByteStreamInfo> {}\n"],"mappings":"AAMA,MAAM,iBAAqD;AAAA,EASzD,YAAY,gBAAmC,MAAgB,SAAsB;AACnF,SAAK,iBAAiB;AACtB,SAAK,gBAAgB,eAAe,UAAU;AAC9C,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,MAAM,OAAyB;AAC7B,WAAO,KAAK,cAAc,MAAM,KAAK;AAAA,EACvC;AAAA,EAEA,MAAM,QAAQ;AA1BhB;AA2BI,UAAM,KAAK,cAAc,MAAM;AAC/B,SAAK,cAAc,YAAY;AAC/B,eAAK,YAAL;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,iBAAyC;AAAC;AAEzE,MAAM,yBAAyB,iBAA6C;AAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data_streams/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataStream_Chunk, DataStream_Header } from '../proto/room_pb.js';\nimport type { ByteStreamReader, TextStreamReader } from './stream_reader.js';\n\nexport interface StreamController<T extends DataStream_Chunk> {\n header: DataStream_Header;\n controller: ReadableStreamDefaultController<T>;\n startTime: number;\n endTime?: number;\n}\n\nexport interface BaseStreamInfo {\n streamId: string;\n mimeType: string;\n topic: string;\n timestamp: number;\n /** total size in bytes for finite streams and undefined for streams of unknown size */\n totalSize?: number;\n attributes?: Record<string, string>;\n}\n\nexport type ByteStreamInfo = BaseStreamInfo & {\n name: string;\n};\n\nexport type TextStreamInfo = BaseStreamInfo;\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/data_streams/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataStream_Chunk, DataStream_Header } from '../proto/room_pb.js';\nimport type { ByteStreamReader, TextStreamReader } from './stream_reader.js';\n\nexport interface StreamController<T extends DataStream_Chunk> {\n header: DataStream_Header;\n controller: ReadableStreamDefaultController<T>;\n startTime: number;\n endTime?: number;\n}\n\nexport interface BaseStreamInfo {\n streamId: string;\n mimeType: string;\n topic: string;\n timestamp: number;\n /** total size in bytes for finite streams and undefined for streams of unknown size */\n totalSize?: number;\n attributes?: Record<string, string>;\n}\n\nexport type ByteStreamInfo = BaseStreamInfo & {\n name: string;\n};\n\nexport type TextStreamInfo = BaseStreamInfo;\n\nexport interface DataStreamOptions {\n topic?: string;\n destinationIdentities?: Array<string>;\n attributes?: Record<string, string>;\n mimeType?: string;\n}\n\nexport interface TextStreamOptions extends DataStreamOptions {\n // replyToMessageId?: string;\n attachments?: [];\n}\n\nexport interface ByteStreamOptions extends DataStreamOptions {\n name?: string;\n onProgress?: (progress: number) => void;\n}\n\nexport type ByteStreamHandler = (\n reader: ByteStreamReader,\n participantInfo: { identity: string },\n) => void;\n\nexport type TextStreamHandler = (\n reader: TextStreamReader,\n participantInfo: { identity: string },\n) => void;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../proto/room_pb.cjs';
|
|
2
|
-
export { a as BaseStreamInfo,
|
|
2
|
+
export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions } from '../types-B28ZM-Ci.cjs';
|
|
3
3
|
import '@bufbuild/protobuf';
|
|
4
4
|
import '../proto/participant_pb.cjs';
|
|
5
5
|
import '../proto/handle_pb.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../proto/room_pb.js';
|
|
2
|
-
export { a as BaseStreamInfo,
|
|
2
|
+
export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions } from '../types-BDnbvXeD.js';
|
|
3
3
|
import '@bufbuild/protobuf';
|
|
4
4
|
import '../proto/participant_pb.js';
|
|
5
5
|
import '../proto/handle_pb.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/data_streams/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,gBAAgB;IAC1D,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/data_streams/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,gBAAgB;IAC1D,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC,CAAC;IAC/C,SAAS,EAAE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Source } 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,
|
|
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
15
|
export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.cjs';
|
|
16
16
|
export { ConnectionQuality, ConnectionState, ContinualGatheringPolicy, DataPacketKind, IceServer, IceTransportType, TrackPublishOptions } from './proto/room_pb.cjs';
|
|
17
17
|
export { PerformRpcParams, RpcError, RpcInvocationData } from './rpc.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ 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,
|
|
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
15
|
export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.js';
|
|
16
16
|
export { ConnectionQuality, ConnectionState, ContinualGatheringPolicy, DataPacketKind, IceServer, IceTransportType, TrackPublishOptions } from './proto/room_pb.js';
|
|
17
17
|
export { PerformRpcParams, RpcError, RpcInvocationData } from './rpc.js';
|
package/dist/participant.cjs
CHANGED
|
@@ -183,36 +183,27 @@ class LocalParticipant extends Participant {
|
|
|
183
183
|
})
|
|
184
184
|
});
|
|
185
185
|
await this.sendStreamHeader(headerReq);
|
|
186
|
-
let
|
|
186
|
+
let nextChunkId = 0;
|
|
187
187
|
const localHandle = this.ffi_handle.handle;
|
|
188
188
|
const sendTrailer = this.sendStreamTrailer;
|
|
189
189
|
const sendChunk = this.sendStreamChunk;
|
|
190
190
|
const writableStream = new WritableStream({
|
|
191
191
|
// Implement the sink
|
|
192
|
-
write(
|
|
193
|
-
|
|
194
|
-
const textInBytes = new TextEncoder().encode(textChunk);
|
|
195
|
-
if (textInBytes.byteLength > STREAM_CHUNK_SIZE) {
|
|
196
|
-
(_a = this.abort) == null ? void 0 : _a.call(this);
|
|
197
|
-
throw new Error("chunk size too large");
|
|
198
|
-
}
|
|
199
|
-
return new Promise(async (resolve) => {
|
|
192
|
+
async write(text) {
|
|
193
|
+
for (const textByteChunk of (0, import_utils.splitUtf8)(text, STREAM_CHUNK_SIZE)) {
|
|
200
194
|
const chunkRequest = new import_room_pb.SendStreamChunkRequest({
|
|
201
195
|
senderIdentity,
|
|
202
196
|
localParticipantHandle: localHandle,
|
|
203
197
|
destinationIdentities,
|
|
204
198
|
chunk: new import_room_pb.DataStream_Chunk({
|
|
205
|
-
content:
|
|
199
|
+
content: textByteChunk,
|
|
206
200
|
streamId,
|
|
207
|
-
chunkIndex: (0, import_utils.numberToBigInt)(
|
|
201
|
+
chunkIndex: (0, import_utils.numberToBigInt)(nextChunkId)
|
|
208
202
|
})
|
|
209
203
|
});
|
|
210
204
|
await sendChunk(chunkRequest);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
resolve();
|
|
214
|
-
}
|
|
215
|
-
});
|
|
205
|
+
nextChunkId += 1;
|
|
206
|
+
}
|
|
216
207
|
},
|
|
217
208
|
async close() {
|
|
218
209
|
const trailerReq = new import_room_pb.SendStreamTrailerRequest({
|
|
@@ -235,9 +226,7 @@ class LocalParticipant extends Participant {
|
|
|
235
226
|
}
|
|
236
227
|
async sendText(text, options) {
|
|
237
228
|
const writer = await this.streamText(options);
|
|
238
|
-
|
|
239
|
-
await writer.write(chunk);
|
|
240
|
-
}
|
|
229
|
+
await writer.write(text);
|
|
241
230
|
await writer.close();
|
|
242
231
|
return writer.info;
|
|
243
232
|
}
|
|
@@ -280,7 +269,7 @@ class LocalParticipant extends Participant {
|
|
|
280
269
|
const sendChunk = this.sendStreamChunk;
|
|
281
270
|
const writeMutex = new import_mutex.Mutex();
|
|
282
271
|
const writableStream = new WritableStream({
|
|
283
|
-
async write(
|
|
272
|
+
async write(chunk) {
|
|
284
273
|
const unlock = await writeMutex.lock();
|
|
285
274
|
let byteOffset = 0;
|
|
286
275
|
try {
|