@leafer/decorator 1.0.0-alpha.6 → 1.0.0-alpha.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/decorator",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.7",
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.6",
23
- "@leafer/debug": "1.0.0-alpha.6"
22
+ "@leafer/platform": "1.0.0-alpha.7",
23
+ "@leafer/debug": "1.0.0-alpha.7"
24
24
  },
25
25
  "devDependencies": {
26
- "@leafer/interface": "1.0.0-alpha.6"
26
+ "@leafer/interface": "1.0.0-alpha.7"
27
27
  }
28
28
  }
package/src/class.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  import { IObject } from '@leafer/interface'
2
2
  import { EventCreator, UICreator } from '@leafer/platform'
3
3
 
4
- export function registerUI() {
5
- return (target: IObject) => {
6
- UICreator.register(target)
7
- }
4
+ export function registerUI() { return (target: IObject) => registerUI__(target) }
5
+ export function registerUI__(target: IObject) {
6
+ UICreator.register(target)
8
7
  }
9
8
 
10
- export function registerEvent() {
11
- return (target: IObject) => {
12
- EventCreator.register(target)
13
- }
9
+ export function registerEvent() { return (target: IObject) => registerEvent__(target) }
10
+ export function registerEvent__(target: IObject) {
11
+ EventCreator.register(target)
14
12
  }
package/src/data.ts CHANGED
@@ -3,173 +3,163 @@ import { defineKey, getDescriptor } from './object'
3
3
 
4
4
  // name
5
5
 
6
- export function aliasType(name: string) {
7
- return (target: ILeaf, key: string) => {
8
- defineKey(target, key, {
9
- get() { return this.__get(name) },
10
- set(value: __Value) {
11
- this.root ? this.__set(name, value) : this.__[name] = value
12
- }
13
- })
14
- }
6
+ export function aliasType(name: string) { return (target: ILeaf, key: string) => aliasType__(target, key, name) }
7
+ export function aliasType__(target: ILeaf, key: string, name: string) {
8
+ defineKey(target, key, {
9
+ get() { return this.__get(name) },
10
+ set(value: __Value) {
11
+ this.root ? this.__set(name, value) : this.__[name] = value
12
+ }
13
+ })
15
14
  }
16
15
 
17
- export function dataType(defaultValue?: __Value) {
18
- return (target: ILeaf, key: string) => {
19
- defineKey(target, key, {
20
- get() { return this.__get(key) },
21
- set(value: __Value) {
22
- this.root ? this.__set(key, value) : this.__[key] = value
23
- }
24
- })
25
- defineDataProcessor(target, key, defaultValue)
26
- }
16
+ export function dataType(defaultValue?: __Value) { return (target: ILeaf, key: string) => dataType__(target, key, defaultValue) }
17
+ export function dataType__(target: ILeaf, key: string, defaultValue?: __Value) {
18
+ defineKey(target, key, {
19
+ get() { return this.__get(key) },
20
+ set(value: __Value) {
21
+ this.root ? this.__set(key, value) : this.__[key] = value
22
+ }
23
+ })
24
+ defineDataProcessor(target, key, defaultValue)
27
25
  }
28
26
 
29
- export function positionType(defaultValue?: __Value) {
30
- return (target: ILeaf, key: string) => {
31
- defineKey(target, key, {
32
- get() { return this.__get(key) },
33
- set(value: __Value) {
34
- this.root ? this.__set(key, value) : this.__[key] = value
35
- this.__layout.positionChanged || this.__layout.positionChange()
36
- }
37
- })
38
- defineDataProcessor(target, key, defaultValue)
39
- }
27
+
28
+ export function positionType(defaultValue?: __Value) { return (target: ILeaf, key: string) => positionType__(target, key, defaultValue) }
29
+ export function positionType__(target: ILeaf, key: string, defaultValue?: __Value) {
30
+ defineKey(target, key, {
31
+ get() { return this.__get(key) },
32
+ set(value: __Value) {
33
+ this.root ? this.__set(key, value) : this.__[key] = value
34
+ this.__layout.positionChanged || this.__layout.positionChange()
35
+ }
36
+ })
37
+ defineDataProcessor(target, key, defaultValue)
40
38
  }
41
39
 
42
- export function scaleType(defaultValue?: __Value) {
43
- return (target: ILeaf, key: string) => {
44
- defineKey(target, key, {
45
- get() { return this.__get(key) },
46
- set(value: __Value) {
47
- this.root ? this.__set(key, value) : this.__[key] = value
48
- this.__layout.scaleChanged || this.__layout.scaleChange()
49
- }
50
- })
51
- defineDataProcessor(target, key, defaultValue)
52
- }
40
+
41
+ export function scaleType(defaultValue?: __Value) { return (target: ILeaf, key: string) => scaleType__(target, key, defaultValue) }
42
+ export function scaleType__(target: ILeaf, key: string, defaultValue?: __Value) {
43
+ defineKey(target, key, {
44
+ get() { return this.__get(key) },
45
+ set(value: __Value) {
46
+ this.root ? this.__set(key, value) : this.__[key] = value
47
+ this.__layout.scaleChanged || this.__layout.scaleChange()
48
+ }
49
+ })
50
+ defineDataProcessor(target, key, defaultValue)
53
51
  }
54
52
 
55
- export function rotationType(defaultValue?: __Value) {
56
- return (target: ILeaf, key: string) => {
57
- defineKey(target, key, {
58
- get() { return this.__get(key) },
59
- set(value: __Value) {
60
- this.root ? this.__set(key, value) : this.__[key] = value
61
- this.__layout.rotationChanged || this.__layout.rotationChange()
53
+ export function rotationType(defaultValue?: __Value) { return (target: ILeaf, key: string) => rotationType__(target, key, defaultValue) }
54
+ export function rotationType__(target: ILeaf, key: string, defaultValue?: __Value) {
55
+ defineKey(target, key, {
56
+ get() { return this.__get(key) },
57
+ set(value: __Value) {
58
+ this.root ? this.__set(key, value) : this.__[key] = value
59
+ this.__layout.rotationChanged || this.__layout.rotationChange()
62
60
 
63
- }
64
- })
65
- defineDataProcessor(target, key, defaultValue)
66
- }
61
+ }
62
+ })
63
+ defineDataProcessor(target, key, defaultValue)
67
64
  }
68
65
 
69
- export function boundsType(defaultValue?: __Value) {
70
- return (target: ILeaf, key: string) => {
71
- defineKey(target, key, {
72
- get() { return this.__get(key) },
73
- set(value: __Value) {
74
- this.root ? this.__set(key, value) : this.__[key] = value
75
- this.__layout.boxBoundsChanged || this.__layout.boxBoundsChange()
76
- }
77
- })
78
- defineDataProcessor(target, key, defaultValue)
79
- }
66
+ export function boundsType(defaultValue?: __Value) { return (target: ILeaf, key: string) => boundsType__(target, key, defaultValue) }
67
+ export function boundsType__(target: ILeaf, key: string, defaultValue?: __Value) {
68
+ defineKey(target, key, {
69
+ get() { return this.__get(key) },
70
+ set(value: __Value) {
71
+ this.root ? this.__set(key, value) : this.__[key] = value
72
+ this.__layout.boxBoundsChanged || this.__layout.boxBoundsChange()
73
+ }
74
+ })
75
+ defineDataProcessor(target, key, defaultValue)
80
76
  }
81
77
 
82
78
  export const pathType = boundsType
79
+ export const pathType__ = boundsType__
83
80
 
84
81
 
85
- export function affectEventBoundsType(defaultValue?: __Value) {
86
- return (target: ILeaf, key: string) => {
87
- defineKey(target, key, {
88
- get() { return this.__get(key) },
89
- set(value: __Value) {
90
- this.root ? this.__set(key, value) : this.__[key] = value
91
- this.__layout.eventBoundsChanged || this.__layout.eventBoundsChange()
92
- }
93
- })
94
- defineDataProcessor(target, key, defaultValue)
95
- }
82
+ export function affectEventBoundsType(defaultValue?: __Value) { return (target: ILeaf, key: string) => affectEventBoundsType__(target, key, defaultValue) }
83
+ export function affectEventBoundsType__(target: ILeaf, key: string, defaultValue?: __Value) {
84
+ defineKey(target, key, {
85
+ get() { return this.__get(key) },
86
+ set(value: __Value) {
87
+ this.root ? this.__set(key, value) : this.__[key] = value
88
+ this.__layout.eventBoundsChanged || this.__layout.eventBoundsChange()
89
+ }
90
+ })
91
+ defineDataProcessor(target, key, defaultValue)
96
92
  }
97
93
 
98
- export function affectRenderBoundsType(defaultValue?: __Value) {
99
- return (target: ILeaf, key: string) => {
100
- defineKey(target, key, {
101
- get() { return this.__get(key) },
102
- set(value: __Value) {
103
- this.root ? this.__set(key, value) : this.__[key] = value
104
- this.__layout.renderBoundsChanged || this.__layout.renderBoundsChange()
105
- }
106
- })
107
- defineDataProcessor(target, key, defaultValue)
108
- }
94
+ export function affectRenderBoundsType(defaultValue?: __Value) { return (target: ILeaf, key: string) => affectRenderBoundsType__(target, key, defaultValue) }
95
+ export function affectRenderBoundsType__(target: ILeaf, key: string, defaultValue?: __Value) {
96
+ defineKey(target, key, {
97
+ get() { return this.__get(key) },
98
+ set(value: __Value) {
99
+ this.root ? this.__set(key, value) : this.__[key] = value
100
+ this.__layout.renderBoundsChanged || this.__layout.renderBoundsChange()
101
+ }
102
+ })
103
+ defineDataProcessor(target, key, defaultValue)
109
104
  }
110
105
 
111
- export function surfaceType(defaultValue?: __Value) {
112
- return (target: ILeaf, key: string) => {
113
- defineKey(target, key, {
114
- get() { return this.__get(key) },
115
- set(value: __Value) {
116
- this.root ? this.__set(key, value) : this.__[key] = value
117
- this.__layout.surfaceChanged || this.__layout.surfaceChange()
118
- }
119
- })
120
- defineDataProcessor(target, key, defaultValue)
121
- }
106
+ export function surfaceType(defaultValue?: __Value) { return (target: ILeaf, key: string) => surfaceType__(target, key, defaultValue) }
107
+ export function surfaceType__(target: ILeaf, key: string, defaultValue?: __Value) {
108
+ defineKey(target, key, {
109
+ get() { return this.__get(key) },
110
+ set(value: __Value) {
111
+ this.root ? this.__set(key, value) : this.__[key] = value
112
+ this.__layout.surfaceChanged || this.__layout.surfaceChange()
113
+ }
114
+ })
115
+ defineDataProcessor(target, key, defaultValue)
122
116
  }
123
117
 
124
- export function opacityType(defaultValue?: __Value) {
125
- return (target: ILeaf, key: string) => {
126
- defineKey(target, key, {
127
- get() { return this.__get(key) },
128
- set(value: __Value) {
129
- this.root ? this.__set(key, value) : this.__[key] = value
130
- this.__layout.opacityChanged || this.__layout.opacityChange()
131
- }
132
- })
133
- defineDataProcessor(target, key, defaultValue)
134
- }
118
+ export function opacityType(defaultValue?: __Value) { return (target: ILeaf, key: string) => opacityType__(target, key, defaultValue) }
119
+ export function opacityType__(target: ILeaf, key: string, defaultValue?: __Value) {
120
+ defineKey(target, key, {
121
+ get() { return this.__get(key) },
122
+ set(value: __Value) {
123
+ this.root ? this.__set(key, value) : this.__[key] = value
124
+ this.__layout.opacityChanged || this.__layout.opacityChange()
125
+ }
126
+ })
127
+ defineDataProcessor(target, key, defaultValue)
135
128
  }
136
129
 
137
- export function sortType(defaultValue?: __Value) {
138
- return (target: ILeaf, key: string) => {
139
- defineKey(target, key, {
140
- get() { return this.__get(key) },
141
- set(value: __Value) {
142
- this.root ? this.__set(key, value) : this.__[key] = value
143
- this.__layout.surfaceChanged || this.__layout.surfaceChange()
144
-
145
- if (this.parent) {
146
- this.parent.__layout.childrenSortChanged || (this.parent.__layout.childrenSortChanged = true)
147
- } else {
148
- this.__addParentWait(() => { this.parent.__layout.childrenSortChanged || (this.parent.__layout.childrenSortChanged = true) })
149
- }
130
+ export function sortType(defaultValue?: __Value) { return (target: ILeaf, key: string) => { sortType__(target, key, defaultValue) } }
131
+ export function sortType__(target: ILeaf, key: string, defaultValue?: __Value) {
132
+ defineKey(target, key, {
133
+ get() { return this.__get(key) },
134
+ set(value: __Value) {
135
+ this.root ? this.__set(key, value) : this.__[key] = value
136
+ this.__layout.surfaceChanged || this.__layout.surfaceChange()
137
+
138
+ if (this.parent) {
139
+ this.parent.__layout.childrenSortChanged || (this.parent.__layout.childrenSortChanged = true)
140
+ } else {
141
+ this.__addParentWait(() => { this.parent.__layout.childrenSortChanged || (this.parent.__layout.childrenSortChanged = true) })
150
142
  }
151
- })
152
- defineDataProcessor(target, key, defaultValue)
153
- }
143
+ }
144
+ })
145
+ defineDataProcessor(target, key, defaultValue)
154
146
  }
155
147
 
156
148
 
157
149
  // get
158
150
 
159
- export function dataProcessor(processor: IObject) {
160
- return (target: ILeaf, _key: string) => {
161
- defineKey(target, '__DataProcessor', {
162
- get() { return processor }
163
- })
164
- }
151
+ export function dataProcessor(processor: IObject) { return (target: ILeaf, _key: string) => dataProcessor__(target, processor) }
152
+ export function dataProcessor__(target: ILeaf, processor: IObject) {
153
+ defineKey(target, '__DataProcessor', {
154
+ get() { return processor }
155
+ })
165
156
  }
166
157
 
167
- export function layoutProcessor(processor: IObject) {
168
- return (target: ILeaf, _key: string) => {
169
- defineKey(target, '__LayoutProcessor', {
170
- get() { return processor }
171
- })
172
- }
158
+ export function layoutProcessor(processor: IObject) { return (target: ILeaf, _key: string) => layoutProcessor__(target, processor) }
159
+ export function layoutProcessor__(target: ILeaf, processor: IObject) {
160
+ defineKey(target, '__LayoutProcessor', {
161
+ get() { return processor }
162
+ })
173
163
  }
174
164
 
175
165
 
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'
2
- export { useModule, rewrite, rewriteAble } from './rewrite'
3
- export { defineKey, getDescriptor } from './object'
4
- export { registerUI, registerEvent } from './class'
1
+ export { registerUI, registerUI__, registerEvent, registerEvent__ } from './class'
2
+ export { aliasType, aliasType__, dataType, dataType__, positionType, positionType__, boundsType, boundsType__, affectEventBoundsType, affectEventBoundsType__, affectRenderBoundsType, affectRenderBoundsType__, scaleType, scaleType__, rotationType, rotationType__, surfaceType, surfaceType__, opacityType, opacityType__, sortType, sortType__, pathType, pathType__, dataProcessor, dataProcessor__, layoutProcessor, layoutProcessor__, defineDataProcessor } from './data'
3
+ export { useModule, useModule__, rewrite, rewriteAble } from './rewrite'
4
+ export { defineKey, getDescriptor } from './object'
package/src/rewrite.ts CHANGED
@@ -42,18 +42,17 @@ setTimeout(() => doRewrite(true))
42
42
 
43
43
  // class
44
44
 
45
- export function useModule(child: IObject) {
46
- return (target: IObject) => {
47
- const names = child.prototype ? getNames(child.prototype) : Object.keys(child)
48
- names.forEach(name => {
49
- if (!excludeNames.includes(name)) {
50
- if (child.prototype) {
51
- const d = getDescriptor(child.prototype, name)
52
- if (d.writable) target.prototype[name] = child.prototype[name]
53
- } else {
54
- target.prototype[name] = child[name]
55
- }
45
+ export function useModule(module: IObject) { return (target: IObject) => useModule__(target, module) }
46
+ export function useModule__(target: IObject, module: IObject) {
47
+ const names = module.prototype ? getNames(module.prototype) : Object.keys(module)
48
+ names.forEach(name => {
49
+ if (!excludeNames.includes(name)) {
50
+ if (module.prototype) {
51
+ const d = getDescriptor(module.prototype, name)
52
+ if (d.writable) target.prototype[name] = module.prototype[name]
53
+ } else {
54
+ target.prototype[name] = module[name]
56
55
  }
57
- })
58
- }
59
- }
56
+ }
57
+ })
58
+ }