perf(canvas): 画布媒体 - 优化媒体加载、播放器与节点交互 (#357)

Merge origin/main at fb089b2 and retain canvas media performance, player layout, and interaction updates.

Co-authored-by: ddCat <2695092045@qq.com>
This commit is contained in:
wurendao007
2026-08-31 09:00:37 +08:00
committed by GitHub
parent 21facff923
commit 8ebceecbb6
58 changed files with 2662 additions and 207 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, it } from "bun:test";
import { buildBatchConnectionCreateRequest, hasBatchConnectionCandidate, planBatchConnections } from "@/lib/canvas/canvas-batch-connection";
import { canvasConnectionPath } from "@/components/canvas/canvas-connections";
import { defaultConfig } from "@/stores/use-config-store";
import { CanvasNodeType, type CanvasConnection, type CanvasNodeData } from "@/types/canvas";
@@ -92,6 +93,35 @@ describe("planBatchConnections", () => {
});
});
describe("canvas connection anchors", () => {
it("keeps ordinary node edges centered even when legacy ratios exist", () => {
const connection: CanvasConnection = {
id: "ratio-test",
fromNodeId: "text-a",
toNodeId: "text-b",
fromAnchorRatio: 0.2,
toAnchorRatio: 0.8,
};
const result = canvasConnectionPath(connection, nodes[0], nodes[1]);
expect(result.startY).toBe(90);
expect(result.endY).toBe(310);
});
it("keeps storyboard row handles positioned independently from the node center", () => {
const connection: CanvasConnection = {
id: "storyboard-row-test",
fromNodeId: "text-a",
toNodeId: "script",
toHandleId: "row:row-1",
};
const result = canvasConnectionPath(connection, nodes[0], nodes[4]);
expect(result.startY).toBe(90);
expect(result.endY).toBeGreaterThan(90);
});
});
describe("buildBatchConnectionCreateRequest", () => {
it("keeps unique eligible sources and uses the first one for the pending connection", () => {
const request = buildBatchConnectionCreateRequest(["frame", "text-a", "text-a", "text-b"], nodes, { x: 900, y: 240 });