docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]

This commit is contained in:
2026-11-16 17:52:11 +08:00
parent 30829eeb86
commit 1090591503
123 changed files with 1279 additions and 3 deletions
+14
View File
@@ -1,3 +1,4 @@
// 成员跨父/子或兄弟子画布移动的纯变换,先解析真实逻辑端点,再按新所有者重建边界。
package platform
import (
@@ -7,8 +8,13 @@ import (
"sort"
)
// canvasCoordinateSpace 表示相对于协调父画布的内容原点与展示缩放,不包含 viewport。
type canvasCoordinateSpace struct{ X, Y, Scale float64 }
// memberLogicalEndpoint 用原画布/节点复合 Key 保留身份,避免不同画布同名节点被错误合并。
type memberLogicalEndpoint struct{ Key, Handle string }
// memberLogicalEdge 保留原边对象、来源坐标空间和解析后的真实端点,供重新选择边所有者。
type memberLogicalEdge struct {
OriginalBoard string
Data map[string]any
@@ -17,6 +23,7 @@ type memberLogicalEdge struct {
// All documents are copied before transforming them. Each node/edge retains its
// ID; collisions in a destination reject the entire operation instead of renaming.
// moveMembersDocuments 只修改新解码副本,保留节点/边 ID;任何目标 ID 冲突都整体拒绝,不自动改名。
func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw map[string]json.RawMessage) (map[string]json.RawMessage, error) {
if source == target || source == "" || target == "" || len(nodeIDs) == 0 {
return nil, errGraphOwnership
@@ -35,6 +42,7 @@ func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw m
if docs[parent] == nil || docs[source] == nil || docs[target] == nil {
return nil, errGraphOwnership
}
// 允许 parent 和其直接子画布间变换;内容偏移为 frame 原点加 (24,36),再应用 contentScale。
spaces := map[string]canvasCoordinateSpace{parent: {Scale: 1}}
frames := map[string]map[string]any{}
childForFrame := map[string]string{}
@@ -92,6 +100,7 @@ func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw m
if targetFrame := frames[target]; targetFrame != nil && source == parent && id == targetFrame["id"] {
return nil, errGraphOwnership
}
// 先映到父坐标再映到目标局部坐标;节点固有宽高不随 presentation 缩放被破坏性重写。
owner[key] = target
p := n["position"].(map[string]any)
from, to := spaces[source], spaces[target]
@@ -99,6 +108,7 @@ func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw m
p["y"] = (from.Y + from.Scale*p["y"].(float64) - to.Y) / to.Scale
delete(n["data"].(map[string]any), "frameId")
}
// 将父边的 frame port 展开为孩子真实端点,再决定迁移后边归哪个画布所有。
resolve := func(board, node, handle string) (memberLogicalEndpoint, error) {
if board == parent {
if child := childForFrame[node]; child != "" {
@@ -143,6 +153,7 @@ func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw m
}
// Remove ports whose target changed ownership. Rebuild only the boundaries
// still needed by logical edges; stable endpoint hashes deduplicate retries.
// 删除已转移节点对应的旧端口,保留未移动端点的稳定端口 ID。
for child, frame := range frames {
data := frame["data"].(map[string]any)
ports, _ := data["ports"].([]any)
@@ -170,6 +181,7 @@ func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw m
outputNodes[destination] = append(outputNodes[destination], n)
}
}
// 边留在父画布而端点在孩子时,复用或补齐该孩子 frame 的端口;同画布直接引用真实节点。
endpoint := func(value memberLogicalEndpoint, edgeBoard, direction string) (string, string, error) {
board := owner[value.Key]
n := nodes[value.Key]
@@ -201,6 +213,7 @@ func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw m
data["ports"] = append(ports, map[string]any{"id": id, "nodeId": node, "handle": handle, "direction": direction})
return frame["id"].(string), "port:" + id, nil
}
// 两端新所有者相同时边下沉,否则留在父画布;曲线位置/向量一起按对应空间转换。
for _, edge := range logical {
destination := parent
if owner[edge.Source.Key] == owner[edge.Target.Key] {
@@ -236,6 +249,7 @@ func moveMembersDocuments(parent, source, target string, nodeIDs []string, raw m
projectEdgePath(e, from.Scale/to.Scale, (from.X-to.X)/to.Scale, (from.Y-to.Y)/to.Scale)
outputEdges[destination] = append(outputEdges[destination], e)
}
// 所有输出重新规范化后才返回;调用方负责原子保存,不能逐张提前提交。
result := map[string]json.RawMessage{}
for _, board := range boards {
doc := docs[board]