@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.
Files changed (147) hide show
  1. package/dist/{access-control-DazDX3RB.js → access-control-CRz_v6bR.js} +4 -5
  2. package/dist/{accounts-CKOFMPf-.js → accounts-CxPuEFi-.js} +44 -4
  3. package/dist/{action-runtime-Bf-12TIH.js → action-runtime-CHU7xb6o.js} +2 -2
  4. package/dist/action-runtime-api.js +1 -1
  5. package/dist/action-runtime.runtime.js +1 -1
  6. package/dist/{active-listener-5kHap439.js → active-listener-BEjWsCNM.js} +1 -1
  7. package/dist/api.js +12 -15
  8. package/dist/{approval-handler.runtime-CBiGQuZ5.js → approval-handler.runtime-C4ddB7Kc.js} +4 -4
  9. package/dist/{approval-reactions-BGQoz25s.js → approval-reactions-P2HXjmln.js} +3 -3
  10. package/dist/{auth-store-BQi9pZqQ.js → auth-store-DirYMTbo.js} +4 -3
  11. package/dist/call-tool-api.js +4 -4
  12. package/dist/{channel-DbadDUDD.js → channel-B9xjrOGG.js} +37 -19
  13. package/dist/channel-config-api.js +1 -1
  14. package/dist/channel-plugin-api.js +1 -1
  15. package/dist/{channel-react-action-PoRWfP9x.js → channel-react-action-CBW-PA8q.js} +10 -13
  16. package/dist/{channel.runtime-BDDy4Lhz.js → channel.runtime-DdKuhlNu.js} +5 -5
  17. package/dist/{channel.setup-BZ-po8fg.js → channel.setup-DXUCPHel.js} +3 -6
  18. package/dist/{config-schema-BZ8h1hWA.js → config-schema-C6IeKIC0.js} +6 -0
  19. package/dist/{connection-controller-C1rwfWb4.js → connection-controller-BVRExqrB.js} +186 -27
  20. package/dist/connection-controller-runtime-context-DG0tuYuw.js +23 -0
  21. package/dist/contract-api.js +1 -1
  22. package/dist/directory-config-BTbJkV1W.js +196 -0
  23. package/dist/directory-contract-api.js +1 -1
  24. package/dist/doctor-CwzVXKoE.js +10 -0
  25. package/dist/doctor-contract-api.js +35 -79
  26. package/dist/{group-session-key-CLTZeH_F.js → group-session-key-DJSdYfnb.js} +9 -4
  27. package/dist/{identity-D7L8LCuH.js → identity-BM4_wZeM.js} +2 -2
  28. package/dist/light-runtime-api.js +2 -2
  29. package/dist/{login-DGIoToX8.js → login-BKUm7KSk.js} +6 -7
  30. package/dist/{login-qr-X-CZHOk9.js → login-qr-DagJvMbg.js} +7 -8
  31. package/dist/login-qr-runtime.js +1 -1
  32. package/dist/{monitor-BZ8QvCeV.js → monitor-CBVNJ2lb.js} +623 -400
  33. package/dist/question-reactions-CaOrSYzU.js +142 -0
  34. package/dist/runtime-BLlToOi6.js +21 -0
  35. package/dist/runtime-api.js +10 -10
  36. package/dist/runtime-setter-api.js +1 -1
  37. package/dist/{send-D9Ydnn4o.js → send-DhJVN30g.js} +38 -85
  38. package/dist/{send-api-W33lI2nR.js → send-api-CpHwbor_.js} +38 -32
  39. package/dist/{setup-finalize-DBf1jjBj.js → setup-finalize-9XzKdFq6.js} +3 -3
  40. package/dist/setup-plugin-api.js +1 -1
  41. package/dist/{setup-surface-CiKGdNJv.js → setup-surface-Kv3mPki2.js} +3 -3
  42. package/dist/{setup-core-3aSOoK2T.js → shared-CuqHFnKd.js} +78 -56
  43. package/dist/{session-mxWFn0eS.js → socket-close-BoSHhQNJ.js} +226 -7
  44. package/dist/{targets-runtime-Bsh0HR9y.js → targets-runtime-CKFrhoX4.js} +142 -29
  45. package/dist/text-runtime-CU_IlbK5.js +4 -0
  46. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  47. package/node_modules/@protobufjs/utf8/index.js +29 -18
  48. package/node_modules/@protobufjs/utf8/package.json +2 -2
  49. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  50. package/node_modules/@thi.ng/bitstream/package.json +4 -4
  51. package/node_modules/@thi.ng/errors/package.json +4 -4
  52. package/node_modules/@types/node/README.md +1 -1
  53. package/node_modules/@types/node/fs/promises.d.ts +16 -6
  54. package/node_modules/@types/node/package.json +2 -2
  55. package/node_modules/audio-type/package.json +3 -2
  56. package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
  57. package/node_modules/lru-cache/dist/commonjs/browser/index.js +11 -4
  58. package/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
  59. package/node_modules/lru-cache/dist/commonjs/browser/index.min.js +1 -1
  60. package/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +3 -3
  61. package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
  62. package/node_modules/lru-cache/dist/commonjs/index.js +11 -4
  63. package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
  64. package/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  65. package/node_modules/lru-cache/dist/commonjs/index.min.js.map +3 -3
  66. package/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
  67. package/node_modules/lru-cache/dist/commonjs/node/index.js +11 -4
  68. package/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
  69. package/node_modules/lru-cache/dist/commonjs/node/index.min.js +1 -1
  70. package/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +3 -3
  71. package/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
  72. package/node_modules/lru-cache/dist/esm/browser/index.js +11 -4
  73. package/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
  74. package/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
  75. package/node_modules/lru-cache/dist/esm/browser/index.min.js.map +3 -3
  76. package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
  77. package/node_modules/lru-cache/dist/esm/index.js +11 -4
  78. package/node_modules/lru-cache/dist/esm/index.js.map +1 -1
  79. package/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  80. package/node_modules/lru-cache/dist/esm/index.min.js.map +3 -3
  81. package/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
  82. package/node_modules/lru-cache/dist/esm/node/index.js +11 -4
  83. package/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
  84. package/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
  85. package/node_modules/lru-cache/dist/esm/node/index.min.js.map +3 -3
  86. package/node_modules/lru-cache/package.json +1 -1
  87. package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
  88. package/node_modules/music-metadata/lib/common/Util.js +7 -1
  89. package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +23 -3
  90. package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
  91. package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
  92. package/node_modules/music-metadata/lib/mp4/AtomToken.js +38 -13
  93. package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
  94. package/node_modules/music-metadata/package.json +6 -6
  95. package/node_modules/p-queue/dist/index.js +17 -6
  96. package/node_modules/p-queue/package.json +1 -1
  97. package/node_modules/protobufjs/dist/light/protobuf.js +145 -188
  98. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  99. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  100. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  101. package/node_modules/protobufjs/dist/minimal/protobuf.js +33 -76
  102. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  103. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  104. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  105. package/node_modules/protobufjs/dist/protobuf.js +168 -208
  106. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  107. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  108. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  109. package/node_modules/protobufjs/index.d.ts +0 -8
  110. package/node_modules/protobufjs/package.json +2 -3
  111. package/node_modules/protobufjs/src/parse.js +3 -0
  112. package/node_modules/protobufjs/src/util/minimal.js +0 -3
  113. package/node_modules/typebox/build/compile/validator.d.mts +1 -4
  114. package/node_modules/typebox/build/guard/guard.d.mts +1 -1
  115. package/node_modules/typebox/build/guard/guard.mjs +5 -2
  116. package/node_modules/typebox/build/guard/string.mjs +16 -4
  117. package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  118. package/node_modules/typebox/build/type/action/readonly_object.d.mts +5 -0
  119. package/node_modules/typebox/build/type/action/readonly_object.mjs +8 -0
  120. package/node_modules/typebox/build/typebox.d.mts +1 -1
  121. package/node_modules/typebox/build/typebox.mjs +1 -1
  122. package/node_modules/typebox/package.json +1 -1
  123. package/node_modules/typebox/readme.md +29 -32
  124. package/node_modules/ws/lib/receiver.js +15 -32
  125. package/node_modules/ws/lib/websocket-server.js +4 -4
  126. package/node_modules/ws/lib/websocket.js +4 -4
  127. package/node_modules/ws/package.json +5 -1
  128. package/npm-shrinkwrap.json +41 -45
  129. package/openclaw.plugin.json +139 -179
  130. package/package.json +21 -11
  131. package/dist/account-config-LiT9wWH9.js +0 -43
  132. package/dist/connection-controller-runtime-context-CbTsqmPT.js +0 -14
  133. package/dist/directory-config-CLBQrjtC.js +0 -37
  134. package/dist/doctor-By3SB4lm.js +0 -48
  135. package/dist/runtime-BfAdAEYT.js +0 -8
  136. package/dist/text-runtime-BTGkMN0o.js +0 -4
  137. package/node_modules/@protobufjs/inquire/CHANGELOG.md +0 -8
  138. package/node_modules/@protobufjs/inquire/LICENSE +0 -26
  139. package/node_modules/@protobufjs/inquire/README.md +0 -13
  140. package/node_modules/@protobufjs/inquire/index.d.ts +0 -10
  141. package/node_modules/@protobufjs/inquire/index.js +0 -38
  142. package/node_modules/@protobufjs/inquire/package.json +0 -21
  143. package/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
  144. package/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
  145. package/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
  146. package/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
  147. package/node_modules/@protobufjs/inquire/tests/index.js +0 -20
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lru-cache",
3
3
  "description": "A cache object that deletes the least-recently-used items.",
