ell-bail 1.2.0 → 2.0.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/README.md +341 -93
- package/engine-requirements.js +1 -2
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +19 -2
- package/lib/Socket/chats.d.ts +215 -28
- package/lib/Socket/chats.js +155 -49
- package/lib/Socket/{luxu.d.ts → dugong.d.ts} +44 -41
- package/lib/Socket/dugong.js +484 -0
- package/lib/Socket/groups.js +1 -0
- package/lib/Socket/index.js +1 -0
- package/lib/Socket/messages-recv.js +5 -47
- package/lib/Socket/messages-send.d.ts +1 -1
- package/lib/Socket/messages-send.js +227 -320
- package/lib/Socket/newsletter.d.ts +130 -232
- package/lib/Socket/newsletter.js +101 -22
- package/lib/Socket/registration.d.ts +0 -1
- package/lib/Socket/registration.js +4 -627
- package/lib/Socket/socket.d.ts +1 -1
- package/lib/Socket/socket.js +66 -31
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Utils/auth-utils.js +0 -5
- package/lib/Utils/crypto.js +1 -18
- package/lib/Utils/generics.d.ts +0 -1
- package/lib/Utils/generics.js +64 -38
- package/lib/Utils/messages-media.js +145 -57
- package/lib/Utils/messages.js +54 -13
- package/lib/Utils/use-multi-file-auth-state.js +45 -6
- package/lib/Utils/validate-connection.js +89 -65
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/encode.js +160 -123
- package/lib/WABinary/generic-utils.d.ts +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -2
- package/package.json +15 -7
- package/WAProto/index.js +0 -130309
- package/lib/KeyDB/BinarySearch.js +0 -18
- package/lib/KeyDB/KeyedDB.js +0 -164
- package/lib/KeyDB/index.js +0 -2
- package/lib/Signal/Group/x +0 -1
- package/lib/Socket/luxu.js +0 -550
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default function binarySearch(array, predicate) {
|
|
2
|
-
let low = 0;
|
|
3
|
-
let high = array.length;
|
|
4
|
-
if (array.length === 0) return low;
|
|
5
|
-
if (predicate(array[low]) < 0) return low - 1;
|
|
6
|
-
else if (predicate(array[low]) === 0) return low;
|
|
7
|
-
const maxPred = predicate(array[high - 1]);
|
|
8
|
-
if (maxPred > 0) return high;
|
|
9
|
-
else if (maxPred === 0) return high - 1;
|
|
10
|
-
while (low !== high) {
|
|
11
|
-
const mid = low + Math.floor((high - low) / 2);
|
|
12
|
-
const pred = predicate(array[mid]);
|
|
13
|
-
if (pred < 0) high = mid;
|
|
14
|
-
else if (pred > 0) low = mid + 1;
|
|
15
|
-
else return mid;
|
|
16
|
-
}
|
|
17
|
-
return low;
|
|
18
|
-
}
|
package/lib/KeyDB/KeyedDB.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import binarySearch from './BinarySearch.js';
|
|
2
|
-
export default class KeyedDB {
|
|
3
|
-
constructor(key, id) {
|
|
4
|
-
this.key = key;
|
|
5
|
-
this.idGetter = id || (v => this.key.key(v).toString());
|
|
6
|
-
this.dict = {};
|
|
7
|
-
this.array = [];
|
|
8
|
-
}
|
|
9
|
-
get length() {
|
|
10
|
-
return this.array.length;
|
|
11
|
-
}
|
|
12
|
-
get first() {
|
|
13
|
-
return this.array[0];
|
|
14
|
-
}
|
|
15
|
-
get last() {
|
|
16
|
-
return this.array[this.array.length - 1];
|
|
17
|
-
}
|
|
18
|
-
toJSON() {
|
|
19
|
-
return this.array;
|
|
20
|
-
}
|
|
21
|
-
insert(...values) {
|
|
22
|
-
values.forEach(v => this._insertSingle(v));
|
|
23
|
-
}
|
|
24
|
-
upsert(...values) {
|
|
25
|
-
const updates = [];
|
|
26
|
-
values.forEach(v => {
|
|
27
|
-
if (!v) return;
|
|
28
|
-
const deleted = this.deleteById(this.idGetter(v), false);
|
|
29
|
-
this._insertSingle(v);
|
|
30
|
-
deleted && updates.push(v);
|
|
31
|
-
});
|
|
32
|
-
return updates;
|
|
33
|
-
}
|
|
34
|
-
insertIfAbsent(...values) {
|
|
35
|
-
const insertions = [];
|
|
36
|
-
values.forEach(v => {
|
|
37
|
-
if (!v) return;
|
|
38
|
-
const presentValue = this.get(this.idGetter(v));
|
|
39
|
-
if (presentValue) return;
|
|
40
|
-
const presentKey = this.firstIndex(v);
|
|
41
|
-
if (this.array[presentKey] && this.key.key(this.array[presentKey]) === this.key.key(v)) return;
|
|
42
|
-
this.insert(v);
|
|
43
|
-
insertions.push(v);
|
|
44
|
-
});
|
|
45
|
-
return insertions;
|
|
46
|
-
}
|
|
47
|
-
deleteById(id, assertPresent = true) {
|
|
48
|
-
const value = this.get(id);
|
|
49
|
-
if (!value) {
|
|
50
|
-
if (assertPresent) throw new Error(`Value not found`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
return this.delete(value);
|
|
54
|
-
}
|
|
55
|
-
delete(value) {
|
|
56
|
-
const index = this.firstIndex(value);
|
|
57
|
-
if (index < 0 || index >= this.array.length || this.key.key(value) !== this.key.key(this.array[index])) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
delete this.dict[this.idGetter(value)];
|
|
61
|
-
return this.array.splice(index, 1)[0];
|
|
62
|
-
}
|
|
63
|
-
slice(start, end) {
|
|
64
|
-
const db = new KeyedDB(this.key, this.idGetter);
|
|
65
|
-
db.array = this.array.slice(start, end);
|
|
66
|
-
db.array.forEach(item => db.dict[this.idGetter(item)] = item);
|
|
67
|
-
return db;
|
|
68
|
-
}
|
|
69
|
-
clear() {
|
|
70
|
-
this.array = [];
|
|
71
|
-
this.dict = {};
|
|
72
|
-
}
|
|
73
|
-
get(id) {
|
|
74
|
-
return this.dict[id];
|
|
75
|
-
}
|
|
76
|
-
all() {
|
|
77
|
-
return this.array;
|
|
78
|
-
}
|
|
79
|
-
update(id, update) {
|
|
80
|
-
const value = this.get(id);
|
|
81
|
-
if (value) {
|
|
82
|
-
const idx = this.firstIndex(value);
|
|
83
|
-
if (idx >= 0 && idx < this.array.length && this.idGetter(this.array[idx]) === id) {
|
|
84
|
-
const oldKey = this.key.key(value);
|
|
85
|
-
update(value);
|
|
86
|
-
const newKey = this.key.key(value);
|
|
87
|
-
if (newKey !== oldKey) {
|
|
88
|
-
delete this.dict[id];
|
|
89
|
-
this.array.splice(idx, 1);
|
|
90
|
-
this._insertSingle(value);
|
|
91
|
-
return 2;
|
|
92
|
-
}
|
|
93
|
-
return 1;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
updateKey(value, update) {
|
|
98
|
-
return this.update(this.idGetter(value), update);
|
|
99
|
-
}
|
|
100
|
-
filter(predicate) {
|
|
101
|
-
const db = new KeyedDB(this.key, this.idGetter);
|
|
102
|
-
db.array = this.array.filter((value, index) => {
|
|
103
|
-
if (predicate(value, index)) {
|
|
104
|
-
db.dict[this.idGetter(value)] = value;
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return db;
|
|
109
|
-
}
|
|
110
|
-
paginatedByValue(value, limit, predicate, mode = 'after') {
|
|
111
|
-
return this.paginated(value && this.key.key(value), limit, predicate, mode);
|
|
112
|
-
}
|
|
113
|
-
paginated(cursor, limit, predicate, mode = 'after') {
|
|
114
|
-
let index = mode === 'after' ? 0 : this.array.length;
|
|
115
|
-
if (cursor !== null && typeof cursor !== 'undefined') {
|
|
116
|
-
index = binarySearch(this.array, v => this.key.compare(cursor, this.key.key(v)));
|
|
117
|
-
if (index < 0) index = 0;
|
|
118
|
-
if (this.key.key(this.array[index]) === cursor) index += (mode === 'after' ? 1 : 0);
|
|
119
|
-
}
|
|
120
|
-
return this.filtered(index, limit, mode, predicate);
|
|
121
|
-
}
|
|
122
|
-
_insertSingle(value) {
|
|
123
|
-
if (!value) throw new Error('falsey value');
|
|
124
|
-
const valueID = this.idGetter(value);
|
|
125
|
-
if (this.get(valueID)) throw new Error('duplicate ID being inserted: ' + valueID);
|
|
126
|
-
|
|
127
|
-
if (this.array.length > 0) {
|
|
128
|
-
const index = this.firstIndex(value);
|
|
129
|
-
if (index >= this.array.length) this.array.push(value);
|
|
130
|
-
else if (index < 0) this.array.unshift(value);
|
|
131
|
-
else if (this.key.key(value) !== this.key.key(this.array[index])) this.array.splice(index, 0, value);
|
|
132
|
-
else throw new Error(`duplicate key: ${this.key.key(value)}, inserting: ${valueID}, present: ${this.idGetter(this.array[index])}`);
|
|
133
|
-
} else {
|
|
134
|
-
this.array.push(value);
|
|
135
|
-
}
|
|
136
|
-
this.dict[valueID] = value;
|
|
137
|
-
}
|
|
138
|
-
filtered(start, count, mode, predicate) {
|
|
139
|
-
let arr;
|
|
140
|
-
if (mode === 'after') {
|
|
141
|
-
if (predicate) {
|
|
142
|
-
arr = [];
|
|
143
|
-
for (let item of this.array.slice(start)) {
|
|
144
|
-
predicate(item, start + arr.length) && arr.push(item);
|
|
145
|
-
if (arr.length >= count) break;
|
|
146
|
-
}
|
|
147
|
-
} else arr = this.array.slice(start, start + count);
|
|
148
|
-
} else if (mode === 'before') {
|
|
149
|
-
if (predicate) {
|
|
150
|
-
arr = [];
|
|
151
|
-
for (let i = start - 1; i >= 0; i--) {
|
|
152
|
-
let item = this.array[i];
|
|
153
|
-
predicate(item, start + arr.length) && arr.unshift(item);
|
|
154
|
-
if (arr.length >= count) break;
|
|
155
|
-
}
|
|
156
|
-
} else arr = this.array.slice(Math.max(start - count, 0), start);
|
|
157
|
-
}
|
|
158
|
-
return arr;
|
|
159
|
-
}
|
|
160
|
-
firstIndex(value) {
|
|
161
|
-
const valueKey = this.key.key(value);
|
|
162
|
-
return binarySearch(this.array, v => this.key.compare(valueKey, this.key.key(v)));
|
|
163
|
-
}
|
|
164
|
-
}
|
package/lib/KeyDB/index.js
DELETED
package/lib/Signal/Group/x
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|