Handbook · Scripts

Scripts

Where in the UI. Scripts tab (Blockly + generated JS). Structure wires from element/layout/component handles to script nodes. Lifecycle events on element inspectors.

Blockly is how you author behavior. The JS tab is a check: it is generated, sandboxed, and not the place to invent APIs.

Blockly vs generated JS

Treat Blockly as the source of truth. The JS view is what the js-interpreter sandbox runs. Do not invent host APIs there — only methods in host methods exist, and each needs a capability. If you edit JS until it no longer matches the blocks, the editor will ask you to confirm; that can invalidate the Blockly graph. Prefer fixing blocks, not hand-writing JS. The JSON tab stores the same script payload the app loads.

When a script runs

Toolbox map

Stock: Logic, Loops, Math, Text, Lists, Variables, Functions. Containd categories: Dialogs, Text helpers, Navigation, Tree, Layouts, Data, Table, Class, Relatives, DateTime, Units, Statistics, Device, Canvas, Graph, Media, Files, Items, AI, System, Actions, Shared, Advanced. Indexes: Blockly, host methods.

Tasks

  1. Create a script; in Blockly show an alert with ContaindText (not a stock English string if users will see it).
  2. Wire a button press to that script.
  3. Preview: tap the button. If policy complains, read the capability on the block.