@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/README.md +3 -1
- package/lib/client.js +1032 -464
- package/lib/client.js.map +1 -1
- package/lib/index.js +260 -54
- package/package.json +81 -81
- package/src/canvas-store.ts +375 -376
- package/src/client/CanvasWorkspace.tsx +273 -30
- package/src/client/ImageGenPanel.tsx +160 -86
- package/src/client/SettingsCard.tsx +1128 -1114
- package/src/client/canvas-workspace.module.css +144 -8
- package/src/client/locales.ts +1515 -1455
- package/src/client/panel.module.css +27 -26
- package/src/engine.ts +998 -828
- package/src/gallery-store.ts +311 -311
- package/src/generation-runtime.ts +2 -2
- package/src/history-store.ts +275 -275
- package/src/image-storage-path.ts +12 -0
- package/src/index.ts +430 -424
- package/src/model-catalog.ts +149 -124
- package/src/presets.ts +95 -86
- package/src/prompt-enhancer.ts +151 -137
- package/src/protocol.ts +580 -574
- package/src/routes.ts +3 -0
- package/src/task-queue.ts +4 -5
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
|
}
|