-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: deprecate invokers - auto proxying apis - strict types (jan…
…hq#924) * refactor: deprecate invokers * refactor: define routes and auto proxying routes * refactor: declare types for APIs, avoid making dynamic calls to any functions from the web * chore: deprecate route handling from preload script * refactor: deprecate unused apis
- Loading branch information
Showing
23 changed files
with
337 additions
and
548 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* App Route APIs | ||
* @description Enum of all the routes exposed by the app | ||
*/ | ||
export enum AppRoute { | ||
setNativeThemeLight = 'setNativeThemeLight', | ||
setNativeThemeDark = 'setNativeThemeDark', | ||
setNativeThemeSystem = 'setNativeThemeSystem', | ||
appDataPath = 'appDataPath', | ||
appVersion = 'appVersion', | ||
getResourcePath = 'getResourcePath', | ||
openExternalUrl = 'openExternalUrl', | ||
openAppDirectory = 'openAppDirectory', | ||
openFileExplore = 'openFileExplorer', | ||
relaunch = 'relaunch', | ||
} | ||
|
||
export enum AppEvent { | ||
onAppUpdateDownloadUpdate = 'onAppUpdateDownloadUpdate', | ||
onAppUpdateDownloadError = 'onAppUpdateDownloadError', | ||
onAppUpdateDownloadSuccess = 'onAppUpdateDownloadSuccess', | ||
} | ||
|
||
export enum DownloadRoute { | ||
abortDownload = 'abortDownload', | ||
downloadFile = 'downloadFile', | ||
pauseDownload = 'pauseDownload', | ||
resumeDownload = 'resumeDownload', | ||
} | ||
|
||
export enum DownloadEvent { | ||
onFileDownloadUpdate = 'onFileDownloadUpdate', | ||
onFileDownloadError = 'onFileDownloadError', | ||
onFileDownloadSuccess = 'onFileDownloadSuccess', | ||
} | ||
|
||
export enum ExtensionRoute { | ||
baseExtensions = 'baseExtensions', | ||
getActiveExtensions = 'getActiveExtensions', | ||
installExtension = 'installExtension', | ||
invokeExtensionFunc = 'invokeExtensionFunc', | ||
updateExtension = 'updateExtension', | ||
uninstallExtension = 'uninstallExtension', | ||
} | ||
export enum FileSystemRoute { | ||
appendFile = 'appendFile', | ||
copyFile = 'copyFile', | ||
deleteFile = 'deleteFile', | ||
exists = 'exists', | ||
getResourcePath = 'getResourcePath', | ||
getUserSpace = 'getUserSpace', | ||
isDirectory = 'isDirectory', | ||
listFiles = 'listFiles', | ||
mkdir = 'mkdir', | ||
readFile = 'readFile', | ||
readLineByLine = 'readLineByLine', | ||
rmdir = 'rmdir', | ||
writeFile = 'writeFile', | ||
} | ||
|
||
export type ApiFunction = (...args: any[]) => any | ||
|
||
export type AppRouteFunctions = { | ||
[K in AppRoute]: ApiFunction | ||
} | ||
|
||
export type AppEventFunctions = { | ||
[K in AppEvent]: ApiFunction | ||
} | ||
|
||
export type DownloadRouteFunctions = { | ||
[K in DownloadRoute]: ApiFunction | ||
} | ||
|
||
export type DownloadEventFunctions = { | ||
[K in DownloadEvent]: ApiFunction | ||
} | ||
|
||
export type ExtensionRouteFunctions = { | ||
[K in ExtensionRoute]: ApiFunction | ||
} | ||
|
||
export type FileSystemRouteFunctions = { | ||
[K in FileSystemRoute]: ApiFunction | ||
} | ||
|
||
export type APIFunctions = AppRouteFunctions & | ||
AppEventFunctions & | ||
DownloadRouteFunctions & | ||
DownloadEventFunctions & | ||
ExtensionRouteFunctions & | ||
FileSystemRouteFunctions | ||
|
||
export const APIRoutes = [ | ||
...Object.values(AppRoute), | ||
...Object.values(DownloadRoute), | ||
...Object.values(ExtensionRoute), | ||
...Object.values(FileSystemRoute), | ||
] | ||
export const APIEvents = [...Object.values(AppEvent), ...Object.values(DownloadEvent)] |
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
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
Oops, something went wrong.