react-native-hls-cache 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/HlsCache.podspec +29 -0
  2. package/LICENSE +20 -0
  3. package/README.md +233 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +118 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/hlscache/HlsCache.kt +32 -0
  9. package/android/src/main/java/com/margelo/nitro/hlscache/HlsCachePackage.kt +22 -0
  10. package/ios/ClientConnectionHandler.swift +234 -0
  11. package/ios/DataSource.swift +394 -0
  12. package/ios/HlsCache.swift +121 -0
  13. package/ios/NetworkDownloader.swift +220 -0
  14. package/ios/PrefetchManager.swift +235 -0
  15. package/ios/VideoCacheStorage.swift +235 -0
  16. package/ios/VideoProxyServer.swift +185 -0
  17. package/lib/module/HlsCache.nitro.js +4 -0
  18. package/lib/module/HlsCache.nitro.js.map +1 -0
  19. package/lib/module/index.js +71 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/package.json +1 -0
  22. package/lib/typescript/package.json +1 -0
  23. package/lib/typescript/src/HlsCache.nitro.d.ts +13 -0
  24. package/lib/typescript/src/HlsCache.nitro.d.ts.map +1 -0
  25. package/lib/typescript/src/index.d.ts +36 -0
  26. package/lib/typescript/src/index.d.ts.map +1 -0
  27. package/nitro.json +23 -0
  28. package/nitrogen/generated/android/c++/JHybridHlsCacheSpec.cpp +89 -0
  29. package/nitrogen/generated/android/c++/JHybridHlsCacheSpec.hpp +68 -0
  30. package/nitrogen/generated/android/hlscache+autolinking.cmake +81 -0
  31. package/nitrogen/generated/android/hlscache+autolinking.gradle +27 -0
  32. package/nitrogen/generated/android/hlscacheOnLoad.cpp +54 -0
  33. package/nitrogen/generated/android/hlscacheOnLoad.hpp +34 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/hlscache/HybridHlsCacheSpec.kt +75 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/hlscache/hlscacheOnLoad.kt +35 -0
  36. package/nitrogen/generated/ios/HlsCache+autolinking.rb +60 -0
  37. package/nitrogen/generated/ios/HlsCache-Swift-Cxx-Bridge.cpp +49 -0
  38. package/nitrogen/generated/ios/HlsCache-Swift-Cxx-Bridge.hpp +160 -0
  39. package/nitrogen/generated/ios/HlsCache-Swift-Cxx-Umbrella.hpp +46 -0
  40. package/nitrogen/generated/ios/HlsCacheAutolinking.mm +33 -0
  41. package/nitrogen/generated/ios/HlsCacheAutolinking.swift +26 -0
  42. package/nitrogen/generated/ios/c++/HybridHlsCacheSpecSwift.cpp +11 -0
  43. package/nitrogen/generated/ios/c++/HybridHlsCacheSpecSwift.hpp +118 -0
  44. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  45. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  46. package/nitrogen/generated/ios/swift/HybridHlsCacheSpec.swift +60 -0
  47. package/nitrogen/generated/ios/swift/HybridHlsCacheSpec_cxx.swift +237 -0
  48. package/nitrogen/generated/shared/c++/HybridHlsCacheSpec.cpp +26 -0
  49. package/nitrogen/generated/shared/c++/HybridHlsCacheSpec.hpp +69 -0
  50. package/package.json +174 -0
  51. package/src/HlsCache.nitro.ts +15 -0
  52. package/src/index.tsx +75 -0
