33#include <unordered_map>
34#include <unordered_set>
44struct BridgeCallbackState;
54 std::unordered_map<std::string, float>
values;
109 if (!(
scale > 0.0f))
return;
110 imported_text_scale_ = std::clamp(
scale, 0.5f, 4.0f);
137 std::string_view receiver,
138 std::string_view
type,
139 const choc::value::Value& payload,
140 std::string_view
id = {},
141 std::string_view context =
"native message dispatch");
147 asset_roots_.clear();
148 asset_roots_.reserve(roots.size());
149 for (
auto& root : roots) {
150 if (root.empty())
continue;
152 auto abs = std::filesystem::absolute(root, ec).lexically_normal();
153 if (ec) abs = root.lexically_normal();
154 asset_roots_.push_back(std::move(abs));
157 const std::vector<std::filesystem::path>&
asset_roots() const noexcept {
return asset_roots_; }
164 const unsigned char*
data =
nullptr;
174 return embedded_assets_;
192 storage_identity_ = std::move(identity);
207 if (dir.empty()) { script_base_dir_.clear();
return; }
209 auto abs = std::filesystem::absolute(dir, ec).lexically_normal();
210 script_base_dir_ = ec ? dir.lexically_normal() : abs;
212 const std::filesystem::path&
script_base_dir() const noexcept {
return script_base_dir_; }
224 allow_unreviewed_file_paths_ = allow;
227 return allow_unreviewed_file_paths_;
254 void load_script(
const std::string& code,
const std::string& script_id);
310 uint16_t modifiers,
bool is_down);
332 const
std::
string& event_json_literal);
337 bool include_custom_state =
true)
const;
343 bool include_custom_state =
true);
358 return pending_runtime_settle_rounds_;
389 return owned_widgets_.size();
392 return widgets_.size();
399 return bridge_call_count_->load(std::memory_order_relaxed);
402 bridge_call_count_->store(0, std::memory_order_relaxed);
434 bool forward_key_event_handled(
int key_code, uint16_t modifiers,
435 bool is_down,
View* focus_root =
nullptr);
444 void evaluate_claude_bundle_in_live_engine(const
ClaudeBundle& bundle);
482 const std::string&
host_kind()
const {
return host_kind_; }
486 using TimeSource = std::function<std::chrono::steady_clock::time_point()>;
488 std::chrono::steady_clock::time_point
time_now()
const;
504 void set_bench_counters(render::bench::PerfCounters* counters);
508 struct NativeGpuBridgeState;
519 std::unique_ptr<NativeGpuBridgeState> native_gpu_bridge_state_;
520 std::vector<std::filesystem::path> asset_roots_;
521 std::filesystem::path script_base_dir_;
522 bool allow_unreviewed_file_paths_ =
false;
523 std::vector<EmbeddedAsset> embedded_assets_;
524 std::string storage_identity_;
530 struct PrivateStoreDirs {
531 std::string identity;
532 std::optional<std::filesystem::path> widget_storage;
533 std::optional<std::filesystem::path> style_presets;
535 PrivateStoreDirs private_store_dirs_;
546 struct BridgeWidgetState {
548 std::uint64_t validated_generation = 0;
549 std::uint64_t instance_id = 0;
550 BridgeWidgetState() =
default;
551 BridgeWidgetState(
View*
v)
553 instance_id(
v ?
v->import_binding_instance_id() : 0) {}
554 BridgeWidgetState& operator=(View*
v) {
556 validated_generation = 0;
557 instance_id =
v ?
v->import_binding_instance_id() : 0;
560 operator View*()
const {
return view; }
561 View* operator->()
const {
return view; }
562 bool identifies(
const View*
candidate)
const {
564 instance_id ==
candidate->import_binding_instance_id();
569 :
public std::unordered_map<std::string, BridgeWidgetState> {
570 using Base = std::unordered_map<std::string, BridgeWidgetState>;
573 explicit WidgetRegistry(std::vector<BridgeWidgetState>& owned_widgets)
574 : owned_widgets_(owned_widgets) {}
579 std::vector<BridgeWidgetState>& owned_widgets)
580 : state_(
state), owned_widgets_(owned_widgets) {}
584 owned_widgets_.emplace_back(
view);
590 BridgeWidgetState& state_;
591 std::vector<BridgeWidgetState>& owned_widgets_;
594 AssignmentSlot operator[](
const std::string&
id) {
595 return AssignmentSlot(Base::operator[](
id), owned_widgets_);
598 void cache(
const std::string&
id,
View*
view) {
599 Base::operator[](
id) =
view;
603 std::vector<BridgeWidgetState>& owned_widgets_;
609 std::vector<BridgeWidgetState> owned_widgets_;
610 WidgetRegistry widgets_;
611 std::unordered_map<std::string, ScrollView*> scroll_wrappers_;
622 struct WidgetRegistrations {
623 bool pointer =
false;
628 std::vector<std::string> gesture_recognizers;
630 std::unordered_map<std::string, WidgetRegistrations> registrations_;
635 bool claim_pointer_registration(
const std::string&
id);
636 bool claim_wheel_registration(
const std::string&
id);
637 bool claim_gesture_registration(
const std::string&
id,
638 const std::string& recognizer_key);
641 struct ShortcutBinding {
644 std::string callback;
646 std::vector<ShortcutBinding> shortcuts_;
652 CssKeyframesRegistry css_keyframes_registry_;
659 std::string ai_cli_command_ =
"claude --print --model {model}";
660 std::string host_kind_ =
"unknown";
662 std::chrono::steady_clock::time_point performance_epoch_ = std::chrono::steady_clock::now();
664 struct AsyncExecResult {
665 std::string callback_id;
672 float imported_text_scale_ = 1.0f;
673 std::shared_ptr<BridgeCallbackState> callback_alive_;
674 std::shared_ptr<std::mutex> async_exec_mutex_ = std::make_shared<std::mutex>();
675 std::shared_ptr<std::vector<AsyncExecResult>> async_exec_results_ =
676 std::make_shared<std::vector<AsyncExecResult>>();
684 std::function<void(
const std::string& callback_id, std::string payload)>
685 make_async_result_sink();
693 std::shared_ptr<QueryService> query_service_;
695 std::vector<int> pending_frame_ids_;
709 bool frames_drained_by_service_ =
false;
710 bool frame_pump_live_ =
false;
711 std::shared_ptr<std::atomic<std::uint64_t>> bridge_call_count_ =
712 std::make_shared<std::atomic<std::uint64_t>>(0);
716 int pending_runtime_settle_rounds_ = 0;
717 bool frame_preamble_loaded_ =
false;
722 std::string active_script_id_;
726 bool runtime_import_installed_ =
false;
727 bool realm_quarantined_ =
false;
728 bool realm_retired_ =
false;
732 struct RetiredRealmState {
733 std::vector<std::unique_ptr<View>> children;
734 std::unique_ptr<ActiveDrag> drag;
735 std::unique_ptr<View::RootInteractionState> interaction;
736 std::function<void(
const std::string&, uint16_t)> root_click_callback;
738 RetiredRealmState retired_realm_;
739 RetiredRealmState emergency_retired_realm_;
746 struct PendingTimer {
748 std::chrono::steady_clock::time_point deadline;
749 std::chrono::milliseconds interval;
752 std::vector<PendingTimer> pending_timers_;
759 struct BindingTransform {
761 float db_min = -60.0f;
766 float clamp_min = 0.0f;
767 float clamp_max = 1.0f;
768 float apply(
float v)
const;
770 struct ParamBinding {
772 std::string widget_id;
777 std::string value_channel;
779 std::string uniform_name;
784 std::uint32_t last_publish_seq = 0;
785 std::uint64_t value_generation_identity = 0;
786 std::chrono::steady_clock::time_point last_publish_at{};
787 float neutral = 0.0f;
788 Target target = Target::value;
789 BindingTransform transform;
793 bool derive_from_param =
false;
794 float last_applied = std::numeric_limits<float>::quiet_NaN();
796 std::vector<ParamBinding> param_bindings_;
798 std::vector<ParamSubscription> param_subscriptions_;
799 std::uint32_t next_param_subscription_id_ = 1;
802 bool in_param_dispatch_ =
false;
803 struct EventBinding {
804 std::uint32_t
id = 0;
805 std::string channel_name;
806 std::uint32_t last_publication = 0;
807 std::uint64_t value_generation_identity = 0;
809 std::vector<EventBinding> event_bindings_;
810 std::uint32_t next_event_binding_id_ = 1;
811 bool in_event_dispatch_ =
false;
812 struct ParamGestureRoute {
816 std::unordered_map<std::string, std::shared_ptr<ParamGestureRoute>>
817 param_gesture_routes_;
821 bool add_param_binding(
const std::string& widget_id,
822 const std::string& param_name,
823 ParamBinding::Target target,
824 const choc::value::Value* transform);
825 bool add_shader_uniform_binding(
const std::string& widget_id,
826 const std::string& uniform_name,
827 const std::string& source,
828 const choc::value::Value* transform);
831 static BindingTransform parse_transform(
const choc::value::Value*
v);
833 static bool transform_requests_derivation(
const choc::value::Value*
v);
836 bool resolve_param_id(
const std::string& name,
state::ParamID& out)
const;
840 void prune_dangling_bindings();
844 void wire_parameter_gestures(
const std::string& widget_id, View*
widget);
849 void begin_param_gesture(
const std::string& widget_id);
850 void end_param_gesture(
const std::string& widget_id);
851 void finish_param_gesture_route(
852 const std::shared_ptr<ParamGestureRoute>& route);
853 void release_param_gesture_route(
const std::string& widget_id)
noexcept;
854 void release_all_param_gesture_routes() noexcept;
855 void defer_all_param_gesture_routes();
859 void forget_widget_subtree(View* node,
bool preserve_js_dom_state = false,
861 bool notify_js =
true);
862 void retire_removed_widget(std::unique_ptr<View>
widget);
865 void commit_realm_retirement(RetiredRealmState& destination)
noexcept;
866 void unregister_global_dispatch() noexcept;
867 void unregister_global_dispatch(const
DeadlineCheck& deadline_check);
868 std::vector<BridgeWidgetState> foreign_owned_widget_states() const;
869 void begin_root_quarantine() noexcept;
870 void end_root_quarantine();
871 void invalidate_cached_subtrees_everywhere(
872 const std::vector<View*>& nodes,
876 void forget_widget_event_state(View& view);
880 bool apply_param_binding(ParamBinding& binding, View*
w,
881 const MeterFrame* value_frame =
nullptr,
882 std::uint32_t publish_seq = 0);
884 void derive_binding_transform(ParamBinding& binding, View*
w);
886 bool apply_scope_binding(ParamBinding& binding, View*
w,
887 const VectorFrame* value_frame,
888 std::uint32_t publish_seq);
891 static bool value_channel_is_stale(ParamBinding& binding, std::uint32_t seq);
897 return binding_attempts_;
907 const std::string& param_name,
914 std::vector<BindingAttempt> binding_attempts_;
916 std::function<void()> repaint_callback_;
919 bool default_repaint_callback_ =
true;
920 std::uint64_t repaint_request_generation_ = 0;
923 render::bench::PerfCounters* bench_counters_ =
nullptr;
931 View* resolve_parent(
const std::string& parent_id,
const View* child =
nullptr);
935 bool attach_created(
const std::string&
id,
const std::string& parent_id,
936 std::unique_ptr<View>
view);
939 void wire_callbacks(
const std::string&
id,
View*
w);
942 void forget_widget_registrations(
const std::string&
id);
953 std::unique_ptr<View> make_widget_for_tag(
const std::string& tag,
954 const std::string&
id);
961 void request_repaint();
967 bool claim_document_navigation_focus();
968 void release_document_navigation_focus() noexcept;
991 void ensure_layout();
992 std::uint64_t last_layout_generation_ = 0;
997 struct NavigationOffer {
999 std::uint16_t modifiers = 0;
1000 bool is_down =
false;
1001 bool pending =
false;
1003 NavigationOffer last_navigation_offer_{};
1006 void register_api();
Why a widget→parameter binding attempt did or did not take effect.
A processor's declared channels.
Definition value_channel_set.hpp:61
Abstract GPU surface — a presentable rendering target backed by a native window/view.
Definition gpu_surface.hpp:112
Centralized parameter storage with lock-free value access.
Definition store.hpp:164
A granted-capability set.
Definition reload_capabilities.hpp:74
static CapabilitySet all()
Definition reload_capabilities.hpp:78
Definition query_service.hpp:51
Definition script_engine.hpp:22
std::function< void(ValueChannelSet *)> ValueChannelVisitor
Runs a value-channel operation while the hosting processor guarantees that the exposed set and all of...
Definition value_channel_set.hpp:52
std::function< void(const ValueChannelVisitor &)> ValueChannelAccess
Definition value_channel_set.hpp:53
SequencerStateChannel is the audio-safe transport for a plugin's structured NON-parameter state: the ...
Definition audio_device_manager.hpp:48
uint32_t ParamID
Unique parameter identifier, stable across plugin versions.
Definition parameter.hpp:55
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ path
Definition anchor_strategy.hpp:42
@ type
Built-in / common type name (e.g. int, Number).
Definition code_editor_tokenizer.hpp:39
BindingOutcome
The outcome of one bindWidgetToParam / bindMeter call.
Definition binding_diagnostics.hpp:26
BindingTarget
What a binding drives on its widget.
Definition binding_diagnostics.hpp:18
KeyCode
Definition input_events.hpp:35
@ v
Definition input_events.hpp:41
@ w
Definition input_events.hpp:41
@ candidate
Definition waveform_editor_primitives.hpp:193
@ scale
Definition css_animation.hpp:126
Definition canvas_widget.hpp:222
Result of unpacking a Claude Design bundle's <script type="__bundler/manifest">.
Definition design_source_types.hpp:113
Application-wide registry for @keyframes blocks.
Definition css_animation.hpp:300
Source-compatible spelling of <pulp/dataplane/value_channel_set.hpp>.