-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { contextBridge } from 'electron'; | ||
|
||
import { appAPI } from './app'; | ||
import { loggerAPI } from './logger'; | ||
import { AppAPI } from './app'; | ||
import { LoggerAPI } from './logger'; | ||
|
||
contextBridge.exposeInMainWorld('appAPI', appAPI); | ||
contextBridge.exposeInMainWorld('loggerAPI', loggerAPI); | ||
contextBridge.exposeInMainWorld('APP_API', AppAPI); | ||
contextBridge.exposeInMainWorld('LOGGER_API', LoggerAPI); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/app-renderer/src/MainWindow/redux/thunks/thunks.app.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { appAPI } from 'src/apis'; | ||
import { AppAPI } from 'src/apis'; | ||
|
||
import { _actions } from '../actions'; | ||
|
||
import { createMainThunk } from './createThunk'; | ||
|
||
export const prepareAppDetails = createMainThunk(async (dispatch) => { | ||
const appDetails = await appAPI.getAppDetails(); | ||
const appDetails = await AppAPI.getAppDetails(); | ||
dispatch(_actions._setAppDetails(appDetails)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { AppRendererAPI } from '@ter/app-common/apis/app'; | ||
import type { LoggerRendererAPI } from '@ter/app-common/apis/logger'; | ||
|
||
declare const window: { | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
APP_API: AppRendererAPI; | ||
LOGGER_API: LoggerRendererAPI; | ||
/* eslint-enable @typescript-eslint/naming-convention */ | ||
}; | ||
|
||
export const { APP_API, LOGGER_API } = window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
/* | ||
* https://www.electronjs.org/docs/latest/api/context-bridge#api-functions | ||
* Exposed functions have some limitations. | ||
* Here we can convert them to meet our requirements, such as converting data structures: | ||
* ```ts | ||
* const { _getUser } = window; | ||
* | ||
* export async function getUser() { | ||
* return User.deserialize(await _getUser()); | ||
* } | ||
* ``` | ||
* | ||
* We can also create new functions that combine some of the exposed functions: | ||
* ```ts | ||
* const { apiA, apiB } = window; | ||
* | ||
* export async function apiX() { | ||
* const resA = await apiA(); | ||
* const resB = await apiB(); | ||
* return resA || resB; | ||
* } | ||
* ``` | ||
*/ | ||
|
||
import type { AppRendererAPI } from '@ter/app-common/apis/app'; | ||
import type { LoggerRendererAPI } from '@ter/app-common/apis/logger'; | ||
|
||
declare const window: { | ||
appAPI: AppRendererAPI; | ||
loggerAPI: LoggerRendererAPI; | ||
}; | ||
import { APP_API, LOGGER_API } from './exposes'; | ||
|
||
export const AppAPI = { | ||
createWindow: APP_API.createWindow, | ||
getAppDetails: APP_API.getAppDetails, | ||
windowType: APP_API.windowType, | ||
} satisfies Record<keyof AppRendererAPI, unknown>; | ||
|
||
export const { appAPI, loggerAPI } = window; | ||
export const LoggerAPI = { | ||
debug: LOGGER_API.debug, | ||
error: LOGGER_API.error, | ||
info: LOGGER_API.info, | ||
log: LOGGER_API.log, | ||
verbose: LOGGER_API.verbose, | ||
warn: LOGGER_API.warn, | ||
} satisfies Record<keyof LoggerRendererAPI, unknown>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters