@dsh-plus/image-studio 0.1.11 → 0.1.12
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/lib/client.js +46 -9
- package/package.json +2 -2
- package/src/client/card.tsx +10 -4
- package/src/client/client.ts +10 -12
- package/src/client/i18n.ts +2 -0
- package/src/ns.ts +5 -2
package/lib/client.js
CHANGED
|
@@ -337,6 +337,35 @@ window.__ModuleLoader__.load({
|
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
//#endregion
|
|
340
|
+
//#region ../shared/src/client/config-slots.ts
|
|
341
|
+
/** dsh-plus 聚合 bundle 的包名(各插件 row 均经其补丁层插入 profile)。 */
|
|
342
|
+
const DSH_PLUS_BUNDLE = "@dsh-plus/bundle-main";
|
|
343
|
+
/**
|
|
344
|
+
* 把一张配置卡片同时注册进 legacy 与新版三个槽位。
|
|
345
|
+
* 任一槽位在当前 dsh 版本未声明时对应 inject 挂起等待,版本不命中即 no-op。
|
|
346
|
+
*/
|
|
347
|
+
function injectPluginConfigCard(slots, reg) {
|
|
348
|
+
const base = {
|
|
349
|
+
locale: reg.ns,
|
|
350
|
+
inject: reg.inject
|
|
351
|
+
};
|
|
352
|
+
slots.inject("settings.plugin.item", () => slots.register({
|
|
353
|
+
name: "settings.plugin.item",
|
|
354
|
+
key: reg.ns,
|
|
355
|
+
...base
|
|
356
|
+
}, reg.component));
|
|
357
|
+
slots.inject("plugins.row.config", () => slots.register({
|
|
358
|
+
name: "plugins.row.config",
|
|
359
|
+
key: `${DSH_PLUS_BUNDLE}#${reg.rowId}`,
|
|
360
|
+
...base
|
|
361
|
+
}, reg.component));
|
|
362
|
+
slots.inject("plugins.bundle.config", () => slots.register({
|
|
363
|
+
name: "plugins.bundle.config",
|
|
364
|
+
key: reg.pkg,
|
|
365
|
+
...base
|
|
366
|
+
}, reg.component));
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
340
369
|
//#region ../shared/src/client/fetch.ts
|
|
341
370
|
async function parse(res, guard) {
|
|
342
371
|
const body = await res.json();
|
|
@@ -586,8 +615,11 @@ ${extra}
|
|
|
586
615
|
//#region src/ns.ts
|
|
587
616
|
/**
|
|
588
617
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
589
|
-
* 服务端直接以字面量注册(settings
|
|
590
|
-
*
|
|
618
|
+
* 服务端直接以字面量注册(0.1.2-alpha.2 起 dsh-settings 对命名空间做编译期
|
|
619
|
+
* 语法校验,见 config.ts);浏览器半把它作为配置卡片的注册键
|
|
620
|
+
* (legacy settings.plugin.item keyed 槽位按「卡片编辑的 settings 命名空间」
|
|
621
|
+
* 分发;0.1.6-alpha.2 起改挂插件页 row/bundle config,见 shared/config-slots),
|
|
622
|
+
* 同一字面量两处共用,防止漂移。
|
|
591
623
|
* @module image-studio/ns
|
|
592
624
|
*/
|
|
593
625
|
const SETTINGS_NS = "dsh-plus-image-studio";
|
|
@@ -992,7 +1024,8 @@ ${extra}
|
|
|
992
1024
|
//#endregion
|
|
993
1025
|
//#region src/client/card.tsx
|
|
994
1026
|
/**
|
|
995
|
-
* 配置卡片(
|
|
1027
|
+
* 配置卡片(injectPluginConfigCard 三槽位,legacy key = settings 命名空间,
|
|
1028
|
+
* 0.1.6-alpha.2 起为插件页 row/bundle config,view 分发 summary/page):
|
|
996
1029
|
* 三组预设(提供商/参数/提示词)+ 高级项(并发/超时/代理/画廊上限)的
|
|
997
1030
|
* staged draft 编辑;提供商预设逐条附 API Key 管理(凭据端点,值不回显)。
|
|
998
1031
|
* JSON 字段(extraHeaders/paramSpecs)以文本镜像编辑,保存时解析 +
|
|
@@ -1131,7 +1164,7 @@ ${extra}
|
|
|
1131
1164
|
const { t, scope, api } = props;
|
|
1132
1165
|
const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
|
|
1133
1166
|
const value = snapshot.value;
|
|
1134
|
-
const [open, setOpen] = (0, react.useState)(
|
|
1167
|
+
const [open, setOpen] = (0, react.useState)(props.view === "page");
|
|
1135
1168
|
const [draft, setDraft] = (0, react.useState)(null);
|
|
1136
1169
|
const [baseline, setBaseline] = (0, react.useState)("");
|
|
1137
1170
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
@@ -1150,6 +1183,7 @@ ${extra}
|
|
|
1150
1183
|
setBaseline(JSON.stringify(initial));
|
|
1151
1184
|
}, [value, draft]);
|
|
1152
1185
|
const dirty = (0, react.useMemo)(() => draft !== null && JSON.stringify(draft) !== baseline, [draft, baseline]);
|
|
1186
|
+
if (props.view === "summary") return t("card.summary");
|
|
1153
1187
|
if (value === void 0 || draft === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
1154
1188
|
className: "imsc-card",
|
|
1155
1189
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -1610,6 +1644,7 @@ ${extra}
|
|
|
1610
1644
|
"gallery.edit": "二次编辑",
|
|
1611
1645
|
"card.title": "图像工作室",
|
|
1612
1646
|
"card.description": "文生图/图生图:提供商与 API Key、参数/提示词预设",
|
|
1647
|
+
"card.summary": "文生图/图生图:提供商与 API Key、参数/提示词预设。",
|
|
1613
1648
|
"card.providers": "提供商预设",
|
|
1614
1649
|
"card.prompts": "提示词预设",
|
|
1615
1650
|
"card.params": "参数预设",
|
|
@@ -1726,6 +1761,7 @@ ${extra}
|
|
|
1726
1761
|
"gallery.edit": "Edit again",
|
|
1727
1762
|
"card.title": "Image Studio",
|
|
1728
1763
|
"card.description": "Text/Image-to-image: providers & API keys, param/prompt presets",
|
|
1764
|
+
"card.summary": "Text/Image-to-image: providers & API keys, param/prompt presets.",
|
|
1729
1765
|
"card.providers": "Provider presets",
|
|
1730
1766
|
"card.prompts": "Prompt presets",
|
|
1731
1767
|
"card.params": "Parameter presets",
|
|
@@ -4079,16 +4115,17 @@ ${extra}
|
|
|
4079
4115
|
api
|
|
4080
4116
|
})
|
|
4081
4117
|
}, StudioPanel)), "image-studio: overlay slot");
|
|
4082
|
-
c.slots
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4118
|
+
injectPluginConfigCard(c.slots, {
|
|
4119
|
+
ns: SETTINGS_NS,
|
|
4120
|
+
rowId: "dsh-plus-image-studio",
|
|
4121
|
+
pkg: PLUGIN_ID,
|
|
4122
|
+
component: StudioConfigCard,
|
|
4086
4123
|
inject: () => ({
|
|
4087
4124
|
t,
|
|
4088
4125
|
scope,
|
|
4089
4126
|
api
|
|
4090
4127
|
})
|
|
4091
|
-
}
|
|
4128
|
+
});
|
|
4092
4129
|
c.effect(() => () => {
|
|
4093
4130
|
panelTag?.remove();
|
|
4094
4131
|
cardTag?.remove();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/image-studio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: 图像工作室——OpenAI Images 协议文生图/图生图,全参数开关化,双预设体系,并发生图任务与可二次编辑画廊",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"https-proxy-agent": "^9.1.0",
|
|
23
|
-
"@dsh-plus/shared": "0.1.
|
|
23
|
+
"@dsh-plus/shared": "0.1.19"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@deepseek-ai/cordis": "^4.0.2",
|
package/src/client/card.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 配置卡片(
|
|
2
|
+
* 配置卡片(injectPluginConfigCard 三槽位,legacy key = settings 命名空间,
|
|
3
|
+
* 0.1.6-alpha.2 起为插件页 row/bundle config,view 分发 summary/page):
|
|
3
4
|
* 三组预设(提供商/参数/提示词)+ 高级项(并发/超时/代理/画廊上限)的
|
|
4
5
|
* staged draft 编辑;提供商预设逐条附 API Key 管理(凭据端点,值不回显)。
|
|
5
6
|
* JSON 字段(extraHeaders/paramSpecs)以文本镜像编辑,保存时解析 +
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
type CardStatusState,
|
|
12
13
|
IDLE_STATUS,
|
|
13
14
|
type NamespaceSettingsApi,
|
|
15
|
+
type PluginConfigViewProps,
|
|
14
16
|
type Scope,
|
|
15
17
|
TextField,
|
|
16
18
|
} from '@dsh-plus/shared/client'
|
|
@@ -22,7 +24,7 @@ import { validateParamSpecs } from '../params/spec.ts'
|
|
|
22
24
|
import { fetchCredentialStatus, fetchProviders, setCredential, unsetCredential } from './api.ts'
|
|
23
25
|
import type { Translate } from './i18n.ts'
|
|
24
26
|
|
|
25
|
-
export interface CardProps {
|
|
27
|
+
export interface CardProps extends PluginConfigViewProps {
|
|
26
28
|
t: Translate
|
|
27
29
|
scope: Scope
|
|
28
30
|
api: NamespaceSettingsApi
|
|
@@ -197,14 +199,15 @@ function CredentialRow(props: { t: Translate; presetId: string; disabled: boolea
|
|
|
197
199
|
)
|
|
198
200
|
}
|
|
199
201
|
|
|
200
|
-
export function StudioConfigCard(props: CardProps): ReactElement | null {
|
|
202
|
+
export function StudioConfigCard(props: CardProps): ReactElement | string | null {
|
|
201
203
|
const { t, scope, api } = props
|
|
202
204
|
const snapshot = useSyncExternalStore(
|
|
203
205
|
(listener: () => void) => scope.subscribe(listener),
|
|
204
206
|
() => scope.getSnapshot(),
|
|
205
207
|
)
|
|
206
208
|
const value = snapshot.value as ImageStudioConfig | undefined
|
|
207
|
-
|
|
209
|
+
// 0.1.6-alpha.2 插件页 page 视图为表单落地页,默认展开;旧槽位无 view,保持折叠。
|
|
210
|
+
const [open, setOpen] = useState(props.view === 'page')
|
|
208
211
|
const [draft, setDraft] = useState<Draft | null>(null)
|
|
209
212
|
const [baseline, setBaseline] = useState('')
|
|
210
213
|
const [saving, setSaving] = useState(false)
|
|
@@ -229,6 +232,9 @@ export function StudioConfigCard(props: CardProps): ReactElement | null {
|
|
|
229
232
|
[draft, baseline],
|
|
230
233
|
)
|
|
231
234
|
|
|
235
|
+
// 插件页 summary 视图只出一行简介(hooks 已全部落定,可安全提前返回)。
|
|
236
|
+
if (props.view === 'summary') return t('card.summary')
|
|
237
|
+
|
|
232
238
|
if (value === undefined || draft === null) {
|
|
233
239
|
return (
|
|
234
240
|
<li className="imsc-card">
|
package/src/client/client.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* 浏览器半入口:
|
|
3
3
|
* - sidebar.footer.action:侧栏底部入口按钮(与文件/终端入口 flex 等分行宽);
|
|
4
4
|
* - shell.overlay:图像工作室面板(文生图/图生图/画廊 + 任务条);
|
|
5
|
-
* -
|
|
5
|
+
* - 配置卡片:injectPluginConfigCard 三槽位(三组预设 + 凭据 + 高级项;
|
|
6
|
+
* legacy settings.plugin.item 与 0.1.6-alpha.2 插件页 row/bundle config)。
|
|
6
7
|
* 模式与 web-files/web-terminal 一致:CJS factory 产物、data-plugin-css 样式
|
|
7
8
|
* 约定、slot 失配静默降级;配置读写经 ctx.remote.settings 直连(远程域名可用)。
|
|
8
9
|
* @module @dsh-plus/image-studio/client
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
createNamespaceApi,
|
|
14
15
|
createSettingsScope,
|
|
15
16
|
injectCardStyle,
|
|
17
|
+
injectPluginConfigCard,
|
|
16
18
|
type ScopeHostContext,
|
|
17
19
|
} from '@dsh-plus/shared/client'
|
|
18
20
|
|
|
@@ -88,17 +90,13 @@ export function apply(ctx: Context): void {
|
|
|
88
90
|
),
|
|
89
91
|
'image-studio: overlay slot',
|
|
90
92
|
)
|
|
91
|
-
c.slots
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
StudioConfigCard,
|
|
100
|
-
),
|
|
101
|
-
)
|
|
93
|
+
injectPluginConfigCard(c.slots, {
|
|
94
|
+
ns: SETTINGS_NS,
|
|
95
|
+
rowId: 'dsh-plus-image-studio',
|
|
96
|
+
pkg: PLUGIN_ID,
|
|
97
|
+
component: StudioConfigCard,
|
|
98
|
+
inject: () => ({ t, scope, api }),
|
|
99
|
+
})
|
|
102
100
|
c.effect(
|
|
103
101
|
() => () => {
|
|
104
102
|
panelTag?.remove()
|
package/src/client/i18n.ts
CHANGED
|
@@ -96,6 +96,7 @@ export const zh = {
|
|
|
96
96
|
// 配置卡片
|
|
97
97
|
'card.title': '图像工作室',
|
|
98
98
|
'card.description': '文生图/图生图:提供商与 API Key、参数/提示词预设',
|
|
99
|
+
'card.summary': '文生图/图生图:提供商与 API Key、参数/提示词预设。',
|
|
99
100
|
'card.providers': '提供商预设',
|
|
100
101
|
'card.prompts': '提示词预设',
|
|
101
102
|
'card.params': '参数预设',
|
|
@@ -219,6 +220,7 @@ export const en: Record<DictKey, string> = {
|
|
|
219
220
|
'gallery.edit': 'Edit again',
|
|
220
221
|
'card.title': 'Image Studio',
|
|
221
222
|
'card.description': 'Text/Image-to-image: providers & API keys, param/prompt presets',
|
|
223
|
+
'card.summary': 'Text/Image-to-image: providers & API keys, param/prompt presets.',
|
|
222
224
|
'card.providers': 'Provider presets',
|
|
223
225
|
'card.prompts': 'Prompt presets',
|
|
224
226
|
'card.params': 'Parameter presets',
|
package/src/ns.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
3
|
-
* 服务端直接以字面量注册(settings
|
|
4
|
-
*
|
|
3
|
+
* 服务端直接以字面量注册(0.1.2-alpha.2 起 dsh-settings 对命名空间做编译期
|
|
4
|
+
* 语法校验,见 config.ts);浏览器半把它作为配置卡片的注册键
|
|
5
|
+
* (legacy settings.plugin.item keyed 槽位按「卡片编辑的 settings 命名空间」
|
|
6
|
+
* 分发;0.1.6-alpha.2 起改挂插件页 row/bundle config,见 shared/config-slots),
|
|
7
|
+
* 同一字面量两处共用,防止漂移。
|
|
5
8
|
* @module image-studio/ns
|
|
6
9
|
*/
|
|
7
10
|
export const SETTINGS_NS = 'dsh-plus-image-studio'
|