ice-entity-designer 0.0.17 → 0.0.18
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/README.md +9 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/react.cjs +2 -2
- package/dist/react.mjs +2 -2
- package/dist/types/designer/EntityDesigner.d.mts +49 -1
- package/dist/types/designer/EntityDesigner.d.ts +49 -1
- package/dist/types/ice-render/graphic/ICEComponent.d.mts +50 -0
- package/dist/types/ice-render/graphic/ICEComponent.d.ts +50 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/react/types.d.mts +15 -2
- package/dist/types/react/types.d.ts +15 -2
- package/dist/types/utils/project_schema.d.mts +16 -1
- package/dist/types/utils/project_schema.d.ts +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,10 +122,17 @@ const issues = designer.validate(); // 校验问题列表
|
|
|
122
122
|
|
|
123
123
|
// 项目存取与历史
|
|
124
124
|
const snapshot = designer.serializeProject();
|
|
125
|
-
designer.loadProject(snapshot);
|
|
125
|
+
const report = designer.loadProject(snapshot); // 非法 / 版本不兼容的快照会抛错,且不会改动当前项目与历史栈
|
|
126
|
+
// report = { loaded, entities, relations, unknownTypes, skipped }
|
|
126
127
|
designer.undo();
|
|
127
128
|
```
|
|
128
129
|
|
|
130
|
+
#### 5.1 项目快照契约
|
|
131
|
+
|
|
132
|
+
- 快照带 `schemaVersion`(当前 `1`)与每个节点的 `typeId`;载入时**按 `typeId` 分派构造函数**(走 ICE 注册表,下游 `ice.registerType()` 注册的领域图元同样可载入)。旧快照没有 `typeId` 时,按所在数组归位(`entities[]` → `Entity`,`relations[]` → `Relation`)。
|
|
133
|
+
- **容错加载**:遇到未注册的 `typeId` 只跳过该节点并记录(`report.unknownTypes` / `report.skipped`),不会让整份数据打不开——与引擎 `Deserializer` 的语义一致。
|
|
134
|
+
- **自洽保证**:`serializeProject()` 的产物永远能通过 `loadProject()` 的结构校验(结构契约见 `src/utils/project-snapshot.schema.json`);载入失败时当前项目与 `undo`/`redo` 栈都不会被改动。
|
|
135
|
+
|
|
129
136
|
也支持更底层的组件式用法:
|
|
130
137
|
|
|
131
138
|
```js
|
|
@@ -194,6 +201,7 @@ export default function App() {
|
|
|
194
201
|
| `value` | `string` | **受控**:项目快照,变化时同步进画布(内部变更经 `onChange` 上报,带循环保护) |
|
|
195
202
|
| `defaultValue` | `string` | **非受控**:初始项目快照 |
|
|
196
203
|
| `onChange` | `(payload: { snapshot, schema }) => void` | 模型变更(增删改 / 载入 / undo / redo)后触发,`snapshot` 可直接用于自动保存 |
|
|
204
|
+
| `onError` | `(payload: { phase, snapshot, error }) => void` | 快照载入失败(非法 / 版本不兼容)时触发,默认 `console.error`;组件内部已捕获,不会把异常抛进渲染树 |
|
|
197
205
|
| `onReady` | `(handle) => void` | 实例就绪,回调里拿到命令式句柄 |
|
|
198
206
|
| `width` / `height` | `number` | 画布尺寸,默认 `1200 × 800` |
|
|
199
207
|
| `renderMode` | `'dirty-rect' \| 'full'` | 渲染模式,默认 `dirty-rect` |
|