@dickpy/dsh-imagegen 1.5.4 → 1.5.6
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 -0
- package/lib/client.js +1141 -508
- package/lib/client.js.map +1 -1
- package/lib/index.js +217 -170
- package/package.json +1 -1
- package/src/canvas-store.ts +15 -16
- package/src/client/CanvasWorkspace.tsx +333 -31
- package/src/client/ImageGenPanel.tsx +2737 -2679
- package/src/client/SettingsCard.tsx +14 -0
- package/src/client/canvas-workspace.module.css +144 -8
- package/src/client/locales.ts +82 -25
- package/src/client/panel.module.css +20 -26
- package/src/engine.ts +181 -146
- package/src/gallery-store.ts +13 -13
- package/src/generation-runtime.ts +2 -2
- package/src/history-store.ts +12 -12
- package/src/image-storage-path.ts +12 -0
- package/src/index.ts +5 -0
- package/src/protocol.ts +8 -2
- package/src/routes.ts +3 -0
- package/src/task-queue.ts +4 -5
package/src/protocol.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export const IMAGEGEN_SETTINGS_NAMESPACE = 'dsh-imagegen'
|
|
9
9
|
|
|
10
10
|
/** Published package version shared by the host updater and the client UI. */
|
|
11
|
-
export const PLUGIN_VERSION = '1.5.
|
|
11
|
+
export const PLUGIN_VERSION = '1.5.6'
|
|
12
12
|
|
|
13
13
|
/** Same-origin route family (loopback-only, mirroring the dsh-ssh fence). */
|
|
14
14
|
export const SETTINGS_API = {
|
|
@@ -324,7 +324,9 @@ export interface CanvasDocument {
|
|
|
324
324
|
title: string
|
|
325
325
|
revision: number
|
|
326
326
|
viewport: CanvasViewport
|
|
327
|
-
background: 'dots' | 'lines' | 'blank'
|
|
327
|
+
background: 'dots' | 'lines' | 'diagonal' | 'checker' | 'blank' | 'image'
|
|
328
|
+
/** Custom background image URL (a canvas asset) when background is 'image'. */
|
|
329
|
+
backgroundImage?: string
|
|
328
330
|
nodes: CanvasNode[]
|
|
329
331
|
connections: CanvasConnection[]
|
|
330
332
|
createdAt: number
|
|
@@ -413,6 +415,10 @@ export interface GenerateRequest extends EcommerceTaskMeta {
|
|
|
413
415
|
detail: string
|
|
414
416
|
/** Reference image as a data URL (edit mode only). */
|
|
415
417
|
image?: string
|
|
418
|
+
/** Additional reference images as data URLs (edit mode only). The first
|
|
419
|
+
* image stays in `image`; providers that accept several references get them
|
|
420
|
+
* all, single-reference providers see `image` alone. */
|
|
421
|
+
images?: string[]
|
|
416
422
|
/** Original reference-image name, retained in the history entry. */
|
|
417
423
|
refName?: string
|
|
418
424
|
/** Channel this request targets (the host falls back to the default when
|
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
|
}
|