@fulate/vue 1.0.19 → 2.0.11
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 +15 -4
- package/dist/chunks/{renderer-DidU2yIP.js → renderer-D5hdLgxq.js} +7 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/renderer.d.ts +1 -1
- package/dist/vue-shape.d.ts +6 -7
- package/dist/yoga.js +1 -1
- package/package.json +40 -39
package/README.md
CHANGED
|
@@ -22,6 +22,12 @@ app.unmount();
|
|
|
22
22
|
使用 Yoga 标签时导入 `@fulate/vue/yoga`;`@fulate/components` 已完成该注册。Vue 主入口可单独使用,
|
|
23
23
|
Yoga 是适配入口的可选 peer dependency。
|
|
24
24
|
|
|
25
|
+
## 场景事件
|
|
26
|
+
|
|
27
|
+
Canvas 标签支持 `@click.capture` 与 JSX 的 `onClickCapture`,普通监听使用 `@click` / `onClick`。
|
|
28
|
+
捕获和普通 handler 独立更新、移除;合并的 handler 数组逐项注册。事件名和阶段由 Core 解析,
|
|
29
|
+
传播、停止及回调变更规则见 [Core 事件指南](../core/docs/guides/events-and-animation.md)。
|
|
30
|
+
|
|
25
31
|
## VueShape 与自定义元素
|
|
26
32
|
|
|
27
33
|
`VueShape` 在元素进入活动 Root 时挂载 Vue component,离开时卸载。它支持两种互斥的 props 模式。
|
|
@@ -57,7 +63,7 @@ class KeyValueShape extends VueShape<KeyValueProperties, KeyValueOption> {
|
|
|
57
63
|
|
|
58
64
|
初始绑定、configured/runtime 更新与清除、属性快照恢复都经过该映射。mapped props 是派生缓存,不写入
|
|
59
65
|
JSON、Clipboard 或 History;mapped 业务类型由其具体 type factory 恢复。manual 模式仍保存组件名称和
|
|
60
|
-
手动 component props,`fromVueToFulate()` 与基础 `
|
|
66
|
+
手动 component props,`fromVueToFulate()` 与基础 `vueShapeV2Codec` 的行为不变。
|
|
61
67
|
|
|
62
68
|
每个 `VueShape` 都拥有独立 Vue app。组件可在 `setup()` 中直接通过 `useFulateHost()` 取得当前宿主;
|
|
63
69
|
派生类型可作为泛型参数保留具体类型:
|
|
@@ -92,12 +98,17 @@ unregister();
|
|
|
92
98
|
|
|
93
99
|
## Clipboard
|
|
94
100
|
|
|
95
|
-
`
|
|
101
|
+
`vueShapeV2Codec` 是供文件与剪贴板共用的 v2 codec:
|
|
96
102
|
|
|
97
103
|
```ts
|
|
98
|
-
const
|
|
104
|
+
const codecs = new Map([...elementV2Codecs, ["vue-component", vueShapeV2Codec]]);
|
|
105
|
+
const select = new Select({ codecs });
|
|
99
106
|
```
|
|
100
107
|
|
|
101
108
|
基础 manual `VueShape` 的复制 payload 保存组件名称、props 和必要元素数据,组件必须在恢复前完成
|
|
102
|
-
注册。mapped 自定义类型不保存组件名称或派生 props,由业务 type
|
|
109
|
+
注册。mapped 自定义类型不保存组件名称或派生 props,由业务 type codec 恢复。该 adapter 不注册
|
|
103
110
|
全局 Select 行为,也不读取旧格式。
|
|
111
|
+
|
|
112
|
+
`f-vector-path` 创建 UI `EditorVectorPath`,path 接受 Core `VectorPathCommand[]` 或 canonical `VectorPathGeometry`;
|
|
113
|
+
`f-polygon` 的 path 接受 points 或 canonical geometry。初始 props 进入构造,后续替换沿同一 setOptions 更新,
|
|
114
|
+
live path 始终为 canonical 值。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Element, Shape, parseEventOptionKey } from "@fulate/core";
|
|
2
|
+
import { Circle, EditorVectorPath, Group, Image, Line, LineTree, Polygon, Rectangle, RippleOverlay, ScrollView, Text, Triangle, Workspace } from "@fulate/ui";
|
|
3
3
|
import { isFunction } from "lodash-es";
|
|
4
|
-
import {
|
|
4
|
+
import { createRenderer, markRaw } from "vue";
|
|
5
5
|
//#region packages/vue/src/renderer.ts
|
|
6
6
|
var elementConstructors = new Map([
|
|
7
7
|
["f-element", Element],
|
|
@@ -10,6 +10,7 @@ var elementConstructors = new Map([
|
|
|
10
10
|
["f-circle", Circle],
|
|
11
11
|
["f-triangle", Triangle],
|
|
12
12
|
["f-polygon", Polygon],
|
|
13
|
+
["f-vector-path", EditorVectorPath],
|
|
13
14
|
["f-text", Text],
|
|
14
15
|
["f-image", Image],
|
|
15
16
|
["f-workspace", Workspace],
|
|
@@ -29,9 +30,6 @@ function getRegisteredElement(type) {
|
|
|
29
30
|
function isEventProp(key) {
|
|
30
31
|
return /^on[A-Z]/.test(key);
|
|
31
32
|
}
|
|
32
|
-
function toEventName(key) {
|
|
33
|
-
return key.slice(2).toLowerCase();
|
|
34
|
-
}
|
|
35
33
|
function forEachEventHandler(value, callback) {
|
|
36
34
|
if (Array.isArray(value)) value.forEach((item) => forEachEventHandler(item, callback));
|
|
37
35
|
else if (isFunction(value)) callback(value);
|
|
@@ -73,9 +71,9 @@ var renderer = createRenderer({
|
|
|
73
71
|
patchProp(el, key, prevValue, nextValue) {
|
|
74
72
|
if (placeholders.has(el)) return;
|
|
75
73
|
if (isEventProp(key)) {
|
|
76
|
-
const eventName =
|
|
77
|
-
forEachEventHandler(prevValue, (handler) => el.removeEventListener(eventName, handler));
|
|
78
|
-
forEachEventHandler(nextValue, (handler) => el.addEventListener(eventName, handler));
|
|
74
|
+
const { eventName, capture } = parseEventOptionKey(key);
|
|
75
|
+
forEachEventHandler(prevValue, (handler) => el.removeEventListener(eventName, handler, { capture }));
|
|
76
|
+
forEachEventHandler(nextValue, (handler) => el.addEventListener(eventName, handler, { capture }));
|
|
79
77
|
return;
|
|
80
78
|
}
|
|
81
79
|
if (!initialElements.has(el)) el.setOptions({ [key]: nextValue });
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { createApp } from "./app";
|
|
|
4
4
|
export type { FulateApp, FulateAppMountOptions } from "./app";
|
|
5
5
|
export { FULATE_HOST_KEY, FULATE_OVERLAY_KEY, FULATE_ROOT_KEY, VUE_SHAPE_SIZE_KEY, registerVueOverlay, useFulateHost } from "./context";
|
|
6
6
|
export { FTransition } from "./transition";
|
|
7
|
-
export { VueShape, fromVueToFulate, registerVueComponent,
|
|
7
|
+
export { VueShape, fromVueToFulate, registerVueComponent, vueShapeV2Codec } from "./vue-shape";
|
|
8
8
|
export type { VueComponentPropsResolver, VueShapeJSON } from "./vue-shape";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as getRegisteredElement, r as registerElement, t as baseCreateApp } from "./chunks/renderer-
|
|
2
|
-
import { BaseTransition, defineComponent, getCurrentInstance, h, inject, markRaw, mergeProps, onBeforeUnmount, reactive, shallowRef } from "vue";
|
|
1
|
+
import { n as getRegisteredElement, r as registerElement, t as baseCreateApp } from "./chunks/renderer-D5hdLgxq.js";
|
|
3
2
|
import { Layer, Root } from "@fulate/core";
|
|
4
|
-
import { cloneDeep, has, isString, isUndefined } from "lodash-es";
|
|
5
3
|
import { Rectangle, RectangleProperties, RectangleTransform } from "@fulate/ui";
|
|
4
|
+
import { cloneDeep, has, isString, isUndefined } from "lodash-es";
|
|
5
|
+
import { BaseTransition, defineComponent, getCurrentInstance, h, inject, markRaw, mergeProps, onBeforeUnmount, reactive, shallowRef } from "vue";
|
|
6
6
|
//#region packages/vue/src/context.ts
|
|
7
7
|
var FULATE_ROOT_KEY = "__fulate_root";
|
|
8
8
|
var FULATE_OVERLAY_KEY = "__fulate_overlay";
|
|
@@ -397,9 +397,11 @@ var VueShape = class extends Rectangle {
|
|
|
397
397
|
if (this.componentPropsResolver) this.setComponentProps(this.componentPropsResolver(properties));
|
|
398
398
|
}
|
|
399
399
|
/** manual 模式保存 component metadata;mapped 模式只保存 Properties。 */
|
|
400
|
+
getPersistentChildren() {
|
|
401
|
+
return [];
|
|
402
|
+
}
|
|
400
403
|
toJSON() {
|
|
401
404
|
const json = super.toJSON();
|
|
402
|
-
delete json.children;
|
|
403
405
|
if (this.componentPropsResolver) return json;
|
|
404
406
|
return {
|
|
405
407
|
...json,
|
|
@@ -408,13 +410,11 @@ var VueShape = class extends Rectangle {
|
|
|
408
410
|
};
|
|
409
411
|
}
|
|
410
412
|
};
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const { type: _type,
|
|
415
|
-
|
|
416
|
-
if (!comp) return;
|
|
417
|
-
return fromVueToFulate(comp, shapeProps, componentProps);
|
|
413
|
+
var vueShapeV2Codec = {
|
|
414
|
+
encode: (element) => element.toJSON(),
|
|
415
|
+
decode(data) {
|
|
416
|
+
const { type: _type, component, componentProps, ...shapeProps } = data;
|
|
417
|
+
return fromVueToFulate(vueCompRegistry.get(component), shapeProps, componentProps);
|
|
418
418
|
}
|
|
419
419
|
};
|
|
420
420
|
/** 从彼此独立的 Rectangle options 和 Vue component props 创建 VueShape。 */
|
|
@@ -422,4 +422,4 @@ function fromVueToFulate(comp, options = {}, componentProps = {}) {
|
|
|
422
422
|
return markRaw(new VueShape(options, componentProps)).bindComponent(comp);
|
|
423
423
|
}
|
|
424
424
|
//#endregion
|
|
425
|
-
export { FTransition, FULATE_HOST_KEY, FULATE_OVERLAY_KEY, FULATE_ROOT_KEY, VUE_SHAPE_SIZE_KEY, VueShape, createApp, fromVueToFulate, getRegisteredElement, registerElement, registerVueComponent, registerVueOverlay, useFulateHost,
|
|
425
|
+
export { FTransition, FULATE_HOST_KEY, FULATE_OVERLAY_KEY, FULATE_ROOT_KEY, VUE_SHAPE_SIZE_KEY, VueShape, createApp, fromVueToFulate, getRegisteredElement, registerElement, registerVueComponent, registerVueOverlay, useFulateHost, vueShapeV2Codec };
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Renderer } from "vue";
|
|
2
1
|
import { Element } from "@fulate/core";
|
|
2
|
+
import { type Renderer } from "vue";
|
|
3
3
|
export type ElementConstructor<T extends Element = Element> = new (options?: any) => T;
|
|
4
4
|
export declare function registerElement(type: string, Constructor: ElementConstructor): void;
|
|
5
5
|
export declare function getRegisteredElement(type: string): ElementConstructor | undefined;
|
package/dist/vue-shape.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ElementV2Codec } from "@fulate/import";
|
|
2
|
+
import { type ElementPayload, type ElementTransformClass, type Layer, type PropertyChanges, type Root } from "@fulate/core";
|
|
2
3
|
import { Rectangle, RectangleProperties, type RectangleOption } from "@fulate/ui";
|
|
3
4
|
import { type Component } from "vue";
|
|
4
5
|
export declare function registerVueComponent(name: string, comp: Component): void;
|
|
5
6
|
/** 将当前 effective Properties 映射为完整 Vue component props。 */
|
|
6
7
|
export type VueComponentPropsResolver<P extends RectangleProperties = RectangleProperties> = (properties: Readonly<P>) => Record<string, unknown>;
|
|
7
|
-
export type VueShapeJSON
|
|
8
|
+
export type VueShapeJSON = ElementPayload & {
|
|
8
9
|
component?: string;
|
|
9
10
|
componentProps?: Record<string, unknown>;
|
|
10
11
|
};
|
|
@@ -33,11 +34,9 @@ export declare class VueShape<P extends RectangleProperties = RectanglePropertie
|
|
|
33
34
|
private syncSize;
|
|
34
35
|
private syncComponentProps;
|
|
35
36
|
/** manual 模式保存 component metadata;mapped 模式只保存 Properties。 */
|
|
36
|
-
|
|
37
|
+
getPersistentChildren(): any[];
|
|
38
|
+
toJSON(): VueShapeJSON;
|
|
37
39
|
}
|
|
38
|
-
export declare const
|
|
39
|
-
readonly type: "vue-component";
|
|
40
|
-
readonly deserialize: (data: Record<string, any>) => VueShape<RectangleProperties, RectangleOption<any>>;
|
|
41
|
-
};
|
|
40
|
+
export declare const vueShapeV2Codec: ElementV2Codec;
|
|
42
41
|
/** 从彼此独立的 Rectangle options 和 Vue component props 创建 VueShape。 */
|
|
43
42
|
export declare function fromVueToFulate(comp: Component, options?: RectangleOption<VueShape>, componentProps?: Record<string, unknown>): VueShape;
|
package/dist/yoga.js
CHANGED
package/package.json
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fulate/vue",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"./yoga": {
|
|
13
|
-
"types": "./dist/yoga.d.ts",
|
|
14
|
-
"import": "./dist/yoga.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"scripts": {
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"test:watch": "vitest"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@fulate/core": "
|
|
27
|
-
"@fulate/ui": "
|
|
28
|
-
"lodash-es": "^4.17.22"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fulate/vue",
|
|
3
|
+
"version": "2.0.11",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./yoga": {
|
|
13
|
+
"types": "./dist/yoga.d.ts",
|
|
14
|
+
"import": "./dist/yoga.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@fulate/core": "2.0.11",
|
|
27
|
+
"@fulate/ui": "2.0.11",
|
|
28
|
+
"lodash-es": "^4.17.22",
|
|
29
|
+
"@fulate/import": "2.0.11"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": "^3.5.0",
|
|
33
|
+
"@fulate/yoga": "2.0.11"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@fulate/yoga": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|