kage-baileys 25.3.11 → 25.3.13
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/Example/plugins/scarr.mjs +1 -1
- package/Example/plugins/unico6.mjs +1 -1
- package/extras/Extensions/package.json +3 -0
- package/extras/Extensions/rich-carousel.js +1 -1
- package/extras/Extensions/rich-classic.js +1 -1
- package/extras/index.js +10 -10
- package/helpers/package.json +3 -0
- package/lib/Defaults/connection.js +49 -108
- package/lib/Defaults/constants.js +71 -153
- package/lib/Defaults/index.js +0 -199
- package/lib/Defaults/media.js +0 -60
- package/lib/Defaults/prefix.js +17 -43
- package/lib/Modded/message_builder.js +0 -2355
- package/lib/Signal/Group/ciphertext-message.js +0 -54
- package/lib/Signal/Group/group-session-builder.js +0 -124
- package/lib/Signal/Group/group_cipher.js +0 -230
- package/lib/Signal/Group/index.js +0 -124
- package/lib/Signal/Group/keyhelper.js +0 -108
- package/lib/Signal/Group/sender-chain-key.js +0 -88
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -157
- package/lib/Signal/Group/sender-key-message.js +0 -166
- package/lib/Signal/Group/sender-key-name.js +0 -130
- package/lib/Signal/Group/sender-key-record.js +0 -122
- package/lib/Signal/Group/sender-key-state.js +0 -220
- package/lib/Signal/Group/sender-message-key.js +0 -82
- package/lib/Signal/libsignal.js +0 -646
- package/lib/Signal/lid-mapping.js +0 -537
- package/lib/Socket/Client/index.js +0 -60
- package/lib/Socket/Client/types.js +0 -51
- package/lib/Socket/Client/websocket.js +0 -164
- package/lib/Socket/business.js +0 -708
- package/lib/Socket/chats.js +0 -2253
- package/lib/Socket/communities.js +0 -441
- package/lib/Socket/community.js +504 -1019
- package/lib/Socket/groups.js +0 -727
- package/lib/Socket/messages-recv.js +0 -2780
- package/lib/Socket/messages-send.js +0 -2640
- package/lib/Socket/mex.js +0 -128
- package/lib/Socket/newsletter.js +0 -486
- package/lib/Socket/socket.js +0 -1899
- package/lib/Store/index.js +0 -68
- package/lib/Store/make-cache-manager-store.js +0 -97
- package/lib/Store/make-in-memory-store.js +0 -908
- package/lib/Store/make-ordered-dictionary.js +0 -187
- package/lib/Store/object-repository.js +0 -78
- package/lib/Types/Bussines.js +2 -2
- package/lib/Types/Chat.js +0 -33
- package/lib/Types/Label.js +0 -78
- package/lib/Types/LabelAssociation.js +0 -42
- package/lib/Types/Message.js +0 -46
- package/lib/Types/Mex.js +0 -53
- package/lib/Types/MexUpdates.js +16 -43
- package/lib/Types/Newsletter.js +0 -27
- package/lib/Types/State.js +0 -42
- package/lib/Types/index.js +0 -134
- package/lib/Utils/auth-utils.js +0 -579
- package/lib/Utils/baileys-event-stream.js +65 -142
- package/lib/Utils/browser-utils.js +0 -104
- package/lib/Utils/business.js +0 -519
- package/lib/Utils/chat-utils.js +0 -1702
- package/lib/Utils/companion-reg-client-utils.js +0 -45
- package/lib/Utils/crypto.js +0 -382
- package/lib/Utils/decode-wa-message.js +0 -605
- package/lib/Utils/event-buffer.js +0 -1207
- package/lib/Utils/generics.js +0 -1020
- package/lib/Utils/history.js +0 -231
- package/lib/Utils/identity-change-handler.js +0 -59
- package/lib/Utils/index.js +0 -133
- package/lib/Utils/link-preview.js +0 -228
- package/lib/Utils/logger.js +0 -35
- package/lib/Utils/lt-hash.js +0 -60
- package/lib/Utils/make-mutex.js +0 -110
- package/lib/Utils/message-retry-manager.js +0 -429
- package/lib/Utils/messages-media.js +0 -1899
- package/lib/Utils/messages.js +0 -2950
- package/lib/Utils/noise-handler.js +0 -369
- package/lib/Utils/offline-node-processor.js +0 -50
- package/lib/Utils/pre-key-manager.js +0 -251
- package/lib/Utils/process-message.js +0 -1239
- package/lib/Utils/reporting-utils.js +0 -268
- package/lib/Utils/signal.js +0 -377
- package/lib/Utils/stanza-ack.js +0 -48
- package/lib/Utils/sync-action-utils.js +0 -58
- package/lib/Utils/tc-token-utils.js +0 -28
- package/lib/Utils/validate-connection.js +0 -508
- package/lib/VoIP/audio-feeder.js +0 -146
- package/lib/VoIP/index.js +0 -292
- package/lib/VoIP/relay-transport.js +0 -569
- package/lib/VoIP/signaling.js +0 -613
- package/lib/VoIP/types.js +0 -27
- package/lib/VoIP/wasm-engine.js +0 -1222
- package/lib/VoIP/worker-bootstrap.js +0 -1785
- package/lib/WABinary/constants.js +0 -2639
- package/lib/WABinary/decode.js +0 -612
- package/lib/WABinary/encode.js +0 -556
- package/lib/WABinary/generic-utils.js +0 -272
- package/lib/WABinary/index.js +0 -82
- package/lib/WABinary/jid-utils.js +0 -262
- package/lib/WAM/BinaryInfo.js +0 -50
- package/lib/WAM/constants.js +0 -38242
- package/lib/WAM/encode.js +0 -396
- package/lib/WAM/index.js +0 -78
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +47 -109
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -88
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -142
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -85
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -63
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -114
- package/lib/WAUSync/Protocols/index.js +0 -82
- package/lib/WAUSync/index.js +0 -78
- package/lib/assets/wasm/loader.js +0 -13
- package/lib/assets/wasm/worker-modules.js +0 -283
- package/lib/index.d.ts +483 -41
- package/lib/index.js +0 -93
- package/package.json +9 -6
- package/WAProto/index.d.ts +0 -46
- package/lib/Builders/index.d.ts +0 -454
- package/lib/Builders/mbuilder/bot-signature.d.ts +0 -22
- package/lib/Builders/mbuilder/extras.d.ts +0 -348
- package/lib/Builders/mbuilder/html-app.d.ts +0 -19
- package/lib/Builders/mbuilder/index.d.ts +0 -221
- package/lib/Builders/mbuilder/metaai.d.ts +0 -438
- package/lib/Defaults/index.d.ts +0 -145
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts +0 -8
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts +0 -11
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts +0 -12
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts +0 -7
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts +0 -12
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts +0 -13
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts +0 -17
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts +0 -12
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts +0 -55
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts +0 -21
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts +0 -6
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts +0 -13
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts +0 -395
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts +0 -137
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts +0 -562
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts +0 -286
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts +0 -530
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts +0 -334
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts +0 -330
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts +0 -2
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts +0 -283
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts +0 -61
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/index.d.ts.map +0 -1
- package/lib/Store/index.js.map +0 -1
- package/lib/Store/make-in-memory-store.d.ts +0 -63
- package/lib/Store/make-in-memory-store.d.ts.map +0 -1
- package/lib/Store/make-in-memory-store.js.map +0 -1
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/make-ordered-dictionary.d.ts.map +0 -1
- package/lib/Store/make-ordered-dictionary.js.map +0 -1
- package/lib/Store/object-repository.d.ts +0 -11
- package/lib/Store/object-repository.d.ts.map +0 -1
- package/lib/Store/object-repository.js.map +0 -1
- package/lib/Types/Auth.d.ts +0 -2
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts +0 -2
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Call.d.ts +0 -2
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Chat.d.ts +0 -2
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Contact.d.ts +0 -2
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Events.d.ts +0 -2
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.d.ts +0 -2
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/Label.d.ts +0 -3
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.d.ts +0 -3
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/Message.d.ts +0 -12
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Mex.d.ts +0 -3
- package/lib/Types/Mex.d.ts.map +0 -1
- package/lib/Types/Product.d.ts +0 -2
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/RichType.d.ts +0 -3
- package/lib/Types/RichType.d.ts.map +0 -1
- package/lib/Types/Signal.d.ts +0 -2
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Socket.d.ts +0 -2
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/State.d.ts +0 -6
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/USync.d.ts +0 -2
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/index.d.ts +0 -14
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Utils/auth-utils.d.ts +0 -58
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/browser-utils.d.ts +0 -9
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts +0 -50
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts +0 -409
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +0 -5
- package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
- package/lib/Utils/companion-reg-client-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts +0 -40
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts +0 -84
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts +0 -13
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts +0 -71
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts +0 -76
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/identity-change-handler.d.ts +0 -14
- package/lib/Utils/identity-change-handler.d.ts.map +0 -1
- package/lib/Utils/identity-change-handler.js.map +0 -1
- package/lib/Utils/index.d.ts +0 -25
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/link-preview.d.ts +0 -13
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts +0 -3
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts +0 -7
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts +0 -80
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts +0 -137
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts +0 -47
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/offline-node-processor.d.ts +0 -10
- package/lib/Utils/offline-node-processor.d.ts.map +0 -1
- package/lib/Utils/offline-node-processor.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts +0 -26
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.js.map +0 -1
- package/lib/Utils/process-message.d.ts +0 -84
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/reporting-utils.d.ts +0 -13
- package/lib/Utils/reporting-utils.d.ts.map +0 -1
- package/lib/Utils/reporting-utils.js.map +0 -1
- package/lib/Utils/rich-message-utils.d.ts +0 -49
- package/lib/Utils/rich-message-utils.d.ts.map +0 -1
- package/lib/Utils/rich-message-utils.js.map +0 -1
- package/lib/Utils/signal.d.ts +0 -83
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/stanza-ack.d.ts +0 -17
- package/lib/Utils/stanza-ack.d.ts.map +0 -1
- package/lib/Utils/stanza-ack.js.map +0 -1
- package/lib/Utils/sync-action-utils.d.ts +0 -3
- package/lib/Utils/sync-action-utils.d.ts.map +0 -1
- package/lib/Utils/sync-action-utils.js.map +0 -1
- package/lib/Utils/tc-token-utils.d.ts +0 -30
- package/lib/Utils/tc-token-utils.d.ts.map +0 -1
- package/lib/Utils/tc-token-utils.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -11
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -11
- package/lib/Utils/use-single-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-single-file-auth-state.js.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.d.ts +0 -11
- package/lib/Utils/use-sqlite-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts +0 -44
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/WABinary/constants.d.ts +0 -62
- package/lib/WABinary/decode.d.ts +0 -10
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -77
- package/lib/WABinary/index.d.ts +0 -6
- package/lib/WABinary/jid-utils.d.ts +0 -29
- package/lib/WABinary/types.d.ts +0 -2
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- /package/extras/{optional-media.js → optional-media.mjs} +0 -0
package/lib/VoIP/audio-feeder.js
CHANGED
|
@@ -1,143 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _nodechild_process = require('node:child_process');
|
|
10
|
-
const LOW_WATERMARK_CHUNKS = 16;
|
|
11
|
-
const MAX_QUEUED_CHUNKS = 1024;
|
|
12
|
-
const DEFAULT_WARMUP_MS = 500;
|
|
13
|
-
class AudioFeeder {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
#proc = null;
|
|
20
|
-
#pending = Buffer.alloc(0);
|
|
21
|
-
#queue = [];
|
|
22
|
-
#emitTimer = null;
|
|
23
|
-
#nextEmitAtMs = 0;
|
|
24
|
-
#warmupUntilMs = 0;
|
|
25
|
-
__init() {this.droppedChunks = 0}
|
|
26
|
-
__init2() {this.underflowChunks = 0}
|
|
27
|
-
__init3() {this.bytesProduced = 0}
|
|
28
|
-
__init4() {this.chunksEmitted = 0}
|
|
29
|
-
constructor(sampleRate, channels, framesPerChunk, onChunk, source = "silence") {;AudioFeeder.prototype.__init.call(this);AudioFeeder.prototype.__init2.call(this);AudioFeeder.prototype.__init3.call(this);AudioFeeder.prototype.__init4.call(this);AudioFeeder.prototype.__init5.call(this);AudioFeeder.prototype.__init6.call(this);
|
|
30
|
-
this.sampleRate = sampleRate;
|
|
31
|
-
this.channels = channels;
|
|
32
|
-
this.framesPerChunk = framesPerChunk;
|
|
33
|
-
this.onChunk = onChunk;
|
|
34
|
-
this.source = source;
|
|
35
|
-
}
|
|
36
|
-
__init5() {this.start = () => {
|
|
37
|
-
if (this.#proc)
|
|
38
|
-
return;
|
|
39
|
-
const chunkSamples = this.framesPerChunk * this.channels;
|
|
40
|
-
const chunkBytes = chunkSamples * Float32Array.BYTES_PER_ELEMENT;
|
|
41
|
-
const chunkIntervalMs = (this.framesPerChunk / this.sampleRate) * 1000;
|
|
42
|
-
const inputArgs = this.#resolveInputArgs();
|
|
43
|
-
this.#proc = _nodechild_process.spawn.call(void 0, "ffmpeg", [
|
|
44
|
-
"-hide_banner",
|
|
45
|
-
"-loglevel", "error",
|
|
46
|
-
"-thread_queue_size", "512",
|
|
47
|
-
...inputArgs,
|
|
48
|
-
"-f", "f32le",
|
|
49
|
-
"-ac", String(this.channels),
|
|
50
|
-
"-ar", String(this.sampleRate),
|
|
51
|
-
"pipe:1",
|
|
52
|
-
]);
|
|
53
|
-
this.#proc.stdout.on("data", (chunk) => {
|
|
54
|
-
this.#pending = Buffer.concat([this.#pending, chunk]);
|
|
55
|
-
while (this.#pending.length >= chunkBytes) {
|
|
56
|
-
if (this.#queue.length >= MAX_QUEUED_CHUNKS) {
|
|
57
|
-
_optionalChain([this, 'access', _8 => _8.#proc, 'optionalAccess', _9 => _9.stdout, 'access', _10 => _10.pause, 'call', _11 => _11()]);
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
const frame = this.#pending.subarray(0, chunkBytes);
|
|
61
|
-
this.#pending = this.#pending.subarray(chunkBytes);
|
|
62
|
-
const out = new Float32Array(chunkSamples);
|
|
63
|
-
out.set(new Float32Array(frame.buffer, frame.byteOffset, chunkSamples));
|
|
64
|
-
this.bytesProduced += chunkBytes;
|
|
65
|
-
this.#queue.push(out);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
this.#proc.stderr.on("data", (chunk) => {
|
|
69
|
-
process.stderr.write(`[AudioFeeder] ${chunk.toString().trim()}\n`);
|
|
70
|
-
});
|
|
71
|
-
this.#proc.on("error", (err) => {
|
|
72
|
-
process.stderr.write(`[AudioFeeder] ffmpeg process error: ${err.message}\n`);
|
|
73
|
-
this.#proc = null;
|
|
74
|
-
});
|
|
75
|
-
this.#proc.on("exit", (code) => {
|
|
76
|
-
if (code !== 0 && code !== null) {
|
|
77
|
-
process.stderr.write(`[AudioFeeder] ffmpeg exited with code=${code}\n`);
|
|
78
|
-
}
|
|
79
|
-
this.#proc = null;
|
|
80
|
-
});
|
|
81
|
-
this.#nextEmitAtMs = 0;
|
|
82
|
-
this.#warmupUntilMs = Date.now() + DEFAULT_WARMUP_MS;
|
|
83
|
-
this.#scheduleNext(chunkSamples, chunkIntervalMs);
|
|
84
|
-
}}
|
|
85
|
-
__init6() {this.stop = () => {
|
|
86
|
-
if (this.#emitTimer) {
|
|
87
|
-
clearTimeout(this.#emitTimer);
|
|
88
|
-
this.#emitTimer = null;
|
|
89
|
-
}
|
|
90
|
-
_optionalChain([this, 'access', _12 => _12.#proc, 'optionalAccess', _13 => _13.kill, 'call', _14 => _14("SIGTERM")]);
|
|
91
|
-
this.#proc = null;
|
|
92
|
-
this.#pending = Buffer.alloc(0);
|
|
93
|
-
this.#queue = [];
|
|
94
|
-
this.#warmupUntilMs = 0;
|
|
95
|
-
}}
|
|
96
|
-
#resolveInputArgs = () => {
|
|
97
|
-
if (!this.source || this.source === "silence") {
|
|
98
|
-
return ["-f", "lavfi", "-i", `aevalsrc=0:d=3600:s=${this.sampleRate}`];
|
|
99
|
-
}
|
|
100
|
-
if (this.source.startsWith("lavfi:")) {
|
|
101
|
-
return ["-f", "lavfi", "-i", this.source.slice("lavfi:".length)];
|
|
102
|
-
}
|
|
103
|
-
return ["-i", this.source];
|
|
104
|
-
};
|
|
105
|
-
#scheduleNext = (chunkSamples, chunkIntervalMs) => {
|
|
106
|
-
if (!this.#proc)
|
|
107
|
-
return;
|
|
108
|
-
const now = Date.now();
|
|
109
|
-
if (this.#nextEmitAtMs === 0)
|
|
110
|
-
this.#nextEmitAtMs = now;
|
|
111
|
-
const delayMs = Math.max(0, this.#nextEmitAtMs - now);
|
|
112
|
-
this.#emitTimer = setTimeout(() => {
|
|
113
|
-
this.#emitTimer = null;
|
|
114
|
-
if (this.#queue.length < LOW_WATERMARK_CHUNKS && Date.now() < this.#warmupUntilMs) {
|
|
115
|
-
this.#nextEmitAtMs = Date.now() + 10;
|
|
116
|
-
this.#scheduleNext(chunkSamples, chunkIntervalMs);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
this.#flushOne(chunkSamples);
|
|
120
|
-
this.#nextEmitAtMs += chunkIntervalMs;
|
|
121
|
-
this.#scheduleNext(chunkSamples, chunkIntervalMs);
|
|
122
|
-
}, delayMs);
|
|
123
|
-
};
|
|
124
|
-
#flushOne = (chunkSamples) => {
|
|
125
|
-
let nextChunk = this.#queue.shift();
|
|
126
|
-
if (!nextChunk) {
|
|
127
|
-
nextChunk = new Float32Array(chunkSamples);
|
|
128
|
-
this.underflowChunks += 1;
|
|
129
|
-
}
|
|
130
|
-
this.chunksEmitted += 1;
|
|
131
|
-
this.onChunk(nextChunk);
|
|
132
|
-
if (_optionalChain([this, 'access', _15 => _15.#proc, 'optionalAccess', _16 => _16.stdout, 'access', _17 => _17.isPaused, 'call', _18 => _18()]) && this.#queue.length <= MAX_QUEUED_CHUNKS / 4) {
|
|
133
|
-
this.#proc.stdout.resume();
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
} exports.AudioFeeder = AudioFeeder;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const __kageModule103 = (() => {
|
|
140
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
141
1
|
"use strict";
|
|
142
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
143
3
|
exports.AudioFeeder = void 0;
|
|
@@ -278,9 +138,3 @@ class AudioFeeder {
|
|
|
278
138
|
};
|
|
279
139
|
}
|
|
280
140
|
exports.AudioFeeder = AudioFeeder;
|
|
281
|
-
|
|
282
|
-
return module.exports;
|
|
283
|
-
})();
|
|
284
|
-
for (const key of Object.keys(__kageModule103)) {
|
|
285
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule103[key]});
|
|
286
|
-
}
|
package/lib/VoIP/index.js
CHANGED
|
@@ -1,289 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createNamedExportFrom(obj, localName, importedName) { Object.defineProperty(exports, localName, {enumerable: true, configurable: true, get: () => obj[importedName]}); } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _nodeevents = require('node:events');
|
|
2
|
-
var _nodecrypto = require('node:crypto');
|
|
3
|
-
|
|
4
|
-
var _wasmenginejs = require('./wasm-engine.js');
|
|
5
|
-
var _relaytransportjs = require('./relay-transport.js');
|
|
6
|
-
var _signalingjs = require('./signaling.js');
|
|
7
|
-
var _audiofeederjs = require('./audio-feeder.js');
|
|
8
|
-
var _typesjs = require('./types.js'); _createNamedExportFrom(_typesjs, 'CallState', 'CallState');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const SHA256_LEN = 32;
|
|
13
|
-
|
|
14
|
-
const toBareJid = (jid) => {
|
|
15
|
-
if (!jid) return jid;
|
|
16
|
-
const at = jid.indexOf("@");
|
|
17
|
-
if (at < 0) return jid;
|
|
18
|
-
const user = jid.slice(0, at).split(":")[0];
|
|
19
|
-
return `${user}@${jid.slice(at + 1)}`;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const computeHkdf = (key, salt, info, length) => {
|
|
23
|
-
const effectiveSalt = salt && salt.length > 0 ? Buffer.from(salt) : Buffer.alloc(SHA256_LEN, 0);
|
|
24
|
-
const prk = _nodecrypto.createHmac.call(void 0, "sha256", effectiveSalt).update(key).digest();
|
|
25
|
-
const blocks = Math.ceil(length / SHA256_LEN);
|
|
26
|
-
const okm = Buffer.alloc(blocks * SHA256_LEN);
|
|
27
|
-
let prev = Buffer.alloc(0);
|
|
28
|
-
for (let i = 1; i <= blocks; i += 1) {
|
|
29
|
-
prev = _nodecrypto.createHmac.call(void 0, "sha256", prk)
|
|
30
|
-
.update(prev)
|
|
31
|
-
.update(info)
|
|
32
|
-
.update(Buffer.from([i]))
|
|
33
|
-
.digest();
|
|
34
|
-
prev.copy(okm, (i - 1) * SHA256_LEN);
|
|
35
|
-
}
|
|
36
|
-
return new Uint8Array(okm.buffer, okm.byteOffset, length);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const computeHmacSha256 = (data, key) => {
|
|
40
|
-
const result = _nodecrypto.createHmac.call(void 0, "sha256", Buffer.from(key)).update(data).digest();
|
|
41
|
-
return new Uint8Array(result.buffer, result.byteOffset, result.byteLength);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const isCallReceiptNode = (node) => {
|
|
45
|
-
if (_optionalChain([node, 'optionalAccess', _ => _.tag]) !== "receipt") return false;
|
|
46
|
-
const child = Array.isArray(node.content) ? node.content[0] : null;
|
|
47
|
-
return !!(_optionalChain([child, 'optionalAccess', _2 => _2.attrs, 'optionalAccess', _3 => _3["call-id"]]) || _optionalChain([child, 'optionalAccess', _4 => _4.attrs, 'optionalAccess', _5 => _5.call_id]));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
class ActiveCall extends _nodeevents.EventEmitter {
|
|
51
|
-
#state = _typesjs.CallState.Idle;
|
|
52
|
-
#endResolver;
|
|
53
|
-
#endPromise;
|
|
54
|
-
#endTimer = null;
|
|
55
|
-
#ended = false;
|
|
56
|
-
#hasBeenActive = false;
|
|
57
|
-
__init() {this._audioSource = "silence"}
|
|
58
|
-
|
|
59
|
-
constructor(callId, engine, durationMs) {
|
|
60
|
-
super();ActiveCall.prototype.__init.call(this);ActiveCall.prototype.__init2.call(this);ActiveCall.prototype.__init3.call(this);ActiveCall.prototype.__init4.call(this);ActiveCall.prototype.__init5.call(this);ActiveCall.prototype.__init6.call(this);ActiveCall.prototype.__init7.call(this);;
|
|
61
|
-
this.callId = callId;
|
|
62
|
-
this.engine = engine;
|
|
63
|
-
this.#endPromise = new Promise((res) => { this.#endResolver = res; });
|
|
64
|
-
if (durationMs > 0) {
|
|
65
|
-
this.#endTimer = setTimeout(() => this.end(), durationMs);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get state() { return this.#state; }
|
|
70
|
-
|
|
71
|
-
__init2() {this.end = () => {
|
|
72
|
-
if (this.#ended) return;
|
|
73
|
-
this.#ended = true;
|
|
74
|
-
if (this.#endTimer) { clearTimeout(this.#endTimer); this.#endTimer = null; }
|
|
75
|
-
try { this.engine.endCall(0, true); } catch (e3) {}
|
|
76
|
-
}}
|
|
77
|
-
|
|
78
|
-
__init3() {this.mute = (muted) => {
|
|
79
|
-
try { this.engine.setMute(muted); } catch (e4) {}
|
|
80
|
-
}}
|
|
81
|
-
|
|
82
|
-
__init4() {this.waitForEnd = () => this.#endPromise}
|
|
83
|
-
|
|
84
|
-
__init5() {this._updateState = (state) => {
|
|
85
|
-
this.#state = state;
|
|
86
|
-
if (state === _typesjs.CallState.Calling || state === _typesjs.CallState.PreacceptReceived || state === _typesjs.CallState.Active) {
|
|
87
|
-
this.#hasBeenActive = true;
|
|
88
|
-
}
|
|
89
|
-
if (state === _typesjs.CallState.PreacceptReceived) this.emit("ringing");
|
|
90
|
-
else if (state === _typesjs.CallState.Active) this.emit("connected");
|
|
91
|
-
else if (this.#hasBeenActive && (state === _typesjs.CallState.Idle || state === _typesjs.CallState.Ending)) {
|
|
92
|
-
this._forceEnd("ended");
|
|
93
|
-
}
|
|
94
|
-
}}
|
|
95
|
-
|
|
96
|
-
__init6() {this._emitAudio = (pcm) => { this.emit("audio", pcm); }}
|
|
97
|
-
|
|
98
|
-
__init7() {this._forceEnd = (reason) => {
|
|
99
|
-
if (this.#ended) return;
|
|
100
|
-
this.#ended = true;
|
|
101
|
-
if (this.#endTimer) { clearTimeout(this.#endTimer); this.#endTimer = null; }
|
|
102
|
-
this.emit("ended", reason);
|
|
103
|
-
this.#endResolver(reason);
|
|
104
|
-
}}
|
|
105
|
-
} exports.ActiveCall = ActiveCall;
|
|
106
|
-
|
|
107
|
-
class VoipClient {
|
|
108
|
-
#config;
|
|
109
|
-
#engine = null;
|
|
110
|
-
#relay = null;
|
|
111
|
-
#signaling = null;
|
|
112
|
-
#sock = null;
|
|
113
|
-
#activeCall = null;
|
|
114
|
-
#capturePtr = 0;
|
|
115
|
-
#captureChunkBytes = 0;
|
|
116
|
-
#captureSampleRate = 16000;
|
|
117
|
-
#captureChannels = 1;
|
|
118
|
-
#captureFramesPerChunk = 320;
|
|
119
|
-
#feeder = null;
|
|
120
|
-
|
|
121
|
-
constructor(config = {}) {;VoipClient.prototype.__init8.call(this);VoipClient.prototype.__init9.call(this);VoipClient.prototype.__init10.call(this);
|
|
122
|
-
this.#config = config;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
__init8() {this.connectWithSocket = async (existingSock) => {
|
|
126
|
-
this.#sock = existingSock;
|
|
127
|
-
await this.#initVoipStack();
|
|
128
|
-
}}
|
|
129
|
-
|
|
130
|
-
#initVoipStack = async () => {
|
|
131
|
-
this.#signaling = new (0, _signalingjs.SignalingBridge)({ sock: this.#sock });
|
|
132
|
-
await this.#signaling.init();
|
|
133
|
-
|
|
134
|
-
this.#relay = new (0, _relaytransportjs.RelayRtcTransport)({
|
|
135
|
-
onTransportMessage: (data, ip, port) => _optionalChain([this, 'access', _15 => _15.#engine, 'optionalAccess', _16 => _16.handleOnTransportMessage, 'call', _17 => _17(data, ip, port)]),
|
|
136
|
-
onIceRtt: (rttMs, ip, port) => _optionalChain([this, 'access', _18 => _18.#engine, 'optionalAccess', _19 => _19.updateIceRtt, 'call', _20 => _20(rttMs, ip, port)]),
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
this.#engine = new (0, _wasmenginejs.WasmEngine)({
|
|
140
|
-
resourcesPath: this.#config.resourcesPath,
|
|
141
|
-
callbacks: {
|
|
142
|
-
onSignalingXmpp: (peerJid, callId, xmlPayload) =>
|
|
143
|
-
this.#signaling.sendSignaling(peerJid, callId, xmlPayload),
|
|
144
|
-
onCallEvent: (eventType, eventData) => this.#handleCallEvent(eventType, eventData),
|
|
145
|
-
sendDataToRelay: (data, ip, port) => this.#relay.send(data, ip, port),
|
|
146
|
-
onAudioCaptureInit: (config) => this.#handleAudioCaptureInit(config),
|
|
147
|
-
onAudioCaptureStart: () => this.#handleAudioCaptureStart(),
|
|
148
|
-
onAudioCaptureStop: () => this.#handleAudioCaptureStop(),
|
|
149
|
-
onAudioPlaybackData: (audioData) => _optionalChain([this, 'access', _21 => _21.#activeCall, 'optionalAccess', _22 => _22._emitAudio, 'call', _23 => _23(audioData)]),
|
|
150
|
-
cryptoHkdf: computeHkdf,
|
|
151
|
-
hmacSha256: computeHmacSha256,
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
await this.#engine.initialize();
|
|
156
|
-
this.#signaling.attachEngine(this.#engine);
|
|
157
|
-
|
|
158
|
-
const selfPnJid = _optionalChain([this, 'access', _24 => _24.#sock, 'access', _25 => _25.authState, 'access', _26 => _26.creds, 'access', _27 => _27.me, 'optionalAccess', _28 => _28.id]);
|
|
159
|
-
const selfLidJid = _optionalChain([this, 'access', _29 => _29.#sock, 'access', _30 => _30.authState, 'access', _31 => _31.creds, 'access', _32 => _32.me, 'optionalAccess', _33 => _33.lid]);
|
|
160
|
-
this.#engine.initVoipStack(selfPnJid, toBareJid(selfPnJid), selfLidJid);
|
|
161
|
-
await this.#engine.waitForVoipStackReady();
|
|
162
|
-
try { this.#engine.updateNetworkMedium(2, 0); } catch (e6) {}
|
|
163
|
-
|
|
164
|
-
this.#sock.ws.on("CB:call", (node) => {
|
|
165
|
-
this.#signaling.processIncomingCall(node, this.#engine, _nullishCoalesce(_optionalChain([this, 'access', _34 => _34.#activeCall, 'optionalAccess', _35 => _35.callId]), () => ( "")));
|
|
166
|
-
});
|
|
167
|
-
this.#sock.ws.on("CB:receipt", (node) => {
|
|
168
|
-
if (!isCallReceiptNode(node)) return;
|
|
169
|
-
this.#signaling.processIncomingReceipt(node, this.#engine, _nullishCoalesce(_optionalChain([this, 'access', _36 => _36.#activeCall, 'optionalAccess', _37 => _37.callId]), () => ( "")));
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
__init9() {this.call = async (phoneNumber, opts = {}) => {
|
|
174
|
-
if (!this.#engine || !this.#signaling) throw new Error("Not connected. Call connectWithSocket() first.");
|
|
175
|
-
if (this.#activeCall) throw new Error("A call is already active.");
|
|
176
|
-
|
|
177
|
-
const targetNumber = phoneNumber.replace(/\D/g, "");
|
|
178
|
-
const targetPnJid = `${targetNumber}@s.whatsapp.net`;
|
|
179
|
-
const durationMs = _nullishCoalesce(opts.durationMs, () => ( 120000));
|
|
180
|
-
const audioSource = _nullishCoalesce(opts.audioSource, () => ( "silence"));
|
|
181
|
-
|
|
182
|
-
const peerLid = await this.#signaling.resolveLid(targetPnJid);
|
|
183
|
-
if (!peerLid) throw new Error(`Could not resolve LID for ${targetPnJid}`);
|
|
184
|
-
|
|
185
|
-
for (const jid of [targetPnJid, peerLid]) {
|
|
186
|
-
try { await this.#sock.presenceSubscribe(jid); } catch (e7) {}
|
|
187
|
-
}
|
|
188
|
-
await new Promise((r) => setTimeout(r, 750));
|
|
189
|
-
|
|
190
|
-
const peerDeviceJids = await this.#signaling.discoverPeerDevices(peerLid);
|
|
191
|
-
const deviceList = peerDeviceJids.length ? peerDeviceJids : [toBareJid(peerLid)];
|
|
192
|
-
|
|
193
|
-
const allSessionTargets = [...new Set([...deviceList, peerLid, toBareJid(peerLid), targetPnJid, toBareJid(targetPnJid)])];
|
|
194
|
-
await this.#signaling.ensureSessionsForPeers(allSessionTargets);
|
|
195
|
-
|
|
196
|
-
await new Promise((r) => setTimeout(r, 500));
|
|
197
|
-
await this.#signaling.issueTcToken(peerLid);
|
|
198
|
-
const tcToken = await this.#signaling.ensureTcToken(peerLid, targetPnJid);
|
|
199
|
-
|
|
200
|
-
const callId = ("00" + _nodecrypto.randomBytes.call(void 0, 16).toString("hex").slice(2)).toUpperCase();
|
|
201
|
-
|
|
202
|
-
const call = new ActiveCall(callId, this.#engine, durationMs);
|
|
203
|
-
call._audioSource = audioSource;
|
|
204
|
-
this.#activeCall = call;
|
|
205
|
-
|
|
206
|
-
this.#engine.startCall({
|
|
207
|
-
peerJid: peerLid,
|
|
208
|
-
peerPn: targetPnJid,
|
|
209
|
-
peerList: deviceList,
|
|
210
|
-
callId,
|
|
211
|
-
isVideo: false,
|
|
212
|
-
isLidCall: true,
|
|
213
|
-
isFromDialer: false,
|
|
214
|
-
extraData: tcToken,
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
return call;
|
|
218
|
-
}}
|
|
219
|
-
|
|
220
|
-
__init10() {this.disconnect = () => {
|
|
221
|
-
_optionalChain([this, 'access', _38 => _38.#activeCall, 'optionalAccess', _39 => _39._forceEnd, 'call', _40 => _40("disconnect")]);
|
|
222
|
-
this.#activeCall = null;
|
|
223
|
-
_optionalChain([this, 'access', _41 => _41.#relay, 'optionalAccess', _42 => _42.closeAll, 'call', _43 => _43()]);
|
|
224
|
-
_optionalChain([this, 'access', _44 => _44.#engine, 'optionalAccess', _45 => _45.destroy, 'call', _46 => _46()]);
|
|
225
|
-
this.#engine = null;
|
|
226
|
-
this.#relay = null;
|
|
227
|
-
this.#signaling = null;
|
|
228
|
-
this.#sock = null;
|
|
229
|
-
}}
|
|
230
|
-
|
|
231
|
-
#handleCallEvent = (eventType, eventData) => {
|
|
232
|
-
if (eventType === 16 && eventData) {
|
|
233
|
-
try {
|
|
234
|
-
const parsed = JSON.parse(eventData);
|
|
235
|
-
const info = _nullishCoalesce(_nullishCoalesce(parsed.call_info, () => ( parsed.callInfo)), () => ( {}));
|
|
236
|
-
const callState = Number(_nullishCoalesce(_nullishCoalesce(info.call_state, () => ( info.callState)), () => ( 0)));
|
|
237
|
-
_optionalChain([this, 'access', _47 => _47.#activeCall, 'optionalAccess', _48 => _48._updateState, 'call', _49 => _49(callState)]);
|
|
238
|
-
} catch (e8) {}
|
|
239
|
-
} else if (eventType === 156 && eventData) {
|
|
240
|
-
try {
|
|
241
|
-
const update = JSON.parse(eventData);
|
|
242
|
-
_optionalChain([this, 'access', _50 => _50.#relay, 'optionalAccess', _51 => _51.updateRelayList, 'call', _52 => _52(update)]);
|
|
243
|
-
} catch (e9) {}
|
|
244
|
-
} else if (eventType === 2) {
|
|
245
|
-
_optionalChain([this, 'access', _53 => _53.#activeCall, 'optionalAccess', _54 => _54._forceEnd, 'call', _55 => _55("remote_end")]);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
#handleAudioCaptureInit = (config) => {
|
|
250
|
-
if (!this.#engine) return;
|
|
251
|
-
this.#captureSampleRate = config.sampleRate || 16000;
|
|
252
|
-
this.#captureChannels = config.channels || 1;
|
|
253
|
-
this.#captureFramesPerChunk = config.framesPerChunk || 320;
|
|
254
|
-
const chunkSamples = this.#captureFramesPerChunk * this.#captureChannels;
|
|
255
|
-
this.#captureChunkBytes = chunkSamples * Float32Array.BYTES_PER_ELEMENT;
|
|
256
|
-
this.#capturePtr = this.#engine.malloc(this.#captureChunkBytes);
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
#handleAudioCaptureStart = () => {
|
|
260
|
-
if (!this.#engine || !this.#capturePtr) return;
|
|
261
|
-
const audioSource = _nullishCoalesce(_optionalChain([this, 'access', _56 => _56.#activeCall, 'optionalAccess', _57 => _57._audioSource]), () => ( "silence"));
|
|
262
|
-
this.#feeder = new (0, _audiofeederjs.AudioFeeder)(
|
|
263
|
-
this.#captureSampleRate,
|
|
264
|
-
this.#captureChannels,
|
|
265
|
-
this.#captureFramesPerChunk,
|
|
266
|
-
(chunk) => {
|
|
267
|
-
if (this.#engine && this.#capturePtr) this.#engine.sendAudioData(chunk, this.#capturePtr);
|
|
268
|
-
},
|
|
269
|
-
audioSource,
|
|
270
|
-
);
|
|
271
|
-
this.#feeder.start();
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
#handleAudioCaptureStop = () => {
|
|
275
|
-
_optionalChain([this, 'access', _58 => _58.#feeder, 'optionalAccess', _59 => _59.stop, 'call', _60 => _60()]);
|
|
276
|
-
this.#feeder = null;
|
|
277
|
-
if (this.#engine && this.#capturePtr) {
|
|
278
|
-
try { this.#engine.free(this.#capturePtr); } catch (e10) {}
|
|
279
|
-
this.#capturePtr = 0;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
} exports.VoipClient = VoipClient;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const __kageModule104 = (() => {
|
|
286
|
-
const module = { exports: {} }; const exports = module.exports;
|
|
287
1
|
"use strict";
|
|
288
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
289
3
|
exports.VoipClient = exports.ActiveCall = exports.CallState = void 0;
|
|
@@ -563,9 +277,3 @@ class VoipClient {
|
|
|
563
277
|
};
|
|
564
278
|
}
|
|
565
279
|
exports.VoipClient = VoipClient;
|
|
566
|
-
|
|
567
|
-
return module.exports;
|
|
568
|
-
})();
|
|
569
|
-
for (const key of Object.keys(__kageModule104)) {
|
|
570
|
-
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule104[key]});
|
|
571
|
-
}
|