@@ -0,0 +1,160 @@
1
+ ///
2
+ /// HlsCache-Swift-Cxx-Bridge.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridHlsCacheSpec` to properly resolve imports.
12
+ namespace margelo::nitro::hlscache { class HybridHlsCacheSpec; }
13
+
14
+ // Forward declarations of Swift defined types
15
+ // Forward declaration of `HybridHlsCacheSpec_cxx` to properly resolve imports.
16
+ namespace HlsCache { class HybridHlsCacheSpec_cxx; }
17
+
18
+ // Include C++ defined types
19
+ #include "HybridHlsCacheSpec.hpp"
20
+ #include <NitroModules/Promise.hpp>
21
+ #include <NitroModules/PromiseHolder.hpp>
22
+ #include <NitroModules/Result.hpp>
23
+ #include <exception>
24
+ #include <functional>
25
+ #include <memory>
26
+ #include <optional>
27
+ #include <string>
28
+
29
+ /**
30
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
31
+ * as well as helper functions to interact with those C++ types from Swift.
32
+ */
33
+ namespace margelo::nitro::hlscache::bridge::swift {
34
+
35
+ // pragma MARK: std::optional<double>
36
+ /**
37
+ * Specialized version of `std::optional<double>`.
38
+ */
39
+ using std__optional_double_ = std::optional<double>;
40
+ inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
41
+ return std::optional<double>(value);
42
+ }
43
+ inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
44
+ return optional.has_value();
45
+ }
46
+ inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
47
+ return optional.value();
48
+ }
49
+
50
+ // pragma MARK: std::optional<bool>
51
+ /**
52
+ * Specialized version of `std::optional<bool>`.
53
+ */
54
+ using std__optional_bool_ = std::optional<bool>;
55
+ inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
56
+ return std::optional<bool>(value);
57
+ }
58
+ inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
59
+ return optional.has_value();
60
+ }
61
+ inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
62
+ return optional.value();
63
+ }
64
+
65
+ // pragma MARK: std::shared_ptr<Promise<void>>
66
+ /**
67
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
68
+ */
69
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
70
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
71
+ return Promise<void>::create();
72
+ }
73
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
74
+ return PromiseHolder<void>(std::move(promise));
75
+ }
76
+
77
+ // pragma MARK: std::function<void()>
78
+ /**
79
+ * Specialized version of `std::function<void()>`.
80
+ */
81
+ using Func_void = std::function<void()>;
82
+ /**
83
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
84
+ */
85
+ class Func_void_Wrapper final {
86
+ public:
87
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
88
+ inline void call() const noexcept {
89
+ _function->operator()();
90
+ }
91
+ private:
92
+ std::unique_ptr<std::function<void()>> _function;
93
+ } SWIFT_NONCOPYABLE;
94
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
95
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
96
+ return Func_void_Wrapper(std::move(value));
97
+ }
98
+
99
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
100
+ /**
101
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
102
+ */
103
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
104
+ /**
105
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
106
+ */
107
+ class Func_void_std__exception_ptr_Wrapper final {
108
+ public:
109
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
110
+ inline void call(std::exception_ptr error) const noexcept {
111
+ _function->operator()(error);
112
+ }
113
+ private:
114
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
115
+ } SWIFT_NONCOPYABLE;
116
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
117
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
118
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
119
+ }
120
+
121
+ // pragma MARK: std::shared_ptr<HybridHlsCacheSpec>
122
+ /**
123
+ * Specialized version of `std::shared_ptr<HybridHlsCacheSpec>`.
124
+ */
125
+ using std__shared_ptr_HybridHlsCacheSpec_ = std::shared_ptr<HybridHlsCacheSpec>;
126
+ std::shared_ptr<HybridHlsCacheSpec> create_std__shared_ptr_HybridHlsCacheSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
127
+ void* NON_NULL get_std__shared_ptr_HybridHlsCacheSpec_(std__shared_ptr_HybridHlsCacheSpec_ cppType);
128
+
129
+ // pragma MARK: std::weak_ptr<HybridHlsCacheSpec>
130
+ using std__weak_ptr_HybridHlsCacheSpec_ = std::weak_ptr<HybridHlsCacheSpec>;
131
+ inline std__weak_ptr_HybridHlsCacheSpec_ weakify_std__shared_ptr_HybridHlsCacheSpec_(const std::shared_ptr<HybridHlsCacheSpec>& strong) noexcept { return strong; }
132
+
133
+ // pragma MARK: Result<void>
134
+ using Result_void_ = Result<void>;
135
+ inline Result_void_ create_Result_void_() noexcept {
136
+ return Result<void>::withValue();
137
+ }
138
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
139
+ return Result<void>::withError(error);
140
+ }
141
+
142
+ // pragma MARK: Result<std::string>
143
+ using Result_std__string_ = Result<std::string>;
144
+ inline Result_std__string_ create_Result_std__string_(const std::string& value) noexcept {
145
+ return Result<std::string>::withValue(value);
146
+ }
147
+ inline Result_std__string_ create_Result_std__string_(const std::exception_ptr& error) noexcept {
148
+ return Result<std::string>::withError(error);
149
+ }
150
+
151
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
152
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
153
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
154
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
155
+ }
156
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
157
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
158
+ }
159
+
160
+ } // namespace margelo::nitro::hlscache::bridge::swift
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// HlsCache-Swift-Cxx-Umbrella.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridHlsCacheSpec` to properly resolve imports.
12
+ namespace margelo::nitro::hlscache { class HybridHlsCacheSpec; }
13
+
14
+ // Include C++ defined types
15
+ #include "HybridHlsCacheSpec.hpp"
16
+ #include <NitroModules/Promise.hpp>
17
+ #include <NitroModules/Result.hpp>
18
+ #include <exception>
19
+ #include <memory>
20
+ #include <optional>
21
+ #include <string>
22
+
23
+ // C++ helpers for Swift
24
+ #include "HlsCache-Swift-Cxx-Bridge.hpp"
25
+
26
+ // Common C++ types used in Swift
27
+ #include <NitroModules/ArrayBufferHolder.hpp>
28
+ #include <NitroModules/AnyMapUtils.hpp>
29
+ #include <NitroModules/RuntimeError.hpp>
30
+ #include <NitroModules/DateToChronoDate.hpp>
31
+
32
+ // Forward declarations of Swift defined types
33
+ // Forward declaration of `HybridHlsCacheSpec_cxx` to properly resolve imports.
34
+ namespace HlsCache { class HybridHlsCacheSpec_cxx; }
35
+
36
+ // Include Swift defined types
37
+ #if __has_include("HlsCache-Swift.h")
38
+ // This header is generated by Xcode/Swift on every app build.
39
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "HlsCache".
40
+ #include "HlsCache-Swift.h"
41
+ // Same as above, but used when building with frameworks (`use_frameworks`)
42
+ #elif __has_include(<HlsCache/HlsCache-Swift.h>)
43
+ #include <HlsCache/HlsCache-Swift.h>
44
+ #else
45
+ #error HlsCache's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "HlsCache", and try building the app first.
46
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// HlsCacheAutolinking.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "HlsCache-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridHlsCacheSpecSwift.hpp"
14
+
15
+ @interface HlsCacheAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation HlsCacheAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::hlscache;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "HlsCache",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridHlsCacheSpec> hybridObject = HlsCache::HlsCacheAutolinking::createHlsCache();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// HlsCacheAutolinking.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ // TODO: Use empty enums once Swift supports exporting them as namespaces
11
+ // See: https://github.com/swiftlang/swift/pull/83616
12
+ public final class HlsCacheAutolinking {
13
+ public typealias bridge = margelo.nitro.hlscache.bridge.swift
14
+
15
+ public static func createHlsCache() -> bridge.std__shared_ptr_HybridHlsCacheSpec_ {
16
+ let hybridObject = HybridHlsCache()
17
+ return { () -> bridge.std__shared_ptr_HybridHlsCacheSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isHlsCacheRecyclable() -> Bool {
24
+ return HybridHlsCache.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridHlsCacheSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridHlsCacheSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::hlscache {
11
+ } // namespace margelo::nitro::hlscache
@@ -0,0 +1,118 @@
1
+ ///
2
+ /// HybridHlsCacheSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridHlsCacheSpec.hpp"
11
+
12
+ // Forward declaration of `HybridHlsCacheSpec_cxx` to properly resolve imports.
13
+ namespace HlsCache { class HybridHlsCacheSpec_cxx; }
14
+
15
+
16
+
17
+ #include <optional>
18
+ #include <string>
19
+ #include <NitroModules/Promise.hpp>
20
+
21
+ #include "HlsCache-Swift-Cxx-Umbrella.hpp"
22
+
23
+ namespace margelo::nitro::hlscache {
24
+
25
+ /**
26
+ * The C++ part of HybridHlsCacheSpec_cxx.swift.
27
+ *
28
+ * HybridHlsCacheSpecSwift (C++) accesses HybridHlsCacheSpec_cxx (Swift), and might
29
+ * contain some additional bridging code for C++ <> Swift interop.
30
+ *
31
+ * Since this obviously introduces an overhead, I hope at some point in
32
+ * the future, HybridHlsCacheSpec_cxx can directly inherit from the C++ class HybridHlsCacheSpec
33
+ * to simplify the whole structure and memory management.
34
+ */
35
+ class HybridHlsCacheSpecSwift: public virtual HybridHlsCacheSpec {
36
+ public:
37
+ // Constructor from a Swift instance
38
+ explicit HybridHlsCacheSpecSwift(const HlsCache::HybridHlsCacheSpec_cxx& swiftPart):
39
+ HybridObject(HybridHlsCacheSpec::TAG),
40
+ _swiftPart(swiftPart) { }
41
+
42
+ public:
43
+ // Get the Swift part
44
+ inline HlsCache::HybridHlsCacheSpec_cxx& getSwiftPart() noexcept {
45
+ return _swiftPart;
46
+ }
47
+
48
+ public:
49
+ inline size_t getExternalMemorySize() noexcept override {
50
+ return _swiftPart.getMemorySize();
51
+ }
52
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
53
+ if (auto otherCast = std::dynamic_pointer_cast<HybridHlsCacheSpecSwift>(other)) {
54
+ return _swiftPart.equals(otherCast->_swiftPart);
55
+ }
56
+ return false;
57
+ }
58
+ void dispose() noexcept override {
59
+ _swiftPart.dispose();
60
+ }
61
+ std::string toString() override {
62
+ return _swiftPart.toString();
63
+ }
64
+
65
+ public:
66
+ // Properties
67
+
68
+
69
+ public:
70
+ // Methods
71
+ inline void startServer(std::optional<double> port, std::optional<double> maxCacheSize, std::optional<bool> headOnlyCache) override {
72
+ auto __result = _swiftPart.startServer(port, maxCacheSize, headOnlyCache);
73
+ if (__result.hasError()) [[unlikely]] {
74
+ std::rethrow_exception(__result.error());
75
+ }
76
+ }
77
+ inline std::string convertUrl(const std::string& url, std::optional<bool> isCacheable) override {
78
+ auto __result = _swiftPart.convertUrl(url, isCacheable);
79
+ if (__result.hasError()) [[unlikely]] {
80
+ std::rethrow_exception(__result.error());
81
+ }
82
+ auto __value = std::move(__result.value());
83
+ return __value;
84
+ }
85
+ inline std::shared_ptr<Promise<void>> clearCache() override {
86
+ auto __result = _swiftPart.clearCache();
87
+ if (__result.hasError()) [[unlikely]] {
88
+ std::rethrow_exception(__result.error());
89
+ }
90
+ auto __value = std::move(__result.value());
91
+ return __value;
92
+ }
93
+ inline std::string prefetch(const std::string& url, std::optional<double> segmentCount) override {
94
+ auto __result = _swiftPart.prefetch(url, segmentCount);
95
+ if (__result.hasError()) [[unlikely]] {
96
+ std::rethrow_exception(__result.error());
97
+ }
98
+ auto __value = std::move(__result.value());
99
+ return __value;
100
+ }
101
+ inline void cancelPrefetch(const std::string& taskId) override {
102
+ auto __result = _swiftPart.cancelPrefetch(taskId);
103
+ if (__result.hasError()) [[unlikely]] {
104
+ std::rethrow_exception(__result.error());
105
+ }
106
+ }
107
+ inline void cancelAllPrefetch() override {
108
+ auto __result = _swiftPart.cancelAllPrefetch();
109
+ if (__result.hasError()) [[unlikely]] {
110
+ std::rethrow_exception(__result.error());
111
+ }
112
+ }
113
+
114
+ private:
115
+ HlsCache::HybridHlsCacheSpec_cxx _swiftPart;
116
+ };
117
+
118
+ } // namespace margelo::nitro::hlscache
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `() -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void {
15
+ public typealias bridge = margelo.nitro.hlscache.bridge.swift
16
+
17
+ private let closure: () -> Void
18
+
19
+ public init(_ closure: @escaping () -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call() -> Void {
25
+ self.closure()
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
44
+ return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__exception_ptr {
15
+ public typealias bridge = margelo.nitro.hlscache.bridge.swift
16
+
17
+ private let closure: (_ error: Error) -> Void
18
+
19
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(error: std.exception_ptr) -> Void {
25
+ self.closure(RuntimeError.from(cppError: error))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
44
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,60 @@
1
+ ///
2
+ /// HybridHlsCacheSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /// See ``HybridHlsCacheSpec``
11
+ public protocol HybridHlsCacheSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func startServer(port: Double?, maxCacheSize: Double?, headOnlyCache: Bool?) throws -> Void
17
+ func convertUrl(url: String, isCacheable: Bool?) throws -> String
18
+ func clearCache() throws -> Promise<Void>
19
+ func prefetch(url: String, segmentCount: Double?) throws -> String
20
+ func cancelPrefetch(taskId: String) throws -> Void
21
+ func cancelAllPrefetch() throws -> Void
22
+ }
23
+
24
+ public extension HybridHlsCacheSpec_protocol {
25
+ /// Default implementation of ``HybridObject.toString``
26
+ func toString() -> String {
27
+ return "[HybridObject HlsCache]"
28
+ }
29
+ }
30
+
31
+ /// See ``HybridHlsCacheSpec``
32
+ open class HybridHlsCacheSpec_base {
33
+ private weak var cxxWrapper: HybridHlsCacheSpec_cxx? = nil
34
+ public init() { }
35
+ public func getCxxWrapper() -> HybridHlsCacheSpec_cxx {
36
+ #if DEBUG
37
+ guard self is any HybridHlsCacheSpec else {
38
+ fatalError("`self` is not a `HybridHlsCacheSpec`! Did you accidentally inherit from `HybridHlsCacheSpec_base` instead of `HybridHlsCacheSpec`?")
39
+ }
40
+ #endif
41
+ if let cxxWrapper = self.cxxWrapper {
42
+ return cxxWrapper
43
+ } else {
44
+ let cxxWrapper = HybridHlsCacheSpec_cxx(self as! any HybridHlsCacheSpec)
45
+ self.cxxWrapper = cxxWrapper
46
+ return cxxWrapper
47
+ }
48
+ }
49
+ }
50
+
51
+ /**
52
+ * A Swift base-protocol representing the HlsCache HybridObject.
53
+ * Implement this protocol to create Swift-based instances of HlsCache.
54
+ * ```swift
55
+ * class HybridHlsCache : HybridHlsCacheSpec {
56
+ * // ...
57
+ * }
58
+ * ```
59
+ */
60
+ public typealias HybridHlsCacheSpec = HybridHlsCacheSpec_protocol & HybridHlsCacheSpec_base