pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • PebbleOS
  • Examples
  • Index 01
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

PebbleOS

  • Overview
  • Contributing
  • Exposing APIs to the SDK
  • Development
    • Prerequisites
    • The pbl CLI
    • Configuration Options
    • Building firmware
    • Build system
    • Running and writing tests
    • Integration tests
    • QEMU
    • Native
    • Debugging
    • Moddable JS Engine
    • Exposing functions to the SDK
    • Software bill of materials
    • Contribution Guidelines
  • Architecture
  • Boards
  • Reference
  • Firmware API Reference

Moddable JS Engine

PebbleOS supports the Moddable SDK’s XS JavaScript engine. The Moddable integration provides a lightweight sandbox for running JavaScript applications and watchfaces on Pebble hardware.

Building with Moddable

Moddable is enabled by default on platforms whose board defconfig sets CONFIG_MODDABLE_XS=y. You can override this at configure time by passing -DCONFIG_MODDABLE_XS=y or -DCONFIG_MODDABLE_XS=n to pbl configure. PRF (recovery) builds always disable the engine.

Installable applications

The JavaScript is stored in a resource. A small native C application bootstraps JavaScript execution by calling moddable_createMachine.

The JavaScript itself is a Moddable SDK mod, which is a precompiled collection of modules. The modules are compiled using the mcrun tool in the Moddable SDK. See Moddable’s Pebble Examples repository for further details. The Pebble resource containing the precompiled mod is currently loaded into RAM for execution; eventually, it should be executed directly from flash (this is what the Moddable SDK does on most platforms).

Sandbox

The JavaScript in installable applications runs inside a lightweight sandbox, which can limit access to certain JavaScript global variables and modules.

Installable applications can be either a normal application or a watchface. The sandbox prevents watchfaces from subscribing to the Pebble hardware buttons (which is slightly redundant since PebbleOS also blocks them — but PebbleOS blocks them silently, whereas the sandbox throws an exception, which is more clear to developers).

Generated from PebbleOS 91af4a22c. This page is maintained in the pebbleos repository: docs/development/moddable.md.

Overview

  • Building with Moddable
  • Installable applications
  • Sandbox