Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3508737
D6175.id20796.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6175.id20796.diff
View Options
diff --git a/desktop/package.json b/desktop/package.json
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -36,6 +36,7 @@
"electron": "^22.0.0",
"flow-bin": "^0.182.0",
"flow-typed": "^3.2.1",
+ "lib": "0.0.1",
"fs-extra": "^10.1.0",
"klaw": "^4.0.1"
}
diff --git a/desktop/src/preload.js b/desktop/src/preload.js
--- a/desktop/src/preload.js
+++ b/desktop/src/preload.js
@@ -2,7 +2,9 @@
import { contextBridge, ipcRenderer } from 'electron';
-const bridge = {
+import type { ElectronBridge } from 'lib/types/electron-types';
+
+const bridge: ElectronBridge = {
onNavigate: callback => {
const withEvent = (event, ...args) => callback(...args);
ipcRenderer.on('on-navigate', withEvent);
diff --git a/lib/types/electron-types.js b/lib/types/electron-types.js
new file mode 100644
--- /dev/null
+++ b/lib/types/electron-types.js
@@ -0,0 +1,14 @@
+// @flow
+
+type OnNavigateListener = ({
+ +canGoBack: boolean,
+ +canGoForward: boolean,
+}) => void;
+
+export type ElectronBridge = {
+ // Returns a callback that you can call to remove the listener
+ +onNavigate: OnNavigateListener => () => void,
+ +clearHistory: () => void,
+ +doubleClickTopBar: () => void,
+ +setBadge: (number | string | null) => void,
+};
diff --git a/web/electron.js b/web/electron.js
--- a/web/electron.js
+++ b/web/electron.js
@@ -1,21 +1,10 @@
// @flow
-type ElectronContextBridge = {
- // Returns a callback that you can call to remove the listener
- +onNavigate: OnNavigateListener => () => void,
- +clearHistory: () => void,
- +doubleClickTopBar: () => void,
- +setBadge: (value: string | number | null) => void,
-};
+import type { ElectronBridge } from 'lib/types/electron-types';
-type OnNavigateListener = ({
- +canGoBack: boolean,
- +canGoForward: boolean,
-}) => void;
+declare var electronContextBridge: void | ElectronBridge;
-declare var electronContextBridge: ?ElectronContextBridge;
-
-const electron: null | ElectronContextBridge =
+const electron: ?ElectronBridge =
typeof electronContextBridge === 'undefined' ? null : electronContextBridge;
export default electron;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 11:43 PM (20 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2689733
Default Alt Text
D6175.id20796.diff (2 KB)
Attached To
Mode
D6175: [desktop] Type bridge object between desktop and web
Attached
Detach File
Event Timeline
Log In to Comment