@leafer/decorator 1.0.0-alpha.1 → 1.0.0-alpha.21
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 +8 -6
- package/src/data.ts +14 -14
- package/src/rewrite.ts +7 -7
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/decorator",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"description": "@leafer/decorator",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
-
"files": [
|
|
8
|
+
"files": [
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
11
13
|
"url": "https://github.com/leaferjs/leafer.git"
|
|
@@ -17,10 +19,10 @@
|
|
|
17
19
|
"leaferjs"
|
|
18
20
|
],
|
|
19
21
|
"dependencies": {
|
|
20
|
-
"@leafer/platform": "1.0.0-alpha.
|
|
21
|
-
"@leafer/debug": "1.0.0-alpha.
|
|
22
|
+
"@leafer/platform": "1.0.0-alpha.21",
|
|
23
|
+
"@leafer/debug": "1.0.0-alpha.21"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
|
-
|
|
26
|
+
"@leafer/interface": "1.0.0-alpha.21"
|
|
25
27
|
}
|
|
26
|
-
}
|
|
28
|
+
}
|
package/src/data.ts
CHANGED
|
@@ -8,7 +8,7 @@ export function aliasType(name: string) {
|
|
|
8
8
|
defineKey(target, key, {
|
|
9
9
|
get() { return this.__get(name) },
|
|
10
10
|
set(value: __Value) {
|
|
11
|
-
this.
|
|
11
|
+
this.__set(name, value)
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
14
|
}
|
|
@@ -19,7 +19,7 @@ export function dataType(defaultValue?: __Value) {
|
|
|
19
19
|
defineKey(target, key, {
|
|
20
20
|
get() { return this.__get(key) },
|
|
21
21
|
set(value: __Value) {
|
|
22
|
-
this.
|
|
22
|
+
this.__set(key, value)
|
|
23
23
|
}
|
|
24
24
|
})
|
|
25
25
|
defineDataProcessor(target, key, defaultValue)
|
|
@@ -31,7 +31,7 @@ export function positionType(defaultValue?: __Value) {
|
|
|
31
31
|
defineKey(target, key, {
|
|
32
32
|
get() { return this.__get(key) },
|
|
33
33
|
set(value: __Value) {
|
|
34
|
-
this.
|
|
34
|
+
this.__set(key, value)
|
|
35
35
|
this.__layout.positionChanged || this.__layout.positionChange()
|
|
36
36
|
}
|
|
37
37
|
})
|
|
@@ -44,7 +44,7 @@ export function scaleType(defaultValue?: __Value) {
|
|
|
44
44
|
defineKey(target, key, {
|
|
45
45
|
get() { return this.__get(key) },
|
|
46
46
|
set(value: __Value) {
|
|
47
|
-
this.
|
|
47
|
+
this.__set(key, value)
|
|
48
48
|
this.__layout.scaleChanged || this.__layout.scaleChange()
|
|
49
49
|
}
|
|
50
50
|
})
|
|
@@ -57,7 +57,7 @@ export function rotationType(defaultValue?: __Value) {
|
|
|
57
57
|
defineKey(target, key, {
|
|
58
58
|
get() { return this.__get(key) },
|
|
59
59
|
set(value: __Value) {
|
|
60
|
-
this.
|
|
60
|
+
this.__set(key, value)
|
|
61
61
|
this.__layout.rotationChanged || this.__layout.rotationChange()
|
|
62
62
|
|
|
63
63
|
}
|
|
@@ -71,7 +71,7 @@ export function boundsType(defaultValue?: __Value) {
|
|
|
71
71
|
defineKey(target, key, {
|
|
72
72
|
get() { return this.__get(key) },
|
|
73
73
|
set(value: __Value) {
|
|
74
|
-
this.
|
|
74
|
+
this.__set(key, value)
|
|
75
75
|
this.__layout.boxBoundsChanged || this.__layout.boxBoundsChange()
|
|
76
76
|
}
|
|
77
77
|
})
|
|
@@ -87,7 +87,7 @@ export function affectEventBoundsType(defaultValue?: __Value) {
|
|
|
87
87
|
defineKey(target, key, {
|
|
88
88
|
get() { return this.__get(key) },
|
|
89
89
|
set(value: __Value) {
|
|
90
|
-
this.
|
|
90
|
+
this.__set(key, value)
|
|
91
91
|
this.__layout.eventBoundsChanged || this.__layout.eventBoundsChange()
|
|
92
92
|
}
|
|
93
93
|
})
|
|
@@ -100,7 +100,7 @@ export function affectRenderBoundsType(defaultValue?: __Value) {
|
|
|
100
100
|
defineKey(target, key, {
|
|
101
101
|
get() { return this.__get(key) },
|
|
102
102
|
set(value: __Value) {
|
|
103
|
-
this.
|
|
103
|
+
this.__set(key, value)
|
|
104
104
|
this.__layout.renderBoundsChanged || this.__layout.renderBoundsChange()
|
|
105
105
|
}
|
|
106
106
|
})
|
|
@@ -113,7 +113,7 @@ export function surfaceType(defaultValue?: __Value) {
|
|
|
113
113
|
defineKey(target, key, {
|
|
114
114
|
get() { return this.__get(key) },
|
|
115
115
|
set(value: __Value) {
|
|
116
|
-
this.
|
|
116
|
+
this.__set(key, value)
|
|
117
117
|
this.__layout.surfaceChanged || this.__layout.surfaceChange()
|
|
118
118
|
}
|
|
119
119
|
})
|
|
@@ -139,13 +139,13 @@ export function sortType(defaultValue?: __Value) {
|
|
|
139
139
|
defineKey(target, key, {
|
|
140
140
|
get() { return this.__get(key) },
|
|
141
141
|
set(value: __Value) {
|
|
142
|
-
this.
|
|
142
|
+
this.__set(key, value)
|
|
143
143
|
this.__layout.surfaceChanged || this.__layout.surfaceChange()
|
|
144
144
|
|
|
145
145
|
if (this.parent) {
|
|
146
|
-
this.parent.__layout.childrenSortChanged
|
|
146
|
+
this.parent.__layout.childrenSortChanged = true
|
|
147
147
|
} else {
|
|
148
|
-
this.__addParentWait(() => { this.parent.__layout.childrenSortChanged
|
|
148
|
+
this.__addParentWait(() => { this.parent.__layout.childrenSortChanged = true })
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
})
|
|
@@ -157,7 +157,7 @@ export function sortType(defaultValue?: __Value) {
|
|
|
157
157
|
// get
|
|
158
158
|
|
|
159
159
|
export function dataProcessor(processor: IObject) {
|
|
160
|
-
return (target: ILeaf,
|
|
160
|
+
return (target: ILeaf, _key: string) => {
|
|
161
161
|
defineKey(target, '__DataProcessor', {
|
|
162
162
|
get() { return processor }
|
|
163
163
|
})
|
|
@@ -165,7 +165,7 @@ export function dataProcessor(processor: IObject) {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
export function layoutProcessor(processor: IObject) {
|
|
168
|
-
return (target: ILeaf,
|
|
168
|
+
return (target: ILeaf, _key: string) => {
|
|
169
169
|
defineKey(target, '__LayoutProcessor', {
|
|
170
170
|
get() { return processor }
|
|
171
171
|
})
|
package/src/rewrite.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function rewrite(method: IFunction) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function rewriteAble() {
|
|
25
|
-
return (
|
|
25
|
+
return (_target: IObject) => {
|
|
26
26
|
doRewrite()
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -42,16 +42,16 @@ setTimeout(() => doRewrite(true))
|
|
|
42
42
|
|
|
43
43
|
// class
|
|
44
44
|
|
|
45
|
-
export function useModule(
|
|
45
|
+
export function useModule(module: IObject) {
|
|
46
46
|
return (target: IObject) => {
|
|
47
|
-
const names =
|
|
47
|
+
const names = module.prototype ? getNames(module.prototype) : Object.keys(module)
|
|
48
48
|
names.forEach(name => {
|
|
49
49
|
if (!excludeNames.includes(name)) {
|
|
50
|
-
if (
|
|
51
|
-
const d = getDescriptor(
|
|
52
|
-
if (d.writable) target.prototype[name] =
|
|
50
|
+
if (module.prototype) {
|
|
51
|
+
const d = getDescriptor(module.prototype, name)
|
|
52
|
+
if (d.writable) target.prototype[name] = module.prototype[name]
|
|
53
53
|
} else {
|
|
54
|
-
target.prototype[name] =
|
|
54
|
+
target.prototype[name] = module[name]
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
})
|