forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: Add
react-native-url-polyfill
.
React Native does have its own built-in polyfill for the URL Web API [1], but it's so minimal that it has some serious bugs, and a React Native maintainer has even recommended `react-native-url-polyfill` as an official workaround for one of those bugs [2]. Many thanks to charpeni for the changes [2] that allow RN v0.60 support! And for the changes from our own PR charpeni/whatwg-url#3, to avoid touching the Buffer global. This commit uses a release candidate version; there will likely be an official release soon. [1]: https://developer.mozilla.org/en-US/docs/Web/API/URL [2]: facebook/react-native#16434 (comment) [3]: charpeni/react-native-url-polyfill@d4e26ce#diff-375a2b7b7d929526f0dd58cd8bb8665b Fixes: zulip#4081
- Loading branch information
1 parent
203e6e7
commit 1587c03
Showing
4 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
declare module 'react-native-url-polyfill/js/URL' { | ||
import type { URLSearchParams } from 'react-native-url-polyfill/js/URLSearchParams'; | ||
|
||
// https://github.com/facebook/flow/blob/v0.98.0/lib/dom.js#L3765-L3783 | ||
declare export class URL { | ||
static createObjectURL(blob: Blob): string; | ||
static createObjectURL(mediaSource: MediaSource): string; | ||
static createFor(blob: Blob): string; | ||
static revokeObjectURL(url: string): void; | ||
constructor(url: string, base?: string | URL): void; | ||
hash: string; | ||
host: string; | ||
hostname: string; | ||
href: string; | ||
origin: string; // readonly | ||
password: string; | ||
pathname: string; | ||
port: string; | ||
protocol: string; | ||
search: string; | ||
searchParams: URLSearchParams; // readonly | ||
username: string; | ||
} | ||
} | ||
|
||
declare module 'react-native-url-polyfill/js/URLSearchParams' { | ||
// https://github.com/facebook/flow/blob/v0.98.0/lib/bom.js#L1000-L1013 | ||
declare export class URLSearchParams { | ||
@@iterator(): Iterator<[string, string]>; | ||
constructor( | ||
query?: string | URLSearchParams | Array<[string, string]> | { [string]: string }, | ||
): void; | ||
append(name: string, value: string): void; | ||
delete(name: string): void; | ||
entries(): Iterator<[string, string]>; | ||
forEach((value: string, name: string, params: URLSearchParams) => any, thisArg?: any): void; | ||
get(name: string): null | string; | ||
getAll(name: string): Array<string>; | ||
has(name: string): boolean; | ||
keys(): Iterator<string>; | ||
set(name: string, value: string): void; | ||
values(): Iterator<string>; | ||
} | ||
} | ||
|
||
// Filename aliases | ||
declare module 'react-native-url-polyfill/index' { | ||
declare module.exports: $Exports<'react-native-url-polyfill'>; | ||
} | ||
declare module 'react-native-url-polyfill/index.js' { | ||
declare module.exports: $Exports<'react-native-url-polyfill'>; | ||
} | ||
declare module 'react-native-url-polyfill/js/URL.js' { | ||
declare module.exports: $Exports<'react-native-url-polyfill/js/URL'>; | ||
} | ||
declare module 'react-native-url-polyfill/js/URLSearchParams.js' { | ||
declare module.exports: $Exports<'react-native-url-polyfill/js/URLSearchParams'>; | ||
} | ||
|
||
/** | ||
* This is an autogenerated libdef stub for: | ||
* | ||
* 'react-native-url-polyfill' | ||
* | ||
* Fill this stub out by replacing all the `any` types. | ||
* | ||
* Once filled out, we encourage you to share your work with the | ||
* community by sending a pull request to: | ||
* https://github.com/flowtype/flow-typed | ||
*/ | ||
|
||
declare module 'react-native-url-polyfill' { | ||
declare export * from 'react-native-url-polyfill/js/URL' | ||
declare export * from 'react-native-url-polyfill/js/URLSearchParams' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters