desktopJS is a common API across multiple HTML5 containers. By programming to a common API, applications can target multiple HTML5 containers without change. Detecting what container in which you are hosted, desktopJS provides shims and polyfills to bridge the common API to the underlying container. The goal is to help applications be container agnostic and provide portability when multiple container deployments are desired.
The first step is to simply resolve the current container. This enumerates all registered containers (including your own custom container or derived custom implementations) and returns the container implementation that matches.
var container = desktopJS.resolveContainer();
console.log("Container: " + container.hostType);
Interact with the container via a single api instead of having conditional code or applications based on deployment.
container.addTrayIcon({ icon: 'assets/img/application.png', text: 'Example' }, () => {
console.log("Icon clicked");
});
The library uses gulp and rollup for building. All build dependencies are included as devDependencies and are installed during npm install.
$ npm install
Build the project. This runs static analysis, unit tests and bundles the output with rollup.
$ npm run build && npm test
For those using Visual Studio Code, tasks.json has a build task.
To run the examples or to manually test scenarios in each container, there is a gulp task providing a local server with live reload. This can be run directly via gulp or through npm.
$ npm start
This is configured to listen at http://localhost:8000 and will reload upon any change to the project build output under /dist or the web example under /examples/web. All of the included examples make use of this example application to showcase the portability of one codebase.
The tests can be run independent of the build.
$ npm test
A task is provided for Visual Studio Code users that can be launched from the command palette via
>Tasks: Run Test Task
or it is recommended to define a custom keyboard binding.
{
"key": "ctrl+shift+t",
"command": "workbench.action.tasks.test"
}
Examples showcasing usage of desktopJS for various containers and scenarios can be found under the examples directory.
Feature | Browser | ComposeUI |
---|---|---|
Hosting | ||
Web | ✔️ | ✔️ |
WPF | ❌ | ❌ |
WinForms | ❌ | ❌ |
Java | ❌ | ❌ |
Win32 | ❌ | ❌ |
Flash | ✔️ | ❌ |
MessageBus | ||
Cross Window | ✔️ | ✔️ |
Cross Technology | ❌ | ✔️ |
Cross Process | ❌ | ✔️ |
Cross Machine | ❌ | ❌ |
Platform | ||
Windows | ✔️ | ✔️ |
Mac | ✔️ | ❌ |
Linux | ✔️ | ❌ |
Node.js | ||
Bootstrap | ❌ | ❌ |
Renderer | ❌ | ❌ |
Notifications | ||
Native API | ✔️ | ❌ |
Web Notifications | ✔️ | ❌ |
System tray | ||
Icon | ❌ | ✔️ |
Context Menu | ❌ | ❌ |
Windows | ||
Popups | ✔️ | ❌ |
Modal | ❌ | ❌ |
Frameless | ❌ | ❌ |
Screenshot | ✔️ | ❌ |
Window Management | ||
Persistence | desktopJS | ❌ |
Grouping | ❌ | ❌ |
Snap/Dock | ❌ | ❌ |
Tabbing | ✔️ | ❌ |
Remote Administration | ❌ | ❌ |
Restart | ❌ | ❌ |
Shutdown | ❌ | ❌ |
Screenshot | ❌ | ❌ |