@fluxerjs/voice 1.2.0 → 1.2.2
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/index.js +26 -2582
- package/dist/index.mjs +20 -27
- package/package.json +5 -5
- package/dist/chunk-EBO3CZXG.mjs +0 -15
- package/dist/dist-N4IEBIZ4.mjs +0 -2552
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./chunk-EBO3CZXG.mjs";
|
|
2
|
-
|
|
3
1
|
// src/VoiceManager.ts
|
|
4
2
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
5
3
|
import { Events } from "@fluxerjs/core";
|
|
@@ -13,6 +11,9 @@ var thumbnail = MINIMAL_PNG_BASE64;
|
|
|
13
11
|
import { EventEmitter } from "events";
|
|
14
12
|
import * as nacl from "tweetnacl";
|
|
15
13
|
import * as dgram from "dgram";
|
|
14
|
+
import * as ws from "ws";
|
|
15
|
+
import { Readable } from "stream";
|
|
16
|
+
import { opus } from "prism-media";
|
|
16
17
|
var VOICE_WS_OPCODES = {
|
|
17
18
|
Identify: 0,
|
|
18
19
|
SelectProtocol: 1,
|
|
@@ -156,11 +157,11 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
156
157
|
this.voiceWs.removeAllListeners();
|
|
157
158
|
}
|
|
158
159
|
};
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
const ws2 = this.voiceWs;
|
|
161
|
+
ws2.on("open", onOpen);
|
|
162
|
+
ws2.on("error", onError);
|
|
163
|
+
ws2.on("message", (data) => onMessage(data));
|
|
164
|
+
ws2.once("close", () => {
|
|
164
165
|
cleanup();
|
|
165
166
|
if (!this._destroyed) reject(new Error("Voice WebSocket closed"));
|
|
166
167
|
});
|
|
@@ -168,7 +169,6 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
168
169
|
}
|
|
169
170
|
async getWebSocketConstructor() {
|
|
170
171
|
try {
|
|
171
|
-
const ws = await import("ws");
|
|
172
172
|
return ws.default;
|
|
173
173
|
} catch {
|
|
174
174
|
throw new Error('Install "ws" for voice support: pnpm add ws');
|
|
@@ -254,8 +254,6 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
254
254
|
*/
|
|
255
255
|
async play(urlOrStream) {
|
|
256
256
|
this.stop();
|
|
257
|
-
const { opus: prismOpus } = await import("prism-media");
|
|
258
|
-
const { Readable } = await import("stream");
|
|
259
257
|
let inputStream;
|
|
260
258
|
if (typeof urlOrStream === "string") {
|
|
261
259
|
try {
|
|
@@ -271,7 +269,7 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
271
269
|
} else {
|
|
272
270
|
inputStream = urlOrStream;
|
|
273
271
|
}
|
|
274
|
-
const demuxer = new
|
|
272
|
+
const demuxer = new opus.WebmDemuxer();
|
|
275
273
|
inputStream.pipe(demuxer);
|
|
276
274
|
this._playing = true;
|
|
277
275
|
this.currentStream = demuxer;
|
|
@@ -364,7 +362,7 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
364
362
|
};
|
|
365
363
|
|
|
366
364
|
// src/LiveKitRtcConnection.ts
|
|
367
|
-
import { spawn } from "child_process";
|
|
365
|
+
import { execFile, spawn } from "child_process";
|
|
368
366
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
369
367
|
import {
|
|
370
368
|
Room,
|
|
@@ -466,6 +464,11 @@ function concatUint8Arrays(a, b) {
|
|
|
466
464
|
}
|
|
467
465
|
|
|
468
466
|
// src/LiveKitRtcConnection.ts
|
|
467
|
+
import { Readable as Readable2 } from "stream";
|
|
468
|
+
import { OpusDecoder } from "opus-decoder";
|
|
469
|
+
import { opus as opus2 } from "prism-media";
|
|
470
|
+
import { promisify } from "util";
|
|
471
|
+
import { createFile } from "mp4box";
|
|
469
472
|
var SAMPLE_RATE = 48e3;
|
|
470
473
|
var CHANNELS2 = 1;
|
|
471
474
|
function getNaluByteLength(nalu) {
|
|
@@ -710,11 +713,10 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
710
713
|
this.emit("error", new Error("useFFmpeg requires a URL; buffer/ArrayBuffer not supported"));
|
|
711
714
|
return;
|
|
712
715
|
}
|
|
713
|
-
const { createFile } = await import("mp4box");
|
|
714
716
|
let VideoDecoder;
|
|
715
717
|
let EncodedVideoChunk;
|
|
716
718
|
try {
|
|
717
|
-
const webcodecs = await import("
|
|
719
|
+
const webcodecs = await import("node-webcodecs");
|
|
718
720
|
VideoDecoder = webcodecs.VideoDecoder;
|
|
719
721
|
EncodedVideoChunk = webcodecs.EncodedVideoChunk;
|
|
720
722
|
} catch {
|
|
@@ -1056,8 +1058,6 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
1056
1058
|
file.start();
|
|
1057
1059
|
});
|
|
1058
1060
|
if (videoUrl && audioSource && audioTrack) {
|
|
1059
|
-
const { opus: prismOpus } = await import("prism-media");
|
|
1060
|
-
const { OpusDecoder } = await import("opus-decoder");
|
|
1061
1061
|
const runAudioFfmpeg = async () => {
|
|
1062
1062
|
if (!this._playingVideo || cleanupCalled || !audioSource) return;
|
|
1063
1063
|
const audioProc = spawn(
|
|
@@ -1079,7 +1079,7 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
1079
1079
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
1080
1080
|
);
|
|
1081
1081
|
audioFfmpegProc = audioProc;
|
|
1082
|
-
const demuxer = new
|
|
1082
|
+
const demuxer = new opus2.WebmDemuxer();
|
|
1083
1083
|
if (audioProc.stdout) audioProc.stdout.pipe(demuxer);
|
|
1084
1084
|
const decoder2 = new OpusDecoder({ sampleRate: SAMPLE_RATE, channels: CHANNELS2 });
|
|
1085
1085
|
await decoder2.ready;
|
|
@@ -1169,8 +1169,6 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
1169
1169
|
let height = 480;
|
|
1170
1170
|
let hasAudio = false;
|
|
1171
1171
|
try {
|
|
1172
|
-
const { execFile } = await import("child_process");
|
|
1173
|
-
const { promisify } = await import("util");
|
|
1174
1172
|
const exec = promisify(execFile);
|
|
1175
1173
|
const { stdout } = await exec(
|
|
1176
1174
|
"ffprobe",
|
|
@@ -1433,9 +1431,7 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
1433
1431
|
}
|
|
1434
1432
|
if (hasAudio && audioReady && audioSource && proc.stdio[3]) {
|
|
1435
1433
|
const audioPipe = proc.stdio[3];
|
|
1436
|
-
const
|
|
1437
|
-
const { OpusDecoder } = await import("opus-decoder");
|
|
1438
|
-
const demuxer = new prismOpus.WebmDemuxer();
|
|
1434
|
+
const demuxer = new opus2.WebmDemuxer();
|
|
1439
1435
|
audioPipe.pipe(demuxer);
|
|
1440
1436
|
const decoder = new OpusDecoder({ sampleRate: SAMPLE_RATE, channels: CHANNELS2 });
|
|
1441
1437
|
await decoder.ready;
|
|
@@ -1517,16 +1513,13 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
1517
1513
|
this.emit("error", new Error("LiveKit: not connected"));
|
|
1518
1514
|
return;
|
|
1519
1515
|
}
|
|
1520
|
-
const { opus: prismOpus } = await import("prism-media");
|
|
1521
|
-
const { Readable } = await import("stream");
|
|
1522
|
-
const { OpusDecoder } = await import("opus-decoder");
|
|
1523
1516
|
let inputStream;
|
|
1524
1517
|
if (typeof urlOrStream === "string") {
|
|
1525
1518
|
try {
|
|
1526
1519
|
const response = await fetch(urlOrStream);
|
|
1527
1520
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
1528
1521
|
if (!response.body) throw new Error("No response body");
|
|
1529
|
-
inputStream =
|
|
1522
|
+
inputStream = Readable2.fromWeb(response.body);
|
|
1530
1523
|
} catch (e) {
|
|
1531
1524
|
this.emit("error", e instanceof Error ? e : new Error(String(e)));
|
|
1532
1525
|
return;
|
|
@@ -1541,7 +1534,7 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
1541
1534
|
const options = new TrackPublishOptions();
|
|
1542
1535
|
options.source = TrackSource.SOURCE_MICROPHONE;
|
|
1543
1536
|
await this.room.localParticipant.publishTrack(track, options);
|
|
1544
|
-
const demuxer = new
|
|
1537
|
+
const demuxer = new opus2.WebmDemuxer();
|
|
1545
1538
|
inputStream.pipe(demuxer);
|
|
1546
1539
|
this.currentStream = demuxer;
|
|
1547
1540
|
const decoder = new OpusDecoder({ sampleRate: SAMPLE_RATE, channels: CHANNELS2 });
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.2",
|
|
7
7
|
"description": "Voice support for Fluxer bots",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"prism-media": "^1.3.5",
|
|
40
40
|
"tweetnacl": "^1.0.3",
|
|
41
41
|
"ws": "^8.18.0",
|
|
42
|
-
"@fluxerjs/
|
|
43
|
-
"@fluxerjs/types": "1.2.
|
|
44
|
-
"@fluxerjs/
|
|
42
|
+
"@fluxerjs/collection": "1.2.1",
|
|
43
|
+
"@fluxerjs/types": "1.2.1",
|
|
44
|
+
"@fluxerjs/core": "1.2.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^20.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"node-webcodecs": "^1.0.0"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
|
-
"build": "tsup
|
|
60
|
+
"build": "tsup",
|
|
61
61
|
"clean": "rm -rf dist",
|
|
62
62
|
"lint": "eslint src --max-warnings 0 --config ../../eslint.config.js",
|
|
63
63
|
"lint:fix": "eslint src --fix --config ../../eslint.config.js",
|
package/dist/chunk-EBO3CZXG.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
__require,
|
|
14
|
-
__commonJS
|
|
15
|
-
};
|