@openfairygui/backend 0.6.2 → 0.6.3

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/dist/docs.cjs CHANGED
@@ -3758,6 +3758,7 @@ const CONTRACT_SNAPSHOT = {
3758
3758
  },
3759
3759
  "resource": { "$ref": "#/$defs/UamResourceRef_3486136f6c" },
3760
3760
  "controllerOverrides": { "type": "string" },
3761
+ "pageController": { "type": "string" },
3761
3762
  "fileName": { "type": "string" },
3762
3763
  "instanceProperties": { "$ref": "#/$defs/Shape_8a3021d271" },
3763
3764
  "propertyOverrides": { "$ref": "#/$defs/Array_7c27bc0bce" },
@@ -4772,6 +4773,7 @@ const CONTRACT_SNAPSHOT = {
4772
4773
  "titleFontSize": { "type": "number" },
4773
4774
  "sound": { "type": "string" },
4774
4775
  "soundVolumeScale": { "type": "number" },
4776
+ "pageController": { "type": "string" },
4775
4777
  "src": { "type": "string" },
4776
4778
  "packageId": { "type": "string" },
4777
4779
  "group": { "type": "string" },
@@ -4861,6 +4863,7 @@ const CONTRACT_SNAPSHOT = {
4861
4863
  "titleFontSize": { "type": "number" },
4862
4864
  "sound": { "type": "string" },
4863
4865
  "soundVolumeScale": { "type": "number" },
4866
+ "pageController": { "type": "string" },
4864
4867
  "src": { "type": "string" },
4865
4868
  "packageId": { "type": "string" },
4866
4869
  "group": { "type": "string" },
@@ -4951,6 +4954,7 @@ const CONTRACT_SNAPSHOT = {
4951
4954
  "titleFontSize": { "type": "number" },
4952
4955
  "sound": { "type": "string" },
4953
4956
  "soundVolumeScale": { "type": "number" },
4957
+ "pageController": { "type": "string" },
4954
4958
  "src": { "type": "string" },
4955
4959
  "packageId": { "type": "string" },
4956
4960
  "group": { "type": "string" },
@@ -5042,6 +5046,7 @@ const CONTRACT_SNAPSHOT = {
5042
5046
  "reverse": { "type": "boolean" },
5043
5047
  "sound": { "type": "string" },
5044
5048
  "soundVolumeScale": { "type": "number" },
5049
+ "pageController": { "type": "string" },
5045
5050
  "src": { "type": "string" },
5046
5051
  "packageId": { "type": "string" },
5047
5052
  "group": { "type": "string" },
@@ -5126,6 +5131,7 @@ const CONTRACT_SNAPSHOT = {
5126
5131
  "max": { "type": "number" },
5127
5132
  "value": { "type": "number" },
5128
5133
  "wholeNumbers": { "type": "boolean" },
5134
+ "pageController": { "type": "string" },
5129
5135
  "src": { "type": "string" },
5130
5136
  "packageId": { "type": "string" },
5131
5137
  "group": { "type": "string" },
@@ -5204,6 +5210,7 @@ const CONTRACT_SNAPSHOT = {
5204
5210
  "const": "scrollBar"
5205
5211
  },
5206
5212
  "fixedGripSize": { "type": "boolean" },
5213
+ "pageController": { "type": "string" },
5207
5214
  "src": { "type": "string" },
5208
5215
  "packageId": { "type": "string" },
5209
5216
  "group": { "type": "string" },
@@ -12128,6 +12135,7 @@ const CONTRACT_SNAPSHOT = {
12128
12135
  },
12129
12136
  "resource": { "$ref": "#/$defs/UamResourceRef_3486136f6c_read" },
12130
12137
  "controllerOverrides": { "type": "string" },
12138
+ "pageController": { "type": "string" },
12131
12139
  "fileName": { "type": "string" },
12132
12140
  "instanceProperties": { "$ref": "#/$defs/Shape_8a3021d271_read" },
12133
12141
  "propertyOverrides": { "$ref": "#/$defs/Array_7c27bc0bce_read" },
@@ -13160,6 +13168,7 @@ const CONTRACT_SNAPSHOT = {
13160
13168
  "titleFontSize": { "type": "number" },
13161
13169
  "sound": { "type": "string" },
13162
13170
  "soundVolumeScale": { "type": "number" },
13171
+ "pageController": { "type": "string" },
13163
13172
  "src": { "type": "string" },
13164
13173
  "packageId": { "type": "string" },
13165
13174
  "group": { "type": "string" },
@@ -13249,6 +13258,7 @@ const CONTRACT_SNAPSHOT = {
13249
13258
  "titleFontSize": { "type": "number" },
13250
13259
  "sound": { "type": "string" },
13251
13260
  "soundVolumeScale": { "type": "number" },
13261
+ "pageController": { "type": "string" },
13252
13262
  "src": { "type": "string" },
13253
13263
  "packageId": { "type": "string" },
13254
13264
  "group": { "type": "string" },
@@ -13339,6 +13349,7 @@ const CONTRACT_SNAPSHOT = {
13339
13349
  "titleFontSize": { "type": "number" },
13340
13350
  "sound": { "type": "string" },
13341
13351
  "soundVolumeScale": { "type": "number" },
13352
+ "pageController": { "type": "string" },
13342
13353
  "src": { "type": "string" },
13343
13354
  "packageId": { "type": "string" },
13344
13355
  "group": { "type": "string" },
@@ -13430,6 +13441,7 @@ const CONTRACT_SNAPSHOT = {
13430
13441
  "reverse": { "type": "boolean" },
13431
13442
  "sound": { "type": "string" },
13432
13443
  "soundVolumeScale": { "type": "number" },
13444
+ "pageController": { "type": "string" },
13433
13445
  "src": { "type": "string" },
13434
13446
  "packageId": { "type": "string" },
13435
13447
  "group": { "type": "string" },
@@ -13514,6 +13526,7 @@ const CONTRACT_SNAPSHOT = {
13514
13526
  "max": { "type": "number" },
13515
13527
  "value": { "type": "number" },
13516
13528
  "wholeNumbers": { "type": "boolean" },
13529
+ "pageController": { "type": "string" },
13517
13530
  "src": { "type": "string" },
13518
13531
  "packageId": { "type": "string" },
13519
13532
  "group": { "type": "string" },
@@ -13592,6 +13605,7 @@ const CONTRACT_SNAPSHOT = {
13592
13605
  "const": "scrollBar"
13593
13606
  },
13594
13607
  "fixedGripSize": { "type": "boolean" },
13608
+ "pageController": { "type": "string" },
13595
13609
  "src": { "type": "string" },
13596
13610
  "packageId": { "type": "string" },
13597
13611
  "group": { "type": "string" },
@@ -16097,16 +16111,16 @@ const CONTRACT_SNAPSHOT = {
16097
16111
  }
16098
16112
  }
16099
16113
  ],
16100
- "digest": "d3ec1cc02994d7af79610540dec9369f9fe8d03de795c754cd1d12ec8b214581"
16114
+ "digest": "5718c7534651570432e9dda5a5cda367cbc292e71e59f5f6ad2e1c55321dee5a"
16101
16115
  };
16102
16116
  //#endregion
16103
16117
  //#region src/generated/docs.ts
16104
16118
  const INSTALLED_DOCS = {
16105
16119
  "version": {
16106
16120
  "packageName": "@openfairygui/backend",
16107
- "packageVersion": "0.6.2",
16121
+ "packageVersion": "0.6.3",
16108
16122
  "nodeEngine": ">=22",
16109
- "documentationDigest": "677cd573d086a5568387d4de69585a5d8ba5575a40648b19f845f79ac5cfa4c3"
16123
+ "documentationDigest": "08afcb7b44b538e1592058f3e20e94c276b86573858962f1b6591cd34ac74b39"
16110
16124
  },
16111
16125
  "workflow": "# Installed OpenFairyGUI workflow\n\nThis is a minimal offline companion, not the full website. Read `ofgui docs ls --json` for the installed package version, contract version, capability schema version and digest. Use the project's installed `ofgui`/`ofgui-mcp`, not a global executable or an online latest-version lookup. A mismatched installation must be reconciled by the host before editing.\n\n## Discover the current contract\n\n- `ofgui docs find \"selector\" --json` searches this installed corpus.\n- `ofgui docs cat contracts --json` lists Core operations and Backend/MCP mappings.\n- `ofgui docs schema setDisplayNodeProps --json` reads one self-contained operation schema.\n- `ofgui docs schema cli/validate --json` reads the installed CLI output schema; `cli/docs cat` is a valid exact document ID for the nested command.\n- `ofgui docs cat methods/queryEntity --json` reads precise input/output wire schemas.\n- `ofgui docs diagnostic stale_write --json` reads recovery guidance.\n- MCP `resources/read` at `openfairygui://docs/index` provides the same index and content URIs. MCP is local stdio, not an assumed HTTP port.\n\nThe generated schemas describe JSON wire structure and input budgets, not semantic validity. Native SDK byte fields remain Uint8Array; MCP transports declared byte fields as integer arrays. Arbitrary extension data is not converted. Host objects/functions are omitted from MCP wire schemas; use SDK declarations for host injection, not guessed JSON fields.\n\nMCP allows up to 8 MiB of aggregate byte input at generated byte paths, without applying the general 10000-element array or per-byte node limits. Arbitrary metadata retains general limits. All value-bearing Gear defaults may be null, preserving the owner's initial state when no default override exists; component-instance controllerOverrides retains controller selections.\n\nAll CLI JSON uses `{schemaVersion:1,command,success:true,result}` or `{schemaVersion:1,command,success:false,error:{code,message},result?}`. Documentation version/index/body fields are inside `result`; read `result.text` for document content. Invalid/incomplete validate and doctor responses retain their full report under `result`. Help/version are text; other JSON-mode stdout contains exactly one document and human logs use stderr. Exit codes: 0 success, 1 workflow failure, 2 arguments, 3 incomplete validation. CLI owns envelopes, not new workflow semantics.\n\n## Edit safely\n\n1. Read capabilities. Existing projects use openSession (with host authorization and a lifetime lock); openProjectSession accepts a host-supplied authoritative UAM, not a shortcut around lossy file-session guards.\n2. Read getProjectOutline to discover exact identities, then queryEntity for the relevant current properties and actual revision. Capabilities list the supported read.entityQuery.kinds: project, package, resource, component, displayNode, controller and transition. Project queries use target {kind:\"project\"} without a selector; package queries use {kind:\"package\",selector:{packageId}}. Both return identity and complete entity.properties.settings. Controllers use packageId + componentResourceId + controllerName; transitions use packageId + componentResourceId + transitionName. Names are exact and component-scoped; duplicates fail as ambiguous. Controller snapshots include pages/actions; transition snapshots include items. Gears are already included in displayNode snapshots. Fixed projections exclude source bytes; budget failures require host inspection.\n3. Read the operation and method schemas. Plan the smallest authorized batch using current identifiers and expectedRevision.\n4. preflightTransaction executes on an isolated snapshot and discards it. Inspect projectedRevision, impact.entities (exact identities and changed fields, including reference normalization), impact.files (ProjectWriter model diff, not a disk write plan) and persistence.nextAction. The diff starts at the current revision, not the last save. It contains no source bytes. Summary overflow or serialization failure returns transaction_preview_failed without a partial result. No revision is reserved; writeVerified is always false. It does not save files or guarantee later apply/save/publish.\n5. Only when authorized, applyTransaction with the planned batch and expectedRevision. On stale_write, refresh and replan; never blindly substitute a newer revision.\n6. validateSession checks the new authoritative state. A successful response can contain an invalid or incomplete validation report; require status valid and complete true before treating validation as passed.\n7. When authorized, saveSession checks revision independently and writes the original project only. Keep path policy, UAM fidelity and rollback guards. Close the session only after handling unsaved changes. Read saved output again when disk round-trip is part of acceptance.\n\nPreview permits invalid references in the existing snapshot so a repair can be reviewed, but serializes that snapshot only into memory. The projected state and all persistence remain validated; unsupported or unrepresentable snapshots still fail explicitly.\n\nupdateProjectSettings and updatePackageSettings replace complete settings snapshots. Copy the corresponding query's entity.properties.settings, change only requested fields, retain other nested settings and optional fields, and submit the complete settings with the queried revision. Package updates also require the original packageId selector. Settings queries share the same response budgets as other entity kinds.\n\nupdateController and updateTransition replace complete snapshots, not partial patches. Copy the queried entity.properties, change only the requested fields, preserve page IDs/remarks/actions, item order/targets, settings and references, and submit the original selector with the queried revision. A stale_write requires refreshing and replanning the full snapshot for all these replacement operations. Querying does not validate references or grant permission to edit them.\n\n## Consume the committed session state\n\nFor complete public UAM consumption, use readSessionState({sessionId, expectedRevision?}); use queryEntity for targeted properties. The detached model excludes only asset resources' primary sourceBytes, retaining sourcePath and JSON extensions. It includes revision, dirty, lastSavedRevision, readComplete, readDiagnostics and uamFidelity. Only this read-model output schema accepts unnamed object fields; transaction input contracts remain unchanged.\n\nRead each asset with readResourceBytes({sessionId, expectedRevision: state.revision, selector:{packageId,resourceId}}). Bytes are detached Uint8Array values in the SDK and integer arrays in MCP, limited to the primary file already held in memory. There is no disk hydration or auxiliary-file discovery. Components are unsupported; unavailable bytes produce session_read_failed with reason bytes_unavailable.\n\nOn stale_read, discard the incomplete model/bytes collection and restart from readSessionState. Reads do not wait for uncommitted transactions, retain historical versions, or reserve revisions. Saving can update sourcePath and dirty without increasing the edit revision; the same revision does not identify permanently identical complete UAM. Completeness/fidelity flags preserve existing meaning and do not guarantee bytes, rendering or saving. Preserve failed reads as failures; never save or repair merely to obtain a read.\n\nCapabilities advertise a 4 MiB compact JSON data limit (depth 64, 500000 nodes) for the model and 1 MiB per primary resource. Both new MCP tools additionally limit the complete JSON CallToolResult, including compact text and structuredContent, to 16 MiB; excess returns mcp_response_budget_exceeded. Native model/buffer overflow returns session_read_failed with reason response_budget_exceeded, without truncation. Read the installed methods/readSessionState and methods/readResourceBytes schemas for precise inputs, results and errors.\n\n## Diagnose without repair\n\n`ofgui doctor --json` checks installed CLI/documentation versions, the Node Backend capability snapshot, in-memory Sharp PNG/JPEG encoding and pixel decoding, and temporary-directory access flags. `ofgui doctor <project-directory-or-fairy-file> --json` additionally runs existing Node project validation, including source reads and available image decoding. Optional `--output-dir <directory>` checks an explicit destination or its nearest existing ancestor, without creating it. Directory checks return the absolute requested `path`, link-resolved `inspectedPath` and `exists` (null when unknown); files, dangling links and access errors fail. The temporary directory must exist. It opens no Backend session, creates no lock, installs nothing, writes no probe files and changes no configuration.\n\nExit 0 means the requested checks completed; exit 1 means a detected error; exit 2 means invalid arguments; exit 3 means native image capability is unavailable/failed or project validation is incomplete. Inspect result.checks, result.errors and result.project. Without a project, its source bytes are not checked. Access flags do not prove effective ACL permissions, available space, later writes/rename/rollback or continued access. The capability manifest remains a declaration; a successful doctor does not prove publish/restore or runtime rendering. Plugins and configured output destinations are not executed or checked automatically; only explicit --output-dir is inspected. This product doctor does not inspect Git, pnpm, repository builds or fixture submodules; maintainers use pnpm repo:doctor for those.\n\nRead diagnostic guides for ownership and recovery boundaries. Every formal Core/Backend diagnostic code is covered; shared codes list all `owners`, while response `owner` identifies the actual source. Missing bytes/decoders, rejected paths and expired sessions require host action; do not invent repair/hydration tools, widen roots, discard unsaved work, or turn incomplete validation into success. Invalid/unsupported operations require schema-based replanning, live locks cannot be removed, and write failures require preserving dirty state and inspecting actual files.\n\n## Publish and recover trusted local artifacts\n\nPublishing and restoration are external Node-hosted workflows, not Backend session methods or general MCP editing tools. The host must authorize input and output directories independently. They require the native image capability; do not rename binary extensions to imitate a different target profile.\n\n- `ofgui publish <project> --output <release-directory> --project-type layabox --json` publishes the current saved project. `--output` overrides runtime artifact destinations; configured code generation still uses its own destinations and project plugins run as trusted local code.\n- The JSON document is `{schemaVersion:1,command:\"publish\",success:true,result:{files:[{path,size}]}}`. Paths are final absolute paths and sizes are bytes. The Node SDK `publishNode()` returns the same `result`. The manifest records actual successful filesystem/atlas writes, including code written through the supplied publish filesystem; it excludes pre-existing untouched files, deletions and arbitrary plugin I/O outside that filesystem. It is not an inventory of everything in the output directory. Explicit runtime output is staged and rolled back on failure; separately configured code outputs and arbitrary plugin effects are not covered by that directory transaction.\n- `ofgui restore <trusted-release-directory> --output <separate-project-directory> --project-type layabox --json` returns `{schemaVersion:1,command:\"restore\",success:true,result:{projectPath,packages:[{id,name}],warnings:[]}}`. Warnings are not a validation pass. Reread the returned projectPath and run `ofgui validate <projectPath> --json`; require valid and complete validation.\n- Both artifact commands exit 0 on workflow success, 1 on workflow failure, and 2 on command syntax errors. Errors are `{schemaVersion:1,command,success:false,error:{code,message}}`, with `publish_failed`, `restore_failed` or `invalid_arguments`. In JSON mode stdout contains only this document; human/plugin output goes to stderr. Help remains human-readable. Errors do not include a claimed successful file manifest.\n- Restore requires a separate directory, not a `.fairy` file. Do not force overwrite by default. `--force` replaces an existing nonempty target only after complete staged recovery; parse/image failures retain the previous target. Only trusted local artifacts are supported, not arbitrary third-party imports.\n- Read `ofgui docs cat restore-limits --json` or MCP resource `openfairygui://docs/restore-limits` for the installed version's full recovery boundary. Accept readable, structurally valid supported semantics and decoded assets, not original project IDs, workspace state, unpublished resources, original filenames/extensions, controller editor selection/export flags, float32 text precision or byte-identical XML.\n",
16112
16126
  "restoreLimits": "# 受限发布产物恢复边界\n\n`restore` 只是一条受限的本地故障恢复路径,不是 FairyGUI 的常规创作入口、第三方发布物导入器或源码还原承诺。本文档记录其安全使用范围,以及当前仓库已经验证过、无法仅凭发布产物稳定恢复的内容。\n\n## 使用范围与安全边界\n\n| 项目 | 当前口径 |\n|---|---|\n| 输入 | 仅处理可信的本地发布目录;不把未知来源 `.fui` / `_fui.bytes` 视为安全输入 |\n| 输出 | 必须是独立工程目录,不接受 `.fairy` 单文件目标 |\n| 路径约束 | 拒绝资源路径、包名、分支名、文件名中的路径逃逸;发布目录内资源若解析到输入目录外也会失败 |\n| 覆盖行为 | 先在相邻暂存目录完成工程和资源写入,再替换目标;`--force` 不会在二进制解析或资源重建前删除旧输出 |\n| 不代表 | 不是恶意文件检测器,也不保证第三方产物能够安全或完整恢复 |\n\n这里的“不可还原”指:\n\n| 项目 | 含义 |\n|---|---|\n| 输入范围 | 仅使用发布目录中的 `.fui` / `_fui.bytes`、图集 PNG、以及同目录 loose 资源 |\n| 判定标准 | 不能稳定、通用、无外部辅助地恢复回原工程语义或原始 XML 文本 |\n| 不包含 | 仍可通过补协议、补 writer 规则、补测试继续收敛的普通实现问题 |\n\n## 总结\n\n| 结论 | 说明 |\n|---|---|\n| 受限恢复目标 | 在可信输入下生成一个可重读、可打开、结构自洽的 FairyGUI 工程 |\n| 不保证目标 | 还原成与原工程逐字节一致的源码工程 |\n| 主要原因 | 发布产物会丢失一部分编辑器阶段信息,或把原始值降精度到运行时格式 |\n\n## 当前已确认的不可还原项\n\n恢复时推导出的图片尺寸用于资源重建,但不作为原始声明尺寸写入 `package.xml`;生成的字体纹理和字形图片按顺序跟随对应字体。`RestoreResult.document` 保留尺寸省略与资源排序两种写入提示,交给新的 `ProjectWriter` 或 `NodeIO.writeProject()` 仍生效。提示属于内存中的序列化控制,不随 UAM 转换或重新读取传播。`ProjectWriter.setImageWriteHints(image, {})` 清除该图片的全部提示,恢复普通尺寸写回和资源排序;需要保留排序时,设置 `{ packageOrder: { afterId, weight } }`,其中目标是同包、同分支且未设置排序提示的资源。\n\n### 1. 发布包中根本不存在的资源或动作\n\n发布物中缺失独立资源项的字形图像使用稳定 glyph 图像 ID 的 UTF-8 十六进制生成 `images/glyph-<id>.png`,不同字体的不同图像 ID 不会因字符相同而重名。已有资源项保留发布物中的名称和路径;生成名称不代表原始源文件名,不依据示例包名或字体名称猜测。\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 组件资源 | 原工程存在、但发布包未携带的组件 XML | 发布产物没有资源定义,restore 无法凭空生成真实内容 | `HitTest/component1.xml`、`PullToRefresh/Button1.xml`、`PullToRefresh/Button2.xml`、`TurnPage/Button3.xml` |\n| Transition item | 原工程存在、但二进制 transition block 未携带的 item | 二进制里没有对应时间轴项,无法可靠反推 | `Transition/BOSS.xml` 中 `target=\"n3\"` 的 6 个 item |\n\n说明:这类内容如果强行补出,只能生成占位内容,不能声称是“还原原工程”。\n\n### 2. 原始资源文件名与扩展名\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 普通图片资源 | 原工程使用的真实文件扩展名与双后缀命名 | 发布包只保留运行时资源名,不稳定保留工程文件名 | `change.jpg -> change.png`、`Paper.jpg -> Paper.png`、`i3.png.png -> i3.png` |\n| 部分 loose 资源 | 若发布名与工程名完全脱钩,且缺少稳定映射线索 | 发布目录只提供发布后文件名,原工程命名信息已经丢失 | 仍可能出现少量发布名残留 |\n\n说明:当前实现已经尽量把“资源 id 命名”还原回工程名,但对原始扩展名并不能做通用、可靠的反推。\n\n### 3. Transition path 的原始文本精度\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 路径字符串 | 编辑器 XML 中 path 的原始小数位数与文本格式 | 发布二进制只保存 float32 数值;写回时只能输出数值等价的字符串 | `Transition/PathDemo.xml` 的 `path` |\n\n说明:这类路径通常还能恢复到相同几何轨迹,但不能保证与原 XML 的字符串完全一致。\n\n### 4. 被降级为运行时默认值的编辑器信息\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| Transition easing | 原工程中的特定 ease 名称 | 当前样本对应二进制读出的就是默认 easing,无法证明原工程曾写过哪个非默认 ease | `Transition/BOSS.xml`、`TRAP.xml`、`GoodHit.xml` 中部分 `Expo.Out` / `Back.Out` / `Bounce.Out` |\n| 简单 Group 节点 | 仅用于编辑器分组、但没有额外运行时语义的 `GGroup` 节点 | 当前样本中的发布组件数据会直接裁掉这类 group,二进制 child list 里既没有 group 节点,也没有可稳定回推的 group 归属索引 | `Basics/Demo_Clip&Scroll.xml`、`Emoji/Main.xml`、`TurnPage/Book.xml` |\n| Group 高级模式 | 原工程 XML 中的 `group.advanced=\"true\"` | 发布 group block写出的是布局与间距等运行时数据,不单独保留编辑器里的高级模式开关;当前样本中二进制读回的 group 会直接落成 `advanced=false` | `Basics/Demo_Grid.xml`、`Transition/Main.xml`、`Transition/PowerUp.xml` |\n| Controller 当前选中页 | 原工程 XML 中的 `controller.selected` 当前页状态 | 发布 controller block稳定保存的是 `homePageType/homePage` 发布首页信息;当前样本中的二进制常写成 `default`,并不保留编辑器工程里当时的非零当前页 | `TurnPage/Main.xml` 的 `bookPos=\"2\"`、`TurnPage/Page.xml` 的 `style=\"1\"` / `side=\"1\"`、`FrontCover.xml` / `BackCover.xml` 的 `side=\"1\"` |\n| Controller 导出标记 | 原工程 XML 中的 `controller.exported=\"true\"` | 当前样本对应的 controller 发布 block只写 `name/pages/homePageType/homePage/actions`,没有独立写出 `exported` | `TurnPage/BackCover.xml`、`TurnPage/FrontCover.xml`、`TurnPage/Page.xml` |\n| 默认值显式性 | 原工程是否显式写出默认属性 | 发布包只保留语义值,不保留“这个默认值当时是否显式写在 XML 里” | 如 `xy=\"0,0\"`、空文本、默认布尔值等 |\n\n说明:这类信息恢复后通常仍然语义可用,但无法保证与原工程的编辑器写法逐项一致。\n\n### 5. 编辑器工程本地设置\n\n| 类别 | 不可还原内容 | 原因 |\n|---|---|---|\n| 工程标识 | 原始 `projectId` | restore 会生成新的工程标识 |\n| 工程设置 | 原始 `.objs` / workspace / 编辑器本地状态 | 发布目录不包含这些本地工程文件 |\n| 初始化设置之外的项目配置 | 原工程的非发布产物配置 | 当前 restore 按初始化默认值生成工程设置,而不是恢复源工程工作区状态 |\n\n说明:当前 restore 的目标是“重建可用工程”,不是恢复编辑器本地工作环境。\n\n### 6. 原工程 XML 的文本级细节\n\n| 类别 | 不可还原内容 | 原因 |\n|---|---|---|\n| 属性顺序 | 原标签属性排列顺序 | XML 语义不依赖属性顺序,发布产物也不保留该信息 |\n| 格式风格 | 换行、缩进、是否自闭合、空格风格 | 这是 writer 生成结果,不是发布产物协议内容 |\n| 大小写风格 | 某些颜色值、小数文本风格 | 发布包保留的是数值语义,不是原文本样式 |\n\n说明:当前实现会尽量贴近 FairyGUI 编辑器写法,但不会把这类文本风格视为“可从发布产物逆推出的正式数据”。\n\n## 当前恢复输出范围\n\n| 项目 | 当前口径 |\n|---|---|\n| 工程目标 | 在可信输入下生成可读、可打开、可继续编辑的 FairyGUI 工程 |\n| 资源目标 | 尽量恢复包内素材、组件 XML、字体派生图与 `.jta` / `.fnt` 等正式资源 |\n| 不承诺 | 与原工程一模一样的文件名、文本格式、局部编辑器状态 |\n\n## 何时需要外部辅助信息\n\n若目标不是“重建可用工程”,而是“尽量贴近原工程文本或命名”,则需要额外输入:\n\n| 额外输入 | 作用 |\n|---|---|\n| 原工程目录 | 作为命名、路径、缺失资源、文本样式的真实基准 |\n| 编辑器工作区文件 | 恢复 `.objs`、workspace、本地工程状态 |\n| 发布前清单或映射表 | 回填发布名与工程名之间的脱钩关系 |\n\n## 当前样本下仍然成立的判断\n\n| 判断 | 说明 |\n|---|---|\n| 可以从发布产物重建“可工作的工程” | 是 |\n| 可以从发布产物重建“原工程的源码真迹” | 否 |\n| 还原结果是否应该继续优化 | 可以,但应只优化“发布产物里确实有证据的部分” |\n",
package/dist/docs.mjs CHANGED
@@ -3757,6 +3757,7 @@ const CONTRACT_SNAPSHOT = {
3757
3757
  },
3758
3758
  "resource": { "$ref": "#/$defs/UamResourceRef_3486136f6c" },
3759
3759
  "controllerOverrides": { "type": "string" },
3760
+ "pageController": { "type": "string" },
3760
3761
  "fileName": { "type": "string" },
3761
3762
  "instanceProperties": { "$ref": "#/$defs/Shape_8a3021d271" },
3762
3763
  "propertyOverrides": { "$ref": "#/$defs/Array_7c27bc0bce" },
@@ -4771,6 +4772,7 @@ const CONTRACT_SNAPSHOT = {
4771
4772
  "titleFontSize": { "type": "number" },
4772
4773
  "sound": { "type": "string" },
4773
4774
  "soundVolumeScale": { "type": "number" },
4775
+ "pageController": { "type": "string" },
4774
4776
  "src": { "type": "string" },
4775
4777
  "packageId": { "type": "string" },
4776
4778
  "group": { "type": "string" },
@@ -4860,6 +4862,7 @@ const CONTRACT_SNAPSHOT = {
4860
4862
  "titleFontSize": { "type": "number" },
4861
4863
  "sound": { "type": "string" },
4862
4864
  "soundVolumeScale": { "type": "number" },
4865
+ "pageController": { "type": "string" },
4863
4866
  "src": { "type": "string" },
4864
4867
  "packageId": { "type": "string" },
4865
4868
  "group": { "type": "string" },
@@ -4950,6 +4953,7 @@ const CONTRACT_SNAPSHOT = {
4950
4953
  "titleFontSize": { "type": "number" },
4951
4954
  "sound": { "type": "string" },
4952
4955
  "soundVolumeScale": { "type": "number" },
4956
+ "pageController": { "type": "string" },
4953
4957
  "src": { "type": "string" },
4954
4958
  "packageId": { "type": "string" },
4955
4959
  "group": { "type": "string" },
@@ -5041,6 +5045,7 @@ const CONTRACT_SNAPSHOT = {
5041
5045
  "reverse": { "type": "boolean" },
5042
5046
  "sound": { "type": "string" },
5043
5047
  "soundVolumeScale": { "type": "number" },
5048
+ "pageController": { "type": "string" },
5044
5049
  "src": { "type": "string" },
5045
5050
  "packageId": { "type": "string" },
5046
5051
  "group": { "type": "string" },
@@ -5125,6 +5130,7 @@ const CONTRACT_SNAPSHOT = {
5125
5130
  "max": { "type": "number" },
5126
5131
  "value": { "type": "number" },
5127
5132
  "wholeNumbers": { "type": "boolean" },
5133
+ "pageController": { "type": "string" },
5128
5134
  "src": { "type": "string" },
5129
5135
  "packageId": { "type": "string" },
5130
5136
  "group": { "type": "string" },
@@ -5203,6 +5209,7 @@ const CONTRACT_SNAPSHOT = {
5203
5209
  "const": "scrollBar"
5204
5210
  },
5205
5211
  "fixedGripSize": { "type": "boolean" },
5212
+ "pageController": { "type": "string" },
5206
5213
  "src": { "type": "string" },
5207
5214
  "packageId": { "type": "string" },
5208
5215
  "group": { "type": "string" },
@@ -12127,6 +12134,7 @@ const CONTRACT_SNAPSHOT = {
12127
12134
  },
12128
12135
  "resource": { "$ref": "#/$defs/UamResourceRef_3486136f6c_read" },
12129
12136
  "controllerOverrides": { "type": "string" },
12137
+ "pageController": { "type": "string" },
12130
12138
  "fileName": { "type": "string" },
12131
12139
  "instanceProperties": { "$ref": "#/$defs/Shape_8a3021d271_read" },
12132
12140
  "propertyOverrides": { "$ref": "#/$defs/Array_7c27bc0bce_read" },
@@ -13159,6 +13167,7 @@ const CONTRACT_SNAPSHOT = {
13159
13167
  "titleFontSize": { "type": "number" },
13160
13168
  "sound": { "type": "string" },
13161
13169
  "soundVolumeScale": { "type": "number" },
13170
+ "pageController": { "type": "string" },
13162
13171
  "src": { "type": "string" },
13163
13172
  "packageId": { "type": "string" },
13164
13173
  "group": { "type": "string" },
@@ -13248,6 +13257,7 @@ const CONTRACT_SNAPSHOT = {
13248
13257
  "titleFontSize": { "type": "number" },
13249
13258
  "sound": { "type": "string" },
13250
13259
  "soundVolumeScale": { "type": "number" },
13260
+ "pageController": { "type": "string" },
13251
13261
  "src": { "type": "string" },
13252
13262
  "packageId": { "type": "string" },
13253
13263
  "group": { "type": "string" },
@@ -13338,6 +13348,7 @@ const CONTRACT_SNAPSHOT = {
13338
13348
  "titleFontSize": { "type": "number" },
13339
13349
  "sound": { "type": "string" },
13340
13350
  "soundVolumeScale": { "type": "number" },
13351
+ "pageController": { "type": "string" },
13341
13352
  "src": { "type": "string" },
13342
13353
  "packageId": { "type": "string" },
13343
13354
  "group": { "type": "string" },
@@ -13429,6 +13440,7 @@ const CONTRACT_SNAPSHOT = {
13429
13440
  "reverse": { "type": "boolean" },
13430
13441
  "sound": { "type": "string" },
13431
13442
  "soundVolumeScale": { "type": "number" },
13443
+ "pageController": { "type": "string" },
13432
13444
  "src": { "type": "string" },
13433
13445
  "packageId": { "type": "string" },
13434
13446
  "group": { "type": "string" },
@@ -13513,6 +13525,7 @@ const CONTRACT_SNAPSHOT = {
13513
13525
  "max": { "type": "number" },
13514
13526
  "value": { "type": "number" },
13515
13527
  "wholeNumbers": { "type": "boolean" },
13528
+ "pageController": { "type": "string" },
13516
13529
  "src": { "type": "string" },
13517
13530
  "packageId": { "type": "string" },
13518
13531
  "group": { "type": "string" },
@@ -13591,6 +13604,7 @@ const CONTRACT_SNAPSHOT = {
13591
13604
  "const": "scrollBar"
13592
13605
  },
13593
13606
  "fixedGripSize": { "type": "boolean" },
13607
+ "pageController": { "type": "string" },
13594
13608
  "src": { "type": "string" },
13595
13609
  "packageId": { "type": "string" },
13596
13610
  "group": { "type": "string" },
@@ -16096,16 +16110,16 @@ const CONTRACT_SNAPSHOT = {
16096
16110
  }
16097
16111
  }
16098
16112
  ],
16099
- "digest": "d3ec1cc02994d7af79610540dec9369f9fe8d03de795c754cd1d12ec8b214581"
16113
+ "digest": "5718c7534651570432e9dda5a5cda367cbc292e71e59f5f6ad2e1c55321dee5a"
16100
16114
  };
16101
16115
  //#endregion
16102
16116
  //#region src/generated/docs.ts
16103
16117
  const INSTALLED_DOCS = {
16104
16118
  "version": {
16105
16119
  "packageName": "@openfairygui/backend",
16106
- "packageVersion": "0.6.2",
16120
+ "packageVersion": "0.6.3",
16107
16121
  "nodeEngine": ">=22",
16108
- "documentationDigest": "677cd573d086a5568387d4de69585a5d8ba5575a40648b19f845f79ac5cfa4c3"
16122
+ "documentationDigest": "08afcb7b44b538e1592058f3e20e94c276b86573858962f1b6591cd34ac74b39"
16109
16123
  },
16110
16124
  "workflow": "# Installed OpenFairyGUI workflow\n\nThis is a minimal offline companion, not the full website. Read `ofgui docs ls --json` for the installed package version, contract version, capability schema version and digest. Use the project's installed `ofgui`/`ofgui-mcp`, not a global executable or an online latest-version lookup. A mismatched installation must be reconciled by the host before editing.\n\n## Discover the current contract\n\n- `ofgui docs find \"selector\" --json` searches this installed corpus.\n- `ofgui docs cat contracts --json` lists Core operations and Backend/MCP mappings.\n- `ofgui docs schema setDisplayNodeProps --json` reads one self-contained operation schema.\n- `ofgui docs schema cli/validate --json` reads the installed CLI output schema; `cli/docs cat` is a valid exact document ID for the nested command.\n- `ofgui docs cat methods/queryEntity --json` reads precise input/output wire schemas.\n- `ofgui docs diagnostic stale_write --json` reads recovery guidance.\n- MCP `resources/read` at `openfairygui://docs/index` provides the same index and content URIs. MCP is local stdio, not an assumed HTTP port.\n\nThe generated schemas describe JSON wire structure and input budgets, not semantic validity. Native SDK byte fields remain Uint8Array; MCP transports declared byte fields as integer arrays. Arbitrary extension data is not converted. Host objects/functions are omitted from MCP wire schemas; use SDK declarations for host injection, not guessed JSON fields.\n\nMCP allows up to 8 MiB of aggregate byte input at generated byte paths, without applying the general 10000-element array or per-byte node limits. Arbitrary metadata retains general limits. All value-bearing Gear defaults may be null, preserving the owner's initial state when no default override exists; component-instance controllerOverrides retains controller selections.\n\nAll CLI JSON uses `{schemaVersion:1,command,success:true,result}` or `{schemaVersion:1,command,success:false,error:{code,message},result?}`. Documentation version/index/body fields are inside `result`; read `result.text` for document content. Invalid/incomplete validate and doctor responses retain their full report under `result`. Help/version are text; other JSON-mode stdout contains exactly one document and human logs use stderr. Exit codes: 0 success, 1 workflow failure, 2 arguments, 3 incomplete validation. CLI owns envelopes, not new workflow semantics.\n\n## Edit safely\n\n1. Read capabilities. Existing projects use openSession (with host authorization and a lifetime lock); openProjectSession accepts a host-supplied authoritative UAM, not a shortcut around lossy file-session guards.\n2. Read getProjectOutline to discover exact identities, then queryEntity for the relevant current properties and actual revision. Capabilities list the supported read.entityQuery.kinds: project, package, resource, component, displayNode, controller and transition. Project queries use target {kind:\"project\"} without a selector; package queries use {kind:\"package\",selector:{packageId}}. Both return identity and complete entity.properties.settings. Controllers use packageId + componentResourceId + controllerName; transitions use packageId + componentResourceId + transitionName. Names are exact and component-scoped; duplicates fail as ambiguous. Controller snapshots include pages/actions; transition snapshots include items. Gears are already included in displayNode snapshots. Fixed projections exclude source bytes; budget failures require host inspection.\n3. Read the operation and method schemas. Plan the smallest authorized batch using current identifiers and expectedRevision.\n4. preflightTransaction executes on an isolated snapshot and discards it. Inspect projectedRevision, impact.entities (exact identities and changed fields, including reference normalization), impact.files (ProjectWriter model diff, not a disk write plan) and persistence.nextAction. The diff starts at the current revision, not the last save. It contains no source bytes. Summary overflow or serialization failure returns transaction_preview_failed without a partial result. No revision is reserved; writeVerified is always false. It does not save files or guarantee later apply/save/publish.\n5. Only when authorized, applyTransaction with the planned batch and expectedRevision. On stale_write, refresh and replan; never blindly substitute a newer revision.\n6. validateSession checks the new authoritative state. A successful response can contain an invalid or incomplete validation report; require status valid and complete true before treating validation as passed.\n7. When authorized, saveSession checks revision independently and writes the original project only. Keep path policy, UAM fidelity and rollback guards. Close the session only after handling unsaved changes. Read saved output again when disk round-trip is part of acceptance.\n\nPreview permits invalid references in the existing snapshot so a repair can be reviewed, but serializes that snapshot only into memory. The projected state and all persistence remain validated; unsupported or unrepresentable snapshots still fail explicitly.\n\nupdateProjectSettings and updatePackageSettings replace complete settings snapshots. Copy the corresponding query's entity.properties.settings, change only requested fields, retain other nested settings and optional fields, and submit the complete settings with the queried revision. Package updates also require the original packageId selector. Settings queries share the same response budgets as other entity kinds.\n\nupdateController and updateTransition replace complete snapshots, not partial patches. Copy the queried entity.properties, change only the requested fields, preserve page IDs/remarks/actions, item order/targets, settings and references, and submit the original selector with the queried revision. A stale_write requires refreshing and replanning the full snapshot for all these replacement operations. Querying does not validate references or grant permission to edit them.\n\n## Consume the committed session state\n\nFor complete public UAM consumption, use readSessionState({sessionId, expectedRevision?}); use queryEntity for targeted properties. The detached model excludes only asset resources' primary sourceBytes, retaining sourcePath and JSON extensions. It includes revision, dirty, lastSavedRevision, readComplete, readDiagnostics and uamFidelity. Only this read-model output schema accepts unnamed object fields; transaction input contracts remain unchanged.\n\nRead each asset with readResourceBytes({sessionId, expectedRevision: state.revision, selector:{packageId,resourceId}}). Bytes are detached Uint8Array values in the SDK and integer arrays in MCP, limited to the primary file already held in memory. There is no disk hydration or auxiliary-file discovery. Components are unsupported; unavailable bytes produce session_read_failed with reason bytes_unavailable.\n\nOn stale_read, discard the incomplete model/bytes collection and restart from readSessionState. Reads do not wait for uncommitted transactions, retain historical versions, or reserve revisions. Saving can update sourcePath and dirty without increasing the edit revision; the same revision does not identify permanently identical complete UAM. Completeness/fidelity flags preserve existing meaning and do not guarantee bytes, rendering or saving. Preserve failed reads as failures; never save or repair merely to obtain a read.\n\nCapabilities advertise a 4 MiB compact JSON data limit (depth 64, 500000 nodes) for the model and 1 MiB per primary resource. Both new MCP tools additionally limit the complete JSON CallToolResult, including compact text and structuredContent, to 16 MiB; excess returns mcp_response_budget_exceeded. Native model/buffer overflow returns session_read_failed with reason response_budget_exceeded, without truncation. Read the installed methods/readSessionState and methods/readResourceBytes schemas for precise inputs, results and errors.\n\n## Diagnose without repair\n\n`ofgui doctor --json` checks installed CLI/documentation versions, the Node Backend capability snapshot, in-memory Sharp PNG/JPEG encoding and pixel decoding, and temporary-directory access flags. `ofgui doctor <project-directory-or-fairy-file> --json` additionally runs existing Node project validation, including source reads and available image decoding. Optional `--output-dir <directory>` checks an explicit destination or its nearest existing ancestor, without creating it. Directory checks return the absolute requested `path`, link-resolved `inspectedPath` and `exists` (null when unknown); files, dangling links and access errors fail. The temporary directory must exist. It opens no Backend session, creates no lock, installs nothing, writes no probe files and changes no configuration.\n\nExit 0 means the requested checks completed; exit 1 means a detected error; exit 2 means invalid arguments; exit 3 means native image capability is unavailable/failed or project validation is incomplete. Inspect result.checks, result.errors and result.project. Without a project, its source bytes are not checked. Access flags do not prove effective ACL permissions, available space, later writes/rename/rollback or continued access. The capability manifest remains a declaration; a successful doctor does not prove publish/restore or runtime rendering. Plugins and configured output destinations are not executed or checked automatically; only explicit --output-dir is inspected. This product doctor does not inspect Git, pnpm, repository builds or fixture submodules; maintainers use pnpm repo:doctor for those.\n\nRead diagnostic guides for ownership and recovery boundaries. Every formal Core/Backend diagnostic code is covered; shared codes list all `owners`, while response `owner` identifies the actual source. Missing bytes/decoders, rejected paths and expired sessions require host action; do not invent repair/hydration tools, widen roots, discard unsaved work, or turn incomplete validation into success. Invalid/unsupported operations require schema-based replanning, live locks cannot be removed, and write failures require preserving dirty state and inspecting actual files.\n\n## Publish and recover trusted local artifacts\n\nPublishing and restoration are external Node-hosted workflows, not Backend session methods or general MCP editing tools. The host must authorize input and output directories independently. They require the native image capability; do not rename binary extensions to imitate a different target profile.\n\n- `ofgui publish <project> --output <release-directory> --project-type layabox --json` publishes the current saved project. `--output` overrides runtime artifact destinations; configured code generation still uses its own destinations and project plugins run as trusted local code.\n- The JSON document is `{schemaVersion:1,command:\"publish\",success:true,result:{files:[{path,size}]}}`. Paths are final absolute paths and sizes are bytes. The Node SDK `publishNode()` returns the same `result`. The manifest records actual successful filesystem/atlas writes, including code written through the supplied publish filesystem; it excludes pre-existing untouched files, deletions and arbitrary plugin I/O outside that filesystem. It is not an inventory of everything in the output directory. Explicit runtime output is staged and rolled back on failure; separately configured code outputs and arbitrary plugin effects are not covered by that directory transaction.\n- `ofgui restore <trusted-release-directory> --output <separate-project-directory> --project-type layabox --json` returns `{schemaVersion:1,command:\"restore\",success:true,result:{projectPath,packages:[{id,name}],warnings:[]}}`. Warnings are not a validation pass. Reread the returned projectPath and run `ofgui validate <projectPath> --json`; require valid and complete validation.\n- Both artifact commands exit 0 on workflow success, 1 on workflow failure, and 2 on command syntax errors. Errors are `{schemaVersion:1,command,success:false,error:{code,message}}`, with `publish_failed`, `restore_failed` or `invalid_arguments`. In JSON mode stdout contains only this document; human/plugin output goes to stderr. Help remains human-readable. Errors do not include a claimed successful file manifest.\n- Restore requires a separate directory, not a `.fairy` file. Do not force overwrite by default. `--force` replaces an existing nonempty target only after complete staged recovery; parse/image failures retain the previous target. Only trusted local artifacts are supported, not arbitrary third-party imports.\n- Read `ofgui docs cat restore-limits --json` or MCP resource `openfairygui://docs/restore-limits` for the installed version's full recovery boundary. Accept readable, structurally valid supported semantics and decoded assets, not original project IDs, workspace state, unpublished resources, original filenames/extensions, controller editor selection/export flags, float32 text precision or byte-identical XML.\n",
16111
16125
  "restoreLimits": "# 受限发布产物恢复边界\n\n`restore` 只是一条受限的本地故障恢复路径,不是 FairyGUI 的常规创作入口、第三方发布物导入器或源码还原承诺。本文档记录其安全使用范围,以及当前仓库已经验证过、无法仅凭发布产物稳定恢复的内容。\n\n## 使用范围与安全边界\n\n| 项目 | 当前口径 |\n|---|---|\n| 输入 | 仅处理可信的本地发布目录;不把未知来源 `.fui` / `_fui.bytes` 视为安全输入 |\n| 输出 | 必须是独立工程目录,不接受 `.fairy` 单文件目标 |\n| 路径约束 | 拒绝资源路径、包名、分支名、文件名中的路径逃逸;发布目录内资源若解析到输入目录外也会失败 |\n| 覆盖行为 | 先在相邻暂存目录完成工程和资源写入,再替换目标;`--force` 不会在二进制解析或资源重建前删除旧输出 |\n| 不代表 | 不是恶意文件检测器,也不保证第三方产物能够安全或完整恢复 |\n\n这里的“不可还原”指:\n\n| 项目 | 含义 |\n|---|---|\n| 输入范围 | 仅使用发布目录中的 `.fui` / `_fui.bytes`、图集 PNG、以及同目录 loose 资源 |\n| 判定标准 | 不能稳定、通用、无外部辅助地恢复回原工程语义或原始 XML 文本 |\n| 不包含 | 仍可通过补协议、补 writer 规则、补测试继续收敛的普通实现问题 |\n\n## 总结\n\n| 结论 | 说明 |\n|---|---|\n| 受限恢复目标 | 在可信输入下生成一个可重读、可打开、结构自洽的 FairyGUI 工程 |\n| 不保证目标 | 还原成与原工程逐字节一致的源码工程 |\n| 主要原因 | 发布产物会丢失一部分编辑器阶段信息,或把原始值降精度到运行时格式 |\n\n## 当前已确认的不可还原项\n\n恢复时推导出的图片尺寸用于资源重建,但不作为原始声明尺寸写入 `package.xml`;生成的字体纹理和字形图片按顺序跟随对应字体。`RestoreResult.document` 保留尺寸省略与资源排序两种写入提示,交给新的 `ProjectWriter` 或 `NodeIO.writeProject()` 仍生效。提示属于内存中的序列化控制,不随 UAM 转换或重新读取传播。`ProjectWriter.setImageWriteHints(image, {})` 清除该图片的全部提示,恢复普通尺寸写回和资源排序;需要保留排序时,设置 `{ packageOrder: { afterId, weight } }`,其中目标是同包、同分支且未设置排序提示的资源。\n\n### 1. 发布包中根本不存在的资源或动作\n\n发布物中缺失独立资源项的字形图像使用稳定 glyph 图像 ID 的 UTF-8 十六进制生成 `images/glyph-<id>.png`,不同字体的不同图像 ID 不会因字符相同而重名。已有资源项保留发布物中的名称和路径;生成名称不代表原始源文件名,不依据示例包名或字体名称猜测。\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 组件资源 | 原工程存在、但发布包未携带的组件 XML | 发布产物没有资源定义,restore 无法凭空生成真实内容 | `HitTest/component1.xml`、`PullToRefresh/Button1.xml`、`PullToRefresh/Button2.xml`、`TurnPage/Button3.xml` |\n| Transition item | 原工程存在、但二进制 transition block 未携带的 item | 二进制里没有对应时间轴项,无法可靠反推 | `Transition/BOSS.xml` 中 `target=\"n3\"` 的 6 个 item |\n\n说明:这类内容如果强行补出,只能生成占位内容,不能声称是“还原原工程”。\n\n### 2. 原始资源文件名与扩展名\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 普通图片资源 | 原工程使用的真实文件扩展名与双后缀命名 | 发布包只保留运行时资源名,不稳定保留工程文件名 | `change.jpg -> change.png`、`Paper.jpg -> Paper.png`、`i3.png.png -> i3.png` |\n| 部分 loose 资源 | 若发布名与工程名完全脱钩,且缺少稳定映射线索 | 发布目录只提供发布后文件名,原工程命名信息已经丢失 | 仍可能出现少量发布名残留 |\n\n说明:当前实现已经尽量把“资源 id 命名”还原回工程名,但对原始扩展名并不能做通用、可靠的反推。\n\n### 3. Transition path 的原始文本精度\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 路径字符串 | 编辑器 XML 中 path 的原始小数位数与文本格式 | 发布二进制只保存 float32 数值;写回时只能输出数值等价的字符串 | `Transition/PathDemo.xml` 的 `path` |\n\n说明:这类路径通常还能恢复到相同几何轨迹,但不能保证与原 XML 的字符串完全一致。\n\n### 4. 被降级为运行时默认值的编辑器信息\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| Transition easing | 原工程中的特定 ease 名称 | 当前样本对应二进制读出的就是默认 easing,无法证明原工程曾写过哪个非默认 ease | `Transition/BOSS.xml`、`TRAP.xml`、`GoodHit.xml` 中部分 `Expo.Out` / `Back.Out` / `Bounce.Out` |\n| 简单 Group 节点 | 仅用于编辑器分组、但没有额外运行时语义的 `GGroup` 节点 | 当前样本中的发布组件数据会直接裁掉这类 group,二进制 child list 里既没有 group 节点,也没有可稳定回推的 group 归属索引 | `Basics/Demo_Clip&Scroll.xml`、`Emoji/Main.xml`、`TurnPage/Book.xml` |\n| Group 高级模式 | 原工程 XML 中的 `group.advanced=\"true\"` | 发布 group block写出的是布局与间距等运行时数据,不单独保留编辑器里的高级模式开关;当前样本中二进制读回的 group 会直接落成 `advanced=false` | `Basics/Demo_Grid.xml`、`Transition/Main.xml`、`Transition/PowerUp.xml` |\n| Controller 当前选中页 | 原工程 XML 中的 `controller.selected` 当前页状态 | 发布 controller block稳定保存的是 `homePageType/homePage` 发布首页信息;当前样本中的二进制常写成 `default`,并不保留编辑器工程里当时的非零当前页 | `TurnPage/Main.xml` 的 `bookPos=\"2\"`、`TurnPage/Page.xml` 的 `style=\"1\"` / `side=\"1\"`、`FrontCover.xml` / `BackCover.xml` 的 `side=\"1\"` |\n| Controller 导出标记 | 原工程 XML 中的 `controller.exported=\"true\"` | 当前样本对应的 controller 发布 block只写 `name/pages/homePageType/homePage/actions`,没有独立写出 `exported` | `TurnPage/BackCover.xml`、`TurnPage/FrontCover.xml`、`TurnPage/Page.xml` |\n| 默认值显式性 | 原工程是否显式写出默认属性 | 发布包只保留语义值,不保留“这个默认值当时是否显式写在 XML 里” | 如 `xy=\"0,0\"`、空文本、默认布尔值等 |\n\n说明:这类信息恢复后通常仍然语义可用,但无法保证与原工程的编辑器写法逐项一致。\n\n### 5. 编辑器工程本地设置\n\n| 类别 | 不可还原内容 | 原因 |\n|---|---|---|\n| 工程标识 | 原始 `projectId` | restore 会生成新的工程标识 |\n| 工程设置 | 原始 `.objs` / workspace / 编辑器本地状态 | 发布目录不包含这些本地工程文件 |\n| 初始化设置之外的项目配置 | 原工程的非发布产物配置 | 当前 restore 按初始化默认值生成工程设置,而不是恢复源工程工作区状态 |\n\n说明:当前 restore 的目标是“重建可用工程”,不是恢复编辑器本地工作环境。\n\n### 6. 原工程 XML 的文本级细节\n\n| 类别 | 不可还原内容 | 原因 |\n|---|---|---|\n| 属性顺序 | 原标签属性排列顺序 | XML 语义不依赖属性顺序,发布产物也不保留该信息 |\n| 格式风格 | 换行、缩进、是否自闭合、空格风格 | 这是 writer 生成结果,不是发布产物协议内容 |\n| 大小写风格 | 某些颜色值、小数文本风格 | 发布包保留的是数值语义,不是原文本样式 |\n\n说明:当前实现会尽量贴近 FairyGUI 编辑器写法,但不会把这类文本风格视为“可从发布产物逆推出的正式数据”。\n\n## 当前恢复输出范围\n\n| 项目 | 当前口径 |\n|---|---|\n| 工程目标 | 在可信输入下生成可读、可打开、可继续编辑的 FairyGUI 工程 |\n| 资源目标 | 尽量恢复包内素材、组件 XML、字体派生图与 `.jta` / `.fnt` 等正式资源 |\n| 不承诺 | 与原工程一模一样的文件名、文本格式、局部编辑器状态 |\n\n## 何时需要外部辅助信息\n\n若目标不是“重建可用工程”,而是“尽量贴近原工程文本或命名”,则需要额外输入:\n\n| 额外输入 | 作用 |\n|---|---|\n| 原工程目录 | 作为命名、路径、缺失资源、文本样式的真实基准 |\n| 编辑器工作区文件 | 恢复 `.objs`、workspace、本地工程状态 |\n| 发布前清单或映射表 | 回填发布名与工程名之间的脱钩关系 |\n\n## 当前样本下仍然成立的判断\n\n| 判断 | 说明 |\n|---|---|\n| 可以从发布产物重建“可工作的工程” | 是 |\n| 可以从发布产物重建“原工程的源码真迹” | 否 |\n| 还原结果是否应该继续优化 | 可以,但应只优化“发布产物里确实有证据的部分” |\n",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfairygui/backend",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "FairyGUI Headless Authoring SDK — stateful backend runtime and session services.",
5
5
  "author": "OpenFairyGUI Contributors",
6
6
  "license": "MIT",
@@ -66,8 +66,8 @@
66
66
  "runtime"
67
67
  ],
68
68
  "dependencies": {
69
- "@openfairygui/core": "0.6.2",
70
- "@openfairygui/functions": "0.6.2"
69
+ "@openfairygui/core": "0.6.3",
70
+ "@openfairygui/functions": "0.6.3"
71
71
  },
72
72
  "devDependencies": {
73
73
  "ava": "^7.0.0",
@@ -5068,6 +5068,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
5068
5068
  "controllerOverrides": {
5069
5069
  "type": "string"
5070
5070
  },
5071
+ "pageController": {
5072
+ "type": "string"
5073
+ },
5071
5074
  "fileName": {
5072
5075
  "type": "string"
5073
5076
  },
@@ -6884,6 +6887,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
6884
6887
  "soundVolumeScale": {
6885
6888
  "type": "number"
6886
6889
  },
6890
+ "pageController": {
6891
+ "type": "string"
6892
+ },
6887
6893
  "src": {
6888
6894
  "type": "string"
6889
6895
  },
@@ -7039,6 +7045,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
7039
7045
  "soundVolumeScale": {
7040
7046
  "type": "number"
7041
7047
  },
7048
+ "pageController": {
7049
+ "type": "string"
7050
+ },
7042
7051
  "src": {
7043
7052
  "type": "string"
7044
7053
  },
@@ -7207,6 +7216,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
7207
7216
  "soundVolumeScale": {
7208
7217
  "type": "number"
7209
7218
  },
7219
+ "pageController": {
7220
+ "type": "string"
7221
+ },
7210
7222
  "src": {
7211
7223
  "type": "string"
7212
7224
  },
@@ -7366,6 +7378,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
7366
7378
  "soundVolumeScale": {
7367
7379
  "type": "number"
7368
7380
  },
7381
+ "pageController": {
7382
+ "type": "string"
7383
+ },
7369
7384
  "src": {
7370
7385
  "type": "string"
7371
7386
  },
@@ -7514,6 +7529,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
7514
7529
  "wholeNumbers": {
7515
7530
  "type": "boolean"
7516
7531
  },
7532
+ "pageController": {
7533
+ "type": "string"
7534
+ },
7517
7535
  "src": {
7518
7536
  "type": "string"
7519
7537
  },
@@ -7648,6 +7666,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
7648
7666
  "fixedGripSize": {
7649
7667
  "type": "boolean"
7650
7668
  },
7669
+ "pageController": {
7670
+ "type": "string"
7671
+ },
7651
7672
  "src": {
7652
7673
  "type": "string"
7653
7674
  },
@@ -17895,6 +17916,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
17895
17916
  "controllerOverrides": {
17896
17917
  "type": "string"
17897
17918
  },
17919
+ "pageController": {
17920
+ "type": "string"
17921
+ },
17898
17922
  "fileName": {
17899
17923
  "type": "string"
17900
17924
  },
@@ -19744,6 +19768,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
19744
19768
  "soundVolumeScale": {
19745
19769
  "type": "number"
19746
19770
  },
19771
+ "pageController": {
19772
+ "type": "string"
19773
+ },
19747
19774
  "src": {
19748
19775
  "type": "string"
19749
19776
  },
@@ -19899,6 +19926,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
19899
19926
  "soundVolumeScale": {
19900
19927
  "type": "number"
19901
19928
  },
19929
+ "pageController": {
19930
+ "type": "string"
19931
+ },
19902
19932
  "src": {
19903
19933
  "type": "string"
19904
19934
  },
@@ -20067,6 +20097,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
20067
20097
  "soundVolumeScale": {
20068
20098
  "type": "number"
20069
20099
  },
20100
+ "pageController": {
20101
+ "type": "string"
20102
+ },
20070
20103
  "src": {
20071
20104
  "type": "string"
20072
20105
  },
@@ -20226,6 +20259,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
20226
20259
  "soundVolumeScale": {
20227
20260
  "type": "number"
20228
20261
  },
20262
+ "pageController": {
20263
+ "type": "string"
20264
+ },
20229
20265
  "src": {
20230
20266
  "type": "string"
20231
20267
  },
@@ -20374,6 +20410,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
20374
20410
  "wholeNumbers": {
20375
20411
  "type": "boolean"
20376
20412
  },
20413
+ "pageController": {
20414
+ "type": "string"
20415
+ },
20377
20416
  "src": {
20378
20417
  "type": "string"
20379
20418
  },
@@ -20508,6 +20547,9 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
20508
20547
  "fixedGripSize": {
20509
20548
  "type": "boolean"
20510
20549
  },
20550
+ "pageController": {
20551
+ "type": "string"
20552
+ },
20511
20553
  "src": {
20512
20554
  "type": "string"
20513
20555
  },
@@ -24161,5 +24203,5 @@ export const CONTRACT_SNAPSHOT: ContractSnapshot = {
24161
24203
  }
24162
24204
  }
24163
24205
  ],
24164
- "digest": "d3ec1cc02994d7af79610540dec9369f9fe8d03de795c754cd1d12ec8b214581"
24206
+ "digest": "5718c7534651570432e9dda5a5cda367cbc292e71e59f5f6ad2e1c55321dee5a"
24165
24207
  };
@@ -2,9 +2,9 @@
2
2
  export const INSTALLED_DOCS = {
3
3
  "version": {
4
4
  "packageName": "@openfairygui/backend",
5
- "packageVersion": "0.6.2",
5
+ "packageVersion": "0.6.3",
6
6
  "nodeEngine": ">=22",
7
- "documentationDigest": "677cd573d086a5568387d4de69585a5d8ba5575a40648b19f845f79ac5cfa4c3"
7
+ "documentationDigest": "08afcb7b44b538e1592058f3e20e94c276b86573858962f1b6591cd34ac74b39"
8
8
  },
9
9
  "workflow": "# Installed OpenFairyGUI workflow\n\nThis is a minimal offline companion, not the full website. Read `ofgui docs ls --json` for the installed package version, contract version, capability schema version and digest. Use the project's installed `ofgui`/`ofgui-mcp`, not a global executable or an online latest-version lookup. A mismatched installation must be reconciled by the host before editing.\n\n## Discover the current contract\n\n- `ofgui docs find \"selector\" --json` searches this installed corpus.\n- `ofgui docs cat contracts --json` lists Core operations and Backend/MCP mappings.\n- `ofgui docs schema setDisplayNodeProps --json` reads one self-contained operation schema.\n- `ofgui docs schema cli/validate --json` reads the installed CLI output schema; `cli/docs cat` is a valid exact document ID for the nested command.\n- `ofgui docs cat methods/queryEntity --json` reads precise input/output wire schemas.\n- `ofgui docs diagnostic stale_write --json` reads recovery guidance.\n- MCP `resources/read` at `openfairygui://docs/index` provides the same index and content URIs. MCP is local stdio, not an assumed HTTP port.\n\nThe generated schemas describe JSON wire structure and input budgets, not semantic validity. Native SDK byte fields remain Uint8Array; MCP transports declared byte fields as integer arrays. Arbitrary extension data is not converted. Host objects/functions are omitted from MCP wire schemas; use SDK declarations for host injection, not guessed JSON fields.\n\nMCP allows up to 8 MiB of aggregate byte input at generated byte paths, without applying the general 10000-element array or per-byte node limits. Arbitrary metadata retains general limits. All value-bearing Gear defaults may be null, preserving the owner's initial state when no default override exists; component-instance controllerOverrides retains controller selections.\n\nAll CLI JSON uses `{schemaVersion:1,command,success:true,result}` or `{schemaVersion:1,command,success:false,error:{code,message},result?}`. Documentation version/index/body fields are inside `result`; read `result.text` for document content. Invalid/incomplete validate and doctor responses retain their full report under `result`. Help/version are text; other JSON-mode stdout contains exactly one document and human logs use stderr. Exit codes: 0 success, 1 workflow failure, 2 arguments, 3 incomplete validation. CLI owns envelopes, not new workflow semantics.\n\n## Edit safely\n\n1. Read capabilities. Existing projects use openSession (with host authorization and a lifetime lock); openProjectSession accepts a host-supplied authoritative UAM, not a shortcut around lossy file-session guards.\n2. Read getProjectOutline to discover exact identities, then queryEntity for the relevant current properties and actual revision. Capabilities list the supported read.entityQuery.kinds: project, package, resource, component, displayNode, controller and transition. Project queries use target {kind:\"project\"} without a selector; package queries use {kind:\"package\",selector:{packageId}}. Both return identity and complete entity.properties.settings. Controllers use packageId + componentResourceId + controllerName; transitions use packageId + componentResourceId + transitionName. Names are exact and component-scoped; duplicates fail as ambiguous. Controller snapshots include pages/actions; transition snapshots include items. Gears are already included in displayNode snapshots. Fixed projections exclude source bytes; budget failures require host inspection.\n3. Read the operation and method schemas. Plan the smallest authorized batch using current identifiers and expectedRevision.\n4. preflightTransaction executes on an isolated snapshot and discards it. Inspect projectedRevision, impact.entities (exact identities and changed fields, including reference normalization), impact.files (ProjectWriter model diff, not a disk write plan) and persistence.nextAction. The diff starts at the current revision, not the last save. It contains no source bytes. Summary overflow or serialization failure returns transaction_preview_failed without a partial result. No revision is reserved; writeVerified is always false. It does not save files or guarantee later apply/save/publish.\n5. Only when authorized, applyTransaction with the planned batch and expectedRevision. On stale_write, refresh and replan; never blindly substitute a newer revision.\n6. validateSession checks the new authoritative state. A successful response can contain an invalid or incomplete validation report; require status valid and complete true before treating validation as passed.\n7. When authorized, saveSession checks revision independently and writes the original project only. Keep path policy, UAM fidelity and rollback guards. Close the session only after handling unsaved changes. Read saved output again when disk round-trip is part of acceptance.\n\nPreview permits invalid references in the existing snapshot so a repair can be reviewed, but serializes that snapshot only into memory. The projected state and all persistence remain validated; unsupported or unrepresentable snapshots still fail explicitly.\n\nupdateProjectSettings and updatePackageSettings replace complete settings snapshots. Copy the corresponding query's entity.properties.settings, change only requested fields, retain other nested settings and optional fields, and submit the complete settings with the queried revision. Package updates also require the original packageId selector. Settings queries share the same response budgets as other entity kinds.\n\nupdateController and updateTransition replace complete snapshots, not partial patches. Copy the queried entity.properties, change only the requested fields, preserve page IDs/remarks/actions, item order/targets, settings and references, and submit the original selector with the queried revision. A stale_write requires refreshing and replanning the full snapshot for all these replacement operations. Querying does not validate references or grant permission to edit them.\n\n## Consume the committed session state\n\nFor complete public UAM consumption, use readSessionState({sessionId, expectedRevision?}); use queryEntity for targeted properties. The detached model excludes only asset resources' primary sourceBytes, retaining sourcePath and JSON extensions. It includes revision, dirty, lastSavedRevision, readComplete, readDiagnostics and uamFidelity. Only this read-model output schema accepts unnamed object fields; transaction input contracts remain unchanged.\n\nRead each asset with readResourceBytes({sessionId, expectedRevision: state.revision, selector:{packageId,resourceId}}). Bytes are detached Uint8Array values in the SDK and integer arrays in MCP, limited to the primary file already held in memory. There is no disk hydration or auxiliary-file discovery. Components are unsupported; unavailable bytes produce session_read_failed with reason bytes_unavailable.\n\nOn stale_read, discard the incomplete model/bytes collection and restart from readSessionState. Reads do not wait for uncommitted transactions, retain historical versions, or reserve revisions. Saving can update sourcePath and dirty without increasing the edit revision; the same revision does not identify permanently identical complete UAM. Completeness/fidelity flags preserve existing meaning and do not guarantee bytes, rendering or saving. Preserve failed reads as failures; never save or repair merely to obtain a read.\n\nCapabilities advertise a 4 MiB compact JSON data limit (depth 64, 500000 nodes) for the model and 1 MiB per primary resource. Both new MCP tools additionally limit the complete JSON CallToolResult, including compact text and structuredContent, to 16 MiB; excess returns mcp_response_budget_exceeded. Native model/buffer overflow returns session_read_failed with reason response_budget_exceeded, without truncation. Read the installed methods/readSessionState and methods/readResourceBytes schemas for precise inputs, results and errors.\n\n## Diagnose without repair\n\n`ofgui doctor --json` checks installed CLI/documentation versions, the Node Backend capability snapshot, in-memory Sharp PNG/JPEG encoding and pixel decoding, and temporary-directory access flags. `ofgui doctor <project-directory-or-fairy-file> --json` additionally runs existing Node project validation, including source reads and available image decoding. Optional `--output-dir <directory>` checks an explicit destination or its nearest existing ancestor, without creating it. Directory checks return the absolute requested `path`, link-resolved `inspectedPath` and `exists` (null when unknown); files, dangling links and access errors fail. The temporary directory must exist. It opens no Backend session, creates no lock, installs nothing, writes no probe files and changes no configuration.\n\nExit 0 means the requested checks completed; exit 1 means a detected error; exit 2 means invalid arguments; exit 3 means native image capability is unavailable/failed or project validation is incomplete. Inspect result.checks, result.errors and result.project. Without a project, its source bytes are not checked. Access flags do not prove effective ACL permissions, available space, later writes/rename/rollback or continued access. The capability manifest remains a declaration; a successful doctor does not prove publish/restore or runtime rendering. Plugins and configured output destinations are not executed or checked automatically; only explicit --output-dir is inspected. This product doctor does not inspect Git, pnpm, repository builds or fixture submodules; maintainers use pnpm repo:doctor for those.\n\nRead diagnostic guides for ownership and recovery boundaries. Every formal Core/Backend diagnostic code is covered; shared codes list all `owners`, while response `owner` identifies the actual source. Missing bytes/decoders, rejected paths and expired sessions require host action; do not invent repair/hydration tools, widen roots, discard unsaved work, or turn incomplete validation into success. Invalid/unsupported operations require schema-based replanning, live locks cannot be removed, and write failures require preserving dirty state and inspecting actual files.\n\n## Publish and recover trusted local artifacts\n\nPublishing and restoration are external Node-hosted workflows, not Backend session methods or general MCP editing tools. The host must authorize input and output directories independently. They require the native image capability; do not rename binary extensions to imitate a different target profile.\n\n- `ofgui publish <project> --output <release-directory> --project-type layabox --json` publishes the current saved project. `--output` overrides runtime artifact destinations; configured code generation still uses its own destinations and project plugins run as trusted local code.\n- The JSON document is `{schemaVersion:1,command:\"publish\",success:true,result:{files:[{path,size}]}}`. Paths are final absolute paths and sizes are bytes. The Node SDK `publishNode()` returns the same `result`. The manifest records actual successful filesystem/atlas writes, including code written through the supplied publish filesystem; it excludes pre-existing untouched files, deletions and arbitrary plugin I/O outside that filesystem. It is not an inventory of everything in the output directory. Explicit runtime output is staged and rolled back on failure; separately configured code outputs and arbitrary plugin effects are not covered by that directory transaction.\n- `ofgui restore <trusted-release-directory> --output <separate-project-directory> --project-type layabox --json` returns `{schemaVersion:1,command:\"restore\",success:true,result:{projectPath,packages:[{id,name}],warnings:[]}}`. Warnings are not a validation pass. Reread the returned projectPath and run `ofgui validate <projectPath> --json`; require valid and complete validation.\n- Both artifact commands exit 0 on workflow success, 1 on workflow failure, and 2 on command syntax errors. Errors are `{schemaVersion:1,command,success:false,error:{code,message}}`, with `publish_failed`, `restore_failed` or `invalid_arguments`. In JSON mode stdout contains only this document; human/plugin output goes to stderr. Help remains human-readable. Errors do not include a claimed successful file manifest.\n- Restore requires a separate directory, not a `.fairy` file. Do not force overwrite by default. `--force` replaces an existing nonempty target only after complete staged recovery; parse/image failures retain the previous target. Only trusted local artifacts are supported, not arbitrary third-party imports.\n- Read `ofgui docs cat restore-limits --json` or MCP resource `openfairygui://docs/restore-limits` for the installed version's full recovery boundary. Accept readable, structurally valid supported semantics and decoded assets, not original project IDs, workspace state, unpublished resources, original filenames/extensions, controller editor selection/export flags, float32 text precision or byte-identical XML.\n",
10
10
  "restoreLimits": "# 受限发布产物恢复边界\n\n`restore` 只是一条受限的本地故障恢复路径,不是 FairyGUI 的常规创作入口、第三方发布物导入器或源码还原承诺。本文档记录其安全使用范围,以及当前仓库已经验证过、无法仅凭发布产物稳定恢复的内容。\n\n## 使用范围与安全边界\n\n| 项目 | 当前口径 |\n|---|---|\n| 输入 | 仅处理可信的本地发布目录;不把未知来源 `.fui` / `_fui.bytes` 视为安全输入 |\n| 输出 | 必须是独立工程目录,不接受 `.fairy` 单文件目标 |\n| 路径约束 | 拒绝资源路径、包名、分支名、文件名中的路径逃逸;发布目录内资源若解析到输入目录外也会失败 |\n| 覆盖行为 | 先在相邻暂存目录完成工程和资源写入,再替换目标;`--force` 不会在二进制解析或资源重建前删除旧输出 |\n| 不代表 | 不是恶意文件检测器,也不保证第三方产物能够安全或完整恢复 |\n\n这里的“不可还原”指:\n\n| 项目 | 含义 |\n|---|---|\n| 输入范围 | 仅使用发布目录中的 `.fui` / `_fui.bytes`、图集 PNG、以及同目录 loose 资源 |\n| 判定标准 | 不能稳定、通用、无外部辅助地恢复回原工程语义或原始 XML 文本 |\n| 不包含 | 仍可通过补协议、补 writer 规则、补测试继续收敛的普通实现问题 |\n\n## 总结\n\n| 结论 | 说明 |\n|---|---|\n| 受限恢复目标 | 在可信输入下生成一个可重读、可打开、结构自洽的 FairyGUI 工程 |\n| 不保证目标 | 还原成与原工程逐字节一致的源码工程 |\n| 主要原因 | 发布产物会丢失一部分编辑器阶段信息,或把原始值降精度到运行时格式 |\n\n## 当前已确认的不可还原项\n\n恢复时推导出的图片尺寸用于资源重建,但不作为原始声明尺寸写入 `package.xml`;生成的字体纹理和字形图片按顺序跟随对应字体。`RestoreResult.document` 保留尺寸省略与资源排序两种写入提示,交给新的 `ProjectWriter` 或 `NodeIO.writeProject()` 仍生效。提示属于内存中的序列化控制,不随 UAM 转换或重新读取传播。`ProjectWriter.setImageWriteHints(image, {})` 清除该图片的全部提示,恢复普通尺寸写回和资源排序;需要保留排序时,设置 `{ packageOrder: { afterId, weight } }`,其中目标是同包、同分支且未设置排序提示的资源。\n\n### 1. 发布包中根本不存在的资源或动作\n\n发布物中缺失独立资源项的字形图像使用稳定 glyph 图像 ID 的 UTF-8 十六进制生成 `images/glyph-<id>.png`,不同字体的不同图像 ID 不会因字符相同而重名。已有资源项保留发布物中的名称和路径;生成名称不代表原始源文件名,不依据示例包名或字体名称猜测。\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 组件资源 | 原工程存在、但发布包未携带的组件 XML | 发布产物没有资源定义,restore 无法凭空生成真实内容 | `HitTest/component1.xml`、`PullToRefresh/Button1.xml`、`PullToRefresh/Button2.xml`、`TurnPage/Button3.xml` |\n| Transition item | 原工程存在、但二进制 transition block 未携带的 item | 二进制里没有对应时间轴项,无法可靠反推 | `Transition/BOSS.xml` 中 `target=\"n3\"` 的 6 个 item |\n\n说明:这类内容如果强行补出,只能生成占位内容,不能声称是“还原原工程”。\n\n### 2. 原始资源文件名与扩展名\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 普通图片资源 | 原工程使用的真实文件扩展名与双后缀命名 | 发布包只保留运行时资源名,不稳定保留工程文件名 | `change.jpg -> change.png`、`Paper.jpg -> Paper.png`、`i3.png.png -> i3.png` |\n| 部分 loose 资源 | 若发布名与工程名完全脱钩,且缺少稳定映射线索 | 发布目录只提供发布后文件名,原工程命名信息已经丢失 | 仍可能出现少量发布名残留 |\n\n说明:当前实现已经尽量把“资源 id 命名”还原回工程名,但对原始扩展名并不能做通用、可靠的反推。\n\n### 3. Transition path 的原始文本精度\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| 路径字符串 | 编辑器 XML 中 path 的原始小数位数与文本格式 | 发布二进制只保存 float32 数值;写回时只能输出数值等价的字符串 | `Transition/PathDemo.xml` 的 `path` |\n\n说明:这类路径通常还能恢复到相同几何轨迹,但不能保证与原 XML 的字符串完全一致。\n\n### 4. 被降级为运行时默认值的编辑器信息\n\n| 类别 | 不可还原内容 | 原因 | 当前样本证据 |\n|---|---|---|---|\n| Transition easing | 原工程中的特定 ease 名称 | 当前样本对应二进制读出的就是默认 easing,无法证明原工程曾写过哪个非默认 ease | `Transition/BOSS.xml`、`TRAP.xml`、`GoodHit.xml` 中部分 `Expo.Out` / `Back.Out` / `Bounce.Out` |\n| 简单 Group 节点 | 仅用于编辑器分组、但没有额外运行时语义的 `GGroup` 节点 | 当前样本中的发布组件数据会直接裁掉这类 group,二进制 child list 里既没有 group 节点,也没有可稳定回推的 group 归属索引 | `Basics/Demo_Clip&Scroll.xml`、`Emoji/Main.xml`、`TurnPage/Book.xml` |\n| Group 高级模式 | 原工程 XML 中的 `group.advanced=\"true\"` | 发布 group block写出的是布局与间距等运行时数据,不单独保留编辑器里的高级模式开关;当前样本中二进制读回的 group 会直接落成 `advanced=false` | `Basics/Demo_Grid.xml`、`Transition/Main.xml`、`Transition/PowerUp.xml` |\n| Controller 当前选中页 | 原工程 XML 中的 `controller.selected` 当前页状态 | 发布 controller block稳定保存的是 `homePageType/homePage` 发布首页信息;当前样本中的二进制常写成 `default`,并不保留编辑器工程里当时的非零当前页 | `TurnPage/Main.xml` 的 `bookPos=\"2\"`、`TurnPage/Page.xml` 的 `style=\"1\"` / `side=\"1\"`、`FrontCover.xml` / `BackCover.xml` 的 `side=\"1\"` |\n| Controller 导出标记 | 原工程 XML 中的 `controller.exported=\"true\"` | 当前样本对应的 controller 发布 block只写 `name/pages/homePageType/homePage/actions`,没有独立写出 `exported` | `TurnPage/BackCover.xml`、`TurnPage/FrontCover.xml`、`TurnPage/Page.xml` |\n| 默认值显式性 | 原工程是否显式写出默认属性 | 发布包只保留语义值,不保留“这个默认值当时是否显式写在 XML 里” | 如 `xy=\"0,0\"`、空文本、默认布尔值等 |\n\n说明:这类信息恢复后通常仍然语义可用,但无法保证与原工程的编辑器写法逐项一致。\n\n### 5. 编辑器工程本地设置\n\n| 类别 | 不可还原内容 | 原因 |\n|---|---|---|\n| 工程标识 | 原始 `projectId` | restore 会生成新的工程标识 |\n| 工程设置 | 原始 `.objs` / workspace / 编辑器本地状态 | 发布目录不包含这些本地工程文件 |\n| 初始化设置之外的项目配置 | 原工程的非发布产物配置 | 当前 restore 按初始化默认值生成工程设置,而不是恢复源工程工作区状态 |\n\n说明:当前 restore 的目标是“重建可用工程”,不是恢复编辑器本地工作环境。\n\n### 6. 原工程 XML 的文本级细节\n\n| 类别 | 不可还原内容 | 原因 |\n|---|---|---|\n| 属性顺序 | 原标签属性排列顺序 | XML 语义不依赖属性顺序,发布产物也不保留该信息 |\n| 格式风格 | 换行、缩进、是否自闭合、空格风格 | 这是 writer 生成结果,不是发布产物协议内容 |\n| 大小写风格 | 某些颜色值、小数文本风格 | 发布包保留的是数值语义,不是原文本样式 |\n\n说明:当前实现会尽量贴近 FairyGUI 编辑器写法,但不会把这类文本风格视为“可从发布产物逆推出的正式数据”。\n\n## 当前恢复输出范围\n\n| 项目 | 当前口径 |\n|---|---|\n| 工程目标 | 在可信输入下生成可读、可打开、可继续编辑的 FairyGUI 工程 |\n| 资源目标 | 尽量恢复包内素材、组件 XML、字体派生图与 `.jta` / `.fnt` 等正式资源 |\n| 不承诺 | 与原工程一模一样的文件名、文本格式、局部编辑器状态 |\n\n## 何时需要外部辅助信息\n\n若目标不是“重建可用工程”,而是“尽量贴近原工程文本或命名”,则需要额外输入:\n\n| 额外输入 | 作用 |\n|---|---|\n| 原工程目录 | 作为命名、路径、缺失资源、文本样式的真实基准 |\n| 编辑器工作区文件 | 恢复 `.objs`、workspace、本地工程状态 |\n| 发布前清单或映射表 | 回填发布名与工程名之间的脱钩关系 |\n\n## 当前样本下仍然成立的判断\n\n| 判断 | 说明 |\n|---|---|\n| 可以从发布产物重建“可工作的工程” | 是 |\n| 可以从发布产物重建“原工程的源码真迹” | 否 |\n| 还原结果是否应该继续优化 | 可以,但应只优化“发布产物里确实有证据的部分” |\n",