Location: webOSTVjs-1.2.10/webOSTV.js
This is the production version of the webOS TV JavaScript library. It provides the core API for interacting with webOS TV services and features. The file is minified for production use.
What it provides:
- Creates the global
window.webOSobject - Provides access to Luna Service API
- Device information and capabilities
- Platform detection
- System integration
Location: webOSTVjs-1.2.10/webOSTV-dev.js
This is the development version with additional debugging and development tools. It provides extra functionality for development and debugging.
What it provides:
- Creates the global
window.webOSDevobject - Additional development utilities
- Enhanced debugging capabilities
- Development-specific APIs
Usage in index.html:
<script src="webOSTVjs-1.2.10/webOSTV.js" charset="utf-8"></script>
<script src="webOSTVjs-1.2.10/webOSTV-dev.js" charset="utf-8"></script>Both files are typically included during development. In production, you may only need webOSTV.js.
Based on the library structure and documentation, here are the main APIs provided:
The primary way to interact with webOS system services.
Main Method: webOS.service.request()
webOS.service.request("luna://SERVICE_NAME", {
method: "METHOD_NAME",
parameters: {
// Service-specific parameters
},
onSuccess: function(response) {
// Handle successful response
},
onFailure: function(error) {
// Handle error
},
onComplete: function(result) {
// Always called after success or failure
},
subscribe: true // Optional: subscribe to updates
});Example from your index.html:
webOS.service.request("luna://com.palm.systemservice", {
method: "clock/getTime",
parameters: {},
onSuccess: function (args) {
console.log("UTC:", args.utc);
},
onFailure: function (args) {
console.log("Failed to getTime");
}
});Get detailed information about the device.
webOS.deviceInfo(function(info) {
console.log("Model:", info.modelName);
console.log("Version:", info.version);
console.log("Screen:", info.screenWidth + "x" + info.screenHeight);
console.log("UHD:", info.uhd);
console.log("OLED:", info.oled);
console.log("HDR10:", info.hdr10);
console.log("Dolby Vision:", info.dolbyVision);
console.log("Brand:", info.brandName);
});Available Properties:
modelName- TV model nameversion- Firmware versionversionMajor,versionMinor,versionDot- Version componentsscreenWidth,screenHeight- Screen dimensionsuhd- UHD support (boolean)uhd8K- 8K support (boolean)oled- OLED display (boolean)hdr10- HDR10 support (boolean)dolbyVision- Dolby Vision support (boolean)dolbyAtmos- Dolby Atmos support (boolean)brandName- TV brand namemanufacturer- Manufacturer namesdkVersion- SDK versionddrSize- Memory sizetuner- TV tuner availability (boolean)platformBizType- Platform type
Detect the platform type.
if (webOS.platform.tv) {
console.log("Running on TV");
} else if (webOS.platform.watch) {
console.log("Running on Smart Watch");
} else if (webOS.platform.open) {
console.log("Running on webOS Open");
} else if (webOS.platform.legacy) {
console.log("Running on legacy webOS");
}Properties:
tv- TV platform (boolean)watch- Smart Watch platform (boolean)open- webOS Open platform (boolean)legacy- Legacy webOS platform (boolean)chrome- Chrome version numberunknown- Unknown platform (boolean)
Get system-level information.
var sysInfo = webOS.systemInfo();
console.log("Country:", sysInfo.country);
console.log("Smart Service Country:", sysInfo.smartServiceCountry);
console.log("Timezone:", sysInfo.timezone);Returns:
country- Device country codesmartServiceCountry- Smart service countrytimezone- Timezone information
Check keyboard visibility.
if (webOS.keyboard.isShowing()) {
console.log("Keyboard is visible");
}Handle platform back button.
webOS.platformBack(); // Trigger back actionGet the current app's ID.
var appId = webOS.fetchAppId();
console.log("App ID:", appId);Get app information from appinfo.json.
webOS.fetchAppInfo(function(appInfo) {
console.log("App ID:", appInfo.id);
console.log("Version:", appInfo.version);
console.log("Title:", appInfo.title);
});Get the root path of the app.
var rootPath = webOS.fetchAppRootPath();
console.log("App root:", rootPath);Get the webOSTV.js library version.
console.log("Library version:", webOS.libVersion);Callback when the system is ready.
webOS.onSystemReady = function() {
console.log("System is ready");
// Initialize your app here
};Launch other applications.
webOSDev.launch({
id: "com.webos.app.browser",
params: {
target: "https://example.com"
},
onSuccess: function() {
console.log("App launched");
},
onFailure: function(error) {
console.error("Launch failed:", error);
}
});Get parameters passed when app was launched.
var params = webOSDev.launchParams();
console.log("Launch params:", params);Check network connection status.
webOSDev.connection.getStatus({
subscribe: true,
onSuccess: function(status) {
console.log("Connected:", status.isInternetConnectionAvailable);
console.log("Wired:", status.wired);
console.log("WiFi:", status.wifi);
},
onFailure: function(error) {
console.error("Connection check failed:", error);
}
});Digital Rights Management support.
var drmAgent = webOSDev.drmAgent("widevine");
drmAgent.load({
onSuccess: function() {
console.log("DRM loaded");
},
onFailure: function(error) {
console.error("DRM load failed:", error);
}
});Get unique device ID.
webOSDev.LGUDID({
onSuccess: function(result) {
console.log("UDID:", result.id);
},
onFailure: function(error) {
console.error("Failed to get UDID:", error);
}
});Here are commonly used Luna Services you can call with webOS.service.request():
Clock Service:
webOS.service.request("luna://com.palm.systemservice", {
method: "clock/getTime",
parameters: {},
onSuccess: function(response) {
console.log("Time:", response.utc);
}
});Application Manager:
webOS.service.request("luna://com.webos.applicationManager", {
method: "launch",
parameters: {
id: "com.webos.app.browser",
params: {}
},
onSuccess: function(response) {
console.log("App launched");
}
});TV Input Service:
webOS.service.request("luna://com.webos.service.tv.input", {
method: "register",
parameters: {
subscribe: true
},
onSuccess: function(response) {
// Handle remote control input
}
});Settings Service:
webOS.service.request("luna://com.webos.settingsservice", {
method: "getSystemSettings",
parameters: {
category: "sound",
keys: ["soundOutput", "soundOutputDigital"]
},
onSuccess: function(response) {
console.log("Sound output:", response.settings.soundOutput);
}
});Media Service:
webOS.service.request("luna://com.webos.service.media", {
method: "play",
parameters: {
uri: "http://example.com/video.mp4"
},
onSuccess: function(response) {
console.log("Media playing");
}
});The ares CLI provides command-line tools for webOS development:
-
ares-generate- Create projects from templates- Generate web apps, services, config files
- Templates:
basic,hosted_webapp,js_service,webappinfo
-
ares-package- Package apps into.ipkfiles- Creates installable packages
- Validates app structure
-
ares-install- Install apps on devices- Installs
.ipkpackages - Can launch after installation
- Installs
-
ares-launch- Launch installed apps- Starts apps on target device
- Can pass launch parameters
-
ares-inspect- Debugging tools- Web Inspector for web apps
- Node Inspector for JS services
-
ares-server- Local development server- Test apps in browser
- Rapid development iteration
-
ares-setup-device- Configure devices- Add/remove device connections
- Setup development environment
-
ares-device- Device information- List connected devices
- Get system information
- Monitor resource usage
-
ares-novacom- Low-level device communication- Get private keys
- Port forwarding
- Execute shell commands
-
ares-shell- Execute shell commands- Run commands on device
- Advanced debugging
-
ares-push- Transfer files to device- Upload files to device
- Deploy resources
-
ares-pull- Retrieve files from device- Download files from device
- Get logs and data
-
ares-log- View application logs- Show app/service logs
- Save logs to file
-
Development Flow:
ares-generate → Create project ares-server → Test locally webOSTV.js → Use APIs in code ares-package → Create package ares-install → Install on device ares-launch → Run app ares-inspect → Debug -
API Usage:
- Include
webOSTV.jsin HTML - Use
webOS.service.request()to call Luna Services - Use
webOS.deviceInfo()to get device capabilities - Use
webOSDevAPIs for development features
- Include
-
Service Communication:
- All system services accessed via Luna Service API
- Services use
luna://protocol - Asynchronous callbacks for responses
- Official Documentation: https://webostv.developer.lge.com/
- webOSTV.js Reference: https://webostv.developer.lge.com/develop/references/webostvjs-introduction
- Luna Service API: https://webostv.developer.lge.com/develop/references/luna-service-introduction
- CLI Developer Guide: https://webostv.developer.lge.com/develop/tools/cli-dev-guide
- webOSTV.js Version: 1.2.10
- Library Location:
webOSTVjs-1.2.10/ - License: Apache-2.0