Skip to main content

JavaScript runtime API

In 27.0.29, window.avstudio exposes the running project's navigation, signals, data, and variables to custom code. It is available in Live Preview and production builds, including inside Custom Element frames through the injected bridge. It is absent from the editor canvas.

Insert an API call​

Open a JavaScript file and use the editor context menu's AVstudio API Functions submenu, or search the Command Palette for a method's snippet title. New functions also include a commented API hint block. Keep the named, synchronous, export-free function contract.

function selectRoom(data) {
window?.avstudio?.setVariableByName({ name: "selectedRoom", value: data });
window?.avstudio?.navigate("/rooms/controls.page");
return data;
}

Create the target variable and page first, select the function in its consuming action, and test that event in preview. The example writes shared state explicitly; a Function action does not consume its return value as an assignment.

Available methods​

MethodArgumentsBehavior
navigateURL path, such as "/rooms/controls.page"Navigate using the runtime router.
navigateToPagePage's name stringCase-insensitive name lookup; warns when no page matches.
publishDigital{ signalName, value }Publish a boolean through the active signal driver.
publishAnalog{ signalName, value }Publish a number.
publishSerial{ signalName, value }Publish text.
getInstantDigitalFb{ signalName, defaultValue }Read cached digital feedback.
getInstantAnalogFb{ signalName, defaultValue }Read cached analog feedback.
getInstantSerialFb{ signalName, defaultValue }Read cached serial feedback.
getDatasource{} or { path: "datasources/rooms.datasource" }Return all resolved datasource values, or one datasource's value. Missing path returns undefined.
getVariableByName{ name }Read current global value or its default before an update.
setVariableByName{ name, value }Write through the same store used by Variable actions.

Use the optional-chaining form shown above so code tolerates an unavailable runtime API. Feedback reads are synchronous cache reads, not requests to the processor; absent/unread feedback returns the supplied default. Publishing without a started connector logs and drops the write. Datasource reads return the data used by dynamic datasource tokens.

Migration and verification​

Use window.avstudio, replacing legacy window.avgatorStudio references. Legacy setStoreValue, getStoreValue, and audioControl have no equivalent methods: use variables and Audio actions as appropriate.

Test navigation, a variable read/write, and each required signal against the intended runtime. Check processor receipt separately from local API execution and defaults separately from incoming feedback. For legacy builds, use the staged migration workflow.