@@ -10,7 +10,7 @@ function randomId() {
1010let listeners = { } ;
1111const Bridge = {
1212 on ( type , callback ) {
13- if ( typeof type != "string" || ! ( callback instanceof Function ) ) {
13+ if ( typeof type !== "string" || ! ( callback instanceof Function ) ) {
1414 throw "`type` must be a string and `callback` must be a function." ;
1515 }
1616
@@ -56,9 +56,9 @@ const Bridge = {
5656 } ,
5757 set ( val ) {
5858 proxy [ field ] = val ;
59- }
59+ } ,
6060 } ;
61- }
61+ } ,
6262 } ,
6363
6464 __internal : {
@@ -67,24 +67,28 @@ const Bridge = {
6767 defineFunction ( name ) {
6868 Object . defineProperty ( object , name , {
6969 value : function ( ) {
70- return Bridge . __internal . invoke ( id , name , Array . from ( arguments ) ) ;
71- }
70+ return Bridge . __internal . invoke (
71+ id ,
72+ name ,
73+ Array . from ( arguments )
74+ ) ;
75+ } ,
7276 } ) ;
7377 } ,
7478
7579 defineProperty ( name ) {
7680 Object . defineProperty ( object , name , {
7781 value : null ,
7882 writable : true ,
79- configurable : true
83+ configurable : true ,
8084 } ) ;
81- }
82- }
85+ } ,
86+ } ,
8387 } ;
8488
8589 const handler = {
8690 get ( obj , property ) {
87- if ( typeof obj [ property ] != "undefined" && obj [ property ] != null ) {
91+ if ( typeof obj [ property ] !== "undefined" && obj [ property ] != = null ) {
8892 return obj [ property ] ;
8993 }
9094
@@ -93,8 +97,8 @@ const Bridge = {
9397 set ( obj , property , value ) {
9498 Bridge . __internal . set ( id , property , value ) ;
9599 return value ;
96- }
97- }
100+ } ,
101+ } ;
98102
99103 Object . freeze ( object . __stores ) ;
100104 Object . freeze ( object . __internal ) ;
@@ -109,7 +113,7 @@ const Bridge = {
109113 Object . defineProperty ( root , propertyName , {
110114 value : proxy ,
111115 writable : true ,
112- configurable : true
116+ configurable : true ,
113117 } ) ;
114118 } ,
115119
@@ -118,7 +122,11 @@ const Bridge = {
118122 } ,
119123
120124 set ( id , property , newValue ) {
121- return Bridge . __internal . sendMessageToJava ( "SET" , { id, property, newValue } ) ;
125+ return Bridge . __internal . sendMessageToJava ( "SET" , {
126+ id,
127+ property,
128+ newValue,
129+ } ) ;
122130 } ,
123131
124132 mutate ( id , property , callback ) {
@@ -129,7 +137,11 @@ const Bridge = {
129137 } ,
130138
131139 invoke ( id , func , arguments ) {
132- return Bridge . __internal . sendMessageToJava ( "INVOKE" , { id, "function" : func , arguments } ) ;
140+ return Bridge . __internal . sendMessageToJava ( "INVOKE" , {
141+ id,
142+ function : func ,
143+ arguments,
144+ } ) ;
133145 } ,
134146
135147 broadcast ( type , data ) {
@@ -140,7 +152,10 @@ const Bridge = {
140152 try {
141153 callback ( type . toLowerCase ( ) , data ) ;
142154 } catch ( e ) {
143- console . error ( "[Webview-Bridge]" , "A listener produced an exception: " ) ;
155+ console . error (
156+ "[Webview-Bridge]" ,
157+ "A listener produced an exception: "
158+ ) ;
144159 console . error ( e ) ;
145160 }
146161 } ) ;
@@ -153,22 +168,24 @@ const Bridge = {
153168 try {
154169 callback ( data ) ;
155170 } catch ( e ) {
156- console . error ( "[Webview-Bridge]" , "A listener produced an exception: " ) ;
171+ console . error (
172+ "[Webview-Bridge]" ,
173+ "A listener produced an exception: "
174+ ) ;
157175 console . error ( e ) ;
158176 }
159177 } ) ;
160178 }
161- }
162- }
179+ } ,
180+ } ,
163181} ;
164182
165-
166183Object . freeze ( Bridge ) ;
167184Object . freeze ( Bridge . __internal ) ;
168185Object . defineProperty ( window , "Bridge" , {
169186 value : Bridge ,
170187 writable : false ,
171- configurable : false
188+ configurable : false ,
172189} ) ;
173190
174191console . log ( "[Webview-Bridge]" , "Injected bridge script." ) ;
0 commit comments