@dsh-plus/image-studio 0.1.27 → 0.1.29
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 +1 -1
- package/lib/index.d.ts +3 -7
- package/lib/index.js +9 -20
- package/package.json +2 -2
- package/src/config.ts +3 -3
- package/src/dto.ts +0 -4
- package/src/ns.ts +1 -1
- package/src/service.ts +10 -17
package/lib/client.js
CHANGED
|
@@ -635,7 +635,7 @@ ${extra}
|
|
|
635
635
|
//#region src/ns.ts
|
|
636
636
|
/**
|
|
637
637
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
638
|
-
* 服务端直接以字面量注册(
|
|
638
|
+
* 服务端直接以字面量注册(dsh-settings 对命名空间做编译期
|
|
639
639
|
* 语法校验,见 config.ts);浏览器半把它作为配置卡片的注册键
|
|
640
640
|
* (插件页配置卡片挂在 row/bundle config 槽位上,与命名空间解耦,
|
|
641
641
|
* 见 shared/config-slots),
|
package/lib/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
46
46
|
galleryMaxItems: z<number, number, "volatile-defined">;
|
|
47
47
|
uploadTtlHours: z<number, number, "volatile-defined">;
|
|
48
48
|
}>>, "plain">;
|
|
49
|
-
/** 活动字段形态(
|
|
49
|
+
/** 活动字段形态(loader 解析产物:volatile 字段为活动引用)。 */
|
|
50
50
|
type ImageStudioConfigFields = Schemastery.TypeT<typeof Config>;
|
|
51
51
|
/** 平面配置形态(消费面的读取形态,由活动引用解包得到)。 */
|
|
52
52
|
type ImageStudioConfig = UnwrapVolatile<ImageStudioConfigFields>;
|
|
@@ -147,10 +147,6 @@ interface GenerateRequest {
|
|
|
147
147
|
sources?: SourceRef[];
|
|
148
148
|
/** 可选遮罩(官方要求 PNG;与源图同一引用形态)。 */
|
|
149
149
|
mask?: SourceRef;
|
|
150
|
-
/** @deprecated 旧客户端兼容:等价于 kind='gallery' 的 sources。 */
|
|
151
|
-
sourceIds?: string[];
|
|
152
|
-
/** @deprecated 旧客户端兼容:等价于 kind='gallery' 的 mask。 */
|
|
153
|
-
maskId?: string;
|
|
154
150
|
}
|
|
155
151
|
/** 任务记录 wire 视图。 */
|
|
156
152
|
interface TaskWire {
|
|
@@ -247,9 +243,9 @@ declare class ImageStudioService extends Service {
|
|
|
247
243
|
* 参数预设 + 覆盖 → 归一化参数表;sources/mask 引用 → 输入图字节。
|
|
248
244
|
*/
|
|
249
245
|
private prepareTask;
|
|
250
|
-
/**
|
|
246
|
+
/** 源图引用规范化(缺省空数组;引用形态统一在 assertRef 收窄)。 */
|
|
251
247
|
private sourceRefsOf;
|
|
252
|
-
/**
|
|
248
|
+
/** 遮罩引用规范化(缺省无遮罩)。 */
|
|
253
249
|
private maskRefOf;
|
|
254
250
|
/** 引用形态校验(请求体来自浏览器,kind 封闭集合 + id uuid 形态)。 */
|
|
255
251
|
private assertRef;
|
package/lib/index.js
CHANGED
|
@@ -1487,27 +1487,16 @@ var ImageStudioService = class extends Service {
|
|
|
1487
1487
|
sourceUploads: sources.uploadIds
|
|
1488
1488
|
};
|
|
1489
1489
|
}
|
|
1490
|
-
/**
|
|
1490
|
+
/** 源图引用规范化(缺省空数组;引用形态统一在 assertRef 收窄)。 */
|
|
1491
1491
|
sourceRefsOf(request) {
|
|
1492
|
-
if (request.sources
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
if (!Array.isArray(legacy)) throw new ImageStudioError("invalid-request", "sourceIds 必须是数组");
|
|
1498
|
-
return legacy.map((id) => this.assertRef({
|
|
1499
|
-
kind: "gallery",
|
|
1500
|
-
id
|
|
1501
|
-
}));
|
|
1502
|
-
}
|
|
1503
|
-
/** 遮罩引用规范化(mask 优先;旧 maskId 等价于 gallery 引用)。 */
|
|
1492
|
+
if (request.sources === void 0) return [];
|
|
1493
|
+
if (!Array.isArray(request.sources)) throw new ImageStudioError("invalid-request", "sources 必须是数组");
|
|
1494
|
+
return request.sources.map((ref) => this.assertRef(ref));
|
|
1495
|
+
}
|
|
1496
|
+
/** 遮罩引用规范化(缺省无遮罩)。 */
|
|
1504
1497
|
maskRefOf(request) {
|
|
1505
|
-
if (request.mask
|
|
1506
|
-
|
|
1507
|
-
return this.assertRef({
|
|
1508
|
-
kind: "gallery",
|
|
1509
|
-
id: request.maskId
|
|
1510
|
-
});
|
|
1498
|
+
if (request.mask === void 0) return null;
|
|
1499
|
+
return this.assertRef(request.mask);
|
|
1511
1500
|
}
|
|
1512
1501
|
/** 引用形态校验(请求体来自浏览器,kind 封闭集合 + id uuid 形态)。 */
|
|
1513
1502
|
assertRef(ref) {
|
|
@@ -1734,7 +1723,7 @@ function stripHostParams(params) {
|
|
|
1734
1723
|
//#region src/config.ts
|
|
1735
1724
|
/**
|
|
1736
1725
|
* 配置单一事实源:cordis 行级 Config(组合默认)与 settings namespace
|
|
1737
|
-
*
|
|
1726
|
+
* (用户层=profile 行级覆盖层 cordis.patch.yml,热生效)共用同一 schemastery schema。
|
|
1738
1727
|
* 三组纯用户配置:提示词预设 / 参数预设 / 提供商预设(API key 不在此,
|
|
1739
1728
|
* 走 credentials,引用名由 preset id 派生)。
|
|
1740
1729
|
* @module image-studio/config
|
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.29",
|
|
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.37"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@deepseek-ai/cordis": "^4.0.5-alpha.1",
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 配置单一事实源:cordis 行级 Config(组合默认)与 settings namespace
|
|
3
|
-
*
|
|
3
|
+
* (用户层=profile 行级覆盖层 cordis.patch.yml,热生效)共用同一 schemastery schema。
|
|
4
4
|
* 三组纯用户配置:提示词预设 / 参数预设 / 提供商预设(API key 不在此,
|
|
5
5
|
* 走 credentials,引用名由 preset id 派生)。
|
|
6
6
|
* @module image-studio/config
|
|
@@ -72,7 +72,7 @@ const ProviderPreset: z<ProviderPresetEntry, ProviderPresetEntry> = z.object({
|
|
|
72
72
|
extraHeaders: z.dict(z.string()).description('附加请求头(部分中转需要)').default({}),
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
//
|
|
75
|
+
// 全字段 `.volatile()`——条目进入 settings describe 视图(卡片可读写),
|
|
76
76
|
// loader 原位提交活动引用,current() 现取即热。
|
|
77
77
|
export const Config = z.object({
|
|
78
78
|
promptPresets: z.array(PromptPreset).description('提示词预设').default([]).volatile(),
|
|
@@ -109,7 +109,7 @@ export const Config = z.object({
|
|
|
109
109
|
.volatile(),
|
|
110
110
|
})
|
|
111
111
|
|
|
112
|
-
/** 活动字段形态(
|
|
112
|
+
/** 活动字段形态(loader 解析产物:volatile 字段为活动引用)。 */
|
|
113
113
|
export type ImageStudioConfigFields = Schemastery.TypeT<typeof Config>
|
|
114
114
|
/** 平面配置形态(消费面的读取形态,由活动引用解包得到)。 */
|
|
115
115
|
export type ImageStudioConfig = UnwrapVolatile<ImageStudioConfigFields>
|
package/src/dto.ts
CHANGED
|
@@ -43,10 +43,6 @@ export interface GenerateRequest {
|
|
|
43
43
|
sources?: SourceRef[]
|
|
44
44
|
/** 可选遮罩(官方要求 PNG;与源图同一引用形态)。 */
|
|
45
45
|
mask?: SourceRef
|
|
46
|
-
/** @deprecated 旧客户端兼容:等价于 kind='gallery' 的 sources。 */
|
|
47
|
-
sourceIds?: string[]
|
|
48
|
-
/** @deprecated 旧客户端兼容:等价于 kind='gallery' 的 mask。 */
|
|
49
|
-
maskId?: string
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
/** 任务记录 wire 视图。 */
|
package/src/ns.ts
CHANGED
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* image-studio 服务主体:
|
|
3
|
-
* - 配置:
|
|
3
|
+
* - 配置:volatile 活动引用(三组预设 + 并发/超时/代理/画廊上限/
|
|
4
4
|
* 上传保留时长;loader 原位提交热生效);
|
|
5
5
|
* - TaskRunner 并发生图:提交即排队,成功自动入画廊(元数据 + 图片落盘);
|
|
6
6
|
* - 提供商预设按 id 即时 resolve credentials(不缓存);
|
|
@@ -82,7 +82,7 @@ export class ImageStudioService extends Service {
|
|
|
82
82
|
|
|
83
83
|
constructor(ctx: ContextT, config: ImageStudioConfig | ImageStudioConfigFields) {
|
|
84
84
|
super(ctx, 'imageStudio')
|
|
85
|
-
//
|
|
85
|
+
// 替代 installSection/setSource:活动引用原位提交,现取即热。
|
|
86
86
|
this.current = () => unwrapVolatile(config)
|
|
87
87
|
this.log = (message) => ctx.logger('image-studio').warn(message)
|
|
88
88
|
this.pruning = null
|
|
@@ -259,26 +259,19 @@ export class ImageStudioService extends Service {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
/**
|
|
262
|
+
/** 源图引用规范化(缺省空数组;引用形态统一在 assertRef 收窄)。 */
|
|
263
263
|
private sourceRefsOf(request: GenerateRequest): SourceRef[] {
|
|
264
|
-
if (request.sources
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
return request.sources.map((ref) => this.assertRef(ref))
|
|
269
|
-
}
|
|
270
|
-
const legacy = request.sourceIds ?? []
|
|
271
|
-
if (!Array.isArray(legacy)) {
|
|
272
|
-
throw new ImageStudioError('invalid-request', 'sourceIds 必须是数组')
|
|
264
|
+
if (request.sources === undefined) return []
|
|
265
|
+
if (!Array.isArray(request.sources)) {
|
|
266
|
+
throw new ImageStudioError('invalid-request', 'sources 必须是数组')
|
|
273
267
|
}
|
|
274
|
-
return
|
|
268
|
+
return request.sources.map((ref) => this.assertRef(ref))
|
|
275
269
|
}
|
|
276
270
|
|
|
277
|
-
/**
|
|
271
|
+
/** 遮罩引用规范化(缺省无遮罩)。 */
|
|
278
272
|
private maskRefOf(request: GenerateRequest): SourceRef | null {
|
|
279
|
-
if (request.mask
|
|
280
|
-
|
|
281
|
-
return this.assertRef({ kind: 'gallery', id: request.maskId })
|
|
273
|
+
if (request.mask === undefined) return null
|
|
274
|
+
return this.assertRef(request.mask)
|
|
282
275
|
}
|
|
283
276
|
|
|
284
277
|
/** 引用形态校验(请求体来自浏览器,kind 封闭集合 + id uuid 形态)。 */
|