@onekeyfe/react-native-scroll-guard 0.1.1
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.
- package/ScrollGuard.podspec +29 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +124 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/scrollguard/ScrollGuard.kt +117 -0
- package/android/src/main/java/com/margelo/nitro/scrollguard/ScrollGuardPackage.kt +27 -0
- package/android/src/main/java/com/margelo/nitro/scrollguard/ScrollGuardViewGroupManager.kt +48 -0
- package/ios/ScrollGuard.swift +243 -0
- package/lib/module/ScrollGuard.nitro.js +9 -0
- package/lib/module/ScrollGuard.nitro.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/nitrogen/generated/android/c++/JHybridScrollGuardSpec.cpp +59 -0
- package/lib/nitrogen/generated/android/c++/JHybridScrollGuardSpec.hpp +66 -0
- package/lib/nitrogen/generated/android/c++/JScrollGuardDirection.hpp +62 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.cpp +56 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.hpp +49 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/HybridScrollGuardSpec.kt +59 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/ScrollGuardDirection.kt +22 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/scrollguardOnLoad.kt +35 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardManager.kt +50 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardStateUpdater.kt +23 -0
- package/lib/nitrogen/generated/android/scrollguard+autolinking.cmake +83 -0
- package/lib/nitrogen/generated/android/scrollguard+autolinking.gradle +27 -0
- package/lib/nitrogen/generated/android/scrollguardOnLoad.cpp +46 -0
- package/lib/nitrogen/generated/android/scrollguardOnLoad.hpp +25 -0
- package/lib/nitrogen/generated/ios/ScrollGuard+autolinking.rb +60 -0
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.cpp +33 -0
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.hpp +59 -0
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Umbrella.hpp +45 -0
- package/lib/nitrogen/generated/ios/ScrollGuardAutolinking.mm +33 -0
- package/lib/nitrogen/generated/ios/ScrollGuardAutolinking.swift +25 -0
- package/lib/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.hpp +77 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridScrollGuardComponent.mm +96 -0
- package/lib/nitrogen/generated/ios/swift/HybridScrollGuardSpec.swift +56 -0
- package/lib/nitrogen/generated/ios/swift/HybridScrollGuardSpec_cxx.swift +146 -0
- package/lib/nitrogen/generated/ios/swift/ScrollGuardDirection.swift +44 -0
- package/lib/nitrogen/generated/shared/c++/HybridScrollGuardSpec.cpp +22 -0
- package/lib/nitrogen/generated/shared/c++/HybridScrollGuardSpec.hpp +65 -0
- package/lib/nitrogen/generated/shared/c++/ScrollGuardDirection.hpp +80 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.cpp +87 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.hpp +108 -0
- package/lib/nitrogen/generated/shared/json/ScrollGuardConfig.json +10 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ScrollGuard.nitro.d.ts +19 -0
- package/lib/typescript/src/ScrollGuard.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JHybridScrollGuardSpec.cpp +59 -0
- package/nitrogen/generated/android/c++/JHybridScrollGuardSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JScrollGuardDirection.hpp +62 -0
- package/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.cpp +56 -0
- package/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/HybridScrollGuardSpec.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/ScrollGuardDirection.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/scrollguardOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardStateUpdater.kt +23 -0
- package/nitrogen/generated/android/scrollguard+autolinking.cmake +83 -0
- package/nitrogen/generated/android/scrollguard+autolinking.gradle +27 -0
- package/nitrogen/generated/android/scrollguardOnLoad.cpp +46 -0
- package/nitrogen/generated/android/scrollguardOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/ScrollGuard+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.hpp +59 -0
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/ScrollGuardAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ScrollGuardAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.hpp +77 -0
- package/nitrogen/generated/ios/c++/views/HybridScrollGuardComponent.mm +96 -0
- package/nitrogen/generated/ios/swift/HybridScrollGuardSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridScrollGuardSpec_cxx.swift +146 -0
- package/nitrogen/generated/ios/swift/ScrollGuardDirection.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridScrollGuardSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridScrollGuardSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/ScrollGuardDirection.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.cpp +87 -0
- package/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.hpp +108 -0
- package/nitrogen/generated/shared/json/ScrollGuardConfig.json +10 -0
- package/package.json +106 -0
- package/src/ScrollGuard.nitro.ts +25 -0
- package/src/index.tsx +11 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ScrollGuard+autolinking.rb
|
|
3
|
+
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
# https://github.com/mrousavy/nitro
|
|
5
|
+
# Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/ScrollGuard+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 ScrollGuard is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only C)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
})
|
|
60
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ScrollGuard-Swift-Cxx-Bridge.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "ScrollGuard-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridScrollGuardSpecSwift.hpp"
|
|
12
|
+
#include "ScrollGuard-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::scrollguard::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::shared_ptr<HybridScrollGuardSpec>
|
|
18
|
+
std::shared_ptr<HybridScrollGuardSpec> create_std__shared_ptr_HybridScrollGuardSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
19
|
+
ScrollGuard::HybridScrollGuardSpec_cxx swiftPart = ScrollGuard::HybridScrollGuardSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
20
|
+
return std::make_shared<margelo::nitro::scrollguard::HybridScrollGuardSpecSwift>(swiftPart);
|
|
21
|
+
}
|
|
22
|
+
void* NON_NULL get_std__shared_ptr_HybridScrollGuardSpec_(std__shared_ptr_HybridScrollGuardSpec_ cppType) {
|
|
23
|
+
std::shared_ptr<margelo::nitro::scrollguard::HybridScrollGuardSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::scrollguard::HybridScrollGuardSpecSwift>(cppType);
|
|
24
|
+
#ifdef NITRO_DEBUG
|
|
25
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("Class \"HybridScrollGuardSpec\" is not implemented in Swift!");
|
|
27
|
+
}
|
|
28
|
+
#endif
|
|
29
|
+
ScrollGuard::HybridScrollGuardSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
30
|
+
return swiftPart.toUnsafe();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} // namespace margelo::nitro::scrollguard::bridge::swift
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ScrollGuard-Swift-Cxx-Bridge.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridScrollGuardSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::scrollguard { class HybridScrollGuardSpec; }
|
|
13
|
+
// Forward declaration of `ScrollGuardDirection` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::scrollguard { enum class ScrollGuardDirection; }
|
|
15
|
+
|
|
16
|
+
// Forward declarations of Swift defined types
|
|
17
|
+
// Forward declaration of `HybridScrollGuardSpec_cxx` to properly resolve imports.
|
|
18
|
+
namespace ScrollGuard { class HybridScrollGuardSpec_cxx; }
|
|
19
|
+
|
|
20
|
+
// Include C++ defined types
|
|
21
|
+
#include "HybridScrollGuardSpec.hpp"
|
|
22
|
+
#include "ScrollGuardDirection.hpp"
|
|
23
|
+
#include <memory>
|
|
24
|
+
#include <optional>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
28
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
29
|
+
*/
|
|
30
|
+
namespace margelo::nitro::scrollguard::bridge::swift {
|
|
31
|
+
|
|
32
|
+
// pragma MARK: std::optional<ScrollGuardDirection>
|
|
33
|
+
/**
|
|
34
|
+
* Specialized version of `std::optional<ScrollGuardDirection>`.
|
|
35
|
+
*/
|
|
36
|
+
using std__optional_ScrollGuardDirection_ = std::optional<ScrollGuardDirection>;
|
|
37
|
+
inline std::optional<ScrollGuardDirection> create_std__optional_ScrollGuardDirection_(const ScrollGuardDirection& value) noexcept {
|
|
38
|
+
return std::optional<ScrollGuardDirection>(value);
|
|
39
|
+
}
|
|
40
|
+
inline bool has_value_std__optional_ScrollGuardDirection_(const std::optional<ScrollGuardDirection>& optional) noexcept {
|
|
41
|
+
return optional.has_value();
|
|
42
|
+
}
|
|
43
|
+
inline ScrollGuardDirection get_std__optional_ScrollGuardDirection_(const std::optional<ScrollGuardDirection>& optional) noexcept {
|
|
44
|
+
return *optional;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// pragma MARK: std::shared_ptr<HybridScrollGuardSpec>
|
|
48
|
+
/**
|
|
49
|
+
* Specialized version of `std::shared_ptr<HybridScrollGuardSpec>`.
|
|
50
|
+
*/
|
|
51
|
+
using std__shared_ptr_HybridScrollGuardSpec_ = std::shared_ptr<HybridScrollGuardSpec>;
|
|
52
|
+
std::shared_ptr<HybridScrollGuardSpec> create_std__shared_ptr_HybridScrollGuardSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
53
|
+
void* NON_NULL get_std__shared_ptr_HybridScrollGuardSpec_(std__shared_ptr_HybridScrollGuardSpec_ cppType);
|
|
54
|
+
|
|
55
|
+
// pragma MARK: std::weak_ptr<HybridScrollGuardSpec>
|
|
56
|
+
using std__weak_ptr_HybridScrollGuardSpec_ = std::weak_ptr<HybridScrollGuardSpec>;
|
|
57
|
+
inline std__weak_ptr_HybridScrollGuardSpec_ weakify_std__shared_ptr_HybridScrollGuardSpec_(const std::shared_ptr<HybridScrollGuardSpec>& strong) noexcept { return strong; }
|
|
58
|
+
|
|
59
|
+
} // namespace margelo::nitro::scrollguard::bridge::swift
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ScrollGuard-Swift-Cxx-Umbrella.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridScrollGuardSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::scrollguard { class HybridScrollGuardSpec; }
|
|
13
|
+
// Forward declaration of `ScrollGuardDirection` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::scrollguard { enum class ScrollGuardDirection; }
|
|
15
|
+
|
|
16
|
+
// Include C++ defined types
|
|
17
|
+
#include "HybridScrollGuardSpec.hpp"
|
|
18
|
+
#include "ScrollGuardDirection.hpp"
|
|
19
|
+
#include <memory>
|
|
20
|
+
#include <optional>
|
|
21
|
+
|
|
22
|
+
// C++ helpers for Swift
|
|
23
|
+
#include "ScrollGuard-Swift-Cxx-Bridge.hpp"
|
|
24
|
+
|
|
25
|
+
// Common C++ types used in Swift
|
|
26
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
27
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
28
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
29
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
30
|
+
|
|
31
|
+
// Forward declarations of Swift defined types
|
|
32
|
+
// Forward declaration of `HybridScrollGuardSpec_cxx` to properly resolve imports.
|
|
33
|
+
namespace ScrollGuard { class HybridScrollGuardSpec_cxx; }
|
|
34
|
+
|
|
35
|
+
// Include Swift defined types
|
|
36
|
+
#if __has_include("ScrollGuard-Swift.h")
|
|
37
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
38
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "ScrollGuard".
|
|
39
|
+
#include "ScrollGuard-Swift.h"
|
|
40
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
41
|
+
#elif __has_include(<ScrollGuard/ScrollGuard-Swift.h>)
|
|
42
|
+
#include <ScrollGuard/ScrollGuard-Swift.h>
|
|
43
|
+
#else
|
|
44
|
+
#error ScrollGuard's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "ScrollGuard", and try building the app first.
|
|
45
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ScrollGuardAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "ScrollGuard-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridScrollGuardSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface ScrollGuardAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation ScrollGuardAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::scrollguard;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"ScrollGuard",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridScrollGuardSpec> hybridObject = ScrollGuard::ScrollGuardAutolinking::createScrollGuard();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ScrollGuardAutolinking.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
public final class ScrollGuardAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.scrollguard.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridScrollGuardSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridScrollGuardSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridScrollGuard`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createScrollGuard() -> bridge.std__shared_ptr_HybridScrollGuardSpec_ {
|
|
19
|
+
let hybridObject = HybridScrollGuard()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridScrollGuardSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridScrollGuardSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridScrollGuardSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::scrollguard {
|
|
11
|
+
} // namespace margelo::nitro::scrollguard
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridScrollGuardSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridScrollGuardSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridScrollGuardSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace ScrollGuard { class HybridScrollGuardSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `ScrollGuardDirection` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::scrollguard { enum class ScrollGuardDirection; }
|
|
17
|
+
|
|
18
|
+
#include "ScrollGuardDirection.hpp"
|
|
19
|
+
#include <optional>
|
|
20
|
+
|
|
21
|
+
#include "ScrollGuard-Swift-Cxx-Umbrella.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::scrollguard {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The C++ part of HybridScrollGuardSpec_cxx.swift.
|
|
27
|
+
*
|
|
28
|
+
* HybridScrollGuardSpecSwift (C++) accesses HybridScrollGuardSpec_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, HybridScrollGuardSpec_cxx can directly inherit from the C++ class HybridScrollGuardSpec
|
|
33
|
+
* to simplify the whole structure and memory management.
|
|
34
|
+
*/
|
|
35
|
+
class HybridScrollGuardSpecSwift: public virtual HybridScrollGuardSpec {
|
|
36
|
+
public:
|
|
37
|
+
// Constructor from a Swift instance
|
|
38
|
+
explicit HybridScrollGuardSpecSwift(const ScrollGuard::HybridScrollGuardSpec_cxx& swiftPart):
|
|
39
|
+
HybridObject(HybridScrollGuardSpec::TAG),
|
|
40
|
+
_swiftPart(swiftPart) { }
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
// Get the Swift part
|
|
44
|
+
inline ScrollGuard::HybridScrollGuardSpec_cxx& getSwiftPart() noexcept {
|
|
45
|
+
return _swiftPart;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
50
|
+
return _swiftPart.getMemorySize();
|
|
51
|
+
}
|
|
52
|
+
void dispose() noexcept override {
|
|
53
|
+
_swiftPart.dispose();
|
|
54
|
+
}
|
|
55
|
+
std::string toString() override {
|
|
56
|
+
return _swiftPart.toString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
// Properties
|
|
61
|
+
inline std::optional<ScrollGuardDirection> getDirection() noexcept override {
|
|
62
|
+
auto __result = _swiftPart.getDirection();
|
|
63
|
+
return __result;
|
|
64
|
+
}
|
|
65
|
+
inline void setDirection(std::optional<ScrollGuardDirection> direction) noexcept override {
|
|
66
|
+
_swiftPart.setDirection(direction);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Methods
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
ScrollGuard::HybridScrollGuardSpec_cxx _swiftPart;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::scrollguard
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridScrollGuardComponent.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import "HybridScrollGuardComponent.hpp"
|
|
9
|
+
#import <memory>
|
|
10
|
+
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <React/RCTComponentViewFactory.h>
|
|
13
|
+
#import <React/UIView+ComponentViewProtocol.h>
|
|
14
|
+
#import <NitroModules/NitroDefines.hpp>
|
|
15
|
+
#import <UIKit/UIKit.h>
|
|
16
|
+
|
|
17
|
+
#import "HybridScrollGuardSpecSwift.hpp"
|
|
18
|
+
#import "ScrollGuard-Swift-Cxx-Umbrella.hpp"
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
using namespace margelo::nitro::scrollguard;
|
|
22
|
+
using namespace margelo::nitro::scrollguard::views;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the React Native View holder for the Nitro "ScrollGuard" HybridView.
|
|
26
|
+
*/
|
|
27
|
+
@interface HybridScrollGuardComponent: RCTViewComponentView
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation HybridScrollGuardComponent {
|
|
31
|
+
std::shared_ptr<HybridScrollGuardSpecSwift> _hybridView;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
+ (void) load {
|
|
35
|
+
[super load];
|
|
36
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridScrollGuardComponent class]];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
40
|
+
return react::concreteComponentDescriptorProvider<HybridScrollGuardComponentDescriptor>();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (instancetype) init {
|
|
44
|
+
if (self = [super init]) {
|
|
45
|
+
std::shared_ptr<HybridScrollGuardSpec> hybridView = ScrollGuard::ScrollGuardAutolinking::createScrollGuard();
|
|
46
|
+
_hybridView = std::dynamic_pointer_cast<HybridScrollGuardSpecSwift>(hybridView);
|
|
47
|
+
[self updateView];
|
|
48
|
+
}
|
|
49
|
+
return self;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (void) updateView {
|
|
53
|
+
// 1. Get Swift part
|
|
54
|
+
ScrollGuard::HybridScrollGuardSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
55
|
+
|
|
56
|
+
// 2. Get UIView*
|
|
57
|
+
void* viewUnsafe = swiftPart.getView();
|
|
58
|
+
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
59
|
+
|
|
60
|
+
// 3. Update RCTViewComponentView's [contentView]
|
|
61
|
+
[self setContentView:view];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
65
|
+
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
66
|
+
// 1. Downcast props
|
|
67
|
+
const auto& newViewPropsConst = *std::static_pointer_cast<HybridScrollGuardProps const>(props);
|
|
68
|
+
auto& newViewProps = const_cast<HybridScrollGuardProps&>(newViewPropsConst);
|
|
69
|
+
ScrollGuard::HybridScrollGuardSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
70
|
+
|
|
71
|
+
// 2. Update each prop individually
|
|
72
|
+
swiftPart.beforeUpdate();
|
|
73
|
+
|
|
74
|
+
// direction: optional
|
|
75
|
+
if (newViewProps.direction.isDirty) {
|
|
76
|
+
swiftPart.setDirection(newViewProps.direction.value);
|
|
77
|
+
newViewProps.direction.isDirty = false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
swiftPart.afterUpdate();
|
|
81
|
+
|
|
82
|
+
// 3. Update hybridRef if it changed
|
|
83
|
+
if (newViewProps.hybridRef.isDirty) {
|
|
84
|
+
// hybridRef changed - call it with new this
|
|
85
|
+
const auto& maybeFunc = newViewProps.hybridRef.value;
|
|
86
|
+
if (maybeFunc.has_value()) {
|
|
87
|
+
maybeFunc.value()(_hybridView);
|
|
88
|
+
}
|
|
89
|
+
newViewProps.hybridRef.isDirty = false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 4. Continue in base class
|
|
93
|
+
[super updateProps:props oldProps:oldProps];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridScrollGuardSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridScrollGuardSpec``
|
|
12
|
+
public protocol HybridScrollGuardSpec_protocol: HybridObject, HybridView {
|
|
13
|
+
// Properties
|
|
14
|
+
var direction: ScrollGuardDirection? { get set }
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridScrollGuardSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject ScrollGuard]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridScrollGuardSpec``
|
|
28
|
+
open class HybridScrollGuardSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridScrollGuardSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridScrollGuardSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is HybridScrollGuardSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridScrollGuardSpec`! Did you accidentally inherit from `HybridScrollGuardSpec_base` instead of `HybridScrollGuardSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridScrollGuardSpec_cxx(self as! HybridScrollGuardSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the ScrollGuard HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of ScrollGuard.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridScrollGuard : HybridScrollGuardSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridScrollGuardSpec = HybridScrollGuardSpec_protocol & HybridScrollGuardSpec_base
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridScrollGuardSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridScrollGuardSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridScrollGuardSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::scrollguard::bridge::swift`)
|
|
23
|
+
* from `ScrollGuard-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.scrollguard.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridScrollGuardSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridScrollGuardSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridScrollGuardSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridScrollGuardSpec_cxx` that wraps the given `HybridScrollGuardSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridScrollGuardSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridScrollGuardSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridScrollGuardSpec() -> any HybridScrollGuardSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridScrollGuardSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridScrollGuardSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridScrollGuardSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridScrollGuardSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridScrollGuardSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridScrollGuardSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridScrollGuardSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridScrollGuardSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
public final var direction: bridge.std__optional_ScrollGuardDirection_ {
|
|
118
|
+
@inline(__always)
|
|
119
|
+
get {
|
|
120
|
+
return { () -> bridge.std__optional_ScrollGuardDirection_ in
|
|
121
|
+
if let __unwrappedValue = self.__implementation.direction {
|
|
122
|
+
return bridge.create_std__optional_ScrollGuardDirection_(__unwrappedValue)
|
|
123
|
+
} else {
|
|
124
|
+
return .init()
|
|
125
|
+
}
|
|
126
|
+
}()
|
|
127
|
+
}
|
|
128
|
+
@inline(__always)
|
|
129
|
+
set {
|
|
130
|
+
self.__implementation.direction = newValue.value
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Methods
|
|
135
|
+
public final func getView() -> UnsafeMutableRawPointer {
|
|
136
|
+
return Unmanaged.passRetained(__implementation.view).toOpaque()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public final func beforeUpdate() {
|
|
140
|
+
__implementation.beforeUpdate()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public final func afterUpdate() {
|
|
144
|
+
__implementation.afterUpdate()
|
|
145
|
+
}
|
|
146
|
+
}
|