1
+ ( function ( ) {
2
+
3
+ var __decorate = ( this && this . __decorate ) || function ( decorators , target , key , desc ) {
4
+ var c = arguments . length ;
5
+ var r = c < 3 ? target : desc === null ? desc = Object . getOwnPropertyDescriptor ( target , key ) : desc , d ;
6
+
7
+ if ( typeof global . Reflect === "object" && typeof global . Reflect . decorate === "function" ) {
8
+ r = global . Reflect . decorate ( decorators , target , key , desc ) ;
9
+ }
10
+ else {
11
+ for ( var i = decorators . length - 1 ; i >= 0 ; i -- ) {
12
+ if ( d = decorators [ i ] ) {
13
+ r = ( c < 3 ? d ( r ) : c > 3 ? d ( target , key , r ) : d ( target , key ) ) || r ;
14
+ }
15
+ }
16
+ }
17
+ return c > 3 && r && Object . defineProperty ( target , key , r ) , r ;
18
+ } ;
19
+
20
+ // For backward compatibility.
21
+ var __native = function ( thiz ) {
22
+ // we are setting the __container__ property to the base class when the super method is called
23
+ // if the constructor returns the __native(this) call we will use the old implementation
24
+ // copying all the properties to the result
25
+ // otherwise if we are using the result from the super() method call we won't need such logic
26
+ // as thiz already contains the parent properties
27
+ // this way we now support both implementations in typescript generated constructors:
28
+ // 1: super(); return __native(this);
29
+ // 2: return super() || this;
30
+ if ( thiz . __container__ ) {
31
+ var result = thiz . __proto__ ;
32
+
33
+ for ( var prop in thiz ) {
34
+ if ( thiz . hasOwnProperty ( prop ) ) {
35
+ thiz . __proto__ [ prop ] = thiz [ prop ] ;
36
+ delete thiz [ prop ] ;
37
+ }
38
+ }
39
+
40
+ thiz . constructor = undefined ;
41
+ thiz . __proto__ = undefined ;
42
+ Object . freeze ( thiz ) ;
43
+ Object . preventExtensions ( thiz ) ;
44
+ return result ;
45
+ } else {
46
+ return thiz ;
47
+ }
48
+ } ;
49
+
50
+ var __extends = function ( Child , Parent ) {
51
+ var extendNativeClass = ! ! Parent . extend && ( Parent . extend . toString ( ) . indexOf ( "[native code]" ) > - 1 ) ;
52
+ if ( ! extendNativeClass ) {
53
+ __extends_ts ( Child , Parent ) ;
54
+ return ;
55
+ }
56
+ if ( Parent . __isPrototypeImplementationObject ) {
57
+ throw new Error ( "Can not extend an already extended native object." ) ;
58
+ }
59
+
60
+ function extend ( thiz ) {
61
+ var child = thiz . __proto__ . __child ;
62
+ if ( ! child . __extended ) {
63
+ var parent = thiz . __proto__ . __parent ;
64
+ child . __extended = parent . extend ( child . name , child . prototype , true ) ;
65
+ // This will deal with "i instanceof child"
66
+ child [ Symbol . hasInstance ] = function ( instance ) {
67
+ return instance instanceof this . __extended ;
68
+ }
69
+ }
70
+ return child . __extended ;
71
+ } ;
72
+
73
+ Parent . __activityExtend = function ( parent , name , implementationObject ) {
74
+ __log ( "__activityExtend called" ) ;
75
+ return parent . extend ( name , implementationObject ) ;
76
+ } ;
77
+
78
+ Parent . call = function ( thiz ) {
79
+ var Extended = extend ( thiz ) ;
80
+ thiz . __container__ = true ;
81
+ if ( arguments . length > 1 ) {
82
+ thiz . __proto__ = new ( Function . prototype . bind . apply ( Extended , [ null ] . concat ( Array . prototype . slice . call ( arguments , 1 ) ) ) ) ;
83
+ }
84
+ else {
85
+ thiz . __proto__ = new Extended ( )
86
+ }
87
+ return thiz . __proto__ ;
88
+ } ;
89
+
90
+ Parent . apply = function ( thiz , args ) {
91
+ var Extended = extend ( thiz ) ;
92
+ thiz . __container__ = true ;
93
+ if ( args && args . length > 0 ) {
94
+ thiz . __proto__ = new ( Function . prototype . bind . apply ( Extended , [ null ] . concat ( args ) ) ) ;
95
+ }
96
+ else {
97
+ thiz . __proto__ = new Extended ( ) ;
98
+ }
99
+ return thiz . __proto__ ;
100
+ } ;
101
+ __extends_ns ( Child , Parent ) ;
102
+ Child . __isPrototypeImplementationObject = true ;
103
+ Child . __proto__ = Parent ;
104
+ Child . prototype . __parent = Parent ;
105
+ Child . prototype . __child = Child ;
106
+ }
107
+
108
+ var __extends_ts = function ( child , parent ) {
109
+ extendStaticFunctions ( child , parent ) ;
110
+ assignPrototypeFromParentToChild ( parent , child ) ;
111
+ } ;
112
+
113
+ var __extends_ns = function ( child , parent ) {
114
+ if ( ! parent . extend ) {
115
+ assignPropertiesFromParentToChild ( parent , child ) ;
116
+ }
117
+
118
+ assignPrototypeFromParentToChild ( parent , child ) ;
119
+ } ;
120
+
121
+ var extendStaticFunctions =
122
+ Object . setPrototypeOf
123
+ || ( hasInternalProtoProperty ( ) && function ( child , parent ) { child . __proto__ = parent ; } )
124
+ || assignPropertiesFromParentToChild ;
125
+
126
+ function hasInternalProtoProperty ( ) {
127
+ return { __proto__ : [ ] } instanceof Array ;
128
+ }
129
+
130
+ function assignPropertiesFromParentToChild ( parent , child ) {
131
+ for ( var property in parent ) {
132
+ if ( parent . hasOwnProperty ( property ) ) {
133
+ child [ property ] = parent [ property ] ;
134
+ }
135
+ }
136
+ }
137
+
138
+ function assignPrototypeFromParentToChild ( parent , child ) {
139
+ function __ ( ) {
140
+ this . constructor = child ;
141
+ }
142
+
143
+ if ( parent === null ) {
144
+ child . prototype = Object . create ( null ) ;
145
+ } else {
146
+ __ . prototype = parent . prototype ;
147
+ child . prototype = new __ ( ) ;
148
+ }
149
+ }
150
+
151
+
152
+ function JavaProxy ( className ) {
153
+ return function ( target ) {
154
+ var extended = target . extend ( className , target . prototype )
155
+ extended . name = className ;
156
+ return extended ;
157
+ } ;
158
+ }
159
+
160
+ function Interfaces ( interfacesArr ) {
161
+ return function ( target ) {
162
+ if ( interfacesArr instanceof Array ) {
163
+ // attach interfaces: [] to the object
164
+ target . prototype . interfaces = interfacesArr ;
165
+ }
166
+ }
167
+ }
168
+
169
+ Object . defineProperty ( global , "__native" , { value : __native } ) ;
170
+ Object . defineProperty ( global , "__extends" , { value : __extends } ) ;
171
+ Object . defineProperty ( global , "__decorate" , { value : __decorate } ) ;
172
+
173
+ global . JavaProxy = JavaProxy ;
174
+ global . Interfaces = Interfaces ;
175
+ } ) ( )
0 commit comments