1- ( function ( ) {
2- var __extends_ts = function ( d , b ) {
3- if ( ! b . extend ) {
4- for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ;
5- }
6-
7- function __ ( ) { this . constructor = d ; }
8- __ . prototype = b . prototype ;
9- d . prototype = new __ ( ) ;
10- } ;
1+ ( function ( ) {
112
123 var __decorate = ( this && this . __decorate ) || function ( decorators , target , key , desc ) {
134 var c = arguments . length ;
2718 } ;
2819
2920 // For backward compatibility.
30- var __native = function ( thiz ) {
31- // we are setting the __container__ property to the base class when the super method is called
32- // if the constructor returns the __native(this) call we will use the old implementation
33- // copying all the properties to the result
34- // otherwise if we are using the result from the super() method call we won't need such logic
35- // as thiz already contains the parent properties
36- // this way we now support both implementations in typescript generated constructors:
37- // 1: super(); return __native(this);
38- // 2: return super() || this;
39- if ( thiz . __container__ ) {
40- var result = thiz . __proto__ ;
41-
42- for ( var prop in thiz )
43- {
44- if ( thiz . hasOwnProperty ( prop ) )
45- {
46- thiz . __proto__ [ prop ] = thiz [ prop ] ;
47- delete thiz [ prop ] ;
48- }
49- }
50-
51- thiz . constructor = undefined ;
52- thiz . __proto__ = undefined ;
53- Object . freeze ( thiz ) ;
54- Object . preventExtensions ( thiz ) ;
55- return result ;
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 ;
5645 } else {
57- return thiz ;
46+ return thiz ;
5847 }
5948 } ;
6049
61- var __extends = function ( Child , Parent ) {
50+ var __extends = function ( Child , Parent ) {
51+ const NATIVE_CODE_REGEX = / \{ \s * \[ n a t i v e c o d e \] \s * \} / g;
52+ var extendNativeClass = ! ! Parent . extend && NATIVE_CODE_REGEX . test ( Parent . extend . toString ( ) ) ;
53+ if ( ! extendNativeClass ) {
54+ __extends_ts ( Child , Parent ) ;
55+ return ;
56+ }
57+ if ( Parent . __isPrototypeImplementationObject ) {
58+ throw new Error ( "Can not extend an already extended native object." ) ;
59+ }
6260
63- if ( Parent . extend ) {
64- if ( Parent . __isPrototypeImplementationObject ) {
65- throw new Error ( "Can not extend an already extended native object." ) ;
61+ function extend ( thiz ) {
62+ var child = thiz . __proto__ . __child ;
63+ if ( ! child . __extended ) {
64+ var parent = thiz . __proto__ . __parent ;
65+ child . __extended = parent . extend ( child . name , child . prototype , true ) ;
66+ // This will deal with "i instanceof child"
67+ child [ Symbol . hasInstance ] = function ( instance ) {
68+ return instance instanceof this . __extended ;
69+ }
6670 }
71+ return child . __extended ;
72+ } ;
6773
68- function extend ( thiz ) {
69- var child = thiz . __proto__ . __child ;
70- if ( ! child . __extended ) {
71- var parent = thiz . __proto__ . __parent ;
72- child . __extended = parent . extend ( child . name , child . prototype , true ) ;
73- // This will deal with "i instanceof child"
74- child [ Symbol . hasInstance ] = function ( instance ) {
75- return instance instanceof this . __extended ;
76- }
77- }
78- return child . __extended ;
79- } ;
80-
81- Parent . __activityExtend = function ( parent , name , implementationObject ) {
82- __log ( "__activityExtend called" ) ;
83- return parent . extend ( name , implementationObject ) ;
84- } ;
85-
86- Parent . call = function ( thiz ) {
87- var Extended = extend ( thiz ) ;
88- thiz . __container__ = true ;
89- if ( arguments . length > 1 )
90- {
91- thiz . __proto__ = new ( Function . prototype . bind . apply ( Extended , [ null ] . concat ( Array . prototype . slice . call ( arguments , 1 ) ) ) ) ;
92- }
93- else
94- {
95- thiz . __proto__ = new Extended ( )
96- }
97- return thiz . __proto__ ;
98- } ;
99-
100- Parent . apply = function ( thiz , args ) {
101- var Extended = extend ( thiz ) ;
102- thiz . __container__ = true ;
103- if ( args && args . length > 0 )
104- {
105- thiz . __proto__ = new ( Function . prototype . bind . apply ( Extended , [ null ] . concat ( args ) ) ) ;
106- }
107- else
108- {
109- thiz . __proto__ = new Extended ( ) ;
110- }
111- return thiz . __proto__ ;
112- } ;
74+ Parent . __activityExtend = function ( parent , name , implementationObject ) {
75+ __log ( "__activityExtend called" ) ;
76+ return parent . extend ( name , implementationObject ) ;
77+ } ;
78+
79+ Parent . call = function ( thiz ) {
80+ var Extended = extend ( thiz ) ;
81+ thiz . __container__ = true ;
82+ if ( arguments . length > 1 ) {
83+ thiz . __proto__ = new ( Function . prototype . bind . apply ( Extended , [ null ] . concat ( Array . prototype . slice . call ( arguments , 1 ) ) ) ) ;
84+ }
85+ else {
86+ thiz . __proto__ = new Extended ( )
87+ }
88+ return thiz . __proto__ ;
89+ } ;
90+
91+ Parent . apply = function ( thiz , args ) {
92+ var Extended = extend ( thiz ) ;
93+ thiz . __container__ = true ;
94+ if ( args && args . length > 0 ) {
95+ thiz . __proto__ = new ( Function . prototype . bind . apply ( Extended , [ null ] . concat ( args ) ) ) ;
96+ }
97+ else {
98+ thiz . __proto__ = new Extended ( ) ;
99+ }
100+ return thiz . __proto__ ;
101+ } ;
102+ __extends_ns ( Child , Parent ) ;
103+ Child . __isPrototypeImplementationObject = true ;
104+ Child . __proto__ = Parent ;
105+ Child . prototype . __parent = Parent ;
106+ Child . prototype . __child = Child ;
107+ }
108+
109+ var __extends_ts = function ( child , parent ) {
110+ extendStaticFunctions ( child , parent ) ;
111+ assignPrototypeFromParentToChild ( parent , child ) ;
112+ } ;
113+
114+ var __extends_ns = function ( child , parent ) {
115+ if ( ! parent . extend ) {
116+ assignPropertiesFromParentToChild ( parent , child ) ;
113117 }
114118
115- __extends_ts ( Child , Parent ) ;
119+ assignPrototypeFromParentToChild ( parent , child ) ;
120+ } ;
116121
122+ var extendStaticFunctions =
123+ Object . setPrototypeOf
124+ || ( hasInternalProtoProperty ( ) && function ( child , parent ) { child . __proto__ = parent ; } )
125+ || assignPropertiesFromParentToChild ;
117126
118- if ( Parent . extend ) {
119- Child . __isPrototypeImplementationObject = true ;
120- Child . __proto__ = Parent ;
121- Child . prototype . __parent = Parent ;
122- Child . prototype . __child = Child ;
127+ function hasInternalProtoProperty ( ) {
128+ return { __proto__ : [ ] } instanceof Array ;
129+ }
130+
131+ function assignPropertiesFromParentToChild ( parent , child ) {
132+ for ( var property in parent ) {
133+ if ( parent . hasOwnProperty ( property ) ) {
134+ child [ property ] = parent [ property ] ;
135+ }
123136 }
124137 }
125138
139+ function assignPrototypeFromParentToChild ( parent , child ) {
140+ function __ ( ) {
141+ this . constructor = child ;
142+ }
143+
144+ if ( parent === null ) {
145+ child . prototype = Object . create ( null ) ;
146+ } else {
147+ __ . prototype = parent . prototype ;
148+ child . prototype = new __ ( ) ;
149+ }
150+ }
151+
152+
126153 function JavaProxy ( className ) {
127154 return function ( target ) {
128155 var extended = target . extend ( className , target . prototype )
133160
134161 function Interfaces ( interfacesArr ) {
135162 return function ( target ) {
136- if ( interfacesArr instanceof Array ) {
163+ if ( interfacesArr instanceof Array ) {
137164 // attach interfaces: [] to the object
138165 target . prototype . interfaces = interfacesArr ;
139166 }
146173
147174 global . JavaProxy = JavaProxy ;
148175 global . Interfaces = Interfaces ;
149- } ) ( )
176+ } ) ( )
0 commit comments