dsh-game-material-master 0.6.0 → 0.7.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/client.js CHANGED
@@ -127,6 +127,23 @@ window.__ModuleLoader__.load({
127
127
  "更换源图": "Replace source image",
128
128
  "刷新状态": "Refresh status",
129
129
  "在访达中打开项目目录": "Open the project directory in Finder",
130
+ "保存全部图片(zip)": "Save all images (zip)",
131
+ "正在打包全部图片…": "Packing all images…",
132
+ "已打包 {n0} 张图片": "Packed {n0} images",
133
+ "已打包 {n0} 张图片(另有 {n1} 张读不到,已跳过)": "Packed {n0} images ({n1} unreadable files were skipped)",
134
+ "选择本地视频": "Choose a local video",
135
+ "正在导入本地视频…": "Importing the local video…",
136
+ "已选用本地视频,正在抽候选帧并切出八个方向…": "Local video selected - extracting candidate frames and cutting the eight directions…",
137
+ "已选用本地视频(抽帧没有自动开始,点「抽取候选帧」即可)": "Local video selected (extraction did not start automatically - click \"Extract candidate frames\")",
138
+ "已选用「{n0}」的本地视频,接着到第 3 步抽取序列帧": "Local video selected for \"{n0}\" - extract the sequence frames in step 3",
139
+ "本地视频:{n0}(不花远程调用)": "Local video: {n0} (no remote call)",
140
+ "保存条带": "Save strip",
141
+ "保存视频": "Save video",
142
+ "保存预览带": "Save preview strip",
143
+ "手上已经有这样一段视频(自己电脑上的文件)时,点「选择本地视频」直接用它即可,不必走远程生成。": "If you already have such a video as a file on this computer, click \"Choose a local video\" and use it directly - no remote generation needed.",
144
+ "某一个方向已经有现成的行走视频(自己电脑上的文件)时,点那一格的「选择本地视频」直接用它,不必走远程生成。": "If you already have a walking video for a direction as a file on this computer, click \"Choose a local video\" in that cell and use it directly - no remote generation needed.",
145
+ "用自己电脑上的一段原地转圈视频(绿幕)顶替远程生成;导入后会自动抽候选帧并切出八个方向": "Use a chroma-key video of the character turning in place from this computer instead of remote generation; after the import the candidate frames are extracted and the eight directions are cut out automatically",
146
+ "用自己电脑上的一段「固定镜头 + 原地走」视频顶替这一方向的远程生成;之后照旧到第 3 步抽帧": "Use a fixed-camera walking-in-place video from this computer instead of remote generation for this direction; frames are still extracted in step 3",
130
147
  "先生成一段「角色原地匀速转一整圈」的绿幕视频,再按时间截出八个方向的帧;下面时间轴上的八个圆圈就是各自的截帧位置,拖动即可改。": "First generate a chroma-key video of the character turning a full circle in place at a constant speed, then cut frames for the eight directions by time. The eight circles on the timeline below mark each direction's frame position; drag them to change it.",
131
148
  "转圈截帧": "Turn-frame capture",
132
149
  "先生成一段「原地匀速转一整圈」的视频,再按时间截出八个方向(默认,一致性最好)": "Generate one video of a full turn in place at a constant speed, then cut the eight directions from it by time (default, best consistency)",
@@ -857,7 +874,40 @@ window.__ModuleLoader__.load({
857
874
  "导入 DragonBones:把 export/dragonbones/skeleton_ske.json 与 atlas/skeleton_tex.json、atlas/skeleton.png 放同一目录后加载 .json 数据与纹理。": "Importing into DragonBones: put export/dragonbones/skeleton_ske.json in the same folder as atlas/skeleton_tex.json and atlas/skeleton.png, then load the .json data and textures.",
858
875
  "正在载入配置…": "Loading configuration…",
859
876
  "配置已保存": "Configuration saved",
860
- "配置两家模型的 API Key 与整条流水线的默认参数。Key 只保存在本机 DSH 数据目录下的 game-material-master/config.json(真实路径见文末「数据位置」),界面里始终脱敏显示。": "Configure the API keys for both models and the default parameters for the whole pipeline. Keys are stored only in game-material-master/config.json under your local DSH data directory (see \"Data location\" at the end for the real path) and are always masked in the UI.",
877
+ "配置生图 / 生视频的模型与整条流水线的默认参数。Key 只保存在本机 DSH 数据目录下的 game-material-master/config.json(真实路径见文末「数据位置」),界面里始终脱敏显示。": "Configure the image/video models and the default parameters for the whole pipeline. Keys are stored only in game-material-master/config.json under your local DSH data directory (see \"Data location\" at the end for the real path) and are always masked in the UI.",
878
+ "生图后端": "Image backend",
879
+ "八方向图、图片生成、骨骼动画、45°地图地块的生图都走这里选的后端;图生视频(MiniMax)不受影响。": "Sprite sheets, image generation, rigged animation and 45° map tiles all generate images through the backend selected here; image-to-video (MiniMax) is unaffected.",
880
+ "当前使用": "In use",
881
+ "火山方舟 Seedream(云端,开箱即用)": "Volcengine Ark Seedream (cloud, works out of the box)",
882
+ "自定义生图模型(OpenAI / ComfyUI / SD WebUI)": "Custom image model (OpenAI / ComfyUI / SD WebUI)",
883
+ "当前生效:{n0}": "Currently active: {n0}",
884
+ "还不能开跑:{n0}": "Not ready yet: {n0}",
885
+ "后端已就绪,可以开跑。": "The backend is ready to use.",
886
+ "自定义生图模型": "Custom image model",
887
+ "填「主机根地址」即可,具体端点由插件按协议拼;本地服务通常不需要 API Key。": "Just the host root URL — the plugin appends the protocol-specific endpoint. Local servers usually need no API key.",
888
+ "协议": "Protocol",
889
+ "模型名(SD WebUI 忽略,模型由服务端决定)": "Model name (ignored by SD WebUI; the server decides the model)",
890
+ "模型名": "Model name",
891
+ "可不填,由工作流决定": "Optional; the workflow decides",
892
+ "输出尺寸(宽x高)": "Output size (width x height)",
893
+ "请求端点:{n0}": "Endpoint: {n0}",
894
+ "(未配置,本地服务可以留空)": "(not configured; local servers can leave it blank)",
895
+ "粘贴 API Key(A1111 的 user:pass 也认)": "Paste the API key (A1111's user:pass is also accepted)",
896
+ "自定义后端 Key 已保存": "Custom backend key saved",
897
+ "已清除自定义后端 Key": "Custom backend key cleared",
898
+ "负面提示词": "Negative prompt",
899
+ "走 {{negative_prompt}} 占位符": "Filled via the {{negative_prompt}} placeholder",
900
+ "采样步数": "Sampling steps",
901
+ "CFG / 引导强度": "CFG / guidance scale",
902
+ "采样器": "Sampler",
903
+ "图生图重绘强度(0~1)": "Image-to-image denoising strength (0–1)",
904
+ "随机种子(-1 = 每次随机)": "Seed (-1 = random each time)",
905
+ "请求超时(毫秒,本地模型建议给足)": "Request timeout (ms; give local models plenty)",
906
+ "工作流(在 ComfyUI 里点「导出(API)」,把那份 JSON 整段粘贴)。可用占位符:{{prompt}} {{negative_prompt}} {{width}} {{height}} {{seed}} {{steps}} {{cfg}} {{sampler}} {{denoising}} {{model}} {{image}};一个都不写就原样跑你保存的工作流。": "Workflow (click \"Export (API)\" in ComfyUI and paste the whole JSON). Placeholders: {{prompt}} {{negative_prompt}} {{width}} {{height}} {{seed}} {{steps}} {{cfg}} {{sampler}} {{denoising}} {{model}} {{image}}. With no placeholder at all, your saved workflow runs as-is.",
907
+ "工作流已保存": "Workflow saved",
908
+ "保存工作流": "Save workflow",
909
+ "清空": "Clear",
910
+ "测试连接(会真实生成 1 张测试图,产生少量费用)": "Test connection (generates one real test image, small charge)",
861
911
  "火山方舟(生图)": "Volcengine Ark (image generation)",
862
912
  "ffmpeg 可用:{n0}": "ffmpeg available: {n0}",
863
913
  "ffmpeg 不可用:{n0}": "ffmpeg unavailable: {n0}",
@@ -1055,16 +1105,11 @@ window.__ModuleLoader__.load({
1055
1105
  "还没有地图项目。": "No map project yet.",
1056
1106
  "还没有导出过。": "Nothing exported yet.",
1057
1107
  "任务进行中…": "A job is running…",
1058
- // ── 地图编辑器:实验性说明弹窗 ──────────────────────────────────────
1059
- "界面上看到的地图与导出的 PNG 执行的是同一份绘制计划,所以不会有「预览好看、导出位移」这种事。": "The map you see and the exported PNG execute the same draw plan, so \"looks right in the preview but shifts on export\" cannot happen.",
1060
- "地图编辑器仍在开发中": "The map editor is still in development",
1061
- "地图编辑器(实验性)": "Map editor (experimental)",
1108
+ // 模块⑥「地图编辑器」已经是正式功能:这里不再需要它的实验性说明词条。
1062
1109
  "已删除项目": "Project deleted",
1063
1110
  "已改地图尺寸": "Map resized",
1064
1111
  "换一组": "Roll again",
1065
1112
  // ── 地图编辑器(模块六):一屏零术语,AsLib RPG Map Maker 同款 ────────
1066
- "这条路是全本地的:导入素材图、自动连接、画地图、导出 PNG 都在本机算,一次模型调用都没有,所以不花钱。": "This path is fully local: importing the image, auto-connecting, painting and exporting the PNG all run on this machine - not a single model call, so nothing is billed.",
1067
- "与模块⑤不同:它不生成素材,只把你自己的素材图切成一块一块,铺图、接边和导出都由本地代码完成。": "Unlike module 5 it generates no artwork: it cuts your own tile image into pieces, and the placing, edge matching and export are all done by local code.",
1068
1113
  "导入自己的素材图 → 自动连接 → 直接画 → 导出 PNG": "Import your own tile image → auto-connect → paint → export PNG",
1069
1114
  "先在左边点一块图当笔刷。": "Pick a tile on the left first.",
1070
1115
  "图层 2": "Layer 2",
@@ -1120,8 +1165,6 @@ window.__ModuleLoader__.load({
1120
1165
  "同色的连通区一次填满": "Fill a connected run of the same tile in one go",
1121
1166
  "吸取这一格用的图块,变成当前笔刷": "Pick up the tile used in this cell and make it the current brush",
1122
1167
  "拖动平移画布;空格拖或中键拖也行": "Drag to pan the canvas; space-drag or middle-drag works too",
1123
- "只显示当前这一层,底铺绿色": "Show only the current layer on a green backdrop",
1124
- "上半换上一层、下半换下一层;中间的数字是当前层号": "Click the upper half for the layer above, the lower half for the one below; the number in the middle is the current layer",
1125
1168
  "显示或隐藏格线,方便数格子": "Show or hide the grid lines so cells are easier to count",
1126
1169
  "随机铺满 / 迷宫 / 大陆:用选中的图块一键铺满整层": "Random fill / maze / continent: fill the whole layer with the selected tiles in one click",
1127
1170
  "地图大小、图层、帮助": "Map size, layers and help",
@@ -1134,7 +1177,6 @@ window.__ModuleLoader__.load({
1134
1177
  "还没有素材,点上面的「素材」上传一张。": "No tile image yet: click \"Image\" above to upload one.",
1135
1178
  "油漆桶": "Paint bucket",
1136
1179
  "抓手": "Hand",
1137
- "单层预览": "Single layer",
1138
1180
  "上一层": "Layer up",
1139
1181
  "下一层": "Layer down",
1140
1182
  "网格线": "Grid lines",
@@ -1178,11 +1220,26 @@ window.__ModuleLoader__.load({
1178
1220
  "图层 {n0}": "Layer {n0}",
1179
1221
  "已加一层": "Layer added",
1180
1222
  "加一层": "Add layer",
1181
- "至少要留一层": "At least one layer must remain",
1182
1223
  "删掉当前这一层": "Delete the current layer",
1183
1224
  "已删掉这一层": "Layer deleted",
1184
- "删一层": "Delete layer",
1185
1225
  "清空当前图层": "Clear current layer",
1226
+ "标记": "Marker",
1227
+ "地图上点一格放一个标记;点已有标记可以改名、按住拖动可以挪位置;右键删掉它": "Click a cell to drop a marker; click an existing marker to rename it, drag it to move it; right-click deletes it",
1228
+ "标记层": "Marker layer",
1229
+ "还没有标记。选「标记」工具,在地图上点一格。": "No markers yet. Pick the Marker tool and click a cell on the map.",
1230
+ "{n0} 个标记": "{n0} markers",
1231
+ "标记 {n0}": "Marker {n0}",
1232
+ "定位": "Go to",
1233
+ "删掉": "Delete",
1234
+ "已重命名这一层": "Layer renamed",
1235
+ "图层名字不能为空": "A layer name cannot be empty",
1236
+ "上移一层": "Move layer up",
1237
+ "下移一层": "Move layer down",
1238
+ "只看这一层": "Only this layer",
1239
+ "点名字可以改名,右边可以换顺序或删掉": "Click a name to rename it; on the right you can reorder or delete it",
1240
+ "标记名字": "Marker name",
1241
+ "点中间的数字打开图层列表(改名 / 换顺序 / 删掉);上半换上一层、下半换下一层": "Click the number in the middle to open the layer list (rename / reorder / delete); the top half switches up a layer, the bottom half switches down",
1242
+ "已换图层顺序": "Layer order updated",
1186
1243
  "帮助": "Help",
1187
1244
  "左键拖动=用当前工具画;空格拖动或中键拖动=平移;滚轮=缩放;右键=橡皮。": "Left-drag paints with the current tool; space-drag or middle-drag pans; the wheel zooms; the right button erases.",
1188
1245
  "调色板里点一下选一块图当笔刷,按住 Shift 或 Ctrl 可以多选,「一键生成」会用这些图块。": "Click a tile in the palette to use it as the brush; hold Shift or Ctrl to select several, and \"Generate\" uses exactly those.",
@@ -1219,9 +1276,6 @@ window.__ModuleLoader__.load({
1219
1276
  () => {
1220
1277
  TILE_STAGES = make_TILE_STAGES();
1221
1278
  },
1222
- () => {
1223
- MAP_EXPERIMENTAL_POINTS = make_MAP_EXPERIMENTAL_POINTS();
1224
- },
1225
1279
  () => {
1226
1280
  STAGES = make_STAGES();
1227
1281
  },
@@ -1358,6 +1412,7 @@ window.__ModuleLoader__.load({
1358
1412
  ["getConfig", false],
1359
1413
  ["saveConfig", true],
1360
1414
  ["testArk", false],
1415
+ ["testCustomImage", false],
1361
1416
  ["testMinimax", false],
1362
1417
  ["listProjects", false],
1363
1418
  ["createProject", true],
@@ -1371,6 +1426,9 @@ window.__ModuleLoader__.load({
1371
1426
  ["setReviewMode", true],
1372
1427
  ["reportClientOrigin", true],
1373
1428
  ["revealProject", true],
1429
+ // 本地自选视频(转圈 / 某个方向)与中间图片打包。
1430
+ ["uploadVideo", true],
1431
+ ["exportImages", true],
1374
1432
  ["runImage", true],
1375
1433
  ["runImages", true],
1376
1434
  ["setImageMode", true],
@@ -1610,16 +1668,10 @@ window.__ModuleLoader__.load({
1610
1668
  ];
1611
1669
  }
1612
1670
  let TILE_EXPERIMENTAL_POINTS = make_TILE_EXPERIMENTAL_POINTS();
1613
- /** 进入模块⑥时的实验性说明要点(导入自己的素材图那条路)。 */
1614
- function make_MAP_EXPERIMENTAL_POINTS() {
1615
- return [
1616
- T("这条路是全本地的:导入素材图、自动连接、画地图、导出 PNG 都在本机算,一次模型调用都没有,所以不花钱。"),
1617
- T("与模块⑤不同:它不生成素材,只把你自己的素材图切成一块一块,铺图、接边和导出都由本地代码完成。"),
1618
- T("界面上看到的地图与导出的 PNG 执行的是同一份绘制计划,所以不会有「预览好看、导出位移」这种事。"),
1619
- T("发现问题或有改进想法,欢迎到 GitHub 仓库一起开发。")
1620
- ];
1621
- }
1622
- let MAP_EXPERIMENTAL_POINTS = make_MAP_EXPERIMENTAL_POINTS();
1671
+ // 模块⑥「地图编辑器」**已经不再是实验性功能**:链路全本地、零计费,几何与导出
1672
+ // 都有像素级自检兜底(`verify-map*` 四件),界面上与导出的 PNG 执行同一份绘制计划。
1673
+ // 所以它没有实验性角标、没有进入弹窗、模块内也没有常驻提示条
1674
+ // —— 留下任何一条都会让「正式」这个说法名不副实。
1623
1675
  /** 六个功能模块。插件是「大师」,每个模块管一类素材。 */
1624
1676
  function make_MODULES() {
1625
1677
  return [
@@ -1628,7 +1680,7 @@ window.__ModuleLoader__.load({
1628
1680
  { key: "sequence", title: T("序列帧生成"), hint: T("图/视频参考生成视频 → 抽帧 → 抠像 → 合成与播放预览") },
1629
1681
  { key: "rig", title: T("骨骼动画生成"), hint: T("拆件 → 装配定位 → 推骨骼与动画 → 打包 Spine 图集"), experimental: true },
1630
1682
  { key: "tile", title: T("45°地图地块生成"), hint: T("45° 等距地块 → 拼成地图:几何交给代码,内容交给 AI"), experimental: true },
1631
- { key: "map", title: T("地图编辑器"), hint: T("导入自己的素材图 → 自动连接 → 直接画 → 导出 PNG"), experimental: true }
1683
+ { key: "map", title: T("地图编辑器"), hint: T("导入自己的素材图 → 自动连接 → 直接画 → 导出 PNG") }
1632
1684
  ];
1633
1685
  }
1634
1686
  let MODULES = make_MODULES();
@@ -2048,7 +2100,28 @@ window.__ModuleLoader__.load({
2048
2100
  .SPR_mapEdLayerHalf{flex:1;width:100%;display:flex;align-items:center;justify-content:center;padding:0;cursor:pointer;color:#4a3416;background:transparent;border:none;border-radius:3px}
2049
2101
  .SPR_mapEdLayerHalf:hover:not(:disabled){background:rgba(255,255,255,.28)}
2050
2102
  .SPR_mapEdLayerHalf:disabled{opacity:.3;cursor:default}
2051
- .SPR_mapEdLayerNum{font-size:10px;line-height:1;font-weight:700;color:#4a3416;font-variant-numeric:tabular-nums}
2103
+ .SPR_mapEdLayerNum{width:100%;padding:0;border:none;background:transparent;cursor:pointer;font-family:inherit;font-size:10px;line-height:1;font-weight:700;color:#4a3416;font-variant-numeric:tabular-nums}
2104
+ .SPR_mapEdLayerNum:hover{background:rgba(255,255,255,.28);border-radius:3px}
2105
+ /* 图层卡:一行一层(点名字就地改名,右边换顺序 / 删掉)。
2106
+ 最上面一行固定是「标记层」,它不是图层数组里的成员 —— 标记有自己的位置与名字。 */
2107
+ .SPR_mapEdLayerList{display:flex;flex-direction:column;gap:3px;margin:6px 0}
2108
+ .SPR_mapEdLayerRow{display:flex;align-items:center;gap:5px;padding:3px 5px;border:1px solid #6b4a22;border-radius:4px;background:rgba(0,0,0,.18)}
2109
+ .SPR_mapEdLayerRow[data-on="true"]{border-color:#e6bd7d;background:rgba(230,189,125,.18)}
2110
+ .SPR_mapEdLayerIdx{width:15px;flex:none;text-align:center;font-size:11px;color:#c9bda8;font-variant-numeric:tabular-nums}
2111
+ .SPR_mapEdLayerName{flex:1;min-width:0;text-align:left;padding:2px 4px;border:1px dashed transparent;border-radius:3px;background:transparent;color:#f3e7d3;font-family:inherit;font-size:12px;cursor:text;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
2112
+ .SPR_mapEdLayerName:hover{border-color:#6b4a22}
2113
+ .SPR_mapEdLayerNameInput{flex:1;min-width:0;padding:2px 4px;border:1px solid #e6bd7d;border-radius:3px;background:#1f1f1f;color:#f3e7d3;font-family:inherit;font-size:12px;outline:none}
2114
+ .SPR_mapEdMiniBtn{padding:1px 5px;border:1px solid #6b4a22;border-radius:3px;background:rgba(0,0,0,.25);color:#e8d7bb;font-family:inherit;font-size:11px;line-height:16px;cursor:pointer}
2115
+ .SPR_mapEdMiniBtn:hover:not(:disabled){background:rgba(230,189,125,.25)}
2116
+ .SPR_mapEdMiniBtn:disabled{opacity:.35;cursor:default}
2117
+ .SPR_mapEdMarkerRow{display:flex;align-items:center;gap:6px;padding:3px 5px;border:1px solid #6b4a22;border-radius:4px;background:rgba(0,0,0,.18)}
2118
+ .SPR_mapEdMarkerRow[data-on="true"]{border-color:#e23b2b;background:rgba(226,59,43,.14)}
2119
+ .SPR_mapEdMarkerDot{width:18px;height:18px;flex:none;display:flex;align-items:center;justify-content:center;border:1.5px solid #f0c040;border-radius:50%;background:#14161e;color:#fff;font-size:11px;font-weight:700;font-variant-numeric:tabular-nums}
2120
+ .SPR_mapEdMarkerName{flex:1;min-width:0;padding:2px 4px;border:1px solid transparent;border-radius:3px;background:transparent;color:#f3e7d3;font-family:inherit;font-size:12px;outline:none}
2121
+ .SPR_mapEdMarkerName:hover{border-color:#6b4a22}
2122
+ .SPR_mapEdMarkerName:focus{border-color:#e6bd7d;background:#1f1f1f}
2123
+ .SPR_mapEdMarkerAt{flex:none;font-size:11px;color:#b9b3a8;font-variant-numeric:tabular-nums}
2124
+ .SPR_mapEdMarkerList{display:flex;flex-direction:column;gap:3px;max-height:216px;overflow:auto;margin-top:4px}
2052
2125
  /* 画布:铺满右列,像素画不糊 */
2053
2126
  .SPR_mapEdStage{position:relative;flex:1;min-width:0;min-height:360px;background:#3a3a3a;overflow:hidden}
2054
2127
  .SPR_mapEdCanvas{display:block;width:100%;height:100%;image-rendering:pixelated;touch-action:none;cursor:crosshair}
@@ -2145,6 +2218,11 @@ window.__ModuleLoader__.load({
2145
2218
  .SPR_btn[data-primary=true]{background:var(--dsw-alias-state-business-primary);border-color:transparent;color:var(--dsw-alias-state-business-on-primary, #fff)}
2146
2219
  .SPR_btn[data-on=true]{border-color:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-state-success-primary)}
2147
2220
  .SPR_btn[data-danger=true]{color:var(--dsw-alias-state-error-primary)}
2221
+ /* 标签当按钮用:包着隐藏 <input type=file> 的 label(选择本地视频)与下载链接。
2222
+ label 默认是行内元素,直接套 .SPR_btn 的对齐会跟旁边的按钮错开一行。 */
2223
+ .SPR_fileBtn{display:inline-flex;align-items:center;justify-content:center;gap:4px}
2224
+ .SPR_fileBtn[data-disabled=true]{cursor:default;opacity:.5}
2225
+ .SPR_fileBtn[data-disabled=true] input{pointer-events:none}
2148
2226
  .SPR_btnRow{display:flex;gap:6px;flex-wrap:wrap;margin-top:auto}
2149
2227
  .SPR_area{width:100%;box-sizing:border-box;min-height:96px;resize:vertical;font-family:ui-monospace,SFMono-Regular,Consolas,Menlo,monospace;font-size:12px;line-height:18px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-markdown-code-block, var(--dsw-alias-bg-layer-1));border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:8px 10px}
2150
2228
  .SPR_input{box-sizing:border-box;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:5px 9px;width:100%}
@@ -3333,6 +3411,31 @@ window.__ModuleLoader__.load({
3333
3411
  }
3334
3412
  return result;
3335
3413
  };
3414
+ /**
3415
+ * 「保存全部图片(zip)」:宿主按**当前项目状态**现打一个 zip 落到 `out/` 下,
3416
+ * 这里再触发一次浏览器下载。
3417
+ *
3418
+ * 为什么不直接摆一个 `<a href>`:包里有哪些图(以及文件名)只有宿主知道,
3419
+ * 没有固定地址可指,所以只能「先请求、拿到相对路径再下载」。
3420
+ */
3421
+ const exportAllImages = () => void start(async () => {
3422
+ const pack = await api.exportImages({ projectId: project.id });
3423
+ const url = `${pack?.assetBase ?? project.assetBase ?? ""}${pack?.file ?? ""}`;
3424
+ const anchor = document.createElement("a");
3425
+ anchor.href = url;
3426
+ anchor.download = fileLabel(pack?.file);
3427
+ anchor.style.display = "none";
3428
+ document.body.appendChild(anchor);
3429
+ anchor.click();
3430
+ anchor.remove();
3431
+ setNotice({
3432
+ kind: "ok",
3433
+ text: Number(pack?.skipped ?? 0) > 0
3434
+ ? T("已打包 {n0} 张图片(另有 {n1} 张读不到,已跳过)", { n0: pack?.count ?? 0, n1: pack?.skipped ?? 0 })
3435
+ : T("已打包 {n0} 张图片", { n0: pack?.count ?? 0 })
3436
+ });
3437
+ return pack;
3438
+ }, { reload: true }, { key: KEY_EXPORT_IMAGES, label: T("正在打包全部图片…") });
3336
3439
  if (api === undefined) {
3337
3440
  return h("div", { className: "SPR_root" }, h("p", { className: "SPR_empty" }, T("正在挂载游戏素材大师…")));
3338
3441
  }
@@ -3454,7 +3557,15 @@ window.__ModuleLoader__.load({
3454
3557
  void uploadSource(file);
3455
3558
  event.target.value = "";
3456
3559
  }
3457
- })))), renderLog(project), h("div", { className: "SPR_toolbar" }, h(Btn, { onClick: () => void loadProject(project.id) }, T("刷新状态")), h(Btn, { onClick: () => void withApi(() => api.revealProject({ projectId: project.id })) }, T("在访达中打开项目目录"))))))
3560
+ })))), renderLog(project), h("div", { className: "SPR_toolbar" }, h(Btn, { onClick: () => void loadProject(project.id) }, T("刷新状态")),
3561
+ // 中间图片(绿幕图 / 转圈候选帧与条带 / 各方向原始帧与抠像帧 / 整图)
3562
+ // 一次打成一个 zip:转圈模式的候选帧一抽就是 32~64 张,一张一个链接
3563
+ // 既点不完也看不清。放在这条**各阶段共用**的工具栏上,任何阶段都能存。
3564
+ h(BusyBtn, {
3565
+ busy: tasks.has(KEY_EXPORT_IMAGES),
3566
+ busyText: T("正在打包…"),
3567
+ onClick: () => void exportAllImages()
3568
+ }, T("保存全部图片(zip)")), h(Btn, { onClick: () => void withApi(() => api.revealProject({ projectId: project.id })) }, T("在访达中打开项目目录"))))))
3458
3569
  : activeModule === "image"
3459
3570
  ? h(ImageModule, { api })
3460
3571
  : activeModule === "sequence"
@@ -3507,6 +3618,15 @@ window.__ModuleLoader__.load({
3507
3618
  const KEY_TURN_VIDEO = "turn:*video";
3508
3619
  const KEY_TURN_FRAMES = "turn:*frames";
3509
3620
  const KEY_TURN_PICK = (key) => `turn:pick:${key}`;
3621
+ /**
3622
+ * 本地自选视频的 pending key(转圈与每个方向各一条)。
3623
+ *
3624
+ * 前缀刻意和 `turn:*` / `video:*` 错开:那两个前缀被「这个阶段有没有在跑」
3625
+ * 的判定用着(`tasks.any("video:*")`),混进去会把不相干的按钮一起禁用。
3626
+ */
3627
+ const KEY_LOCAL_VIDEO = (key) => `local-video:${key}`;
3628
+ /** 「保存全部图片(zip)」的 pending key(这条工具栏是各阶段共用的)。 */
3629
+ const KEY_EXPORT_IMAGES = "images:*zip";
3510
3630
  const TURN_FRAME_MIN = 8;
3511
3631
  const TURN_FRAME_MAX = 64;
3512
3632
  /**
@@ -3683,7 +3803,8 @@ window.__ModuleLoader__.load({
3683
3803
  const allApproved = DIRECTION_KEYS.every((key) => project.images?.[key]?.approved);
3684
3804
  const readyImages = DIRECTION_KEYS.filter((key) => project.images?.[key]?.file !== undefined).length;
3685
3805
  const stale = frames.stale === true;
3686
- return h(React.Fragment, null, h("p", { className: "SPR_hint" }, T("先生成一段「角色原地匀速转一整圈」的视频(绿幕、保持原图风格、除旋转外不做任何动作),再按时间截出八个方向的帧。八个方向出自同一段视频,一致性比逐方向生图好得多;下面时间轴上的八个圆圈就是各自的截帧位置,随便拖。")), h("textarea", {
3806
+ return h(React.Fragment, null, h("p", { className: "SPR_hint" }, T("先生成一段「角色原地匀速转一整圈」的视频(绿幕、保持原图风格、除旋转外不做任何动作),再按时间截出八个方向的帧。八个方向出自同一段视频,一致性比逐方向生图好得多;下面时间轴上的八个圆圈就是各自的截帧位置,随便拖。") +
3807
+ T("手上已经有这样一段视频(自己电脑上的文件)时,点「选择本地视频」直接用它即可,不必走远程生成。")), h("textarea", {
3687
3808
  className: "SPR_area",
3688
3809
  value: promptDraft,
3689
3810
  "data-testid": "turn-prompt",
@@ -3707,7 +3828,16 @@ window.__ModuleLoader__.load({
3707
3828
  ? T("生成转圈视频(计费一次)")
3708
3829
  : videoRunning
3709
3830
  ? T("转圈视频生成中…")
3710
- : T("重新生成转圈视频(计费一次)")), h(BusyBtn, {
3831
+ : T("重新生成转圈视频(计费一次)")),
3832
+ // 和远程生成**并列**的一条路:手上已经有一段原地转圈的绿幕视频时,
3833
+ // 直接选它就行——不用花那一次视频调用,导入后同样自动抽帧、切八个方向。
3834
+ h(LocalVideoPick, {
3835
+ label: T("选择本地视频"),
3836
+ title: T("用自己电脑上的一段原地转圈视频(绿幕)顶替远程生成;导入后会自动抽候选帧并切出八个方向"),
3837
+ disabled: videoRunning,
3838
+ testId: "turn-local-video",
3839
+ onFile: (file) => pickLocalVideo({ start, setNotice, api, project, key: "turn", file })
3840
+ }), h(BusyBtn, {
3711
3841
  busy: tasks.has(KEY_TURN_FRAMES),
3712
3842
  busyText: T("正在抽帧…"),
3713
3843
  disabled: video.file === undefined || cutting,
@@ -3732,7 +3862,13 @@ window.__ModuleLoader__.load({
3732
3862
  }, T("应用帧数")), h("span", { className: "SPR_refRow" }, project.settings?.turnFrameCount === frameCount ? T("当前 {n0} 张", { n0: project.settings?.turnFrameCount ?? "—" }) : T("未应用(当前 {n0} 张)", { n0: project.settings?.turnFrameCount ?? "—" }))), h("div", { className: "SPR_toolbar" }, h(Btn, {
3733
3863
  disabled: total === 0 || cutting,
3734
3864
  onClick: () => void start(() => api.resetTurnPicks({ projectId: project.id }), { reload: true, notice: T("八个圆圈已回到默认等分位置"), noticeKind: "ok" })
3735
- }, T("重置八个圆圈")), h(Btn, {
3865
+ }, T("重置八个圆圈")),
3866
+ // 条带本身就是「整圈候选帧」那张中间图,值得能单独存下来(对着它挑帧/发给别人看)。
3867
+ h(SaveLink, {
3868
+ url: frames.strip === undefined ? undefined : assetUrl(project, frames.strip, frames.updatedAt),
3869
+ name: `${project.name}-turn-strip.png`,
3870
+ label: T("保存条带")
3871
+ }), h(Btn, {
3736
3872
  disabled: total === 0 || cutting,
3737
3873
  title: T("转圈方向决定默认位置怎么排;拖动过的圆圈以你的位置为准"),
3738
3874
  onClick: () => void start(() => api.resetTurnPicks({ projectId: project.id, direction: project.turn?.direction === "ccw" ? "cw" : "ccw" }), {
@@ -3756,7 +3892,20 @@ window.__ModuleLoader__.load({
3756
3892
  "data-testid": "turn-video"
3757
3893
  })
3758
3894
  }))
3759
- : h("div", { className: "SPR_thumbEmpty", style: { aspectRatio: "16/9" } }, videoRunning ? T("正在生成转圈视频…") : T("还没有转圈视频:点上面的「生成转圈视频」")), video.error !== undefined ? h("p", { className: "SPR_error" }, video.error) : null, h("div", { className: "SPR_refRow" }, T("首帧用的是{n0}:{n1}", { n0: video.firstFrame !== undefined && String(video.firstFrame).startsWith("images/") ? T("已生成的正面绿幕图") : T("上传的源图"), n1: video.firstFrame ?? "—" })), total > 0
3895
+ : h("div", { className: "SPR_thumbEmpty", style: { aspectRatio: "16/9" } }, videoRunning ? T("正在生成转圈视频…") : T("还没有转圈视频:点上面的「生成转圈视频」")), video.error !== undefined ? h("p", { className: "SPR_error" }, video.error) : null,
3896
+ // 这一栏在界面上是「这段视频的来路」:本地选的视频没有输入首帧,
3897
+ // 照旧印「首帧用的是源图」会把人指向一张跟它无关的图。
3898
+ h("div", { className: "SPR_refRow" }, video.origin === "local"
3899
+ ? T("本地视频:{n0}(不花远程调用)", { n0: video.originalName ?? fileLabel(video.file) })
3900
+ : T("首帧用的是{n0}:{n1}", { n0: video.firstFrame !== undefined && String(video.firstFrame).startsWith("images/") ? T("已生成的正面绿幕图") : T("上传的源图"), n1: video.firstFrame ?? "—" })),
3901
+ // 视频本身也是中间产物(远程生成的那次是真金白银),得能存下来。
3902
+ video.file !== undefined
3903
+ ? h("div", { className: "SPR_btnRow", style: { marginTop: 0 } }, h(SaveLink, {
3904
+ url: assetUrl(project, video.file, video.updatedAt),
3905
+ name: `${project.name}-turn.mp4`,
3906
+ label: T("保存视频")
3907
+ }))
3908
+ : null, total > 0
3760
3909
  ? h(TurnAxis, {
3761
3910
  project,
3762
3911
  total,
@@ -3786,7 +3935,12 @@ window.__ModuleLoader__.load({
3786
3935
  key,
3787
3936
  approved: node?.approved !== true
3788
3937
  }), { reload: true })
3789
- }, node?.approved === true ? T("已通过") : T("通过"))));
3938
+ }, node?.approved === true ? T("已通过") : T("通过")), h(SaveLink, {
3939
+ url: node?.file === undefined ? undefined : assetUrl(project, node.file, node.updatedAt ?? project.updatedAt),
3940
+ name: `${project.name}-${key}.png`,
3941
+ label: T("保存"),
3942
+ busy: nodeBusy
3943
+ })));
3790
3944
  })));
3791
3945
  }
3792
3946
  function renderImageStage(ctx) {
@@ -3895,7 +4049,14 @@ window.__ModuleLoader__.load({
3895
4049
  key: direction.key,
3896
4050
  approved: node?.approved !== true
3897
4051
  }), { reload: true })
3898
- }, node?.approved === true ? T("已通过") : T("通过"))));
4052
+ }, node?.approved === true ? T("已通过") : T("通过")),
4053
+ // 绿幕图是这一阶段唯一看得见的产物,直接存下来(拖进别的工具 / 存档)。
4054
+ h(SaveLink, {
4055
+ url: node?.file === undefined ? undefined : assetUrl(project, node.file, node.updatedAt ?? project.updatedAt),
4056
+ name: `${project.name}-${direction.key}.png`,
4057
+ label: T("保存"),
4058
+ busy: nodeBusy
4059
+ })));
3899
4060
  })));
3900
4061
  }
3901
4062
  // ── 阶段 2:视频 ─────────────────────────────────────────────────────
@@ -3915,7 +4076,7 @@ window.__ModuleLoader__.load({
3915
4076
  // 批量提交视频时八个方向都会重新出片,提交阶段先把预览整体盖住。
3916
4077
  const allBusy = tasks.has(KEY_VIDEO_ALL);
3917
4078
  const allLabel = tasks.label(KEY_VIDEO_ALL) ?? T("正在提交 8 个方向的视频任务…");
3918
- return h(React.Fragment, null, h("p", { className: "SPR_hint" }, T("提示词要求「固定镜头、固定背景、原地走三步」。Hailuo 一段通常要 1~6 分钟,提交后可以离开这个页面。")), h("textarea", {
4079
+ return h(React.Fragment, null, h("p", { className: "SPR_hint" }, T("提示词要求「固定镜头、固定背景、原地走三步」。Hailuo 一段通常要 1~6 分钟,提交后可以离开这个页面。") + T("某一个方向已经有现成的行走视频(自己电脑上的文件)时,点那一格的「选择本地视频」直接用它,不必走远程生成。")), h("textarea", {
3919
4080
  className: "SPR_area",
3920
4081
  value: videoPromptDraft,
3921
4082
  onChange: (event) => setVideoPromptDraft(event.target.value)
@@ -3965,7 +4126,11 @@ window.__ModuleLoader__.load({
3965
4126
  }))
3966
4127
  : image?.file !== undefined
3967
4128
  ? h(MediaBox, { overlay: nodeBusy || waiting, text: overlayText }, h("img", { className: "SPR_thumb", src: assetUrl(project, image.file, image.updatedAt), alt: direction.label }))
3968
- : h("div", { className: "SPR_thumbEmpty" }, T("还没有绿幕图")), nodeBusy || waiting ? h(BusyBadge, { show: true, text: overlayText }) : null, video?.remoteStatus !== undefined ? h("span", { className: "SPR_refRow" }, T("远端状态:{n0}", { n0: video.remoteStatus })) : null, video?.error !== undefined ? h("p", { className: "SPR_error" }, video.error) : null, h("div", { className: "SPR_btnRow" }, h(BusyBtn, {
4129
+ : h("div", { className: "SPR_thumbEmpty" }, T("还没有绿幕图")), nodeBusy || waiting ? h(BusyBadge, { show: true, text: overlayText }) : null, video?.origin === "local"
4130
+ ? h("span", { className: "SPR_refRow" }, T("本地视频:{n0}(不花远程调用)", { n0: video.originalName ?? fileLabel(video.file) }))
4131
+ : video?.remoteStatus !== undefined
4132
+ ? h("span", { className: "SPR_refRow" }, T("远端状态:{n0}", { n0: video.remoteStatus }))
4133
+ : null, video?.error !== undefined ? h("p", { className: "SPR_error" }, video.error) : null, h("div", { className: "SPR_btnRow" }, h(BusyBtn, {
3969
4134
  primary: video?.file === undefined && image?.file !== undefined,
3970
4135
  busy: tasks.has(taskKey),
3971
4136
  busyText: T("正在提交…"),
@@ -3982,7 +4147,15 @@ window.__ModuleLoader__.load({
3982
4147
  key: taskKey,
3983
4148
  label: T("正在生成「{n0}」视频…", { n0: direction.label })
3984
4149
  })
3985
- }, video?.file === undefined ? T("生成视频") : T("重新生成")), h(Btn, {
4150
+ }, video?.file === undefined ? T("生成视频") : T("重新生成")),
4151
+ // 本地自选视频:和「生成视频」并列,落在**这一格**的槽位上。
4152
+ h(LocalVideoPick, {
4153
+ label: T("选择本地视频"),
4154
+ title: T("用自己电脑上的一段「固定镜头 + 原地走」视频顶替这一方向的远程生成;之后照旧到第 3 步抽帧"),
4155
+ disabled: nodeBusy === true,
4156
+ testId: `local-video-${direction.key}`,
4157
+ onFile: (file) => pickLocalVideo({ start, setNotice, api, project, key: direction.key, file, label: direction.label })
4158
+ }), h(Btn, {
3986
4159
  on: video?.approved === true,
3987
4160
  disabled: video?.status !== "ready",
3988
4161
  onClick: () => void start(() => api.setApproved({
@@ -3991,7 +4164,12 @@ window.__ModuleLoader__.load({
3991
4164
  key: direction.key,
3992
4165
  approved: video?.approved !== true
3993
4166
  }), { reload: true })
3994
- }, video?.approved === true ? T("已通过") : T("通过"))));
4167
+ }, video?.approved === true ? T("已通过") : T("通过")), h(SaveLink, {
4168
+ url: video?.file === undefined ? undefined : assetUrl(project, video.file, video.updatedAt ?? project.updatedAt),
4169
+ name: `${project.name}-${direction.key}.mp4`,
4170
+ label: T("保存视频"),
4171
+ busy: nodeBusy
4172
+ })));
3995
4173
  })));
3996
4174
  }
3997
4175
  /**
@@ -4275,7 +4453,15 @@ window.__ModuleLoader__.load({
4275
4453
  key: direction.key,
4276
4454
  approved: node?.approved !== true
4277
4455
  }), { reload: true })
4278
- }, node?.approved === true ? T("已通过") : T("通过")))),
4456
+ }, node?.approved === true ? T("已通过") : T("通过")),
4457
+ // 预览带就是这一段的全部帧(绿幕原帧);要一张一张地拿,用底部的
4458
+ // 「保存全部图片(zip)」——那里连抠像帧和候选帧一起打进去。
4459
+ h(SaveLink, {
4460
+ url: node?.strip === undefined ? undefined : assetUrl(project, node.strip, node.updatedAt),
4461
+ name: `${project.name}-${direction.key}-strip.png`,
4462
+ label: T("保存预览带"),
4463
+ busy: nodeBusy
4464
+ }))),
4279
4465
  pickKey === direction.key
4280
4466
  ? h(FramePickPanel, {
4281
4467
  key: `${direction.key}-pick`,
@@ -4718,6 +4904,82 @@ window.__ModuleLoader__.load({
4718
4904
  }
4719
4905
  })));
4720
4906
  }
4907
+ /**
4908
+ * 「选择本地视频」:一个包着隐藏 `<input type="file">` 的标签按钮。
4909
+ *
4910
+ * 为什么是 `<label>` 而不是 button + ref:文件选择框必须由**用户手势**打开,
4911
+ * 而 label 天然把点击转给内部的 input,不需要 useRef / useState——少一个 Hook
4912
+ * 就少一处「渲染顺序变了」的坑(这个模块的界面测试按住 Hook 顺序)。
4913
+ */
4914
+ function LocalVideoPick({ label, title, onFile, disabled, testId }) {
4915
+ return h("label", {
4916
+ className: "SPR_btn SPR_fileBtn",
4917
+ "data-disabled": disabled === true ? "true" : undefined,
4918
+ title,
4919
+ "data-testid": testId
4920
+ }, label, h("input", {
4921
+ type: "file",
4922
+ accept: "video/*",
4923
+ disabled: disabled === true,
4924
+ style: { display: "none" },
4925
+ "data-testid": testId === undefined ? undefined : `${testId}-input`,
4926
+ onChange: (event) => {
4927
+ const file = event.target.files?.[0];
4928
+ // 先清空 value:同一个文件连选两次也要能触发 change。
4929
+ event.target.value = "";
4930
+ if (file !== undefined && file !== null)
4931
+ void onFile(file);
4932
+ }
4933
+ }));
4934
+ }
4935
+ /** `download` 属性要的是**文件名**:带上目录浏览器会当非法名丢掉。 */
4936
+ function fileLabel(relative) {
4937
+ const name = String(relative ?? "").split("/").pop() ?? "";
4938
+ return name === "" ? "asset.png" : name;
4939
+ }
4940
+ /**
4941
+ * 一张中间产物的「保存」。
4942
+ *
4943
+ * 用 `<a download>` 而不是按钮:下载本来就是浏览器的事(同源静态路由直接给文件),
4944
+ * 宿主不必为它多开一个方法;产物就在眼前时,「保存」应该是一个链接而不是又一次调用。
4945
+ */
4946
+ function SaveLink({ url, name, label, busy, title }) {
4947
+ if (url === undefined || url === null)
4948
+ return null;
4949
+ return h("a", {
4950
+ className: "SPR_btn SPR_fileBtn",
4951
+ href: url,
4952
+ download: name,
4953
+ title,
4954
+ style: { textDecoration: "none" },
4955
+ "aria-disabled": busy === true ? "true" : undefined,
4956
+ onClick: busy === true ? (event) => event.preventDefault() : undefined
4957
+ }, label ?? T("保存"));
4958
+ }
4959
+ /**
4960
+ * 选用一段本地视频(「选择本地视频」/ 拖进来之后走这里)。
4961
+ *
4962
+ * 两条链路共用:`key === "turn"` 是转圈视频(宿主导入后会**立刻**抽候选帧并切出
4963
+ * 八个方向),其余 key 是某个方向的行走视频(之后照旧到第 3 步抽帧)。
4964
+ * 文件字节走和源图同一条 base64 通道——插件零运行时依赖,不为它另开上传接口。
4965
+ */
4966
+ function pickLocalVideo({ start, setNotice, api, project, key, file, label }) {
4967
+ if (project === null || file === undefined || file === null)
4968
+ return;
4969
+ void start(async () => {
4970
+ const data = await readFileBase64(file);
4971
+ const result = await api.uploadVideo({ projectId: project.id, key, name: file.name, data });
4972
+ setNotice({
4973
+ kind: "ok",
4974
+ text: key === "turn"
4975
+ ? result?.extractStarted === true
4976
+ ? T("已选用本地视频,正在抽候选帧并切出八个方向…")
4977
+ : T("已选用本地视频(抽帧没有自动开始,点「抽取候选帧」即可)")
4978
+ : T("已选用「{n0}」的本地视频,接着到第 3 步抽取序列帧", { n0: label ?? key })
4979
+ });
4980
+ return result;
4981
+ }, { reload: true }, { key: KEY_LOCAL_VIDEO(key), label: T("正在导入本地视频…") });
4982
+ }
4721
4983
  /** 抠像参数表单(三个模块共用同一套字段)。 */
4722
4984
  function KeyingFields({ draft, onChange }) {
4723
4985
  return h("div", { className: "SPR_fields" }, h(NumField, { label: T("抠像下限(绿色优势)"), value: draft.keyLow ?? 14, min: 0, max: 255, onChange: (v) => onChange({ keyLow: v }) }), h(NumField, { label: T("抠像上限(绿色优势)"), value: draft.keyHigh ?? 80, min: 1, max: 255, onChange: (v) => onChange({ keyHigh: v }) }), h(NumField, { label: T("去绿溢出 0~1"), value: draft.despill ?? 0.65, min: 0, max: 1, step: 0.05, onChange: (v) => onChange({ despill: v }) }), h(NumField, { label: T("背景分割容差(0 = 只认绿色)"), value: draft.bgTolerance ?? 90, min: 0, max: 160, onChange: (v) => onChange({ bgTolerance: v }) }), h(NumField, { label: T("边缘收缩(px)"), value: draft.edgeShrink ?? 0, min: 0, max: 8, onChange: (v) => onChange({ edgeShrink: v }) }));
@@ -4850,6 +5112,10 @@ window.__ModuleLoader__.load({
4850
5112
  return h("svg", { viewBox: "0 0 10 6", width: 11, height: 7, "aria-hidden": "true", fill: "currentColor" }, path("M5 0 10 6H0z"));
4851
5113
  if (name === "down")
4852
5114
  return h("svg", { viewBox: "0 0 10 6", width: 11, height: 7, "aria-hidden": "true", fill: "currentColor" }, path("M0 0h10L5 6z"));
5115
+ // 标记:圆圈里一个数字(画布上标记点就是长这样的,工具图标照它画,用户一眼能对上)。
5116
+ if (name === "marker") {
5117
+ return h("svg", box, h("circle", { cx: 12, cy: 12, r: 8.4, fill: "none", stroke: "currentColor", strokeWidth: 2 }), h("text", { x: 12, y: 16.1, textAnchor: "middle", fontSize: 11.5, fontWeight: 700, fill: "currentColor" }, "1"));
5118
+ }
4853
5119
  return null;
4854
5120
  }
4855
5121
  /**
@@ -4879,6 +5145,14 @@ window.__ModuleLoader__.load({
4879
5145
  /** 计划缓存:key → 绘制条目。`have` 直接由它派发。 */
4880
5146
  const planRef = React.useRef(new Map());
4881
5147
  const [planOps, setPlanOps] = React.useState(new Map());
5148
+ /**
5149
+ * 视口里的标记点(宿主每次查询整份回)。
5150
+ *
5151
+ * ⚠️ **故意不进 `planRef` 那份按块缓存**:编号是连续的,删掉第 2 个之后第 3 个
5152
+ * 就变成第 2 个 —— 缓存住的号码会留在屏幕上。所以它是独立的一份状态,
5153
+ * 每次查询覆盖(数量级是几十个)。
5154
+ */
5155
+ const [planMarkers, setPlanMarkers] = React.useState([]);
4882
5156
  const [visibleKeys, setVisibleKeys] = React.useState([]);
4883
5157
  const visibleRef = React.useRef([]);
4884
5158
  /** 自增一次=「重新问一遍宿主缺哪些块」(补拉用)。 */
@@ -4920,6 +5194,12 @@ window.__ModuleLoader__.load({
4920
5194
  const [single, setSingle] = React.useState(false);
4921
5195
  const [showGrid, setShowGrid] = React.useState(false);
4922
5196
  const [hover, setHover] = React.useState(null);
5197
+ /** 选中 / 正在改名的标记 id(画布上那个圈描红、标记卡里高亮)。 */
5198
+ const [markerSel, setMarkerSel] = React.useState(null);
5199
+ /** 图层改名的就地草稿:`{ id, value }`;null = 没有在改。 */
5200
+ const [layerDraft, setLayerDraft] = React.useState(null);
5201
+ /** 标记改名的就地草稿:`{ id, value }`。 */
5202
+ const [markerDraft, setMarkerDraft] = React.useState(null);
4923
5203
  // ── 保存状态 / 生成草稿 / 导出 ────────────────────────────────────────
4924
5204
  const [genKind, setGenKind] = React.useState("random");
4925
5205
  const [genSeed, setGenSeed] = React.useState(20261005);
@@ -5036,14 +5316,6 @@ window.__ModuleLoader__.load({
5036
5316
  const fittedRef = React.useRef(null);
5037
5317
  const spaceRef = React.useRef(false);
5038
5318
  const intent = useStudioIntent();
5039
- /**
5040
- * 实验性进入提示。
5041
- *
5042
- * ⚠️ Hook 必须在**任何提前 return 之前**:下面 `view === null` 那条早返回
5043
- * 会绕过它,顺序一变就是 React error #310,整块白屏。
5044
- */
5045
- const [gateOpen, setGateOpen] = React.useState(experimentalGateMuted.map !== true);
5046
- const closeGate = React.useCallback(() => setGateOpen(false), []);
5047
5319
  const viewId = view === null ? null : view.id;
5048
5320
  const layers = view === null ? [] : view.layers || [];
5049
5321
  const safeLayerIndex = layers.length === 0 ? 0 : Math.min(Math.max(0, layerIndex), layers.length - 1);
@@ -5131,6 +5403,7 @@ window.__ModuleLoader__.load({
5131
5403
  staleRef.current = new Set();
5132
5404
  visibleRef.current = [];
5133
5405
  setPlanOps(new Map());
5406
+ setPlanMarkers([]);
5134
5407
  setVisibleKeys([]);
5135
5408
  }, []);
5136
5409
  /**
@@ -5231,6 +5504,8 @@ window.__ModuleLoader__.load({
5231
5504
  planRef.current = next;
5232
5505
  visibleRef.current = keys;
5233
5506
  setPlanOps(next);
5507
+ // 标记**整份覆盖**(不进那份按块缓存):编号会随删除整体前移,缓存住的号码会留在屏幕上。
5508
+ setPlanMarkers(Array.isArray(result?.markers) ? result.markers : []);
5234
5509
  setVisibleKeys(keys);
5235
5510
  const fps = Number(result?.fps);
5236
5511
  const frames = Number(result?.frameCount);
@@ -5438,6 +5713,27 @@ window.__ModuleLoader__.load({
5438
5713
  count++;
5439
5714
  }
5440
5715
  }
5716
+ /**
5717
+ * 标记点:圆 + 圆圈里的数字。
5718
+ *
5719
+ * 圆心、半径、字号、数字**全在宿主给的计划里** —— 界面只负责 `arc` 与 `fillText`。
5720
+ * 绘制放在图块与格线**之后**,所以标记永远压在地图上;环绕接缝处同一个标记会出现
5721
+ * 多份(宿主按像素位置各发一条),这里照单全画。
5722
+ */
5723
+ for (const marker of planMarkers) {
5724
+ ctx.beginPath();
5725
+ ctx.arc(marker.x, marker.y, marker.radius, 0, Math.PI * 2);
5726
+ ctx.fillStyle = marker.id === markerSel ? "rgba(210,59,44,0.92)" : "rgba(20,22,30,0.86)";
5727
+ ctx.fill();
5728
+ ctx.lineWidth = Math.max(1, marker.radius * 0.16);
5729
+ ctx.strokeStyle = "#f0c040";
5730
+ ctx.stroke();
5731
+ ctx.fillStyle = "#ffffff";
5732
+ ctx.font = `700 ${marker.font}px sans-serif`;
5733
+ ctx.textAlign = "center";
5734
+ ctx.textBaseline = "middle";
5735
+ ctx.fillText(String(marker.n), marker.x, marker.y);
5736
+ }
5441
5737
  // 悬停格:2px 红框(四条细矩形,不用 stroke,免得被 DPR 影响粗细)
5442
5738
  // ⚠️ 用**未取模**的坐标定位:环绕时同一格在屏幕上有多份,红框必须画在指针
5443
5739
  // 所在的那一份上。拿取模后的 r/c 去算,指针在地图外那一份时红框会跳一整张地图。
@@ -5454,6 +5750,41 @@ window.__ModuleLoader__.load({
5454
5750
  ctx.fillRect(topLeft.x, topLeft.y + thickness, thickness, hh - thickness * 2);
5455
5751
  ctx.fillRect(topLeft.x + w - thickness, topLeft.y + thickness, thickness, hh - thickness * 2);
5456
5752
  }
5753
+ /**
5754
+ * 悬停到标记上:把**名字**写在圆圈旁边。
5755
+ *
5756
+ * 名字不常驻画布(几十个名字会糊成一片),只有指针停上去才出现。
5757
+ * 「停到了哪个」按**指针到圆心的距离**判:环绕时同一个标记在屏幕上有好几份,
5758
+ * 只看格号会挑到地图另一头那一份(红框当年就是这个坑)。圆心与半径都是宿主给的。
5759
+ */
5760
+ if (hover !== null && hover !== undefined) {
5761
+ let found = undefined;
5762
+ let best = Infinity;
5763
+ for (const marker of planMarkers) {
5764
+ const distance = Math.hypot(marker.x - hover.x, marker.y - hover.y);
5765
+ if (distance <= marker.radius * 2.5 && distance < best) {
5766
+ best = distance;
5767
+ found = marker;
5768
+ }
5769
+ }
5770
+ if (found !== undefined) {
5771
+ const label = found.name === "" ? T("标记 {n0}", { n0: String(found.n) }) : `${found.n} · ${found.name}`;
5772
+ // 缩得很小时文字会跟着变小到看不清,所以字号有个下限(只影响这个浮层,不影响圆)。
5773
+ const font = Math.max(12 / zoom, found.font * 0.85);
5774
+ ctx.font = `600 ${font}px sans-serif`;
5775
+ ctx.textAlign = "left";
5776
+ ctx.textBaseline = "middle";
5777
+ const padding = 4 / zoom;
5778
+ const boxWidth = ctx.measureText(label).width + padding * 2;
5779
+ const boxHeight = font + padding * 2;
5780
+ const left = found.x + found.radius + 3 / zoom;
5781
+ const top = found.y - boxHeight / 2;
5782
+ ctx.fillStyle = "rgba(20,22,30,0.9)";
5783
+ ctx.fillRect(left, top, boxWidth, boxHeight);
5784
+ ctx.fillStyle = "#f3e7d3";
5785
+ ctx.fillText(label, left + padding, found.y);
5786
+ }
5787
+ }
5457
5788
  if (stats !== null && typeof window !== "undefined") {
5458
5789
  stats.frame = frame;
5459
5790
  window.__mapDrawStats = stats;
@@ -5466,7 +5797,7 @@ window.__ModuleLoader__.load({
5466
5797
  */
5467
5798
  window.__mapCamera = { pan: { x: pan.x, y: pan.y }, zoom, viewport: { w: viewport.w, h: viewport.h } };
5468
5799
  }
5469
- }, [layout, viewport, zoom, pan, planOps, legend, legendMap, single, showGrid, hover, frame]);
5800
+ }, [layout, viewport, zoom, pan, planOps, planMarkers, markerSel, legend, legendMap, single, showGrid, hover, frame]);
5470
5801
  React.useEffect(() => {
5471
5802
  draw();
5472
5803
  }, [draw, imagesReady]);
@@ -5764,6 +6095,22 @@ window.__ModuleLoader__.load({
5764
6095
  strokeRef.current = { mode: "pan", clientX: event.clientX, clientY: event.clientY, pan: { ...pan } };
5765
6096
  return;
5766
6097
  }
6098
+ if (tool === "marker") {
6099
+ const existing = markerAtCell(hit.r, hit.c);
6100
+ if (event.button === 2) {
6101
+ if (existing !== undefined)
6102
+ void markerOp({ kind: "marker", op: "remove", id: existing.id }, true);
6103
+ return;
6104
+ }
6105
+ if (existing !== undefined) {
6106
+ // 点已有标记 = 选中它(图层卡里就能改名);按住拖到别的格就是挪位置。
6107
+ setMarkerSel(existing.id);
6108
+ strokeRef.current = { mode: "marker", id: existing.id, from: { r: hit.r, c: hit.c } };
6109
+ return;
6110
+ }
6111
+ void markerOp({ kind: "marker", op: "add", r: hit.r, c: hit.c }, true);
6112
+ return;
6113
+ }
5767
6114
  if (event.button === 2 || tool === "eraser") {
5768
6115
  currentStroke.current = null;
5769
6116
  strokeRef.current = { mode: "paint", from: hit, tile: 0 };
@@ -5821,6 +6168,14 @@ window.__ModuleLoader__.load({
5821
6168
  * 红框是按格对齐的,格号没变画面就没变,返回同一个对象让 React 直接跳过这次渲染。
5822
6169
  */
5823
6170
  setHover((prev) => (prev !== null && prev.r === hit.r && prev.c === hit.c ? prev : hit));
6171
+ if (stroke !== null && stroke !== undefined && stroke.mode === "marker") {
6172
+ // 每跨一格提交一次(挪位置不改编号,所以**不重读视图**;松手时补一次)。
6173
+ if (stroke.from.r !== hit.r || stroke.from.c !== hit.c) {
6174
+ stroke.from = { r: hit.r, c: hit.c };
6175
+ void markerOp({ kind: "marker", op: "move", id: stroke.id, r: hit.r, c: hit.c }, false);
6176
+ }
6177
+ return;
6178
+ }
5824
6179
  if (stroke !== null && stroke !== undefined && stroke.mode === "paint") {
5825
6180
  if (stroke.from.r !== hit.r || stroke.from.c !== hit.c) {
5826
6181
  paintCells(stroke.from, hit, stroke.tile);
@@ -5833,9 +6188,14 @@ window.__ModuleLoader__.load({
5833
6188
  pointersRef.current.delete(pointerId);
5834
6189
  if (pointersRef.current.size < 2)
5835
6190
  delete pointersRef.current.pinch;
6191
+ const stroke = strokeRef.current;
5836
6192
  strokeRef.current = null;
5837
6193
  currentStroke.current = null;
5838
6194
  void flushOps();
6195
+ // 拖完标记补读一次视图:拖动期间刻意没读(每格读一次太吵),列表里的坐标要跟上。
6196
+ if (stroke !== null && stroke !== undefined && stroke.mode === "marker" && api !== undefined && viewId !== null) {
6197
+ void loadProject(viewId, true);
6198
+ }
5839
6199
  };
5840
6200
  // 快捷键:B/E/G/I/H/V 与撤销重做;焦点在输入框里时全部失效
5841
6201
  React.useEffect(() => {
@@ -5876,6 +6236,8 @@ window.__ModuleLoader__.load({
5876
6236
  setTool("pipette");
5877
6237
  else if (key === "h")
5878
6238
  setTool("hand");
6239
+ else if (key === "m")
6240
+ setTool("marker");
5879
6241
  else if (key === "v")
5880
6242
  setSingle((value) => value !== true);
5881
6243
  };
@@ -6272,6 +6634,58 @@ window.__ModuleLoader__.load({
6272
6634
  return;
6273
6635
  await saveDoc({ clearLayerId: activeLayer.id }, T("已清空这一层"));
6274
6636
  };
6637
+ // ── 标记点:放 / 改名 / 挪走 / 删掉 ──────────────────────────────────
6638
+ /**
6639
+ * 标记改动走的是**和画笔同一条 op 通道**:撤销栈、脏块(`dropKeys`)全是现成的,
6640
+ * 界面不需要自己算「这一下让哪几块失效」。
6641
+ *
6642
+ * `refresh`:增删会改变编号(删掉第 2 个,第 3 个就变成第 2 个),所以要把视图
6643
+ * 重读一遍让列表跟上;拖动挪位置不影响编号,拖完再读一次就够。
6644
+ */
6645
+ const markerOp = async (op, refresh) => {
6646
+ if (api === undefined || viewId === null)
6647
+ return;
6648
+ try {
6649
+ applyResult(await api.applyMapOps({ projectId: viewId, ops: [op], have: [...planRef.current.keys()] }));
6650
+ }
6651
+ catch (error) {
6652
+ setNotice({ kind: "error", text: msg(error) });
6653
+ return;
6654
+ }
6655
+ if (refresh === true)
6656
+ await loadProject(viewId, true);
6657
+ };
6658
+ /** 这一格的标记(没有就 undefined)。格号是**规范坐标**,与命中测试同一套。 */
6659
+ const markerAtCell = (r, c) => {
6660
+ const list = view === null || view.markers === undefined ? [] : view.markers;
6661
+ return list.find((marker) => marker.r === r && marker.c === c);
6662
+ };
6663
+ /** 把视图挪到某一格(标记列表里的「定位」)。用允许复刻的那份坐标函数,不新算几何。 */
6664
+ const centerOnCell = (r, c) => {
6665
+ if (layout === null)
6666
+ return;
6667
+ const topLeft = MAP_cellTopLeft(layout, r, c, layout.grid.tileWidth, layout.grid.tileHeight);
6668
+ const center = { x: topLeft.x + layout.grid.tileWidth / 2, y: topLeft.y + layout.grid.tileHeight / 2 };
6669
+ setPan(clampPan({ x: center.x - viewport.w / (2 * zoom), y: center.y - viewport.h / (2 * zoom) }));
6670
+ };
6671
+ /** 图层改名:空名字**本地就拦住**(宿主对空名字是静默 no-op,会让人以为改成功了)。 */
6672
+ const commitLayerName = async (id, value) => {
6673
+ setLayerDraft(null);
6674
+ const name = String(value ?? "").trim();
6675
+ if (name === "") {
6676
+ setNotice({ kind: "error", text: T("图层名字不能为空") });
6677
+ return;
6678
+ }
6679
+ const current = layers.find((layer) => layer.id === id);
6680
+ if (current !== undefined && current.name === name)
6681
+ return;
6682
+ await saveDoc({ layers: [{ id, name }] }, T("已重命名这一层"));
6683
+ };
6684
+ /** 标记改名:空名字是合法的(界面按「标记 N」显示)。 */
6685
+ const commitMarkerName = async (id, value) => {
6686
+ setMarkerDraft(null);
6687
+ await markerOp({ kind: "marker", op: "rename", id, name: String(value ?? "") }, true);
6688
+ };
6275
6689
  const runGenerate = async () => {
6276
6690
  if (view === null || api === undefined)
6277
6691
  return;
@@ -6449,7 +6863,7 @@ window.__ModuleLoader__.load({
6449
6863
  event.target.value = "";
6450
6864
  }
6451
6865
  });
6452
- const shell = (inner) => h("div", { className: "SPR_moduleBody", "data-module": "map" }, gateOpen ? h(MapExperimentalDialog, { onClose: closeGate }) : null, inner, fileInput, addFileInput, addDialog);
6866
+ const shell = (inner) => h("div", { className: "SPR_moduleBody", "data-module": "map" }, inner, fileInput, addFileInput, addDialog);
6453
6867
  if (view === null || layout === null) {
6454
6868
  return shell(h("div", { className: "SPR_mapEdRoot" }, h("div", { className: "SPR_mapEdEmpty" }, h("p", { className: "SPR_mapEdEmptyText" }, T("还没有地图项目。")), h("p", { className: "SPR_mapEdHint" }, T("选一张素材图开始,或者先用自带素材试试。建出来就是 32×32、两层,可以直接画。")), h("div", { className: "SPR_mapEdEmptyRow" }, h(Btn, { onClick: () => askProjectName("create") }, T("新建项目")), h(Btn, { primary: true, onClick: () => fileRef.current?.click(), busy: busyKey === "upload" }, T("选一张素材图开始")), h(Btn, { onClick: () => void startWithSample(), busy: busyKey === "sample" }, T("用自带素材试试"))), notice === null ? null : h("div", { className: `SPR_notice SPR_notice-${notice.kind}` }, notice.text)), nameDialog));
6455
6869
  }
@@ -6585,10 +6999,10 @@ window.__ModuleLoader__.load({
6585
6999
  onClick: options.onClick
6586
7000
  }, options.icon === undefined ? null : h(MapToolIcon, { name: options.icon }));
6587
7001
  };
6588
- const tools = h("div", { className: "SPR_mapEdTools" }, toolButton("undo", T("撤销"), T("撤回上一步"), { icon: "undo", shortcut: "⌘Z", onClick: () => void doUndo(), disabled: view.canUndo !== true }), toolButton("redo", T("重做"), T("把刚撤回的一步再做回来"), { icon: "redo", shortcut: "⇧⌘Z", onClick: () => void doRedo(), disabled: view.canRedo !== true }), toolButton("pen", T("画笔"), T("按住左键涂抹,铺当前选中的那块图"), { icon: "pen", shortcut: "B", on: tool === "pen", onClick: () => setTool("pen") }), toolButton("eraser", T("橡皮"), T("把这格擦成空;右键随时是橡皮"), { icon: "eraser", shortcut: "E", on: tool === "eraser", onClick: () => setTool("eraser") }), toolButton("bucket", T("油漆桶"), T("同色的连通区一次填满"), { icon: "bucket", shortcut: "G", on: tool === "bucket", onClick: () => setTool("bucket") }), toolButton("pipette", T("吸管"), T("吸取这一格用的图块,变成当前笔刷"), { icon: "pipette", shortcut: "I", on: tool === "pipette", onClick: () => setTool("pipette") }), toolButton("hand", T("抓手"), T("拖动平移画布;空格拖或中键拖也行"), { icon: "hand", shortcut: "H", on: tool === "hand", onClick: () => setTool("hand") }), toolButton("single", T("单层预览"), T("只显示当前这一层,底铺绿色"), { icon: "single", shortcut: "V", on: single === true, onClick: () => setSingle(single !== true) }), h("div", {
7002
+ const tools = h("div", { className: "SPR_mapEdTools" }, toolButton("undo", T("撤销"), T("撤回上一步"), { icon: "undo", shortcut: "⌘Z", onClick: () => void doUndo(), disabled: view.canUndo !== true }), toolButton("redo", T("重做"), T("把刚撤回的一步再做回来"), { icon: "redo", shortcut: "⇧⌘Z", onClick: () => void doRedo(), disabled: view.canRedo !== true }), toolButton("pen", T("画笔"), T("按住左键涂抹,铺当前选中的那块图"), { icon: "pen", shortcut: "B", on: tool === "pen", onClick: () => setTool("pen") }), toolButton("eraser", T("橡皮"), T("把这格擦成空;右键随时是橡皮"), { icon: "eraser", shortcut: "E", on: tool === "eraser", onClick: () => setTool("eraser") }), toolButton("bucket", T("油漆桶"), T("同色的连通区一次填满"), { icon: "bucket", shortcut: "G", on: tool === "bucket", onClick: () => setTool("bucket") }), toolButton("pipette", T("吸管"), T("吸取这一格用的图块,变成当前笔刷"), { icon: "pipette", shortcut: "I", on: tool === "pipette", onClick: () => setTool("pipette") }), toolButton("hand", T("抓手"), T("拖动平移画布;空格拖或中键拖也行"), { icon: "hand", shortcut: "H", on: tool === "hand", onClick: () => setTool("hand") }), toolButton("marker", T("标记"), T("地图上点一格放一个标记;点已有标记可以改名、按住拖动可以挪位置;右键删掉它"), { icon: "marker", shortcut: "M", on: tool === "marker", onClick: () => setTool("marker") }), h("div", {
6589
7003
  key: "layer",
6590
7004
  className: "SPR_mapEdTool SPR_mapEdLayerBtn",
6591
- onMouseEnter: showToolTip(T("图层"), T("上半换上一层、下半换下一层;中间的数字是当前层号"), null),
7005
+ onMouseEnter: showToolTip(T("图层"), T("点中间的数字打开图层列表(改名 / 换顺序 / 删掉);上半换上一层、下半换下一层"), null),
6592
7006
  onMouseLeave: hideToolTip
6593
7007
  }, h("button", {
6594
7008
  type: "button",
@@ -6597,7 +7011,13 @@ window.__ModuleLoader__.load({
6597
7011
  "aria-label": T("上一层"),
6598
7012
  disabled: safeLayerIndex >= layers.length - 1,
6599
7013
  onClick: () => setLayerIndex(Math.min(layers.length - 1, safeLayerIndex + 1))
6600
- }, h(MapToolIcon, { name: "up" })), h("span", { className: "SPR_mapEdLayerNum" }, String(safeLayerIndex + 1)), h("button", {
7014
+ }, h(MapToolIcon, { name: "up" })), h("button", {
7015
+ type: "button",
7016
+ className: "SPR_mapEdLayerNum",
7017
+ "aria-label": T("图层"),
7018
+ "data-testid": "map-open-layers",
7019
+ onClick: () => setOpenCard(openCard === "layers" ? null : "layers")
7020
+ }, String(safeLayerIndex + 1)), h("button", {
6601
7021
  type: "button",
6602
7022
  className: "SPR_mapEdLayerHalf",
6603
7023
  "data-dir": "down",
@@ -6707,16 +7127,74 @@ window.__ModuleLoader__.load({
6707
7127
  : null), h("p", { className: "SPR_mapEdHint" }, canSaveAs
6708
7128
  ? T("下载走浏览器(默认进它的下载目录);想自己挑位置就点「另存为…」。")
6709
7129
  : T("下载走浏览器:文件会进它的下载目录(想每次都自己挑位置,在浏览器里打开「下载前询问保存位置」)。")), h("ul", { className: "SPR_mapEdFiles", "data-testid": "map-export-files" }, listedFiles.map((file) => h("li", { key: file }, h("a", { href: exportUrlOf(file), download: baseNameOf(file), "data-testid": `map-export-file-${baseNameOf(file)}` }, file), isZip(file) ? h("span", { className: "SPR_mapEdTsBadge", "data-anim": "true" }, T("打包,含全部内容")) : null))), h("p", { className: "SPR_mapEdHint", "data-testid": "map-export-path" }, T("文件都在 {n0}", { n0: view.exportPath === "" ? "—" : String(view.exportPath) }))));
7130
+ /**
7131
+ * 图层卡:一张列表管三件事 —— 改名字、换顺序、删掉;最上面一行固定是「标记层」。
7132
+ *
7133
+ * 名字是宿主的字段(`saveMapDoc({ layers: [{ id, name }] })`),所以改名走一次结构补丁、
7134
+ * 回来重读视图。标记列表放在同一张卡里:点一行就能改名 / 定位 / 删掉。
7135
+ *
7136
+ * 列表**从上往下列**(最后添加的层在最上):画布上就是这个叠放顺序,反向列会让人点错。
7137
+ */
7138
+ const layerRows = [...layers].map((layer, index) => ({ layer, index })).reverse();
7139
+ const markers = view === null || view.markers === undefined ? [] : view.markers;
7140
+ const smallBtn = (key, label, title, onClick, disabled) => h("button", { key, type: "button", className: "SPR_mapEdMiniBtn", title, "aria-label": title, disabled: disabled === true, onClick }, label);
7141
+ const layersCard = h("div", { className: "SPR_mapEdCard", "data-testid": "map-layers-card" }, cardHead(T("图层")), h("p", { className: "SPR_mapEdHint" }, T("点名字可以改名,右边可以换顺序或删掉")), h("div", { className: "SPR_mapEdLayerList" }, h("div", { className: "SPR_mapEdLayerRow", "data-testid": "map-marker-layer-row" }, h("span", { className: "SPR_mapEdLayerIdx" }, "●"), h("span", { className: "SPR_mapEdLayerName", style: { cursor: "default" } }, T("标记层")), h("span", { className: "SPR_mapEdMarkerAt" }, T("{n0} 个标记", { n0: String(markers.length) })), smallBtn("marker", T("标记"), T("标记"), () => setTool("marker"), false)), layerRows.map(({ layer, index }) => {
7142
+ const editing = layerDraft !== null && layerDraft.id === layer.id;
7143
+ return h("div", { key: layer.id, className: "SPR_mapEdLayerRow", "data-on": index === safeLayerIndex ? "true" : undefined }, h("span", { className: "SPR_mapEdLayerIdx" }, String(index + 1)), editing
7144
+ ? h("input", {
7145
+ className: "SPR_mapEdLayerNameInput",
7146
+ autoFocus: true,
7147
+ value: layerDraft.value,
7148
+ "data-testid": `map-layer-name-${index}`,
7149
+ onChange: (event) => setLayerDraft({ id: layer.id, value: event.target.value }),
7150
+ onBlur: () => void commitLayerName(layer.id, layerDraft.value),
7151
+ onKeyDown: (event) => {
7152
+ if (event.key === "Enter") {
7153
+ event.preventDefault();
7154
+ event.currentTarget.blur();
7155
+ }
7156
+ else if (event.key === "Escape") {
7157
+ setLayerDraft(null);
7158
+ }
7159
+ }
7160
+ })
7161
+ : h("button", {
7162
+ type: "button",
7163
+ className: "SPR_mapEdLayerName",
7164
+ "data-testid": `map-layer-pick-${index}`,
7165
+ title: T("点名字可以改名,右边可以换顺序或删掉"),
7166
+ onClick: () => setLayerIndex(index),
7167
+ onDoubleClick: () => setLayerDraft({ id: layer.id, value: layer.name })
7168
+ }, layer.name), smallBtn("up", "↑", T("上移一层"), () => void saveDoc({ moveLayer: { id: layer.id, toIndex: index + 1 } }, T("已换图层顺序")), index >= layers.length - 1), smallBtn("down", "↓", T("下移一层"), () => void saveDoc({ moveLayer: { id: layer.id, toIndex: index - 1 } }, T("已换图层顺序")), index <= 0), smallBtn("remove", "×", T("删掉当前这一层"), () => void saveDoc({ removeLayerId: layer.id }, T("已删掉这一层")), layers.length <= 1));
7169
+ })), h("div", { className: "SPR_mapEdCardRow" }, h(Btn, { onClick: () => void saveDoc({ addLayer: { name: T("图层 {n0}", { n0: String(layers.length + 1) }) } }, T("已加一层")) }, T("加一层")), h(Btn, { onClick: () => void clearLayer() }, T("清空当前图层")), h("label", { className: "SPR_mapEdCheck" }, h("input", { type: "checkbox", "data-testid": "map-single-layer", checked: single === true, onChange: (event) => setSingle(event.target.checked) }), T("只看这一层"))), h("div", { className: "SPR_mapEdMarkerList", "data-testid": "map-marker-list" }, markers.length === 0
7170
+ ? h("p", { className: "SPR_mapEdHint" }, T("还没有标记。选「标记」工具,在地图上点一格。"))
7171
+ : markers.map((marker) => h("div", { key: marker.id, className: "SPR_mapEdMarkerRow", "data-on": marker.id === markerSel ? "true" : undefined, "data-testid": `map-marker-${marker.n}` }, h("span", { className: "SPR_mapEdMarkerDot" }, String(marker.n)), h("input", {
7172
+ className: "SPR_mapEdMarkerName",
7173
+ "aria-label": T("标记名字"),
7174
+ placeholder: T("标记 {n0}", { n0: String(marker.n) }),
7175
+ value: markerDraft !== null && markerDraft.id === marker.id ? markerDraft.value : marker.name,
7176
+ onFocus: () => setMarkerSel(marker.id),
7177
+ onChange: (event) => setMarkerDraft({ id: marker.id, value: event.target.value }),
7178
+ onBlur: () => {
7179
+ if (markerDraft !== null && markerDraft.id === marker.id)
7180
+ void commitMarkerName(marker.id, markerDraft.value);
7181
+ },
7182
+ onKeyDown: (event) => {
7183
+ if (event.key === "Enter") {
7184
+ event.preventDefault();
7185
+ event.currentTarget.blur();
7186
+ }
7187
+ }
7188
+ }), h("span", { className: "SPR_mapEdMarkerAt" }, `(${marker.r},${marker.c})`), smallBtn("go", T("定位"), T("定位"), () => {
7189
+ setMarkerSel(marker.id);
7190
+ centerOnCell(marker.r, marker.c);
7191
+ }, false), smallBtn("drop", T("删掉"), T("删掉"), () => void markerOp({ kind: "marker", op: "remove", id: marker.id }, true), false)))));
6710
7192
  const settingsCard = h("div", { className: "SPR_mapEdCard" }, cardHead(T("设置")), row(T("地图大小"), h("div", { className: "SPR_mapEdPair" }, h(NumField, { label: T("宽"), value: view.cols, min: 1, max: 512, onChange: (value) => void applyMapSize(value, view.rows) }), h("span", { className: "SPR_mapEdTimes" }, "×"), h(NumField, { label: T("高"), value: view.rows, min: 1, max: 512, onChange: (value) => void applyMapSize(view.cols, value) })), T("单位是格。改大只是多出空地;改小会丢掉范围外的格子(可撤销)")), row(T("动画速度"), h("select", {
6711
7193
  className: "SPR_mapEdSelect",
6712
7194
  "data-testid": "map-anim-speed",
6713
7195
  value: speedValue,
6714
7196
  onChange: (event) => setAnimFps(Number(event.target.value))
6715
- }, speedOptions.map(([value, label]) => h("option", { key: value, value }, `${label} · ${value} 帧/秒`))), T("只影响会动的素材(水、翻页图这类)")), h("div", { className: "SPR_mapEdCardRow" }, h(Btn, { onClick: () => void saveDoc({ addLayer: { name: T("图层 {n0}", { n0: String(layers.length + 1) }) } }, T("已加一层")) }, T("加一层")), h(Btn, {
6716
- disabled: layers.length <= 1,
6717
- title: layers.length <= 1 ? T("至少要留一层") : T("删掉当前这一层"),
6718
- onClick: () => void saveDoc({ removeLayerId: activeLayer.id }, T("已删掉这一层"))
6719
- }, T("删一层")), h(Btn, { onClick: () => void clearLayer() }, T("清空当前图层"))), h("label", { className: "SPR_mapEdCheck" }, h("input", { type: "checkbox", checked: showGrid === true, onChange: (event) => setShowGrid(event.target.checked) }), T("网格线")), h("div", { className: "SPR_mapEdHelp" }, h("h5", null, T("帮助")), h("p", null, T("左键拖动=用当前工具画;空格拖动或中键拖动=平移;滚轮=缩放;右键=橡皮。")), h("p", null, T("调色板里点一下选一块图当笔刷,按住 Shift 或 Ctrl 可以多选,「一键生成」会用这些图块。")), h("p", null, T("地图四周是接上的:自动连接会把上下、左右两边接起来。画布拖不出地图 —— 拖到边就停,地图左上角对齐后不会再乱动;图外那片空白画不上。"))), h("div", { className: "SPR_mapEdCardRow" }, h(Btn, { onClick: () => void withApi(() => api.revealMapProject({ projectId: view.id })) }, T("在访达中打开项目目录")), h(Btn, { primary: true, on: approvedAll === true, onClick: () => void markWholeModuleSeen() }, T("整个模块看过了"))));
7197
+ }, speedOptions.map(([value, label]) => h("option", { key: value, value }, `${label} · ${value} 帧/秒`))), T("只影响会动的素材(水、翻页图这类)")), h("label", { className: "SPR_mapEdCheck" }, h("input", { type: "checkbox", checked: showGrid === true, onChange: (event) => setShowGrid(event.target.checked) }), T("网格线")), h("div", { className: "SPR_mapEdHelp" }, h("h5", null, T("帮助")), h("p", null, T("左键拖动=用当前工具画;空格拖动或中键拖动=平移;滚轮=缩放;右键=橡皮。")), h("p", null, T("调色板里点一下选一块图当笔刷,按住 Shift 或 Ctrl 可以多选,「一键生成」会用这些图块。")), h("p", null, T("地图四周是接上的:自动连接会把上下、左右两边接起来。画布拖不出地图 —— 拖到边就停,地图左上角对齐后不会再乱动;图外那片空白画不上。"))), h("div", { className: "SPR_mapEdCardRow" }, h(Btn, { onClick: () => void withApi(() => api.revealMapProject({ projectId: view.id })) }, T("在访达中打开项目目录")), h(Btn, { primary: true, on: approvedAll === true, onClick: () => void markWholeModuleSeen() }, T("整个模块看过了"))));
6720
7198
  const genTiles = multi.length > 0 ? multi : brush === null ? [] : [brush.index];
6721
7199
  const genCard = h("div", { className: "SPR_mapEdCard" }, cardHead(T("一键生成")), h("div", { className: "SPR_mapEdRadios" }, [
6722
7200
  ["random", T("随机铺满")],
@@ -6729,7 +7207,17 @@ window.__ModuleLoader__.load({
6729
7207
  : genKind === "continent"
6730
7208
  ? T("大陆:按顺序取最多四块当四种地貌(水下 / 海面 / 草地 / 雪地)。")
6731
7209
  : T("随机铺满:在选中的图块里均匀随机。")), h("div", { className: "SPR_mapEdCardRow" }, h(NumField, { label: T("种子"), value: genSeed, onChange: (value) => setGenSeed(value) }), h(Btn, { onClick: () => setGenSeed(Math.floor(Math.random() * 1000000)) }, T("换一组")), h(Btn, { primary: true, busy: busyKey === "gen", onClick: () => void runGenerate() }, T("生成"))));
6732
- const openCardNode = openCard === "assets" ? assetsCard : openCard === "export" ? exportCard : openCard === "settings" ? settingsCard : openCard === "gen" ? genCard : null;
7210
+ const openCardNode = openCard === "assets"
7211
+ ? assetsCard
7212
+ : openCard === "export"
7213
+ ? exportCard
7214
+ : openCard === "layers"
7215
+ ? layersCard
7216
+ : openCard === "settings"
7217
+ ? settingsCard
7218
+ : openCard === "gen"
7219
+ ? genCard
7220
+ : null;
6733
7221
  const canvas = h("canvas", {
6734
7222
  ref: bindCanvas,
6735
7223
  className: "SPR_mapEdCanvas",
@@ -8672,7 +9160,7 @@ window.__ModuleLoader__.load({
8672
9160
  if (suffixDraft !== (job.suffix ?? ""))
8673
9161
  void saveJob({ suffix: suffixDraft });
8674
9162
  }
8675
- }), h("div", { className: "SPR_fields" }, h(GlobalModelField, { label: T("生图模型"), value: globalConfig?.arkModel ?? settingsDraft.model }), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("尺寸")), h("input", { className: "SPR_input", value: settingsDraft.size ?? "", onChange: (event) => setSettingsDraft({ ...settingsDraft, size: event.target.value }), onBlur: () => void saveJob({ settings: settingsDraft }) })), h(NumField, { label: T("生成张数(1~8)"), value: settingsDraft.count ?? 1, min: 1, max: 8, onChange: (v) => { setSettingsDraft({ ...settingsDraft, count: v }); void saveJob({ settings: { ...settingsDraft, count: v } }); } })), h("div", { className: "SPR_toolbar" }, h(BusyBtn, {
9163
+ }), h("div", { className: "SPR_fields" }, h(GlobalModelField, { label: T("生图模型"), value: globalConfig?.imageModel ?? globalConfig?.arkModel ?? settingsDraft.model }), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("尺寸")), h("input", { className: "SPR_input", value: settingsDraft.size ?? "", onChange: (event) => setSettingsDraft({ ...settingsDraft, size: event.target.value }), onBlur: () => void saveJob({ settings: settingsDraft }) })), h(NumField, { label: T("生成张数(1~8)"), value: settingsDraft.count ?? 1, min: 1, max: 8, onChange: (v) => { setSettingsDraft({ ...settingsDraft, count: v }); void saveJob({ settings: { ...settingsDraft, count: v } }); } })), h("div", { className: "SPR_toolbar" }, h(BusyBtn, {
8676
9164
  primary: true,
8677
9165
  busy: tasks.has(K_IMG_JOB),
8678
9166
  busyText: T("正在生成 {n0} 张…", { n0: settingsDraft.count ?? 1 }),
@@ -10973,8 +11461,11 @@ window.__ModuleLoader__.load({
10973
11461
  * ⚠️ 必须**按模块分开**:共用一个标志的话,用户在骨骼动画那边勾了
10974
11462
  * 「不再提示」,进 45° 地图地块时弹窗就再也不出现了 —— 两个模块的
10975
11463
  * 实验性说明内容完全不同,那样等于静默漏掉一次告知。
11464
+ *
11465
+ * 只有 `rig` / `tile` 两格:模块⑥「地图编辑器」已经不是实验性功能,
11466
+ * 它没有弹窗,也就不需要这一格。
10976
11467
  */
10977
- const experimentalGateMuted = { rig: false, tile: false, map: false };
11468
+ const experimentalGateMuted = { rig: false, tile: false };
10978
11469
  /**
10979
11470
  * 实验性说明弹窗(模块④ / ⑤ 共用)。
10980
11471
  *
@@ -11031,16 +11522,7 @@ window.__ModuleLoader__.load({
11031
11522
  onClose
11032
11523
  });
11033
11524
  }
11034
- /** 进入模块⑥时的实验性说明弹窗(地图编辑器)。 */
11035
- function MapExperimentalDialog({ onClose }) {
11036
- return h(ExperimentalDialog, {
11037
- moduleKey: "map",
11038
- title: T("地图编辑器仍在开发中"),
11039
- ariaLabel: T("地图编辑器(实验性)"),
11040
- points: MAP_EXPERIMENTAL_POINTS,
11041
- onClose
11042
- });
11043
- }
11525
+ // 模块⑥「地图编辑器」已经没有实验性弹窗了(它不是实验性功能)。
11044
11526
  /**
11045
11527
  * 模块④的主体界面。
11046
11528
  *
@@ -11259,7 +11741,7 @@ window.__ModuleLoader__.load({
11259
11741
  return h("div", { className: "SPR_rigPanel" },
11260
11742
  // 弹窗是 position:fixed,放在这个滚动容器里也照样盖住整个工作台,
11261
11743
  // 不必为此把 RigModule 再包一层 Fragment。
11262
- gateOpen ? h(RigExperimentalDialog, { onClose: closeGate }) : null, h(ExperimentalBar, null), h("div", { className: "SPR_toolbar" }, h("span", { className: "SPR_refRow" }, T("生图模型")), h("span", { className: "SPR_badge" }, globalConfig?.arkModel ?? job?.settings?.model ?? T("未配置")), h("span", { className: "SPR_refRow" }, T("(模型在「设置 → 游戏素材大师」里改)")), h("span", { className: "SPR_spacer" }), headerButtons), notice !== null
11744
+ gateOpen ? h(RigExperimentalDialog, { onClose: closeGate }) : null, h(ExperimentalBar, null), h("div", { className: "SPR_toolbar" }, h("span", { className: "SPR_refRow" }, T("生图模型")), h("span", { className: "SPR_badge" }, globalConfig?.imageModel ?? globalConfig?.arkModel ?? job?.settings?.model ?? T("未配置")), h("span", { className: "SPR_refRow" }, T("(模型在「设置 → 游戏素材大师」里改)")), h("span", { className: "SPR_spacer" }), headerButtons), notice !== null
11263
11745
  ? h("div", { className: "SPR_notice", "data-kind": notice.kind === "error" ? "error" : "info" }, notice.text, h(Btn, { onClick: () => setNotice(null) }, T("关闭")))
11264
11746
  : null, h("div", { className: "SPR_modules" }, RIG_STAGES.map((entry) => {
11265
11747
  const info = job === null ? { status: "empty" } : rigStageOf(job, entry.key);
@@ -11432,9 +11914,18 @@ window.__ModuleLoader__.load({
11432
11914
  const api = props?.api;
11433
11915
  const [config, setConfig] = React.useState(null);
11434
11916
  const [arkKey, setArkKey] = React.useState("");
11917
+ const [customKey, setCustomKey] = React.useState("");
11435
11918
  const [minimaxKey, setMinimaxKey] = React.useState("");
11436
11919
  const [notice, setNotice] = React.useState(null);
11437
11920
  const [testing, setTesting] = React.useState(null);
11921
+ /**
11922
+ * ComfyUI 工作流草稿。
11923
+ *
11924
+ * ⚠️ 不能像别的文本框那样「每敲一个字就 patch 一次」:一份工作流 JSON 几 KB,
11925
+ * 每个字符都往返一次会明显卡;而且中途的**非法 JSON** 存进去之后,
11926
+ * 下一次生成要在几十秒后才报错。所以用本地草稿,失焦 / 点保存才提交。
11927
+ */
11928
+ const [workflowDraft, setWorkflowDraft] = React.useState(null);
11438
11929
  const load = React.useCallback(async () => {
11439
11930
  if (api === undefined)
11440
11931
  return;
@@ -11505,9 +11996,41 @@ window.__ModuleLoader__.load({
11505
11996
  void patch(values);
11506
11997
  };
11507
11998
  const usingCompshare = compshareModelId !== undefined && config.minimaxModel === compshareModelId;
11508
- return h("section", { className: "SPR_settings" }, h("h2", { style: { margin: 0, fontSize: 15 } }, T("游戏素材大师")), h("p", { className: "SPR_hint" }, T("配置两家模型的 API Key 与整条流水线的默认参数。Key 只保存在本机 DSH 数据目录下的 game-material-master/config.json(真实路径见文末「数据位置」),界面里始终脱敏显示。")), notice !== null
11999
+ /**
12000
+ * 生图后端。`ark` 与 `custom` 互斥,两组配置同时保留、只由这个开关决定用哪一组
12001
+ * —— 来回切不会丢任何一边的 Key 和参数。
12002
+ */
12003
+ const imageProvider = config.imageProvider === "custom" ? "custom" : "ark";
12004
+ const protocols = config.customProtocols ?? [];
12005
+ const protocolInfo = protocols.find((entry) => entry.id === config.customProtocol);
12006
+ const customProtocol = config.customProtocol ?? "openai";
12007
+ const workflowNow = workflowDraft === null ? config.customWorkflow ?? "" : workflowDraft;
12008
+ const workflowDirty = workflowDraft !== null && workflowDraft !== (config.customWorkflow ?? "");
12009
+ /**
12010
+ * 切换协议时顺手换地址:只有当**当前地址还停在另一个协议的默认值**时才换,
12011
+ * 手动改过的地址一律不动(与 MiniMax 切「优云智算版」同一套判断)。
12012
+ * 不这么做的话,用户从 OpenAI 切到 ComfyUI 会得到一个指向 api.openai.com 的
12013
+ * ComfyUI 配置 —— 点测试才报「连不上」,中间没有任何提示。
12014
+ */
12015
+ const onProtocolChange = (nextProtocol) => {
12016
+ const values = { customProtocol: nextProtocol };
12017
+ const knownDefaults = protocols.map((entry) => entry.baseUrl);
12018
+ const target = protocols.find((entry) => entry.id === nextProtocol);
12019
+ if (target !== undefined && (config.customBaseUrl === "" || knownDefaults.includes(config.customBaseUrl))) {
12020
+ values.customBaseUrl = target.baseUrl;
12021
+ }
12022
+ void patch(values);
12023
+ };
12024
+ return h("section", { className: "SPR_settings" }, h("h2", { style: { margin: 0, fontSize: 15 } }, T("游戏素材大师")), h("p", { className: "SPR_hint" }, T("配置生图 / 生视频的模型与整条流水线的默认参数。Key 只保存在本机 DSH 数据目录下的 game-material-master/config.json(真实路径见文末「数据位置」),界面里始终脱敏显示。")), notice !== null
11509
12025
  ? h("div", { className: "SPR_note", "data-kind": notice.kind }, notice.text)
11510
- : null, h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("火山方舟(生图)")), h("p", null, config.ffmpeg?.ok === true ? T("ffmpeg 可用:{n0}", { n0: config.ffmpeg.version }) : T("ffmpeg 不可用:{n0}", { n0: config.ffmpeg?.error ?? T("未知") })), h("div", { className: "SPR_keyRow" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("API Key {n0}", { n0: config.arkApiKeySet ? T("(已配置 {n0})", { n0: config.arkApiKeyHint }) : T("(未配置)") })), h("input", {
12026
+ : null, h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("生图后端")), h("p", null, T("八方向图、图片生成、骨骼动画、45°地图地块的生图都走这里选的后端;图生视频(MiniMax)不受影响。")), h("div", { className: "SPR_fields" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("当前使用")), h("select", {
12027
+ className: "SPR_input",
12028
+ "data-testid": "cfg-image-provider",
12029
+ value: imageProvider,
12030
+ onChange: (event) => void patch({ imageProvider: event.target.value })
12031
+ }, h("option", { value: "ark" }, T("火山方舟 Seedream(云端,开箱即用)")), h("option", { value: "custom" }, T("自定义生图模型(OpenAI / ComfyUI / SD WebUI)"))))), h("p", { className: "SPR_hint" }, T("当前生效:{n0}", { n0: config.imageProviderSummary ?? "" })), config.imageProviderBlocker
12032
+ ? h("div", { className: "SPR_note", "data-kind": "error" }, T("还不能开跑:{n0}", { n0: config.imageProviderBlocker }))
12033
+ : h("div", { className: "SPR_note", "data-kind": "ok" }, T("后端已就绪,可以开跑。"))), h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("火山方舟(生图)"), imageProvider === "ark" ? h("span", { className: "SPR_badge" }, T("当前使用")) : null), h("p", null, config.ffmpeg?.ok === true ? T("ffmpeg 可用:{n0}", { n0: config.ffmpeg.version }) : T("ffmpeg 不可用:{n0}", { n0: config.ffmpeg?.error ?? T("未知") })), h("div", { className: "SPR_keyRow" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("API Key {n0}", { n0: config.arkApiKeySet ? T("(已配置 {n0})", { n0: config.arkApiKeyHint }) : T("(未配置)") })), h("input", {
11511
12034
  className: "SPR_input",
11512
12035
  type: "password",
11513
12036
  placeholder: config.arkApiKeySet ? T("留空表示不修改") : T("粘贴 ARK_API_KEY"),
@@ -11549,7 +12072,136 @@ window.__ModuleLoader__.load({
11549
12072
  await run(() => api.testArk(), (value) => T("连接正常:{n0} 返回 {n1} 字节图片", { n0: value.model, n1: value.bytes }));
11550
12073
  setTesting(null);
11551
12074
  }
11552
- }, T("测试连接(会真实生成 1 张 1K 小图,产生少量费用)")))), h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("MiniMax(图生视频)")), h("p", null, T("视频阶段使用图生视频(I2V)。建议用 MiniMax-Hailuo-02,镜头稳定性最好。")), h("div", { className: "SPR_keyRow" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("API Key {n0}", { n0: config.minimaxApiKeySet ? T("(已配置 {n0})", { n0: config.minimaxApiKeyHint }) : T("(未配置)") })), h("input", {
12075
+ }, T("测试连接(会真实生成 1 张 1K 小图,产生少量费用)")))),
12076
+ /**
12077
+ * 自定义生图后端。
12078
+ *
12079
+ * 三种协议共用一套表单,只有「高级参数」和「工作流」按协议显示——
12080
+ * 每个协议单独一块的话,用户切换协议时会看到完全换了一套界面,
12081
+ * 反而不知道哪些是共通的。
12082
+ */
12083
+ h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("自定义生图模型"), imageProvider === "custom" ? h("span", { className: "SPR_badge" }, T("当前使用")) : null), h("p", null, T("填「主机根地址」即可,具体端点由插件按协议拼;本地服务通常不需要 API Key。")), h("div", { className: "SPR_fields" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("协议")), h("select", {
12084
+ className: "SPR_input",
12085
+ "data-testid": "cfg-custom-protocol",
12086
+ value: customProtocol,
12087
+ onChange: (event) => onProtocolChange(event.target.value)
12088
+ }, protocols.length > 0
12089
+ ? protocols.map((entry) => h("option", { key: entry.id, value: entry.id }, entry.label))
12090
+ : [
12091
+ h("option", { key: "openai", value: "openai" }, "OpenAI API"),
12092
+ h("option", { key: "comfyui", value: "comfyui" }, "ComfyUI API"),
12093
+ h("option", { key: "sdwebui", value: "sdwebui" }, "Stable Diffusion WebUI API")
12094
+ ])), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, "Base URL"), h("input", {
12095
+ className: "SPR_input",
12096
+ "data-testid": "cfg-custom-base-url",
12097
+ value: config.customBaseUrl ?? "",
12098
+ placeholder: protocolInfo?.baseUrl ?? "",
12099
+ onChange: (event) => void patch({ customBaseUrl: event.target.value })
12100
+ })), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, customProtocol === "sdwebui" ? T("模型名(SD WebUI 忽略,模型由服务端决定)") : T("模型名")), h("input", {
12101
+ className: "SPR_input",
12102
+ "data-testid": "cfg-custom-model",
12103
+ value: config.customModel ?? "",
12104
+ disabled: customProtocol === "sdwebui",
12105
+ placeholder: customProtocol === "comfyui" ? T("可不填,由工作流决定") : "gpt-image-1",
12106
+ onChange: (event) => void patch({ customModel: event.target.value })
12107
+ })), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("输出尺寸(宽x高)")), h("input", {
12108
+ className: "SPR_input",
12109
+ "data-testid": "cfg-custom-size",
12110
+ value: config.customSize ?? "",
12111
+ placeholder: "1024x1024",
12112
+ onChange: (event) => void patch({ customSize: event.target.value })
12113
+ }))), h("p", { className: "SPR_hint" }, T("请求端点:{n0}", { n0: protocolInfo?.hint ?? "" })), h("div", { className: "SPR_keyRow" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("API Key {n0}", { n0: config.customApiKeySet ? T("(已配置 {n0})", { n0: config.customApiKeyHint }) : T("(未配置,本地服务可以留空)") })), h("input", {
12114
+ className: "SPR_input",
12115
+ type: "password",
12116
+ placeholder: config.customApiKeySet ? T("留空表示不修改") : T("粘贴 API Key(A1111 的 user:pass 也认)"),
12117
+ value: customKey,
12118
+ onChange: (event) => setCustomKey(event.target.value)
12119
+ })), h(Btn, { onClick: () => run(async () => { await api.saveConfig({ customApiKey: customKey }); setCustomKey(""); }, T("自定义后端 Key 已保存")) }, T("保存 Key")), h(Btn, { disabled: !config.customApiKeySet, onClick: () => run(() => api.saveConfig({ clearCustomApiKey: true }), T("已清除自定义后端 Key")) }, T("清除"))),
12120
+ /**
12121
+ * 高级参数:OpenAI 协议不认这些(它只有 prompt / size / n),
12122
+ * 所以那一档不显示,免得用户以为调了有用。
12123
+ */
12124
+ customProtocol === "sdwebui" || customProtocol === "comfyui"
12125
+ ? h("div", { className: "SPR_fields" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("负面提示词")), h("input", {
12126
+ className: "SPR_input",
12127
+ value: config.customNegativePrompt ?? "",
12128
+ placeholder: customProtocol === "comfyui" ? T("走 {{negative_prompt}} 占位符") : "",
12129
+ onChange: (event) => void patch({ customNegativePrompt: event.target.value })
12130
+ })), h(NumField, {
12131
+ label: T("采样步数"),
12132
+ value: config.customSteps ?? 28,
12133
+ min: 1,
12134
+ max: 150,
12135
+ onChange: (value) => void patch({ customSteps: value })
12136
+ }), h(NumField, {
12137
+ label: T("CFG / 引导强度"),
12138
+ value: config.customCfgScale ?? 7,
12139
+ min: 0,
12140
+ max: 30,
12141
+ onChange: (value) => void patch({ customCfgScale: value })
12142
+ }), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("采样器")), h("input", {
12143
+ className: "SPR_input",
12144
+ value: config.customSampler ?? "",
12145
+ placeholder: "DPM++ 2M Karras",
12146
+ onChange: (event) => void patch({ customSampler: event.target.value })
12147
+ })), customProtocol === "sdwebui"
12148
+ ? h(NumField, {
12149
+ label: T("图生图重绘强度(0~1)"),
12150
+ value: config.customDenoising ?? 0.65,
12151
+ min: 0,
12152
+ max: 1,
12153
+ step: 0.05,
12154
+ onChange: (value) => void patch({ customDenoising: value })
12155
+ })
12156
+ : null, h(NumField, {
12157
+ label: T("随机种子(-1 = 每次随机)"),
12158
+ value: config.customSeed ?? -1,
12159
+ min: -1,
12160
+ max: 2147483647,
12161
+ onChange: (value) => void patch({ customSeed: value })
12162
+ }))
12163
+ : null,
12164
+ // 超时对所有协议都有效(云端 OpenAI 也可能很慢),所以放在条件块外面。
12165
+ h(NumField, {
12166
+ label: T("请求超时(毫秒,本地模型建议给足)"),
12167
+ value: config.customTimeoutMs ?? 300000,
12168
+ min: 10000,
12169
+ max: 3600000,
12170
+ onChange: (value) => void patch({ customTimeoutMs: value })
12171
+ }),
12172
+ /**
12173
+ * ComfyUI 的工作流。必须整段粘贴 API 格式的 JSON —— 从界面导出的
12174
+ * 「工作流」格式(带 nodes / links 的那份)不是 API 格式,提交会直接 400。
12175
+ */
12176
+ customProtocol === "comfyui"
12177
+ ? h("div", null, h("p", { className: "SPR_hint" }, T("工作流(在 ComfyUI 里点「导出(API)」,把那份 JSON 整段粘贴)。可用占位符:{{prompt}} {{negative_prompt}} {{width}} {{height}} {{seed}} {{steps}} {{cfg}} {{sampler}} {{denoising}} {{model}} {{image}};一个都不写就原样跑你保存的工作流。")), h("textarea", {
12178
+ className: "SPR_area",
12179
+ "data-testid": "cfg-custom-workflow",
12180
+ placeholder: '{"3":{"class_type":"KSampler","inputs":{"seed":"{{seed}}","steps":"{{steps}}","cfg":"{{cfg}}","sampler_name":"{{sampler}}","denoise":"{{denoising}}","model":["4",0],"positive":["6",0],"negative":["7",0],"latent_image":["5",0]}},"6":{"class_type":"CLIPTextEncode","inputs":{"text":"{{prompt}}","clip":["4",1]}}}',
12181
+ value: workflowNow,
12182
+ onChange: (event) => setWorkflowDraft(event.target.value)
12183
+ }), h("div", { className: "SPR_toolbar" }, h(Btn, {
12184
+ disabled: !workflowDirty,
12185
+ onClick: () => run(async () => {
12186
+ await api.saveConfig({ customWorkflow: workflowNow });
12187
+ setWorkflowDraft(null);
12188
+ }, T("工作流已保存"))
12189
+ }, workflowDirty ? T("保存工作流") : T("工作流已保存")), h(Btn, {
12190
+ onClick: () => {
12191
+ setWorkflowDraft("");
12192
+ void patch({ customWorkflow: "" });
12193
+ }
12194
+ }, T("清空"))))
12195
+ : null, h("div", { className: "SPR_toolbar" }, h(BusyBtn, {
12196
+ busy: testing === "custom",
12197
+ busyText: T("正在生成测试图…"),
12198
+ disabled: testing !== null || config.customImageBlocker != null,
12199
+ onClick: async () => {
12200
+ setTesting("custom");
12201
+ await run(() => api.testCustomImage(), (value) => T("连接正常:{n0} 返回 {n1} 字节图片", { n0: value.provider, n1: value.bytes }));
12202
+ setTesting(null);
12203
+ }
12204
+ }, T("测试连接(会真实生成 1 张测试图,产生少量费用)")))), h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("MiniMax(图生视频)")), h("p", null, T("视频阶段使用图生视频(I2V)。建议用 MiniMax-Hailuo-02,镜头稳定性最好。")), h("div", { className: "SPR_keyRow" }, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("API Key {n0}", { n0: config.minimaxApiKeySet ? T("(已配置 {n0})", { n0: config.minimaxApiKeyHint }) : T("(未配置)") })), h("input", {
11553
12205
  className: "SPR_input",
11554
12206
  type: "password",
11555
12207
  placeholder: config.minimaxApiKeySet ? T("留空表示不修改") : T("粘贴 MiniMax API Key"),
@@ -11731,6 +12383,7 @@ window.__ModuleLoader__.load({
11731
12383
  getConfig: () => call("getConfig"),
11732
12384
  saveConfig: (payload) => call("saveConfig", payload),
11733
12385
  testArk: () => call("testArk"),
12386
+ testCustomImage: () => call("testCustomImage"),
11734
12387
  testMinimax: () => call("testMinimax"),
11735
12388
  listProjects: () => call("listProjects"),
11736
12389
  createProject: (payload) => call("createProject", payload),
@@ -11745,6 +12398,8 @@ window.__ModuleLoader__.load({
11745
12398
  saveSettings: (payload) => call("saveSettings", payload),
11746
12399
  setApproved: (payload) => call("setApproved", payload),
11747
12400
  revealProject: (payload) => call("revealProject", payload),
12401
+ uploadVideo: (payload) => call("uploadVideo", payload),
12402
+ exportImages: (payload) => call("exportImages", payload),
11748
12403
  runImage: (payload) => call("runImage", payload),
11749
12404
  runImages: (payload) => call("runImages", payload),
11750
12405
  setImageMode: (payload) => call("setImageMode", payload),
@@ -11921,7 +12576,7 @@ window.__ModuleLoader__.load({
11921
12576
  * `mapgeom` / `mapdoc` 的真实现做黄金对照逐点比对 —— 界面复刻的那部分几何
11922
12577
  * 必须有守门的,否则「预览与导出错位」会以静默的方式回来。
11923
12578
  */
11924
- bundleModule.exports.__test = { StudioPanel, TileModule, ImageModule, SequenceModule, RigSemanticsPanel, MapModule, MapExperimentalDialog, MAP_pointToCell, MAP_cellAnchor, MAP_cellTopLeft, MAP_lineCells, usePendingTasks, LoadingOverlay, MediaBox, BusyBtn, BusyBadge, NumField, ZoomableImage, CSS, subscribeIntent, parseIntents, openStudioIntent, OPEN_QUERY_KEY, StudioGlyph, StudioGlyphIcon, publishHiddenModules, useHiddenModules, visibleModulesOf, normalizeHiddenKeys, ConfigSection };
12579
+ bundleModule.exports.__test = { StudioPanel, TileModule, ImageModule, SequenceModule, RigSemanticsPanel, MapModule, MAP_pointToCell, MAP_cellAnchor, MAP_cellTopLeft, MAP_lineCells, usePendingTasks, LoadingOverlay, MediaBox, BusyBtn, BusyBadge, NumField, ZoomableImage, CSS, subscribeIntent, parseIntents, openStudioIntent, OPEN_QUERY_KEY, StudioGlyph, StudioGlyphIcon, publishHiddenModules, useHiddenModules, visibleModulesOf, normalizeHiddenKeys, ConfigSection };
11925
12580
  return bundleModule.exports;
11926
12581
  }
11927
12582
  });