@likec4/language-server 1.48.0 → 1.49.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.
Files changed (78) hide show
  1. package/browser/package.json +2 -2
  2. package/browser-worker/package.json +2 -2
  3. package/dist/THIRD-PARTY-LICENSES.md +178 -0
  4. package/dist/_chunks/ConfigurableLayouter.mjs +1 -1956
  5. package/dist/_chunks/LikeC4FileSystem.mjs +3 -0
  6. package/dist/_chunks/LikeC4Views.mjs +34 -0
  7. package/dist/_chunks/ProjectsManager.mjs +1 -0
  8. package/dist/_chunks/WithMCPServer.mjs +481 -0
  9. package/dist/_chunks/icons.mjs +2 -5211
  10. package/dist/_chunks/{LikeC4LanguageServices.d.mts → index.d.mts} +1836 -707
  11. package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -805
  12. package/dist/_chunks/libs/eventemitter3.mjs +1 -243
  13. package/dist/_chunks/libs/fast-equals.mjs +1 -446
  14. package/dist/_chunks/libs/p-queue.mjs +1 -449
  15. package/dist/_chunks/libs/parse-ms.mjs +1 -36
  16. package/dist/_chunks/libs/picomatch.mjs +1 -1673
  17. package/dist/_chunks/libs/pretty-ms.mjs +1 -80
  18. package/dist/_chunks/libs/remeda.mjs +1 -482
  19. package/dist/_chunks/libs/strip-indent.mjs +1 -15
  20. package/dist/_chunks/libs/ufo.mjs +1 -166
  21. package/dist/_chunks/logger.mjs +1 -0
  22. package/dist/_chunks/rolldown-runtime.mjs +1 -42
  23. package/dist/_chunks/utils.mjs +1 -0
  24. package/dist/browser/index.d.mts +10 -0
  25. package/dist/browser/index.mjs +1 -0
  26. package/dist/browser/worker.mjs +1 -0
  27. package/dist/bundled.d.mts +2 -3
  28. package/dist/bundled.mjs +1 -51
  29. package/dist/filesystem/index.d.mts +2 -4
  30. package/dist/filesystem/index.mjs +1 -3
  31. package/dist/index.d.mts +38 -3
  32. package/dist/index.mjs +1 -48
  33. package/dist/likec4lib.d.mts +10 -3
  34. package/dist/likec4lib.mjs +1 -4
  35. package/dist/mcp/index.d.mts +2 -4
  36. package/dist/mcp/index.mjs +1 -3
  37. package/dist/module.d.mts +126 -4
  38. package/dist/module.mjs +1 -3
  39. package/dist/protocol.d.mts +314 -1
  40. package/dist/protocol.mjs +1 -3
  41. package/filesystem/package.json +4 -0
  42. package/mcp/package.json +4 -0
  43. package/module/package.json +4 -0
  44. package/package.json +79 -56
  45. package/LICENSE +0 -21
  46. package/dist/LikeC4LanguageServices.d.mts +0 -4
  47. package/dist/LikeC4LanguageServices.mjs +0 -3
  48. package/dist/_chunks/LikeC4LanguageServices.mjs +0 -725
  49. package/dist/_chunks/ast.d.mts +0 -1444
  50. package/dist/_chunks/ast.mjs +0 -2375
  51. package/dist/_chunks/ast2.mjs +0 -176
  52. package/dist/_chunks/common-exports.mjs +0 -0
  53. package/dist/_chunks/filesystem.mjs +0 -58
  54. package/dist/_chunks/grammar.mjs +0 -8
  55. package/dist/_chunks/libs/@hono/node-server.mjs +0 -436
  56. package/dist/_chunks/libs/hono.mjs +0 -1829
  57. package/dist/_chunks/likec4lib.mjs +0 -9
  58. package/dist/_chunks/mcp.mjs +0 -33
  59. package/dist/_chunks/module.mjs +0 -28
  60. package/dist/_chunks/module2.mjs +0 -6576
  61. package/dist/_chunks/protocol.d.mts +0 -311
  62. package/dist/_chunks/protocol.mjs +0 -78
  63. package/dist/ast.d.mts +0 -4
  64. package/dist/ast.mjs +0 -4
  65. package/dist/browser-worker.mjs +0 -6
  66. package/dist/browser.d.mts +0 -11
  67. package/dist/browser.mjs +0 -27
  68. package/dist/common-exports.d.mts +0 -4
  69. package/dist/common-exports.mjs +0 -5
  70. package/dist/generated/ast.d.mts +0 -2
  71. package/dist/generated/ast.mjs +0 -3
  72. package/dist/generated/grammar.d.mts +0 -6
  73. package/dist/generated/grammar.mjs +0 -3
  74. package/dist/generated/module.d.mts +0 -14
  75. package/dist/generated/module.mjs +0 -3
  76. package/dist/generated-lib/icons.d.mts +0 -4
  77. package/dist/generated-lib/icons.mjs +0 -3
  78. /package/dist/{browser-worker.d.mts → browser/worker.d.mts} +0 -0
