@dickpy/dsh-imagegen 1.5.5 → 1.5.7

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/src/routes.ts CHANGED
@@ -187,6 +187,9 @@ function parseGenerateRequest(body: Record<string, unknown>): GenerateRequest |
187
187
  n: typeof body.n === 'number' ? body.n : 1,
188
188
  detail: typeof body.detail === 'string' ? body.detail : '',
189
189
  ...typeof body.image === 'string' && body.image !== '' ? { image: body.image } : {},
190
+ ...Array.isArray(body.images)
191
+ ? { images: body.images.filter((item): item is string => typeof item === 'string' && item !== '').slice(0, 4) }
192
+ : {},
190
193
  ...typeof body.refName === 'string' && body.refName !== '' ? { refName: body.refName } : {},
191
194
  ...typeof body.channelId === 'string' && body.channelId !== '' ? { channelId: body.channelId } : {},
192
195
  ...typeof body.comparisonId === 'string' && body.comparisonId !== '' ? { comparisonId: body.comparisonId } : {},
package/src/task-queue.ts CHANGED
@@ -10,7 +10,6 @@ export class GenerationTaskQueue {
10
10
  private readonly controllers = new Map<string, AbortController>()
11
11
  private readonly listeners = new Set<GenerationTaskListener>()
12
12
  private running = 0
13
- private serialRunning = false
14
13
 
15
14
  constructor(
16
15
  private readonly run: (request: GenerateRequest, signal: AbortSignal) => Promise<GenerateResult>,
@@ -51,16 +50,16 @@ export class GenerationTaskQueue {
51
50
  return previous === undefined ? undefined : this.submit(previous.request)
52
51
  }
53
52
 
53
+ /** Start queued tasks while capacity remains. Plain submissions and
54
+ * comparison batches alike run in parallel up to the host-wide limit, so one
55
+ * slow upstream can no longer hold back unrelated generations. */
54
56
  private drain(): void {
55
57
  while (this.running < Math.max(1, this.concurrency)) {
56
- const task = this.tasks.find(item => item.status === 'queued'
57
- && (this.running === 0 || (item.request.comparisonId !== undefined && !this.serialRunning)))
58
+ const task = this.tasks.find(item => item.status === 'queued')
58
59
  if (task === undefined) return
59
60
  this.running += 1
60
- if (task.request.comparisonId === undefined) this.serialRunning = true
61
61
  void this.runTask(task).finally(() => {
62
62
  this.running -= 1
63
- if (task.request.comparisonId === undefined) this.serialRunning = false
64
63
  this.drain()
65
64
  })
66
65
  }