objc2_tv_ml_kit/generated/
TVApplicationController.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-javascript-core")]
8use objc2_javascript_core::*;
9#[cfg(feature = "objc2-ui-kit")]
10use objc2_ui_kit::*;
11
12use crate::*;
13
14extern_class!(
15    /// This class is used to provide launch info to TVApplicationController.
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvmlkit/tvapplicationcontrollercontext?language=objc)
18    #[unsafe(super(NSObject))]
19    #[derive(Debug, PartialEq, Eq, Hash)]
20    #[deprecated = "Please use SwiftUI or UIKit"]
21    pub struct TVApplicationControllerContext;
22);
23
24extern_conformance!(
25    unsafe impl NSCopying for TVApplicationControllerContext {}
26);
27
28unsafe impl CopyingHelper for TVApplicationControllerContext {
29    type Result = Self;
30}
31
32extern_conformance!(
33    unsafe impl NSObjectProtocol for TVApplicationControllerContext {}
34);
35
36impl TVApplicationControllerContext {
37    extern_methods!(
38        /// URL to application JavaScript.
39        #[deprecated = "Please use SwiftUI or UIKit"]
40        #[unsafe(method(javaScriptApplicationURL))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn javaScriptApplicationURL(&self) -> Retained<NSURL>;
43
44        /// Setter for [`javaScriptApplicationURL`][Self::javaScriptApplicationURL].
45        ///
46        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
47        #[deprecated = "Please use SwiftUI or UIKit"]
48        #[unsafe(method(setJavaScriptApplicationURL:))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn setJavaScriptApplicationURL(&self, java_script_application_url: &NSURL);
51
52        /// Optional identifier for local storage file name.
53        #[deprecated = "Please use SwiftUI or UIKit"]
54        #[unsafe(method(storageIdentifier))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn storageIdentifier(&self) -> Option<Retained<NSString>>;
57
58        /// Setter for [`storageIdentifier`][Self::storageIdentifier].
59        ///
60        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
61        #[deprecated = "Please use SwiftUI or UIKit"]
62        #[unsafe(method(setStorageIdentifier:))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn setStorageIdentifier(&self, storage_identifier: Option<&NSString>);
65
66        /// Allows PiP to happen when playing back media
67        #[deprecated = "Please use SwiftUI or UIKit"]
68        #[unsafe(method(supportsPictureInPicturePlayback))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn supportsPictureInPicturePlayback(&self) -> bool;
71
72        /// Setter for [`supportsPictureInPicturePlayback`][Self::supportsPictureInPicturePlayback].
73        #[deprecated = "Please use SwiftUI or UIKit"]
74        #[unsafe(method(setSupportsPictureInPicturePlayback:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn setSupportsPictureInPicturePlayback(
77            &self,
78            supports_picture_in_picture_playback: bool,
79        );
80
81        /// Data that gets passed to JavaScript onLaunch method. Values must be
82        /// serializable. If app intends for JavaScript to handle openURL: then
83        /// launchOptions should include UIApplicationLaunchOptionsURLKey and
84        /// UIApplicationLaunchOptionsSourceApplicationKey to the launch options.
85        /// TVApplicationController adds location (boot url) by default. If UIApplicationLaunchOptionsURLKey
86        /// and UIApplicationLaunchOptionsSourceApplicationKey are provided then
87        /// maps them to openURL and sourceAppIdentifier keys respectively.
88        #[deprecated = "Please use SwiftUI or UIKit"]
89        #[unsafe(method(launchOptions))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn launchOptions(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
92
93        /// Setter for [`launchOptions`][Self::launchOptions].
94        ///
95        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
96        ///
97        /// # Safety
98        ///
99        /// `launch_options` generic should be of the correct type.
100        #[deprecated = "Please use SwiftUI or UIKit"]
101        #[unsafe(method(setLaunchOptions:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn setLaunchOptions(&self, launch_options: &NSDictionary<NSString, AnyObject>);
104    );
105}
106
107/// Methods declared on superclass `NSObject`.
108impl TVApplicationControllerContext {
109    extern_methods!(
110        #[unsafe(method(init))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
113
114        #[unsafe(method(new))]
115        #[unsafe(method_family = new)]
116        pub unsafe fn new() -> Retained<Self>;
117    );
118}
119
120extern_protocol!(
121    /// [Apple's documentation](https://developer.apple.com/documentation/tvmlkit/tvapplicationcontrollerdelegate?language=objc)
122    #[deprecated = "Please use SwiftUI or UIKit"]
123    pub unsafe trait TVApplicationControllerDelegate: NSObjectProtocol {
124        #[cfg(feature = "objc2-javascript-core")]
125        /// This method lets delegate to add JavaScript classes and objects.
126        #[deprecated = "Please use SwiftUI or UIKit"]
127        #[optional]
128        #[unsafe(method(appController:evaluateAppJavaScriptInContext:))]
129        #[unsafe(method_family = none)]
130        unsafe fn appController_evaluateAppJavaScriptInContext(
131            &self,
132            app_controller: &TVApplicationController,
133            js_context: &JSContext,
134        );
135
136        /// Tells the delegate that the application did finish launching.
137        ///
138        /// # Safety
139        ///
140        /// `options` generic should be of the correct type.
141        #[deprecated = "Please use SwiftUI or UIKit"]
142        #[optional]
143        #[unsafe(method(appController:didFinishLaunchingWithOptions:))]
144        #[unsafe(method_family = none)]
145        unsafe fn appController_didFinishLaunchingWithOptions(
146            &self,
147            app_controller: &TVApplicationController,
148            options: Option<&NSDictionary<NSString, AnyObject>>,
149        );
150
151        /// Tells the delegate that the application failed to load.
152        #[deprecated = "Please use SwiftUI or UIKit"]
153        #[optional]
154        #[unsafe(method(appController:didFailWithError:))]
155        #[unsafe(method_family = none)]
156        unsafe fn appController_didFailWithError(
157            &self,
158            app_controller: &TVApplicationController,
159            error: &NSError,
160        );
161
162        /// Tells the delegate that the application did stop.
163        ///
164        /// # Safety
165        ///
166        /// `options` generic should be of the correct type.
167        #[deprecated = "Please use SwiftUI or UIKit"]
168        #[optional]
169        #[unsafe(method(appController:didStopWithOptions:))]
170        #[unsafe(method_family = none)]
171        unsafe fn appController_didStopWithOptions(
172            &self,
173            app_controller: &TVApplicationController,
174            options: Option<&NSDictionary<NSString, AnyObject>>,
175        );
176
177        #[cfg(feature = "TVPlayback")]
178        /// Asks the delegate for a custom player object for a particular player bridge.
179        #[deprecated = "Please use SwiftUI or UIKit"]
180        #[optional]
181        #[unsafe(method(playerForAppController:))]
182        #[unsafe(method_family = none)]
183        unsafe fn playerForAppController(
184            &self,
185            app_controller: &TVApplicationController,
186        ) -> Option<Retained<TVPlayer>>;
187    }
188);
189
190extern_class!(
191    /// The TVApplicationController class establishes the JavaScript environment
192    /// to provide a centralized point of control and co-ordination. The class
193    /// bridges the UI, navigation stack, storage and event handling from JavaScript.
194    ///
195    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvmlkit/tvapplicationcontroller?language=objc)
196    #[unsafe(super(NSObject))]
197    #[derive(Debug, PartialEq, Eq, Hash)]
198    #[deprecated = "Please use SwiftUI or UIKit"]
199    pub struct TVApplicationController;
200);
201
202extern_conformance!(
203    unsafe impl NSObjectProtocol for TVApplicationController {}
204);
205
206impl TVApplicationController {
207    extern_methods!(
208        #[cfg(feature = "objc2-ui-kit")]
209        /// Initializes and returns application controller given the launch context.
210        /// Optionally window can be passed, and in that case TVApplicationController
211        /// acts like an application delegate, and handles the JavaScript
212        /// application lifecycle events e.g. onResume, onSuspend. If window
213        /// is not provided, caller is responsible for hosting the navigationController.
214        #[deprecated = "Please use SwiftUI or UIKit"]
215        #[unsafe(method(initWithContext:window:delegate:))]
216        #[unsafe(method_family = init)]
217        pub unsafe fn initWithContext_window_delegate(
218            this: Allocated<Self>,
219            context: &TVApplicationControllerContext,
220            window: Option<&UIWindow>,
221            delegate: Option<&ProtocolObject<dyn TVApplicationControllerDelegate>>,
222        ) -> Retained<Self>;
223
224        #[deprecated = "Please use SwiftUI or UIKit"]
225        #[unsafe(method(init))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
228
229        #[cfg(feature = "objc2-ui-kit")]
230        #[deprecated = "Please use SwiftUI or UIKit"]
231        #[unsafe(method(window))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn window(&self, mtm: MainThreadMarker) -> Option<Retained<UIWindow>>;
234
235        #[deprecated = "Please use SwiftUI or UIKit"]
236        #[unsafe(method(context))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn context(&self) -> Retained<TVApplicationControllerContext>;
239
240        #[deprecated = "Please use SwiftUI or UIKit"]
241        #[unsafe(method(delegate))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn delegate(
244            &self,
245        ) -> Option<Retained<ProtocolObject<dyn TVApplicationControllerDelegate>>>;
246
247        #[cfg(feature = "objc2-ui-kit")]
248        /// Returns the navigation controller which is bridged from JavaScript. Native controllers can also be pushed onto this controller.
249        #[deprecated = "Please use SwiftUI or UIKit"]
250        #[unsafe(method(navigationController))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn navigationController(
253            &self,
254            mtm: MainThreadMarker,
255        ) -> Retained<UINavigationController>;
256
257        #[cfg(all(feature = "block2", feature = "objc2-javascript-core"))]
258        /// Adds the block to the JavaScript execution queue and invokes
259        /// completion block once the evaluation block has finished execution. JSContext is
260        /// valid within the scope of evaluation block and should not be referenced by the
261        /// application outside the block.
262        ///
263        /// Parameter `evaluation`: Block to evaluate in JavaScript execution queue.
264        ///
265        /// Parameter `completion`: Invoked after the evaluation block has been executed.
266        /// evaluated is YES if the block was evaluated; NO otherwise.
267        #[deprecated = "Please use SwiftUI or UIKit"]
268        #[unsafe(method(evaluateInJavaScriptContext:completion:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn evaluateInJavaScriptContext_completion(
271            &self,
272            evaluation: &block2::DynBlock<dyn Fn(NonNull<JSContext>)>,
273            completion: Option<&block2::DynBlock<dyn Fn(Bool)>>,
274        );
275
276        /// Stops the application lifecycle. appController:didStopWithOptions: is
277        /// called once the JSContext has finished execution and has released all
278        /// it's resources. The delegate must wait before releasing the controller.
279        /// The controller cannot be reused after calling stop.
280        #[deprecated = "Please use SwiftUI or UIKit"]
281        #[unsafe(method(stop))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn stop(&self);
284    );
285}
286
287/// Methods declared on superclass `NSObject`.
288impl TVApplicationController {
289    extern_methods!(
290        #[unsafe(method(new))]
291        #[unsafe(method_family = new)]
292        pub unsafe fn new() -> Retained<Self>;
293    );
294}