@@ -1,449 +1 @@
1
- import { t as import_eventemitter3 } from "./eventemitter3.mjs";
2
-
3
- //#region ../../node_modules/.pnpm/p-timeout@6.1.4/node_modules/p-timeout/index.js
4
- var TimeoutError = class extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = "TimeoutError";
8
- }
9
- };
10
- /**
11
- An error to be thrown when the request is aborted by AbortController.
12
- DOMException is thrown instead of this Error when DOMException is available.
13
- */
14
- var AbortError = class extends Error {
15
- constructor(message) {
16
- super();
17
- this.name = "AbortError";
18
- this.message = message;
19
- }
20
- };
21
- /**
22
- TODO: Remove AbortError and just throw DOMException when targeting Node 18.
23
- */
24
- const getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError(errorMessage) : new DOMException(errorMessage);
25
- /**
26
- TODO: Remove below function and just 'reject(signal.reason)' when targeting Node 18.
27
- */
28
- const getAbortedReason = (signal) => {
29
- const reason = signal.reason === void 0 ? getDOMException("This operation was aborted.") : signal.reason;
30
- return reason instanceof Error ? reason : getDOMException(reason);
31
- };
32
- function pTimeout(promise, options) {
33
- const { milliseconds, fallback, message, customTimers = {
34
- setTimeout,
35
- clearTimeout
36
- } } = options;
37
- let timer;
38
- let abortHandler;
39
- const cancelablePromise = new Promise((resolve, reject) => {
40
- if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
41
- if (options.signal) {
42
- const { signal } = options;
43
- if (signal.aborted) reject(getAbortedReason(signal));
44
- abortHandler = () => {
45
- reject(getAbortedReason(signal));
46
- };
47
- signal.addEventListener("abort", abortHandler, { once: true });
48
- }
49
- if (milliseconds === Number.POSITIVE_INFINITY) {
50
- promise.then(resolve, reject);
51
- return;
52
- }
53
- const timeoutError = new TimeoutError();
54
- timer = customTimers.setTimeout.call(void 0, () => {
55
- if (fallback) {
56
- try {
57
- resolve(fallback());
58
- } catch (error) {
59
- reject(error);
60
- }
61
- return;
62
- }
63
- if (typeof promise.cancel === "function") promise.cancel();
64
- if (message === false) resolve();
65
- else if (message instanceof Error) reject(message);
66
- else {
67
- timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
68
- reject(timeoutError);
69
- }
70
- }, milliseconds);
71
- (async () => {
72
- try {
73
- resolve(await promise);
74
- } catch (error) {
75
- reject(error);
76
- }
77
- })();
78
- }).finally(() => {
79
- cancelablePromise.clear();
80
- if (abortHandler && options.signal) options.signal.removeEventListener("abort", abortHandler);
81
- });
82
- cancelablePromise.clear = () => {
83
- customTimers.clearTimeout.call(void 0, timer);
84
- timer = void 0;
85
- };
86
- return cancelablePromise;
87
- }
88
-
89
- //#endregion
90
- //#region ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/lower-bound.js
91
- function lowerBound(array, value, comparator) {
92
- let first = 0;
93
- let count = array.length;
94
- while (count > 0) {
95
- const step = Math.trunc(count / 2);
96
- let it = first + step;
97
- if (comparator(array[it], value) <= 0) {
98
- first = ++it;
99
- count -= step + 1;
100
- } else count = step;
101
- }
102
- return first;
103
- }
104
-
105
- //#endregion
106
- //#region ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/priority-queue.js
107
- var PriorityQueue = class {
108
- #queue = [];
109
- enqueue(run, options) {
110
- options = {
111
- priority: 0,
112
- ...options
113
- };
114
- const element = {
115
- priority: options.priority,
116
- id: options.id,
117
- run
118
- };
119
- if (this.size === 0 || this.#queue[this.size - 1].priority >= options.priority) {
120
- this.#queue.push(element);
121
- return;
122
- }
123
- const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);
124
- this.#queue.splice(index, 0, element);
125
- }
126
- setPriority(id, priority) {
127
- const index = this.#queue.findIndex((element) => element.id === id);
128
- if (index === -1) throw new ReferenceError(`No promise function with the id "${id}" exists in the queue.`);
129
- const [item] = this.#queue.splice(index, 1);
130
- this.enqueue(item.run, {
131
- priority,
132
- id
133
- });
134
- }
135
- dequeue() {
136
- return this.#queue.shift()?.run;
137
- }
138
- filter(options) {
139
- return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);
140
- }
141
- get size() {
142
- return this.#queue.length;
143
- }
144
- };
145
-
146
- //#endregion
147
- //#region ../../node_modules/.pnpm/p-queue@8.1.1/node_modules/p-queue/dist/index.js
148
- /**
149
- Promise queue with concurrency control.
150
- */
151
- var PQueue = class extends import_eventemitter3.default {
152
- #carryoverConcurrencyCount;
153
- #isIntervalIgnored;
154
- #intervalCount = 0;
155
- #intervalCap;
156
- #interval;
157
- #intervalEnd = 0;
158
- #intervalId;
159
- #timeoutId;
160
- #queue;
161
- #queueClass;
162
- #pending = 0;
163
- #concurrency;
164
- #isPaused;
165
- #throwOnTimeout;
166
- #idAssigner = 1n;
167
- /**
168
- Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
169
-
170
- Applies to each future operation.
171
- */
172
- timeout;
173
- constructor(options) {
174
- super();
175
- options = {
176
- carryoverConcurrencyCount: false,
177
- intervalCap: Number.POSITIVE_INFINITY,
178
- interval: 0,
179
- concurrency: Number.POSITIVE_INFINITY,
180
- autoStart: true,
181
- queueClass: PriorityQueue,
182
- ...options
183
- };
184
- if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${options.intervalCap?.toString() ?? ""}\` (${typeof options.intervalCap})`);
185
- if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
186
- this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;
187
- this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
188
- this.#intervalCap = options.intervalCap;
189
- this.#interval = options.interval;
190
- this.#queue = new options.queueClass();
191
- this.#queueClass = options.queueClass;
192
- this.concurrency = options.concurrency;
193
- this.timeout = options.timeout;
194
- this.#throwOnTimeout = options.throwOnTimeout === true;
195
- this.#isPaused = options.autoStart === false;
196
- }
197
- get #doesIntervalAllowAnother() {
198
- return this.#isIntervalIgnored || this.#intervalCount < this.#intervalCap;
199
- }
200
- get #doesConcurrentAllowAnother() {
201
- return this.#pending < this.#concurrency;
202
- }
203
- #next() {
204
- this.#pending--;
205
- this.#tryToStartAnother();
206
- this.emit("next");
207
- }
208
- #onResumeInterval() {
209
- this.#onInterval();
210
- this.#initializeIntervalIfNeeded();
211
- this.#timeoutId = void 0;
212
- }
213
- get #isIntervalPaused() {
214
- const now = Date.now();
215
- if (this.#intervalId === void 0) {
216
- const delay = this.#intervalEnd - now;
217
- if (delay < 0) this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;
218
- else {
219
- if (this.#timeoutId === void 0) this.#timeoutId = setTimeout(() => {
220
- this.#onResumeInterval();
221
- }, delay);
222
- return true;
223
- }
224
- }
225
- return false;
226
- }
227
- #tryToStartAnother() {
228
- if (this.#queue.size === 0) {
229
- if (this.#intervalId) clearInterval(this.#intervalId);
230
- this.#intervalId = void 0;
231
- this.emit("empty");
232
- if (this.#pending === 0) this.emit("idle");
233
- return false;
234
- }
235
- if (!this.#isPaused) {
236
- const canInitializeInterval = !this.#isIntervalPaused;
237
- if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {
238
- const job = this.#queue.dequeue();
239
- if (!job) return false;
240
- this.emit("active");
241
- job();
242
- if (canInitializeInterval) this.#initializeIntervalIfNeeded();
243
- return true;
244
- }
245
- }
246
- return false;
247
- }
248
- #initializeIntervalIfNeeded() {
249
- if (this.#isIntervalIgnored || this.#intervalId !== void 0) return;
250
- this.#intervalId = setInterval(() => {
251
- this.#onInterval();
252
- }, this.#interval);
253
- this.#intervalEnd = Date.now() + this.#interval;
254
- }
255
- #onInterval() {
256
- if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {
257
- clearInterval(this.#intervalId);
258
- this.#intervalId = void 0;
259
- }
260
- this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;
261
- this.#processQueue();
262
- }
263
- /**
264
- Executes all queued functions until it reaches the limit.
265
- */
266
- #processQueue() {
267
- while (this.#tryToStartAnother());
268
- }
269
- get concurrency() {
270
- return this.#concurrency;
271
- }
272
- set concurrency(newConcurrency) {
273
- if (!(typeof newConcurrency === "number" && newConcurrency >= 1)) throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${newConcurrency}\` (${typeof newConcurrency})`);
274
- this.#concurrency = newConcurrency;
275
- this.#processQueue();
276
- }
277
- async #throwOnAbort(signal) {
278
- return new Promise((_resolve, reject) => {
279
- signal.addEventListener("abort", () => {
280
- reject(signal.reason);
281
- }, { once: true });
282
- });
283
- }
284
- /**
285
- Updates the priority of a promise function by its id, affecting its execution order. Requires a defined concurrency limit to take effect.
286
-
287
- For example, this can be used to prioritize a promise function to run earlier.
288
-
289
- ```js
290
- import PQueue from 'p-queue';
291
-
292
- const queue = new PQueue({concurrency: 1});
293
-
294
- queue.add(async () => '🦄', {priority: 1});
295
- queue.add(async () => '🦀', {priority: 0, id: '🦀'});
296
- queue.add(async () => '🦄', {priority: 1});
297
- queue.add(async () => '🦄', {priority: 1});
298
-
299
- queue.setPriority('🦀', 2);
300
- ```
301
-
302
- In this case, the promise function with `id: '🦀'` runs second.
303
-
304
- You can also deprioritize a promise function to delay its execution:
305
-
306
- ```js
307
- import PQueue from 'p-queue';
308
-
309
- const queue = new PQueue({concurrency: 1});
310
-
311
- queue.add(async () => '🦄', {priority: 1});
312
- queue.add(async () => '🦀', {priority: 1, id: '🦀'});
313
- queue.add(async () => '🦄');
314
- queue.add(async () => '🦄', {priority: 0});
315
-
316
- queue.setPriority('🦀', -1);
317
- ```
318
- Here, the promise function with `id: '🦀'` executes last.
319
- */
320
- setPriority(id, priority) {
321
- this.#queue.setPriority(id, priority);
322
- }
323
- async add(function_, options = {}) {
324
- options.id ??= (this.#idAssigner++).toString();
325
- options = {
326
- timeout: this.timeout,
327
- throwOnTimeout: this.#throwOnTimeout,
328
- ...options
329
- };
330
- return new Promise((resolve, reject) => {
331
- this.#queue.enqueue(async () => {
332
- this.#pending++;
333
- try {
334
- options.signal?.throwIfAborted();
335
- this.#intervalCount++;
336
- let operation = function_({ signal: options.signal });
337
- if (options.timeout) operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
338
- if (options.signal) operation = Promise.race([operation, this.#throwOnAbort(options.signal)]);
339
- const result = await operation;
340
- resolve(result);
341
- this.emit("completed", result);
342
- } catch (error) {
343
- if (error instanceof TimeoutError && !options.throwOnTimeout) {
344
- resolve();
345
- return;
346
- }
347
- reject(error);
348
- this.emit("error", error);
349
- } finally {
350
- this.#next();
351
- }
352
- }, options);
353
- this.emit("add");
354
- this.#tryToStartAnother();
355
- });
356
- }
357
- async addAll(functions, options) {
358
- return Promise.all(functions.map(async (function_) => this.add(function_, options)));
359
- }
360
- /**
361
- Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
362
- */
363
- start() {
364
- if (!this.#isPaused) return this;
365
- this.#isPaused = false;
366
- this.#processQueue();
367
- return this;
368
- }
369
- /**
370
- Put queue execution on hold.
371
- */
372
- pause() {
373
- this.#isPaused = true;
374
- }
375
- /**
376
- Clear the queue.
377
- */
378
- clear() {
379
- this.#queue = new this.#queueClass();
380
- }
381
- /**
382
- Can be called multiple times. Useful if you for example add additional items at a later time.
383
-
384
- @returns A promise that settles when the queue becomes empty.
385
- */
386
- async onEmpty() {
387
- if (this.#queue.size === 0) return;
388
- await this.#onEvent("empty");
389
- }
390
- /**
391
- @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
392
-
393
- If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
394
-
395
- 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.
396
- */
397
- async onSizeLessThan(limit) {
398
- if (this.#queue.size < limit) return;
399
- await this.#onEvent("next", () => this.#queue.size < limit);
400
- }
401
- /**
402
- 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.
403
-
404
- @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
405
- */
406
- async onIdle() {
407
- if (this.#pending === 0 && this.#queue.size === 0) return;
408
- await this.#onEvent("idle");
409
- }
410
- async #onEvent(event, filter) {
411
- return new Promise((resolve) => {
412
- const listener = () => {
413
- if (filter && !filter()) return;
414
- this.off(event, listener);
415
- resolve();
416
- };
417
- this.on(event, listener);
418
- });
419
- }
420
- /**
421
- Size of the queue, the number of queued items waiting to run.
422
- */
423
- get size() {
424
- return this.#queue.size;
425
- }
426
- /**
427
- Size of the queue, filtered by the given options.
428
-
429
- For example, this can be used to find the number of items remaining in the queue with a specific priority level.
430
- */
431
- sizeBy(options) {
432
- return this.#queue.filter(options).length;
433
- }
434
- /**
435
- Number of running items (no longer in the queue).
436
- */
437
- get pending() {
438
- return this.#pending;
439
- }
440
- /**
441
- Whether the queue is currently paused.
442
- */
443
- get isPaused() {
444
- return this.#isPaused;
445
- }
446
- };
447
-
448
- //#endregion
449
- export { PQueue as t };
1
+ import{t as import_eventemitter3}from"./eventemitter3.mjs";var TimeoutError=class extends Error{constructor(e){super(e),this.name=`TimeoutError`}},AbortError=class extends Error{constructor(e){super(),this.name=`AbortError`,this.message=e}};const getDOMException=e=>globalThis.DOMException===void 0?new AbortError(e):new DOMException(e),getAbortedReason=e=>{let t=e.reason===void 0?getDOMException(`This operation was aborted.`):e.reason;return t instanceof Error?t:getDOMException(t)};function pTimeout(e,t){let{milliseconds:n,fallback:r,message:i,customTimers:a={setTimeout,clearTimeout}}=t,o,abortHandler,s=new Promise((s,c)=>{if(typeof n!=`number`||Math.sign(n)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(t.signal){let{signal:e}=t;e.aborted&&c(getAbortedReason(e)),abortHandler=()=>{c(getAbortedReason(e))},e.addEventListener(`abort`,abortHandler,{once:!0})}if(n===1/0){e.then(s,c);return}let l=new TimeoutError;o=a.setTimeout.call(void 0,()=>{if(r){try{s(r())}catch(e){c(e)}return}typeof e.cancel==`function`&&e.cancel(),i===!1?s():i instanceof Error?c(i):(l.message=i??`Promise timed out after ${n} milliseconds`,c(l))},n),(async()=>{try{s(await e)}catch(e){c(e)}})()}).finally(()=>{s.clear(),abortHandler&&t.signal&&t.signal.removeEventListener(`abort`,abortHandler)});return s.clear=()=>{a.clearTimeout.call(void 0,o),o=void 0},s}function lowerBound(e,t,n){let r=0,i=e.length;for(;i>0;){let a=Math.trunc(i/2),o=r+a;n(e[o],t)<=0?(r=++o,i-=a+1):i=a}return r}var PriorityQueue=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,id:t.id,run:e};if(this.size===0||this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let r=lowerBound(this.#e,n,(e,t)=>t.priority-e.priority);this.#e.splice(r,0,n)}setPriority(e,t){let n=this.#e.findIndex(t=>t.id===e);if(n===-1)throw ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[r]=this.#e.splice(n,1);this.enqueue(r.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this.#e.length}},PQueue=class extends import_eventemitter3.default{#e;#t;#n=0;#r;#i;#a=0;#o;#s;#c;#l;#u=0;#d;#f;#p;#m=1n;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:PriorityQueue,...e},!(typeof e.intervalCap==`number`&&e.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??``}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??``}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#t=e.intervalCap===1/0||e.interval===0,this.#r=e.intervalCap,this.#i=e.interval,this.#c=new e.queueClass,this.#l=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#p=e.throwOnTimeout===!0,this.#f=e.autoStart===!1}get#h(){return this.#t||this.#n<this.#r}get#g(){return this.#u<this.#d}#_(){this.#u--,this.#b(),this.emit(`next`)}#v(){this.#S(),this.#x(),this.#s=void 0}get#y(){let e=Date.now();if(this.#o===void 0){let t=this.#a-e;if(t<0)this.#n=this.#e?this.#u:0;else return this.#s===void 0&&(this.#s=setTimeout(()=>{this.#v()},t)),!0}return!1}#b(){if(this.#c.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit(`empty`),this.#u===0&&this.emit(`idle`),!1;if(!this.#f){let e=!this.#y;if(this.#h&&this.#g){let t=this.#c.dequeue();return t?(this.emit(`active`),t(),e&&this.#x(),!0):!1}}return!1}#x(){this.#t||this.#o!==void 0||(this.#o=setInterval(()=>{this.#S()},this.#i),this.#a=Date.now()+this.#i)}#S(){this.#n===0&&this.#u===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#n=this.#e?this.#u:0,this.#C()}#C(){for(;this.#b(););}get concurrency(){return this.#d}set concurrency(e){if(!(typeof e==`number`&&e>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#d=e,this.#C()}async#w(e){return new Promise((t,n)=>{e.addEventListener(`abort`,()=>{n(e.reason)},{once:!0})})}setPriority(e,t){this.#c.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#m++).toString(),t={timeout:this.timeout,throwOnTimeout:this.#p,...t},new Promise((n,r)=>{this.#c.enqueue(async()=>{this.#u++;try{t.signal?.throwIfAborted(),this.#n++;let r=e({signal:t.signal});t.timeout&&(r=pTimeout(Promise.resolve(r),{milliseconds:t.timeout})),t.signal&&(r=Promise.race([r,this.#w(t.signal)]));let i=await r;n(i),this.emit(`completed`,i)}catch(e){if(e instanceof TimeoutError&&!t.throwOnTimeout){n();return}r(e),this.emit(`error`,e)}finally{this.#_()}},t),this.emit(`add`),this.#b()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#f?(this.#f=!1,this.#C(),this):this}pause(){this.#f=!0}clear(){this.#c=new this.#l}async onEmpty(){this.#c.size!==0&&await this.#T(`empty`)}async onSizeLessThan(e){this.#c.size<e||await this.#T(`next`,()=>this.#c.size<e)}async onIdle(){this.#u===0&&this.#c.size===0||await this.#T(`idle`)}async#T(e,t){return new Promise(n=>{let listener=()=>{t&&!t()||(this.off(e,listener),n())};this.on(e,listener)})}get size(){return this.#c.size}sizeBy(e){return this.#c.filter(e).length}get pending(){return this.#u}get isPaused(){return this.#f}};export{PQueue as t};
@@ -1,36 +1 @@
1
- //#region ../../node_modules/.pnpm/parse-ms@4.0.0/node_modules/parse-ms/index.js
2
- const toZeroIfInfinity = (value) => Number.isFinite(value) ? value : 0;
3
- function parseNumber(milliseconds) {
4
- return {
5
- days: Math.trunc(milliseconds / 864e5),
6
- hours: Math.trunc(milliseconds / 36e5 % 24),
7
- minutes: Math.trunc(milliseconds / 6e4 % 60),
8
- seconds: Math.trunc(milliseconds / 1e3 % 60),
9
- milliseconds: Math.trunc(milliseconds % 1e3),
10
- microseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1e3) % 1e3),
11
- nanoseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1e6) % 1e3)
12
- };
13
- }
14
- function parseBigint(milliseconds) {
15
- return {
16
- days: milliseconds / 86400000n,
17
- hours: milliseconds / 3600000n % 24n,
18
- minutes: milliseconds / 60000n % 60n,
19
- seconds: milliseconds / 1000n % 60n,
20
- milliseconds: milliseconds % 1000n,
21
- microseconds: 0n,
22
- nanoseconds: 0n
23
- };
24
- }
25
- function parseMilliseconds(milliseconds) {
26
- switch (typeof milliseconds) {
27
- case "number":
28
- if (Number.isFinite(milliseconds)) return parseNumber(milliseconds);
29
- break;
30
- case "bigint": return parseBigint(milliseconds);
31
- }
32
- throw new TypeError("Expected a finite number or bigint");
33
- }
34
-
35
- //#endregion
36
- export { parseMilliseconds as t };
1
+ const toZeroIfInfinity=e=>Number.isFinite(e)?e:0;function parseNumber(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(toZeroIfInfinity(e*1e3)%1e3),nanoseconds:Math.trunc(toZeroIfInfinity(e*1e6)%1e3)}}function parseBigint(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function parseMilliseconds(e){switch(typeof e){case`number`:if(Number.isFinite(e))return parseNumber(e);break;case`bigint`:return parseBigint(e)}throw TypeError(`Expected a finite number or bigint`)}export{parseMilliseconds as t};