dsh-game-material-master 0.2.0 → 0.3.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/lib/wire.js CHANGED
@@ -16,6 +16,15 @@ const projectListSchema = z.object({ projects: z.array(jsonObject) });
16
16
  const saveConfigSchema = z.record(z.string(), z.unknown());
17
17
  const createProjectSchema = z.object({ name: z.string().optional() });
18
18
  const projectIdSchema = z.object({ projectId: z.string() });
19
+ /**
20
+ * 读项目:比 `projectIdSchema` 多一个 `lang`。
21
+ *
22
+ * 内置默认提示词存在宿主侧,而宿主没有 locale 服务,所以界面语言只能由浏览器半区带过来。
23
+ * **这个字段必须写进 schema**:typert 会按声明校验 payload,schema 里没有的键会被丢掉,
24
+ * 方法里 `input.lang` 永远是 undefined——表现就是「切了英文提示词还是中文」,
25
+ * 而且不报任何错(实测踩过)。
26
+ */
27
+ const getProjectSchema = z.object({ projectId: z.string(), lang: z.string().optional() });
19
28
  const renameSchema = z.object({ projectId: z.string(), name: z.string() });
20
29
  const uploadSchema = z.object({
21
30
  projectId: z.string(),
@@ -25,6 +34,8 @@ const uploadSchema = z.object({
25
34
  });
26
35
  const promptsSchema = z.object({
27
36
  projectId: z.string(),
37
+ /** 界面语言:「重置为默认」要重置成哪一国话的默认提示词(见 getProjectSchema)。 */
38
+ lang: z.string().optional(),
28
39
  images: z.record(z.string(), z.string()).optional(),
29
40
  video: z.string().optional(),
30
41
  /** 转圈模式的旋转视频提示词(整圈只有这一份)。 */
@@ -86,6 +97,25 @@ const resetTurnPicksSchema = z.object({
86
97
  });
87
98
  const cutTurnFramesSchema = z.object({ projectId: z.string(), keys: z.array(z.string()).optional() });
88
99
  const runKeysSchema = z.object({ projectId: z.string(), keys: z.array(z.string()).optional() });
100
+ /** 从一个方向的行走视频抽出候选帧。count 是候选张数(8~64),不是最终序列帧数。 */
101
+ const prepareFramePickSchema = z.object({
102
+ projectId: z.string(),
103
+ key: z.string(),
104
+ count: z.number().optional()
105
+ });
106
+ /** 拖动某一个输出帧的圆圈。slot 是输出帧序号,index 是候选帧下标。 */
107
+ const setFramePickSchema = z.object({
108
+ projectId: z.string(),
109
+ key: z.string(),
110
+ slot: z.number(),
111
+ index: z.number()
112
+ });
113
+ const setWalkPicksSchema = z.object({
114
+ projectId: z.string(),
115
+ key: z.string(),
116
+ picks: z.array(z.number())
117
+ });
118
+ const resetWalkPicksSchema = z.object({ projectId: z.string(), key: z.string() });
89
119
  const runVideosSchema = z.object({
90
120
  projectId: z.string(),
91
121
  keys: z.array(z.string()).optional(),
@@ -434,8 +464,79 @@ const setRigSemanticsSchema = z.object({
434
464
  * 深链接,只能由页面自己上报一次。见 src/links.ts。
435
465
  */
436
466
  const reportOriginSchema = z.object({ origin: z.string() });
437
- export const METHODS = [
438
- { method: "getConfig", result: configViewSchema },
467
+ // ── 地图地块生成(模块五)────────────────────────────────────────────────
468
+ //
469
+ // ⚠️ 每个字段都必须写进 schema:typert 按声明校验 payload,
470
+ // **schema 里没有的键会被静默丢掉**。`getTileProject` 的 `lang` 漏了的话,
471
+ // 表现就是「切了英文提示词还是中文」,而且不报任何错(AGENTS.md 的硬约束)。
472
+ const tileIdSchema = z.object({ projectId: z.string() });
473
+ const tileGetSchema = z.object({ projectId: z.string(), lang: z.string().optional() });
474
+ const createTileProjectSchema = z.object({
475
+ name: z.string().optional(),
476
+ style: z.string().optional(),
477
+ lang: z.string().optional(),
478
+ settings: z.record(z.string(), z.unknown()).optional()
479
+ });
480
+ const saveTileProjectSchema = z.object({
481
+ projectId: z.string(),
482
+ /** 界面语言:`resetItemsToDefault` 要重置成哪一国话的默认清单。 */
483
+ lang: z.string().optional(),
484
+ name: z.string().optional(),
485
+ style: z.string().optional(),
486
+ items: z.array(z.record(z.string(), z.unknown())).optional(),
487
+ settings: z.record(z.string(), z.unknown()).optional(),
488
+ resetItemsToDefault: z.boolean().optional()
489
+ });
490
+ const runTileItemsSchema = z.object({
491
+ projectId: z.string(),
492
+ /** 限定要生成的地块 key;不给就是全部。 */
493
+ keys: z.array(z.string()).optional()
494
+ });
495
+ const runTileItemSchema = z.object({
496
+ projectId: z.string(),
497
+ key: z.string(),
498
+ /** 只重跑某一个变体(0 起)。 */
499
+ variant: z.number().optional()
500
+ });
501
+ const tileApprovedSchema = z.object({
502
+ projectId: z.string(),
503
+ key: z.string().optional(),
504
+ variant: z.number().optional(),
505
+ approved: z.boolean()
506
+ });
507
+ const runTileMapSchema = z.object({
508
+ projectId: z.string(),
509
+ rows: z.number().optional(),
510
+ cols: z.number().optional(),
511
+ seed: z.number().optional(),
512
+ fill: z.string().optional(),
513
+ decorDensity: z.number().optional(),
514
+ /**
515
+ * 重撒装饰与建筑布局(「换个种子重铺」)。
516
+ *
517
+ * ⚠️ 必须声明:typert 会**静默丢掉** schema 之外的键。
518
+ * 漏了它的表现是「点了换个种子,图却一模一样」—— 不报任何错。
519
+ */
520
+ reroll: z.boolean().optional()
521
+ });
522
+ const saveTileMapCellsSchema = z.object({
523
+ projectId: z.string(),
524
+ rows: z.number().optional(),
525
+ cols: z.number().optional(),
526
+ seed: z.number().optional(),
527
+ cells: z.array(z.array(z.string())).optional(),
528
+ decor: z.record(z.string(), z.string()).optional(),
529
+ buildings: z.array(z.array(z.unknown())).optional(),
530
+ /**
531
+ * 跨格建筑(界面「手动编辑布局」回传)。
532
+ *
533
+ * ⚠️ 必须在 schema 里声明:typert 按声明校验 payload,**没声明的键会被静默丢掉**。
534
+ * 少了它界面就传不进建筑,拼图只能在「cells 里还有建筑键」时反推 ——
535
+ * 而占格一旦被清空(拼图自己就会清)就再也推不出来,建筑会凭空消失。
536
+ */
537
+ layouts: z.array(z.record(z.string(), z.unknown())).optional()
538
+ });
539
+ export const METHODS = [{ method: "getConfig", result: configViewSchema },
439
540
  { method: "saveConfig", payload: saveConfigSchema, result: configViewSchema },
440
541
  { method: "testArk", result: jsonObject },
441
542
  { method: "testMinimax", result: jsonObject },
@@ -443,7 +544,7 @@ export const METHODS = [
443
544
  { method: "reportClientOrigin", payload: reportOriginSchema, result: okSchema, clientOnly: true },
444
545
  { method: "listProjects", result: projectListSchema },
445
546
  { method: "createProject", payload: createProjectSchema, result: jsonObject },
446
- { method: "getProject", payload: projectIdSchema, result: projectViewSchema },
547
+ { method: "getProject", payload: getProjectSchema, result: projectViewSchema },
447
548
  { method: "deleteProject", payload: projectIdSchema, result: okSchema },
448
549
  { method: "renameProject", payload: renameSchema, result: okSchema },
449
550
  { method: "uploadSource", payload: uploadSchema, result: okSchema },
@@ -465,6 +566,10 @@ export const METHODS = [
465
566
  { method: "pollVideos", payload: projectOnlySchema, result: okSchema },
466
567
  { method: "clearVideos", payload: runKeysSchema, result: okSchema },
467
568
  { method: "runFrames", payload: runKeysSchema, result: startedSchema },
569
+ { method: "prepareFramePick", payload: prepareFramePickSchema, result: startedSchema },
570
+ { method: "setFramePick", payload: setFramePickSchema, result: jsonObject },
571
+ { method: "setFramePicks", payload: setWalkPicksSchema, result: jsonObject },
572
+ { method: "resetFramePicks", payload: resetWalkPicksSchema, result: jsonObject },
468
573
  { method: "rekey", payload: projectOnlySchema, result: startedSchema },
469
574
  { method: "compose", payload: projectOnlySchema, result: startedSchema },
470
575
  // 图片生成
@@ -531,10 +636,36 @@ export const METHODS = [
531
636
  { method: "runRigSegment", payload: rigJobIdSchema, result: startedSchema },
532
637
  { method: "runRigLayout", payload: runRigLayoutSchema, result: startedSchema },
533
638
  { method: "runRigBones", payload: rigJobIdSchema, result: startedSchema },
534
- { method: "runRigAtlas", payload: rigJobIdSchema, result: startedSchema }
639
+ { method: "runRigAtlas", payload: rigJobIdSchema, result: startedSchema },
640
+ // 地图地块生成
641
+ { method: "listTileProjects", result: z.object({ projects: z.array(jsonObject) }) },
642
+ { method: "createTileProject", payload: createTileProjectSchema, result: jsonObject },
643
+ { method: "getTileProject", payload: tileGetSchema, result: projectViewSchema },
644
+ { method: "deleteTileProject", payload: tileIdSchema, result: okSchema },
645
+ { method: "saveTileProject", payload: saveTileProjectSchema, result: jsonObject },
646
+ { method: "runTileItems", payload: runTileItemsSchema, result: startedSchema },
647
+ { method: "runTileItem", payload: runTileItemSchema, result: startedSchema },
648
+ { method: "setTileApproved", payload: tileApprovedSchema, result: okSchema },
649
+ { method: "runTileMap", payload: runTileMapSchema, result: startedSchema },
650
+ { method: "saveTileMapCells", payload: saveTileMapCellsSchema, result: okSchema },
651
+ { method: "runTileExport", payload: tileIdSchema, result: startedSchema },
652
+ { method: "cancelTileJob", payload: tileIdSchema, result: okSchema },
653
+ { method: "revealTileProject", payload: tileIdSchema, result: okSchema }
535
654
  ];
536
655
  export const PACKAGE_NAME = "dsh-game-material-master";
537
656
  export const SERVICE_NAME = "gameStudio";
657
+ /**
658
+ * 当前 DSH(typert 0.1.7+)的 strict codec 必须带 `create()`。
659
+ * 注册时只检查工厂存在;真正过边界时调用 `codec.create().parse(value)`。
660
+ * 旧写法把 Zod schema 挂在 `schema` 上,启动时会直接拒绝整份 manifest。
661
+ */
662
+ function strictCodec(typeSymbol, schema) {
663
+ return {
664
+ mode: "strict",
665
+ typeSymbol,
666
+ create: () => schema
667
+ };
668
+ }
538
669
  /** 注册给宿主 typert 网关的 package face。 */
539
670
  export const MANIFEST = {
540
671
  package: PACKAGE_NAME,
@@ -553,10 +684,10 @@ export const MANIFEST = {
553
684
  name: "payload",
554
685
  wire: "payload",
555
686
  source: "json",
556
- codec: { mode: "strict", typeSymbol: `${PACKAGE_NAME}#${spec.method}Payload`, schema: spec.payload }
687
+ codec: strictCodec(`${PACKAGE_NAME}#${spec.method}Payload`, spec.payload)
557
688
  }
558
689
  ],
559
- result: { mode: "strict", typeSymbol: `${PACKAGE_NAME}#${spec.method}Result`, schema: spec.result }
690
+ result: strictCodec(`${PACKAGE_NAME}#${spec.method}Result`, spec.result)
560
691
  })),
561
692
  model: { services: [], events: [], objects: [] }
562
693
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-game-material-master",
3
- "version": "0.2.0",
4
- "description": "游戏素材大师:DSH 插件,包含八方向图生成、图片生成、序列帧生成三个游戏素材模块,以及实验性的骨骼动画生成模块。八方向图默认「转圈截帧」(一段原地匀速转一圈的绿幕视频 → 按时间轴截出八个方向),也可逐方向生图;火山方舟 Seedream 生图 + MiniMax 图生视频 + 本地抠绿幕合成。",
3
+ "version": "0.3.0",
4
+ "description": "游戏素材大师:DSH 插件,包含八方向图生成、图片生成、序列帧生成三个正式模块,以及实验性的 45° 地图地块生成与骨骼动画生成模块。界面与内置提示词跟随 DSH 语言设置(中 / 英)。八方向图默认「转圈截帧」(一段原地匀速转一圈的绿幕视频 → 按时间轴截出八个方向),也可逐方向生图;45° 地图地块用「几何交给代码、内容交给 AI」的方式拼成整张地图。火山方舟 Seedream 生图 + MiniMax 图生视频 + 本地抠绿幕合成。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -32,6 +32,7 @@
32
32
  "files": [
33
33
  "lib",
34
34
  "README.md",
35
+ "README.en.md",
35
36
  "cordis.patch.yml"
36
37
  ],
37
38
  "scripts": {