mirror of
				https://github.com/SteamDeckHomebrew/decky-plugin-template.git
				synced 2025-10-30 14:52:29 -05:00 
			
		
		
		
	Initial commit
This commit is contained in:
		
				commit
				
					
						52f6ca1c58
					
				
			
		
					 8 changed files with 2679 additions and 0 deletions
				
			
		
							
								
								
									
										37
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| lib-cov | ||||
| *.seed | ||||
| *.log | ||||
| *.csv | ||||
| *.dat | ||||
| *.out | ||||
| *.pid | ||||
| *.gz | ||||
| *.swp | ||||
| 
 | ||||
| pids | ||||
| logs | ||||
| results | ||||
| tmp | ||||
| 
 | ||||
| # Coverage reports | ||||
| coverage | ||||
| 
 | ||||
| # API keys and secrets | ||||
| .env | ||||
| 
 | ||||
| # Dependency directory | ||||
| node_modules | ||||
| bower_components | ||||
| 
 | ||||
| # Editors | ||||
| .idea | ||||
| *.iml | ||||
| 
 | ||||
| # OS metadata | ||||
| .DS_Store | ||||
| Thumbs.db | ||||
| 
 | ||||
| # Ignore built ts files | ||||
| dist/ | ||||
| 
 | ||||
| __pycache__/ | ||||
							
								
								
									
										9
									
								
								main.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								main.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| class Plugin: | ||||
|     # A normal method. It can be called from JavaScript using call_plugin_function("method_1", argument1, argument2) | ||||
|     async def add(self, left, right): | ||||
|         return left + right | ||||
| 
 | ||||
| 
 | ||||
