@hy-bricks/canvas 0.4.2 → 0.5.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @hy-bricks/canvas
2
2
 
3
+ ## [0.5.0] - 2026-06-03 · free-split 自由分割布局
4
+
5
+ 新增第 6 种容器布局 `free-split`(递归分割树)+ 渲染/编辑 gate 解耦。@hy-bricks 4 包同步升 0.5.0。
6
+
7
+ ### ✨ 新特性 — free-split
8
+
9
+ - `containerLayout.mode = 'free-split'`:容器内一棵递归分割树(`SplitBranch` row/col + `SplitLeaf`),每格一个组件。
10
+ - 设计器可视化编辑(`:free-split-enabled="true"` 开):切分(`⬌` 左右 / `⬍` 上下)、拖分隔条 resize、合并(双击 / hover 合并按钮)、删除分区(`✕`)、移动/交换(`⠿` 拖)、拖组件填格。
11
+ - handle 出口:`handle.freeSplit.{fill,clear,swap,resize,split,merge}` + `handle.getFreeSplitDropTarget(point)` + leaf/divider 并行选区。
12
+ - 不可伪造 undo、每操作一次 undo、结构锁(`structureLocked` / `leaf.locked`)。
13
+
14
+ ### ⚠️ BREAKING
15
+
16
+ - **`HyperCardPageRenderer` 移除 `freeSplitEnabled` prop** —— 渲染改为 **data-driven**:页面文档里有合法 free-split 就自动按树渲染(任意宿主**零 opt-in**;非法树 fallback 平铺)。若之前给 **Renderer** 传过该 prop,删掉即可,渲染照常。`HyperCardCanvasDesigner` 的 `freeSplitEnabled` prop **保留**(它控编辑)。
17
+
18
+ ### 升级
19
+
20
+ - **不用 free-split 的页面/宿主**:零行为变化(非 free-split 页渲染完全不变)。
21
+ - **要用 free-split**:① 设计器传 `:free-split-enabled="true"` ② 宿主**后端放行** `mode='free-split'` 校验(id 唯一 / NodeSize ratio>0·min≤max / 深度≤8;参考 `reference-backend`)③ drop 走 `handle.freeSplit.fill`。详见文档「指南 → 自由分割布局(free-split)」。
22
+
23
+ ### 依赖
24
+
25
+ - `@hy-bricks/core@0.5.0`(fixed 组同步)。
26
+
27
+ ## 0.4.3
28
+
29
+ ### Patch Changes
30
+
31
+ - @hy-bricks/core@0.4.3
32
+
3
33
  ## [0.4.2] - 2026-05-28 · devtools 强化(配套升级)
4
34
 
5
35
  跟 `@hy-bricks/devtools` 0.4.2 同步。canvas 本次给 runtime renderer 加诊断 handle 自动注册,
@@ -20,7 +50,7 @@
20
50
  - `registerRendererDiagnostics` / `unregisterRendererDiagnostics` /
21
51
  `getRendererDiagnostics` / `subscribeRendererDiagnostics`
22
52
  - `RendererDiagnosticsHandle` 接口:`getSchedulerStats / listRuntimeInstances /
23
- getInstanceTimings / getLayoutIssues`
53
+ getInstanceTimings / getLayoutIssues`
24
54
 
25
55
  详见 [根 CHANGELOG.md](../../CHANGELOG.md) §0.4.2。
26
56
 
@@ -49,29 +79,29 @@ pnpm up @hy-bricks/canvas@0.4.2
49
79
 
50
80
  每个组件实例可读 3 个 SDK 注入 prop:
51
81
 
52
- | Prop | 含义 |
53
- |---|---|
54
- | `this.hcInstanceId` | 实例 ID |
55
- | `this.hcCanvasId` | 所属画布 ID |
56
- | `this.hcComponentId` | 组件源 ID |
82
+ | Prop | 含义 |
83
+ | -------------------- | ----------- |
84
+ | `this.hcInstanceId` | 实例 ID |
85
+ | `this.hcCanvasId` | 所属画布 ID |
86
+ | `this.hcComponentId` | 组件源 ID |
57
87
 
58
88
  ```js
59
89
  // 组件源码 component.js
60
90
  export default {
61
91
  mounted() {
62
- console.log('我是谁', this.hcInstanceId, this.hcCanvasId)
92
+ console.log("我是谁", this.hcInstanceId, this.hcCanvasId);
63
93
 
64
94
  // ✅ 立即订阅,不再要等
65
- __HYPERCARD__.runtime.on(this.hcInstanceId, 'click', (payload) => {
95
+ __HYPERCARD__.runtime.on(this.hcInstanceId, "click", (payload) => {
66
96
  // ...
67
- })
97
+ });
68
98
 
69
99
  // ✅ 立即拿到 handle
70
100
  const handle = __HYPERCARD__.canvases
71
101
  .get(this.hcCanvasId)
72
- ?.getInstance(this.hcInstanceId)
102
+ ?.getInstance(this.hcInstanceId);
73
103
  },
74
- }
104
+ };
75
105
  ```
76
106
 
77
107
  ### ⚠ BREAKING — host 升级前 audit
@@ -101,6 +131,7 @@ grep -rn "instance:ready\|onInstanceLifecycle\|getInstanceReady" src/
101
131
  ```
102
132
 
103
133
  每处看回调内是否访问 `vm.$el` / DOM。
134
+
104
135
  - 没访问 → `npm install @hy-bricks/{core,canvas,editor,devtools}@^0.4.0` 透明升
105
136
  - 访问了 → 改 `nextTick`
106
137