@japofc/baileys 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +111 -0
- package/README.md +1254 -0
- package/WAProto/index.d.ts +9 -0
- package/WAProto/index.js +142276 -0
- package/engine-requirements.js +13 -0
- package/lib/Builders/A2UI.d.ts +242 -0
- package/lib/Builders/A2UI.js +308 -0
- package/lib/Builders/AIRich.d.ts +105 -0
- package/lib/Builders/AIRich.js +2286 -0
- package/lib/Builders/Button.d.ts +103 -0
- package/lib/Builders/Button.js +883 -0
- package/lib/Builders/ButtonV2.d.ts +28 -0
- package/lib/Builders/ButtonV2.js +144 -0
- package/lib/Builders/ButtonV3.d.ts +25 -0
- package/lib/Builders/ButtonV3.js +184 -0
- package/lib/Builders/Carousel.d.ts +22 -0
- package/lib/Builders/Carousel.js +111 -0
- package/lib/Builders/JapBaileys.d.ts +34 -0
- package/lib/Builders/JapBaileys.js +108 -0
- package/lib/Builders/Poll.d.ts +25 -0
- package/lib/Builders/Poll.js +128 -0
- package/lib/Builders/index.d.ts +17 -0
- package/lib/Builders/index.js +11 -0
- package/lib/Builders/shared.d.ts +67 -0
- package/lib/Builders/shared.js +652 -0
- package/lib/Defaults/index.d.ts +154 -0
- package/lib/Defaults/index.js +178 -0
- package/lib/Framework/Bot.d.ts +61 -0
- package/lib/Framework/Bot.js +248 -0
- package/lib/Framework/Context.d.ts +21 -0
- package/lib/Framework/Context.js +89 -0
- package/lib/Framework/MediaManager.d.ts +17 -0
- package/lib/Framework/MediaManager.js +151 -0
- package/lib/Framework/SessionManager.d.ts +13 -0
- package/lib/Framework/SessionManager.js +33 -0
- package/lib/Framework/StatsManager.d.ts +26 -0
- package/lib/Framework/StatsManager.js +119 -0
- package/lib/Framework/Store/SQLiteStore.d.ts +11 -0
- package/lib/Framework/Store/SQLiteStore.js +73 -0
- package/lib/Framework/index.d.ts +9 -0
- package/lib/Framework/index.js +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.d.ts +10 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.d.ts +54 -0
- package/lib/Signal/libsignal.js +430 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Signal/lid-mapping.js +276 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.d.ts +395 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.d.ts +136 -0
- package/lib/Socket/chats.js +1327 -0
- package/lib/Socket/communities.d.ts +562 -0
- package/lib/Socket/communities.js +439 -0
- package/lib/Socket/dugong.d.ts +117 -0
- package/lib/Socket/dugong.js +798 -0
- package/lib/Socket/groups.d.ts +285 -0
- package/lib/Socket/groups.js +354 -0
- package/lib/Socket/index.d.ts +585 -0
- package/lib/Socket/index.js +52 -0
- package/lib/Socket/messages-recv.d.ts +333 -0
- package/lib/Socket/messages-recv.js +1781 -0
- package/lib/Socket/messages-send.d.ts +353 -0
- package/lib/Socket/messages-send.js +1524 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.d.ts +286 -0
- package/lib/Socket/newsletter.js +364 -0
- package/lib/Socket/socket.d.ts +60 -0
- package/lib/Socket/socket.js +1012 -0
- package/lib/Socket/username.d.ts +82 -0
- package/lib/Socket/username.js +159 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.d.ts +62 -0
- package/lib/Store/make-in-memory-store.js +428 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +26 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +5 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +6 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +62 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +138 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +8 -0
- package/lib/Types/State.js +55 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/index.d.ts +68 -0
- package/lib/Types/index.js +27 -0
- package/lib/Utils/MessageBuilder.d.ts +2 -0
- package/lib/Utils/MessageBuilder.js +2 -0
- package/lib/Utils/PersistentStore.d.ts +60 -0
- package/lib/Utils/PersistentStore.js +592 -0
- package/lib/Utils/anti-delete.d.ts +74 -0
- package/lib/Utils/anti-delete.js +221 -0
- package/lib/Utils/auth-secure.d.ts +86 -0
- package/lib/Utils/auth-secure.js +764 -0
- package/lib/Utils/auth-utils.d.ts +57 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/auto-reply.d.ts +47 -0
- package/lib/Utils/auto-reply.js +157 -0
- package/lib/Utils/baileys-event-stream.d.ts +8 -0
- package/lib/Utils/baileys-event-stream.js +62 -0
- package/lib/Utils/browser-utils.d.ts +8 -0
- package/lib/Utils/browser-utils.js +27 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +239 -0
- package/lib/Utils/button-helper-utils.d.ts +53 -0
- package/lib/Utils/button-helper-utils.js +312 -0
- package/lib/Utils/button-sender.d.ts +54 -0
- package/lib/Utils/button-sender.js +822 -0
- package/lib/Utils/chat-control.d.ts +159 -0
- package/lib/Utils/chat-control.js +230 -0
- package/lib/Utils/chat-history-helpers.d.ts +21 -0
- package/lib/Utils/chat-history-helpers.js +70 -0
- package/lib/Utils/chat-utils.d.ts +407 -0
- package/lib/Utils/chat-utils.js +885 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/companion-reg-client-utils.js +39 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +147 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +316 -0
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/event-buffer.js +635 -0
- package/lib/Utils/generics.d.ts +69 -0
- package/lib/Utils/generics.js +438 -0
- package/lib/Utils/history-share.d.ts +11 -0
- package/lib/Utils/history-share.js +70 -0
- package/lib/Utils/history.d.ts +90 -0
- package/lib/Utils/history.js +146 -0
- package/lib/Utils/humanizer.d.ts +12 -0
- package/lib/Utils/humanizer.js +73 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/index.d.ts +57 -0
- package/lib/Utils/index.js +56 -0
- package/lib/Utils/jid-tools.d.ts +6 -0
- package/lib/Utils/jid-tools.js +77 -0
- package/lib/Utils/link-preview.d.ts +12 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +26 -0
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/media-messages.d.ts +18 -0
- package/lib/Utils/media-messages.js +70 -0
- package/lib/Utils/media-set.d.ts +13 -0
- package/lib/Utils/media-set.js +171 -0
- package/lib/Utils/message-kind.d.ts +32 -0
- package/lib/Utils/message-kind.js +136 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/message-retry-manager.js +264 -0
- package/lib/Utils/message-search.d.ts +44 -0
- package/lib/Utils/message-search.js +188 -0
- package/lib/Utils/messages-media.d.ts +135 -0
- package/lib/Utils/messages-media.js +868 -0
- package/lib/Utils/messages.d.ts +44 -0
- package/lib/Utils/messages.js +2326 -0
- package/lib/Utils/meta-ai.d.ts +13 -0
- package/lib/Utils/meta-ai.js +74 -0
- package/lib/Utils/mini-app.d.ts +35 -0
- package/lib/Utils/mini-app.js +213 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +9 -0
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/past-participants.d.ts +14 -0
- package/lib/Utils/past-participants.js +40 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +82 -0
- package/lib/Utils/process-message.js +808 -0
- package/lib/Utils/qr-render.d.ts +59 -0
- package/lib/Utils/qr-render.js +179 -0
- package/lib/Utils/qrcodegen.d.ts +79 -0
- package/lib/Utils/qrcodegen.js +848 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +444 -0
- package/lib/Utils/router.d.ts +37 -0
- package/lib/Utils/router.js +165 -0
- package/lib/Utils/scheduled-posts.d.ts +30 -0
- package/lib/Utils/scheduled-posts.js +110 -0
- package/lib/Utils/scheduling.d.ts +42 -0
- package/lib/Utils/scheduling.js +139 -0
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/signal.js +200 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/status.d.ts +50 -0
- package/lib/Utils/status.js +107 -0
- package/lib/Utils/stickerpack.d.ts +51 -0
- package/lib/Utils/stickerpack.js +274 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tag.d.ts +12 -0
- package/lib/Utils/tag.js +44 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/tc-token-utils.js +162 -0
- package/lib/Utils/templates.d.ts +76 -0
- package/lib/Utils/templates.js +150 -0
- package/lib/Utils/transcribe.d.ts +12 -0
- package/lib/Utils/transcribe.js +107 -0
- package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
- package/lib/Utils/use-cache-manager-auth-state.js +81 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-multi-file-auth-state.js +166 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.js +113 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +169 -0
- package/lib/Utils/validate-connection.d.ts +42 -0
- package/lib/Utils/validate-connection.js +198 -0
- package/lib/Utils/vcard.d.ts +58 -0
- package/lib/Utils/vcard.js +104 -0
- package/lib/Utils/voice-note.d.ts +15 -0
- package/lib/Utils/voice-note.js +63 -0
- package/lib/VoIP/audio-feeder.d.ts +18 -0
- package/lib/VoIP/audio-feeder.js +160 -0
- package/lib/VoIP/call-recorder.d.ts +13 -0
- package/lib/VoIP/call-recorder.js +73 -0
- package/lib/VoIP/index.d.ts +86 -0
- package/lib/VoIP/index.js +611 -0
- package/lib/VoIP/relay-transport.d.ts +43 -0
- package/lib/VoIP/relay-transport.js +563 -0
- package/lib/VoIP/signaling.d.ts +26 -0
- package/lib/VoIP/signaling.js +662 -0
- package/lib/VoIP/types.d.ts +69 -0
- package/lib/VoIP/types.js +17 -0
- package/lib/VoIP/wasm-engine.d.ts +120 -0
- package/lib/VoIP/wasm-engine.js +1358 -0
- package/lib/VoIP/worker-bootstrap.d.ts +4 -0
- package/lib/VoIP/worker-bootstrap.js +1046 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/constants.js +1466 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +74 -0
- package/lib/WABinary/generic-utils.js +276 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +62 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +7 -0
- package/lib/WAUSync/Protocols/index.js +7 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncQuery.js +121 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/USyncUser.js +30 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/assets/wasm/loader.d.ts +5 -0
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.d.ts +5 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +23 -0
- package/package.json +180 -0
- package/postinstall-banner.js +82 -0
|
@@ -0,0 +1,1046 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker-thread bootstrap for the WhatsApp WASM VoIP engine.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the browser Web-Worker environment (self/postMessage/babelHelpers/
|
|
5
|
+
* MessagePort) the WASM loader expects, then runs that loader inside a Node
|
|
6
|
+
* `worker_threads` Worker. Function-keyword shims are intentional — the
|
|
7
|
+
* loader inspects `.prototype` and `instanceof` on these.
|
|
8
|
+
*
|
|
9
|
+
* @author J.AP
|
|
10
|
+
*/
|
|
11
|
+
"use strict";
|
|
12
|
+
import { parentPort, workerData } from "worker_threads";
|
|
13
|
+
import * as path from "path";
|
|
14
|
+
import * as fs from "fs";
|
|
15
|
+
import * as crypto from "crypto";
|
|
16
|
+
import * as vm from "vm";
|
|
17
|
+
import { fileURLToPath } from "url";
|
|
18
|
+
import { createRequire } from "module";
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = path.dirname(__filename);
|
|
21
|
+
const _require = createRequire(import.meta.url);
|
|
22
|
+
const typedWorkerData = workerData;
|
|
23
|
+
if (typeof process === "undefined") {
|
|
24
|
+
global.process = {
|
|
25
|
+
cwd: () => __dirname || ".",
|
|
26
|
+
env: {},
|
|
27
|
+
platform: "linux",
|
|
28
|
+
version: "v18.0.0",
|
|
29
|
+
versions: {},
|
|
30
|
+
nextTick: (fn, ...args) => setImmediate(fn, ...args),
|
|
31
|
+
exit: (code) => {
|
|
32
|
+
throw new Error(`Process exit: ${code}`);
|
|
33
|
+
},
|
|
34
|
+
on: () => { },
|
|
35
|
+
off: () => { },
|
|
36
|
+
once: () => { },
|
|
37
|
+
emit: () => { },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else if (!process.cwd) {
|
|
41
|
+
process.cwd = () => __dirname || ".";
|
|
42
|
+
}
|
|
43
|
+
global.babelHelpers = {
|
|
44
|
+
extends: function (target) {
|
|
45
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
46
|
+
var source = arguments[i];
|
|
47
|
+
if (source != null) {
|
|
48
|
+
for (var key in source) {
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
50
|
+
target[key] = source[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return target;
|
|
56
|
+
},
|
|
57
|
+
inheritsLoose: function (subClass, superClass) {
|
|
58
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
59
|
+
subClass.prototype.constructor = subClass;
|
|
60
|
+
subClass.__proto__ = superClass;
|
|
61
|
+
},
|
|
62
|
+
taggedTemplateLiteralLoose: function (strings, raw) {
|
|
63
|
+
if (!raw)
|
|
64
|
+
raw = strings.slice(0);
|
|
65
|
+
strings.raw = raw;
|
|
66
|
+
return strings;
|
|
67
|
+
},
|
|
68
|
+
asyncToGenerator: function (fn) {
|
|
69
|
+
return function () {
|
|
70
|
+
var self = this;
|
|
71
|
+
var args = arguments;
|
|
72
|
+
return new Promise(function (resolve, reject) {
|
|
73
|
+
var gen = fn.apply(self, args);
|
|
74
|
+
function step(key, arg) {
|
|
75
|
+
try {
|
|
76
|
+
var info = gen[key](arg);
|
|
77
|
+
var value = info.value;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
reject(error);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (info.done) {
|
|
84
|
+
resolve(value);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
Promise.resolve(value).then(function (val) { step("next", val); }, function (err) { step("throw", err); });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
step("next");
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
createClass: function (Constructor, protoProps, staticProps) {
|
|
95
|
+
if (protoProps) {
|
|
96
|
+
for (var i = 0; i < protoProps.length; i++) {
|
|
97
|
+
var descriptor = protoProps[i];
|
|
98
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
99
|
+
descriptor.configurable = true;
|
|
100
|
+
if ("value" in descriptor)
|
|
101
|
+
descriptor.writable = true;
|
|
102
|
+
Object.defineProperty(Constructor.prototype, descriptor.key, descriptor);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (staticProps) {
|
|
106
|
+
for (var j = 0; j < staticProps.length; j++) {
|
|
107
|
+
var staticDescriptor = staticProps[j];
|
|
108
|
+
staticDescriptor.enumerable = staticDescriptor.enumerable || false;
|
|
109
|
+
staticDescriptor.configurable = true;
|
|
110
|
+
if ("value" in staticDescriptor)
|
|
111
|
+
staticDescriptor.writable = true;
|
|
112
|
+
Object.defineProperty(Constructor, staticDescriptor.key, staticDescriptor);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return Constructor;
|
|
116
|
+
},
|
|
117
|
+
classCallCheck: function (instance, Constructor) {
|
|
118
|
+
if (!(instance instanceof Constructor)) {
|
|
119
|
+
throw new TypeError("Cannot call a class as a function");
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
defineProperty: function (obj, key, value) {
|
|
123
|
+
if (key in obj) {
|
|
124
|
+
Object.defineProperty(obj, key, {
|
|
125
|
+
value: value,
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
writable: true,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
obj[key] = value;
|
|
133
|
+
}
|
|
134
|
+
return obj;
|
|
135
|
+
},
|
|
136
|
+
objectSpread: function (target) {
|
|
137
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
138
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
139
|
+
var ownKeys = Object.keys(source);
|
|
140
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
141
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
|
142
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
ownKeys.forEach(function (key) {
|
|
146
|
+
target[key] = source[key];
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return target;
|
|
150
|
+
},
|
|
151
|
+
objectSpread2: function (target) {
|
|
152
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
153
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
154
|
+
if (i % 2) {
|
|
155
|
+
Object.keys(source).forEach(function (key) {
|
|
156
|
+
target[key] = source[key];
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else if (Object.getOwnPropertyDescriptors) {
|
|
160
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
Object.keys(source).forEach(function (key) {
|
|
164
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return target;
|
|
169
|
+
},
|
|
170
|
+
wrapNativeSuper: function (Class) {
|
|
171
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
172
|
+
function Wrapper() {
|
|
173
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
174
|
+
}
|
|
175
|
+
function _construct(Parent, args, Class) {
|
|
176
|
+
if (typeof Reflect !== "undefined" && Reflect.construct) {
|
|
177
|
+
return Reflect.construct(Parent, args, Class);
|
|
178
|
+
}
|
|
179
|
+
var a = [null];
|
|
180
|
+
a.push.apply(a, args);
|
|
181
|
+
var instance = new (Function.bind.apply(Parent, a))();
|
|
182
|
+
if (Class)
|
|
183
|
+
Object.setPrototypeOf(instance, Class.prototype);
|
|
184
|
+
return instance;
|
|
185
|
+
}
|
|
186
|
+
function _getPrototypeOf(o) {
|
|
187
|
+
return Object.getPrototypeOf || function (o) { return o.__proto__; };
|
|
188
|
+
}
|
|
189
|
+
if (typeof Class !== "function")
|
|
190
|
+
return Class;
|
|
191
|
+
if (_cache) {
|
|
192
|
+
if (_cache.has(Class))
|
|
193
|
+
return _cache.get(Class);
|
|
194
|
+
_cache.set(Class, Wrapper);
|
|
195
|
+
}
|
|
196
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
197
|
+
constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true },
|
|
198
|
+
});
|
|
199
|
+
return Object.setPrototypeOf(Wrapper, Class);
|
|
200
|
+
},
|
|
201
|
+
isNativeFunction: function (fn) {
|
|
202
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
203
|
+
},
|
|
204
|
+
getPrototypeOf: function (o) {
|
|
205
|
+
return Object.getPrototypeOf ? Object.getPrototypeOf(o) : o.__proto__;
|
|
206
|
+
},
|
|
207
|
+
setPrototypeOf: function (o, p) {
|
|
208
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(o, p) : ((o.__proto__ = p), o);
|
|
209
|
+
},
|
|
210
|
+
assertThisInitialized: function (self) {
|
|
211
|
+
if (self === void 0) {
|
|
212
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
213
|
+
}
|
|
214
|
+
return self;
|
|
215
|
+
},
|
|
216
|
+
possibleConstructorReturn: function (self, call) {
|
|
217
|
+
if (call && (typeof call === "object" || typeof call === "function"))
|
|
218
|
+
return call;
|
|
219
|
+
return global.babelHelpers.assertThisInitialized(self);
|
|
220
|
+
},
|
|
221
|
+
inherits: function (subClass, superClass) {
|
|
222
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
223
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
224
|
+
}
|
|
225
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
226
|
+
constructor: { value: subClass, writable: true, configurable: true },
|
|
227
|
+
});
|
|
228
|
+
if (superClass)
|
|
229
|
+
Object.setPrototypeOf(subClass, superClass);
|
|
230
|
+
},
|
|
231
|
+
construct: function (Parent, args, Class) {
|
|
232
|
+
if (typeof Reflect !== "undefined" && Reflect.construct) {
|
|
233
|
+
return Reflect.construct(Parent, args, Class);
|
|
234
|
+
}
|
|
235
|
+
var a = [null];
|
|
236
|
+
a.push.apply(a, args);
|
|
237
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
238
|
+
var instance = new Constructor();
|
|
239
|
+
if (Class)
|
|
240
|
+
Object.setPrototypeOf(instance, Class.prototype);
|
|
241
|
+
return instance;
|
|
242
|
+
},
|
|
243
|
+
isNativeReflectConstruct: function () {
|
|
244
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
245
|
+
return false;
|
|
246
|
+
try {
|
|
247
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () { }));
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
if (typeof global.require === "undefined") {
|
|
256
|
+
global.require = _require;
|
|
257
|
+
}
|
|
258
|
+
const _originalProcess = global.process;
|
|
259
|
+
const _originalRequire = global.require;
|
|
260
|
+
const hideNodeEnv = () => {
|
|
261
|
+
try {
|
|
262
|
+
delete global.process;
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
265
|
+
global.process = undefined;
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
delete global.require;
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
global.require = undefined;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const restoreNodeEnv = () => {
|
|
275
|
+
global.process = _originalProcess;
|
|
276
|
+
global.require = _originalRequire;
|
|
277
|
+
};
|
|
278
|
+
const __modules = {};
|
|
279
|
+
const __moduleFactories = {};
|
|
280
|
+
global.__d = function (name, deps, factory, flags) {
|
|
281
|
+
if (typeof deps === "function") {
|
|
282
|
+
factory = deps;
|
|
283
|
+
deps = [];
|
|
284
|
+
}
|
|
285
|
+
__moduleFactories[name] = { factory, deps, flags };
|
|
286
|
+
};
|
|
287
|
+
const importDefaultModule = (name) => {
|
|
288
|
+
const value = global.__r(name);
|
|
289
|
+
return value && value.__esModule ? value.default : value;
|
|
290
|
+
};
|
|
291
|
+
const importAllModule = (name) => {
|
|
292
|
+
const value = global.__r(name);
|
|
293
|
+
if (value == null) {
|
|
294
|
+
return { default: value };
|
|
295
|
+
}
|
|
296
|
+
if (value.__esModule) {
|
|
297
|
+
return value;
|
|
298
|
+
}
|
|
299
|
+
if (typeof value !== "object" && typeof value !== "function") {
|
|
300
|
+
return { default: value };
|
|
301
|
+
}
|
|
302
|
+
const namespace = {};
|
|
303
|
+
for (const key of Object.keys(value)) {
|
|
304
|
+
namespace[key] = value[key];
|
|
305
|
+
}
|
|
306
|
+
namespace.default = value;
|
|
307
|
+
return namespace;
|
|
308
|
+
};
|
|
309
|
+
global.__r = function (name) {
|
|
310
|
+
if (__modules[name])
|
|
311
|
+
return __modules[name].exports;
|
|
312
|
+
const moduleFactory = __moduleFactories[name];
|
|
313
|
+
if (!moduleFactory)
|
|
314
|
+
throw new Error(`Module "${name}" not found`);
|
|
315
|
+
const module = { exports: {} };
|
|
316
|
+
__modules[name] = module;
|
|
317
|
+
try {
|
|
318
|
+
// FB Comet bundle uses two export conventions by module flag: flag-66 factories
|
|
319
|
+
// write exports to arg 6, flag-98 factories (124 of 204 modules) write to arg 7.
|
|
320
|
+
// No factory reads the dependency map (string-requires only), so passing the
|
|
321
|
+
// exports object at BOTH positions satisfies every convention in the bundle.
|
|
322
|
+
moduleFactory.factory(global, global.__r, importDefaultModule, importAllModule, module, module.exports, module.exports);
|
|
323
|
+
}
|
|
324
|
+
catch (e) {
|
|
325
|
+
delete __modules[name];
|
|
326
|
+
throw e;
|
|
327
|
+
}
|
|
328
|
+
return module.exports;
|
|
329
|
+
};
|
|
330
|
+
__modules["Promise"] = { exports: Promise };
|
|
331
|
+
const bxFunc = function (id) { return id; };
|
|
332
|
+
bxFunc.getURL = function (_id, _opts) { return ""; };
|
|
333
|
+
__modules["bx"] = { exports: bxFunc };
|
|
334
|
+
__modules["WorkerBundleResource"] = {
|
|
335
|
+
exports: { createDedicatedWebWorker: function () { return null; } },
|
|
336
|
+
};
|
|
337
|
+
__modules["WorkerClient"] = { exports: { init: function () { } } };
|
|
338
|
+
__modules["WorkerMessagePort"] = {
|
|
339
|
+
exports: { WorkerSyncedMessagePort: function () { } },
|
|
340
|
+
};
|
|
341
|
+
__modules["WAWebVoipWebWasmWorkerResource"] = { exports: {} };
|
|
342
|
+
if (typeof self === "undefined")
|
|
343
|
+
global.self = global;
|
|
344
|
+
global.self = global;
|
|
345
|
+
if (typeof global.window === "undefined")
|
|
346
|
+
global.window = global;
|
|
347
|
+
global.importScripts = function (...urls) {
|
|
348
|
+
for (const url of urls) {
|
|
349
|
+
try {
|
|
350
|
+
const code = fs.readFileSync(url, "utf8");
|
|
351
|
+
eval(code);
|
|
352
|
+
}
|
|
353
|
+
catch (e) { console.error(`[VoIP worker-bootstrap] importScripts failed for "${url}":`, e); }
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
if (typeof global.location === "undefined") {
|
|
357
|
+
global.location = {
|
|
358
|
+
href: __filename,
|
|
359
|
+
origin: "file://",
|
|
360
|
+
protocol: "file:",
|
|
361
|
+
host: "",
|
|
362
|
+
hostname: "",
|
|
363
|
+
port: "",
|
|
364
|
+
pathname: __filename,
|
|
365
|
+
search: "",
|
|
366
|
+
hash: "",
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
global.postMessage = function (data, transfer) {
|
|
370
|
+
if (parentPort)
|
|
371
|
+
parentPort.postMessage(data, transfer);
|
|
372
|
+
};
|
|
373
|
+
const messageListeners = [];
|
|
374
|
+
global.addEventListener = function (type, handler) {
|
|
375
|
+
if (type === "message") {
|
|
376
|
+
messageListeners.push(handler);
|
|
377
|
+
if (parentPort)
|
|
378
|
+
parentPort.on("message", (data) => {
|
|
379
|
+
handler({ data });
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
class SimpleHook {
|
|
384
|
+
listeners = [];
|
|
385
|
+
add = (fn) => { this.listeners.push(fn); return fn; };
|
|
386
|
+
remove = (fn) => { const idx = this.listeners.indexOf(fn); if (idx >= 0) {
|
|
387
|
+
this.listeners.splice(idx, 1);
|
|
388
|
+
return true;
|
|
389
|
+
} return false; };
|
|
390
|
+
clear = () => { this.listeners = []; };
|
|
391
|
+
call = (data) => { for (const fn of this.listeners) {
|
|
392
|
+
try {
|
|
393
|
+
fn(data);
|
|
394
|
+
}
|
|
395
|
+
catch { }
|
|
396
|
+
} };
|
|
397
|
+
}
|
|
398
|
+
class WorkerSyncedMessagePort {
|
|
399
|
+
$1 = {};
|
|
400
|
+
onUnhandledMessage = new SimpleHook();
|
|
401
|
+
onMessage = new SimpleHook();
|
|
402
|
+
onPostMessage = new SimpleHook();
|
|
403
|
+
onError = new SimpleHook();
|
|
404
|
+
$2;
|
|
405
|
+
name;
|
|
406
|
+
constructor(port, name) {
|
|
407
|
+
this.$2 = port;
|
|
408
|
+
this.name = name;
|
|
409
|
+
if (parentPort) {
|
|
410
|
+
parentPort.on("message", (data) => {
|
|
411
|
+
this.onMessageHandler(data);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
onMessageHandler(data) {
|
|
416
|
+
try {
|
|
417
|
+
this.onMessage.call(data);
|
|
418
|
+
let handled = false;
|
|
419
|
+
const dispatch = (key) => {
|
|
420
|
+
if (!key)
|
|
421
|
+
return;
|
|
422
|
+
const hook = this.$1[key];
|
|
423
|
+
if (hook) {
|
|
424
|
+
handled = true;
|
|
425
|
+
hook.call(data);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
dispatch(data.type);
|
|
429
|
+
if (data.cmd !== data.type)
|
|
430
|
+
dispatch(data.cmd);
|
|
431
|
+
if (!handled)
|
|
432
|
+
this.onUnhandledMessage.call(data);
|
|
433
|
+
}
|
|
434
|
+
catch (e) {
|
|
435
|
+
this.onError.call(e);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
postMessage(data, transfer) {
|
|
439
|
+
this.onPostMessage.call(data);
|
|
440
|
+
if (parentPort) {
|
|
441
|
+
if (transfer)
|
|
442
|
+
parentPort.postMessage(data, transfer);
|
|
443
|
+
else
|
|
444
|
+
parentPort.postMessage(data);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
addMessageListener(type, fn) {
|
|
448
|
+
let hook = this.$1[type];
|
|
449
|
+
if (!hook) {
|
|
450
|
+
hook = new SimpleHook();
|
|
451
|
+
this.$1[type] = hook;
|
|
452
|
+
}
|
|
453
|
+
return hook.add(fn);
|
|
454
|
+
}
|
|
455
|
+
removeMessageListener(type, fn) {
|
|
456
|
+
const hook = this.$1[type];
|
|
457
|
+
return !!hook && hook.remove(fn);
|
|
458
|
+
}
|
|
459
|
+
removeAllMessageListeners(type) {
|
|
460
|
+
const hook = this.$1[type];
|
|
461
|
+
if (hook)
|
|
462
|
+
hook.clear();
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
let WABinary = {
|
|
466
|
+
Binary: {
|
|
467
|
+
build: function (data) {
|
|
468
|
+
return {
|
|
469
|
+
readByteArrayView: function () {
|
|
470
|
+
if (data instanceof Uint8Array)
|
|
471
|
+
return data;
|
|
472
|
+
if (typeof data === "string")
|
|
473
|
+
return new TextEncoder().encode(data);
|
|
474
|
+
if (Array.isArray(data))
|
|
475
|
+
return new Uint8Array(data);
|
|
476
|
+
if (Buffer.isBuffer(data))
|
|
477
|
+
return new Uint8Array(data);
|
|
478
|
+
if (data instanceof ArrayBuffer)
|
|
479
|
+
return new Uint8Array(data);
|
|
480
|
+
if (ArrayBuffer.isView(data)) {
|
|
481
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
482
|
+
}
|
|
483
|
+
if (typeof data === "object" && data !== null && typeof data.length === "number") {
|
|
484
|
+
const arr = new Uint8Array(data.length);
|
|
485
|
+
for (let i = 0; i < data.length; i++)
|
|
486
|
+
arr[i] = data[i] || 0;
|
|
487
|
+
return arr;
|
|
488
|
+
}
|
|
489
|
+
return new Uint8Array(0);
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
};
|
|
495
|
+
let WACryptoHkdfSync = {
|
|
496
|
+
hkdf: function (key, salt, info, length) {
|
|
497
|
+
const prk = crypto
|
|
498
|
+
.createHmac("sha256", salt || Buffer.alloc(32))
|
|
499
|
+
.update(key)
|
|
500
|
+
.digest();
|
|
501
|
+
const n = Math.ceil(length / 32);
|
|
502
|
+
const okm = Buffer.alloc(n * 32);
|
|
503
|
+
let prev = Buffer.alloc(0);
|
|
504
|
+
for (let i = 0; i < n; i++) {
|
|
505
|
+
prev = crypto
|
|
506
|
+
.createHmac("sha256", prk)
|
|
507
|
+
.update(Buffer.concat([prev, info || Buffer.alloc(0), Buffer.from([i + 1])]))
|
|
508
|
+
.digest();
|
|
509
|
+
prev.copy(okm, i * 32);
|
|
510
|
+
}
|
|
511
|
+
return new Uint8Array(okm.slice(0, length));
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
class Sha256HMacBuilder {
|
|
515
|
+
hmac;
|
|
516
|
+
constructor(key) {
|
|
517
|
+
this.hmac = crypto.createHmac("sha256", key);
|
|
518
|
+
}
|
|
519
|
+
update(data) {
|
|
520
|
+
this.hmac.update(data);
|
|
521
|
+
return this;
|
|
522
|
+
}
|
|
523
|
+
finish() {
|
|
524
|
+
return new Uint8Array(this.hmac.digest());
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const WACryptoSha256HmacBuilder = { Sha256HMacBuilder };
|
|
528
|
+
const WAWebVoipPersistentFS = {
|
|
529
|
+
getVoipPersistentDirectoryPath: function () {
|
|
530
|
+
return "/tmp/voip";
|
|
531
|
+
},
|
|
532
|
+
initPersistentFS: async function (_module) {
|
|
533
|
+
return Promise.resolve();
|
|
534
|
+
},
|
|
535
|
+
};
|
|
536
|
+
let WAWebVoipJsWorkerMessageHandler = {
|
|
537
|
+
handleJsWorkerMessage: function () { },
|
|
538
|
+
};
|
|
539
|
+
const getPreferredLoaderModuleNames = () => {
|
|
540
|
+
return [
|
|
541
|
+
typedWorkerData?.loaderModuleName,
|
|
542
|
+
"WAWebVoipWebWasmLoader",
|
|
543
|
+
"WAWebVoipWebWasmLoader.worker",
|
|
544
|
+
"WAWebVoipWebWasmLoader_ProdLab_internal.worker",
|
|
545
|
+
"WAWebVoipWebWasmLoader_ProdLabvideo_internal.worker",
|
|
546
|
+
].filter((value, index, array) => !!value && array.indexOf(value) === index);
|
|
547
|
+
};
|
|
548
|
+
const resolveLoaderModule = () => {
|
|
549
|
+
for (const moduleName of getPreferredLoaderModuleNames()) {
|
|
550
|
+
try {
|
|
551
|
+
const loaderModule = global.__r(moduleName);
|
|
552
|
+
const resolved = loaderModule?.default ?? loaderModule?.exports ?? loaderModule;
|
|
553
|
+
if (typeof resolved === "function") {
|
|
554
|
+
return resolved;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
catch (e) { console.error(`[VoIP worker-bootstrap] resolveLoaderModule failed for "${moduleName}":`, e); }
|
|
558
|
+
}
|
|
559
|
+
return null;
|
|
560
|
+
};
|
|
561
|
+
const nullthrows = (value) => {
|
|
562
|
+
if (value == null)
|
|
563
|
+
throw new Error("Got unexpected null or undefined");
|
|
564
|
+
return value;
|
|
565
|
+
};
|
|
566
|
+
const asyncToGeneratorRuntime = {
|
|
567
|
+
asyncToGenerator: function (fn) {
|
|
568
|
+
return function (...args) {
|
|
569
|
+
const gen = fn.apply(this, args);
|
|
570
|
+
return new Promise((resolve, reject) => {
|
|
571
|
+
function step(key, arg) {
|
|
572
|
+
try {
|
|
573
|
+
const info = gen[key](arg);
|
|
574
|
+
const value = info.value;
|
|
575
|
+
if (info.done)
|
|
576
|
+
resolve(value);
|
|
577
|
+
else
|
|
578
|
+
Promise.resolve(value).then((val) => step("next", val), (err) => step("throw", err));
|
|
579
|
+
}
|
|
580
|
+
catch (e) {
|
|
581
|
+
reject(e);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
step("next", undefined);
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
},
|
|
588
|
+
};
|
|
589
|
+
const e = new WorkerSyncedMessagePort(global.self, "VoipWebWasmWorker");
|
|
590
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = {
|
|
591
|
+
onSignalingXmpp: function (n) {
|
|
592
|
+
e.postMessage({
|
|
593
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
594
|
+
__name: "onSignalingXmpp",
|
|
595
|
+
peerJid: n.peerJid,
|
|
596
|
+
callId: n.callId,
|
|
597
|
+
xmlPayload: n.xmlPayload,
|
|
598
|
+
});
|
|
599
|
+
},
|
|
600
|
+
onCallEvent: function (n) {
|
|
601
|
+
e.postMessage({
|
|
602
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
603
|
+
__name: "onCallEvent",
|
|
604
|
+
eventType: n.eventType,
|
|
605
|
+
userData: n.userData,
|
|
606
|
+
eventDataJson: n.eventDataJson,
|
|
607
|
+
});
|
|
608
|
+
},
|
|
609
|
+
sendDataToRelay: function (n) {
|
|
610
|
+
const t = n.data;
|
|
611
|
+
const r = n.len;
|
|
612
|
+
const o = n.ip;
|
|
613
|
+
const a = n.port;
|
|
614
|
+
e.postMessage({
|
|
615
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
616
|
+
__name: "sendDataToRelay",
|
|
617
|
+
data: t,
|
|
618
|
+
len: r,
|
|
619
|
+
ip: o,
|
|
620
|
+
port: a,
|
|
621
|
+
});
|
|
622
|
+
return r || (t ? t.length || t.byteLength || 0 : 0);
|
|
623
|
+
},
|
|
624
|
+
loggingCallback: function (n) {
|
|
625
|
+
try {
|
|
626
|
+
e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "loggingCallback" }, n));
|
|
627
|
+
}
|
|
628
|
+
catch (err) { console.error("[VoIP worker-bootstrap] loggingCallback postMessage failed:", err); }
|
|
629
|
+
},
|
|
630
|
+
initCaptureDriverJS: function (n) {
|
|
631
|
+
e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "initCaptureDriverJS" }, n));
|
|
632
|
+
return 0;
|
|
633
|
+
},
|
|
634
|
+
startCaptureJS: function () {
|
|
635
|
+
e.postMessage({
|
|
636
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
637
|
+
__name: "startCaptureJS",
|
|
638
|
+
});
|
|
639
|
+
return 0;
|
|
640
|
+
},
|
|
641
|
+
stopCaptureJS: function () {
|
|
642
|
+
e.postMessage({
|
|
643
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
644
|
+
__name: "stopCaptureJS",
|
|
645
|
+
});
|
|
646
|
+
return 0;
|
|
647
|
+
},
|
|
648
|
+
initPlaybackDriverJS: function (n) {
|
|
649
|
+
e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "initPlaybackDriverJS" }, n));
|
|
650
|
+
return 0;
|
|
651
|
+
},
|
|
652
|
+
startPlaybackJS: function () {
|
|
653
|
+
e.postMessage({
|
|
654
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
655
|
+
__name: "startPlaybackJS",
|
|
656
|
+
});
|
|
657
|
+
return 0;
|
|
658
|
+
},
|
|
659
|
+
stopPlaybackJS: function () {
|
|
660
|
+
e.postMessage({
|
|
661
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
662
|
+
__name: "stopPlaybackJS",
|
|
663
|
+
});
|
|
664
|
+
return 0;
|
|
665
|
+
},
|
|
666
|
+
startVideoCaptureJS: function (n) {
|
|
667
|
+
e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "startVideoCaptureJS" }, n));
|
|
668
|
+
return 0;
|
|
669
|
+
},
|
|
670
|
+
stopVideoCaptureJS: function () {
|
|
671
|
+
e.postMessage({
|
|
672
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
673
|
+
__name: "stopVideoCaptureJS",
|
|
674
|
+
});
|
|
675
|
+
return 0;
|
|
676
|
+
},
|
|
677
|
+
onVideoFrameWasmToJs: function (n) {
|
|
678
|
+
e.postMessage({
|
|
679
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
680
|
+
__name: "onVideoFrameWasmToJs",
|
|
681
|
+
userJid: n.userJid,
|
|
682
|
+
frameBuffer: n.frameBuffer,
|
|
683
|
+
width: n.width,
|
|
684
|
+
height: n.height,
|
|
685
|
+
orientation: n.orientation,
|
|
686
|
+
format: n.format,
|
|
687
|
+
timestamp: n.timestamp,
|
|
688
|
+
isKeyFrame: n.isKeyFrame,
|
|
689
|
+
}, [n.frameBuffer]);
|
|
690
|
+
},
|
|
691
|
+
startDesktopCaptureJS: function (n) {
|
|
692
|
+
e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "startDesktopCaptureJS" }, n));
|
|
693
|
+
return 0;
|
|
694
|
+
},
|
|
695
|
+
stopDesktopCaptureJS: function () {
|
|
696
|
+
e.postMessage({
|
|
697
|
+
type: "waWasmWorkerCompatibleCallback",
|
|
698
|
+
__name: "stopDesktopCaptureJS",
|
|
699
|
+
});
|
|
700
|
+
return 0;
|
|
701
|
+
},
|
|
702
|
+
cryptoHkdfExtractWithSaltAndExpand: function (t) {
|
|
703
|
+
const i = new Uint8Array(t.key_);
|
|
704
|
+
const l = t.salt_ ? new Uint8Array(t.salt_) : undefined;
|
|
705
|
+
const s = WABinary.Binary.build(t.info_).readByteArrayView();
|
|
706
|
+
return WACryptoHkdfSync.hkdf(i, l, s, t.length);
|
|
707
|
+
},
|
|
708
|
+
hmacSha256KeyGenerator: function (t) {
|
|
709
|
+
const r = new Uint8Array(t.data_);
|
|
710
|
+
const a = new Uint8Array(t.key_);
|
|
711
|
+
return new Sha256HMacBuilder(a).update(r).finish();
|
|
712
|
+
},
|
|
713
|
+
isParticipantKnownContact: function (_t) {
|
|
714
|
+
return false;
|
|
715
|
+
},
|
|
716
|
+
getPersistentDirectoryPath: function () {
|
|
717
|
+
return WAWebVoipPersistentFS.getVoipPersistentDirectoryPath();
|
|
718
|
+
},
|
|
719
|
+
getBrowserAudioProcessingStatus: function () {
|
|
720
|
+
return 7;
|
|
721
|
+
},
|
|
722
|
+
getBweModelPath: function () {
|
|
723
|
+
return null;
|
|
724
|
+
},
|
|
725
|
+
videoFrameConsumed: function () { },
|
|
726
|
+
dataChannelStateCallback: function () { },
|
|
727
|
+
};
|
|
728
|
+
let wasmLoader = null;
|
|
729
|
+
if (typedWorkerData && (typedWorkerData.loaderCode || typedWorkerData.workerModulesCode)) {
|
|
730
|
+
try {
|
|
731
|
+
const modulePrelude = "var __d = global.__d, __r = global.__r;\n";
|
|
732
|
+
const savedCallbacks = global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
|
|
733
|
+
if (typedWorkerData.workerModulesCode) {
|
|
734
|
+
const workerScript = new vm.Script(modulePrelude + typedWorkerData.workerModulesCode, {
|
|
735
|
+
filename: "workerModulesCode-SEM22icu2S7.js",
|
|
736
|
+
});
|
|
737
|
+
workerScript.runInThisContext();
|
|
738
|
+
}
|
|
739
|
+
if (typedWorkerData.loaderCode) {
|
|
740
|
+
const loaderScript = new vm.Script(modulePrelude + typedWorkerData.loaderCode, {
|
|
741
|
+
filename: "loaderCode-1eFv_3F3hOU.js",
|
|
742
|
+
});
|
|
743
|
+
loaderScript.runInThisContext();
|
|
744
|
+
}
|
|
745
|
+
if (!global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks?.loggingCallback) {
|
|
746
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = savedCallbacks;
|
|
747
|
+
if (global.self !== global.self) {
|
|
748
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = savedCallbacks;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (global.self !== global.self) {
|
|
752
|
+
if (global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
|
|
753
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks =
|
|
754
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
|
|
755
|
+
}
|
|
756
|
+
else if (global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
|
|
757
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks =
|
|
758
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
|
|
759
|
+
}
|
|
760
|
+
global.self = global.self;
|
|
761
|
+
}
|
|
762
|
+
wasmLoader = resolveLoaderModule();
|
|
763
|
+
try {
|
|
764
|
+
const jsWorkerModule = global.__r("WAWebVoipJsWorkerMessageHandler");
|
|
765
|
+
if (jsWorkerModule) {
|
|
766
|
+
WAWebVoipJsWorkerMessageHandler = jsWorkerModule.default ?? jsWorkerModule;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
catch (e) { console.error("[VoIP worker-bootstrap] WAWebVoipJsWorkerMessageHandler resolution failed:", e); }
|
|
770
|
+
}
|
|
771
|
+
catch (e) { console.error("[VoIP worker-bootstrap] loaderCode block failed:", e); }
|
|
772
|
+
}
|
|
773
|
+
if (!wasmLoader) {
|
|
774
|
+
const resourcesPath = typedWorkerData?.resourcesPath || path.join(__dirname, "wasm-resources");
|
|
775
|
+
const rsrcPath = path.join(resourcesPath, "loader.js");
|
|
776
|
+
if (fs.existsSync(rsrcPath)) {
|
|
777
|
+
try {
|
|
778
|
+
const loaderCode = fs.readFileSync(rsrcPath, "utf8");
|
|
779
|
+
const savedCallbacks = global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
|
|
780
|
+
const script = new vm.Script(loaderCode, { filename: rsrcPath });
|
|
781
|
+
script.runInThisContext();
|
|
782
|
+
if (!global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks?.loggingCallback) {
|
|
783
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = savedCallbacks;
|
|
784
|
+
}
|
|
785
|
+
wasmLoader = resolveLoaderModule();
|
|
786
|
+
}
|
|
787
|
+
catch (e) { console.error(`[VoIP worker-bootstrap] failed to run loader.js from "${rsrcPath}":`, e); }
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
let s = {};
|
|
791
|
+
let u = false;
|
|
792
|
+
let _ = null;
|
|
793
|
+
let jsWorkerRawVideoFramePtr = 0;
|
|
794
|
+
let jsWorkerRawVideoFrameSize = 0;
|
|
795
|
+
const c = (condition, msg) => {
|
|
796
|
+
if (!condition)
|
|
797
|
+
throw "Assertion failed: " + msg;
|
|
798
|
+
};
|
|
799
|
+
const d = (..._args) => { };
|
|
800
|
+
const m = (...args) => {
|
|
801
|
+
const text = args.join(" ");
|
|
802
|
+
global.postMessage({
|
|
803
|
+
cmd: "alert",
|
|
804
|
+
text: text,
|
|
805
|
+
threadId: s._pthread_self ? s._pthread_self() : undefined,
|
|
806
|
+
});
|
|
807
|
+
};
|
|
808
|
+
const p = d;
|
|
809
|
+
global.self.alert = m;
|
|
810
|
+
s.instantiateWasm = function (imports, successCallback) {
|
|
811
|
+
const wasmModule = nullthrows(s.wasmModule);
|
|
812
|
+
s.wasmModule = null;
|
|
813
|
+
const instance = new WebAssembly.Instance(wasmModule, imports);
|
|
814
|
+
return successCallback(instance);
|
|
815
|
+
};
|
|
816
|
+
global.self.onunhandledrejection = function (event) {
|
|
817
|
+
throw event.reason ?? event;
|
|
818
|
+
};
|
|
819
|
+
const getActiveWasmModule = () => {
|
|
820
|
+
return _ || global.self.__waModule || s;
|
|
821
|
+
};
|
|
822
|
+
const releaseJsWorkerRawVideoFrameBuffer = (moduleRef) => {
|
|
823
|
+
if (jsWorkerRawVideoFramePtr && moduleRef && typeof moduleRef._free === "function") {
|
|
824
|
+
try {
|
|
825
|
+
moduleRef._free(jsWorkerRawVideoFramePtr);
|
|
826
|
+
}
|
|
827
|
+
catch { }
|
|
828
|
+
}
|
|
829
|
+
jsWorkerRawVideoFramePtr = 0;
|
|
830
|
+
jsWorkerRawVideoFrameSize = 0;
|
|
831
|
+
};
|
|
832
|
+
const handleRawVideoFrameOnJsWorker = (msg) => {
|
|
833
|
+
const moduleRef = getActiveWasmModule();
|
|
834
|
+
const sendFrameFn = msg?.useDesktopCapture
|
|
835
|
+
? moduleRef?.onDesktopCaptureDataFromJs
|
|
836
|
+
: moduleRef?.onVideoDataFromJs;
|
|
837
|
+
const frameBuffer = msg?.frameBuffer;
|
|
838
|
+
const width = Math.max(0, Math.trunc(Number(msg?.width || 0)));
|
|
839
|
+
const height = Math.max(0, Math.trunc(Number(msg?.height || 0)));
|
|
840
|
+
const fps = Math.max(1, Math.trunc(Number(msg?.fps || 0)) || 1);
|
|
841
|
+
const orientation = Math.trunc(Number(msg?.orientation || 0));
|
|
842
|
+
const format = Math.trunc(Number(msg?.format || 0));
|
|
843
|
+
const timestamp = Math.trunc(Number(msg?.timestamp || 0));
|
|
844
|
+
if (!moduleRef ||
|
|
845
|
+
typeof moduleRef._malloc !== "function" ||
|
|
846
|
+
typeof moduleRef._free !== "function" ||
|
|
847
|
+
typeof sendFrameFn !== "function" ||
|
|
848
|
+
!(frameBuffer instanceof ArrayBuffer || ArrayBuffer.isView(frameBuffer))) {
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
const bytes = ArrayBuffer.isView(frameBuffer)
|
|
852
|
+
? new Uint8Array(frameBuffer.buffer, frameBuffer.byteOffset, frameBuffer.byteLength)
|
|
853
|
+
: new Uint8Array(frameBuffer);
|
|
854
|
+
if (bytes.byteLength === 0 || width <= 0 || height <= 0) {
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
if (!jsWorkerRawVideoFramePtr || jsWorkerRawVideoFrameSize < bytes.byteLength) {
|
|
858
|
+
releaseJsWorkerRawVideoFrameBuffer(moduleRef);
|
|
859
|
+
jsWorkerRawVideoFramePtr = Number(moduleRef._malloc(bytes.byteLength)) || 0;
|
|
860
|
+
jsWorkerRawVideoFrameSize = jsWorkerRawVideoFramePtr ? bytes.byteLength : 0;
|
|
861
|
+
}
|
|
862
|
+
if (!jsWorkerRawVideoFramePtr || jsWorkerRawVideoFrameSize < bytes.byteLength) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
moduleRef.GROWABLE_HEAP_U8().set(bytes, jsWorkerRawVideoFramePtr);
|
|
866
|
+
try {
|
|
867
|
+
sendFrameFn.call(moduleRef, jsWorkerRawVideoFramePtr, bytes.byteLength, width, height, fps, format, orientation);
|
|
868
|
+
}
|
|
869
|
+
catch (error) {
|
|
870
|
+
if (error?.name !== "BindingError") {
|
|
871
|
+
throw error;
|
|
872
|
+
}
|
|
873
|
+
try {
|
|
874
|
+
sendFrameFn.call(moduleRef, jsWorkerRawVideoFramePtr, bytes.byteLength, width, height, fps, format);
|
|
875
|
+
}
|
|
876
|
+
catch (legacyError) {
|
|
877
|
+
if (legacyError?.name !== "BindingError") {
|
|
878
|
+
throw legacyError;
|
|
879
|
+
}
|
|
880
|
+
sendFrameFn.call(moduleRef, jsWorkerRawVideoFramePtr, bytes.byteLength, width, height, orientation, format, timestamp);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
function f(t) {
|
|
885
|
+
try {
|
|
886
|
+
if (t.cmd === "load") {
|
|
887
|
+
const wasmModule = t.wasmModule;
|
|
888
|
+
const wasmMemory = t.wasmMemory;
|
|
889
|
+
const workerID = t.workerID;
|
|
890
|
+
const handlers = t.handlers;
|
|
891
|
+
const pendingMessages = [];
|
|
892
|
+
function g(msg) {
|
|
893
|
+
pendingMessages.push(msg);
|
|
894
|
+
}
|
|
895
|
+
e.removeMessageListener("cmd", f);
|
|
896
|
+
e.addMessageListener("cmd", g);
|
|
897
|
+
global.self.startWorker = function (module) {
|
|
898
|
+
global.self.__waModule = module;
|
|
899
|
+
global.__waModule = module;
|
|
900
|
+
s = module;
|
|
901
|
+
e.postMessage({ type: "cmd", cmd: "loaded" });
|
|
902
|
+
for (const msg of pendingMessages)
|
|
903
|
+
f(msg);
|
|
904
|
+
e.removeMessageListener("cmd", g);
|
|
905
|
+
e.addMessageListener("cmd", f);
|
|
906
|
+
};
|
|
907
|
+
s.wasmModule = wasmModule;
|
|
908
|
+
function h(name) {
|
|
909
|
+
s[name] = function () {
|
|
910
|
+
const args = Array.from(arguments);
|
|
911
|
+
e.postMessage({
|
|
912
|
+
type: "cmd",
|
|
913
|
+
cmd: "callHandler",
|
|
914
|
+
callHandler: { handler: name, args: args },
|
|
915
|
+
});
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
for (const handler of handlers)
|
|
919
|
+
h(handler);
|
|
920
|
+
s.wasmMemory = wasmMemory;
|
|
921
|
+
s.buffer = s.wasmMemory.buffer;
|
|
922
|
+
s.workerID = workerID;
|
|
923
|
+
s.ENVIRONMENT_IS_PTHREAD = true;
|
|
924
|
+
if (!s.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
|
|
925
|
+
s.WhatsAppVoipWasmWorkerCompatibleCallbacks =
|
|
926
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
|
|
927
|
+
}
|
|
928
|
+
if (wasmLoader) {
|
|
929
|
+
hideNodeEnv();
|
|
930
|
+
wasmLoader(s).then(asyncToGeneratorRuntime.asyncToGenerator(function* (module) {
|
|
931
|
+
if (!module.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
|
|
932
|
+
module.WhatsAppVoipWasmWorkerCompatibleCallbacks =
|
|
933
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
|
|
934
|
+
}
|
|
935
|
+
if (!s.WhatsAppVoipWasmWorkerCompatibleCallbacks?.loggingCallback) {
|
|
936
|
+
s.WhatsAppVoipWasmWorkerCompatibleCallbacks =
|
|
937
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
|
|
938
|
+
}
|
|
939
|
+
_ = module;
|
|
940
|
+
try {
|
|
941
|
+
yield WAWebVoipPersistentFS.initPersistentFS(_);
|
|
942
|
+
}
|
|
943
|
+
catch (err) { console.error("[VoIP worker-bootstrap] initPersistentFS failed:", err); }
|
|
944
|
+
}));
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
e.postMessage({ type: "cmd", cmd: "loaded" });
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
else if (t.cmd === "run") {
|
|
951
|
+
const pthread_ptr = t.pthread_ptr;
|
|
952
|
+
if (s.__emscripten_thread_init)
|
|
953
|
+
s.__emscripten_thread_init(pthread_ptr, 0, 0, 1);
|
|
954
|
+
if (s.__emscripten_thread_mailbox_await)
|
|
955
|
+
s.__emscripten_thread_mailbox_await(pthread_ptr);
|
|
956
|
+
c(!!pthread_ptr, "pthread_ptr is required in event " + t.cmd);
|
|
957
|
+
if (s.establishStackSpace)
|
|
958
|
+
s.establishStackSpace();
|
|
959
|
+
if (s.PThread)
|
|
960
|
+
s.PThread.receiveObjectTransfer(t);
|
|
961
|
+
if (s.PThread)
|
|
962
|
+
s.PThread.threadInitTLS();
|
|
963
|
+
if (!u) {
|
|
964
|
+
if (s.__embind_initialize_bindings)
|
|
965
|
+
s.__embind_initialize_bindings();
|
|
966
|
+
u = true;
|
|
967
|
+
}
|
|
968
|
+
try {
|
|
969
|
+
if (s.invokeEntryPoint)
|
|
970
|
+
s.invokeEntryPoint(t.start_routine, t.arg);
|
|
971
|
+
}
|
|
972
|
+
catch (err) {
|
|
973
|
+
if (err !== "unwind")
|
|
974
|
+
throw err;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
else if (t.cmd === "cancel") {
|
|
978
|
+
if (s._pthread_self && s._pthread_self()) {
|
|
979
|
+
if (s.__emscripten_thread_exit)
|
|
980
|
+
s.__emscripten_thread_exit(-1);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
else if (t.target !== "setimmediate") {
|
|
984
|
+
if (t.cmd === "checkMailbox") {
|
|
985
|
+
if (u && s.checkMailbox)
|
|
986
|
+
s.checkMailbox();
|
|
987
|
+
}
|
|
988
|
+
else if (t.cmd === "jsWorkerCmd") {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
else if (t.cmd) {
|
|
992
|
+
p("worker.js received unknown command " + t.cmd);
|
|
993
|
+
p(t);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
catch (err) {
|
|
998
|
+
p("worker.js onmessage() captured an uncaught exception: " + err);
|
|
999
|
+
if (err?.stack)
|
|
1000
|
+
p(err.stack);
|
|
1001
|
+
if (s.__emscripten_thread_crashed)
|
|
1002
|
+
s.__emscripten_thread_crashed();
|
|
1003
|
+
throw err;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
e.addMessageListener("cmd", f);
|
|
1007
|
+
e.addMessageListener("jsWorkerCmd", function (msg) {
|
|
1008
|
+
try {
|
|
1009
|
+
if (msg?.jsWorkerCmd === "pushRawVideoFrame") {
|
|
1010
|
+
return handleRawVideoFrameOnJsWorker(msg);
|
|
1011
|
+
}
|
|
1012
|
+
if (msg?.jsWorkerCmd === "releaseRawVideoFrameBuffer") {
|
|
1013
|
+
return releaseJsWorkerRawVideoFrameBuffer(getActiveWasmModule());
|
|
1014
|
+
}
|
|
1015
|
+
return WAWebVoipJsWorkerMessageHandler.handleJsWorkerMessage(_, msg);
|
|
1016
|
+
}
|
|
1017
|
+
catch (err) {
|
|
1018
|
+
throw err;
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
e.addMessageListener("waWasmWorkerCompatibleCallback", function (msg) {
|
|
1022
|
+
const callbackName = msg.__name;
|
|
1023
|
+
if (!callbackName)
|
|
1024
|
+
return;
|
|
1025
|
+
if (!global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks)
|
|
1026
|
+
return;
|
|
1027
|
+
if (typeof global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks[callbackName] !== "function")
|
|
1028
|
+
return;
|
|
1029
|
+
try {
|
|
1030
|
+
if (["startCaptureJS", "startPlaybackJS", "stopCaptureJS", "stopPlaybackJS"].includes(callbackName)) {
|
|
1031
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks[callbackName]();
|
|
1032
|
+
}
|
|
1033
|
+
else {
|
|
1034
|
+
const args = {};
|
|
1035
|
+
for (const key in msg) {
|
|
1036
|
+
if (key !== "type" && key !== "__name" && !key.startsWith("__"))
|
|
1037
|
+
args[key] = msg[key];
|
|
1038
|
+
}
|
|
1039
|
+
global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks[callbackName](args);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
catch (err) { console.error("[VoIP worker-bootstrap] message handler failed:", err); }
|
|
1043
|
+
});
|
|
1044
|
+
if (parentPort) {
|
|
1045
|
+
parentPort.postMessage({ type: "worker_ready" });
|
|
1046
|
+
}
|