-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathindex.ts
More file actions
47 lines (41 loc) · 1.37 KB
/
index.ts
File metadata and controls
47 lines (41 loc) · 1.37 KB
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
// polyfills
import { install } from 'react-native-quick-crypto';
install();
// TextEncoder/TextDecoder polyfill (required for jose)
import FastEncoder from 'react-native-fast-encoder';
class TextEncoderPolyfill {
encode(input: string): Uint8Array {
const encoder = new FastEncoder();
return encoder.encode(input);
}
}
class TextDecoderPolyfill {
private encoder: FastEncoder;
constructor(_encoding: string = 'utf-8') {
this.encoder = new FastEncoder(_encoding);
}
decode(input: Uint8Array): string {
return this.encoder.decode(input);
}
}
global.TextEncoder = TextEncoderPolyfill as unknown as typeof TextEncoder;
global.TextDecoder = TextDecoderPolyfill as unknown as typeof TextDecoder;
// structuredClone polyfill (required for jose)
if (typeof global.structuredClone === 'undefined') {
global.structuredClone = <T>(obj: T): T => JSON.parse(JSON.stringify(obj));
}
// event-target-shim
import 'event-target-polyfill';
// readable-stream
if (global.process == null) {
// @ts-expect-error - process is not defined
global.process = {};
}
if (global.process.version == null) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(global.process as any).version = 'v22.0.0';
}
import { AppRegistry } from 'react-native';
import App from './src/App';
import { name as appName } from './app.json';
AppRegistry.registerComponent(appName, () => App);