-
Notifications
You must be signed in to change notification settings - Fork 12
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
32 changed files
with
8,727 additions
and
92 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,3 @@ | ||
|
||
/spotify/node_modules | ||
/image/node_modules |
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,5 @@ | ||
# Deskthing App Template | ||
|
||
This will be where I describe how to use this template. However, I do not have the time nor patience to write yet another README. | ||
|
||
Modify this README.md with your own app details and install instructions so that anyone can install your app into DeskThing |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,18 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>DeskThing - App</title> | ||
<script type="module" crossorigin src="./index-CdoHZ0JD.js"></script> | ||
<link rel="stylesheet" crossorigin href="./index-DKuwYFHd.css"> | ||
<script type="module">import.meta.url;import("_").catch(()=>1);(async function*(){})().next();if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script> | ||
<script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script> | ||
<script nomodule crossorigin id="vite-legacy-polyfill" src="./polyfills-legacy-B1XmITMC.js"></script> | ||
<script nomodule crossorigin id="vite-legacy-entry" data-src="./index-legacy-XUFlSEaw.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script> | ||
</body> | ||
</html> |
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,124 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DeskThing = void 0; | ||
const deskthing_server_1 = require("deskthing-server"); | ||
const promises_1 = __importDefault(require("fs/promises")); // Import the fs module to read files | ||
const path_1 = __importDefault(require("path")); | ||
const DeskThing = deskthing_server_1.DeskThing.getInstance(); | ||
exports.DeskThing = DeskThing; | ||
const start = async () => { | ||
let Data = await DeskThing.getData(); | ||
DeskThing.on('data', (newData) => { | ||
// Syncs the data with the server | ||
Data = newData; | ||
}); | ||
if (!Data?.settings?.source) { | ||
const settings = { | ||
"image_source": { | ||
"value": 'prompt', | ||
"label": "Image Source", | ||
"options": [ | ||
{ | ||
"value": "unset", | ||
"label": "Unset" | ||
}, | ||
{ | ||
"value": "prompt", | ||
"label": "Prompt for Another" | ||
}, | ||
] | ||
}, | ||
}; | ||
DeskThing.addSettings(settings); | ||
} | ||
const sendImageToClient = async (imagePath) => { | ||
try { | ||
const imageData = await promises_1.default.readFile(imagePath); | ||
const base64Image = imageData.toString('base64'); | ||
const mimeType = path_1.default.extname(imagePath).slice(1); // Get file extension to use as MIME type | ||
DeskThing.sendDataToClient({ | ||
type: 'imageData', payload: `data:image/${mimeType};base64,${base64Image}` | ||
}); | ||
} | ||
catch (error) { | ||
DeskThing.sendError('Error reading image file: ' + error); | ||
} | ||
}; | ||
// Getting data from the user (Ensure these match) | ||
const promptForImage = async () => { | ||
const requestScopes = { | ||
'image_source': { | ||
'value': 'C:/', | ||
'label': 'Image Source', | ||
'instructions': 'Input the absolute path to the image you want to display.', | ||
} | ||
}; | ||
DeskThing.getUserInput(requestScopes, async (data) => { | ||
if (data.payload.image_source) { | ||
const newImageSource = data.payload.image_source; | ||
// Add the new image source to the settings options | ||
if (!Data?.settings?.image_source.options.some(opt => opt.value === newImageSource)) { | ||
Data?.settings?.image_source.options.push({ | ||
value: newImageSource, | ||
label: `Image: ${path_1.default.basename(newImageSource)}`, | ||
}); | ||
} | ||
// Save the updated settings | ||
DeskThing.saveData({ settings: Data?.settings }); | ||
// Send the new image to the client | ||
await sendImageToClient(newImageSource); | ||
// If still set to prompt, prompt again | ||
if (Data?.settings?.image_source.value === 'prompt') { | ||
promptForImage(); | ||
} | ||
} | ||
else { | ||
DeskThing.sendError('Please fill out all the fields! Restart to try again'); | ||
} | ||
}); | ||
}; | ||
if (Data?.settings?.image_source.value === 'prompt') { | ||
await promptForImage(); | ||
} | ||
else if (Data?.settings?.image_source.value !== 'unset') { | ||
await sendImageToClient(Data?.settings?.image_source.value); | ||
} | ||
DeskThing.on('settings', async (setting) => { | ||
if (setting.image_source.value === 'prompt') { | ||
await promptForImage(); | ||
} | ||
else if (setting.image_source.value !== 'unset') { | ||
await sendImageToClient(setting.image_source.value); | ||
} | ||
}); | ||
DeskThing.on('get', async (data) => { | ||
if (data.type == null) { | ||
DeskThing.sendError('No args provided!'); | ||
return; | ||
} | ||
switch (data.request) { | ||
case 'image': | ||
if (Data?.settings?.image_source.value !== 'unset') { | ||
await sendImageToClient(Data?.settings?.image_source.value); | ||
} | ||
else { | ||
DeskThing.sendError('No image source found!'); | ||
} | ||
break; | ||
default: | ||
DeskThing.sendError(`Unknown request: ${data.request}`); | ||
break; | ||
// Handle other types ? | ||
} | ||
}); | ||
}; | ||
const stop = async () => { | ||
// Function called when the server is stopped | ||
}; | ||
// Main Entrypoint of the server | ||
DeskThing.on('start', start); | ||
// Main exit point of the server | ||
DeskThing.on('stop', stop); |
Binary file not shown.
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,21 @@ | ||
{ | ||
"id": "image", | ||
"isAudioSource": false, | ||
"isScreenSaver": true, | ||
"isWebApp": true, | ||
"isLocalApp": false, | ||
"requires": [ | ||
"" | ||
], | ||
"label": "Image Viewer", | ||
"version": "0.8.11", | ||
"description": "A simple app that displays an image", | ||
"author": "Riprod", | ||
"platforms": [ | ||
"windows", | ||
"macos", | ||
"linux" | ||
], | ||
"homepage": "deskthing.app", | ||
"repository": "https://github.com/ItsRiprod/Deskthing-Apps" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,28 @@ | ||
import js from '@eslint/js' | ||
import globals from 'globals' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import reactRefresh from 'eslint-plugin-react-refresh' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default tseslint.config( | ||
{ ignores: ['dist'] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
ecmaVersion: 2020, | ||
globals: globals.browser, | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
'react-refresh': reactRefresh, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
}, | ||
) |
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,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>DeskThing - App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.