Core
App
Create custom applications for your virtual computer
Overview
Apps in cuse are modular components that can be installed and run on a virtual computer. Each app is an instance of a class that extends the abstract App
class and implements its core lifecycle methods.
Creating an App
To create a custom app, extend the App
class and implement the required methods:
Configuration
When creating an app, you must provide an AppConfig
:
Property | Type | Description |
---|---|---|
name | string | Unique name for your app |
platform | string | Target platform (e.g., ‘linux’, ‘windows’) |
autoStart | boolean | Whether to start the app automatically when the computer boots |
Lifecycle Methods
Each app must implement three core lifecycle methods:
- install(): Called when the app is first initialized. Use this to install dependencies or set up the app environment.
- start(): Called when the app should start running, either automatically if
autoStart
is true or manually. - stop(): Called when the app should shut down, typically when the computer is shutting down.
Using Apps with a Computer
To use your apps with a Computer instance, first define an interface for your app collection:
Accessing the Computer
Inside your app, you can access the computer instance through this.computer
:
Example: Browser App
Here’s a complete example of a browser app that installs and controls a web browser:
Best Practices
- Error Handling: Implement proper error handling in all lifecycle methods
- Cleanup: Ensure the
stop()
method properly cleans up all resources - Idempotency: Make the
install()
method idempotent - it should be safe to call multiple times - Documentation: Document any custom methods and requirements for your app
- Dependencies: Clearly specify any system dependencies your app requires