docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// 将旧快照树显式迁入 canonical 模型,保存完整旧→新稳定身份映射,原输入文档保持不变。
|
||||
package platform
|
||||
|
||||
import (
|
||||
@@ -6,21 +7,27 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// modelIdentity 包含来源画布和结构类型,避免不同画布或 node/edge 同名时映射碰撞。
|
||||
type modelIdentity struct {
|
||||
SourceCanvasID string `json:"sourceCanvasId"`
|
||||
Structure string `json:"structure"`
|
||||
SourceID string `json:"sourceId"`
|
||||
ElementID string `json:"elementId"`
|
||||
}
|
||||
|
||||
// modelMigration 返回模型、身份映射和普通旧 frame 新生成的画布 ID,由外层事务一次保存。
|
||||
type modelMigration struct {
|
||||
Model canvasModel
|
||||
Identities []modelIdentity
|
||||
NewCanvases []string
|
||||
}
|
||||
|
||||
// modelSpace 描述累积到根的平移/缩放,用于迁移曲线路径,不应用 viewport。
|
||||
type modelSpace struct{ X, Y, Scale float64 }
|
||||
|
||||
// No source document is changed. IDs are allocated once inside the eventual
|
||||
// migration transaction and the complete mapping is stored with its receipt.
|
||||
// migrateCanvasModel 通过注入 allocate 分配一次性稳定 ID;重复或非法分配结果直接拒绝。
|
||||
func migrateCanvasModel(root string, snapshots map[string]canvasSnapshot, relations []subgraphRelation, allocate func() string) (modelMigration, error) {
|
||||
result := modelMigration{Model: emptyModel(root), Identities: []modelIdentity{}, NewCanvases: []string{}}
|
||||
documents, nodes := map[string]map[string]any{}, map[string]map[string]any{}
|
||||
@@ -73,6 +80,7 @@ func migrateCanvasModel(root string, snapshots map[string]canvasSnapshot, relati
|
||||
}
|
||||
}
|
||||
}
|
||||
// 已有独立子图保留画布 ID,入口节点换为新元素 ID;关系必须与快照 subgraph 一致。
|
||||
for _, relation := range relations {
|
||||
if relation.Archived {
|
||||
continue
|
||||
@@ -91,6 +99,7 @@ func migrateCanvasModel(root string, snapshots map[string]canvasSnapshot, relati
|
||||
result.Model.Canvases[relation.Child] = modelCanvas{ID: relation.Child, Parent: &modelParent{CanvasID: relation.Parent, EntryElementID: identities[identityKey(relation.Parent, "node", relation.Frame)]}}
|
||||
}
|
||||
// Ordinary legacy frameId groups also become actual canvases, even if empty.
|
||||
// 没有独立子图的旧框也变成真实画布(包括空框),随后把显式 frameId 成员迁入。
|
||||
for _, key := range sortedKeys(nodes) {
|
||||
node := nodes[key]
|
||||
data := node["data"].(map[string]any)
|
||||
@@ -149,6 +158,7 @@ func migrateCanvasModel(root string, snapshots map[string]canvasSnapshot, relati
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
// 解开最多八层旧 port 链,得到 canonical 真实元素端点;方向错误或循环均拒绝。
|
||||
resolve := func(board, node, handle, direction string) (map[string]any, error) {
|
||||
seen := map[string]bool{}
|
||||
for depth := 0; depth <= 8; depth++ {
|
||||
@@ -217,6 +227,8 @@ func migrateCanvasModel(root string, snapshots map[string]canvasSnapshot, relati
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// modelContentScale 读取正展示缩放,缺省一;仅在迁移几何和路径空间计算时使用。
|
||||
func modelContentScale(data map[string]any) float64 {
|
||||
presentation, _ := data["presentation"].(map[string]any)
|
||||
if scale, ok := presentation["contentScale"].(float64); ok && scale > 0 {
|
||||
@@ -224,6 +236,8 @@ func modelContentScale(data map[string]any) float64 {
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
// legacyModelGeometry 为旧节点缺省尺寸补种类默认值,将 position/rotation 汇总到 canonical geometry。
|
||||
func legacyModelGeometry(node map[string]any, kind string) map[string]any {
|
||||
width, height := float64(260), float64(200)
|
||||
switch kind {
|
||||
@@ -247,6 +261,8 @@ func legacyModelGeometry(node map[string]any, kind string) map[string]any {
|
||||
rotation, _ := data["rotation"].(float64)
|
||||
return map[string]any{"x": position["x"], "y": position["y"], "width": width, "height": height, "rotation": rotation}
|
||||
}
|
||||
|
||||
// modelSpaces 迭代从已知父空间求孩子累计空间,九轮仍未覆盖或无进展表示树无效。
|
||||
func modelSpaces(model canvasModel) (map[string]modelSpace, error) {
|
||||
result := map[string]modelSpace{model.Root: {Scale: 1}}
|
||||
remaining := len(model.Canvases) - 1
|
||||
|
||||
Reference in New Issue
Block a user