Your Name 1912bcd25b
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
chore: sync all remaining local workspace changes
2026-05-08 11:26:57 +08:00

977 lines
32 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Extracted from browser-delivered Turbopack chunk: fd0220e4d10052af.701bdafa2d.js
* Module id: 898823
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t = e.i(417754),
n = e.i(459812),
i = e.i(877497),
r = e.i(713118),
a = e.i(799545),
o = e.i(182004),
s = e.i(299750),
c = e.i(562530),
l = e.i(216257),
u = e.i(135623),
h = e.i(437425),
f = e.i(403216);
let d = 0;
class p {
_trace;
_listeners = new Set();
_startTime = 0;
constructor() {
this._trace = {
traceId: (d++, `pipeline-${Date.now()}-${d}`),
startNodeId: "",
plan: [],
startTime: 0,
nodeTraces: {},
events: [],
};
}
getTrace() {
return this._trace;
}
get traceId() {
return this._trace.traceId;
}
onEvent(e) {
return (
this._listeners.add(e),
() => {
this._listeners.delete(e);
}
);
}
pipelineStart(e, t) {
for (let n of ((this._startTime = performance.now()),
(this._trace.startNodeId = e),
(this._trace.plan = [...t]),
(this._trace.startTime = Date.now()),
t))
this._trace.nodeTraces[n] = { nodeId: n, status: "pending" };
this.emit({
type: "pipeline:start",
timestamp: Date.now(),
elapsed: 0,
detail: { startNodeId: e, planLength: t.length, plan: t },
}),
console.log(
`%c[Pipeline Trace] 🚀 开始执行 (${this._trace.traceId})`,
"color: #4CAF50; font-weight: bold",
`
起始节点: ${e}
计划: ${t.length} 个节点`,
t,
);
}
pipelineEnd(e) {
let t = Date.now(),
n = performance.now() - this._startTime;
(this._trace.endTime = t),
(this._trace.totalDurationMs = Math.round(n)),
(this._trace.outcome = e),
(this._trace.summary = this.computeSummary()),
this.emit({
type: "aborted" === e ? "pipeline:abort" : "pipeline:end",
timestamp: t,
elapsed: Math.round(n),
detail: {
outcome: e,
totalDurationMs: this._trace.totalDurationMs,
summary: this._trace.summary,
},
});
let i = this._trace.summary,
r = "completed" === e ? "✅" : "aborted" === e ? "🛑" : "❌";
console.log(
`%c[Pipeline Trace] ${r} 执行${"completed" === e ? "完成" : "aborted" === e ? "中止" : "失败"} (${this._trace.traceId})`,
`color: ${"completed" === e ? "#4CAF50" : "#F44336"}; font-weight: bold`,
`
耗时: ${(this._trace.totalDurationMs / 1e3).toFixed(1)}s
完成: ${i.completedNodes}/${i.totalNodes}
失败: ${i.failedNodes} | 跳过: ${i.skippedNodes}
平均节点耗时: ${(i.avgNodeDurationMs / 1e3).toFixed(1)}s`,
),
console.groupCollapsed(`[Pipeline Trace] 完整追踪数据`),
console.log(JSON.parse(JSON.stringify(this._trace))),
console.groupEnd();
}
nodeStart(e, t) {
let n = Math.round(performance.now() - this._startTime),
i = this._trace.nodeTraces[e];
i &&
((i.status = "running"),
(i.startTime = Date.now()),
(i.generatorType = t)),
this.emit({
type: "node:start",
timestamp: Date.now(),
elapsed: n,
nodeId: e,
detail: { generatorType: t },
}),
console.log(
`%c[Pipeline Trace] ▶ 节点开始: ${e}`,
"color: #2196F3",
t ? `(${t})` : "",
`+${(n / 1e3).toFixed(1)}s`,
);
}
nodeEnd(e, t, n) {
let i = Math.round(performance.now() - this._startTime),
r = this._trace.nodeTraces[e];
r &&
((r.status = t),
(r.endTime = Date.now()),
r.startTime && (r.durationMs = r.endTime - r.startTime),
n?.taskId && (r.taskId = n.taskId),
n?.error && (r.error = n.error)),
this.emit({
type: "skipped" === t ? "node:skip" : "node:end",
timestamp: Date.now(),
elapsed: i,
nodeId: e,
detail: { status: t, durationMs: r?.durationMs, ...n },
});
let a = "success" === t ? "✓" : "failed" === t ? "✗" : "⊘",
o =
"success" === t
? "#4CAF50"
: "failed" === t
? "#F44336"
: "#9E9E9E";
console.log(
`%c[Pipeline Trace] ${a} 节点${"success" === t ? "成功" : "failed" === t ? "失败" : "跳过"}: ${e}`,
`color: ${o}`,
r?.durationMs ? `耗时 ${(r.durationMs / 1e3).toFixed(1)}s` : "",
n ?? "",
);
}
nodeValidationWarning(e, t) {
let n = Math.round(performance.now() - this._startTime),
i = this._trace.nodeTraces[e];
i && (i.validationWarnings = t),
this.emit({
type: "node:validation_warning",
timestamp: Date.now(),
elapsed: n,
nodeId: e,
detail: { warnings: t },
}),
console.warn(`[Pipeline Trace] ⚠ 节点 ${e} 参数校验警告:`, t);
}
nodeError(e, t) {
let n = Math.round(performance.now() - this._startTime),
i = t instanceof Error ? t.message : String(t),
r = this._trace.nodeTraces[e];
r && (r.error = i),
this.emit({
type: "node:error",
timestamp: Date.now(),
elapsed: n,
nodeId: e,
detail: { error: i, stack: t instanceof Error ? t.stack : void 0 },
});
}
conflictDetected(e) {
let t = Math.round(performance.now() - this._startTime);
this.emit({
type: "conflict:detected",
timestamp: Date.now(),
elapsed: t,
detail: e,
});
}
conflictResolved(e) {
let t = Math.round(performance.now() - this._startTime);
this.emit({
type: "conflict:resolved",
timestamp: Date.now(),
elapsed: t,
detail: e,
});
}
emit(e) {
for (let t of (this._trace.events.push(e), this._listeners))
try {
t(e);
} catch (e) {
console.error("[PipelineObserver] 事件监听回调出错:", e);
}
}
computeSummary() {
let e = Object.values(this._trace.nodeTraces),
t = e.filter((e) => "success" === e.status).length,
n = e.filter((e) => "failed" === e.status).length,
i = e.filter((e) => "skipped" === e.status).length,
r = e.filter((e) => null != e.durationMs).map((e) => e.durationMs),
a = r.length > 0 ? r.reduce((e, t) => e + t, 0) / r.length : 0,
o = r.length > 0 ? Math.max(...r) : 0,
s = r.length > 0 ? Math.min(...r) : 0;
return {
totalNodes: e.length,
completedNodes: t,
failedNodes: n,
skippedNodes: i,
avgNodeDurationMs: Math.round(a),
maxNodeDurationMs: o,
minNodeDurationMs: s,
};
}
}
var g = e.i(136036),
b = e.i(10036);
function m(e, t) {
let n = new Map(),
i = new Map();
for (let t of e) n.set(t.id, 0), i.set(t.id, []);
for (let e of t)
i.get(e.source)?.push(e.target),
n.set(e.target, (n.get(e.target) ?? 0) + 1);
let r = [];
n.forEach((e, t) => {
0 === e && r.push(t);
});
let a = [];
for (; r.length > 0; ) {
let e = r.shift();
if (!e) break;
for (let t of (a.push(e), i.get(e) ?? [])) {
let e = (n.get(t) ?? 1) - 1;
n.set(t, e), 0 === e && r.push(t);
}
}
return a;
}
function w(e, t) {
let n = new Set(),
i = [e];
for (; i.length > 0; ) {
let e = i.shift();
if (!e) break;
for (let r of t)
r.source !== e ||
n.has(r.target) ||
(n.add(r.target), i.push(r.target));
}
return n;
}
function v(e) {
let t = e.data;
return (
!!t?.action &&
[
o.NodeAction.TEXT_GENERATE,
o.NodeAction.IMAGE_GENERATE,
o.NodeAction.VIDEO_GENERATE,
o.NodeAction.AUDIO_GENERATE,
o.NodeAction.VIDEO_EDIT,
o.NodeAction.IMAGE_EDIT,
o.NodeAction.SCRIPT_GENERATE,
].includes(t.action)
);
}
let x = new Set([
o.NodeType.TEXT,
o.NodeType.IMAGE,
o.NodeType.VIDEO,
o.NodeType.AUDIO,
o.NodeType.SCRIPT,
]),
y = {
[o.NodeType.TEXT]: "text",
[o.NodeType.IMAGE]: "image",
[o.NodeType.VIDEO]: "video",
[o.NodeType.AUDIO]: "audio",
[o.NodeType.SCRIPT]: "text",
};
function _(e, t, n) {
let i = t.filter((t) => t.parentId === e);
if (0 === i.length) return [];
let r = new Set(i.map((e) => e.id)),
a = n.filter((e) => r.has(e.source) && r.has(e.target)),
o = new Set(a.map((e) => e.target));
return m(i, a).filter((e) => {
var t;
let n,
r = i.find((t) => t.id === e);
return (
r &&
((t = o.has(e)),
(n = r.data),
!!n?.type && !!x.has(n.type) && (!!v(r) || !!t))
);
});
}
async function S(e) {
let i = l.stores.canvas,
r = l.stores.global;
if (!i || !r) return { totalPower: 0, nodeCount: 0, hasError: !0 };
let a = _(e, i.getNodes(), i.getEdges());
if (0 === a.length) return { totalPower: 0, nodeCount: 0, hasError: !1 };
let o = i.projectId,
c = await Promise.allSettled(
a.map(async (e) => {
let a = i.getNode(e);
if (!a) return 0;
let c = (0, b.getGeneratorTypeFromNode)(a);
if ((c || (c = y[a.data?.type] ?? null), !c)) return 0;
let l = a.data,
u = l?.params ?? {},
h = i.getIncomingNodes(e),
f = (0, t.collectIncomingNodeData)(h),
d = {
...u,
textList: f.textList,
imageList: f.imageList,
videoList: f.videoList,
audioList: f.audioList,
};
if (!d.model) {
let e = c.replace(/^enhance/, "").toLowerCase();
d.model = r.defaultModel[e] ?? "";
}
let p = d.model || "",
m = c.startsWith("enhance")
? c.replace(/^enhance/, "").toLowerCase()
: c,
w = r.getModel(m, p);
if (w) {
let e = Array.isArray(d.imageList) && d.imageList.length > 0,
t =
d.modeType ??
("image" === c ? (e ? "image2image" : "text2image") : void 0),
i = (0, n.mergeParamsWithSchema)(
d.settings,
d.advancedSettings,
w,
t,
);
(d.settings = i.settings),
(d.advancedSettings = i.advancedSettings),
t && !d.modeType && (d.modeType = t);
}
let v = (0, b.buildRequestData)(d, c, e, o, r.getModel),
x = await (0, s.calculatePower)(v);
if (x?.code === 0) {
let e = x.data,
t = e?.power ?? 0,
n = e?.originalPrice,
i = (0, g.resolveStrikethroughPowerDisplay)({
strikethroughPrice: (0, g.isStrikethroughPriceEnabled)(
r.getModel(m, p),
(0, g.buildStrikethroughEvaluationContextFromParams)(d),
),
power: t,
originalPrice: n,
});
return i?.primary ?? t;
}
return 0;
}),
),
u = 0,
h = !1;
for (let e of c) "fulfilled" === e.status ? (u += e.value) : (h = !0);
return { totalPower: u, nodeCount: a.length, hasError: h };
}
function E() {
return { running: !1, plan: [], currentIndex: -1, nodeStatuses: {} };
}
class M {
abortController = null;
_state = E();
_onStateChange;
_observer = null;
_lastTrace = null;
_options = {};
_epoch = 0;
_activeRunEpoch = 0;
constructor(e) {
this._onStateChange = e;
}
get lastTrace() {
return this._lastTrace;
}
get observer() {
return this._observer;
}
get state() {
return this._state;
}
get isRunning() {
return this._state.running;
}
async run(e) {
let t, n;
if (this.isRunning)
return (
console.warn("[Pipeline] 已有 Pipeline 正在运行"),
{ completed: [], failed: null, skipped: [] }
);
let i = l.stores.canvas;
if (!i)
return (
console.error("[Pipeline] canvasStore 未初始化"),
{ completed: [], failed: null, skipped: [] }
);
let r = i.getNodes(),
a = i.getEdges(),
o =
((t = w(e, a)),
(n = r.find((t) => t.id === e)) && v(n) && t.add(e),
m(r, a).filter((e) => {
if (!t.has(e)) return !1;
let n = r.find((t) => t.id === e);
return n && v(n);
}));
if (0 === o.length)
return (
console.log("[Pipeline] 无可执行的生成节点"),
{ completed: [], failed: null, skipped: [] }
);
(this._observer = new p()),
this._observer.pipelineStart(e, o),
(this._activeRunEpoch = this._epoch);
let s = {};
for (let e of o) s[e] = "pending";
(this.abortController = new AbortController()),
this.updateState({
running: !0,
plan: o,
currentIndex: 0,
nodeStatuses: s,
});
let c = [],
u = [],
h = null;
for (let e = 0; e < o.length; e++) {
if (this.abortController?.signal.aborted) {
for (let t = e; t < o.length; t++)
(s[o[t]] = "skipped"),
u.push(o[t]),
this._observer?.nodeEnd(o[t], "skipped", {
reason: "pipeline_aborted",
});
break;
}
let t = o[e];
this.updateState({ currentIndex: e });
let n = await this.executeNode(t, this.abortController.signal);
if (
((s[t] = n),
this.updateState({ nodeStatuses: { ...s } }),
"success" === n)
)
c.push(t);
else if ("failed" === n) {
h = t;
for (let t = e + 1; t < o.length; t++)
(s[o[t]] = "skipped"),
u.push(o[t]),
this._observer?.nodeEnd(o[t], "skipped", {
reason: "upstream_failed",
});
this.updateState({ nodeStatuses: { ...s } });
break;
} else "skipped" === n && u.push(t);
}
this.updateState({ running: !1 }), (this.abortController = null);
let f = h
? "failed"
: this.abortController?.signal.aborted
? "aborted"
: c.length === o.length
? "completed"
: "partial";
return (
this._observer?.pipelineEnd(f),
(this._lastTrace = this._observer?.getTrace() ?? null),
(this._observer = null),
{ completed: c, failed: h, skipped: u }
);
}
async runGroup(e, t = {}) {
if (this.isRunning)
return (
console.warn("[Pipeline] 已有 Pipeline 正在运行"),
{ completed: [], failed: null, skipped: [] }
);
let n = l.stores.canvas;
if (!n)
return (
console.error("[Pipeline] canvasStore 未初始化"),
{ completed: [], failed: null, skipped: [] }
);
this._options = { autoFocus: !0, ...t };
let i = n.getNodes(),
r = n.getEdges(),
a = _(e, i, r);
if (0 === a.length)
return (
console.log("[Pipeline] 组内无可执行的生成节点"),
{ completed: [], failed: null, skipped: [] }
);
(this._observer = new p()),
this._observer.pipelineStart(e, a),
(this._activeRunEpoch = this._epoch);
let o = {};
for (let e of a) o[e] = "pending";
(this.abortController = new AbortController()),
this.updateState({
running: !0,
plan: a,
currentIndex: 0,
nodeStatuses: o,
groupNodeId: e,
});
let s = new Set(a),
c = r.filter((e) => s.has(e.source) && s.has(e.target)),
u = [],
h = [],
f = [],
d = new Set();
for (let e = 0; e < a.length; e++) {
if (this.abortController?.signal.aborted) {
for (let t = e; t < a.length; t++)
"skipped" !== o[a[t]] &&
((o[a[t]] = "skipped"),
h.push(a[t]),
this._observer?.nodeEnd(a[t], "skipped", {
reason: "pipeline_aborted",
}));
break;
}
let t = a[e];
if ((this.updateState({ currentIndex: e }), d.has(t))) continue;
this._options.autoFocus && this.autoSelectNode(t);
let n = await this.executeNode(t, this.abortController.signal);
if (
((o[t] = n),
this.updateState({ nodeStatuses: { ...o } }),
"success" === n)
)
u.push(t);
else if ("failed" === n) {
for (let e of (f.push(t), w(t, c)))
d.has(e) ||
"pending" !== o[e] ||
(d.add(e),
(o[e] = "skipped"),
h.push(e),
this._observer?.nodeEnd(e, "skipped", {
reason: "upstream_failed",
}));
this.updateState({ nodeStatuses: { ...o } });
} else "skipped" === n && h.push(t);
}
this.updateState({ running: !1 }),
(this._options = {}),
(this.abortController = null);
let g =
f.length > 0
? "failed"
: u.length === a.length
? "completed"
: "partial";
return (
this._observer?.pipelineEnd(g),
(this._lastTrace = this._observer?.getTrace() ?? null),
(this._observer = null),
{ completed: u, failed: f.length > 0 ? f[0] : null, skipped: h }
);
}
stop() {
this.abortController &&
(console.log("[Pipeline] 用户中止"), this.abortController.abort());
}
reset() {
this._epoch++,
this.abortController &&
(this.abortController.abort(), (this.abortController = null)),
(this._state = E()),
(this._options = {}),
(this._observer = null),
this._onStateChange?.({ ...this._state });
}
destroy() {
this.stop(), (this._onStateChange = void 0), (this._observer = null);
}
async executeNode(e, d) {
let p = l.stores.canvas,
g = l.stores.global;
if (!p || !g) return "failed";
let m = p.getNode(e);
if (!m)
return console.warn(`[Pipeline] 节点 ${e} 已不存在,跳过`), "skipped";
let w = (0, b.getGeneratorTypeFromNode)(m);
if (!w) {
let e = m.data;
w = y[e?.type ?? ""] ?? null;
}
if (!w)
return (
this._observer?.nodeEnd(e, "skipped", { reason: "not_generator" }),
"skipped"
);
let v = m.data;
if (
(0, o.isResourceAction)(v?.action) &&
((v?.type === o.NodeType.TEXT && v.content?.length) ||
(v?.type !== o.NodeType.TEXT && v.url?.length))
)
return (
this._observer?.nodeEnd(e, "success", {
reason: "resource_already_has_output",
}),
"success"
);
this._observer?.nodeStart(e, w);
let x = v?.params ?? {},
_ = p.projectId,
S = p.getIncomingNodes(e),
E = (0, t.collectIncomingNodeData)(S),
M = x.focusRegion,
T = M?.nodeId;
T &&
(E = { ...E, imageList: E.imageList.filter((e) => e.nodeId !== T) });
let k = v?.type,
C = v?.scriptRowHiddenUuid;
if ("video" === k && C && 0 === E.imageList.length) {
let n = p.getNodes(),
i = (0, t.findHiddenLineImageNode)(C, n, e);
if (i) E = { ...E, imageList: [i] };
else {
let e = x.imageList,
t = x.image;
Array.isArray(e) && e.length > 0
? (E = { ...E, imageList: (0, a.normalizeMediaList)(e) })
: "string" == typeof t &&
t &&
(E = {
...E,
imageList: [{ url: t, nodeId: "pipeline-image" }],
});
}
}
let A = {
...x,
textList: E.textList,
imageList: E.imageList,
videoList: E.videoList,
audioList: E.audioList,
};
if (
v?._mattingNode === !0 ||
v?.label === "抠图" ||
v?.name === "抠图"
) {
let t = E.imageList[0]?.url?.[0],
n = "string" == typeof t ? t.trim() : "";
if (!n)
return (
this._observer?.nodeEnd(e, "failed", {
error: "matting_missing_upstream_image",
}),
p.updateNodeData(e, {
taskInfo: {
taskId: "",
loading: !1,
status: 3,
failedReason: "抠图缺少上游图片",
},
}),
"failed"
);
p.updateNodeData(e, { taskInfo: { taskId: "", loading: !0 } });
try {
let t = (0, i.buildRemoveBackgroundRequest)(n, {
cid: (0, u.getCookieWebid)(),
eid: (0, h.createRandomId)(),
}),
a = await (0, s.removeBackgroundInference)(t),
c = a?.images?.[0];
if (!c) throw Error("未返回抠图结果");
let l = (0, s.getRemoveBackgroundImageUrl)(c),
f = E.imageList[0]?.nodeId,
d = (function (e, t) {
if (!t) return null;
let n = e(t);
if (!n) return null;
let i = n.data;
if (!i || i.type !== o.NodeType.IMAGE) return null;
let a = i.contentWidth,
s = i.contentHeight;
if (
"number" == typeof a &&
"number" == typeof s &&
a > 0 &&
s > 0
)
return {
contentWidth: Math.round(a),
contentHeight: Math.round(s),
};
let c = n.resourceMeta,
l = c?.items?.[0];
if (
l?.kind === "image" &&
null != l.width &&
null != l.height &&
l.width > 0 &&
l.height > 0
) {
let e = (0, r.computeNodeDimensionsFromNatural)(
l.width,
l.height,
);
return { contentWidth: e.width, contentHeight: e.height };
}
let u = n.measured?.width ?? n.width,
h = n.measured?.height ?? n.height;
return "number" == typeof u &&
"number" == typeof h &&
Number.isFinite(u) &&
Number.isFinite(h) &&
u > 0 &&
h > 0
? {
contentWidth: Math.round(u),
contentHeight: Math.round(h),
}
: null;
})((e) => p.getNode(e), f);
return (
p.updateNodeData(e, {
url: [l],
...(d ?? {}),
taskInfo: { taskId: "", loading: !1, status: 2 },
}),
p.markDownstreamStale(e),
this._observer?.nodeEnd(e, "success", {
reason: "matting_complete",
}),
"success"
);
} catch (n) {
let t = n instanceof Error ? n.message : "抠图失败";
return (
this._observer?.nodeEnd(e, "failed", { error: t }),
p.updateNodeData(e, {
taskInfo: {
taskId: "",
loading: !1,
status: 3,
failedReason:
t.includes("抠图") || t.includes("结果")
? t
: `抠图失败:${t}`,
},
}),
"failed"
);
}
}
if (!A.model) {
let t = w.replace(/^enhance/, "").toLowerCase(),
n = g.defaultModel[t] ?? "";
n &&
((A.model = n),
console.log(`[Pipeline] 节点 ${e} 缺少 model,使用默认模型: ${n}`));
}
let N = A.model || "",
I = w.startsWith("enhance")
? w.replace(/^enhance/, "").toLowerCase()
: w,
P = g.getModel(I, N);
if (P) {
let e = Array.isArray(A.imageList) && A.imageList.length > 0,
t =
A.modeType ??
("image" === w ? (e ? "image2image" : "text2image") : void 0),
i = (0, n.mergeParamsWithSchema)(
A.settings,
A.advancedSettings,
P,
t,
);
(A.settings = i.settings),
(A.advancedSettings = i.advancedSettings),
t && !A.modeType && (A.modeType = t);
}
if ("text" === w) {
let t = "string" == typeof A.prompt ? A.prompt.trim() : "",
n = A.textList,
i =
Array.isArray(n) &&
n.some((e) => e.content && e.content.length > 0);
if (!t && !i)
return (
console.log(
`[Pipeline] 文本节点 ${e} 无提示词且无上游文本输入,跳过`,
),
this._observer?.nodeEnd(e, "skipped", { reason: "empty_prompt" }),
"skipped"
);
}
if ("image" === w) {
let t = "string" == typeof A.prompt ? A.prompt.trim() : "";
if (!t || "/" === t) {
let t = v?.selectedSlash;
if (t?.scene) {
if (
((A.scene = t.scene), "character_turnaround_3view" === t.scene)
) {
let e = A.settings ?? {},
t =
Object.keys(e).find((e) =>
e.toLowerCase().startsWith("ratio"),
) ?? "ratio";
A.settings = { ...e, [t]: "16:9" };
}
(A.prompt = "/"),
console.log(
`[Pipeline] 图片节点 ${e} 使用 slash 指令: ${t.scene}`,
);
}
}
}
let R = w,
L = (0, f.validateGenerateParams)(R, A);
L.success || this._observer?.nodeValidationWarning(e, L.errors),
this.updateNodeStatus(e, "running"),
p.updateNodeData(e, { taskInfo: { taskId: "", loading: !0 } });
try {
let t = A;
if ("image" === w)
try {
t = await (0, b.prepareImageParamsForFocusRegion)(A);
} catch (t) {
return (
this._observer?.nodeError(e, t),
this._observer?.nodeEnd(e, "failed", {
error: t instanceof Error ? t.message : String(t),
}),
p.updateNodeData(e, {
taskInfo: {
taskId: "",
loading: !1,
status: 3,
failedReason: t instanceof Error ? t.message : String(t),
},
}),
"failed"
);
}
let n = (0, b.buildRequestData)(t, w, e, _, g.getModel);
console.log(`[Pipeline] 触发节点 ${e} (${w})`, n),
(0, c.markNodeSubmitting)(e);
try {
let t = await (0, c.submitGenerationTask)(n);
if (t.skippedDuplicate) return this.waitForCompletion(e, d);
if (t.success)
p.updateNodeData(e, {
taskInfo: { taskId: t.taskId, loading: !0 },
});
else {
let n = t.errorMsg ?? "网络异常,请重试";
return (
this._observer?.nodeEnd(e, "failed", { error: n }),
p.updateNodeData(e, {
taskInfo: {
taskId: "",
loading: !1,
status: 3,
failedReason: n,
},
}),
"failed"
);
}
} finally {
(0, c.unmarkNodeSubmitting)(e);
}
} catch (t) {
return (
this._observer?.nodeError(e, t),
this._observer?.nodeEnd(e, "failed", {
error: t instanceof Error ? t.message : String(t),
}),
p.updateNodeData(e, {
taskInfo: {
taskId: "",
loading: !1,
status: 3,
failedReason: "网络异常,请重试",
},
}),
"failed"
);
}
return this.waitForCompletion(e, d);
}
waitForCompletion(e, t) {
return new Promise((n) => {
let i = (t, i) => {
this._observer?.nodeEnd(e, t, i), n(t);
},
r = () => {
if (t.aborted) return void i("skipped", { reason: "aborted" });
let n = l.stores.canvas;
if (!n) return void i("failed", { error: "canvas_not_found" });
let a = n.getNode(e);
if (!a) return void i("skipped", { reason: "node_removed" });
let o = a.data?.taskInfo;
o?.status === 2
? i("success", { taskId: o.taskId })
: o?.status === 3
? i("failed", { taskId: o.taskId, error: "task_failed" })
: o?.loading || o?.taskId
? setTimeout(r, 1e3)
: i("failed", { error: "task_cancelled_externally" });
};
setTimeout(r, 1e3);
});
}
updateNodeStatus(e, t) {
(this._state.nodeStatuses[e] = t),
this.updateState({ nodeStatuses: { ...this._state.nodeStatuses } });
}
updateState(e) {
this._activeRunEpoch === this._epoch &&
((this._state = { ...this._state, ...e }),
this._onStateChange?.({ ...this._state }));
}
autoSelectNode(e) {
let t = l.stores.canvas;
if (!t) return;
let n = this._state.groupNodeId,
i = t
.getNodes()
.map((t) => ({
...t,
selected: t.id === e || (!!n && t.id === n),
}));
t.setNodes(i);
}
}
e.s(
[
"PipelineRunner",
() => M,
"calculateGroupPower",
() => S,
"createInitialPipelineState",
() => E,
],
898823,
);
};
export default moduleFactory;