Actuall add decky-frontend-lib and remove some old code

This commit is contained in:
Jonas Dellinger 2022-05-13 23:18:19 +02:00
parent 52f6ca1c58
commit 5a60010268
5 changed files with 84 additions and 51 deletions

57
package-lock.json generated
View file

@ -9,11 +9,12 @@
"version": "0.0.1", "version": "0.0.1",
"license": "GPL-2.0-or-later", "license": "GPL-2.0-or-later",
"dependencies": { "dependencies": {
"decky-frontend-lib": "file:../decky-frontend-lib", "decky-frontend-lib": "^0.0.2",
"react-icons": "^4.3.1" "react-icons": "^4.3.1"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^21.1.0", "@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.2.1", "@rollup/plugin-node-resolve": "^13.2.1",
"@rollup/plugin-replace": "^4.0.0", "@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.3.2", "@rollup/plugin-typescript": "^8.3.2",
@ -26,17 +27,18 @@
} }
}, },
"../decky-frontend-lib": { "../decky-frontend-lib": {
"version": "0.0.1", "version": "0.0.2",
"extraneous": true,
"license": "GPL-2.0-or-later", "license": "GPL-2.0-or-later",
"dependencies": {
"moduleraid": "^6.0.0"
},
"devDependencies": { "devDependencies": {
"@types/jest": "^27.4.1",
"@types/react": "16.14.0", "@types/react": "16.14.0",
"import-sort-style-module": "^6.0.0", "import-sort-style-module": "^6.0.0",
"jest": "^27.5.1",
"prettier-plugin-import-sort": "^0.0.7", "prettier-plugin-import-sort": "^0.0.7",
"react": "16.14.0", "react": "^16.14.0",
"shx": "^0.3.4", "shx": "^0.3.4",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3" "typescript": "^4.6.3"
}, },
"peerDependencies": { "peerDependencies": {
@ -64,6 +66,18 @@
"rollup": "^2.38.3" "rollup": "^2.38.3"
} }
}, },
"node_modules/@rollup/plugin-json": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz",
"integrity": "sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==",
"dev": true,
"dependencies": {
"@rollup/pluginutils": "^3.0.8"
},
"peerDependencies": {
"rollup": "^1.20.0 || ^2.0.0"
}
},
"node_modules/@rollup/plugin-node-resolve": { "node_modules/@rollup/plugin-node-resolve": {
"version": "13.2.1", "version": "13.2.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.2.1.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.2.1.tgz",
@ -535,8 +549,12 @@
"dev": true "dev": true
}, },
"node_modules/decky-frontend-lib": { "node_modules/decky-frontend-lib": {
"resolved": "../decky-frontend-lib", "version": "0.0.2",
"link": true "resolved": "https://registry.npmjs.org/decky-frontend-lib/-/decky-frontend-lib-0.0.2.tgz",
"integrity": "sha512-XyxSLrkvEjA0oDsPnV30cyMgzqSOKMp3riAkk1e0iEItvt26m4w4iGPD7JO1rtXquWpSEvYB9SCmhlrX/3COXA==",
"peerDependencies": {
"react": "16.14.0"
}
}, },
"node_modules/deepmerge": { "node_modules/deepmerge": {
"version": "4.2.2", "version": "4.2.2",
@ -1409,6 +1427,15 @@
"resolve": "^1.17.0" "resolve": "^1.17.0"
} }
}, },
"@rollup/plugin-json": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz",
"integrity": "sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^3.0.8"
}
},
"@rollup/plugin-node-resolve": { "@rollup/plugin-node-resolve": {
"version": "13.2.1", "version": "13.2.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.2.1.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.2.1.tgz",
@ -1810,16 +1837,10 @@
"dev": true "dev": true
}, },
"decky-frontend-lib": { "decky-frontend-lib": {
"version": "file:../decky-frontend-lib", "version": "0.0.2",
"requires": { "resolved": "https://registry.npmjs.org/decky-frontend-lib/-/decky-frontend-lib-0.0.2.tgz",
"@types/react": "16.14.0", "integrity": "sha512-XyxSLrkvEjA0oDsPnV30cyMgzqSOKMp3riAkk1e0iEItvt26m4w4iGPD7JO1rtXquWpSEvYB9SCmhlrX/3COXA==",
"import-sort-style-module": "^6.0.0", "requires": {}
"moduleraid": "^6.0.0",
"prettier-plugin-import-sort": "^0.0.7",
"react": "16.14.0",
"shx": "^0.3.4",
"typescript": "^4.6.3"
}
}, },
"deepmerge": { "deepmerge": {
"version": "4.2.2", "version": "4.2.2",

View file

@ -26,6 +26,7 @@
"homepage": "https://github.com/SteamDeckHomebrew/decky-plugin-template#readme", "homepage": "https://github.com/SteamDeckHomebrew/decky-plugin-template#readme",
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^21.1.0", "@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.2.1", "@rollup/plugin-node-resolve": "^13.2.1",
"@rollup/plugin-replace": "^4.0.0", "@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.3.2", "@rollup/plugin-typescript": "^8.3.2",
@ -37,7 +38,7 @@
"shx": "^0.3.4" "shx": "^0.3.4"
}, },
"dependencies": { "dependencies": {
"decky-frontend-lib": "file:../decky-frontend-lib", "decky-frontend-lib": "^0.0.2",
"react-icons": "^4.3.1" "react-icons": "^4.3.1"
} }
} }

