@fressh/react-native-terminal 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.
- package/README.md +182 -0
- package/ReactNativeTerminal.podspec +82 -0
- package/android/CMakeLists.txt +76 -0
- package/android/build.gradle +121 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/src/main/assets/fonts/DejaVuSansMono.ttf +0 -0
- package/android/src/main/cpp/cpp-adapter.cpp +180 -0
- package/android/src/main/java/com/margelo/nitro/fressh/HybridTerminal.kt +146 -0
- package/android/src/main/java/com/margelo/nitro/fressh/ReactNativeTerminalModule.kt +43 -0
- package/android/src/main/java/com/margelo/nitro/fressh/ReactNativeTerminalPackage.kt +32 -0
- package/android/src/main/jniLibs/arm64-v8a/libshim_uniffi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libshim_uniffi.so +0 -0
- package/babel.config.js +12 -0
- package/cpp/README.md +14 -0
- package/cpp/generated/shim_uniffi.cpp +4246 -0
- package/cpp/generated/shim_uniffi.hpp +364 -0
- package/ios/FresshTerminalRenderABI.h +46 -0
- package/ios/HybridTerminal.swift +144 -0
- package/ios/ReactNativeTerminalUniffi.mm +77 -0
- package/ios/fetch-angle.sh +39 -0
- package/ios/fonts/DejaVuSansMono.ttf +0 -0
- package/libEGL.xcframework/Info.plist +44 -0
- package/libEGL.xcframework/ios-arm64/libEGL.framework/Info.plist +0 -0
- package/libEGL.xcframework/ios-arm64/libEGL.framework/libEGL +0 -0
- package/libEGL.xcframework/ios-arm64_x86_64-simulator/libEGL.framework/Info.plist +0 -0
- package/libEGL.xcframework/ios-arm64_x86_64-simulator/libEGL.framework/libEGL +0 -0
- package/libGLESv2.xcframework/Info.plist +44 -0
- package/libGLESv2.xcframework/ios-arm64/libGLESv2.framework/Info.plist +0 -0
- package/libGLESv2.xcframework/ios-arm64/libGLESv2.framework/libGLESv2 +0 -0
- package/libGLESv2.xcframework/ios-arm64_x86_64-simulator/libGLESv2.framework/Info.plist +0 -0
- package/libGLESv2.xcframework/ios-arm64_x86_64-simulator/libGLESv2.framework/libGLESv2 +0 -0
- package/nitro/Terminal.nitro.ts +40 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/ReactNativeTerminal+autolinking.cmake +83 -0
- package/nitrogen/generated/android/ReactNativeTerminal+autolinking.gradle +27 -0
- package/nitrogen/generated/android/ReactNativeTerminalOnLoad.cpp +56 -0
- package/nitrogen/generated/android/ReactNativeTerminalOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JHybridTerminalSpec.cpp +76 -0
- package/nitrogen/generated/android/c++/JHybridTerminalSpec.hpp +68 -0
- package/nitrogen/generated/android/c++/views/JHybridTerminalStateUpdater.cpp +64 -0
- package/nitrogen/generated/android/c++/views/JHybridTerminalStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/HybridTerminalSpec.kt +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/ReactNativeTerminalOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/views/HybridTerminalManager.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/views/HybridTerminalStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/ReactNativeTerminal+autolinking.rb +62 -0
- package/nitrogen/generated/ios/ReactNativeTerminal-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/ReactNativeTerminal-Swift-Cxx-Bridge.hpp +57 -0
- package/nitrogen/generated/ios/ReactNativeTerminal-Swift-Cxx-Umbrella.hpp +43 -0
- package/nitrogen/generated/ios/ReactNativeTerminalAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeTerminalAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridTerminalSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridTerminalSpecSwift.hpp +96 -0
- package/nitrogen/generated/ios/c++/views/HybridTerminalComponent.mm +132 -0
- package/nitrogen/generated/ios/swift/HybridTerminalSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridTerminalSpec_cxx.swift +204 -0
- package/nitrogen/generated/shared/c++/HybridTerminalSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridTerminalSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/views/HybridTerminalComponent.cpp +110 -0
- package/nitrogen/generated/shared/c++/views/HybridTerminalComponent.hpp +113 -0
- package/nitrogen/generated/shared/json/TerminalConfig.json +12 -0
- package/package.json +97 -0
- package/react-native.config.js +12 -0
- package/shim_uniffi.xcframework/Info.plist +44 -0
- package/shim_uniffi.xcframework/ios-arm64/libshim_uniffi.a +0 -0
- package/shim_uniffi.xcframework/ios-arm64_x86_64-simulator/libshim_uniffi.a +0 -0
- package/src/Terminal.tsx +135 -0
- package/src/generated/shim_uniffi-ffi.ts +320 -0
- package/src/generated/shim_uniffi.ts +2527 -0
- package/src/index.ts +52 -0
- package/src/ssh.ts +239 -0
- package/tsconfig.json +31 -0
- package/ubrn.config.yaml +24 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridTerminalComponent.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 "HybridTerminalComponent.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 "HybridTerminalSpecSwift.hpp"
|
|
18
|
+
#import "ReactNativeTerminal-Swift-Cxx-Umbrella.hpp"
|
|
19
|
+
|
|
20
|
+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
|
|
21
|
+
#include <cxxreact/ReactNativeVersion.h>
|
|
22
|
+
#if REACT_NATIVE_VERSION_MINOR >= 82
|
|
23
|
+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
24
|
+
#endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
using namespace margelo::nitro::fressh;
|
|
29
|
+
using namespace margelo::nitro::fressh::views;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Represents the React Native View holder for the Nitro "Terminal" HybridView.
|
|
33
|
+
*/
|
|
34
|
+
@interface HybridTerminalComponent: RCTViewComponentView
|
|
35
|
+
+ (BOOL)shouldBeRecycled;
|
|
36
|
+
@end
|
|
37
|
+
|
|
38
|
+
@implementation HybridTerminalComponent {
|
|
39
|
+
std::shared_ptr<HybridTerminalSpecSwift> _hybridView;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
+ (void) load {
|
|
43
|
+
[super load];
|
|
44
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridTerminalComponent class]];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
48
|
+
return react::concreteComponentDescriptorProvider<HybridTerminalComponentDescriptor>();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (instancetype) init {
|
|
52
|
+
if (self = [super init]) {
|
|
53
|
+
std::shared_ptr<HybridTerminalSpec> hybridView = ReactNativeTerminal::ReactNativeTerminalAutolinking::createTerminal();
|
|
54
|
+
_hybridView = std::dynamic_pointer_cast<HybridTerminalSpecSwift>(hybridView);
|
|
55
|
+
[self updateView];
|
|
56
|
+
}
|
|
57
|
+
return self;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void) updateView {
|
|
61
|
+
// 1. Get Swift part
|
|
62
|
+
ReactNativeTerminal::HybridTerminalSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
63
|
+
|
|
64
|
+
// 2. Get UIView*
|
|
65
|
+
void* viewUnsafe = swiftPart.getView();
|
|
66
|
+
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
67
|
+
|
|
68
|
+
// 3. Update RCTViewComponentView's [contentView]
|
|
69
|
+
[self setContentView:view];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
73
|
+
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
74
|
+
// 1. Downcast props
|
|
75
|
+
const auto& newViewPropsConst = *std::static_pointer_cast<HybridTerminalProps const>(props);
|
|
76
|
+
auto& newViewProps = const_cast<HybridTerminalProps&>(newViewPropsConst);
|
|
77
|
+
ReactNativeTerminal::HybridTerminalSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
78
|
+
|
|
79
|
+
// 2. Update each prop individually
|
|
80
|
+
swiftPart.beforeUpdate();
|
|
81
|
+
|
|
82
|
+
// fontPath: string
|
|
83
|
+
if (newViewProps.fontPath.isDirty) {
|
|
84
|
+
swiftPart.setFontPath(newViewProps.fontPath.value);
|
|
85
|
+
newViewProps.fontPath.isDirty = false;
|
|
86
|
+
}
|
|
87
|
+
// configJson: optional
|
|
88
|
+
if (newViewProps.configJson.isDirty) {
|
|
89
|
+
swiftPart.setConfigJson(newViewProps.configJson.value);
|
|
90
|
+
newViewProps.configJson.isDirty = false;
|
|
91
|
+
}
|
|
92
|
+
// shellId: optional
|
|
93
|
+
if (newViewProps.shellId.isDirty) {
|
|
94
|
+
swiftPart.setShellId(newViewProps.shellId.value);
|
|
95
|
+
newViewProps.shellId.isDirty = false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
swiftPart.afterUpdate();
|
|
99
|
+
|
|
100
|
+
// 3. Update hybridRef if it changed
|
|
101
|
+
if (newViewProps.hybridRef.isDirty) {
|
|
102
|
+
// hybridRef changed - call it with new this
|
|
103
|
+
const auto& maybeFunc = newViewProps.hybridRef.value;
|
|
104
|
+
if (maybeFunc.has_value()) {
|
|
105
|
+
maybeFunc.value()(_hybridView);
|
|
106
|
+
}
|
|
107
|
+
newViewProps.hybridRef.isDirty = false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 4. Continue in base class
|
|
111
|
+
[super updateProps:props oldProps:oldProps];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
+ (BOOL)shouldBeRecycled {
|
|
115
|
+
return ReactNativeTerminal::ReactNativeTerminalAutolinking::isTerminalRecyclable();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
- (void)prepareForRecycle {
|
|
119
|
+
[super prepareForRecycle];
|
|
120
|
+
ReactNativeTerminal::HybridTerminalSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
121
|
+
swiftPart.maybePrepareForRecycle();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
125
|
+
- (void)invalidate {
|
|
126
|
+
ReactNativeTerminal::HybridTerminalSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
127
|
+
swiftPart.onDropView();
|
|
128
|
+
[super invalidate];
|
|
129
|
+
}
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
@end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridTerminalSpec.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 ``HybridTerminalSpec``
|
|
11
|
+
public protocol HybridTerminalSpec_protocol: HybridObject, HybridView {
|
|
12
|
+
// Properties
|
|
13
|
+
var fontPath: String { get set }
|
|
14
|
+
var configJson: String? { get set }
|
|
15
|
+
var shellId: String? { get set }
|
|
16
|
+
|
|
17
|
+
// Methods
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public extension HybridTerminalSpec_protocol {
|
|
22
|
+
/// Default implementation of ``HybridObject.toString``
|
|
23
|
+
func toString() -> String {
|
|
24
|
+
return "[HybridObject Terminal]"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// See ``HybridTerminalSpec``
|
|
29
|
+
open class HybridTerminalSpec_base {
|
|
30
|
+
private weak var cxxWrapper: HybridTerminalSpec_cxx? = nil
|
|
31
|
+
public init() { }
|
|
32
|
+
public func getCxxWrapper() -> HybridTerminalSpec_cxx {
|
|
33
|
+
#if DEBUG
|
|
34
|
+
guard self is any HybridTerminalSpec else {
|
|
35
|
+
fatalError("`self` is not a `HybridTerminalSpec`! Did you accidentally inherit from `HybridTerminalSpec_base` instead of `HybridTerminalSpec`?")
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
39
|
+
return cxxWrapper
|
|
40
|
+
} else {
|
|
41
|
+
let cxxWrapper = HybridTerminalSpec_cxx(self as! any HybridTerminalSpec)
|
|
42
|
+
self.cxxWrapper = cxxWrapper
|
|
43
|
+
return cxxWrapper
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A Swift base-protocol representing the Terminal HybridObject.
|
|
50
|
+
* Implement this protocol to create Swift-based instances of Terminal.
|
|
51
|
+
* ```swift
|
|
52
|
+
* class HybridTerminal : HybridTerminalSpec {
|
|
53
|
+
* // ...
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
public typealias HybridTerminalSpec = HybridTerminalSpec_protocol & HybridTerminalSpec_base
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridTerminalSpec_cxx.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
|
+
* A class implementation that bridges HybridTerminalSpec over to C++.
|
|
12
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
+
*
|
|
14
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
+
*/
|
|
19
|
+
open class HybridTerminalSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::fressh::bridge::swift`)
|
|
22
|
+
* from `ReactNativeTerminal-Swift-Cxx-Bridge.hpp`.
|
|
23
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
+
*/
|
|
25
|
+
public typealias bridge = margelo.nitro.fressh.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridTerminalSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridTerminalSpec
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
+
*/
|
|
35
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridTerminalSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridTerminalSpec_cxx` that wraps the given `HybridTerminalSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridTerminalSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridTerminalSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridTerminalSpec() -> any HybridTerminalSpec {
|
|
52
|
+
return __implementation
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
+
* This acquires one additional strong reference on the object!
|
|
58
|
+
*/
|
|
59
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Casts an unsafe pointer to a `HybridTerminalSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridTerminalSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridTerminalSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridTerminalSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
+
* The C++ part is a `std::shared_ptr<HybridTerminalSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridTerminalSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridTerminalSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridTerminalSpec_(newCxxPart)
|
|
83
|
+
return newCxxPart
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
+
*/
|
|
93
|
+
@inline(__always)
|
|
94
|
+
public var memorySize: Int {
|
|
95
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridTerminalSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Call dispose() on the Swift class.
|
|
108
|
+
* This _may_ be called manually from JS.
|
|
109
|
+
*/
|
|
110
|
+
@inline(__always)
|
|
111
|
+
public func dispose() {
|
|
112
|
+
self.__implementation.dispose()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Call toString() on the Swift class.
|
|
117
|
+
*/
|
|
118
|
+
@inline(__always)
|
|
119
|
+
public func toString() -> String {
|
|
120
|
+
return self.__implementation.toString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Properties
|
|
124
|
+
public final var fontPath: std.string {
|
|
125
|
+
@inline(__always)
|
|
126
|
+
get {
|
|
127
|
+
return std.string(self.__implementation.fontPath)
|
|
128
|
+
}
|
|
129
|
+
@inline(__always)
|
|
130
|
+
set {
|
|
131
|
+
self.__implementation.fontPath = String(newValue)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public final var configJson: bridge.std__optional_std__string_ {
|
|
136
|
+
@inline(__always)
|
|
137
|
+
get {
|
|
138
|
+
return { () -> bridge.std__optional_std__string_ in
|
|
139
|
+
if let __unwrappedValue = self.__implementation.configJson {
|
|
140
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
141
|
+
} else {
|
|
142
|
+
return .init()
|
|
143
|
+
}
|
|
144
|
+
}()
|
|
145
|
+
}
|
|
146
|
+
@inline(__always)
|
|
147
|
+
set {
|
|
148
|
+
self.__implementation.configJson = { () -> String? in
|
|
149
|
+
if bridge.has_value_std__optional_std__string_(newValue) {
|
|
150
|
+
let __unwrapped = bridge.get_std__optional_std__string_(newValue)
|
|
151
|
+
return String(__unwrapped)
|
|
152
|
+
} else {
|
|
153
|
+
return nil
|
|
154
|
+
}
|
|
155
|
+
}()
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public final var shellId: bridge.std__optional_std__string_ {
|
|
160
|
+
@inline(__always)
|
|
161
|
+
get {
|
|
162
|
+
return { () -> bridge.std__optional_std__string_ in
|
|
163
|
+
if let __unwrappedValue = self.__implementation.shellId {
|
|
164
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
165
|
+
} else {
|
|
166
|
+
return .init()
|
|
167
|
+
}
|
|
168
|
+
}()
|
|
169
|
+
}
|
|
170
|
+
@inline(__always)
|
|
171
|
+
set {
|
|
172
|
+
self.__implementation.shellId = { () -> String? in
|
|
173
|
+
if bridge.has_value_std__optional_std__string_(newValue) {
|
|
174
|
+
let __unwrapped = bridge.get_std__optional_std__string_(newValue)
|
|
175
|
+
return String(__unwrapped)
|
|
176
|
+
} else {
|
|
177
|
+
return nil
|
|
178
|
+
}
|
|
179
|
+
}()
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Methods
|
|
184
|
+
public final func getView() -> UnsafeMutableRawPointer {
|
|
185
|
+
return Unmanaged.passRetained(__implementation.view).toOpaque()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public final func beforeUpdate() {
|
|
189
|
+
__implementation.beforeUpdate()
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
public final func afterUpdate() {
|
|
193
|
+
__implementation.afterUpdate()
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public final func maybePrepareForRecycle() {
|
|
197
|
+
guard let recyclable = __implementation as? any RecyclableView else { return }
|
|
198
|
+
recyclable.prepareForRecycle()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public final func onDropView() {
|
|
202
|
+
__implementation.onDropView()
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridTerminalSpec.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 "HybridTerminalSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::fressh {
|
|
11
|
+
|
|
12
|
+
void HybridTerminalSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("fontPath", &HybridTerminalSpec::getFontPath);
|
|
18
|
+
prototype.registerHybridSetter("fontPath", &HybridTerminalSpec::setFontPath);
|
|
19
|
+
prototype.registerHybridGetter("configJson", &HybridTerminalSpec::getConfigJson);
|
|
20
|
+
prototype.registerHybridSetter("configJson", &HybridTerminalSpec::setConfigJson);
|
|
21
|
+
prototype.registerHybridGetter("shellId", &HybridTerminalSpec::getShellId);
|
|
22
|
+
prototype.registerHybridSetter("shellId", &HybridTerminalSpec::setShellId);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
} // namespace margelo::nitro::fressh
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridTerminalSpec.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
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <optional>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::fressh {
|
|
22
|
+
|
|
23
|
+
using namespace margelo::nitro;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An abstract base class for `Terminal`
|
|
27
|
+
* Inherit this class to create instances of `HybridTerminalSpec` in C++.
|
|
28
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
29
|
+
* @example
|
|
30
|
+
* ```cpp
|
|
31
|
+
* class HybridTerminal: public HybridTerminalSpec {
|
|
32
|
+
* public:
|
|
33
|
+
* HybridTerminal(...): HybridObject(TAG) { ... }
|
|
34
|
+
* // ...
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class HybridTerminalSpec: public virtual HybridObject {
|
|
39
|
+
public:
|
|
40
|
+
// Constructor
|
|
41
|
+
explicit HybridTerminalSpec(): HybridObject(TAG) { }
|
|
42
|
+
|
|
43
|
+
// Destructor
|
|
44
|
+
~HybridTerminalSpec() override = default;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
// Properties
|
|
48
|
+
virtual std::string getFontPath() = 0;
|
|
49
|
+
virtual void setFontPath(const std::string& fontPath) = 0;
|
|
50
|
+
virtual std::optional<std::string> getConfigJson() = 0;
|
|
51
|
+
virtual void setConfigJson(const std::optional<std::string>& configJson) = 0;
|
|
52
|
+
virtual std::optional<std::string> getShellId() = 0;
|
|
53
|
+
virtual void setShellId(const std::optional<std::string>& shellId) = 0;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
protected:
|
|
60
|
+
// Hybrid Setup
|
|
61
|
+
void loadHybridMethods() override;
|
|
62
|
+
|
|
63
|
+
protected:
|
|
64
|
+
// Tag for logging
|
|
65
|
+
static constexpr auto TAG = "Terminal";
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro::fressh
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridTerminalComponent.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 "HybridTerminalComponent.hpp"
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <exception>
|
|
12
|
+
#include <utility>
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
16
|
+
#include <react/renderer/core/RawValue.h>
|
|
17
|
+
#include <react/renderer/core/ShadowNode.h>
|
|
18
|
+
#include <react/renderer/core/ComponentDescriptor.h>
|
|
19
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::fressh::views {
|
|
22
|
+
|
|
23
|
+
extern const char HybridTerminalComponentName[] = "Terminal";
|
|
24
|
+
|
|
25
|
+
HybridTerminalProps::HybridTerminalProps(const react::PropsParserContext& context,
|
|
26
|
+
const HybridTerminalProps& sourceProps,
|
|
27
|
+
const react::RawProps& rawProps):
|
|
28
|
+
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
29
|
+
fontPath([&]() -> CachedProp<std::string> {
|
|
30
|
+
try {
|
|
31
|
+
const react::RawValue* rawValue = rawProps.at("fontPath", nullptr, nullptr);
|
|
32
|
+
if (rawValue == nullptr) return sourceProps.fontPath;
|
|
33
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
34
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.fontPath);
|
|
35
|
+
} catch (const std::exception& exc) {
|
|
36
|
+
throw std::runtime_error(std::string("Terminal.fontPath: ") + exc.what());
|
|
37
|
+
}
|
|
38
|
+
}()),
|
|
39
|
+
configJson([&]() -> CachedProp<std::optional<std::string>> {
|
|
40
|
+
try {
|
|
41
|
+
const react::RawValue* rawValue = rawProps.at("configJson", nullptr, nullptr);
|
|
42
|
+
if (rawValue == nullptr) return sourceProps.configJson;
|
|
43
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
44
|
+
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.configJson);
|
|
45
|
+
} catch (const std::exception& exc) {
|
|
46
|
+
throw std::runtime_error(std::string("Terminal.configJson: ") + exc.what());
|
|
47
|
+
}
|
|
48
|
+
}()),
|
|
49
|
+
shellId([&]() -> CachedProp<std::optional<std::string>> {
|
|
50
|
+
try {
|
|
51
|
+
const react::RawValue* rawValue = rawProps.at("shellId", nullptr, nullptr);
|
|
52
|
+
if (rawValue == nullptr) return sourceProps.shellId;
|
|
53
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
54
|
+
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.shellId);
|
|
55
|
+
} catch (const std::exception& exc) {
|
|
56
|
+
throw std::runtime_error(std::string("Terminal.shellId: ") + exc.what());
|
|
57
|
+
}
|
|
58
|
+
}()),
|
|
59
|
+
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridTerminalSpec>& /* ref */)>>> {
|
|
60
|
+
try {
|
|
61
|
+
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
62
|
+
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
63
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
64
|
+
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridTerminalSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
|
|
65
|
+
} catch (const std::exception& exc) {
|
|
66
|
+
throw std::runtime_error(std::string("Terminal.hybridRef: ") + exc.what());
|
|
67
|
+
}
|
|
68
|
+
}()) { }
|
|
69
|
+
|
|
70
|
+
bool HybridTerminalProps::filterObjectKeys(const std::string& propName) {
|
|
71
|
+
switch (hashString(propName)) {
|
|
72
|
+
case hashString("fontPath"): return true;
|
|
73
|
+
case hashString("configJson"): return true;
|
|
74
|
+
case hashString("shellId"): return true;
|
|
75
|
+
case hashString("hybridRef"): return true;
|
|
76
|
+
default: return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
HybridTerminalComponentDescriptor::HybridTerminalComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
|
|
81
|
+
: ConcreteComponentDescriptor(parameters,
|
|
82
|
+
react::RawPropsParser()) {}
|
|
83
|
+
|
|
84
|
+
std::shared_ptr<const react::Props> HybridTerminalComponentDescriptor::cloneProps(const react::PropsParserContext& context,
|
|
85
|
+
const std::shared_ptr<const react::Props>& props,
|
|
86
|
+
react::RawProps rawProps) const {
|
|
87
|
+
// 1. Prepare raw props parser
|
|
88
|
+
rawProps.parse(rawPropsParser_);
|
|
89
|
+
// 2. Copy props with Nitro's cached copy constructor
|
|
90
|
+
return HybridTerminalShadowNode::Props(context, /* & */ rawProps, props);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#ifdef ANDROID
|
|
94
|
+
void HybridTerminalComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
95
|
+
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
96
|
+
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
97
|
+
auto& concreteShadowNode = static_cast<HybridTerminalShadowNode&>(shadowNode);
|
|
98
|
+
// NOTE: `getConcreteSharedProps()` returns a DANGLING reference to a temporary
|
|
99
|
+
// shared_ptr (RN `ConcreteShadowNode::getConcreteSharedProps` returns
|
|
100
|
+
// `std::static_pointer_cast<...>(props_)` bound to a `const&` return type).
|
|
101
|
+
// Reading it is UB and yields freed/garbage props in some memory layouts. Cast
|
|
102
|
+
// the stable `getProps()` member into a local shared_ptr instead.
|
|
103
|
+
auto props = std::const_pointer_cast<HybridTerminalProps>(
|
|
104
|
+
std::static_pointer_cast<const HybridTerminalProps>(shadowNode.getProps()));
|
|
105
|
+
HybridTerminalState state{props};
|
|
106
|
+
concreteShadowNode.setStateData(std::move(state));
|
|
107
|
+
}
|
|
108
|
+
#endif
|
|
109
|
+
|
|
110
|
+
} // namespace margelo::nitro::fressh::views
|