4
- "version": "11.5.1",
4
+ "version": "11.5.2",
5
5
  "author": "Isaac Z. Schlueter <i@izs.me>",
6
6
  "keywords": [
7
7
  "mru",
@@ -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, 7),
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(valueArray, encoding.encoding),
393
+ text: util.decodeString(uint8Array, encoding.encoding),
394
394
  len: originalLen
395
395
  };
396
396
  }
397
- const txt = valueArray.subarray(0, zeroIndex);
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-16le', bom: false };
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
- return {
230
- version: Token.UINT8.get(buf, off),
231
- flags: Token.UINT24_BE.get(buf, off + 1),
232
- creationTime: SecondsSinceMacEpoch.get(buf, off + 4),
233
- modificationTime: SecondsSinceMacEpoch.get(buf, off + 8),
234
- trackId: Token.UINT32_BE.get(buf, off + 12),
235
- // reserved 4 bytes
236
- duration: Token.UINT32_BE.get(buf, off + 20),
237
- layer: Token.UINT16_BE.get(buf, off + 24),
238
- alternateGroup: Token.UINT16_BE.get(buf, off + 26),
239
- volume: Token.UINT16_BE.get(buf, off + 28) // ToDo: fixed point
240
- // ToDo: add remaining fields
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, -1
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.13.0",
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.4.6",
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": "^1.1.9",
131
- "@types/debug": "^4.1.12",
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": "^25.2.0",
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.5",
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 queue is empty.
520
+ // Instantly resolve if the size is already below the limit.
518
521
  if (this.#queue.size < limit) {
519
522
  return;
520
523
  }
521
- await this.#onEvent('next', () => this.#queue.size < limit);
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(event, filter) {
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
- this.off(event, listener);
616
+ for (const event of eventList) {
617
+ this.off(event, listener);
618
+ }
610
619
  resolve();
611
620
  };
612
- this.on(event, listener);
621
+ for (const event of eventList) {
622
+ this.on(event, listener);
623
+ }
613
624
  });
614
625
  }
615
626
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "p-queue",
3
- "version": "9.3.0",
3
+ "version": "9.3.2",
4
4
  "description": "Promise queue with concurrency control",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/p-queue",