objc2-tv-ml-kit 0.3.2

Bindings to the TVMLKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-javascript-core")]
use objc2_javascript_core::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

extern_class!(
    /// This class is used to provide launch info to TVApplicationController.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvmlkit/tvapplicationcontrollercontext?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated = "Please use SwiftUI or UIKit"]
    pub struct TVApplicationControllerContext;
);

extern_conformance!(
    unsafe impl NSCopying for TVApplicationControllerContext {}
);

unsafe impl CopyingHelper for TVApplicationControllerContext {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for TVApplicationControllerContext {}
);

impl TVApplicationControllerContext {
    extern_methods!(
        /// URL to application JavaScript.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(javaScriptApplicationURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn javaScriptApplicationURL(&self) -> Retained<NSURL>;

        /// Setter for [`javaScriptApplicationURL`][Self::javaScriptApplicationURL].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(setJavaScriptApplicationURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setJavaScriptApplicationURL(&self, java_script_application_url: &NSURL);

        /// Optional identifier for local storage file name.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(storageIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn storageIdentifier(&self) -> Option<Retained<NSString>>;

        /// Setter for [`storageIdentifier`][Self::storageIdentifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(setStorageIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setStorageIdentifier(&self, storage_identifier: Option<&NSString>);

        /// Allows PiP to happen when playing back media
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(supportsPictureInPicturePlayback))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportsPictureInPicturePlayback(&self) -> bool;

        /// Setter for [`supportsPictureInPicturePlayback`][Self::supportsPictureInPicturePlayback].
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(setSupportsPictureInPicturePlayback:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSupportsPictureInPicturePlayback(
            &self,
            supports_picture_in_picture_playback: bool,
        );

        /// Data that gets passed to JavaScript onLaunch method. Values must be
        /// serializable. If app intends for JavaScript to handle openURL: then
        /// launchOptions should include UIApplicationLaunchOptionsURLKey and
        /// UIApplicationLaunchOptionsSourceApplicationKey to the launch options.
        /// TVApplicationController adds location (boot url) by default. If UIApplicationLaunchOptionsURLKey
        /// and UIApplicationLaunchOptionsSourceApplicationKey are provided then
        /// maps them to openURL and sourceAppIdentifier keys respectively.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(launchOptions))]
        #[unsafe(method_family = none)]
        pub unsafe fn launchOptions(&self) -> Retained<NSDictionary<NSString, AnyObject>>;

        /// Setter for [`launchOptions`][Self::launchOptions].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `launch_options` generic should be of the correct type.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(setLaunchOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLaunchOptions(&self, launch_options: &NSDictionary<NSString, AnyObject>);
    );
}

/// Methods declared on superclass `NSObject`.
impl TVApplicationControllerContext {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/tvmlkit/tvapplicationcontrollerdelegate?language=objc)
    #[deprecated = "Please use SwiftUI or UIKit"]
    pub unsafe trait TVApplicationControllerDelegate: NSObjectProtocol {
        #[cfg(feature = "objc2-javascript-core")]
        /// This method lets delegate to add JavaScript classes and objects.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[optional]
        #[unsafe(method(appController:evaluateAppJavaScriptInContext:))]
        #[unsafe(method_family = none)]
        unsafe fn appController_evaluateAppJavaScriptInContext(
            &self,
            app_controller: &TVApplicationController,
            js_context: &JSContext,
        );

        /// Tells the delegate that the application did finish launching.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[optional]
        #[unsafe(method(appController:didFinishLaunchingWithOptions:))]
        #[unsafe(method_family = none)]
        unsafe fn appController_didFinishLaunchingWithOptions(
            &self,
            app_controller: &TVApplicationController,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        );

        /// Tells the delegate that the application failed to load.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[optional]
        #[unsafe(method(appController:didFailWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn appController_didFailWithError(
            &self,
            app_controller: &TVApplicationController,
            error: &NSError,
        );

        /// Tells the delegate that the application did stop.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[optional]
        #[unsafe(method(appController:didStopWithOptions:))]
        #[unsafe(method_family = none)]
        unsafe fn appController_didStopWithOptions(
            &self,
            app_controller: &TVApplicationController,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        );

        #[cfg(feature = "TVPlayback")]
        /// Asks the delegate for a custom player object for a particular player bridge.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[optional]
        #[unsafe(method(playerForAppController:))]
        #[unsafe(method_family = none)]
        unsafe fn playerForAppController(
            &self,
            app_controller: &TVApplicationController,
        ) -> Option<Retained<TVPlayer>>;
    }
);

extern_class!(
    /// The TVApplicationController class establishes the JavaScript environment
    /// to provide a centralized point of control and co-ordination. The class
    /// bridges the UI, navigation stack, storage and event handling from JavaScript.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvmlkit/tvapplicationcontroller?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated = "Please use SwiftUI or UIKit"]
    pub struct TVApplicationController;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for TVApplicationController {}
);

impl TVApplicationController {
    extern_methods!(
        #[cfg(feature = "objc2-ui-kit")]
        /// Initializes and returns application controller given the launch context.
        /// Optionally window can be passed, and in that case TVApplicationController
        /// acts like an application delegate, and handles the JavaScript
        /// application lifecycle events e.g. onResume, onSuspend. If window
        /// is not provided, caller is responsible for hosting the navigationController.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(initWithContext:window:delegate:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithContext_window_delegate(
            this: Allocated<Self>,
            context: &TVApplicationControllerContext,
            window: Option<&UIWindow>,
            delegate: Option<&ProtocolObject<dyn TVApplicationControllerDelegate>>,
        ) -> Retained<Self>;

        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "objc2-ui-kit")]
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(window))]
        #[unsafe(method_family = none)]
        pub unsafe fn window(&self, mtm: MainThreadMarker) -> Option<Retained<UIWindow>>;

        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(context))]
        #[unsafe(method_family = none)]
        pub unsafe fn context(&self) -> Retained<TVApplicationControllerContext>;

        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn TVApplicationControllerDelegate>>>;

        #[cfg(feature = "objc2-ui-kit")]
        /// Returns the navigation controller which is bridged from JavaScript. Native controllers can also be pushed onto this controller.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(navigationController))]
        #[unsafe(method_family = none)]
        pub unsafe fn navigationController(
            &self,
            mtm: MainThreadMarker,
        ) -> Retained<UINavigationController>;

        #[cfg(all(feature = "block2", feature = "objc2-javascript-core"))]
        /// Adds the block to the JavaScript execution queue and invokes
        /// completion block once the evaluation block has finished execution. JSContext is
        /// valid within the scope of evaluation block and should not be referenced by the
        /// application outside the block.
        ///
        /// Parameter `evaluation`: Block to evaluate in JavaScript execution queue.
        ///
        /// Parameter `completion`: Invoked after the evaluation block has been executed.
        /// evaluated is YES if the block was evaluated; NO otherwise.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(evaluateInJavaScriptContext:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn evaluateInJavaScriptContext_completion(
            &self,
            evaluation: &block2::DynBlock<dyn Fn(NonNull<JSContext>)>,
            completion: Option<&block2::DynBlock<dyn Fn(Bool)>>,
        );

        /// Stops the application lifecycle. appController:didStopWithOptions: is
        /// called once the JSContext has finished execution and has released all
        /// it's resources. The delegate must wait before releasing the controller.
        /// The controller cannot be reused after calling stop.
        #[deprecated = "Please use SwiftUI or UIKit"]
        #[unsafe(method(stop))]
        #[unsafe(method_family = none)]
        pub unsafe fn stop(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl TVApplicationController {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}