dsh-game-material-master 0.4.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/README.en.md +101 -12
- package/README.md +86 -11
- package/lib/ark.js +1 -1
- package/lib/{tilemedia.js → bitmap.js} +21 -3
- package/lib/client.js +3295 -158
- package/lib/config.js +70 -2
- package/lib/customimage.js +518 -0
- package/lib/imagegen.js +15 -15
- package/lib/imageprovider.js +151 -0
- package/lib/index.js +305 -9
- package/lib/jsonio.js +24 -3
- package/lib/links.js +11 -2
- package/lib/mapauto.js +126 -0
- package/lib/mapdoc.js +617 -0
- package/lib/mapexport.js +188 -0
- package/lib/mapgen.js +1591 -0
- package/lib/mapgeom.js +320 -0
- package/lib/maprender.js +484 -0
- package/lib/mapsample.js +36 -0
- package/lib/mapsamplegen.js +760 -0
- package/lib/maptiles.js +253 -0
- package/lib/media.js +34 -0
- package/lib/pipeline.js +197 -15
- package/lib/rigexport.js +29 -98
- package/lib/riggen.js +34 -30
- package/lib/rigpath.js +47 -10
- package/lib/rigpreview.js +91 -84
- package/lib/rigsemantics.js +4 -4
- package/lib/rigvalidate.js +72 -14
- package/lib/spine.js +147 -80
- package/lib/store.js +12 -3
- package/lib/tilegen.js +7 -11
- package/lib/tilegeom.js +1 -1
- package/lib/tools.js +253 -29
- package/lib/wire.js +198 -3
- package/lib/zip.js +127 -0
- package/package.json +10 -4
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 生图后端的分发层。
|
|
3
|
+
*
|
|
4
|
+
* 插件支持两类生图后端(`config.imageProvider`):
|
|
5
|
+
*
|
|
6
|
+
* · `ark`(默认)—— 火山方舟 Seedream,走 `ark.generateImage`;
|
|
7
|
+
* · `custom` —— 用户自己的服务,协议见 `customimage.ts`(OpenAI / ComfyUI / SD WebUI)。
|
|
8
|
+
*
|
|
9
|
+
* 所有生图调用点(八方向图 / 图片生成 / 骨骼动画 / 地图地块)都只经过这里。
|
|
10
|
+
* 这样「换生图后端」只改一处,各模块不必各判一次 provider —— 历史教训是
|
|
11
|
+
* 这种「每处判一次」的分叉迟早会漏一处,而漏掉的那一处**不报错**,
|
|
12
|
+
* 只是偷偷还在用另一家模型。
|
|
13
|
+
*/
|
|
14
|
+
import { generateImage } from "./ark.js";
|
|
15
|
+
import { CUSTOM_PROTOCOL_DEFAULTS, loadConfig } from "./config.js";
|
|
16
|
+
import { CustomImageError, generateCustomImage } from "./customimage.js";
|
|
17
|
+
export function isCustomProvider(config) {
|
|
18
|
+
return config.imageProvider === "custom";
|
|
19
|
+
}
|
|
20
|
+
/** 当前生图模型(Ark 是 `arkModel`,自定义是 `customModel`)。 */
|
|
21
|
+
export function imageModelOf(config) {
|
|
22
|
+
return isCustomProvider(config) ? config.customModel : config.arkModel;
|
|
23
|
+
}
|
|
24
|
+
/** 当前输出尺寸。 */
|
|
25
|
+
export function imageSizeOf(config) {
|
|
26
|
+
return isCustomProvider(config) ? config.customSize : config.arkSize;
|
|
27
|
+
}
|
|
28
|
+
/** 当前水印开关。水印是火山方舟特有的参数,自定义后端一律不带。 */
|
|
29
|
+
export function imageWatermarkOf(config) {
|
|
30
|
+
return isCustomProvider(config) ? false : config.arkWatermark;
|
|
31
|
+
}
|
|
32
|
+
/** 当前请求超时。 */
|
|
33
|
+
export function imageTimeoutOf(config) {
|
|
34
|
+
return isCustomProvider(config) ? config.customTimeoutMs : config.arkTimeoutMs;
|
|
35
|
+
}
|
|
36
|
+
/** 自定义后端自己的必填项检查(不看 `imageProvider`,供「测试连接」按钮用)。 */
|
|
37
|
+
export function customImageBlocker(config) {
|
|
38
|
+
if (config.customBaseUrl.trim() === "") {
|
|
39
|
+
return "尚未配置自定义生图服务的地址(设置 → 游戏素材大师 → 生图后端 → 自定义生图模型)";
|
|
40
|
+
}
|
|
41
|
+
if (config.customProtocol === "comfyui" && config.customWorkflow.trim() === "") {
|
|
42
|
+
return "选了 ComfyUI 协议,但还没填工作流 JSON(在 ComfyUI 里「导出(API)」拿到那份 JSON,整段粘贴)";
|
|
43
|
+
}
|
|
44
|
+
if (config.customProtocol === "openai" && config.customModel.trim() === "") {
|
|
45
|
+
return "选了 OpenAI 协议,但还没填模型名";
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 当前后端「能不能开跑」。返回 undefined = 可以。
|
|
51
|
+
*
|
|
52
|
+
* 错误文案里必须写清**去哪里配**:两种后端的用户不是同一批人,
|
|
53
|
+
* 只说「未配置」会让人在设置页里来回找。
|
|
54
|
+
*/
|
|
55
|
+
export function imageProviderBlocker(config) {
|
|
56
|
+
if (!isCustomProvider(config)) {
|
|
57
|
+
if (config.arkApiKey.trim() === "") {
|
|
58
|
+
return "尚未配置火山方舟 API Key(设置 → 游戏素材大师 → 生图后端 → 火山方舟)";
|
|
59
|
+
}
|
|
60
|
+
if (config.arkModel.trim() === "")
|
|
61
|
+
return "尚未配置火山方舟的生图模型 ID";
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return customImageBlocker(config);
|
|
65
|
+
}
|
|
66
|
+
export function assertImageProviderReady(config) {
|
|
67
|
+
const blocker = imageProviderBlocker(config);
|
|
68
|
+
if (blocker !== undefined)
|
|
69
|
+
throw new Error(blocker);
|
|
70
|
+
}
|
|
71
|
+
/** 一句话摘要(界面角标与工具面共用)。 */
|
|
72
|
+
export function imageProviderSummary(config) {
|
|
73
|
+
if (!isCustomProvider(config))
|
|
74
|
+
return `火山方舟 · ${config.arkModel}`;
|
|
75
|
+
const label = CUSTOM_PROTOCOL_DEFAULTS[config.customProtocol]?.label ?? config.customProtocol;
|
|
76
|
+
const model = config.customModel.trim() === "" ? "" : ` · ${config.customModel}`;
|
|
77
|
+
return `自定义 · ${label} · ${config.customBaseUrl}${model}`;
|
|
78
|
+
}
|
|
79
|
+
/** 调一次生图,自动按当前后端分发。 */
|
|
80
|
+
export async function generateImageWithProvider(request, signal) {
|
|
81
|
+
const config = await loadConfig();
|
|
82
|
+
assertImageProviderReady(config);
|
|
83
|
+
if (isCustomProvider(config)) {
|
|
84
|
+
return generateCustomImage({
|
|
85
|
+
protocol: config.customProtocol,
|
|
86
|
+
baseUrl: config.customBaseUrl,
|
|
87
|
+
apiKey: config.customApiKey,
|
|
88
|
+
model: request.model?.trim() || config.customModel,
|
|
89
|
+
prompt: request.prompt,
|
|
90
|
+
images: request.images,
|
|
91
|
+
size: request.size,
|
|
92
|
+
timeoutMs: request.timeoutMs ?? config.customTimeoutMs,
|
|
93
|
+
negativePrompt: config.customNegativePrompt,
|
|
94
|
+
steps: config.customSteps,
|
|
95
|
+
cfgScale: config.customCfgScale,
|
|
96
|
+
sampler: config.customSampler,
|
|
97
|
+
denoising: config.customDenoising,
|
|
98
|
+
seed: config.customSeed,
|
|
99
|
+
workflow: config.customWorkflow
|
|
100
|
+
}, signal);
|
|
101
|
+
}
|
|
102
|
+
return generateImage({
|
|
103
|
+
baseUrl: config.arkBaseUrl,
|
|
104
|
+
apiKey: config.arkApiKey,
|
|
105
|
+
model: request.model?.trim() || config.arkModel,
|
|
106
|
+
prompt: request.prompt,
|
|
107
|
+
images: request.images,
|
|
108
|
+
size: request.size,
|
|
109
|
+
watermark: request.watermark,
|
|
110
|
+
timeoutMs: request.timeoutMs ?? config.arkTimeoutMs
|
|
111
|
+
}, signal);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 连通性自检:对**自定义后端**真实生成一张小图。
|
|
115
|
+
*
|
|
116
|
+
* 与 `testArk` 对称:各自测各自那一组配置,所以「当前用哪家」不影响按钮能不能点
|
|
117
|
+
* —— 用户经常是先把两边的地址都填好、各测一次,再决定切哪个。
|
|
118
|
+
* 只有真跑一次才能同时验证「地址对不对」和「服务端真的能出图」,看配置看不出来。
|
|
119
|
+
*/
|
|
120
|
+
export async function testCustomImage() {
|
|
121
|
+
const config = await loadConfig();
|
|
122
|
+
const blocker = customImageBlocker(config);
|
|
123
|
+
if (blocker !== undefined)
|
|
124
|
+
throw new Error(blocker);
|
|
125
|
+
const result = await generateCustomImage({
|
|
126
|
+
protocol: config.customProtocol,
|
|
127
|
+
baseUrl: config.customBaseUrl,
|
|
128
|
+
apiKey: config.customApiKey,
|
|
129
|
+
model: config.customModel,
|
|
130
|
+
prompt: "一张纯绿色背景的空白测试图,画面中只有一个居中的小圆点",
|
|
131
|
+
images: [],
|
|
132
|
+
size: config.customSize,
|
|
133
|
+
timeoutMs: config.customTimeoutMs,
|
|
134
|
+
negativePrompt: config.customNegativePrompt,
|
|
135
|
+
steps: config.customSteps,
|
|
136
|
+
cfgScale: config.customCfgScale,
|
|
137
|
+
sampler: config.customSampler,
|
|
138
|
+
denoising: config.customDenoising,
|
|
139
|
+
// 测试图固定种子,便于对比两次测试的结果是否一致(排查缓存 / 没真跑的问题)。
|
|
140
|
+
seed: 20261016,
|
|
141
|
+
workflow: config.customWorkflow
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
ok: true,
|
|
145
|
+
provider: `自定义 · ${CUSTOM_PROTOCOL_DEFAULTS[config.customProtocol]?.label ?? config.customProtocol}`,
|
|
146
|
+
model: config.customModel,
|
|
147
|
+
bytes: result.bytes.length,
|
|
148
|
+
ext: result.ext
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export { CustomImageError };
|
package/lib/index.js
CHANGED
|
@@ -15,17 +15,19 @@ import { fileURLToPath } from "node:url";
|
|
|
15
15
|
import { spawn } from "node:child_process";
|
|
16
16
|
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
17
17
|
import { appendJobLog } from "./jsonio.js";
|
|
18
|
-
import { ARK_MODEL_PRESETS, DEFAULT_CONFIG, ROW_ORDER_VERSION, MINIMAX_HOST_PRESETS, MINIMAX_MODEL_PRESETS, loadConfig, maskConfig, migrateLegacyDataRoot, projectsRoot, saveConfig } from "./config.js";
|
|
18
|
+
import { ARK_MODEL_PRESETS, CUSTOM_PROTOCOLS, CUSTOM_PROTOCOL_DEFAULTS, DEFAULT_CONFIG, ROW_ORDER_VERSION, MINIMAX_HOST_PRESETS, MINIMAX_MODEL_PRESETS, loadConfig, maskConfig, migrateLegacyDataRoot, projectsRoot, saveConfig } from "./config.js";
|
|
19
19
|
import { DEFAULT_ROW_ORDER, DIRECTION_KEYS, TURN_DIRECTION_DEFAULT, TURN_FRAME_COUNT_MAX, TURN_FRAME_COUNT_MIN, defaultPrompts, directionOf, localizePrompts, normalizePromptLang } from "./directions.js";
|
|
20
20
|
import { checkFfmpeg } from "./media.js";
|
|
21
21
|
import { testArk } from "./ark.js";
|
|
22
|
+
import { customImageBlocker, imageModelOf, imageProviderBlocker, imageProviderSummary, isCustomProvider, testCustomImage } from "./imageprovider.js";
|
|
22
23
|
import { COMP_SHARE_BASE_URL, COMP_SHARE_MODEL_ID, capabilityOf, isCompshareModel, normalizeDuration, normalizeResolution, pathPrefixOf, testMiniMax } from "./minimax.js";
|
|
23
|
-
import { applyTurnPicks, clearVideos, disposePipeline, ensurePoller, listJobs, pollVideosOnce, resetFramePicks, resetTurnPicks, setFramePick, setFramePicks, setImageMode, setTurnPick, setTurnPicks, startAllImages, startCompose, startFramePick, startExtract, startImage, startRekey, startTurnFrames, startTurnVideo, startVideos } from "./pipeline.js";
|
|
24
|
+
import { applyTurnPicks, clearVideos, disposePipeline, ensurePoller, exportImages, importLocalVideo, listJobs, pollVideosOnce, resetFramePicks, resetTurnPicks, setFramePick, setFramePicks, setImageMode, setTurnPick, setTurnPicks, startAllImages, startCompose, startFramePick, startExtract, startImage, startRekey, startTurnFrames, startTurnVideo, startVideos } from "./pipeline.js";
|
|
24
25
|
import { assetPath, createProject, deleteProject, listProjects, log, patchProject, projectDir, projectExists, readProject, } from "./store.js";
|
|
25
26
|
import * as imagegen from "./imagegen.js";
|
|
26
27
|
import * as seqgen from "./seqgen.js";
|
|
27
28
|
import * as riggen from "./riggen.js";
|
|
28
29
|
import * as tilegen from "./tilegen.js";
|
|
30
|
+
import * as mapgen from "./mapgen.js";
|
|
29
31
|
import { MANIFEST, METHODS, SERVICE_NAME } from "./wire.js";
|
|
30
32
|
import { rememberClientOrigin } from "./links.js";
|
|
31
33
|
import { registerStudioTools } from "./tools.js";
|
|
@@ -170,6 +172,9 @@ const MIME_TYPES = {
|
|
|
170
172
|
".mp4": "video/mp4",
|
|
171
173
|
".webm": "video/webm",
|
|
172
174
|
".json": "application/json; charset=utf-8",
|
|
175
|
+
// 模块六的导出包:`.zip` 少了这一条会掉进 octet-stream —— 浏览器照样存得下来,
|
|
176
|
+
// 但少了这个类型,某些浏览器/壳会把「另存为」的默认扩展名写错。
|
|
177
|
+
".zip": "application/zip",
|
|
173
178
|
// 骨骼动画的自包含预览是一整个 HTML 文件,必须用 text/html 才能被 iframe 渲染。
|
|
174
179
|
".html": "text/html; charset=utf-8",
|
|
175
180
|
".atlas": "text/plain; charset=utf-8"
|
|
@@ -240,6 +245,24 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
240
245
|
rowOrder: [...config.rowOrder],
|
|
241
246
|
defaults: { ...DEFAULT_CONFIG },
|
|
242
247
|
arkModels: ARK_MODEL_PRESETS,
|
|
248
|
+
/**
|
|
249
|
+
* 生图后端的呈现材料。
|
|
250
|
+
*
|
|
251
|
+
* `imageProviderBlocker` 由宿主算好回传,界面与**对话工具面**共用同一份判断
|
|
252
|
+
* (tools.ts 的 intake 也读它):两边各写一套「配好了没」的规则,
|
|
253
|
+
* 迟早会出现「界面说没配好、模型说配好了」这种互相矛盾的提示。
|
|
254
|
+
*/
|
|
255
|
+
customProtocols: CUSTOM_PROTOCOLS.map((key) => ({
|
|
256
|
+
id: key,
|
|
257
|
+
label: CUSTOM_PROTOCOL_DEFAULTS[key].label,
|
|
258
|
+
baseUrl: CUSTOM_PROTOCOL_DEFAULTS[key].baseUrl,
|
|
259
|
+
hint: CUSTOM_PROTOCOL_DEFAULTS[key].hint
|
|
260
|
+
})),
|
|
261
|
+
imageProviderSummary: imageProviderSummary(config),
|
|
262
|
+
/** 当前生效的生图模型(模块里那个只读展示位用它,比 summary 短)。 */
|
|
263
|
+
imageModel: imageModelOf(config),
|
|
264
|
+
imageProviderBlocker: imageProviderBlocker(config) ?? null,
|
|
265
|
+
customImageBlocker: customImageBlocker(config) ?? null,
|
|
243
266
|
minimaxModels: MINIMAX_MODEL_PRESETS,
|
|
244
267
|
minimaxHosts: MINIMAX_HOST_PRESETS,
|
|
245
268
|
// 「优云智算版 H3」由用户在模型下拉里显式选择,选中后网关地址/路径/档位全部跟着它走。
|
|
@@ -265,13 +288,26 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
265
288
|
}
|
|
266
289
|
/**
|
|
267
290
|
* 保存配置。
|
|
268
|
-
* 约定:`arkApiKey` / `minimaxApiKey`
|
|
269
|
-
*
|
|
291
|
+
* 约定:`arkApiKey` / `minimaxApiKey` / `customApiKey` **只有用户确实改了才带**——
|
|
292
|
+
* 不带就是保持原值,带空串才是清除。这样界面就不必把明文 key 回填到输入框里。
|
|
270
293
|
*/
|
|
271
294
|
async saveConfig(payload) {
|
|
272
295
|
const input = asRecord(payload);
|
|
273
296
|
const patch = {};
|
|
274
297
|
const directKeys = [
|
|
298
|
+
"imageProvider",
|
|
299
|
+
"customProtocol",
|
|
300
|
+
"customBaseUrl",
|
|
301
|
+
"customModel",
|
|
302
|
+
"customSize",
|
|
303
|
+
"customNegativePrompt",
|
|
304
|
+
"customSteps",
|
|
305
|
+
"customCfgScale",
|
|
306
|
+
"customSampler",
|
|
307
|
+
"customDenoising",
|
|
308
|
+
"customSeed",
|
|
309
|
+
"customWorkflow",
|
|
310
|
+
"customTimeoutMs",
|
|
275
311
|
"arkBaseUrl",
|
|
276
312
|
"arkModel",
|
|
277
313
|
"arkSize",
|
|
@@ -312,10 +348,14 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
312
348
|
patch.arkApiKey = input.arkApiKey.trim();
|
|
313
349
|
if (typeof input.minimaxApiKey === "string")
|
|
314
350
|
patch.minimaxApiKey = input.minimaxApiKey.trim();
|
|
351
|
+
if (typeof input.customApiKey === "string")
|
|
352
|
+
patch.customApiKey = input.customApiKey.trim();
|
|
315
353
|
if (input.clearArkApiKey === true)
|
|
316
354
|
patch.arkApiKey = "";
|
|
317
355
|
if (input.clearMinimaxApiKey === true)
|
|
318
356
|
patch.minimaxApiKey = "";
|
|
357
|
+
if (input.clearCustomApiKey === true)
|
|
358
|
+
patch.customApiKey = "";
|
|
319
359
|
const saved = await saveConfig(patch);
|
|
320
360
|
this.ffmpegCache = undefined;
|
|
321
361
|
return this.decorateConfig(saved);
|
|
@@ -331,6 +371,10 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
331
371
|
timeoutMs: config.arkTimeoutMs
|
|
332
372
|
});
|
|
333
373
|
}
|
|
374
|
+
/** 测自定义生图后端。与 testArk 对称,各自测各自那一组配置。 */
|
|
375
|
+
async testCustomImage() {
|
|
376
|
+
return testCustomImage();
|
|
377
|
+
}
|
|
334
378
|
async testMinimax() {
|
|
335
379
|
const config = await loadConfig();
|
|
336
380
|
return testMiniMax({
|
|
@@ -423,6 +467,27 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
423
467
|
});
|
|
424
468
|
return { ok: true, file: relative, name: originalName };
|
|
425
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* 选用一段**本地视频**(用户自己选的,不走远程生成)。
|
|
472
|
+
*
|
|
473
|
+
* `key` 是槽位:`turn`(转圈视频)或八个方向之一的 key。远端生成与本地导入
|
|
474
|
+
* 产出的节点完全同形,所以阶段 3、4 不必区分;转圈模式在导入后会自动抽候选帧。
|
|
475
|
+
*/
|
|
476
|
+
async uploadVideo(payload) {
|
|
477
|
+
const input = asRecord(payload);
|
|
478
|
+
return importLocalVideo(asString(input.projectId), asString(input.key), asString(input.name, "local-video"), asString(input.data));
|
|
479
|
+
}
|
|
480
|
+
/** 把项目里所有中间图片打成一个 zip(落在 `out/` 下,返回相对路径给界面下载)。 */
|
|
481
|
+
async exportImages(payload) {
|
|
482
|
+
const projectId = asString(asRecord(payload).projectId);
|
|
483
|
+
const pack = await exportImages(projectId);
|
|
484
|
+
const project = await readProject(projectId);
|
|
485
|
+
return {
|
|
486
|
+
...pack,
|
|
487
|
+
assetBase: `${ROUTE_PREFIX}/assets/${projectId}/`,
|
|
488
|
+
name: project?.name ?? projectId
|
|
489
|
+
};
|
|
490
|
+
}
|
|
426
491
|
async savePrompts(payload) {
|
|
427
492
|
const input = asRecord(payload);
|
|
428
493
|
const projectId = asString(input.projectId);
|
|
@@ -644,6 +709,16 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
644
709
|
});
|
|
645
710
|
return { ok: true, id, module, reviewMode };
|
|
646
711
|
}
|
|
712
|
+
// 地图编辑器(模块六)。**别重犯 rig / tile 那两个漏**:wire 的 module 枚举
|
|
713
|
+
// 与这里必须成对加,否则「固定流程第 0 步必须问清审核模式」对 map 落不了地。
|
|
714
|
+
if (module === "map") {
|
|
715
|
+
// 同样走带写队列的 `patchMapProject`:地图文档的防抖落盘也在同一条队列上。
|
|
716
|
+
await mapgen.patchMapProject(id, (project) => {
|
|
717
|
+
project.reviewMode = reviewMode;
|
|
718
|
+
appendJobLog(project.logs, "info", `审核模式:${reviewMode === "manual" ? "每一步人工审核" : "agent 自动审核"}`);
|
|
719
|
+
});
|
|
720
|
+
return { ok: true, id, module, reviewMode };
|
|
721
|
+
}
|
|
647
722
|
throw new Error(`未知模块:${module}`);
|
|
648
723
|
}
|
|
649
724
|
// ── 地图地块生成(模块五)──────────────────────────────────────────────
|
|
@@ -918,6 +993,183 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
918
993
|
}
|
|
919
994
|
return { ok: true, dir };
|
|
920
995
|
}
|
|
996
|
+
// ── 地图编辑器(模块六,单项目 = 单张地图)──────────────────────────────
|
|
997
|
+
async listMapProjects() {
|
|
998
|
+
return { projects: await mapgen.listMapProjects() };
|
|
999
|
+
}
|
|
1000
|
+
async createMapProject(payload) {
|
|
1001
|
+
const input = asRecord(payload);
|
|
1002
|
+
const project = await mapgen.createMapProject(asString(input.name, "未命名地图"), {
|
|
1003
|
+
grid: input.grid,
|
|
1004
|
+
cols: typeof input.cols === "number" ? input.cols : undefined,
|
|
1005
|
+
rows: typeof input.rows === "number" ? input.rows : undefined
|
|
1006
|
+
});
|
|
1007
|
+
return mapgen.mapView(project);
|
|
1008
|
+
}
|
|
1009
|
+
async getMapProject(payload) {
|
|
1010
|
+
const input = asRecord(payload);
|
|
1011
|
+
const id = asString(input.projectId);
|
|
1012
|
+
const project = await mapgen.readMapProject(id);
|
|
1013
|
+
if (project === undefined)
|
|
1014
|
+
throw new Error(`项目不存在:${id}`);
|
|
1015
|
+
// `input.mapId` 只是旧深链接的兼容位:单项目 = 单张地图,它没有意义,忽略。
|
|
1016
|
+
return mapgen.mapView(project);
|
|
1017
|
+
}
|
|
1018
|
+
async saveMapProject(payload) {
|
|
1019
|
+
const input = asRecord(payload);
|
|
1020
|
+
const id = asString(input.projectId);
|
|
1021
|
+
const name = typeof input.name === "string" ? input.name.trim() : "";
|
|
1022
|
+
const next = await mapgen.patchMapProject(id, (project) => {
|
|
1023
|
+
if (name !== "")
|
|
1024
|
+
project.name = name;
|
|
1025
|
+
return project;
|
|
1026
|
+
});
|
|
1027
|
+
return mapgen.mapView(next);
|
|
1028
|
+
}
|
|
1029
|
+
async deleteMapProject(payload) {
|
|
1030
|
+
const id = asString(asRecord(payload).projectId);
|
|
1031
|
+
await mapgen.deleteMapProject(id);
|
|
1032
|
+
return { ok: true };
|
|
1033
|
+
}
|
|
1034
|
+
async importMapTileset(payload) {
|
|
1035
|
+
const input = asRecord(payload);
|
|
1036
|
+
const result = await mapgen.importMapTileset(asString(input.projectId), asString(input.name), asString(input.data), {
|
|
1037
|
+
cell: input.cell,
|
|
1038
|
+
shape: input.shape,
|
|
1039
|
+
animRows: input.animRows
|
|
1040
|
+
});
|
|
1041
|
+
return { tilesets: result.tilesets.map(mapTilesetBrief), warnings: result.warnings };
|
|
1042
|
+
}
|
|
1043
|
+
/** 内置素材:本机现算,零成本(4 张自动连接图 + 1 张道具图)。 */
|
|
1044
|
+
async importSampleTileset(payload) {
|
|
1045
|
+
const result = await mapgen.importSampleTileset(asString(asRecord(payload).projectId));
|
|
1046
|
+
return { tilesets: result.tilesets.map(mapTilesetBrief), warnings: result.warnings };
|
|
1047
|
+
}
|
|
1048
|
+
async saveMapTileset(payload) {
|
|
1049
|
+
const input = asRecord(payload);
|
|
1050
|
+
const result = await mapgen.saveMapTileset(asString(input.projectId), asString(input.tilesetId), {
|
|
1051
|
+
name: typeof input.name === "string" ? input.name : undefined,
|
|
1052
|
+
cell: input.cell === undefined ? undefined : { width: Number(asRecord(input.cell).width), height: Number(asRecord(input.cell).height) },
|
|
1053
|
+
shape: mapgen.parseTilesetShape(input.shape),
|
|
1054
|
+
animRows: typeof input.animRows === "boolean" ? input.animRows : undefined
|
|
1055
|
+
});
|
|
1056
|
+
return { tileset: mapTilesetBrief(result.tileset), warnings: result.warnings };
|
|
1057
|
+
}
|
|
1058
|
+
async removeMapTileset(payload) {
|
|
1059
|
+
const input = asRecord(payload);
|
|
1060
|
+
const result = await mapgen.removeMapTileset(asString(input.projectId), asString(input.tilesetId));
|
|
1061
|
+
return { ok: true, ...result };
|
|
1062
|
+
}
|
|
1063
|
+
async saveMapDoc(payload) {
|
|
1064
|
+
const input = asRecord(payload);
|
|
1065
|
+
const id = asString(input.projectId);
|
|
1066
|
+
const result = await mapgen.saveMapDocStructure(id, {
|
|
1067
|
+
name: typeof input.name === "string" ? input.name : undefined,
|
|
1068
|
+
cols: typeof input.cols === "number" ? input.cols : undefined,
|
|
1069
|
+
rows: typeof input.rows === "number" ? input.rows : undefined,
|
|
1070
|
+
layers: Array.isArray(input.layers) ? input.layers : undefined,
|
|
1071
|
+
addLayer: input.addLayer === undefined ? undefined : { name: typeof asRecord(input.addLayer).name === "string" ? asRecord(input.addLayer).name : undefined },
|
|
1072
|
+
removeLayerId: typeof input.removeLayerId === "string" ? input.removeLayerId : undefined,
|
|
1073
|
+
moveLayer: input.moveLayer === undefined ? undefined : { id: asString(asRecord(input.moveLayer).id), toIndex: Number(asRecord(input.moveLayer).toIndex) },
|
|
1074
|
+
clearLayerId: typeof input.clearLayerId === "string" ? input.clearLayerId : undefined,
|
|
1075
|
+
wrap: typeof input.wrap === "boolean" ? input.wrap : undefined
|
|
1076
|
+
});
|
|
1077
|
+
// 结构变了(尺寸 / 图层 / 环绕)→ 界面要重算画布与计划,把最新视图一起回给它。
|
|
1078
|
+
const project = await mapgen.readMapProject(id);
|
|
1079
|
+
return {
|
|
1080
|
+
doc: { id: result.doc.id, name: result.doc.name, cols: result.doc.cols, rows: result.doc.rows, layers: result.doc.layers },
|
|
1081
|
+
dropped: result.dropped,
|
|
1082
|
+
warnings: result.warnings,
|
|
1083
|
+
view: project === undefined ? undefined : await mapgen.mapView(project)
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
async applyMapOps(payload) {
|
|
1087
|
+
const input = asRecord(payload);
|
|
1088
|
+
return mapgen.applyMapOps(asString(input.projectId), Array.isArray(input.ops) ? input.ops : [], {
|
|
1089
|
+
stroke: typeof input.stroke === "string" && input.stroke !== "" ? input.stroke : undefined,
|
|
1090
|
+
have: mapHave(input.have)
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
async mapUndo(payload) {
|
|
1094
|
+
const input = asRecord(payload);
|
|
1095
|
+
return mapgen.undoMap(asString(input.projectId), mapHave(input.have));
|
|
1096
|
+
}
|
|
1097
|
+
async mapRedo(payload) {
|
|
1098
|
+
const input = asRecord(payload);
|
|
1099
|
+
return mapgen.redoMap(asString(input.projectId), mapHave(input.have));
|
|
1100
|
+
}
|
|
1101
|
+
async mapPlan(payload) {
|
|
1102
|
+
const input = asRecord(payload);
|
|
1103
|
+
const view = asRecord(input.view);
|
|
1104
|
+
return mapgen.mapPlan(asString(input.projectId), {
|
|
1105
|
+
view: { x: Number(view.x) || 0, y: Number(view.y) || 0, width: Number(view.width) || 0, height: Number(view.height) || 0 },
|
|
1106
|
+
have: mapHave(input.have),
|
|
1107
|
+
layerIds: Array.isArray(input.layerIds) ? input.layerIds.map((entry) => Number(entry)) : undefined,
|
|
1108
|
+
pending: Array.isArray(input.pending) ? input.pending : undefined
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
/** 一键生成:整层一次提交(一次撤销就能回去),同种子逐字节可复现。 */
|
|
1112
|
+
async runMapGenerate(payload) {
|
|
1113
|
+
const input = asRecord(payload);
|
|
1114
|
+
const kind = asString(input.kind, "random");
|
|
1115
|
+
if (kind !== "random" && kind !== "maze" && kind !== "continent")
|
|
1116
|
+
throw new Error(`未知生成算法:${kind}(可选 random / maze / continent)`);
|
|
1117
|
+
return mapgen.runMapGenerate(asString(input.projectId), {
|
|
1118
|
+
kind,
|
|
1119
|
+
tiles: Array.isArray(input.tiles) ? input.tiles.map((entry) => Number(entry)) : undefined,
|
|
1120
|
+
seed: typeof input.seed === "number" ? input.seed : undefined,
|
|
1121
|
+
layerId: typeof input.layerId === "string" && input.layerId !== "" ? input.layerId : undefined
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
async runMapPreview(payload) {
|
|
1125
|
+
return mapgen.runPreviewStage(asString(asRecord(payload).projectId));
|
|
1126
|
+
}
|
|
1127
|
+
async runMapExport(payload) {
|
|
1128
|
+
const input = asRecord(payload);
|
|
1129
|
+
return mapgen.runExportStage(asString(input.projectId), {
|
|
1130
|
+
scale: typeof input.scale === "number" ? input.scale : undefined,
|
|
1131
|
+
formats: input.formats === undefined ? undefined : input.formats
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
async cancelMapJob(payload) {
|
|
1135
|
+
mapgen.cancelMapJob(asString(asRecord(payload).projectId));
|
|
1136
|
+
return { ok: true };
|
|
1137
|
+
}
|
|
1138
|
+
async setMapApproved(payload) {
|
|
1139
|
+
const input = asRecord(payload);
|
|
1140
|
+
const id = asString(input.projectId);
|
|
1141
|
+
const stage = asString(input.stage);
|
|
1142
|
+
const approved = input.approved === true;
|
|
1143
|
+
await mapgen.patchMapProject(id, (project) => {
|
|
1144
|
+
const stages = stage === "" ? mapgen.MAP_STAGES : [stage];
|
|
1145
|
+
for (const key of stages) {
|
|
1146
|
+
if (!mapgen.MAP_STAGES.includes(key))
|
|
1147
|
+
throw new Error(`未知阶段:${key}`);
|
|
1148
|
+
const current = project.stages[key];
|
|
1149
|
+
project.stages[key] = { ...current, approved, approvedAt: approved ? new Date().toISOString() : undefined };
|
|
1150
|
+
}
|
|
1151
|
+
appendJobLog(project.logs, "info", `${approved ? "通过" : "取消通过"}:${stage === "" ? "全部阶段" : stage}`);
|
|
1152
|
+
});
|
|
1153
|
+
return { ok: true, stage: stage === "" ? null : stage, approved };
|
|
1154
|
+
}
|
|
1155
|
+
async revealMapProject(payload) {
|
|
1156
|
+
const input = asRecord(payload);
|
|
1157
|
+
const id = asString(input.projectId);
|
|
1158
|
+
/**
|
|
1159
|
+
* `target: "export"` = 打开**导出目录**(界面上的「打开导出目录」按钮);
|
|
1160
|
+
* 其余(含省略)= 项目目录。两者都不是随便拼路径 —— 见 `mapgen.mapRevealDir`:
|
|
1161
|
+
* 它按与导出同一处口径算目录名,还没导出过就退回项目目录并用 `fallback` 说明。
|
|
1162
|
+
*/
|
|
1163
|
+
const { dir, fallback } = await mapgen.mapRevealDir(id, asString(input.target));
|
|
1164
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
|
|
1165
|
+
try {
|
|
1166
|
+
spawn(command, [dir], { detached: true, stdio: "ignore" }).unref();
|
|
1167
|
+
}
|
|
1168
|
+
catch (error) {
|
|
1169
|
+
throw new Error(`无法打开目录:${error instanceof Error ? error.message : String(error)}`);
|
|
1170
|
+
}
|
|
1171
|
+
return { ok: true, dir, fallback };
|
|
1172
|
+
}
|
|
921
1173
|
// ── 流水线控制 ──────────────────────────────────────────────────────────
|
|
922
1174
|
async runImage(payload) {
|
|
923
1175
|
const input = asRecord(payload);
|
|
@@ -1181,9 +1433,11 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
1181
1433
|
job.suffix = input.suffix;
|
|
1182
1434
|
if (input.settings !== undefined) {
|
|
1183
1435
|
const raw = asRecord(input.settings);
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
job.settings.
|
|
1436
|
+
const current = await loadConfig();
|
|
1437
|
+
// 生图模型是全局设置(设置 → 游戏素材大师 → 生图后端),任务里不保留可覆盖的副本。
|
|
1438
|
+
job.settings.model = imageModelOf(current);
|
|
1439
|
+
// 自定义后端的尺寸也是全局参数;火山方舟下才保留任务级覆盖。
|
|
1440
|
+
job.settings.size = isCustomProvider(current) ? current.customSize : asString(raw.size, job.settings.size);
|
|
1187
1441
|
job.settings.count = clampInt(raw.count, job.settings.count, 1, 8);
|
|
1188
1442
|
job.settings.watermark = raw.watermark === true;
|
|
1189
1443
|
}
|
|
@@ -1794,7 +2048,7 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
1794
2048
|
if (typeof record.role === "string")
|
|
1795
2049
|
patch.role = record.role;
|
|
1796
2050
|
if (record.parent === null)
|
|
1797
|
-
patch.parent =
|
|
2051
|
+
patch.parent = null;
|
|
1798
2052
|
else if (typeof record.parent === "string")
|
|
1799
2053
|
patch.parent = record.parent;
|
|
1800
2054
|
if (Array.isArray(record.proximal) && record.proximal.length === 2)
|
|
@@ -1879,6 +2133,31 @@ function kickImageKey(jobId) {
|
|
|
1879
2133
|
function disposeImageTasks() {
|
|
1880
2134
|
imageTasks.clear();
|
|
1881
2135
|
}
|
|
2136
|
+
/**
|
|
2137
|
+
* 素材的紧凑摘要(网关回给界面 / 工具面用)。
|
|
2138
|
+
*
|
|
2139
|
+
* 不回**整张 `tiles` 表**:一张大素材图能切出上千个小格,每次导入都把它们发一遍
|
|
2140
|
+
* 没有意义(界面要的是几何 + 调色板,调色板在 `mapView.tilesets[].palette` 里)。
|
|
2141
|
+
*/
|
|
2142
|
+
function mapTilesetBrief(tileset) {
|
|
2143
|
+
return {
|
|
2144
|
+
id: tileset.id,
|
|
2145
|
+
name: tileset.name,
|
|
2146
|
+
file: tileset.file,
|
|
2147
|
+
imageWidth: tileset.imageWidth,
|
|
2148
|
+
imageHeight: tileset.imageHeight,
|
|
2149
|
+
cell: tileset.cell,
|
|
2150
|
+
shape: tileset.shape,
|
|
2151
|
+
animRows: tileset.animRows,
|
|
2152
|
+
variants: tileset.variants,
|
|
2153
|
+
builtin: tileset.builtin === true ? true : undefined,
|
|
2154
|
+
tileCount: tileset.tiles.length
|
|
2155
|
+
};
|
|
2156
|
+
}
|
|
2157
|
+
/** 客户端报上来的 chunk key 列表收口(不是数组就是「没报」)。 */
|
|
2158
|
+
function mapHave(value) {
|
|
2159
|
+
return Array.isArray(value) ? value.map((entry) => String(entry)) : undefined;
|
|
2160
|
+
}
|
|
1882
2161
|
// ── 静态资源路由 ────────────────────────────────────────────────────────
|
|
1883
2162
|
/** 各模块允许通过 HTTP 路由读取的子目录白名单。 */
|
|
1884
2163
|
// `turn/` 是转圈截帧的候选帧与缩略条带:轴上那八个圆圈是对着条带拖的,
|
|
@@ -1892,6 +2171,16 @@ const SERVABLE_SEQUENCE_DIRS = new Set(["refs", "video-refs", "videos", "frames"
|
|
|
1892
2171
|
const SERVABLE_RIG_DIRS = new Set(["source", "sheet", "parts", "layout", "rig", "atlas", "export"]);
|
|
1893
2172
|
/** 地图地块:模板、原始生成、规整产物、装饰、地图、导出包。 */
|
|
1894
2173
|
const SERVABLE_TILE_DIRS = new Set(["template", "raw", "cell", "decor", "map", "export"]);
|
|
2174
|
+
/**
|
|
2175
|
+
* 地图编辑器(模块六):素材原图、验收预览图、导出包。
|
|
2176
|
+
*
|
|
2177
|
+
* ⚠️ 这个白名单、`AssetScope` 类型、`resolveAssetTarget` 的分支、`SCOPES`
|
|
2178
|
+
* 数组**四处必须同步**:漏一处就是 403,而界面只表现为「图裂了」。
|
|
2179
|
+
*
|
|
2180
|
+
* 单项目 = 单张地图之后 `maps/` 目录不存在了(地图就是项目根下的 `map.json`,
|
|
2181
|
+
* 不通过资源路由读)。
|
|
2182
|
+
*/
|
|
2183
|
+
const SERVABLE_MAP_DIRS = new Set(["tilesets", "preview", "export"]);
|
|
1895
2184
|
function resolveAssetTarget(scope, id, relative) {
|
|
1896
2185
|
if (scope === "assets") {
|
|
1897
2186
|
if (!PROJECT_ID_PATTERN.test(id))
|
|
@@ -1913,6 +2202,11 @@ function resolveAssetTarget(scope, id, relative) {
|
|
|
1913
2202
|
return undefined;
|
|
1914
2203
|
return { file: tilegen.tileAssetPath(id, relative), dirs: SERVABLE_TILE_DIRS };
|
|
1915
2204
|
}
|
|
2205
|
+
if (scope === "map-assets") {
|
|
2206
|
+
if (!mapgen.isValidMapProjectId(id))
|
|
2207
|
+
return undefined;
|
|
2208
|
+
return { file: mapgen.mapAssetPath(id, relative), dirs: SERVABLE_MAP_DIRS };
|
|
2209
|
+
}
|
|
1916
2210
|
if (!seqgen.isValidSequenceJobId(id))
|
|
1917
2211
|
return undefined;
|
|
1918
2212
|
return { file: seqgen.sequenceAssetPath(id, relative), dirs: SERVABLE_SEQUENCE_DIRS };
|
|
@@ -1927,6 +2221,8 @@ function sendText(res, status, text) {
|
|
|
1927
2221
|
* /dsh-game-material-master/image-assets/<任务 id>/<相对路径> 图片生成
|
|
1928
2222
|
* /dsh-game-material-master/sequence-assets/<任务 id>/<相对路径> 序列帧生成
|
|
1929
2223
|
* /dsh-game-material-master/rig-assets/<任务 id>/<相对路径> 骨骼动画生成
|
|
2224
|
+
* /dsh-game-material-master/tile-assets/<项目 id>/<相对路径> 45°地图地块生成
|
|
2225
|
+
* /dsh-game-material-master/map-assets/<项目 id>/<相对路径> 地图编辑器
|
|
1930
2226
|
*
|
|
1931
2227
|
* 支持 Range:没有它浏览器里的 <video> 就不能拖动进度条,验收视频时会很难受。
|
|
1932
2228
|
*/
|
|
@@ -1960,7 +2256,7 @@ async function handleAsset(req, res) {
|
|
|
1960
2256
|
// 三处同步。只改类型不改这里,TypeScript 一句话都不会说 —— `scope` 是断言出来的,
|
|
1961
2257
|
// 而漏掉的那个 scope 会在这里直接掉进 404(界面表现只是「图裂了」)。
|
|
1962
2258
|
// 实测:`tile-assets` 就这么漏过一轮,模板图全 404。
|
|
1963
|
-
const SCOPES = ["assets", "image-assets", "sequence-assets", "rig-assets", "tile-assets"];
|
|
2259
|
+
const SCOPES = ["assets", "image-assets", "sequence-assets", "rig-assets", "tile-assets", "map-assets"];
|
|
1964
2260
|
if (!SCOPES.includes(scope)) {
|
|
1965
2261
|
sendText(res, 404, "Not Found");
|
|
1966
2262
|
return;
|
package/lib/jsonio.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 三个功能模块(八方向图 / 图片生成 / 序列帧生成)各自独立存目录,
|
|
5
5
|
* 但「原子写 + 读文件 + 日志裁剪」这几件事是一样的,抽在这里避免重复。
|
|
6
6
|
*/
|
|
7
|
-
import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
7
|
+
import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
export async function readJson(file) {
|
|
@@ -62,7 +62,16 @@ export async function writeJsonAtomic(file, value) {
|
|
|
62
62
|
* `project.json.fa69b405.tmp`。它们不会被读,只会越积越乱,
|
|
63
63
|
* 所以在读项目时顺手扫一次。
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
|
+
* 清掉目录里**陈旧**的 `*.tmp`(原子写留下的中间态)。
|
|
67
|
+
*
|
|
68
|
+
* ⚠️ **不能见到 `*.tmp` 就删**:`writeJsonAtomic` 是「写 tmp → rename」,而读路径
|
|
69
|
+
* (`readMapProject` / `readTileProject`)会顺手扫一次目录。删除所有 tmp 的话,
|
|
70
|
+
* 读与写并发时正在写的那个中间文件会被读路径删掉,紧接着 `rename` 报 `ENOENT`
|
|
71
|
+
* —— 真机与自检各撞到过一次(`project.json.<hex>.tmp -> project.json`)。
|
|
72
|
+
* 所以只清「超过 `staleMs` 没动过」的那些(崩溃留下的残骸),默认 5 分钟。
|
|
73
|
+
*/
|
|
74
|
+
export async function sweepTempFiles(dir, staleMs = 5 * 60 * 1000) {
|
|
66
75
|
let names;
|
|
67
76
|
try {
|
|
68
77
|
names = await readdir(dir);
|
|
@@ -70,9 +79,21 @@ export async function sweepTempFiles(dir) {
|
|
|
70
79
|
catch {
|
|
71
80
|
return;
|
|
72
81
|
}
|
|
82
|
+
const now = Date.now();
|
|
73
83
|
await Promise.all(names
|
|
74
84
|
.filter((name) => name.endsWith(".tmp"))
|
|
75
|
-
.map((name) =>
|
|
85
|
+
.map(async (name) => {
|
|
86
|
+
const file = join(dir, name);
|
|
87
|
+
try {
|
|
88
|
+
const info = await stat(file);
|
|
89
|
+
if (now - info.mtimeMs < staleMs)
|
|
90
|
+
return; // 可能正有人写:别动它
|
|
91
|
+
await rm(file, { force: true });
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// 已经被人删掉了 / 读不到属性:都不是错误
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
76
97
|
}
|
|
77
98
|
export function appendJobLog(log, level, message, limit = 200) {
|
|
78
99
|
log.push({ at: Date.now(), level, message });
|
package/lib/links.js
CHANGED
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
export const OPEN_QUERY_KEY = "dsh-gmm";
|
|
29
29
|
/** 工作台在 `main` 槽里的 key,也是侧栏 `sidebar.panellist` 的 id。 */
|
|
30
30
|
export const PANEL_KEY = "gameStudio";
|
|
31
|
-
/**
|
|
32
|
-
export const STUDIO_MODULES = ["sprite", "image", "sequence", "rig", "tile"];
|
|
31
|
+
/** 六个模块的 key。 */
|
|
32
|
+
export const STUDIO_MODULES = ["sprite", "image", "sequence", "rig", "tile", "map"];
|
|
33
33
|
/** 八方向图的四个阶段。 */
|
|
34
34
|
export const SPRITE_STAGES = ["images", "videos", "frames", "sheet"];
|
|
35
35
|
/**
|
|
@@ -40,6 +40,15 @@ export const SPRITE_STAGES = ["images", "videos", "frames", "sheet"];
|
|
|
40
40
|
* 老的 `stage=template` 深链接会被忽略(`TILE_STAGES.includes` 不通过)。
|
|
41
41
|
*/
|
|
42
42
|
export const TILE_STAGES = ["generate", "review", "map", "export"];
|
|
43
|
+
/**
|
|
44
|
+
* 地图编辑器(模块六)的四个阶段。
|
|
45
|
+
*
|
|
46
|
+
* 与模块五(AI 生成地块)不同,这条链路**全本地**:导入素材 → 自动连接 → 画地图 →
|
|
47
|
+
* 导出。所以阶段名是素材 / 自动连接 / 地图 / 导出;`rules`(自动连接)没有可配的
|
|
48
|
+
* 东西、由宿主自动完成,界面里不显示它,但 key 保留 —— 对话面的
|
|
49
|
+
* `stage=assets|rules|paint|export` 契约不能变。
|
|
50
|
+
*/
|
|
51
|
+
export const MAP_STAGES = ["assets", "rules", "paint", "export"];
|
|
43
52
|
let clientOrigin = "";
|
|
44
53
|
/** 浏览器半区上报真实 origin。只接受 http(s),其它一律忽略。 */
|
|
45
54
|
export function rememberClientOrigin(origin) {
|