Merge pull request #1179 from Mikunj/window-fix-2
Change back to old window syntax and add stubbing method.pull/1180/head
commit
50d27d1143
@ -0,0 +1,76 @@
|
|||||||
|
import { LocalizerType } from '../types/Util';
|
||||||
|
import LokiMessageAPI from '../../js/modules/loki_message_api';
|
||||||
|
import LokiPublicChatFactoryAPI from '../../js/modules/loki_public_chat_api';
|
||||||
|
import { LibsignalProtocol } from '../../libtextsecure/libsignal-protocol';
|
||||||
|
import { SignalInterface } from '../../js/modules/signal';
|
||||||
|
|
||||||
|
/*
|
||||||
|
We declare window stuff here instead of global.d.ts because we are importing other declarations.
|
||||||
|
If you import anything in global.d.ts, the type system won't work correctly.
|
||||||
|
*/
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
CONSTANTS: any;
|
||||||
|
ConversationController: any;
|
||||||
|
Events: any;
|
||||||
|
Lodash: any;
|
||||||
|
LokiAppDotNetServerAPI: any;
|
||||||
|
LokiFileServerAPI: any;
|
||||||
|
LokiPublicChatAPI: any;
|
||||||
|
LokiRssAPI: any;
|
||||||
|
LokiSnodeAPI: any;
|
||||||
|
MessageController: any;
|
||||||
|
SenderKeyAPI: any;
|
||||||
|
Session: any;
|
||||||
|
Signal: SignalInterface;
|
||||||
|
StringView: any;
|
||||||
|
StubAppDotNetApi: any;
|
||||||
|
StubMessageAPI: any;
|
||||||
|
WebAPI: any;
|
||||||
|
Whisper: any;
|
||||||
|
attemptConnection: any;
|
||||||
|
clearLocalData: any;
|
||||||
|
clipboard: any;
|
||||||
|
confirmationDialog: any;
|
||||||
|
dcodeIO: any;
|
||||||
|
deleteAccount: any;
|
||||||
|
displayNameRegex: any;
|
||||||
|
friends: any;
|
||||||
|
generateID: any;
|
||||||
|
getAccountManager: any;
|
||||||
|
getConversations: any;
|
||||||
|
getFriendsFromContacts: any;
|
||||||
|
getSettingValue: any;
|
||||||
|
i18n: LocalizerType;
|
||||||
|
libloki: any;
|
||||||
|
libsignal: LibsignalProtocol;
|
||||||
|
log: any;
|
||||||
|
lokiFeatureFlags: any;
|
||||||
|
lokiFileServerAPI: any;
|
||||||
|
lokiMessageAPI: LokiMessageAPI;
|
||||||
|
lokiPublicChatAPI: LokiPublicChatFactoryAPI;
|
||||||
|
mnemonic: any;
|
||||||
|
onLogin: any;
|
||||||
|
passwordUtil: any;
|
||||||
|
pushToast: any;
|
||||||
|
resetDatabase: any;
|
||||||
|
restart: any;
|
||||||
|
seedNodeList: any;
|
||||||
|
setPassword: any;
|
||||||
|
setSettingValue: any;
|
||||||
|
shortenPubkey: any;
|
||||||
|
showEditProfileDialog: any;
|
||||||
|
showPasswordDialog: any;
|
||||||
|
showQRDialog: any;
|
||||||
|
showSeedDialog: any;
|
||||||
|
storage: any;
|
||||||
|
textsecure: any;
|
||||||
|
toggleLinkPreview: any;
|
||||||
|
toggleMediaPermissions: any;
|
||||||
|
toggleMenuBar: any;
|
||||||
|
toggleSpellCheck: any;
|
||||||
|
toggleTheme: any;
|
||||||
|
userConfig: any;
|
||||||
|
versionInfo: any;
|
||||||
|
}
|
||||||
|
}
|
@ -1,142 +0,0 @@
|
|||||||
import { LocalizerType } from '../types/Util';
|
|
||||||
import LokiMessageAPI from '../../js/modules/loki_message_api';
|
|
||||||
import LokiPublicChatFactoryAPI from '../../js/modules/loki_public_chat_api';
|
|
||||||
import { LibsignalProtocol } from '../../libtextsecure/libsignal-protocol';
|
|
||||||
import { SignalInterface } from '../../js/modules/signal';
|
|
||||||
|
|
||||||
interface WindowInterface extends Window {
|
|
||||||
seedNodeList: any;
|
|
||||||
|
|
||||||
WebAPI: any;
|
|
||||||
LokiSnodeAPI: any;
|
|
||||||
SenderKeyAPI: any;
|
|
||||||
StubMessageAPI: any;
|
|
||||||
StubAppDotNetApi: any;
|
|
||||||
LokiPublicChatAPI: any;
|
|
||||||
LokiAppDotNetServerAPI: any;
|
|
||||||
LokiFileServerAPI: any;
|
|
||||||
LokiRssAPI: any;
|
|
||||||
|
|
||||||
CONSTANTS: any;
|
|
||||||
versionInfo: any;
|
|
||||||
|
|
||||||
Events: any;
|
|
||||||
Lodash: any;
|
|
||||||
clearLocalData: any;
|
|
||||||
getAccountManager: any;
|
|
||||||
getConversations: any;
|
|
||||||
getFriendsFromContacts: any;
|
|
||||||
mnemonic: any;
|
|
||||||
clipboard: any;
|
|
||||||
attemptConnection: any;
|
|
||||||
|
|
||||||
passwordUtil: any;
|
|
||||||
userConfig: any;
|
|
||||||
shortenPubkey: any;
|
|
||||||
|
|
||||||
dcodeIO: any;
|
|
||||||
libsignal: LibsignalProtocol;
|
|
||||||
libloki: any;
|
|
||||||
displayNameRegex: any;
|
|
||||||
|
|
||||||
Signal: SignalInterface;
|
|
||||||
Whisper: any;
|
|
||||||
ConversationController: any;
|
|
||||||
|
|
||||||
onLogin: any;
|
|
||||||
setPassword: any;
|
|
||||||
textsecure: any;
|
|
||||||
Session: any;
|
|
||||||
log: any;
|
|
||||||
i18n: LocalizerType;
|
|
||||||
friends: any;
|
|
||||||
generateID: any;
|
|
||||||
storage: any;
|
|
||||||
pushToast: any;
|
|
||||||
|
|
||||||
confirmationDialog: any;
|
|
||||||
showQRDialog: any;
|
|
||||||
showSeedDialog: any;
|
|
||||||
showPasswordDialog: any;
|
|
||||||
showEditProfileDialog: any;
|
|
||||||
|
|
||||||
deleteAccount: any;
|
|
||||||
|
|
||||||
toggleTheme: any;
|
|
||||||
toggleMenuBar: any;
|
|
||||||
toggleSpellCheck: any;
|
|
||||||
toggleLinkPreview: any;
|
|
||||||
toggleMediaPermissions: any;
|
|
||||||
|
|
||||||
getSettingValue: any;
|
|
||||||
setSettingValue: any;
|
|
||||||
lokiFeatureFlags: any;
|
|
||||||
|
|
||||||
resetDatabase: any;
|
|
||||||
|
|
||||||
lokiMessageAPI: LokiMessageAPI;
|
|
||||||
lokiPublicChatAPI: LokiPublicChatFactoryAPI;
|
|
||||||
}
|
|
||||||
|
|
||||||
// In the case for tests
|
|
||||||
// tslint:disable-next-line: no-typeof-undefined
|
|
||||||
if (typeof window === 'undefined') {
|
|
||||||
const globalAny: any = global;
|
|
||||||
globalAny.window = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
declare const window: WindowInterface;
|
|
||||||
|
|
||||||
// TODO: Is there an easier way to dynamically export these?
|
|
||||||
|
|
||||||
// Utilities
|
|
||||||
export const WebAPI = window.WebAPI;
|
|
||||||
export const Events = window.Events;
|
|
||||||
export const Signal = window.Signal;
|
|
||||||
export const Whisper = window.Whisper;
|
|
||||||
export const ConversationController = window.ConversationController;
|
|
||||||
export const passwordUtil = window.passwordUtil;
|
|
||||||
|
|
||||||
// Values
|
|
||||||
export const CONSTANTS = window.CONSTANTS;
|
|
||||||
export const versionInfo = window.versionInfo;
|
|
||||||
export const mnemonic = window.mnemonic;
|
|
||||||
export const lokiFeatureFlags = window.lokiFeatureFlags;
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
export const getAccountManager = window.getAccountManager;
|
|
||||||
export const getConversations = window.getConversations;
|
|
||||||
export const getFriendsFromContacts = window.getFriendsFromContacts;
|
|
||||||
export const getSettingValue = window.getSettingValue;
|
|
||||||
|
|
||||||
// Setters
|
|
||||||
export const setPassword = window.setPassword;
|
|
||||||
export const setSettingValue = window.setSettingValue;
|
|
||||||
|
|
||||||
// UI Events
|
|
||||||
export const pushToast = window.pushToast;
|
|
||||||
export const confirmationDialog = window.confirmationDialog;
|
|
||||||
|
|
||||||
export const showQRDialog = window.showQRDialog;
|
|
||||||
export const showSeedDialog = window.showSeedDialog;
|
|
||||||
export const showPasswordDialog = window.showPasswordDialog;
|
|
||||||
export const showEditProfileDialog = window.showEditProfileDialog;
|
|
||||||
|
|
||||||
export const toggleTheme = window.toggleTheme;
|
|
||||||
export const toggleMenuBar = window.toggleMenuBar;
|
|
||||||
export const toggleSpellCheck = window.toggleSpellCheck;
|
|
||||||
export const toggleLinkPreview = window.toggleLinkPreview;
|
|
||||||
export const toggleMediaPermissions = window.toggleMediaPermissions;
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
export const clearLocalData = window.clearLocalData;
|
|
||||||
export const deleteAccount = window.deleteAccount;
|
|
||||||
export const resetDatabase = window.resetDatabase;
|
|
||||||
export const attemptConnection = window.attemptConnection;
|
|
||||||
|
|
||||||
export const libloki = window.libloki;
|
|
||||||
export const libsignal = window.libsignal;
|
|
||||||
export const textsecure = window.textsecure;
|
|
||||||
|
|
||||||
export const lokiMessageAPI = window.lokiMessageAPI;
|
|
||||||
export const lokiPublicChatAPI = window.lokiPublicChatAPI;
|
|
Loading…
Reference in New Issue