chore: cleanup reexports

This commit is contained in:
Nathan Walker
2020-07-05 14:53:34 -07:00
parent 1525c89733
commit 8f2900ad0b
306 changed files with 1197 additions and 1534 deletions

View File

@@ -5,7 +5,7 @@ import * as platformModule from "../../platform";
import * as fsModule from "../../file-system";
import { getFilenameFromUrl } from "./http-request-common";
import { NetworkAgent } from "../../debugger/debugger";
import { NetworkAgent } from "../../debugger";
export enum HttpResponseEncoding {
UTF8,

View File

@@ -4,7 +4,7 @@ import * as imageSourceModule from "../../image-source";
import * as fsModule from "../../file-system";
import * as types from "../../utils/types";
import * as domainDebugger from "../../debugger/debugger";
import * as domainDebugger from "../../debugger";
import { getFilenameFromUrl } from "./http-request-common";
export enum HttpResponseEncoding {

View File

@@ -1,6 +0,0 @@
{
"name": "http-request",
"main": "http-request",
"types": "http-request.d.ts",
"nativescript": {}
}

View File

@@ -1,7 +1,105 @@
import { ImageSource } from "../image-source";
import { File } from "../file-system";
import * as httpRequest from "./http-request";
export * from "./http-request";
/**
* Provides options for the http requests.
*/
export interface HttpRequestOptions {
/**
* Gets or sets the request url.
*/
url: string;
/**
* Gets or sets the request method.
*/
method: string;
/**
* Gets or sets the request headers in JSON format.
*/
headers?: any;
/**
* Gets or sets the request body.
*/
content?: string | FormData | ArrayBuffer;
/**
* Gets or sets the request timeout in milliseconds.
*/
timeout?: number;
/**
* Gets or sets wether to *not* follow server's redirection responses.
*/
dontFollowRedirects?: boolean;
}
/**
* Encapsulates HTTP-response information from an HTTP-request.
*/
export interface HttpResponse {
/**
* Gets the response status code.
*/
statusCode: number;
/**
* Gets the response headers.
*/
headers: Headers;
/**
* Gets the response content.
*/
content?: HttpContent;
}
export type Headers = { [key: string]: string | string[] };
export enum HttpResponseEncoding {
UTF8,
GBK
}
/**
* Encapsulates the content of an HttpResponse.
*/
export interface HttpContent {
/**
* Gets the response body as raw data.
*/
raw: any;
/**
* Gets the response body as ArrayBuffer
*/
toArrayBuffer: () => ArrayBuffer;
/**
* Gets the response body as string.
*/
toString: (encoding?: HttpResponseEncoding) => string;
/**
* Gets the response body as JSON object.
*/
toJSON: (encoding?: HttpResponseEncoding) => any;
/**
* Gets the response body as ImageSource.
*/
toImage: () => Promise<ImageSource>;
/**
* Gets the response body as file.
*/
toFile: (destinationFilePath?: string) => File;
}
export function getString(arg: any): Promise<string> {
return new Promise<string>((resolve, reject) => {
httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)

View File

@@ -1,6 +0,0 @@
{
"name": "http",
"main": "http",
"types": "http.d.ts",
"nativescript": {}
}