-
Notifications
You must be signed in to change notification settings - Fork 13
Home
There isn't a ton here - but it should be enough to get started. The wiki is broken down into two parts: A functional overview and a conceptual overview.
The functional overview covers every feature and function and goes into detail on them.
The conceptual overview covers abstract concepts and how to implement them.
to get started, run
npm create deskthing@latest
in the terminal. This will require having nodejs installed and npm (ships with Node) installed.
The command will walk you through a setup process and ask various questions detailed more in #getting-started
The basic structure of the app is as follows:
yourAppId
- public/ // holds meta information about your app
- server/ // The back end of your app or the SERVER
- src/ // The front end of your app or the CLIENT
- index.html // The entrypoint of the CLIENT
There are two concepts that need to be understood about how deskthing works. Unlike a traditional website, you communicate through the DeskThing software when having your SERVER talk to the CLIENT.
CLIENT -> Deskthing -> SERVER
Let's go over what both of these mean individually:
The CLIENT is built using VITE and TAILWIND but it doesn't have to be. For the sake of this tutorial, that is what will be assumed you are using.
The client runs on the Car Thing and must be considered offline outside of what you send / receive from DeskThing. This means it cannot
- Access external images
- Import styling libraries from the web
- Directly access API endpoints etc
This means that you will be forced to use DeskThing to send JSON objects back and forth with the server to send and receive information. The best way to send data is as follows:
// client
import { DeskThing } from 'deskthing-client'
DeskThing.send({ type: 'sampleType', payload: 'Hello from the client!' })
This can be received on the server with
// server
import { DeskThing } from 'deskthing-server'
DeskThing.on('sampleType', (data) => {
console.log(data.payload) // prints 'Hello from the client!'
})
This should be enough to get most people started. The rest of the interactions are detailed further in the wiki (pending)
The SERVER is built using NODEJS on the backend. It can for all intents and purposes be considered online and able to have full access to the internet. It is also where utility functions are defined such as settings, buttons, keys, and more.
When setting up your server, it should have the basic structure of:
// server
import { DeskThing } from 'deskthing-server'
export ( DeskThing }
const startup = () => {
DeskThing.sendLog('Starting Up')
}
const stop = () => {
DeskThing.sendLog('Stopping app')
}
// Ideally, all of your code logic is held within the Startup function. Anything outside of this function wont reliably run
DeskThing.on('start', startup)
DeskThing.on('stop', stop)
To send data to the client, you can do:
// server
import { DeskThing } from 'deskthing-server'
DeskThing.send({ type: 'samepleType', payload: 'Hello from the server!' })
And to receive the data on the client, you can do
// client
import { DeskThing } from 'deskthing-client'
DeskThing.on('sampleType', (data) => {
console.log(data.payload) // prints 'Hello from the server!'
})
There are three primary entrypoints from the server that you need to be able to use. 'start', 'purge', and 'stop' These will be called once the server is started, purged, and stopped from DeskThing.
import { DeskThing } from 'deskthing-server'
export { DeskThing }
DeskThing.on('start', () => {
console.log('Sample App has started successfully!')
})
DeskThing.on('stop', () => {
console.log('Sample app has stopped successfully')
})
DeskThing.on('purge' () => {
console.log('Sample app is cleaned up successfully')
})
⚠️ The WIKI is still in the works and is subject to being updated or changed at any point until DeskThing reached v1.0.0
Thank you for your understanding ^-^