Package Exports
- @deskthing/types
- @deskthing/types/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@deskthing/types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
DeskThing Types
TypeScript type definitions for the DeskThing application framework.
Installation
Install types
npm install @deskthing/types
Create new DeskThing app
npm create deskthing@latest
or
npx @deskthing/cli template
Install core packages
npm install @deskthing/client @deskthing/server
Core Types
Actions
Action- Defines an executable action with properties like id, name, value, etc.ActionReference- Reference to an action with minimal propertiesEventMode- Enum for different input event types (KeyUp, KeyDown, Swipes, etc.)Key- Defines a key mapping with modes and metadata
App Events
ServerEvent- Enum for server-side events (MESSAGE, DATA, GET, etc.)SEND_TYPES- Enum for client-to-server communication typesGetTypes- Types for 'get' event requests
Client
ClientManifest- Client details like name, version, device infoClientPreferences- User preferences for client appearance/behaviorApp- Interface for app state in clientKeyTrigger- Interface for key trigger events
Tasks
Task- Defines a task with steps and metadataStep- Base interface for task stepsTaskStep- Standard step in a taskTaskAction- Step requiring action executionTaskSetting- Step requiring settings inputSTEP_TYPES- Enum for different step types
Settings
SettingsType- Union type of all setting typesSettingsNumber- Number input settingSettingsBoolean- Boolean toggle settingSettingsString- Text input settingSettingsSelect- Dropdown select settingSettingsMultiSelect- Multiple selection settingSettingsColor- Color picker settingAppSettings- Record of app settings
Music
SongData- Current playing song informationThemeColor- Color theme informationAUDIO_REQUESTS- Enum for audio control requests
Utils
AppManifest- Application manifest typePlatformTypes- Supported platform typesTagTypes- App categorization tagsLOGGING_LEVELS- Log level typesSocketData- Socket communication data type
Usage
import { Action, ServerEvent, ClientManifest } from "@deskthing/types";
import { DeskThing } from "@deskthing/server";
// Define an action
const myAction: Action = {
id: "my-action",
name: "My Action",
version: "1.0.0",
enabled: true,
};
DeskThing.registerAction(myAction);
DeskThing.on(ServerEvent.ACTION, (event) => {
// Handle action event
});
// Handle server events
function handleEvent(event: ServerEvent) {
switch (event) {
case ServerEvent.DATA:
// Handle data event
break;
case ServerEvent.ACTION:
// Handle action event
break;
}
}License
MIT