Skip to content

Commit

Permalink
refactor: move WebContentsView to index.ts because it is exported fro…
Browse files Browse the repository at this point in the history
…m CrossProcessExports
  • Loading branch information
ductridev committed Oct 14, 2024
1 parent d52d3f0 commit 1386bd0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Electron from 'electron';
import { WebContentsView } from './src/main/index';
import { WebContentsView } from './index';

export {
ClientRequest,
Expand Down
14 changes: 14 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { isVersionGreaterOrEqual } from './src/common/utils';
import * as Electron from 'electron';

const electronVersion = process.versions.electron;

let WebContentsView_: typeof Electron.WebContentsView | undefined;

if (isVersionGreaterOrEqual('29.0.0', electronVersion)) {
WebContentsView_ = Electron.WebContentsView; // This will throw an error if it doesn't exist
} else {
throw new Error('WebContentsView is only available in Electron >= 29.0.0');
}

export const WebContentsView = WebContentsView_;
12 changes: 0 additions & 12 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
export { initialize, isInitialized, enable } from "./server";

import { isVersionGreaterOrEqual } from '../common/utils';

const electronVersion = process.versions.electron;

let WebContentsView: typeof Electron.WebContentsView | undefined;

if (isVersionGreaterOrEqual('29.0.0', electronVersion)) {
WebContentsView = Electron.WebContentsView;
}

export { WebContentsView };

0 comments on commit 1386bd0

Please sign in to comment.