@openclaw/whatsapp 2026.7.2-beta.2 → 2026.7.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-control-DazDX3RB.js → access-control-CRz_v6bR.js} +4 -5
- package/dist/{accounts-CKOFMPf-.js → accounts-CxPuEFi-.js} +44 -4
- package/dist/{action-runtime-Bf-12TIH.js → action-runtime-CHU7xb6o.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{active-listener-5kHap439.js → active-listener-BEjWsCNM.js} +1 -1
- package/dist/api.js +12 -15
- package/dist/{approval-handler.runtime-CBiGQuZ5.js → approval-handler.runtime-C4ddB7Kc.js} +4 -4
- package/dist/{approval-reactions-BGQoz25s.js → approval-reactions-P2HXjmln.js} +3 -3
- package/dist/{auth-store-BQi9pZqQ.js → auth-store-DirYMTbo.js} +4 -3
- package/dist/call-tool-api.js +4 -4
- package/dist/{channel-DbadDUDD.js → channel-B9xjrOGG.js} +37 -19
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-PoRWfP9x.js → channel-react-action-CBW-PA8q.js} +10 -13
- package/dist/{channel.runtime-BDDy4Lhz.js → channel.runtime-DdKuhlNu.js} +5 -5
- package/dist/{channel.setup-BZ-po8fg.js → channel.setup-DXUCPHel.js} +3 -6
- package/dist/{config-schema-BZ8h1hWA.js → config-schema-C6IeKIC0.js} +6 -0
- package/dist/{connection-controller-C1rwfWb4.js → connection-controller-BVRExqrB.js} +186 -27
- package/dist/connection-controller-runtime-context-DG0tuYuw.js +23 -0
- package/dist/contract-api.js +1 -1
- package/dist/directory-config-BTbJkV1W.js +196 -0
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-CwzVXKoE.js +10 -0
- package/dist/doctor-contract-api.js +35 -79
- package/dist/{group-session-key-CLTZeH_F.js → group-session-key-DJSdYfnb.js} +9 -4
- package/dist/{identity-D7L8LCuH.js → identity-BM4_wZeM.js} +2 -2
- package/dist/light-runtime-api.js +2 -2
- package/dist/{login-DGIoToX8.js → login-BKUm7KSk.js} +6 -7
- package/dist/{login-qr-X-CZHOk9.js → login-qr-DagJvMbg.js} +7 -8
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-BZ8QvCeV.js → monitor-CBVNJ2lb.js} +623 -400
- package/dist/question-reactions-CaOrSYzU.js +142 -0
- package/dist/runtime-BLlToOi6.js +21 -0
- package/dist/runtime-api.js +10 -10
- package/dist/runtime-setter-api.js +1 -1
- package/dist/{send-D9Ydnn4o.js → send-DhJVN30g.js} +38 -85
- package/dist/{send-api-W33lI2nR.js → send-api-CpHwbor_.js} +38 -32
- package/dist/{setup-finalize-DBf1jjBj.js → setup-finalize-9XzKdFq6.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CiKGdNJv.js → setup-surface-Kv3mPki2.js} +3 -3
- package/dist/{setup-core-3aSOoK2T.js → shared-CuqHFnKd.js} +78 -56
- package/dist/{session-mxWFn0eS.js → socket-close-BoSHhQNJ.js} +226 -7
- package/dist/{targets-runtime-Bsh0HR9y.js → targets-runtime-CKFrhoX4.js} +142 -29
- package/dist/text-runtime-CU_IlbK5.js +4 -0
- package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/utf8/index.js +29 -18
- package/node_modules/@protobufjs/utf8/package.json +2 -2
- package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
- package/node_modules/@thi.ng/bitstream/package.json +4 -4
- package/node_modules/@thi.ng/errors/package.json +4 -4
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/fs/promises.d.ts +16 -6
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/audio-type/package.json +3 -2
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.js +11 -4
- package/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.js +11 -4
- package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.js +11 -4
- package/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.js +11 -4
- package/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.js +11 -4
- package/node_modules/lru-cache/dist/esm/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.min.js +1 -1
- package/node_modules/lru-cache/dist/esm/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.js +11 -4
- package/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.min.js.map +3 -3
- package/node_modules/lru-cache/package.json +1 -1
- package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/Util.js +7 -1
- package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +23 -3
- package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
- package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +38 -13
- package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
- package/node_modules/music-metadata/package.json +6 -6
- package/node_modules/p-queue/dist/index.js +17 -6
- package/node_modules/p-queue/package.json +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.js +145 -188
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +33 -76
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.js +168 -208
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/index.d.ts +0 -8
- package/node_modules/protobufjs/package.json +2 -3
- package/node_modules/protobufjs/src/parse.js +3 -0
- package/node_modules/protobufjs/src/util/minimal.js +0 -3
- package/node_modules/typebox/build/compile/validator.d.mts +1 -4
- package/node_modules/typebox/build/guard/guard.d.mts +1 -1
- package/node_modules/typebox/build/guard/guard.mjs +5 -2
- package/node_modules/typebox/build/guard/string.mjs +16 -4
- package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +5 -0
- package/node_modules/typebox/build/type/action/readonly_object.mjs +8 -0
- package/node_modules/typebox/build/typebox.d.mts +1 -1
- package/node_modules/typebox/build/typebox.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +29 -32
- package/node_modules/ws/lib/receiver.js +15 -32
- package/node_modules/ws/lib/websocket-server.js +4 -4
- package/node_modules/ws/lib/websocket.js +4 -4
- package/node_modules/ws/package.json +5 -1
- package/npm-shrinkwrap.json +41 -45
- package/openclaw.plugin.json +139 -179
- package/package.json +21 -11
- package/dist/account-config-LiT9wWH9.js +0 -43
- package/dist/connection-controller-runtime-context-CbTsqmPT.js +0 -14
- package/dist/directory-config-CLBQrjtC.js +0 -37
- package/dist/doctor-By3SB4lm.js +0 -48
- package/dist/runtime-BfAdAEYT.js +0 -8
- package/dist/text-runtime-BTGkMN0o.js +0 -4
- package/node_modules/@protobufjs/inquire/CHANGELOG.md +0 -8
- package/node_modules/@protobufjs/inquire/LICENSE +0 -26
- package/node_modules/@protobufjs/inquire/README.md +0 -13
- package/node_modules/@protobufjs/inquire/index.d.ts +0 -10
- package/node_modules/@protobufjs/inquire/index.js +0 -38
- package/node_modules/@protobufjs/inquire/package.json +0 -21
- package/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/index.js +0 -20
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IRatio } from '../type.js';
|
|
2
|
-
export type StringEncoding = 'ascii' | 'utf8' | 'utf-16le' | 'ucs2' | 'base64url' | 'latin1' | 'hex';
|
|
2
|
+
export type StringEncoding = 'ascii' | 'utf8' | 'utf-16le' | 'utf-16be' | 'ucs2' | 'base64url' | 'latin1' | 'hex';
|
|
3
3
|
export declare function getBit(buf: Uint8Array, off: number, bit: number): boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Find delimiting zero in uint8Array
|
|
@@ -12,7 +12,7 @@ export function getBit(buf, off, bit) {
|
|
|
12
12
|
*/
|
|
13
13
|
export function findZero(uint8Array, encoding) {
|
|
14
14
|
const len = uint8Array.length;
|
|
15
|
-
if (encoding === 'utf-16le') {
|
|
15
|
+
if (encoding === 'utf-16le' || encoding === 'utf-16be') {
|
|
16
16
|
// Look for 0x00 0x00 on 2-byte boundary
|
|
17
17
|
for (let i = 0; i + 1 < len; i += 2) {
|
|
18
18
|
if (uint8Array[i] === 0 && uint8Array[i + 1] === 0)
|
|
@@ -57,6 +57,12 @@ export function decodeString(uint8Array, encoding) {
|
|
|
57
57
|
throw new FieldDecodingError('Expected even number of octets for 16-bit unicode string');
|
|
58
58
|
return decodeString(swapBytes(uint8Array), encoding);
|
|
59
59
|
}
|
|
60
|
+
if (encoding === 'utf-16be') {
|
|
61
|
+
// There is no native UTF-16BE decoder; swap to UTF-16LE and decode that.
|
|
62
|
+
if ((uint8Array.length & 1) !== 0)
|
|
63
|
+
throw new FieldDecodingError('Expected even number of octets for 16-bit unicode string');
|
|
64
|
+
return new StringType(uint8Array.length, 'utf-16le').get(swapBytes(Uint8Array.from(uint8Array)), 0);
|
|
65
|
+
}
|
|
60
66
|
return new StringType(uint8Array.length, encoding).get(uint8Array, 0);
|
|
61
67
|
}
|
|
62
68
|
export function stripNulls(str) {
|
|
@@ -15,7 +15,27 @@ export function getFrameHeaderLength(majorVer) {
|
|
|
15
15
|
default: throw makeUnexpectedMajorVersionError(majorVer);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
function readFrameFlags(b) {
|
|
18
|
+
function readFrameFlags(b, majorVer) {
|
|
19
|
+
// ID3v2.3 and ID3v2.4 use different bit layouts for the frame status and format flags.
|
|
20
|
+
if (majorVer === 3) {
|
|
21
|
+
// ID3v2.3: status `%abc00000`, format `%ijk00000` (https://id3.org/id3v2.3.0)
|
|
22
|
+
return {
|
|
23
|
+
status: {
|
|
24
|
+
tag_alter_preservation: util.getBit(b, 0, 7),
|
|
25
|
+
file_alter_preservation: util.getBit(b, 0, 6),
|
|
26
|
+
read_only: util.getBit(b, 0, 5)
|
|
27
|
+
},
|
|
28
|
+
format: {
|
|
29
|
+
compression: util.getBit(b, 1, 7),
|
|
30
|
+
encryption: util.getBit(b, 1, 6),
|
|
31
|
+
grouping_identity: util.getBit(b, 1, 5),
|
|
32
|
+
// Unsynchronisation and data-length-indicator do not exist as per-frame flags in ID3v2.3.
|
|
33
|
+
unsynchronisation: false,
|
|
34
|
+
data_length_indicator: false
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// ID3v2.4: status `%0abc0000`, format `%0h00kmnp` (https://id3.org/id3v2.4.0-structure)
|
|
19
39
|
return {
|
|
20
40
|
status: {
|
|
21
41
|
tag_alter_preservation: util.getBit(b, 0, 6),
|
|
@@ -23,7 +43,7 @@ function readFrameFlags(b) {
|
|
|
23
43
|
read_only: util.getBit(b, 0, 4)
|
|
24
44
|
},
|
|
25
45
|
format: {
|
|
26
|
-
grouping_identity: util.getBit(b, 1,
|
|
46
|
+
grouping_identity: util.getBit(b, 1, 6),
|
|
27
47
|
compression: util.getBit(b, 1, 3),
|
|
28
48
|
encryption: util.getBit(b, 1, 2),
|
|
29
49
|
unsynchronisation: util.getBit(b, 1, 1),
|
|
@@ -61,7 +81,7 @@ function parseFrameHeaderV23V24(uint8Array, majorVer, warningCollector) {
|
|
|
61
81
|
const header = {
|
|
62
82
|
id: textDecode(uint8Array.subarray(0, 4), 'ascii'),
|
|
63
83
|
length: (majorVer === 4 ? UINT32SYNCSAFE : Token.UINT32_BE).get(uint8Array, 4),
|
|
64
|
-
flags: readFrameFlags(uint8Array.subarray(8, 10))
|
|
84
|
+
flags: readFrameFlags(uint8Array.subarray(8, 10), majorVer)
|
|
65
85
|
};
|
|
66
86
|
if (!header.id.match(/^[A-Z0-9]{4}$/)) {
|
|
67
87
|
warningCollector.addWarning(`Invalid ID3v2.${majorVer} frame-header-ID: ${header.id}`);
|
|
@@ -390,11 +390,11 @@ export class FrameParser {
|
|
|
390
390
|
if (zeroIndex >= valueArray.length) {
|
|
391
391
|
// No terminator found, decode full buffer remainder
|
|
392
392
|
return {
|
|
393
|
-
text: util.decodeString(
|
|
393
|
+
text: util.decodeString(uint8Array, encoding.encoding),
|
|
394
394
|
len: originalLen
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
|
-
const txt =
|
|
397
|
+
const txt = uint8Array.subarray(0, bomSize + zeroIndex);
|
|
398
398
|
return {
|
|
399
399
|
text: util.decodeString(txt, encoding.encoding),
|
|
400
400
|
len: bomSize + zeroIndex + FrameParser.getNullTerminatorLength(encoding.encoding)
|
|
@@ -109,7 +109,7 @@ export const TextEncodingToken = {
|
|
|
109
109
|
case 0x01:
|
|
110
110
|
return { encoding: 'utf-16le', bom: true };
|
|
111
111
|
case 0x02:
|
|
112
|
-
return { encoding: 'utf-
|
|
112
|
+
return { encoding: 'utf-16be', bom: false };
|
|
113
113
|
case 0x03:
|
|
114
114
|
return { encoding: 'utf8', bom: false };
|
|
115
115
|
default:
|
|
@@ -226,19 +226,44 @@ export class TrackHeaderAtom {
|
|
|
226
226
|
this.len = len;
|
|
227
227
|
}
|
|
228
228
|
get(buf, off) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
229
|
+
const version = Token.UINT8.get(buf, off);
|
|
230
|
+
const flags = Token.UINT24_BE.get(buf, off + 1);
|
|
231
|
+
switch (version) {
|
|
232
|
+
case 0:
|
|
233
|
+
// Version 0: 32-bit fields
|
|
234
|
+
return {
|
|
235
|
+
version,
|
|
236
|
+
flags,
|
|
237
|
+
creationTime: SecondsSinceMacEpoch.get(buf, off + 4),
|
|
238
|
+
modificationTime: SecondsSinceMacEpoch.get(buf, off + 8),
|
|
239
|
+
trackId: Token.UINT32_BE.get(buf, off + 12),
|
|
240
|
+
// reserved 4 bytes
|
|
241
|
+
duration: Token.UINT32_BE.get(buf, off + 20),
|
|
242
|
+
// reserved 8 bytes
|
|
243
|
+
layer: Token.UINT16_BE.get(buf, off + 32),
|
|
244
|
+
alternateGroup: Token.UINT16_BE.get(buf, off + 34),
|
|
245
|
+
volume: Token.UINT16_BE.get(buf, off + 36) // ToDo: fixed point
|
|
246
|
+
// ToDo: add remaining fields
|
|
247
|
+
};
|
|
248
|
+
case 1:
|
|
249
|
+
// Version 1: 64-bit creation/modification times and duration
|
|
250
|
+
return {
|
|
251
|
+
version,
|
|
252
|
+
flags,
|
|
253
|
+
creationTime: SecondsSinceMacEpoch64.get(buf, off + 4),
|
|
254
|
+
modificationTime: SecondsSinceMacEpoch64.get(buf, off + 12),
|
|
255
|
+
trackId: Token.UINT32_BE.get(buf, off + 20),
|
|
256
|
+
// reserved 4 bytes
|
|
257
|
+
duration: Number(Token.UINT64_BE.get(buf, off + 28)),
|
|
258
|
+
// reserved 8 bytes
|
|
259
|
+
layer: Token.UINT16_BE.get(buf, off + 44),
|
|
260
|
+
alternateGroup: Token.UINT16_BE.get(buf, off + 46),
|
|
261
|
+
volume: Token.UINT16_BE.get(buf, off + 48) // ToDo: fixed point
|
|
262
|
+
// ToDo: add remaining fields
|
|
263
|
+
};
|
|
264
|
+
default:
|
|
265
|
+
throw new FieldDecodingError('Invalid tkhd version header');
|
|
266
|
+
}
|
|
242
267
|
}
|
|
243
268
|
}
|
|
244
269
|
/**
|
|
@@ -31,7 +31,7 @@ const MPEG4 = {
|
|
|
31
31
|
* https://wiki.multimedia.cx/index.php/MPEG-4_Audio#Sampling_Frequencies
|
|
32
32
|
*/
|
|
33
33
|
SamplingFrequencies: [
|
|
34
|
-
96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, null, null,
|
|
34
|
+
96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, null, null, null
|
|
35
35
|
]
|
|
36
36
|
/**
|
|
37
37
|
* Channel Configurations
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "music-metadata",
|
|
3
3
|
"description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.14.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
7
7
|
"url": "https://github.com/Borewit"
|
|
@@ -124,20 +124,20 @@
|
|
|
124
124
|
"win-guid": "^0.2.1"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
|
-
"@biomejs/biome": "2.
|
|
127
|
+
"@biomejs/biome": "2.5.3",
|
|
128
128
|
"@types/chai": "^5.2.3",
|
|
129
129
|
"@types/chai-as-promised": "^8.0.2",
|
|
130
|
-
"@types/content-type": "^
|
|
131
|
-
"@types/debug": "^4.1.
|
|
130
|
+
"@types/content-type": "^2.0.0",
|
|
131
|
+
"@types/debug": "^4.1.13",
|
|
132
132
|
"@types/media-typer": "^1.1.3",
|
|
133
133
|
"@types/mocha": "^10.0.10",
|
|
134
|
-
"@types/node": "^
|
|
134
|
+
"@types/node": "^26.1.1",
|
|
135
135
|
"c8": "^11.0.0",
|
|
136
136
|
"chai": "^6.2.2",
|
|
137
137
|
"chai-as-promised": "^8.0.2",
|
|
138
138
|
"del-cli": "^7.0.0",
|
|
139
139
|
"mime": "^4.1.0",
|
|
140
|
-
"mocha": "^11.7.
|
|
140
|
+
"mocha": "^11.7.6",
|
|
141
141
|
"node-readable-to-web-readable-stream": "^0.4.2",
|
|
142
142
|
"remark-cli": "^12.0.1",
|
|
143
143
|
"remark-preset-lint-consistent": "^6.0.1",
|
|
@@ -350,6 +350,9 @@ export default class PQueue extends EventEmitter {
|
|
|
350
350
|
// Assign unique ID if not provided
|
|
351
351
|
id: options.id ?? (this.#idAssigner++).toString(),
|
|
352
352
|
};
|
|
353
|
+
if (options.timeout !== undefined && !(Number.isFinite(options.timeout) && options.timeout > 0)) {
|
|
354
|
+
throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${options.timeout}\` (${typeof options.timeout})`);
|
|
355
|
+
}
|
|
353
356
|
return new Promise((resolve, reject) => {
|
|
354
357
|
// Create a unique symbol for tracking this task
|
|
355
358
|
const taskSymbol = Symbol(`task-${options.id}`);
|
|
@@ -380,7 +383,7 @@ export default class PQueue extends EventEmitter {
|
|
|
380
383
|
}
|
|
381
384
|
this.#lastExecutionTime = Date.now();
|
|
382
385
|
let operation = function_({ signal: options.signal });
|
|
383
|
-
if (options.timeout) {
|
|
386
|
+
if (options.timeout !== undefined) {
|
|
384
387
|
operation = pTimeout(Promise.resolve(operation), {
|
|
385
388
|
milliseconds: options.timeout,
|
|
386
389
|
message: `Task timed out after ${options.timeout}ms (queue has ${this.#pending} running, ${this.#queue.size} waiting)`,
|
|
@@ -514,11 +517,14 @@ export default class PQueue extends EventEmitter {
|
|
|
514
517
|
Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
|
|
515
518
|
*/
|
|
516
519
|
async onSizeLessThan(limit) {
|
|
517
|
-
// Instantly resolve if the
|
|
520
|
+
// Instantly resolve if the size is already below the limit.
|
|
518
521
|
if (this.#queue.size < limit) {
|
|
519
522
|
return;
|
|
520
523
|
}
|
|
521
|
-
|
|
524
|
+
// Listen on both `'next'` (task completion, queued abort, `clear()`) and `'active'` (every dequeue),
|
|
525
|
+
// so waiters wake even when the queue drains without a completion (`start()`, a runtime `concurrency`
|
|
526
|
+
// increase, or an interval tick).
|
|
527
|
+
await this.#onEvent(['next', 'active'], () => this.#queue.size < limit);
|
|
522
528
|
}
|
|
523
529
|
/**
|
|
524
530
|
The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
|
|
@@ -600,16 +606,21 @@ export default class PQueue extends EventEmitter {
|
|
|
600
606
|
this.on('error', handleError);
|
|
601
607
|
});
|
|
602
608
|
}
|
|
603
|
-
async #onEvent(
|
|
609
|
+
async #onEvent(events, filter) {
|
|
610
|
+
const eventList = Array.isArray(events) ? events : [events];
|
|
604
611
|
return new Promise(resolve => {
|
|
605
612
|
const listener = () => {
|
|
606
613
|
if (filter && !filter()) {
|
|
607
614
|
return;
|
|
608
615
|
}
|
|
609
|
-
|
|
616
|
+
for (const event of eventList) {
|
|
617
|
+
this.off(event, listener);
|
|
618
|
+
}
|
|
610
619
|
resolve();
|
|
611
620
|
};
|
|
612
|
-
|
|
621
|
+
for (const event of eventList) {
|
|
622
|
+
this.on(event, listener);
|
|
623
|
+
}
|
|
613
624
|
});
|
|
614
625
|
}
|
|
615
626
|
/**
|