generated from SteamDeckHomebrew/decky-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use new decky plugin format (#35)
* refactor: Use new decky plugin format * replace usage of decky-frontend-lib with @decky/api & @decky/ui * use @decky/rollup to do rollup configuration * upgrade outdated dependencies * update ci to use pnpm@9 specifically Signed-off-by: eXhumer <[email protected]> * replace deprecated `VFC` with `FC` * style: Add eslint to lint frontend source * add CI job to lint source Signed-off-by: eXhumer <[email protected]> * chore: Remove unused backend methods * add CI job to lint backend code Signed-off-by: eXhumer <[email protected]> * fix custom options Signed-off-by: eXhumer <[email protected]> * chore: dependency changes * change @decky/ui to dev dependency * remove shx (not needed as @decky/rollup takes care of cleaning dist directory) * add tslib as normal dependency * upgrade rollup to 4.22.5 Signed-off-by: eXhumer <[email protected]> --------- Signed-off-by: eXhumer <[email protected]> Co-authored-by: sheffey <[email protected]>
- Loading branch information
Showing
23 changed files
with
3,270 additions
and
843 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
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,32 @@ | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import pluginReact from "eslint-plugin-react"; | ||
import stylistic from "@stylistic/eslint-plugin"; | ||
|
||
export default [ | ||
{ | ||
ignores: ["dist/*"], | ||
}, | ||
{ | ||
settings: { | ||
react: { | ||
version: "18.3", | ||
}, | ||
}, | ||
}, | ||
stylistic.configs.customize({ | ||
indent: 2, | ||
quotes: "double", | ||
semi: true, | ||
jsx: true, | ||
}), | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
pluginReact.configs.flat.recommended, | ||
{ | ||
files: ["src/**/*.{js,mjs,cjs,ts,jsx,tsx}"], | ||
rules: { | ||
"react/react-in-jsx-scope": "off", | ||
}, | ||
}, | ||
]; |
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,52 +1,61 @@ | ||
#!/usr/bin/env python | ||
import logging, os | ||
from settings import SettingsManager # type: ignore | ||
import decky_plugin # type: ignore | ||
import logging | ||
import typing | ||
from settings import SettingsManager # type: ignore | ||
import decky # type: ignore | ||
|
||
# Setup environment variables | ||
deckyHomeDir = decky_plugin.DECKY_HOME | ||
settingsDir = decky_plugin.DECKY_PLUGIN_SETTINGS_DIR | ||
loggingDir = decky_plugin.DECKY_PLUGIN_LOG_DIR | ||
logger = decky_plugin.logger | ||
deckyHomeDir = decky.DECKY_HOME | ||
settingsDir = decky.DECKY_PLUGIN_SETTINGS_DIR | ||
loggingDir = decky.DECKY_PLUGIN_LOG_DIR | ||
logger = decky.logger | ||
|
||
# Setup backend logger | ||
logger.setLevel(logging.DEBUG) # can be changed to logging.DEBUG for debugging issues | ||
logger.setLevel(logging.DEBUG) | ||
logger.info('[backend] Settings path: {}'.format(settingsDir)) | ||
settings = SettingsManager(name="settings", settings_directory=settingsDir) | ||
settings.read() | ||
|
||
|
||
class SetSettingOptions(typing.TypedDict): | ||
key: str | ||
value: typing.Any | ||
|
||
|
||
class GetSettingOptions(typing.TypedDict): | ||
key: str | ||
defaults: typing.Any | ||
|
||
|
||
class Plugin: | ||
async def plugin_info(self): | ||
# Call plugin_info only once preferably | ||
logger.debug('[backend] PluginInfo:\n\tPluginName: {}\n\tPluginVersion: {}\n\tDeckyVersion: {}'.format( | ||
decky_plugin.DECKY_PLUGIN_NAME, | ||
decky_plugin.DECKY_PLUGIN_VERSION, | ||
decky_plugin.DECKY_VERSION | ||
)) | ||
pluginInfo = { | ||
"name": decky_plugin.DECKY_PLUGIN_NAME, | ||
"version": decky_plugin.DECKY_PLUGIN_VERSION | ||
} | ||
return pluginInfo | ||
|
||
async def logger(self, logLevel:str, msg:str): | ||
msg = '[frontend] {}'.format(msg) | ||
match logLevel.lower(): | ||
case 'info': logger.info(msg) | ||
case 'debug': logger.debug(msg) | ||
case 'warning': logger.warning(msg) | ||
case 'error': logger.error(msg) | ||
case 'critical': logger.critical(msg) | ||
|
||
async def settings_read(self): | ||
logger.info('[backend] Reading settings') | ||
return settings.read() | ||
async def settings_commit(self): | ||
logger.info('[backend] Saving settings') | ||
return settings.commit() | ||
async def settings_getSetting(self, key: str, defaults): | ||
logger.info('[backend] Get {}'.format(key)) | ||
return settings.getSetting(key, defaults) | ||
async def settings_setSetting(self, key: str, value): | ||
logger.info('[backend] Set {}: {}'.format(key, value)) | ||
return settings.setSetting(key, value) | ||
@classmethod | ||
async def _main(cls): | ||
logger.info("[backend] Loading CheatDeck!") | ||
|
||
@classmethod | ||
async def _unload(cls): | ||
logger.info("[backend] Unloading CheatDeck!") | ||
|
||
@classmethod | ||
async def _uninstall(cls): | ||
logger.info("[backend] Uninstalling CheatDeck!") | ||
|
||
@classmethod | ||
async def settings_read(cls): | ||
logger.info('[backend] Reading settings') | ||
return settings.read() | ||
|
||
@classmethod | ||
async def settings_commit(cls): | ||
logger.info('[backend] Saving settings') | ||
return settings.commit() | ||
|
||
@classmethod | ||
async def settings_getSetting(cls, data: GetSettingOptions): | ||
logger.info('[backend] Get {}'.format(data['key'])) | ||
return settings.getSetting(data['key'], data['defaults']) | ||
|
||
@classmethod | ||
async def settings_setSetting(cls, data: SetSettingOptions): | ||
logger.info('[backend] Set {}: {}'.format(data['key'], data['value'])) | ||
return settings.setSetting(data['key'], data['value']) |
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.