Skip to content

Commit

Permalink
ESLint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaydeo committed Aug 5, 2022
1 parent ab3f7d3 commit 10f3e4d
Show file tree
Hide file tree
Showing 3 changed files with 404 additions and 811 deletions.
19 changes: 2 additions & 17 deletions docs/api/context-bridge.md
Expand Up @@ -90,7 +90,7 @@ contextBridge.exposeInMainWorld(
)
```

An example of complex API exposed in an isolated world is shown below:
An example of API exposed in an isolated world is shown below:

```javascript

Expand All @@ -104,22 +104,7 @@ contextBridge.exposeInIsolatedWorld(
1005,
'electron',
{
doThing: () => ipcRenderer.send('do-a-thing'),
myPromises: [Promise.resolve(), Promise.reject(new Error('whoops'))],
anAsyncFunction: async () => 123,
data: {
myFlags: ['a', 'b', 'c'],
bootTime: 1234
},
nestedAPI: {
evenDeeper: {
youCanDoThisAsMuchAsYouWant: {
fn: () => ({
returnData: 123
})
}
}
}
doThing: () => ipcRenderer.send('do-a-thing')
}
)

Expand Down
23 changes: 4 additions & 19 deletions lib/renderer/api/context-bridge.ts
@@ -1,11 +1,7 @@
const binding = process._linkedBinding('electron_renderer_context_bridge');

const checkContextIsolationEnabled = () => {
if (!process.contextIsolated) {
throw new Error(
'contextBridge API can only be used when contextIsolation is enabled'
);
}
if (!process.contextIsolated) throw new Error('contextBridge API can only be used when contextIsolation is enabled');
};

const contextBridge: Electron.ContextBridge = {
Expand All @@ -26,22 +22,11 @@ export const internalContextBridge = {
overrideGlobalValueFromIsolatedWorld: (keys: string[], value: any) => {
return binding._overrideGlobalValueFromIsolatedWorld(keys, value, false);
},
overrideGlobalValueWithDynamicPropsFromIsolatedWorld: (
keys: string[],
value: any
) => {
overrideGlobalValueWithDynamicPropsFromIsolatedWorld: (keys: string[], value: any) => {
return binding._overrideGlobalValueFromIsolatedWorld(keys, value, true);
},
overrideGlobalPropertyFromIsolatedWorld: (
keys: string[],
getter: Function,
setter?: Function
) => {
return binding._overrideGlobalPropertyFromIsolatedWorld(
keys,
getter,
setter || null
);
overrideGlobalPropertyFromIsolatedWorld: (keys: string[], getter: Function, setter?: Function) => {
return binding._overrideGlobalPropertyFromIsolatedWorld(keys, getter, setter || null);
},
isInMainWorld: () => binding._isCalledFromMainWorld() as boolean
};
Expand Down

0 comments on commit 10f3e4d

Please sign in to comment.