14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
+ gi
18
+ export enum EventType {
19
+ OPEN = 'open' ,
20
+ CLOSE = 'close' ,
21
+ ERROR = 'error' ,
22
+ MESSAGE = 'message' ,
23
+ COMPLETE = 'complete'
24
+ }
17
25
18
- // TODO(mikelehen): Flesh out proper types (or figure out how to generate via
19
- // clutz or something).
20
- export class XhrIo { }
21
- export const ErrorCode : any ;
22
- export const EventType : any ;
23
26
export namespace WebChannel {
24
- export type EventType = any ;
25
- export const EventType : any ;
27
+ export enum EventType {
28
+ OPEN = 'open' ,
29
+ CLOSE = 'close' ,
30
+ ERROR = 'error' ,
31
+ MESSAGE = 'message' ,
32
+ COMPLETE = 'complete'
33
+ }
34
+ }
35
+
36
+ export enum ErrorCode {
37
+ NO_ERROR = 0 ,
38
+ ACCESS_DENIED ,
39
+ FILE_NOT_FOUND ,
40
+ FF_SILENT_ERROR ,
41
+ CUSTOM_ERROR ,
42
+ EXCEPTION ,
43
+ HTTP_ERROR ,
44
+ ABORT ,
45
+ TIMEOUT ,
46
+ OFFLINE
47
+ }
48
+
49
+ export interface Headers {
50
+ [ name : string ] : string | number ;
51
+ }
52
+
53
+ export class XhrIo {
54
+ send (
55
+ url : string ,
56
+ method ?: string ,
57
+ body ?: ArrayBufferView | Blob | string | null ,
58
+ headers ?: Headers ,
59
+ timeoutInterval ?: number
60
+ ) : Promise < XhrIo > ;
61
+
62
+ getLastErrorCode ( ) : ErrorCode ;
63
+
64
+ getLastError ( ) : string ;
65
+
66
+ getStatus ( ) : number ;
67
+
68
+ getResponseText ( ) : string ;
69
+
70
+ getResponseJson ( ) : Object | any ;
71
+
72
+ abort ( ) : void ;
73
+
74
+ getResponseHeader ( header : string ) : { [ key : string ] : string } ;
75
+
76
+ listenOnce < T > ( type : EventType , cb : ( param : T ) => void ) : void ;
26
77
}
27
78
28
79
type StringMap = { [ key : string ] : string } ;
@@ -31,7 +82,9 @@ export interface WebChannelOptions {
31
82
messageHeaders ?: StringMap ;
32
83
initMessageHeaders ?: StringMap ;
33
84
messageContentType ?: string ;
34
- messageUrlParams ?: StringMap ;
85
+ messageUrlParams ?: {
86
+ database ?: string ;
87
+ } ;
35
88
clientProtocolHeaderRequired ?: boolean ;
36
89
concurrentRequestLimit ?: number ;
37
90
supportsCrossDomainXhr ?: boolean ;
@@ -44,13 +97,23 @@ export interface WebChannelOptions {
44
97
fastHandshake ?: boolean ;
45
98
disableRedac ?: boolean ;
46
99
clientProfile ?: string ;
47
- internalChannelParams ?: { [ key : string ] : boolean | number } ;
100
+ internalChannelParams ?: {
101
+ forwardChannelRequestTimeoutMs ?: number ;
102
+ } ;
48
103
xmlHttpFactory ?: unknown ;
49
104
requestRefreshThresholds ?: { [ key : string ] : number } ;
50
105
}
51
106
107
+ export interface WebChannel {
108
+ open ( ) : void ;
109
+ close ( ) : void ;
110
+ halfClose ( ) : void ;
111
+ listen < T > ( type : EventType , cb : ( param : T ) => void ) : void ;
112
+ send < T > ( msg : T ) : void ;
113
+ }
114
+
52
115
export interface WebChannelTransport {
53
- createWebChannel ( url : string , options : WebChannelOptions ) : any ;
116
+ createWebChannel ( url : string , options : WebChannelOptions ) : WebChannel ;
54
117
}
55
118
56
119
export function createWebChannelTransport ( ) : WebChannelTransport ;
0 commit comments