1
1
/**
2
- * vue-class-component v6.2 .0
2
+ * vue-class-component v6.3 .0
3
3
* (c) 2015-present Evan You
4
4
* @license MIT
5
5
*/
@@ -11,7 +11,37 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
11
11
12
12
var Vue = _interopDefault ( require ( 'vue' ) ) ;
13
13
14
- var hasProto = { __proto__ : [ ] } instanceof Array ;
14
+ function reflectionIsSupported ( ) {
15
+ return ( Reflect && Reflect . defineMetadata ) !== undefined ;
16
+ }
17
+ function copyReflectionMetadata ( to , from ) {
18
+ forwardMetadata ( to , from ) ;
19
+ Object . getOwnPropertyNames ( from . prototype ) . forEach ( function ( key ) {
20
+ forwardMetadata ( to . prototype , from . prototype , key ) ;
21
+ } ) ;
22
+ Object . getOwnPropertyNames ( from ) . forEach ( function ( key ) {
23
+ forwardMetadata ( to , from , key ) ;
24
+ } ) ;
25
+ }
26
+ function forwardMetadata ( to , from , propertyKey ) {
27
+ var metaKeys = propertyKey
28
+ ? Reflect . getOwnMetadataKeys ( from , propertyKey )
29
+ : Reflect . getOwnMetadataKeys ( from ) ;
30
+ metaKeys . forEach ( function ( metaKey ) {
31
+ var metadata = propertyKey
32
+ ? Reflect . getOwnMetadata ( metaKey , from , propertyKey )
33
+ : Reflect . getOwnMetadata ( metaKey , from ) ;
34
+ if ( propertyKey ) {
35
+ Reflect . defineMetadata ( metaKey , metadata , to , propertyKey ) ;
36
+ }
37
+ else {
38
+ Reflect . defineMetadata ( metaKey , metadata , to ) ;
39
+ }
40
+ } ) ;
41
+ }
42
+
43
+ var fakeArray = { __proto__ : [ ] } ;
44
+ var hasProto = fakeArray instanceof Array ;
15
45
function createDecorator ( factory ) {
16
46
return function ( target , key , index ) {
17
47
var Ctor = typeof target === 'function'
@@ -35,7 +65,7 @@ function mixins() {
35
65
}
36
66
function isPrimitive ( value ) {
37
67
var type = typeof value ;
38
- return value == null || ( type !== " object" && type !== " function" ) ;
68
+ return value == null || ( type !== ' object' && type !== ' function' ) ;
39
69
}
40
70
function warn ( message ) {
41
71
if ( typeof console !== 'undefined' ) {
@@ -62,7 +92,7 @@ function collectDataFromConstructor(vm, Component) {
62
92
if ( key . charAt ( 0 ) !== '_' ) {
63
93
Object . defineProperty ( _this , key , {
64
94
get : function ( ) { return vm [ key ] ; } ,
65
- set : function ( value ) { return vm [ key ] = value ; } ,
95
+ set : function ( value ) { vm [ key ] = value ; } ,
66
96
configurable : true
67
97
} ) ;
68
98
}
@@ -118,9 +148,20 @@ function componentFactory(Component, options) {
118
148
return ;
119
149
}
120
150
var descriptor = Object . getOwnPropertyDescriptor ( proto , key ) ;
121
- if ( typeof descriptor . value === 'function' ) {
151
+ if ( descriptor . value !== void 0 ) {
122
152
// methods
123
- ( options . methods || ( options . methods = { } ) ) [ key ] = descriptor . value ;
153
+ if ( typeof descriptor . value === 'function' ) {
154
+ ( options . methods || ( options . methods = { } ) ) [ key ] = descriptor . value ;
155
+ }
156
+ else {
157
+ // typescript decorated data
158
+ ( options . mixins || ( options . mixins = [ ] ) ) . push ( {
159
+ data : function ( ) {
160
+ var _a ;
161
+ return _a = { } , _a [ key ] = descriptor . value , _a ;
162
+ }
163
+ } ) ;
164
+ }
124
165
}
125
166
else if ( descriptor . get || descriptor . set ) {
126
167
// computed properties
@@ -148,6 +189,9 @@ function componentFactory(Component, options) {
148
189
: Vue ;
149
190
var Extended = Super . extend ( options ) ;
150
191
forwardStaticMembers ( Extended , Component , Super ) ;
192
+ if ( reflectionIsSupported ( ) ) {
193
+ copyReflectionMetadata ( Extended , Component ) ;
194
+ }
151
195
return Extended ;
152
196
}
153
197
var reservedPropertyNames = [
@@ -193,15 +237,15 @@ function forwardStaticMembers(Extended, Original, Super) {
193
237
return ;
194
238
}
195
239
var superDescriptor = Object . getOwnPropertyDescriptor ( Super , key ) ;
196
- if ( ! isPrimitive ( descriptor . value )
197
- && superDescriptor
198
- && superDescriptor . value === descriptor . value ) {
240
+ if ( ! isPrimitive ( descriptor . value ) &&
241
+ superDescriptor &&
242
+ superDescriptor . value === descriptor . value ) {
199
243
return ;
200
244
}
201
245
}
202
246
// Warn if the users manually declare reserved properties
203
- if ( process . env . NODE_ENV !== 'production'
204
- && reservedPropertyNames . indexOf ( key ) >= 0 ) {
247
+ if ( process . env . NODE_ENV !== 'production' &&
248
+ reservedPropertyNames . indexOf ( key ) >= 0 ) {
205
249
warn ( "Static property name '" + key + "' declared on class '" + Original . name + "' " +
206
250
'conflicts with reserved property name of Vue internal. ' +
207
251
'It may cause unexpected behavior of the component. Consider renaming the property.' ) ;
@@ -218,14 +262,10 @@ function Component(options) {
218
262
return componentFactory ( Component , options ) ;
219
263
} ;
220
264
}
221
- ( function ( Component ) {
222
- function registerHooks ( keys ) {
223
- $internalHooks . push . apply ( $internalHooks , keys ) ;
224
- }
225
- Component . registerHooks = registerHooks ;
226
- } ) ( Component || ( Component = { } ) ) ;
227
- var Component$1 = Component ;
265
+ Component . registerHooks = function registerHooks ( keys ) {
266
+ $internalHooks . push . apply ( $internalHooks , keys ) ;
267
+ } ;
228
268
229
- exports . default = Component$1 ;
269
+ exports . default = Component ;
230
270
exports . createDecorator = createDecorator ;
231
271
exports . mixins = mixins ;
0 commit comments