Files
AFFiNE-Mirror/apps/web/src/bootstrap/index.ts
Himself65 b9d2a06a2e feat: init window.affine (#2682)
(cherry picked from commit 8f6db00402)
2023-06-08 18:25:03 +08:00

35 lines
730 B
TypeScript

import { config, setupGlobal } from '@affine/env/config';
setupGlobal();
if (config.enablePlugin && !environment.isServer) {
import('@affine/copilot');
}
if (!environment.isServer) {
import('@affine/bookmark-block');
}
if (!environment.isDesktop && !environment.isServer) {
// Polyfill Electron
const unimplemented = () => {
throw new Error('AFFiNE Plugin Web will be supported in the future');
};
const affine = {
ipcRenderer: {
invoke: unimplemented,
send: unimplemented,
on: unimplemented,
once: unimplemented,
removeListener: unimplemented,
},
};
Object.freeze(affine);
Object.defineProperty(window, 'affine', {
value: affine,
writable: false,
});
}