2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-10-06 16:16:51 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import { contextBridge, ipcRenderer } from 'electron';
|
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
import { SignalContext } from '../context';
|
2021-10-06 16:16:51 +00:00
|
|
|
import { DebugLogWindow } from '../../components/DebugLogWindow';
|
|
|
|
import * as debugLog from '../../logging/debuglogs';
|
2022-01-11 20:02:46 +00:00
|
|
|
import { upload } from '../../logging/uploadDebugLog';
|
|
|
|
import * as logger from '../../logging/log';
|
2021-10-06 16:16:51 +00:00
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
contextBridge.exposeInMainWorld('SignalContext', {
|
|
|
|
...SignalContext,
|
2021-10-06 16:16:51 +00:00
|
|
|
renderWindow: () => {
|
2021-10-07 23:28:47 +00:00
|
|
|
const environmentText: Array<string> = [SignalContext.getEnvironment()];
|
2021-10-06 16:16:51 +00:00
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
const appInstance = SignalContext.getAppInstance();
|
2021-10-06 16:16:51 +00:00
|
|
|
if (appInstance) {
|
|
|
|
environmentText.push(appInstance);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
React.createElement(DebugLogWindow, {
|
2022-07-05 16:44:53 +00:00
|
|
|
hasCustomTitleBar: SignalContext.OS.hasCustomTitleBar(),
|
2022-06-08 22:00:32 +00:00
|
|
|
executeMenuRole: SignalContext.executeMenuRole,
|
|
|
|
closeWindow: () => SignalContext.executeMenuRole('close'),
|
2021-10-06 16:16:51 +00:00
|
|
|
downloadLog: (logText: string) =>
|
|
|
|
ipcRenderer.send('show-debug-log-save-dialog', logText),
|
2021-10-07 23:28:47 +00:00
|
|
|
i18n: SignalContext.i18n,
|
2021-10-06 16:16:51 +00:00
|
|
|
fetchLogs() {
|
|
|
|
return debugLog.fetch(
|
2021-10-07 23:28:47 +00:00
|
|
|
SignalContext.getNodeVersion(),
|
|
|
|
SignalContext.getVersion()
|
2021-10-06 16:16:51 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
uploadLogs(logs: string) {
|
2022-01-11 20:02:46 +00:00
|
|
|
return upload({
|
|
|
|
content: logs,
|
|
|
|
appVersion: SignalContext.getVersion(),
|
|
|
|
logger,
|
|
|
|
});
|
2021-10-06 16:16:51 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
document.getElementById('app')
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|