@fulate/vue 2.0.11 → 3.0.2
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 +27 -50
- package/dist/vue-shape.d.ts +1 -1
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# `@fulate/vue`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
frame runtime;每个挂载的应用只拥有自己的 content/overlay Layer 和 Vue 生命周期。
|
|
3
|
+
提供 Fulate 的 Vue 渲染器,以及在图元中嵌入 Vue 组件的 `VueShape`。
|
|
5
4
|
|
|
6
5
|
## 创建与挂载
|
|
7
6
|
|
|
@@ -9,31 +8,28 @@ frame runtime;每个挂载的应用只拥有自己的 content/overlay Layer
|
|
|
9
8
|
import { createApp } from "@fulate/vue";
|
|
10
9
|
|
|
11
10
|
const app = createApp(App);
|
|
12
|
-
app.mount(container);
|
|
13
|
-
// 或:app.mount(root); // 使用已有 Root,Root 仍由调用方拥有
|
|
14
|
-
|
|
11
|
+
app.mount(container); // 也可传入选择器或已有 Root
|
|
15
12
|
app.unmount();
|
|
16
13
|
```
|
|
17
14
|
|
|
18
|
-
传入
|
|
19
|
-
|
|
20
|
-
重新挂载。初次 `onMounted()` 中卸载 app 或 Root,也会结束该次 Vue scope。
|
|
15
|
+
传入 DOM 容器或选择器时,app 自动创建 Root,并在卸载时释放。传入已有 Root 时,app 只释放自己
|
|
16
|
+
创建的 Layer,调用方仍需释放 Root。一个 Root 只能承载一个 Fulate Vue app;卸载后的 app 不能重新挂载。
|
|
21
17
|
|
|
22
|
-
使用
|
|
23
|
-
|
|
18
|
+
使用 Flex 标签时导入 `@fulate/vue/yoga`;`@fulate/components` 已完成该注册。
|
|
19
|
+
`f-vector-path` 创建 UI `EditorVectorPath`,接受 Core 路径命令或 `VectorPathGeometry`;
|
|
20
|
+
`f-polygon` 接受顶点数组或路径几何。
|
|
24
21
|
|
|
25
22
|
## 场景事件
|
|
26
23
|
|
|
27
|
-
Canvas 标签支持 `@click
|
|
28
|
-
|
|
29
|
-
传播、停止及回调变更规则见 [Core 事件指南](../core/docs/guides/events-and-animation.md)。
|
|
24
|
+
Canvas 标签支持 `@click` / `onClick` 和捕获监听 `@click.capture` / `onClickCapture`。
|
|
25
|
+
传播与停止规则见 [Core 事件指南](../core/docs/guides/events-and-animation.md)。
|
|
30
26
|
|
|
31
27
|
## VueShape 与自定义元素
|
|
32
28
|
|
|
33
|
-
`VueShape`
|
|
29
|
+
`VueShape` 进入活动 Root 时挂载组件,离开时卸载。它支持两种 props 模式。
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
手动模式通过 `setComponentProps()` 整体替换 props;同一引用不触发更新。需要保存或复制组件时,
|
|
32
|
+
先注册名称:
|
|
37
33
|
|
|
38
34
|
```ts
|
|
39
35
|
import { VueShape, registerVueComponent } from "@fulate/vue";
|
|
@@ -43,9 +39,7 @@ const badge = new VueShape({ width: 120, height: 32 }, { label: "Ready" })
|
|
|
43
39
|
.bindComponent(Badge);
|
|
44
40
|
```
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
时注册一次 properties resolver。resolver 读取包含 configured/runtime 的最终 effective Properties,
|
|
48
|
-
每次返回完整 props;Fulate 通过同一 `setComponentProps()` 路径整体替换:
|
|
42
|
+
映射模式通过自定义 Properties 生成完整 props,配置和运行态属性变化都会重新映射:
|
|
49
43
|
|
|
50
44
|
```ts
|
|
51
45
|
class KeyValueShape extends VueShape<KeyValueProperties, KeyValueOption> {
|
|
@@ -61,12 +55,9 @@ class KeyValueShape extends VueShape<KeyValueProperties, KeyValueOption> {
|
|
|
61
55
|
}
|
|
62
56
|
```
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
JSON、Clipboard 或 History;mapped 业务类型由其具体 type factory 恢复。manual 模式仍保存组件名称和
|
|
66
|
-
手动 component props,`fromVueToFulate()` 与基础 `vueShapeV2Codec` 的行为不变。
|
|
58
|
+
两种模式互斥。映射结果不保存到文件或 History;自定义类型需提供自己的 codec。
|
|
67
59
|
|
|
68
|
-
每个 `VueShape`
|
|
69
|
-
派生类型可作为泛型参数保留具体类型:
|
|
60
|
+
每个 `VueShape` 拥有独立 Vue app。组件在 `setup()` 中可取得宿主:
|
|
70
61
|
|
|
71
62
|
```ts
|
|
72
63
|
import { useFulateHost } from "@fulate/vue";
|
|
@@ -74,41 +65,27 @@ import { useFulateHost } from "@fulate/vue";
|
|
|
74
65
|
const shape = useFulateHost<KeyValueShape>();
|
|
75
66
|
```
|
|
76
67
|
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
外层 Vue app 的 `provide()` 不会自动传入这些独立 app。组件尺寸通过 `useVueShapeSize()` 读取,
|
|
69
|
+
过渡动画使用 `FTransition`。
|
|
79
70
|
|
|
80
|
-
自定义 Canvas 元素通过 `registerElement("f-widget", Widget)`
|
|
81
|
-
`<f-widget />`。未知元素会在 renderer 创建时自然抛错,不另设兼容路径。
|
|
71
|
+
自定义 Canvas 元素通过 `registerElement("f-widget", Widget)` 注册后,可在模板中使用 `<f-widget />`。
|
|
82
72
|
|
|
83
73
|
## Root 与 overlay
|
|
84
74
|
|
|
85
|
-
`createApp()`
|
|
86
|
-
|
|
87
|
-
返回的 cleanup 必须在场景销毁时调用。
|
|
75
|
+
`createApp()` 创建内容层和浮层,通过 `FULATE_ROOT_KEY`、`FULATE_OVERLAY_KEY` 注入给组件。
|
|
76
|
+
手工管理场景时,为 `VueShape` 注册浮层,并在销毁时清理:
|
|
88
77
|
|
|
89
78
|
```ts
|
|
79
|
+
import { registerVueOverlay } from "@fulate/vue";
|
|
80
|
+
|
|
90
81
|
const unregister = registerVueOverlay(root, overlayLayer);
|
|
91
|
-
//
|
|
82
|
+
// 挂载并使用 VueShape。
|
|
92
83
|
unregister();
|
|
93
84
|
```
|
|
94
85
|
|
|
95
|
-
|
|
96
|
-
`animate()` 与 Root frame 路径完成。`registerVueOverlay()` 和组件 overlay 定位的 cleanup 绑定
|
|
97
|
-
所属 Root 生命周期;`useOverlayPosition()` 的异步结果只在 task、引用和挂载状态仍有效时安装。
|
|
98
|
-
|
|
99
|
-
## Clipboard
|
|
100
|
-
|
|
101
|
-
`vueShapeV2Codec` 是供文件与剪贴板共用的 v2 codec:
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
const codecs = new Map([...elementV2Codecs, ["vue-component", vueShapeV2Codec]]);
|
|
105
|
-
const select = new Select({ codecs });
|
|
106
|
-
```
|
|
86
|
+
## 文件与剪贴板
|
|
107
87
|
|
|
108
|
-
|
|
109
|
-
注册。mapped 自定义类型不保存组件名称或派生 props,由业务 type codec 恢复。该 adapter 不注册
|
|
110
|
-
全局 Select 行为,也不读取旧格式。
|
|
88
|
+
将 `vueShapeV2Codec` 加入文件与剪贴板共用的 codec map,完整组合见[Tools IO 指南](../tools/README.md#原生场景与文件-io)。
|
|
111
89
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
live path 始终为 canonical 值。
|
|
90
|
+
手动模式保存组件名称、props 和元素数据,恢复前必须注册组件。映射模式的自定义类型由业务 codec 恢复,
|
|
91
|
+
不保存派生 props。
|
package/dist/vue-shape.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ElementV2Codec } from "@fulate/core";
|
|
2
2
|
import { type ElementPayload, type ElementTransformClass, type Layer, type PropertyChanges, type Root } from "@fulate/core";
|
|
3
3
|
import { Rectangle, RectangleProperties, type RectangleOption } from "@fulate/ui";
|
|
4
4
|
import { type Component } from "vue";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fulate/vue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,14 +23,13 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@fulate/core": "
|
|
27
|
-
"@fulate/ui": "
|
|
28
|
-
"lodash-es": "^4.17.22"
|
|
29
|
-
"@fulate/import": "2.0.11"
|
|
26
|
+
"@fulate/core": "3.0.2",
|
|
27
|
+
"@fulate/ui": "3.0.2",
|
|
28
|
+
"lodash-es": "^4.17.22"
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
32
31
|
"vue": "^3.5.0",
|
|
33
|
-
"@fulate/yoga": "
|
|
32
|
+
"@fulate/yoga": "^3.0.2"
|
|
34
33
|
},
|
|
35
34
|
"peerDependenciesMeta": {
|
|
36
35
|
"@fulate/yoga": {
|