App Templates

To help accelerate app development, the webOS TV platform provides templates for web apps, both basic (packaged) and hosted web app, and for JS services. Also, templates for info files are also available.

List of available templates

The webOS TV platform provides several templates.

Category Template name Description
For web app basic Teamplate for a basic web app (default)
hosted_webapp Template for a hosted web app
webappinfo Template for an appinfo.json file with sample values
For JS service js_service Template for a JavaScript (JS) service
jsserviceinfo Template for a package.json and services.json file with sample values
pakageinfo Template for a packageinfo.json file with sample values

For web app

Basic web app

The basic web template provides a "Hello World" app with the minimum essential files for webOS TV. This template is useful when using other UI frameworks.

The following table describes the directories/files of a basic web app created using the template.

Directory / File Description
webOSTVjs-x.x.x The webOS TV library directory. The webOS TV-specific library to call LS API. See webOSTV.js for the detailed description of the webOS TV library.
appinfo.json The web app configuration file. The appinfo.json file includes metadata of the web app. This file must exist for packaging the web app. See appinfo.json for the detailed description of the appinfo.json file.
 icon.png The icon image file. See App icons for the detailed description of the icon.png file.
largeicon.png The large icon image file. See App icons for the detailed description of the largeicon.png file.
index.html The web app's main page. This page only shows "Hello World" text on a screen.

Hosted web app

The hosted web app template provides a hosted web app that contains a redirect URL with the minimum essential files for webOS TV.

The following table describes the directories/files of a hosted web app created using the template.

Directory / File Description
appinfo.json The web app configuration file. The appinfo.json file includes metadata of the web app. This file must exist for packaging a web app. See appinfo.json for the detailed description of the appinfo.json file.
 icon.png The icon image file. See App icons for the detailed description of the icon.png file.
largeicon.png The large icon image file. See App icons for the detailed description of the largeicon.png file.
index.html The web app's main page that contains the redirect URL.

Web app info

The web app info template provides an appinfo.json file with sample values. If you are building a new web app without templates or using the existing web app which was not made from templates, you should add the appinfo.json file into your app. The appinfo.json file holds the app's name, ID, app type, icon image, and the main page information to the file.

The webOS TV CLI provides the appinfo.json file template as below.

{
  "id": "com.domain.app",
  "version": "0.0.1",
  "vendor": "My Company",
  "type": "web",
  "main": "index.html",
  "title": "new app",
  "icon": "icon.png",
  "largeIcon": "largeIcon.png"
}

For JS service

JS service

The JS service template provides a sample JS service running as a background service on webOS TV. The sample JS service responds to simple messages for a service request.

The following table is a basic description of the directories/files of a JS service created using the template.

Directory/File Description
helloworld_service.js The sample JS service code that provides several simple commands. These commands are specified in the services.json file to use them.
package.json The configuration file of NPM. For more information, see https://docs.npmjs.com/getting-started/using-a-package.json
services.json The configuration file defines what commands the service provides on the webOS bus. For more information, See services.json.

JS service info

The JS service info template provides package.json and services.json files with sample values. If you are creating a JS service without the template or using the existing service which was not made from the template, you should add the package.json and services.json_ files with this JS service info template into your app.

The generated package.json file with this template will look like:

{
  "name": "com.domain.app.service",
  "version": "1.0.0",
  "description": "Helloworld service",
  "main": "helloworld_service.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "BSD"
}

The generated services.json file with this template will look like:

{
  "id": "com.domain.app.service",
  "description": "HelloWorld Service",
  "services": [
    {
      "name": "com.domain.app.service"
    }
  ]
}

Package info

The package info template is used to generated a packageinfo.json file that defines the content of a package. A package contains one app and zero or more services.

The generated packageinfo.json file with this template will look like:

{
  "id": "com.domain",
  "version": "0.0.1"
}

See also

No Headings