forked from tutao/tutanota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.d.ts
57 lines (50 loc) · 1.67 KB
/
global.d.ts
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
/**
* This file is used for *monkey-patching* existing declarations. Don't use it to declare global variables.
*/
import {Logger} from "./api/common/Logger";
import Mithril from "mithril";
import {LanguageViewModel} from "./misc/LanguageViewModel";
import {ClientDetector} from "./misc/ClientDetector";
import {RootView} from "./RootView";
import {LoginController} from "./api/main/LoginController";
import {IMainLocator} from "./api/main/MainLocator";
import {WhitelabelCustomizations} from "./misc/WhitelabelCustomizations";
import {WorkerLocatorType} from "./api/worker/WorkerLocator"
interface NativeApp {
// In desktop we can pass whole objects
// In app, we can only pass strings
invoke(message: any)
attach(handler: (JsMessage) => unknown),
startWebMessageChannel() // Available in android
}
type Tutao = {
currentView,
m: typeof Mithril,
lang: LanguageViewModel,
client: ClientDetector,
root: RootView,
logins: LoginController,
locator: IMainLocator | null,
nativeApp?, // Will either be IosNativeTransport or null
appState?,
}
// Monkey-patch Window.
// see https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html
declare global {
interface Window {
tutao: Tutao,
logger: Logger,
/** Set by the server for whitelabel domains. */
whitelabelCustomizations: WhitelabelCustomizations | undefined,
/** The NativeApp for use in the main client */
nativeApp: NativeApp,
/**
* The NativeApp for use in web dialogs.
* It's existence can be used to determine whether or not we are inside a web dialog
* */
nativeAppWebDialog: NativeApp | undefined,
}
interface WorkerGlobalScope {
locator: WorkerLocatorType
}
}