@leafer/decorator 1.0.0-alpha.21 → 1.0.0-alpha.23
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/package.json +4 -4
- package/src/class.ts +1 -1
- package/src/data.ts +49 -46
- package/src/index.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/decorator",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
4
|
"description": "@leafer/decorator",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/platform": "1.0.0-alpha.
|
|
23
|
-
"@leafer/debug": "1.0.0-alpha.
|
|
22
|
+
"@leafer/platform": "1.0.0-alpha.23",
|
|
23
|
+
"@leafer/debug": "1.0.0-alpha.23"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@leafer/interface": "1.0.0-alpha.
|
|
26
|
+
"@leafer/interface": "1.0.0-alpha.23"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/class.ts
CHANGED
package/src/data.ts
CHANGED
|
@@ -6,76 +6,72 @@ import { defineKey, getDescriptor } from './object'
|
|
|
6
6
|
export function aliasType(name: string) {
|
|
7
7
|
return (target: ILeaf, key: string) => {
|
|
8
8
|
defineKey(target, key, {
|
|
9
|
-
get() { return this.
|
|
9
|
+
get() { return this.__getAttr(name) },
|
|
10
10
|
set(value: __Value) {
|
|
11
|
-
this.
|
|
11
|
+
this.__setAttr(name, value)
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
|
|
18
|
+
export function defineLeafAttr(target: ILeaf, key: string, defaultValue: __Value, mergeDescriptor?: IObject & ThisType<ILeaf>): void {
|
|
19
|
+
const defaultDescriptor: IObject & ThisType<ILeaf> = {
|
|
20
|
+
get() { return this.__getAttr(key) },
|
|
21
|
+
set(value: __Value) { this.__setAttr(key, value) }
|
|
22
|
+
}
|
|
23
|
+
defineKey(target, key, Object.assign(defaultDescriptor, mergeDescriptor || {}))
|
|
24
|
+
defineDataProcessor(target, key, defaultValue)
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
export function dataType(defaultValue?: __Value) {
|
|
18
28
|
return (target: ILeaf, key: string) => {
|
|
19
|
-
|
|
20
|
-
get() { return this.__get(key) },
|
|
21
|
-
set(value: __Value) {
|
|
22
|
-
this.__set(key, value)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
defineDataProcessor(target, key, defaultValue)
|
|
29
|
+
defineLeafAttr(target, key, defaultValue)
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export function positionType(defaultValue?: __Value) {
|
|
30
34
|
return (target: ILeaf, key: string) => {
|
|
31
|
-
|
|
32
|
-
get() { return this.__get(key) },
|
|
35
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
33
36
|
set(value: __Value) {
|
|
34
|
-
this.
|
|
37
|
+
this.__setAttr(key, value)
|
|
35
38
|
this.__layout.positionChanged || this.__layout.positionChange()
|
|
36
39
|
}
|
|
37
40
|
})
|
|
38
|
-
defineDataProcessor(target, key, defaultValue)
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
export function scaleType(defaultValue?: __Value) {
|
|
43
45
|
return (target: ILeaf, key: string) => {
|
|
44
|
-
|
|
45
|
-
get() { return this.__get(key) },
|
|
46
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
46
47
|
set(value: __Value) {
|
|
47
|
-
this.
|
|
48
|
+
this.__setAttr(key, value)
|
|
48
49
|
this.__layout.scaleChanged || this.__layout.scaleChange()
|
|
49
50
|
}
|
|
50
51
|
})
|
|
51
|
-
defineDataProcessor(target, key, defaultValue)
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export function rotationType(defaultValue?: __Value) {
|
|
56
56
|
return (target: ILeaf, key: string) => {
|
|
57
|
-
|
|
58
|
-
get() { return this.__get(key) },
|
|
57
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
59
58
|
set(value: __Value) {
|
|
60
|
-
this.
|
|
59
|
+
this.__setAttr(key, value)
|
|
61
60
|
this.__layout.rotationChanged || this.__layout.rotationChange()
|
|
62
61
|
|
|
63
62
|
}
|
|
64
63
|
})
|
|
65
|
-
defineDataProcessor(target, key, defaultValue)
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
export function boundsType(defaultValue?: __Value) {
|
|
70
68
|
return (target: ILeaf, key: string) => {
|
|
71
|
-
|
|
72
|
-
get() { return this.__get(key) },
|
|
69
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
73
70
|
set(value: __Value) {
|
|
74
|
-
this.
|
|
71
|
+
this.__setAttr(key, value)
|
|
75
72
|
this.__layout.boxBoundsChanged || this.__layout.boxBoundsChange()
|
|
76
73
|
}
|
|
77
74
|
})
|
|
78
|
-
defineDataProcessor(target, key, defaultValue)
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
77
|
|
|
@@ -84,62 +80,53 @@ export const pathType = boundsType
|
|
|
84
80
|
|
|
85
81
|
export function affectEventBoundsType(defaultValue?: __Value) {
|
|
86
82
|
return (target: ILeaf, key: string) => {
|
|
87
|
-
|
|
88
|
-
get() { return this.__get(key) },
|
|
83
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
89
84
|
set(value: __Value) {
|
|
90
|
-
this.
|
|
91
|
-
this.__layout.
|
|
85
|
+
this.__setAttr(key, value)
|
|
86
|
+
this.__layout.strokeBoundsChanged || this.__layout.strokeBoundsChange()
|
|
92
87
|
}
|
|
93
88
|
})
|
|
94
|
-
defineDataProcessor(target, key, defaultValue)
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
export function affectRenderBoundsType(defaultValue?: __Value) {
|
|
99
93
|
return (target: ILeaf, key: string) => {
|
|
100
|
-
|
|
101
|
-
get() { return this.__get(key) },
|
|
94
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
102
95
|
set(value: __Value) {
|
|
103
|
-
this.
|
|
96
|
+
this.__setAttr(key, value)
|
|
104
97
|
this.__layout.renderBoundsChanged || this.__layout.renderBoundsChange()
|
|
105
98
|
}
|
|
106
99
|
})
|
|
107
|
-
defineDataProcessor(target, key, defaultValue)
|
|
108
100
|
}
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
export function surfaceType(defaultValue?: __Value) {
|
|
112
104
|
return (target: ILeaf, key: string) => {
|
|
113
|
-
|
|
114
|
-
get() { return this.__get(key) },
|
|
105
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
115
106
|
set(value: __Value) {
|
|
116
|
-
this.
|
|
107
|
+
this.__setAttr(key, value)
|
|
117
108
|
this.__layout.surfaceChanged || this.__layout.surfaceChange()
|
|
118
109
|
}
|
|
119
110
|
})
|
|
120
|
-
defineDataProcessor(target, key, defaultValue)
|
|
121
111
|
}
|
|
122
112
|
}
|
|
123
113
|
|
|
124
114
|
export function opacityType(defaultValue?: __Value) {
|
|
125
115
|
return (target: ILeaf, key: string) => {
|
|
126
|
-
|
|
127
|
-
get() { return this.__get(key) },
|
|
116
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
128
117
|
set(value: __Value) {
|
|
129
|
-
this.
|
|
118
|
+
this.__setAttr(key, value)
|
|
130
119
|
this.__layout.opacityChanged || this.__layout.opacityChange()
|
|
131
120
|
}
|
|
132
121
|
})
|
|
133
|
-
defineDataProcessor(target, key, defaultValue)
|
|
134
122
|
}
|
|
135
123
|
}
|
|
136
124
|
|
|
137
125
|
export function sortType(defaultValue?: __Value) {
|
|
138
126
|
return (target: ILeaf, key: string) => {
|
|
139
|
-
|
|
140
|
-
get() { return this.__get(key) },
|
|
127
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
141
128
|
set(value: __Value) {
|
|
142
|
-
this.
|
|
129
|
+
this.__setAttr(key, value)
|
|
143
130
|
this.__layout.surfaceChanged || this.__layout.surfaceChange()
|
|
144
131
|
|
|
145
132
|
if (this.parent) {
|
|
@@ -149,7 +136,23 @@ export function sortType(defaultValue?: __Value) {
|
|
|
149
136
|
}
|
|
150
137
|
}
|
|
151
138
|
})
|
|
152
|
-
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function maskType(defaultValue?: __Value) {
|
|
143
|
+
return (target: ILeaf, key: string) => {
|
|
144
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
145
|
+
set(value: __Value) {
|
|
146
|
+
this.__setAttr(key, value)
|
|
147
|
+
this.__layout.boxBoundsChanged || this.__layout.boxBoundsChange()
|
|
148
|
+
|
|
149
|
+
if (this.parent) {
|
|
150
|
+
this.parent.__hasMask = value ? true : this.parent.children.some(item => item.isMask)
|
|
151
|
+
} else {
|
|
152
|
+
this.__addParentWait(() => { this.parent.__hasMask = value ? true : this.parent.children.some(item => item.isMask) })
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
})
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
158
|
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { aliasType, dataType, positionType, boundsType, affectEventBoundsType, affectRenderBoundsType, scaleType, rotationType, surfaceType, opacityType, sortType, pathType, dataProcessor, layoutProcessor, defineDataProcessor } from './data'
|
|
1
|
+
export { aliasType, defineLeafAttr, dataType, positionType, boundsType, affectEventBoundsType, affectRenderBoundsType, scaleType, rotationType, surfaceType, opacityType, sortType, maskType, pathType, dataProcessor, layoutProcessor, defineDataProcessor } from './data'
|
|
2
2
|
export { useModule, rewrite, rewriteAble } from './rewrite'
|
|
3
3
|
export { defineKey, getDescriptor } from './object'
|
|
4
|
-
export { registerUI,
|
|
4
|
+
export { registerUI, registerUIEvent } from './class'
|