View file

@ -2,5 +2,5 @@
"name": "Example Plugin", "name": "Example Plugin",
"author": "John Doe", "author": "John Doe",
"frontend_bundle": "dist/example-plugin.js", "frontend_bundle": "dist/example-plugin.js",
"flags": ["hot_reload", "_root"] "flags": ["debug", "_root"]
} }

View file

@ -1,4 +1,5 @@
import commonjs from '@rollup/plugin-commonjs'; import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve'; import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace'; import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript'; import typescript from '@rollup/plugin-typescript';
@ -10,6 +11,7 @@ export default defineConfig({
commonjs(), commonjs(),
nodeResolve(), nodeResolve(),
typescript(), typescript(),
json(),
replace({ replace({
preventAssignment: false, preventAssignment: false,
'process.env.NODE_ENV': JSON.stringify('production'), 'process.env.NODE_ENV': JSON.stringify('production'),

View file

@ -1,50 +1,59 @@
import { import {
Button, Button,
definePlugin, definePlugin,
PanelSection, Menu,
PanelSectionRow, MenuItem,
ServerAPI, ServerAPI,
TabTitle, showModal,
staticClasses,
} from "decky-frontend-lib"; } from "decky-frontend-lib";
import { useState, VFC } from "react"; import { VFC } from "react";
import { FaShip } from "react-icons/fa"; import { FaShip } from "react-icons/fa";
interface AddMethodArgs { // interface AddMethodArgs {
left: number; // left: number;
right: number; // right: number;
} // }
const Content: VFC<{ serverAPI: ServerAPI }> = ({ serverAPI }) => { const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => {
const [result, setResult] = useState<number | undefined>(); // const [result, setResult] = useState<number | undefined>();
const onClick = async () => { // const onClick = async () => {
const result = await serverAPI.callPluginMethod<AddMethodArgs, number>( // const result = await serverAPI.callPluginMethod<AddMethodArgs, number>(
"add", // "add",
{ // {
left: 2, // left: 2,
right: 2, // right: 2,
} // }
); // );
if (result.success) { // if (result.success) {
setResult(result.result); // setResult(result.result);
} // }
}; // };
return ( return (
<PanelSection> <div>
<PanelSectionRow> <Button
<Button layout="below" bottomSeparator={false} onClick={onClick}> onClick={(e) =>
What is 2+2? showModal(
<Menu label="Menu" cancelText="CAAAANCEL" onCancel={() => {}}>
<MenuItem onSelected={() => {}}>Item #1</MenuItem>
<MenuItem onSelected={() => {}}>Item #2</MenuItem>
<MenuItem onSelected={() => {}}>Item #3</MenuItem>
</Menu>,
e.currentTarget ?? window
)
}
>
Server says yolo
</Button> </Button>
<div>Server says: {result}</div> </div>
</PanelSectionRow>
</PanelSection>
); );
}; };
export default definePlugin((serverApi) => { export default definePlugin((serverApi) => {
return { return {
title: <TabTitle>Example Plugin</TabTitle>, title: <div className={staticClasses.Title}>Example Plugin</div>,
content: <Content serverAPI={serverApi} />, content: <Content serverAPI={serverApi} />,
icon: <FaShip />, icon: <FaShip />,
}; };