Skip to main content

Module javascript

Module javascript 

Source
Expand description

In-app scratch scripts. Source is saved only on request and never on a model.

Structs§

JavaScriptEditor

Constants§

WINDOW_ID
The window’s egui id — one name for the panel, the tests and the host.

Statics§

HIT_KEYS
The hit keys this window publishes under __brepJavascriptHit (see automation::hit_keys); panel:clip is the key every scrolling pane publishes for its visible region, so click_widget can wheel a row into view.

Traits§

ScriptHost
Where Run sends a program when the app has a script runner: the app’s own server’s code mode (crate::mcp::EditorHost), the same worker, limits and sdk.<namespace>.<action> functions an agent’s run program gets. Without one (the web build, a bare test harness) Run uses the plugin runner’s editor action.

Functions§

program
An editor script as a program for the ScriptHost: both are plain script bodies with top-level await and return, and sdk (every app command as await sdk.<namespace>.<action>(args)) is the runner’s global. The editor adds its own names around the body: cad.document (the history snapshot with addFeature(type, params, persistentData), updateFeature(id, params) (a merge, as feature_set_params merges) and deleteFeature(id)), cad.selection, cad.sdk (the same sdk) and ui.notify. The document commands apply in order after the body returns, and a returned value prints as Result:. One leading import … from "@brep/cad" line is dropped, as the runner drops it.