2024-07-29 14:05:22 +03:00
|
|
|
import 'setimmediate';
|
|
|
|
import '@affine/component/theme/global.css';
|
|
|
|
import '@affine/component/theme/theme.css';
|
2024-07-31 10:03:30 +03:00
|
|
|
import '@affine/core/bootstrap/preload';
|
2024-08-02 05:02:03 +03:00
|
|
|
import '../global.css';
|
2024-07-29 14:05:22 +03:00
|
|
|
|
|
|
|
import { ThemeProvider } from '@affine/component/theme-provider';
|
|
|
|
import { configureAppTabsHeaderModule } from '@affine/core/modules/app-tabs-header';
|
|
|
|
import { configureElectronStateStorageImpls } from '@affine/core/modules/storage';
|
|
|
|
import { performanceLogger } from '@affine/core/shared';
|
2024-07-31 10:03:30 +03:00
|
|
|
import { apis, events } from '@affine/electron-api';
|
2024-07-29 14:05:22 +03:00
|
|
|
import {
|
|
|
|
configureGlobalStorageModule,
|
|
|
|
Framework,
|
|
|
|
FrameworkRoot,
|
|
|
|
} from '@toeverything/infra';
|
|
|
|
import { StrictMode } from 'react';
|
|
|
|
import { createRoot } from 'react-dom/client';
|
|
|
|
|
|
|
|
import { ShellRoot } from './shell';
|
|
|
|
|
|
|
|
const framework = new Framework();
|
|
|
|
configureGlobalStorageModule(framework);
|
|
|
|
configureElectronStateStorageImpls(framework);
|
|
|
|
configureAppTabsHeaderModule(framework);
|
|
|
|
const frameworkProvider = framework.provider();
|
|
|
|
|
|
|
|
const logger = performanceLogger.namespace('shell');
|
|
|
|
|
|
|
|
function main() {
|
2024-07-31 10:03:30 +03:00
|
|
|
const handleMaximized = (maximized: boolean | undefined) => {
|
|
|
|
document.documentElement.dataset.maximized = String(maximized);
|
|
|
|
};
|
|
|
|
const handleFullscreen = (fullscreen: boolean | undefined) => {
|
|
|
|
document.documentElement.dataset.fullscreen = String(fullscreen);
|
|
|
|
};
|
|
|
|
|
|
|
|
apis?.ui.isMaximized().then(handleMaximized).catch(console.error);
|
|
|
|
apis?.ui.isFullScreen().then(handleFullscreen).catch(console.error);
|
|
|
|
events?.ui.onMaximized(handleMaximized);
|
|
|
|
events?.ui.onFullScreen(handleFullscreen);
|
2024-07-29 14:05:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function mountApp() {
|
|
|
|
const root = document.getElementById('app');
|
|
|
|
if (!root) {
|
|
|
|
throw new Error('Root element not found');
|
|
|
|
}
|
|
|
|
logger.info('render app');
|
|
|
|
createRoot(root).render(
|
|
|
|
<StrictMode>
|
|
|
|
<FrameworkRoot framework={frameworkProvider}>
|
|
|
|
<ThemeProvider>
|
|
|
|
<ShellRoot />
|
|
|
|
</ThemeProvider>
|
|
|
|
</FrameworkRoot>
|
|
|
|
</StrictMode>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
main();
|
|
|
|
mountApp();
|
|
|
|
} catch (err) {
|
|
|
|
console.error('Failed to bootstrap app', err);
|
|
|
|
}
|