|     # Asyncio-compatible long-running code, executed in a task when the plugin is loaded | ||||
|     async def _main(self): | ||||
|         pass | ||||
							
								
								
									
										2483
									
								
								package-lock.json
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										2483
									
								
								package-lock.json
									
										
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										43
									
								
								package.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								package.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| { | ||||
|   "name": "decky-plugin-template", | ||||
|   "version": "0.0.1", | ||||
|   "description": "A template to quickly create decky plugins from scratch, based on TypeScript and webpack", | ||||
|   "scripts": { | ||||
|     "build": "shx rm -rf dist && rollup -c", | ||||
|     "dev": "rollup -c -w", | ||||
|     "test": "echo \"Error: no test specified\" && exit 1" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git+https://github.com/SteamDeckHomebrew/decky-plugin-template.git" | ||||
|   }, | ||||
|   "keywords": [ | ||||
|     "decky", | ||||
|     "plugin", | ||||
|     "plugin-template", | ||||
|     "steam-deck", | ||||
|     "deck" | ||||
|   ], | ||||
|   "author": "Jonas Dellinger <jonas@dellinger.dev>", | ||||
|   "license": "GPL-2.0-or-later", | ||||
|   "bugs": { | ||||
|     "url": "https://github.com/SteamDeckHomebrew/decky-plugin-template/issues" | ||||
|   }, | ||||
|   "homepage": "https://github.com/SteamDeckHomebrew/decky-plugin-template#readme", | ||||
|   "devDependencies": { | ||||
|     "@rollup/plugin-commonjs": "^21.1.0", | ||||
|     "@rollup/plugin-node-resolve": "^13.2.1", | ||||
|     "@rollup/plugin-replace": "^4.0.0", | ||||
|     "@rollup/plugin-typescript": "^8.3.2", | ||||
|     "@types/react": "16.14.0", | ||||
|     "@types/webpack": "^5.28.0", | ||||
|     "react": "16.14.0", | ||||
|     "react-dom": "16.14.0", | ||||
|     "rollup": "^2.70.2", | ||||
|     "shx": "^0.3.4" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "decky-frontend-lib": "file:../decky-frontend-lib", | ||||
|     "react-icons": "^4.3.1" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										6
									
								
								plugin.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								plugin.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| { | ||||
|   "name": "Example Plugin", | ||||
|   "author": "John Doe", | ||||
|   "frontend_bundle": "dist/example-plugin.js", | ||||
|   "flags": ["hot_reload", "_root"] | ||||
| } | ||||
							
								
								
									
										28
									
								
								rollup.config.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								rollup.config.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| import commonjs from '@rollup/plugin-commonjs'; | ||||
| import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||||
| import replace from '@rollup/plugin-replace'; | ||||
| import typescript from '@rollup/plugin-typescript'; | ||||
| import { defineConfig } from 'rollup'; | ||||
| 
 | ||||
| export default defineConfig({ | ||||
|   input: './src/index.tsx', | ||||
|   plugins: [ | ||||
|     commonjs(), | ||||
|     nodeResolve(), | ||||
|     typescript(), | ||||
|     replace({ | ||||
|       preventAssignment: false, | ||||
|       'process.env.NODE_ENV': JSON.stringify('production'), | ||||
|     }), | ||||
|   ], | ||||
|   context: 'window', | ||||
|   external: ['react', 'react-dom'], | ||||
|   output: { | ||||
|     file: 'dist/example-plugin.js', | ||||
|     globals: { | ||||
|       react: 'SP_REACT', | ||||
|     }, | ||||
|     format: 'iife', | ||||
|     exports: 'default', | ||||
|   }, | ||||
| }); | ||||
							
								
								
									
										51
									
								
								src/index.tsx
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/index.tsx
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,51 @@ | |||
| import { | ||||
|   Button, | ||||
|   definePlugin, | ||||
|   PanelSection, | ||||
|   PanelSectionRow, | ||||
|   ServerAPI, | ||||
|   TabTitle, | ||||
| } from "decky-frontend-lib"; | ||||
| import { useState, VFC } from "react"; | ||||
| import { FaShip } from "react-icons/fa"; | ||||
| 
 | ||||
| interface AddMethodArgs { | ||||
|   left: number; | ||||
|   right: number; | ||||
| } | ||||
| 
 | ||||
| const Content: VFC<{ serverAPI: ServerAPI }> = ({ serverAPI }) => { | ||||
|   const [result, setResult] = useState<number | undefined>(); | ||||
| 
 | ||||
|   const onClick = async () => { | ||||
|     const result = await serverAPI.callPluginMethod<AddMethodArgs, number>( | ||||
|       "add", | ||||
|       { | ||||
|         left: 2, | ||||
|         right: 2, | ||||
|       } | ||||
|     ); | ||||
|     if (result.success) { | ||||
|       setResult(result.result); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   return ( | ||||
|     <PanelSection> | ||||
|       <PanelSectionRow> | ||||
|         <Button layout="below" bottomSeparator={false} onClick={onClick}> | ||||
|           What is 2+2? | ||||
|         </Button> | ||||
|         <div>Server says: {result}</div> | ||||
|       </PanelSectionRow> | ||||
|     </PanelSection> | ||||
|   ); | ||||
| }; | ||||
| 
 | ||||
| export default definePlugin((serverApi) => { | ||||
|   return { | ||||
|     title: <TabTitle>Example Plugin</TabTitle>, | ||||
|     content: <Content serverAPI={serverApi} />, | ||||
|     icon: <FaShip />, | ||||
|   }; | ||||
| }); | ||||
							
								
								
									
										22
									
								
								tsconfig.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								tsconfig.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| { | ||||
|   "compilerOptions": { | ||||
|     "outDir": "dist", | ||||
|     "module": "ESNext", | ||||
|     "target": "ES2020", | ||||
|     "jsx": "react-jsx", | ||||
|     "declaration": false, | ||||
|     "moduleResolution": "node", | ||||
|     "noUnusedLocals": true, | ||||
|     "noUnusedParameters": true, | ||||
|     "esModuleInterop": true, | ||||
|     "noImplicitReturns": true, | ||||
|     "noImplicitThis": true, | ||||
|     "noImplicitAny": true, | ||||
|     "strict": true, | ||||
|     "suppressImplicitAnyIndexErrors": true, | ||||
|     "allowSyntheticDefaultImports": true, | ||||
|     "skipLibCheck": true | ||||
|   }, | ||||
|   "include": ["src"], | ||||
|   "exclude": ["node_modules"] | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue