Skip to content

sweetbean.protection._context

Module-level context for the currently-active protections during JS generation.

Stimulus-level hooks (_BaseStimulus._on_load_js / to_js) consult this during compilation so each trial's on_load and on_finish callbacks can embed protection-specific JS (e.g. per-trial slider tracking, inline traps).

Experiment sets the active protections immediately before generating stimulus JS and clears them in a finally so a partial compile never leaks state into a later one.