forked from GaloyMoney/blink-mobile
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
118 lines (99 loc) · 3.19 KB
/
index.js
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
// This is the first file that ReactNative will run when it starts up.
//
// We jump out of here immediately and into our main entry point instead.
//
// It is possible to have React Native load our main module first, but we'd have to
// change that in both AppDelegate.m and MainApplication.java. This would have the
// side effect of breaking other tooling like mobile-center and react-native-rename.
//
// It's easier just to leave it here.
import "react-native-get-random-values"
import { TextEncoder, TextDecoder } from "@sinonjs/text-encoding"
import { AppRegistry, LogBox, TextInput, Text } from "react-native"
import { App } from "./app/app.tsx"
import * as React from "react"
// Override Text scaling
if (Text.defaultProps) {
Text.defaultProps.allowFontScaling = false
} else {
Text.defaultProps = {}
Text.defaultProps.allowFontScaling = false
}
// Override Text scaling in input fields
if (TextInput.defaultProps) {
TextInput.defaultProps.allowFontScaling = false
} else {
TextInput.defaultProps = {}
TextInput.defaultProps.allowFontScaling = false
}
class MessageChannel {
constructor() {
this.port1 = new MessagePort()
this.port2 = new MessagePort()
this.port1.setOtherPort(this.port2)
this.port2.setOtherPort(this.port1)
}
}
class MessagePort {
constructor() {
this.otherPort = null
this.listeners = new Map()
}
setOtherPort(otherPort) {
this.otherPort = otherPort
}
addEventListener(event, listener) {
if (!this.listeners.has(event)) {
this.listeners.set(event, [])
}
this.listeners.get(event).push(listener)
}
removeEventListener(event, listener) {
const eventListeners = this.listeners.get(event)
if (eventListeners) {
const index = eventListeners.indexOf(listener)
if (index !== -1) {
eventListeners.splice(index, 1)
}
}
}
postMessage(data) {
this.otherPort.dispatchEvent("message", { data })
}
start() {
// No-op in React Native
}
dispatchEvent(event, data) {
const eventListeners = this.listeners.get(event)
if (eventListeners) {
eventListeners.forEach((listener) => listener(data))
}
}
}
global.MessageChannel = MessageChannel
if (typeof global.TextEncoder === "undefined") {
global.TextEncoder = TextEncoder
}
if (typeof global.TextDecoder === "undefined") {
global.TextDecoder = TextDecoder
}
const ignoreLogs = [
/Non-serializable values were found in the navigation state. Check:\s*sendBitcoinDetails/, // SendBitcoin navigation values are not serializable to prevent boiler plate serialization and deserialization across the flow.
]
LogBox.ignoreLogs(ignoreLogs)
/**
* This needs to match what's found in your app_delegate.m and MainActivity.java.
*/
const APP_NAME = "LNFlash"
// Should we show storybook instead of our app?
//
// ⚠️ Leave this as `false` when checking into git.
const SHOW_STORYBOOK = false
let RootComponent = () => <App />
if (__DEV__ && SHOW_STORYBOOK) {
// Only include Storybook if we're in dev mode
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { StorybookUIRoot } = require("./.storybook/index.ts")
RootComponent = StorybookUIRoot
}
AppRegistry.registerComponent(APP_NAME, () => RootComponent)