signal-desktop/ts/windows/about/preload.ts

46 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-06-23 19:15:27 +00:00
// Copyright 2018-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2022-06-23 19:15:27 +00:00
// This has to be the first import because of monkey-patching
import '../shims';
import React from 'react';
import ReactDOM from 'react-dom';
import { contextBridge } from 'electron';
import { SignalContext } from '../context';
import { About } from '../../components/About';
contextBridge.exposeInMainWorld('SignalContext', {
...SignalContext,
renderWindow: () => {
const environmentText: Array<string> = [SignalContext.getEnvironment()];
const appInstance = SignalContext.getAppInstance();
if (appInstance) {
environmentText.push(appInstance);
}
2021-12-13 23:04:29 +00:00
let platform = '';
if (process.platform === 'darwin') {
if (process.arch === 'arm64') {
platform = ' (M1)';
} else {
platform = ' (Intel)';
}
}
ReactDOM.render(
React.createElement(About, {
closeAbout: () => SignalContext.executeMenuRole('close'),
2021-12-13 23:04:29 +00:00
environment: `${environmentText.join(' - ')}${platform}`,
i18n: SignalContext.i18n,
version: SignalContext.getVersion(),
2022-07-05 16:44:53 +00:00
hasCustomTitleBar: SignalContext.OS.hasCustomTitleBar(),
executeMenuRole: SignalContext.executeMenuRole,
}),
document.getElementById('app')
);
},
});