Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Inject Native helper object in browser window
Browse files Browse the repository at this point in the history
  • Loading branch information
gwleuverink committed Sep 13, 2024
1 parent 6313e4d commit 844c33a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { contextBridge, ipcRenderer } from 'electron'
import * as remote from '@electron/remote'

import Native from './native';

// @ts-ignore
window.Native = Native;

// @ts-ignore
window.remote = remote;

Expand Down
13 changes: 13 additions & 0 deletions src/preload/native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ipcRenderer } from 'electron'

export default {
on: (event, callback) => {
ipcRenderer.on('native-event', (_, data) => {
if(event !== data.event) {
return;
}

callback(data.payload);
})
}
}

0 comments on commit 844c33a

Please sign in to comment.