Skip to content

Commit 273a1ad

Browse files
author
Vladimir Enchev
committed
replace current fetch with github fetch
1 parent ff4f9d4 commit 273a1ad

File tree

8 files changed

+92
-1161
lines changed

8 files changed

+92
-1161
lines changed

CrossPlatformModules.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,7 @@
288288
</TypeScriptCompile>
289289
<TypeScriptCompile Include="es-collections.d.ts" />
290290
<TypeScriptCompile Include="es6-promise.d.ts" />
291-
<TypeScriptCompile Include="fetch\body.ts" />
292-
<TypeScriptCompile Include="fetch\fetch.ts" />
293-
<TypeScriptCompile Include="fetch\headers.ts" />
294-
<TypeScriptCompile Include="fetch\webidl.d.ts" />
291+
<TypeScriptCompile Include="fetch\fetch.d.ts" />
295292
<TypeScriptCompile Include="file-system\file-name-resolver.d.ts" />
296293
<TypeScriptCompile Include="file-system\file-name-resolver.ts">
297294
<DependentUpon>file-name-resolver.d.ts</DependentUpon>
@@ -813,6 +810,7 @@
813810
<Content Include="apps\ui-tests-app\pages\text\label.xml" />
814811
<Content Include="apps\ui-tests-app\pages\text\button.xml" />
815812
<Content Include="apps\ui-tests-app\web-view\webview.xml" />
813+
<Content Include="fetch\fetch.js" />
816814
<Content Include="js-libs\reworkcss-value\reworkcss-value.js" />
817815
<Content Include="ui\layouts\stack-layout\package.json">
818816
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

fetch/body.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

fetch/fetch.d.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Type definitions for fetch API
2+
// Project: https://github.com/github/fetch
3+
// Definitions by: Ryan Graham <https://github.com/ryan-codingintrigue>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
/// <reference path="../es6-promise.d.ts" />
7+
8+
declare module "fetch" {
9+
10+
class Request {
11+
constructor(input: string|Request, init?: RequestInit);
12+
method: string;
13+
url: string;
14+
headers: Headers;
15+
context: RequestContext;
16+
referrer: string;
17+
mode: RequestMode;
18+
credentials: RequestCredentials;
19+
cache: RequestCache;
20+
}
21+
22+
interface RequestInit {
23+
method?: string;
24+
headers?: HeaderInit|{ [index: string]: string };
25+
body?: BodyInit;
26+
mode?: RequestMode;
27+
credentials?: RequestCredentials;
28+
cache?: RequestCache;
29+
}
30+
31+
enum RequestContext {
32+
"audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch",
33+
"font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import",
34+
"internal", "location", "manifest", "object", "ping", "plugin", "prefetch", "script",
35+
"serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker",
36+
"xmlhttprequest", "xslt"
37+
}
38+
39+
enum RequestMode { "same-origin", "no-cors", "cors" }
40+
enum RequestCredentials { "omit", "same-origin", "include" }
41+
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" }
42+
43+
class Headers {
44+
append(name: string, value: string): void;
45+
delete(name: string): void;
46+
get(name: string): string;
47+
getAll(name: string): Array<string>;
48+
has(name: string): boolean;
49+
set(name: string, value: string): void;
50+
}
51+
52+
class Body {
53+
bodyUsed: boolean;
54+
arrayBuffer(): Promise<ArrayBuffer>;
55+
blob(): Promise<Blob>;
56+
formData(): Promise<FormData>;
57+
json(): Promise<any>;
58+
text(): Promise<string>;
59+
}
60+
61+
class Response extends Body {
62+
constructor(body?: BodyInit, init?: ResponseInit);
63+
error(): Response;
64+
redirect(url: string, status: number): Response;
65+
type: ResponseType;
66+
url: string;
67+
status: number;
68+
ok: boolean;
69+
statusText: string;
70+
headers: Headers;
71+
clone(): Response;
72+
}
73+
74+
enum ResponseType { "basic", "cors", "default", "error", "opaque" }
75+
76+
class ResponseInit {
77+
status: number;
78+
statusText: string;
79+
headers: HeaderInit;
80+
}
81+
82+
type HeaderInit = Headers|Array<string>;
83+
type BodyInit = Blob|FormData|string;
84+
type RequestInfo = Request|string;
85+
86+
function fetch(url: string, init?: RequestInit): Promise<Response>;
87+
}

0 commit comments

Comments
 (0)