@oxidezap/baileyrs 0.3.6 → 0.3.8
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/README.md +67 -8
- package/lib/Bridge/history-sync-wire.d.ts +2 -2
- package/lib/Bridge/history-sync-wire.js +4 -4
- package/lib/Bridge/schema.js +7 -1
- package/lib/Bridge/types.d.ts +7 -1
- package/lib/Compatibility/auth-state.d.ts +30 -0
- package/lib/Compatibility/auth-state.js +96 -0
- package/lib/Compatibility/encode-proto-core.d.ts +31 -0
- package/lib/Compatibility/encode-proto-core.js +51 -0
- package/lib/Compatibility/encode-proto.d.ts +0 -19
- package/lib/Compatibility/encode-proto.js +3 -35
- package/lib/Compatibility/host-auth-state.d.ts +6 -0
- package/lib/Compatibility/host-auth-state.js +162 -0
- package/lib/Compatibility/internal/auth-state.d.ts +3 -7
- package/lib/Compatibility/internal/auth-state.js +34 -1
- package/lib/Compatibility/internal/host-auth-state.d.ts +4 -0
- package/lib/Compatibility/internal/host-auth-state.js +14 -0
- package/lib/Compatibility/legacy-store/device.js +5 -5
- package/lib/Compatibility/message-ids.d.ts +17 -0
- package/lib/Compatibility/message-ids.js +47 -0
- package/lib/Compatibility/message-relay.d.ts +2 -2
- package/lib/Compatibility/message-relay.js +4 -4
- package/lib/Compatibility/proto-runtime.d.ts +5 -0
- package/lib/Compatibility/proto-runtime.js +214 -32
- package/lib/Compatibility/socket-results.d.ts +1 -1
- package/lib/Compatibility/tagged-message-waiter.d.ts +5 -2
- package/lib/Compatibility/tagged-message-waiter.js +5 -5
- package/lib/Compatibility/usync/adapter.d.ts +1 -1
- package/lib/Compatibility/websocket-client.d.ts +11 -3
- package/lib/Compatibility/websocket-client.js +84 -11
- package/lib/Defaults/index.d.ts +8 -8
- package/lib/Defaults/index.js +8 -8
- package/lib/Media/content.d.ts +28 -0
- package/lib/Media/content.js +129 -0
- package/lib/Media/core.d.ts +34 -0
- package/lib/Media/core.js +120 -0
- package/lib/Media/mutations.d.ts +24 -0
- package/lib/Media/mutations.js +38 -0
- package/lib/Runtime/aes-gcm.d.ts +4 -0
- package/lib/Runtime/aes-gcm.js +11 -0
- package/lib/Runtime/bridge.d.ts +44 -0
- package/lib/Runtime/bridge.js +76 -0
- package/lib/Runtime/buffer.d.ts +9 -0
- package/lib/Runtime/buffer.js +22 -0
- package/lib/Runtime/bytes.d.ts +61 -0
- package/lib/Runtime/bytes.js +270 -0
- package/lib/Runtime/host.d.ts +22 -0
- package/lib/Runtime/host.js +43 -0
- package/lib/Runtime/long.d.ts +33 -0
- package/lib/Runtime/long.js +64 -0
- package/lib/Runtime/node-media-processors.d.ts +4 -0
- package/lib/Runtime/node-media-processors.js +29 -0
- package/lib/Runtime/node-media.d.ts +28 -0
- package/lib/Runtime/node-media.js +115 -0
- package/lib/Runtime/node.d.ts +14 -0
- package/lib/Runtime/node.js +81 -0
- package/lib/Runtime/paths.d.ts +4 -0
- package/lib/Runtime/paths.js +7 -0
- package/lib/Runtime/stream.d.ts +11 -0
- package/lib/Runtime/stream.js +25 -0
- package/lib/Runtime/types.d.ts +98 -0
- package/lib/Runtime/types.js +13 -0
- package/lib/Socket/core.d.ts +312 -0
- package/lib/Socket/core.js +1122 -0
- package/lib/Socket/events-core.d.ts +75 -0
- package/lib/Socket/events-core.js +1058 -0
- package/lib/Socket/events.d.ts +1 -63
- package/lib/Socket/events.js +4 -1047
- package/lib/Socket/groups.js +4 -3
- package/lib/Socket/index.d.ts +521 -103
- package/lib/Socket/index.js +10 -1007
- package/lib/Socket/messages-core.d.ts +41 -0
- package/lib/Socket/messages-core.js +270 -0
- package/lib/Socket/messages.d.ts +9 -36
- package/lib/Socket/messages.js +3 -260
- package/lib/Socket/newsletter.js +3 -3
- package/lib/Socket/profile.js +1 -1
- package/lib/Socket/terminal-close-reporter.d.ts +2 -0
- package/lib/Socket/terminal-close-reporter.js +3 -3
- package/lib/Socket/transport.d.ts +2 -0
- package/lib/Socket/transport.js +16 -1
- package/lib/Socket/types.d.ts +2 -0
- package/lib/Types/Auth.d.ts +11 -0
- package/lib/Types/Message.d.ts +1 -1
- package/lib/Types/Socket.d.ts +2 -2
- package/lib/Types/index.d.ts +6 -1
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.js +53 -2
- package/lib/Utils/crypto.d.ts +1 -0
- package/lib/Utils/crypto.js +1 -0
- package/lib/Utils/event-buffer.d.ts +6 -1
- package/lib/Utils/event-buffer.js +28 -27
- package/lib/Utils/link-preview.d.ts +4 -3
- package/lib/Utils/logger.d.ts +3 -0
- package/lib/Utils/logger.js +35 -6
- package/lib/Utils/messages-core.d.ts +174 -0
- package/lib/Utils/messages-core.js +1042 -0
- package/lib/Utils/messages-media-core.d.ts +73 -0
- package/lib/Utils/messages-media-core.js +319 -0
- package/lib/Utils/messages-media.d.ts +1 -72
- package/lib/Utils/messages-media.js +9 -358
- package/lib/Utils/messages.d.ts +1 -166
- package/lib/Utils/messages.js +7 -1040
- package/lib/Utils/optional-peer.js +14 -5
- package/lib/Utils/process-history-message-core.d.ts +36 -0
- package/lib/Utils/process-history-message-core.js +187 -0
- package/lib/Utils/process-history-message.d.ts +5 -43
- package/lib/Utils/process-history-message.js +11 -197
- package/lib/Utils/process-message-core.d.ts +29 -0
- package/lib/Utils/process-message-core.js +112 -0
- package/lib/Utils/process-message.d.ts +4 -24
- package/lib/Utils/process-message.js +6 -111
- package/lib/WABinary/generic-utils.js +7 -5
- package/lib/host-shared.d.ts +74 -0
- package/lib/host-shared.js +15 -0
- package/lib/host-socket-operations.d.ts +3 -0
- package/lib/host-socket-operations.js +2 -0
- package/lib/host-surface.d.ts +21 -0
- package/lib/host-surface.js +35 -0
- package/lib/host-types.d.ts +356 -0
- package/lib/host-types.js +2 -0
- package/lib/host.d.ts +33 -0
- package/lib/host.js +31 -0
- package/lib/node-surface.d.ts +9 -0
- package/lib/node-surface.js +15 -0
- package/lib/surface.d.ts +5 -0
- package/lib/surface.js +6 -0
- package/lib/wasm.d.ts +27 -0
- package/lib/wasm.js +27 -0
- package/package.json +18 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical → Baileys event dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* `adaptBridgeEvent` (Bridge/schema.ts) yields a `CanonicalEvent`
|
|
5
|
+
* discriminated union; `DISPATCHERS` is a `{ [K in CanonicalEvent['type']]: … }`
|
|
6
|
+
* mapped type so TS forces a handler per variant — a missing handler
|
|
7
|
+
* is a compile error.
|
|
8
|
+
*/
|
|
9
|
+
import DefaultLong from 'long';
|
|
10
|
+
import { BinaryReader as DefaultBinaryReader, decodeMessageWireBatch as defaultDecodeMessageWireBatch, decodeReceiptWireBatch as defaultDecodeReceiptWireBatch, decodeServerAckWireBatch as defaultDecodeServerAckWireBatch } from '@oxidezap/whatsapp-rust-bridge/host';
|
|
11
|
+
import type { WhatsAppEvent, WhatsAppEventCallbacks } from '@oxidezap/whatsapp-rust-bridge/host';
|
|
12
|
+
import type { CanonicalEvent } from '../Bridge/index.js';
|
|
13
|
+
import type { SocketContext } from './types.js';
|
|
14
|
+
type EventBridgeRuntime = {
|
|
15
|
+
BinaryReader: typeof DefaultBinaryReader;
|
|
16
|
+
Long: typeof DefaultLong;
|
|
17
|
+
setTimeout: (callback: () => void, ms: number) => unknown;
|
|
18
|
+
clearTimeout: (handle: unknown) => void;
|
|
19
|
+
decodeMessageWireBatch: typeof defaultDecodeMessageWireBatch;
|
|
20
|
+
decodeReceiptWireBatch: typeof defaultDecodeReceiptWireBatch;
|
|
21
|
+
decodeServerAckWireBatch: typeof defaultDecodeServerAckWireBatch;
|
|
22
|
+
};
|
|
23
|
+
interface EventCallbacks {
|
|
24
|
+
onPairSuccess?: (data: {
|
|
25
|
+
platform?: string;
|
|
26
|
+
businessName?: string;
|
|
27
|
+
}) => void | Promise<void>;
|
|
28
|
+
onIncomingCall?: (event: Extract<CanonicalEvent, {
|
|
29
|
+
type: 'incomingCall';
|
|
30
|
+
}>) => void;
|
|
31
|
+
onDirtyState?: (event: Extract<CanonicalEvent, {
|
|
32
|
+
type: 'dirtyState';
|
|
33
|
+
}>) => void;
|
|
34
|
+
/**
|
|
35
|
+
* The engine has stopped reconnecting: this client is dead weight only
|
|
36
|
+
* `free()` can reclaim.
|
|
37
|
+
*
|
|
38
|
+
* Owns publishing the `close` too — `publish()` must be called, and the
|
|
39
|
+
* point of handing it over is that the socket can finish tearing down
|
|
40
|
+
* first. Upstream does the same, emitting its close only after `ws.close()`
|
|
41
|
+
* and the end handlers (`Socket/socket.ts`). A consumer answering `close`
|
|
42
|
+
* with a replacement socket on the same auth folder would otherwise race
|
|
43
|
+
* the old one's store flush and `free()`.
|
|
44
|
+
*/
|
|
45
|
+
onTerminalClose?: (error: Error, publish: () => void) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Hand back a cleanup for anything the dispatcher armed that outlives a
|
|
48
|
+
* single event — today the history-sync pause timer. The socket registers
|
|
49
|
+
* it as an end handler, so a plain `sock.end()` or an `await using` scope
|
|
50
|
+
* exiting cancels it too: only the terminal-close path goes through
|
|
51
|
+
* `emitClose`, and a timer surviving disposal fires
|
|
52
|
+
* `messaging-history.status: paused` from a socket that is already gone.
|
|
53
|
+
*
|
|
54
|
+
* Called once, during `makeEventHandlers`.
|
|
55
|
+
*/
|
|
56
|
+
onCleanup?: (cleanup: () => void) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Whether `sock.setAutoReconnect(true)` is in effect. A plain drop is only
|
|
59
|
+
* transient while the engine still intends to retry: with auto-reconnect
|
|
60
|
+
* off, the run loop dispatches `Disconnected` and then breaks for good
|
|
61
|
+
* (`client/lifecycle.rs` tests the flag *after* the dispatch), so the same
|
|
62
|
+
* event becomes terminal. Absent callback means the default, enabled.
|
|
63
|
+
*/
|
|
64
|
+
isAutoReconnectEnabled?: () => boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create typed single and batch handlers for the bridge. The bridge only uses
|
|
68
|
+
* the batch capability when adjacent messages are already queued, while this
|
|
69
|
+
* layer owns all Baileys-specific translation and EventEmitter aggregation.
|
|
70
|
+
*/
|
|
71
|
+
export declare const makeEventHandlers: (ctx: SocketContext, callbacks?: EventCallbacks, runtime?: EventBridgeRuntime) => WhatsAppEventCallbacks;
|
|
72
|
+
/** Legacy single-event helper retained for direct consumers and tests. */
|
|
73
|
+
export declare const makeEventHandler: (ctx: SocketContext, callbacks?: EventCallbacks) => (event: WhatsAppEvent) => void;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=events-core.d.ts.map
|