Start using it
This commit is contained in:
6
web/packages/next/global-electron.d.ts
vendored
6
web/packages/next/global-electron.d.ts
vendored
@@ -14,5 +14,9 @@ declare global {
|
||||
* {@link Electron}) that allow us to communicate with the Node.js layer of
|
||||
* our desktop app.
|
||||
*/
|
||||
const electron: Electron | undefined;
|
||||
// This needs to be a var for it to be recognized as a property of
|
||||
// globalThis, so we unfortunately need to hush eslint for the next line.
|
||||
//
|
||||
// eslint-disable-next-line no-var
|
||||
var electron: Electron | undefined;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { inWorker } from "@/next/env";
|
||||
import isElectron from "is-electron";
|
||||
import ElectronAPIs from "./electron";
|
||||
import { isDevBuild } from "./env";
|
||||
import { logToDisk as webLogToDisk } from "./log-web";
|
||||
import { workerBridge } from "./worker/worker-bridge";
|
||||
@@ -12,7 +10,8 @@ import { workerBridge } from "./worker/worker-bridge";
|
||||
* in the log that is saved on disk.
|
||||
*/
|
||||
export const logToDisk = (message: string) => {
|
||||
if (isElectron()) ElectronAPIs.logToDisk(message);
|
||||
const electron = globalThis.electron;
|
||||
if (electron) electron.logToDisk(message);
|
||||
else if (inWorker()) workerLogToDisk(message);
|
||||
else webLogToDisk(message);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user