@dickpy/dsh-imagegen 1.2.3 → 1.4.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.
- package/LICENSE +201 -201
- package/README.md +203 -181
- package/cordis.patch.yml +8 -8
- package/docs/images/multi-model-comparison.png +0 -0
- package/lib/client.js +2711 -1318
- package/lib/client.js.map +1 -1
- package/lib/index.js +830 -155
- package/package.json +70 -68
- package/src/agent-image-tools.ts +418 -316
- package/src/client/ImageGenPanel.tsx +1703 -1476
- package/src/client/SettingsCard.tsx +936 -648
- package/src/client/TemplateLibrary.tsx +336 -336
- package/src/client/api.ts +193 -193
- package/src/client/channels-form.ts +263 -0
- package/src/client/controller.ts +46 -46
- package/src/client/conversation-sync.ts +14 -0
- package/src/client/css-modules.d.ts +5 -5
- package/src/client/helpers.ts +33 -33
- package/src/client/image-toolview.module.css +73 -73
- package/src/client/image-toolview.tsx +170 -152
- package/src/client/index.ts +32 -22
- package/src/client/locales.ts +610 -484
- package/src/client/mount.tsx +185 -96
- package/src/client/panel.module.css +1713 -1445
- package/src/client/settings-card.module.css +1023 -536
- package/src/client/settings-form.ts +336 -336
- package/src/client/settings-scope.ts +298 -250
- package/src/client/sidebar-entry.ts +148 -102
- package/src/client/templates.module.css +453 -453
- package/src/engine.ts +520 -464
- package/src/gallery-store.ts +286 -280
- package/src/generation-runtime.ts +79 -48
- package/src/history-store.ts +250 -238
- package/src/image-format.ts +11 -0
- package/src/image-models.ts +19 -19
- package/src/index.ts +318 -212
- package/src/model-catalog.ts +115 -0
- package/src/presets.ts +71 -0
- package/src/prompt-enhancer.ts +137 -79
- package/src/protocol.ts +338 -253
- package/src/routes.ts +916 -738
- package/src/task-queue.ts +113 -103
- package/src/templates/cases.json +10196 -10196
- package/src/templates-store.ts +278 -278
- package/src/updater.ts +117 -117
package/src/client/controller.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image-gen panel controller: the single owner of the panel's open/closed
|
|
3
|
-
* state. Framework-free so the DOM mounts and the React panel share one tiny
|
|
4
|
-
* subscription surface. The state lives only for the browser session.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** Immutable controller snapshot for UI subscriptions. */
|
|
8
|
-
export interface ImageGenControllerSnapshot {
|
|
9
|
-
panelOpen: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** The panel state owner the sidebar entry toggles and the view renders from. */
|
|
13
|
-
export class ImageGenController {
|
|
14
|
-
private panelOpen = false
|
|
15
|
-
private listeners = new Set<() => void>()
|
|
16
|
-
|
|
17
|
-
getSnapshot(): ImageGenControllerSnapshot {
|
|
18
|
-
return { panelOpen: this.panelOpen }
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
subscribe(fn: () => void): () => void {
|
|
22
|
-
this.listeners.add(fn)
|
|
23
|
-
return () => { this.listeners.delete(fn) }
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
open(): void {
|
|
27
|
-
if (this.panelOpen) return
|
|
28
|
-
this.panelOpen = true
|
|
29
|
-
this.notify()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
close(): void {
|
|
33
|
-
if (!this.panelOpen) return
|
|
34
|
-
this.panelOpen = false
|
|
35
|
-
this.notify()
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
toggle(): void {
|
|
39
|
-
if (this.panelOpen) this.close()
|
|
40
|
-
else this.open()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private notify(): void {
|
|
44
|
-
for (const fn of [...this.listeners]) fn()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Image-gen panel controller: the single owner of the panel's open/closed
|
|
3
|
+
* state. Framework-free so the DOM mounts and the React panel share one tiny
|
|
4
|
+
* subscription surface. The state lives only for the browser session.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Immutable controller snapshot for UI subscriptions. */
|
|
8
|
+
export interface ImageGenControllerSnapshot {
|
|
9
|
+
panelOpen: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The panel state owner the sidebar entry toggles and the view renders from. */
|
|
13
|
+
export class ImageGenController {
|
|
14
|
+
private panelOpen = false
|
|
15
|
+
private listeners = new Set<() => void>()
|
|
16
|
+
|
|
17
|
+
getSnapshot(): ImageGenControllerSnapshot {
|
|
18
|
+
return { panelOpen: this.panelOpen }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
subscribe(fn: () => void): () => void {
|
|
22
|
+
this.listeners.add(fn)
|
|
23
|
+
return () => { this.listeners.delete(fn) }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
open(): void {
|
|
27
|
+
if (this.panelOpen) return
|
|
28
|
+
this.panelOpen = true
|
|
29
|
+
this.notify()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
close(): void {
|
|
33
|
+
if (!this.panelOpen) return
|
|
34
|
+
this.panelOpen = false
|
|
35
|
+
this.notify()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toggle(): void {
|
|
39
|
+
if (this.panelOpen) this.close()
|
|
40
|
+
else this.open()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private notify(): void {
|
|
44
|
+
for (const fn of [...this.listeners]) fn()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'
|
|
2
|
+
import type { ConversationController, IConversation } from '@deepseek-ai/dsh-client-ui-conversation/client'
|
|
3
|
+
import type { SessionId } from '@deepseek-ai/dsh-client-runtime/client'
|
|
4
|
+
|
|
5
|
+
/** Document event used to bridge chat tool results into the image workspace. */
|
|
6
|
+
export const CHAT_IMAGE_EVENT = 'dsh-imagegen:chat-images'
|
|
7
|
+
|
|
8
|
+
export interface ChatImageEventDetail {
|
|
9
|
+
sessionId: SessionId
|
|
10
|
+
refs: readonly ImageAttachmentRef[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Composer-facing extension of the narrower public conversation interface. */
|
|
14
|
+
export type ConversationService = IConversation & Pick<ConversationController, 'createDraftImages' | 'releaseDraftImages'>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** CSS Modules type shim (the bundle inlines the compiled class map). */
|
|
2
|
-
declare module '*.module.css' {
|
|
3
|
-
const classes: Record<string, string>
|
|
4
|
-
export default classes
|
|
5
|
-
}
|
|
1
|
+
/** CSS Modules type shim (the bundle inlines the compiled class map). */
|
|
2
|
+
declare module '*.module.css' {
|
|
3
|
+
const classes: Record<string, string>
|
|
4
|
+
export default classes
|
|
5
|
+
}
|
package/src/client/helpers.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared panel helpers: the active-dictionary pick (document-language based,
|
|
3
|
-
* dsh-ssh precedent) bound to the dsh-imagegen interpolator, plus a small
|
|
4
|
-
* error-message extractor. All copy stays in the locale dictionaries.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { en, zh, type ImageGenKey } from './locales.ts'
|
|
8
|
-
|
|
9
|
-
/** Template values accepted by the interpolator. */
|
|
10
|
-
export type TranslateValues = Record<string, string | number>
|
|
11
|
-
|
|
12
|
-
/** Active dictionary, picked by the document language at call time. */
|
|
13
|
-
export function dictionary(): Record<string, string> {
|
|
14
|
-
const lang = typeof document !== 'undefined' ? document.documentElement.lang : 'zh'
|
|
15
|
-
return lang.toLowerCase().startsWith('en') ? { ...en } : { ...zh }
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Translate a key with optional {name} template params (current language). */
|
|
19
|
-
export function tt(key: ImageGenKey, values?: TranslateValues): string {
|
|
20
|
-
const text = dictionary()[key] ?? key
|
|
21
|
-
if (values === undefined) return text
|
|
22
|
-
let rendered = text
|
|
23
|
-
for (const [name, value] of Object.entries(values)) {
|
|
24
|
-
rendered = rendered.replaceAll(`{${name}}`, String(value))
|
|
25
|
-
}
|
|
26
|
-
return rendered
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Human-readable error text from an unknown thrown value. */
|
|
30
|
-
export function errorMessage(error: unknown): string {
|
|
31
|
-
if (error instanceof Error) return error.message
|
|
32
|
-
return String(error)
|
|
33
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Shared panel helpers: the active-dictionary pick (document-language based,
|
|
3
|
+
* dsh-ssh precedent) bound to the dsh-imagegen interpolator, plus a small
|
|
4
|
+
* error-message extractor. All copy stays in the locale dictionaries.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { en, zh, type ImageGenKey } from './locales.ts'
|
|
8
|
+
|
|
9
|
+
/** Template values accepted by the interpolator. */
|
|
10
|
+
export type TranslateValues = Record<string, string | number>
|
|
11
|
+
|
|
12
|
+
/** Active dictionary, picked by the document language at call time. */
|
|
13
|
+
export function dictionary(): Record<string, string> {
|
|
14
|
+
const lang = typeof document !== 'undefined' ? document.documentElement.lang : 'zh'
|
|
15
|
+
return lang.toLowerCase().startsWith('en') ? { ...en } : { ...zh }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Translate a key with optional {name} template params (current language). */
|
|
19
|
+
export function tt(key: ImageGenKey, values?: TranslateValues): string {
|
|
20
|
+
const text = dictionary()[key] ?? key
|
|
21
|
+
if (values === undefined) return text
|
|
22
|
+
let rendered = text
|
|
23
|
+
for (const [name, value] of Object.entries(values)) {
|
|
24
|
+
rendered = rendered.replaceAll(`{${name}}`, String(value))
|
|
25
|
+
}
|
|
26
|
+
return rendered
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Human-readable error text from an unknown thrown value. */
|
|
30
|
+
export function errorMessage(error: unknown): string {
|
|
31
|
+
if (error instanceof Error) return error.message
|
|
32
|
+
return String(error)
|
|
33
|
+
}
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: 7px;
|
|
5
|
-
margin: 4px 0;
|
|
6
|
-
padding: 8px 10px 10px;
|
|
7
|
-
border: 1px solid var(--dsw-alias-border-l1);
|
|
8
|
-
border-radius: 8px;
|
|
9
|
-
background: var(--dsw-alias-bg-layer-1);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.header {
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
gap: 7px;
|
|
16
|
-
min-height: 20px;
|
|
17
|
-
color: var(--dsw-alias-label-secondary);
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.icon {
|
|
22
|
-
color: var(--dsw-alias-brand-primary);
|
|
23
|
-
font-size: 15px;
|
|
24
|
-
line-height: 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.status {
|
|
28
|
-
margin-left: auto;
|
|
29
|
-
color: var(--dsw-alias-label-tertiary);
|
|
30
|
-
font-size: 11px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.message,
|
|
34
|
-
.loading,
|
|
35
|
-
.error {
|
|
36
|
-
margin: 0;
|
|
37
|
-
color: var(--dsw-alias-label-tertiary);
|
|
38
|
-
font-size: 12px;
|
|
39
|
-
line-height: 1.5;
|
|
40
|
-
overflow-wrap: anywhere;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.images {
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-wrap: wrap;
|
|
46
|
-
gap: 8px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.imageLink {
|
|
50
|
-
display: block;
|
|
51
|
-
max-width: min(280px, 100%);
|
|
52
|
-
overflow: hidden;
|
|
53
|
-
border: 1px solid var(--dsw-alias-border-l1);
|
|
54
|
-
border-radius: 6px;
|
|
55
|
-
background: var(--dsw-alias-bg-base);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.imageLink:hover {
|
|
59
|
-
border-color: var(--dsw-alias-brand-primary);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.image {
|
|
63
|
-
display: block;
|
|
64
|
-
width: auto;
|
|
65
|
-
max-width: 280px;
|
|
66
|
-
height: auto;
|
|
67
|
-
max-height: 220px;
|
|
68
|
-
object-fit: contain;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.error {
|
|
72
|
-
color: var(--dsw-alias-state-error-primary);
|
|
73
|
-
}
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 7px;
|
|
5
|
+
margin: 4px 0;
|
|
6
|
+
padding: 8px 10px 10px;
|
|
7
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
8
|
+
border-radius: 8px;
|
|
9
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.header {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 7px;
|
|
16
|
+
min-height: 20px;
|
|
17
|
+
color: var(--dsw-alias-label-secondary);
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.icon {
|
|
22
|
+
color: var(--dsw-alias-brand-primary);
|
|
23
|
+
font-size: 15px;
|
|
24
|
+
line-height: 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.status {
|
|
28
|
+
margin-left: auto;
|
|
29
|
+
color: var(--dsw-alias-label-tertiary);
|
|
30
|
+
font-size: 11px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.message,
|
|
34
|
+
.loading,
|
|
35
|
+
.error {
|
|
36
|
+
margin: 0;
|
|
37
|
+
color: var(--dsw-alias-label-tertiary);
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
line-height: 1.5;
|
|
40
|
+
overflow-wrap: anywhere;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.images {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-wrap: wrap;
|
|
46
|
+
gap: 8px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.imageLink {
|
|
50
|
+
display: block;
|
|
51
|
+
max-width: min(280px, 100%);
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
54
|
+
border-radius: 6px;
|
|
55
|
+
background: var(--dsw-alias-bg-base);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.imageLink:hover {
|
|
59
|
+
border-color: var(--dsw-alias-brand-primary);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.image {
|
|
63
|
+
display: block;
|
|
64
|
+
width: auto;
|
|
65
|
+
max-width: 280px;
|
|
66
|
+
height: auto;
|
|
67
|
+
max-height: 220px;
|
|
68
|
+
object-fit: contain;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.error {
|
|
72
|
+
color: var(--dsw-alias-state-error-primary);
|
|
73
|
+
}
|