@@ -3,42 +3,43 @@ import OpenCombine
33import OpenSpatial
44
55/// A graph host for a scene.
6- package final class SceneGraph : GraphHost {
6+ @MainActor
7+ class SceneGraph : GraphHost {
78
89 // MARK: - Represented object
910
1011 /// The scene outputs snapshot for this node.
11- package private( set) var outputs : _SceneOutputs
12+ private( set) var outputs : _SceneOutputs
1213
1314 // MARK : - Window Associated objects
1415
1516 /// Runtime window for renderable scenes (e.g. `Window`).
16- package private( set) var window : _Window ? = nil
17+ private( set) var window : _Window ? = nil
1718
1819 // MARK: - Runtime Associated objects
1920
2021 /// The environment values for the scene.
21- package var environmentValues : EnvironmentValues
22+ var environmentValues : EnvironmentValues
2223
2324 /// Whether this scene is the main scene.
24- package var isMain : Bool = false
25+ var isMain : Bool = false
2526
2627 /// The title of the scene.
27- package var title : PassthroughSubject < String , Never > = PassthroughSubject < String , Never > ( )
28+ var title : PassthroughSubject < String , Never > = PassthroughSubject < String , Never > ( )
2829
2930 /// The phase of the scene.
30- package var scenePhase : PassthroughSubject < ScenePhase , Never > = PassthroughSubject < ScenePhase , Never > ( )
31+ var scenePhase : PassthroughSubject < ScenePhase , Never > = PassthroughSubject < ScenePhase , Never > ( )
3132
3233 /// The runtime subscriptions for this node.
33- private var cancellables : Set < AnyCancellable > = [ ]
34+ var cancellables : Set < AnyCancellable > = [ ]
3435
3536 /// The runtime view graph for this scene's root view.
36- @ MainActor package private( set) var viewGraph : ViewGraph ? = nil
37+ private( set) var viewGraph : ViewGraph ? = nil
3738
3839 /// Creates a scene graph with the given outputs.
3940 ///
4041 /// - Parameter outputs: The outputs of the scene.
41- package init ( outputs: _SceneOutputs ) {
42+ init ( outputs: _SceneOutputs ) {
4243 self . outputs = outputs
4344 self . environmentValues = outputs. environmentValues
4445
@@ -61,7 +62,7 @@ package final class SceneGraph : GraphHost {
6162 // MARK: - Runtime lifecycle
6263
6364 /// Creates runtime objects for this scene node and its descendants.
64- @ MainActor package func mountRuntime( ) {
65+ func mountRuntime( ) {
6566 if let content = outputs. content {
6667 // Create window from scene outputs (runtime lives in the graph, not in outputs).
6768 let title = outputs. title ?? String ( describing: outputs. type)
@@ -88,7 +89,7 @@ package final class SceneGraph : GraphHost {
8889 }
8990 }
9091
91- @ MainActor package func unmountRuntime( ) {
92+ func unmountRuntime( ) {
9293 cancellables. removeAll ( )
9394 if let w = window {
9495 w. destroy ( )
@@ -101,7 +102,7 @@ package final class SceneGraph : GraphHost {
101102 }
102103 }
103104
104- override package func mount( ) {
105+ override func mount( ) {
105106 let window = _Window ( frame: Rect3D ( center: Point3D . zero, size: Size3D ( width: 900 , height: 450 , depth: 0 ) ) , title: " \( Self . self) " )
106107 self . window = window
107108 window. delegate = self
@@ -116,7 +117,7 @@ package final class SceneGraph : GraphHost {
116117 /// Reconciles this node with a new `_SceneOutputs` snapshot.
117118 ///
118119 /// Identity is based on `outputs.id`. For nodes without stable IDs, this will recreate.
119- @ MainActor package func reconcile( newOutputs: _SceneOutputs ) {
120+ func reconcile( newOutputs: _SceneOutputs ) {
120121 let oldHadWindow = ( outputs. content != nil )
121122 let newHasWindow = ( newOutputs. content != nil )
122123
@@ -186,15 +187,15 @@ package final class SceneGraph : GraphHost {
186187
187188 // MARK: - Queries
188189
189- @ MainActor package func firstWindow( ) -> _Window ? {
190+ func firstWindow( ) -> _Window ? {
190191 if let w = window { return w }
191192 for child in children {
192193 if let w = ( child as? SceneGraph ) ? . firstWindow ( ) { return w }
193194 }
194195 return nil
195196 }
196197
197- @ MainActor package func collectWindowScenes( into result: inout [ SceneGraph ] ) {
198+ func collectWindowScenes( into result: inout [ SceneGraph ] ) {
198199 if window != nil {
199200 result. append ( self )
200201 }
@@ -204,7 +205,7 @@ package final class SceneGraph : GraphHost {
204205 }
205206}
206207
207- extension SceneGraph : CustomStringConvertible {
208+ extension SceneGraph : @ MainActor CustomStringConvertible {
208209 package var description : String {
209210 """
210211 - SceneGraph<outputs: \( outputs. type) >
@@ -214,7 +215,7 @@ extension SceneGraph : CustomStringConvertible {
214215 }
215216}
216217
217- extension SceneGraph : WindowDelegate {
218+ extension SceneGraph : @ MainActor WindowDelegate {
218219
219220 /// Tells the delegate that the window is about to be minimized.
220221 package func windowWillMiniaturize( _ window: _Window ) {
0 commit comments