M3 app model: App, Entity, Context, subscriptions, events, globals
- app: port of GPUI's App effect cycle (update / flush_effects with deferred subscription activation and notification dedup), EntityMap (typed cells, leasing, explicit release), Context<T> (notify, emit, observe, subscribe, observe_self/subscribe_self, on_release, observe_release, observe_global, defer_call), SubscriberSet and Subscription. - TypeId-keyed maps become EventKey[E] / GlobalKey[G]: values cross the app's untyped maps as closures writing into the key's typed slot. - No Drop: App::release replaces the last-handle drop; subscriptions end with unsubscribe() or when their entity is released. - Fail loudly on re-entrant updates, reads during updates, use after release, cross-app use, missing globals, global_mut outside an update. - Tests: GPUI's subscription tests ported, plus app-model and panic tests. - examples/counter; PORTING.md M3 status, deviations, toolchain notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cca9a49c51
commit
64bf747047
15 files changed
+1940
-8
No files matched your search
@@ -0,0 +1,113 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "experiments/gpui/app"
|
||||
|
||||
import {
|
||||
"moonbitlang/core/debug",
|
||||
}
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub struct App {
|
||||
// private fields
|
||||
}
|
||||
pub fn[G] App::default_global(Self, GlobalKey[G], () -> G) -> G
|
||||
pub fn App::defer_call(Self, (Self) -> Unit) -> Unit
|
||||
pub fn App::entity_count(Self) -> Int32
|
||||
pub fn[G] App::global(Self, GlobalKey[G]) -> G
|
||||
pub fn[G] App::global_mut(Self, GlobalKey[G]) -> G
|
||||
pub fn[G] App::has_global(Self, GlobalKey[G]) -> Bool
|
||||
pub fn[T] App::insert_entity(Self, Reservation[T], (Context[T]) -> T) -> Entity[T]
|
||||
pub fn App::new() -> Self
|
||||
pub fn[T] App::new_entity(Self, (Context[T]) -> T) -> Entity[T]
|
||||
pub fn App::notify(Self, EntityId) -> Unit
|
||||
pub fn[T] App::observe(Self, Entity[T], (Entity[T], Self) -> Unit) -> Subscription
|
||||
pub fn[G] App::observe_global(Self, GlobalKey[G], (Self) -> Unit) -> Subscription
|
||||
pub fn[T] App::observe_release(Self, Entity[T], (T, Self) -> Unit) -> Subscription
|
||||
pub fn[T] App::read_entity(Self, Entity[T]) -> T
|
||||
pub fn[T] App::release(Self, Entity[T]) -> Unit
|
||||
pub fn[G] App::remove_global(Self, GlobalKey[G]) -> G
|
||||
pub fn[T] App::reserve_entity(Self) -> Reservation[T]
|
||||
pub fn[G] App::set_global(Self, GlobalKey[G], G) -> Unit
|
||||
pub fn[T, E] App::subscribe(Self, Entity[T], EventKey[E], (Entity[T], E, Self) -> Unit) -> Subscription
|
||||
pub fn[G] App::try_global(Self, GlobalKey[G]) -> G?
|
||||
pub fn[R] App::update(Self, (Self) -> R) -> R
|
||||
pub fn[T, R] App::update_entity(Self, Entity[T], (T, Context[T]) -> R) -> R
|
||||
pub fn[G, R] App::update_global(Self, GlobalKey[G], (G, Self) -> R) -> R
|
||||
|
||||
pub struct Context[T] {
|
||||
app : App
|
||||
// private fields
|
||||
}
|
||||
pub fn[T] Context::defer_call(Self[T], (App) -> Unit) -> Unit
|
||||
pub fn[T, E] Context::emit(Self[T], EventKey[E], E) -> Unit
|
||||
pub fn[T] Context::entity(Self[T]) -> Entity[T]
|
||||
pub fn[T] Context::entity_id(Self[T]) -> EntityId
|
||||
pub fn[T] Context::notify(Self[T]) -> Unit
|
||||
pub fn[T, W] Context::observe(Self[T], Entity[W], (T, Entity[W], Self[T]) -> Unit) -> Subscription
|
||||
pub fn[T, G] Context::observe_global(Self[T], GlobalKey[G], (T, Self[T]) -> Unit) -> Subscription
|
||||
pub fn[T, W] Context::observe_release(Self[T], Entity[W], (T, W, Self[T]) -> Unit) -> Subscription
|
||||
pub fn[T] Context::observe_self(Self[T], (T, Self[T]) -> Unit) -> Subscription
|
||||
pub fn[T] Context::on_release(Self[T], (T, App) -> Unit) -> Subscription
|
||||
pub fn[T, W, E] Context::subscribe(Self[T], Entity[W], EventKey[E], (T, Entity[W], E, Self[T]) -> Unit) -> Subscription
|
||||
pub fn[T, E] Context::subscribe_self(Self[T], EventKey[E], (T, E, Self[T]) -> Unit) -> Subscription
|
||||
pub fn[T] Context::weak_entity(Self[T]) -> WeakEntity[T]
|
||||
|
||||
pub struct Entity[T] {
|
||||
// private fields
|
||||
}
|
||||
pub fn[T] Entity::downgrade(Self[T]) -> WeakEntity[T]
|
||||
pub fn[T] Entity::entity_id(Self[T]) -> EntityId
|
||||
pub fn[T] Entity::is_released(Self[T]) -> Bool
|
||||
pub fn[T] Entity::read(Self[T], App) -> T
|
||||
pub fn[T, R] Entity::update(Self[T], App, (T, Context[T]) -> R) -> R
|
||||
pub impl[T] Eq for Entity[T]
|
||||
pub impl[T] Hash for Entity[T]
|
||||
pub impl[T] Show for Entity[T]
|
||||
|
||||
#derive(Compare, Eq, Hash, @debug.Debug)
|
||||
pub(all) struct EntityId(Int32)
|
||||
pub impl Show for EntityId
|
||||
|
||||
pub struct EventKey[E] {
|
||||
id : Int32
|
||||
name : String
|
||||
// private fields
|
||||
}
|
||||
pub fn[E] EventKey::new(String) -> Self[E]
|
||||
|
||||
pub struct GlobalKey[G] {
|
||||
id : Int32
|
||||
name : String
|
||||
// private fields
|
||||
}
|
||||
pub fn[G] GlobalKey::new(String) -> Self[G]
|
||||
|
||||
pub struct Reservation[T] {
|
||||
// private fields
|
||||
}
|
||||
pub fn[T] Reservation::entity_id(Self[T]) -> EntityId
|
||||
|
||||
type SubscriberSet[K, C]
|
||||
|
||||
pub struct Subscription {
|
||||
// private fields
|
||||
}
|
||||
pub fn Subscription::detach(Self) -> Unit
|
||||
pub fn Subscription::is_active(Self) -> Bool
|
||||
pub fn Subscription::join(Self, Self) -> Self
|
||||
pub fn Subscription::new(() -> Unit) -> Self
|
||||
pub fn Subscription::unsubscribe(Self) -> Unit
|
||||
|
||||
pub struct WeakEntity[T] {
|
||||
// private fields
|
||||
}
|
||||
pub fn[T] WeakEntity::entity_id(Self[T]) -> EntityId
|
||||
pub fn[T, R] WeakEntity::update(Self[T], App, (T, Context[T]) -> R) -> R?
|
||||
pub fn[T] WeakEntity::upgrade(Self[T]) -> Entity[T]?
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
Reference in new issue
Block a user