feat: notify Endor objects of mount lifecycle transitions
Verify Tessera GUI / verify (push) Failing after 7m23s
Verify Tessera GUI / verify (push) Failing after 7m23s
This commit is contained in:
+40
-13
@@ -210,6 +210,8 @@ enum Operation {
|
||||
On,
|
||||
Dispatch,
|
||||
OnEvent,
|
||||
OnMount,
|
||||
OnUnmount,
|
||||
Click,
|
||||
Present,
|
||||
}
|
||||
@@ -493,7 +495,7 @@ impl NativeCallable for Function {
|
||||
Click => (0, 1),
|
||||
On => (2, 3),
|
||||
Dispatch => (1, 2),
|
||||
OnEvent => (1, 1),
|
||||
OnEvent | OnMount | OnUnmount => (1, 1),
|
||||
};
|
||||
if !(minimum..=maximum).contains(&args.len()) {
|
||||
return Err(invalid("incorrect UI method argument count"));
|
||||
@@ -916,7 +918,7 @@ impl NativeCallable for Function {
|
||||
data.subscriptions = active;
|
||||
result = Value::Object(token);
|
||||
}
|
||||
OnEvent => return Ok(NativeResult::Return(Value::Nil)),
|
||||
OnEvent | OnMount | OnUnmount => return Ok(NativeResult::Return(Value::Nil)),
|
||||
Click | Dispatch => {
|
||||
let desktop = self
|
||||
.session
|
||||
@@ -1095,19 +1097,42 @@ impl UiBridge {
|
||||
let page = state.pending.unwrap_or(state.active);
|
||||
let desktop = state.desktop;
|
||||
let nodes = state.nodes.clone();
|
||||
state.mounts.synchronize(vm, desktop, page, nodes, frame)?;
|
||||
if snapshot.is_none() {
|
||||
state.layout.clear_occurrences();
|
||||
let hooks = state.mounts.synchronize(vm, desktop, page, nodes, frame)?;
|
||||
let result = (|| {
|
||||
if snapshot.is_none() {
|
||||
state.layout.clear_occurrences();
|
||||
}
|
||||
if let Some(page) = state.pending.take() {
|
||||
state.active = page;
|
||||
}
|
||||
vm.set_attr(state.desktop, "pending", Value::Nil)?;
|
||||
vm.set_attr(state.desktop, "focusRequested", Value::Bool(false))?;
|
||||
state.last_snapshot = snapshot;
|
||||
state.published_version = frame.layout_version;
|
||||
// Hooks may call Page/container APIs; never hold the session mutex
|
||||
// across user code. Publish only after the refresh loop settles.
|
||||
drop(state);
|
||||
if let Some(hooks) = hooks {
|
||||
let value = vm
|
||||
.call_with_limits(
|
||||
hooks,
|
||||
&[],
|
||||
endor_core::ExecutionLimits {
|
||||
max_frames: 128,
|
||||
max_instructions: 1_000_000,
|
||||
},
|
||||
)
|
||||
.map_err(|error| crate::endor_host::runtime_error(vm, error))?;
|
||||
vm.release_value(value)?;
|
||||
}
|
||||
Ok(())
|
||||
})();
|
||||
if let Some(hooks) = hooks {
|
||||
vm.release(hooks)?;
|
||||
}
|
||||
if let Some(page) = state.pending.take() {
|
||||
state.active = page;
|
||||
}
|
||||
vm.set_attr(state.desktop, "pending", Value::Nil)?;
|
||||
vm.set_attr(state.desktop, "focusRequested", Value::Bool(false))?;
|
||||
state.last_snapshot = snapshot;
|
||||
state.published_version = frame.layout_version;
|
||||
Ok(())
|
||||
result
|
||||
}
|
||||
|
||||
pub fn layout_frame(&self, vm: &Vm, root: &UiNode) -> Result<crate::document::Frame> {
|
||||
let mut state = self
|
||||
.session
|
||||
@@ -1291,6 +1316,8 @@ pub fn install(vm: &mut Vm, roots: &mut Vec<ObjectRef>) -> Result<UiBridge> {
|
||||
("Block", "on", Operation::On),
|
||||
("Block", "dispatch", Operation::Dispatch),
|
||||
("Block", "onEvent", Operation::OnEvent),
|
||||
("Block", "onMount", Operation::OnMount),
|
||||
("Block", "onUnmount", Operation::OnUnmount),
|
||||
("Block", "click", Operation::Click),
|
||||
("TextBlock", "setText", Operation::SetText),
|
||||
("TextBlock", "setColor", Operation::SetColor),
|
||||
|
||||
Reference in New Issue
Block a user