@ninkch/dsh-infinite-canvas 0.19.13 → 0.19.14
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/client.js +52 -2
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -6760,6 +6760,13 @@ function queueThumb(assetId) {
|
|
|
6760
6760
|
// moyu 类中转站:OpenAI 风格但图片字段用 input_reference / images:string[](dataURL 直接放),
|
|
6761
6761
|
// 不收 [{url,role}] 对象数组;resolution 用大写枚举;无 generate_audio/output_format 参数。
|
|
6762
6762
|
const isMoyuFlavor = /moyu\.info/i.test(base);
|
|
6763
|
+
// moyu 的图片代理接受「裸 base64」或「http(s) URL」,但【不认 data: 前缀】——
|
|
6764
|
+
// dataURL 的前缀会让它的 URL 校验失败(0.19.13 实测 502「需要 http(s) 接口 url」)。
|
|
6765
|
+
const moyuImagePayload = (dataUrl) => {
|
|
6766
|
+
const t = String(dataUrl || '');
|
|
6767
|
+
const m = /^data:[^;]+;base64,(.+)$/.exec(t);
|
|
6768
|
+
return m ? m[1] : t;
|
|
6769
|
+
};
|
|
6763
6770
|
const headers = { 'Content-Type': 'application/json', ...(s.apiKey ? { Authorization: 'Bearer ' + s.apiKey } : {}) };
|
|
6764
6771
|
// 尾帧+参考图同连(跨镜衔接)→ 尾帧降级为第一张衔接参考图(first_frame/reference_image 互斥),标注写在提示词里
|
|
6765
6772
|
const vRefs = o.hardFrame ? [] : (o.refs || []).slice(0, 8);
|
|
@@ -6777,12 +6784,12 @@ function queueThumb(assetId) {
|
|
|
6777
6784
|
// 首帧图生视频:构图以首帧为准——Seedance 系要求首帧模式必须 ratio=adaptive(仅纯首帧模式)
|
|
6778
6785
|
if (frameBlob && !downgrade) {
|
|
6779
6786
|
body.ratio = 'adaptive';
|
|
6780
|
-
if (isMoyuFlavor) body.input_reference = await blobToDataUrlScaled(frameBlob);
|
|
6787
|
+
if (isMoyuFlavor) body.input_reference = moyuImagePayload(await blobToDataUrlScaled(frameBlob));
|
|
6781
6788
|
else try { body.image = await blobToDataUrlScaled(frameBlob); } catch { /* 忽略首帧编码失败 */ }
|
|
6782
6789
|
} else if (vRefs.length) {
|
|
6783
6790
|
const imgs = downgrade ? [frameBlob].concat(vRefs) : vRefs;
|
|
6784
6791
|
body.images = isMoyuFlavor
|
|
6785
|
-
? await Promise.all(imgs.map((b) => blobToDataUrlScaled(b)))
|
|
6792
|
+
? await Promise.all(imgs.map(async (b) => moyuImagePayload(await blobToDataUrlScaled(b))))
|
|
6786
6793
|
: isOpenaiVideo
|
|
6787
6794
|
? await Promise.all(imgs.map(async (b) => ({ url: await blobToDataUrlScaled(b), role: 'reference_image' })))
|
|
6788
6795
|
: await Promise.all(imgs.map((b) => blobToDataUrlScaled(b)));
|
|
@@ -9165,7 +9172,46 @@ function queueThumb(assetId) {
|
|
|
9165
9172
|
data,
|
|
9166
9173
|
};
|
|
9167
9174
|
}
|
|
9175
|
+
/**
|
|
9176
|
+
* 客户端建点布局(与 Host nextNodePos 同一套算法,代码级强控制):
|
|
9177
|
+
* ① 一类型一列:同类型已有节点 → x 对齐该列(取最小 x),y 追加到列尾(最大 bottom + 40);
|
|
9178
|
+
* ② 该类型第一个节点 → 用调用者给的 pos 起新列;
|
|
9179
|
+
* ③ 碰撞下移:候选框(含 28px 最小间距)与任何节点相交 → 自动下移到相交节点下方,绝不重叠;
|
|
9180
|
+
* ④ 上限 80 轮防死循环。
|
|
9181
|
+
* 调用者传入的 pos 只用于"起新列",不用于自由摆放——布局纪律由代码保证,
|
|
9182
|
+
* 不依赖调用者(对话框/工具条/快捷键)自觉。
|
|
9183
|
+
*/
|
|
9184
|
+
function nextNodePosClient(type, pos, size) {
|
|
9185
|
+
const GAP_X = 60, GAP_Y = 40, MIN_GAP = 28;
|
|
9186
|
+
const H = (n) => Number(n && n.h) || 160;
|
|
9187
|
+
const W = (n) => Number(n && n.w) || 280;
|
|
9188
|
+
const nodes = Object.values(S.graph.nodes);
|
|
9189
|
+
const estH = (size && Number(size.h)) || 360;
|
|
9190
|
+
const estW = (size && Number(size.w)) || 360;
|
|
9191
|
+
const same = nodes.filter((n) => n.type === type && n.type !== 'group');
|
|
9192
|
+
let x = Math.round((pos && pos.x) || 80);
|
|
9193
|
+
let y = Math.round((pos && pos.y) || 40);
|
|
9194
|
+
if (same.length) {
|
|
9195
|
+
x = Math.min(...same.map((n) => n.x || 0));
|
|
9196
|
+
y = Math.max(...same.map((n) => (n.y || 0) + H(n))) + GAP_Y;
|
|
9197
|
+
}
|
|
9198
|
+
const hit = (yy) => nodes.find((n) => n.type !== 'group' && !((n.data && n.data.hidden))
|
|
9199
|
+
&& (n.x || 0) < x + estW + MIN_GAP && (n.x || 0) + W(n) + MIN_GAP > x
|
|
9200
|
+
&& (n.y || 0) < yy + estH + MIN_GAP && (n.y || 0) + H(n) + MIN_GAP > yy);
|
|
9201
|
+
let blocker = hit(y);
|
|
9202
|
+
let guard = 0;
|
|
9203
|
+
while (blocker && guard++ < 80) { y = (blocker.y || 0) + H(blocker) + MIN_GAP; blocker = hit(y); }
|
|
9204
|
+
return { x, y };
|
|
9205
|
+
}
|
|
9206
|
+
|
|
9168
9207
|
function addNodeAt(type, pos) {
|
|
9208
|
+
// 代码级强控制:建点坐标由布局引擎决定(一类型一列 + 碰撞下移),不信任调用者的自由坐标。
|
|
9209
|
+
// 媒体节点外框按比例(与 Host nextNodePos 同口径),其余 360×360。
|
|
9210
|
+
const t2 = normalizeNodeType(type);
|
|
9211
|
+
const sz = (t2 === 'image' || t2 === 'video')
|
|
9212
|
+
? nodeSizeForRatio((pos && pos.ratio) || '16:9', { hasFooter: false })
|
|
9213
|
+
: null;
|
|
9214
|
+
pos = nextNodePosClient(t2, pos, sz);
|
|
9169
9215
|
const n = newNode(type, pos);
|
|
9170
9216
|
update((s) => { s.graph.nodes[n.id] = n; s.sel = new Set([n.id]); s.selEdge = null; });
|
|
9171
9217
|
pushHistory();
|
|
@@ -20012,6 +20058,10 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20012
20058
|
ratioIsValid, ratioAspect, ratioFromDims, mediaRatioOf, mediaAspectOf, mediaRatioForDims,
|
|
20013
20059
|
normalizeMediaNodeSize, normalizeGraphDoc, resizeBoxFor, composerWidthFor,
|
|
20014
20060
|
wheelScrollTarget,
|
|
20061
|
+
// 建点布局强控制(一类型一列 + 碰撞下移):addNodeAt 收口 + 纯函数,供回归测试直接驱动
|
|
20062
|
+
nextNodePosClient, addNodeAt,
|
|
20063
|
+
graph: () => JSON.parse(JSON.stringify(S.graph)), // 建点结果断言用(与 SYNC.graph 同口径)
|
|
20064
|
+
addGraphNodes: (list) => { for (const n of (list || [])) S.graph.nodes[n.id] = n; }, // 测试播种(写入活状态)
|
|
20015
20065
|
// 下拉自定义数值的纯函数:范围夹取 / 整数与小数口径(分镜数、单段上限共用)
|
|
20016
20066
|
clampCustomNumber,
|
|
20017
20067
|
// 视频请求时长策略:手动秒数 vs 分镜节拍(供面板禁用态与请求侧共用)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninkch/dsh-infinite-canvas",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.14",
|
|
4
4
|
"description": "无限画布(Infinite Canvas)for DeepSeek Harness:节点式创作工作室(剧本/分镜/生成/成片),内置「媒体创作」预设模式(导演第一视角 + 引导工作坊)。Version-agnostic: reads the live catalog from the installed package at load time.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|