This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresponse-body-view.d.ts
230 lines (193 loc) · 6.38 KB
/
response-body-view.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/**
* DO NOT EDIT
*
* This file was automatically generated by
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
*
* To modify these typings, edit the source file(s):
* response-body-view.js
*/
// tslint:disable:variable-name Describing an API that's defined elsewhere.
// tslint:disable:no-any describes the API as best we are able today
import {html, css, LitElement} from 'lit-element';
export {ResponseBodyView};
declare namespace UiElements {
/**
* An element to display a HTTP response body.
*
* The element will try to select best view for given `contentType`. It will
* choose the JSON viewer for JSON response and XML viewer for XML responses.
* Otherise it will display a syntax hagligter.
*
* Note that the `contentType` property **must** be set in order to display any
* view.
*
* ### Save content to file
*
* The element uses the web way of file saving. However, it sends the
* `export-data` custom event first to check if hosting application implements
* other save functionality. See event description for more information.
*/
class ResponseBodyView extends LitElement {
/**
* Raw response as a response text.
*/
responseText: String|ArrayBuffer|Buffer|object|null;
/**
* When set it opens the "raw" view.
*/
rawView: boolean|null|undefined;
/**
* If set it opens the JSON table view.
*/
jsonTableView: boolean|null|undefined;
/**
* The response content type.
*/
contentType: string|null|undefined;
/**
* A variable to be set after the `responseText` change
*/
_raw: string|null|undefined;
/**
* Current value of charset encoding, if available.
* It should be set to correctly decode buffer to string
*/
charset: string|null|undefined;
/**
* Computed value, true if the parsed view can be displayed.
* If false then the syntax highligter will be removed from the DOM
* so it will not try to do the parsing job if it is not necessary.
*/
_isParsed: boolean|null|undefined;
/**
* Computed value, true if the JSON view can be displayed.
* If false then the syntax highligter will be removed from the DOM
* so it will not try to do the parsing job if it is not necessary.
*/
_isJson: boolean|null|undefined;
/**
* Selected view.
*/
activeView: number|null|undefined;
/**
* When saving a file this will be the download URL created by the
* `URL.createObjectURL` function.
*/
_downloadFileUrl: string|null|undefined;
/**
* Autogenerated file name for the download file.
*/
_downloadFileName: string|null|undefined;
/**
* When true then the text in "raw" preview will be wrapped.
*/
rawTextWrap: boolean|null|undefined;
/**
* Enables Anypoint compatibility
*/
compatibility: boolean|null|undefined;
_imageDataUrl: string|null|undefined;
constructor();
connectedCallback(): void;
disconnectedCallback(): void;
render(): any;
_activeTemplate(activeView: any, content: any): any;
_downloadTemplate(): any;
_imageTemplate(): any;
_pdfTemplate(): any;
/**
* Set's `_raw` property that it propagated to current viewer.
* The operation is async for performance reasons.
*/
_responseTextChanged(payload: String|null): void;
/**
* Updates `activeView` property based on `contentType` value.
*
* @param contentType Current content type of the response
*/
_contentTypeChanged(contentType: String|null): void;
/**
* Converts current `_raw` data to an image data URL string.
*
* @param contentType Response content type
* @returns Procerssed image data or undefined when error.
*/
_prepareImageDataUrl(contentType: String|null, raw: Buffer|ArrayBuffer|null): String|null|undefined;
/**
* When response's content type is JSON the view renders the
* JSON table element. This function reads current state for the table
* (if it is turned on) and handles view change if needed.
*/
_ensureJsonTable(): void;
/**
* The component may work in Electron app where Buffer can be returned from
* the transport library. This ensures that string is always returned.
*
* @returns String value of `_raw` property
*/
_getRawContent(): String|null;
/**
* Coppies current response text value to clipboard.
*/
_copyToClipboard(e: Event|null): void;
_resetCopyButtonState(button: any): void;
/**
* Fires the `export-data` custom event. If the event is not canceled
* then it will use default web implementation for file saving.
*/
_saveFile(): void;
/**
* Creates a file object form current response text and opens a dialog
* with the link to a file.
*/
saveToFile(data: String|ArrayBuffer|null, fileName: String|null): void;
/**
* Creates file extension name based on current content type.
*
* @returns A file extension. `txt` as default
*/
_fileExtension(): String|null;
/**
* @returns content pre-processed for export.
*/
_exportContent(): String|ArrayBuffer|Buffer|null;
/**
* Handler for download link click to prevent default and close the dialog.
*/
_downloadHandler(): void;
/**
* Handler for file download dialog close.
*/
_downloadDialogClose(): void;
/**
* Toggles "view source" or raw message view.
*/
_toggleViewSource(opened: Boolean|null): void;
/**
* Handler for the `jsonTableView` property change.
*/
_jsonTableViewChanged(state: any): void;
/**
* Updates the value of the `jsonTableView` property when the
* corresponding localStorage property change.
*/
_onStorageChanged(e: StorageEvent|null): void;
/**
* Reads the local value (always a string) as a boolean value.
*
* @param value The value read from the local storage.
* @returns Boolean value read from the value.
*/
_localStorageValueToBoolean(value: String|null): Boolean|null;
_onJsonTableStateChanged(e: any): void;
_sourceViewHandler(e: any): void;
_jsonTableViewHandler(e: any): void;
_rawTextWrapViewHandler(e: any): void;
}
}
declare global {
interface HTMLElementTagNameMap {
"response-body-view": UiElements.ResponseBodyView;
}
}