@onramper/onramper-react-native 1.2.1 → 1.2.2-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/CHANGELOG.md +33 -0
- package/README.md +1 -1
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/Info.plist +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/OnramperSDK_OnramperSDK.bundle/Info.plist +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/DWARF/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/OnramperSDK.yml +1268 -1268
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Info.plist +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/OnramperSDK_OnramperSDK.bundle/Info.plist +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/DWARF/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/OnramperSDK.yml +1268 -1268
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/OnramperSDK.yml +1261 -1261
- package/ios/HybridOnramperCheckoutButton.swift +77 -3
- package/lib/commonjs/CheckoutButton.js +34 -0
- package/lib/commonjs/CheckoutButton.js.map +1 -0
- package/lib/commonjs/OnramperClient.js +3 -7
- package/lib/commonjs/OnramperClient.js.map +1 -1
- package/lib/commonjs/generated/OnramperCheckoutButtonConfig.json +1 -0
- package/lib/module/CheckoutButton.js +30 -0
- package/lib/module/CheckoutButton.js.map +1 -0
- package/lib/module/OnramperClient.js +3 -7
- package/lib/module/OnramperClient.js.map +1 -1
- package/lib/module/generated/OnramperCheckoutButtonConfig.json +1 -0
- package/lib/typescript/commonjs/src/CheckoutButton.d.ts +20 -0
- package/lib/typescript/commonjs/src/CheckoutButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/OnramperCheckoutButton.nitro.d.ts +6 -0
- package/lib/typescript/commonjs/src/specs/OnramperCheckoutButton.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/CheckoutButton.d.ts +20 -0
- package/lib/typescript/module/src/CheckoutButton.d.ts.map +1 -0
- package/lib/typescript/module/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/OnramperCheckoutButton.nitro.d.ts +6 -0
- package/lib/typescript/module/src/specs/OnramperCheckoutButton.nitro.d.ts.map +1 -1
- package/nitrogen/generated/ios/OnramperReactNative-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/OnramperReactNative-Swift-Cxx-Bridge.hpp +37 -0
- package/nitrogen/generated/ios/c++/HybridOnramperCheckoutButtonSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/c++/views/HybridOnramperCheckoutButtonComponent.mm +5 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridOnramperCheckoutButtonSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridOnramperCheckoutButtonSpec_cxx.swift +32 -0
- package/nitrogen/generated/shared/c++/HybridOnramperCheckoutButtonSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridOnramperCheckoutButtonSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridOnramperCheckoutButtonComponent.cpp +11 -0
- package/nitrogen/generated/shared/c++/views/HybridOnramperCheckoutButtonComponent.hpp +3 -2
- package/nitrogen/generated/shared/json/OnramperCheckoutButtonConfig.json +1 -0
- package/package.json +4 -2
- package/src/CheckoutButton.ts +28 -0
- package/src/OnramperClient.ts +2 -5
- package/src/generated/OnramperCheckoutButtonConfig.json +1 -0
- package/src/specs/OnramperCheckoutButton.nitro.ts +6 -0
|
@@ -131,6 +131,38 @@ open class HybridOnramperCheckoutButtonSpec_cxx {
|
|
|
131
131
|
self.__implementation.intentHandle = String(newValue)
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
|
|
135
|
+
public final var onContentHeightChange: bridge.std__optional_std__function_void_double____height______ {
|
|
136
|
+
@inline(__always)
|
|
137
|
+
get {
|
|
138
|
+
return { () -> bridge.std__optional_std__function_void_double____height______ in
|
|
139
|
+
if let __unwrappedValue = self.__implementation.onContentHeightChange {
|
|
140
|
+
return bridge.create_std__optional_std__function_void_double____height______({ () -> bridge.Func_void_double in
|
|
141
|
+
let __closureWrapper = Func_void_double(__unwrappedValue)
|
|
142
|
+
return bridge.create_Func_void_double(__closureWrapper.toUnsafe())
|
|
143
|
+
}())
|
|
144
|
+
} else {
|
|
145
|
+
return .init()
|
|
146
|
+
}
|
|
147
|
+
}()
|
|
148
|
+
}
|
|
149
|
+
@inline(__always)
|
|
150
|
+
set {
|
|
151
|
+
self.__implementation.onContentHeightChange = { () -> ((_ height: Double) -> Void)? in
|
|
152
|
+
if bridge.has_value_std__optional_std__function_void_double____height______(newValue) {
|
|
153
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_double____height______(newValue)
|
|
154
|
+
return { () -> (Double) -> Void in
|
|
155
|
+
let __wrappedFunction = bridge.wrap_Func_void_double(__unwrapped)
|
|
156
|
+
return { (__height: Double) -> Void in
|
|
157
|
+
__wrappedFunction.call(__height)
|
|
158
|
+
}
|
|
159
|
+
}()
|
|
160
|
+
} else {
|
|
161
|
+
return nil
|
|
162
|
+
}
|
|
163
|
+
}()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
134
166
|
|
|
135
167
|
// Methods
|
|
136
168
|
public final func getView() -> UnsafeMutableRawPointer {
|
|
@@ -16,6 +16,8 @@ namespace margelo::nitro::onramper {
|
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
17
|
prototype.registerHybridGetter("intentHandle", &HybridOnramperCheckoutButtonSpec::getIntentHandle);
|
|
18
18
|
prototype.registerHybridSetter("intentHandle", &HybridOnramperCheckoutButtonSpec::setIntentHandle);
|
|
19
|
+
prototype.registerHybridGetter("onContentHeightChange", &HybridOnramperCheckoutButtonSpec::getOnContentHeightChange);
|
|
20
|
+
prototype.registerHybridSetter("onContentHeightChange", &HybridOnramperCheckoutButtonSpec::setOnContentHeightChange);
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
#include <string>
|
|
19
|
+
#include <functional>
|
|
20
|
+
#include <optional>
|
|
19
21
|
|
|
20
22
|
namespace margelo::nitro::onramper {
|
|
21
23
|
|
|
@@ -46,6 +48,8 @@ namespace margelo::nitro::onramper {
|
|
|
46
48
|
// Properties
|
|
47
49
|
virtual std::string getIntentHandle() = 0;
|
|
48
50
|
virtual void setIntentHandle(const std::string& intentHandle) = 0;
|
|
51
|
+
virtual std::optional<std::function<void(double /* height */)>> getOnContentHeightChange() = 0;
|
|
52
|
+
virtual void setOnContentHeightChange(const std::optional<std::function<void(double /* height */)>>& onContentHeightChange) = 0;
|
|
49
53
|
|
|
50
54
|
public:
|
|
51
55
|
// Methods
|
|
@@ -36,6 +36,16 @@ namespace margelo::nitro::onramper::views {
|
|
|
36
36
|
throw std::runtime_error(std::string("OnramperCheckoutButton.intentHandle: ") + exc.what());
|
|
37
37
|
}
|
|
38
38
|
}()),
|
|
39
|
+
onContentHeightChange([&]() -> CachedProp<std::optional<std::function<void(double /* height */)>>> {
|
|
40
|
+
try {
|
|
41
|
+
const react::RawValue* rawValue = rawProps.at("onContentHeightChange", nullptr, nullptr);
|
|
42
|
+
if (rawValue == nullptr) return sourceProps.onContentHeightChange;
|
|
43
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
44
|
+
return CachedProp<std::optional<std::function<void(double /* height */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onContentHeightChange);
|
|
45
|
+
} catch (const std::exception& exc) {
|
|
46
|
+
throw std::runtime_error(std::string("OnramperCheckoutButton.onContentHeightChange: ") + exc.what());
|
|
47
|
+
}
|
|
48
|
+
}()),
|
|
39
49
|
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOnramperCheckoutButtonSpec>& /* ref */)>>> {
|
|
40
50
|
try {
|
|
41
51
|
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
@@ -50,6 +60,7 @@ namespace margelo::nitro::onramper::views {
|
|
|
50
60
|
bool HybridOnramperCheckoutButtonProps::filterObjectKeys(const std::string& propName) {
|
|
51
61
|
switch (hashString(propName)) {
|
|
52
62
|
case hashString("intentHandle"): return true;
|
|
63
|
+
case hashString("onContentHeightChange"): return true;
|
|
53
64
|
case hashString("hybridRef"): return true;
|
|
54
65
|
default: return false;
|
|
55
66
|
}
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
#include <react/renderer/components/view/ViewProps.h>
|
|
18
18
|
|
|
19
19
|
#include <string>
|
|
20
|
-
#include <memory>
|
|
21
|
-
#include "HybridOnramperCheckoutButtonSpec.hpp"
|
|
22
20
|
#include <functional>
|
|
23
21
|
#include <optional>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include "HybridOnramperCheckoutButtonSpec.hpp"
|
|
24
24
|
|
|
25
25
|
namespace margelo::nitro::onramper::views {
|
|
26
26
|
|
|
@@ -43,6 +43,7 @@ namespace margelo::nitro::onramper::views {
|
|
|
43
43
|
|
|
44
44
|
public:
|
|
45
45
|
CachedProp<std::string> intentHandle;
|
|
46
|
+
CachedProp<std::optional<std::function<void(double /* height */)>>> onContentHeightChange;
|
|
46
47
|
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOnramperCheckoutButtonSpec>& /* ref */)>>> hybridRef;
|
|
47
48
|
|
|
48
49
|
private:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onramper/onramper-react-native",
|
|
3
|
-
"version": "1.2.1",
|
|
3
|
+
"version": "1.2.2-1",
|
|
4
4
|
"description": "React Native wrapper for the Onramper iOS SDK",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"license": "Apache-2.0",
|
|
65
65
|
"homepage": "https://github.com/onramper/onramper-react-native#readme",
|
|
66
66
|
"onramperSDK": {
|
|
67
|
-
"checksum": "
|
|
67
|
+
"checksum": "754184c10a736e1db3292b592ca634ddbaa61dd01540b60610df4aa73a61de9a"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"react": ">=19.0.0",
|
|
@@ -76,12 +76,14 @@
|
|
|
76
76
|
"@expo/config-plugins": "^10.0.0",
|
|
77
77
|
"@types/jest": "^29.5.14",
|
|
78
78
|
"@types/react": "~19.2.0",
|
|
79
|
+
"@types/react-test-renderer": "^19.3.0",
|
|
79
80
|
"jest": "^29.7.0",
|
|
80
81
|
"nitrogen": "^0.35.9",
|
|
81
82
|
"react": "19.2.3",
|
|
82
83
|
"react-native": "0.85.3",
|
|
83
84
|
"react-native-builder-bob": "^0.43.0",
|
|
84
85
|
"react-native-nitro-modules": "^0.35.9",
|
|
86
|
+
"react-test-renderer": "^19.2.3",
|
|
85
87
|
"ts-jest": "^29.4.10",
|
|
86
88
|
"typescript": "~5.8.3"
|
|
87
89
|
},
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createElement, useMemo, useState } from 'react';
|
|
2
|
+
import { callback } from 'react-native-nitro-modules';
|
|
3
|
+
|
|
4
|
+
import { OnramperCheckoutButtonView } from './OnramperCheckoutButtonView';
|
|
5
|
+
|
|
6
|
+
// Height of the bare Buy button. Used until native reports the measured content
|
|
7
|
+
// height so the first frame isn't collapsed.
|
|
8
|
+
export const CHECKOUT_BUTTON_FALLBACK_HEIGHT = 56;
|
|
9
|
+
|
|
10
|
+
export interface CheckoutButtonProps {
|
|
11
|
+
intentHandle: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sizes the native checkout button to its SwiftUI content. The content grows when
|
|
16
|
+
* the SDK shows ToS text under the Buy button (which can change after mount), and
|
|
17
|
+
* Yoga can't measure a SwiftUI view — so native reports the height and it is
|
|
18
|
+
* applied here as an explicit `height`.
|
|
19
|
+
*/
|
|
20
|
+
export function CheckoutButton({ intentHandle }: CheckoutButtonProps) {
|
|
21
|
+
const [height, setHeight] = useState<number | null>(null);
|
|
22
|
+
const onContentHeightChange = useMemo(() => callback((h: number) => setHeight(Math.ceil(h))), []);
|
|
23
|
+
return createElement(OnramperCheckoutButtonView, {
|
|
24
|
+
intentHandle,
|
|
25
|
+
onContentHeightChange,
|
|
26
|
+
style: { width: '100%', height: height ?? CHECKOUT_BUTTON_FALLBACK_HEIGHT },
|
|
27
|
+
});
|
|
28
|
+
}
|
package/src/OnramperClient.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactElement, createElement } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { CheckoutButton } from './CheckoutButton';
|
|
4
4
|
import { createOnramperNative } from './OnramperNative';
|
|
5
5
|
import { OnramperError } from './errors';
|
|
6
6
|
import type { CheckoutEvent, EventName, EventPayload } from './events';
|
|
@@ -171,10 +171,7 @@ export class OnramperClient {
|
|
|
171
171
|
JSON.stringify(buttonStyle),
|
|
172
172
|
);
|
|
173
173
|
const quote = JSON.parse(result.quoteJson) as QuoteResponse;
|
|
174
|
-
const button = createElement(
|
|
175
|
-
intentHandle: result.intentHandle,
|
|
176
|
-
style: { width: '100%', minHeight: 56 },
|
|
177
|
-
});
|
|
174
|
+
const button = createElement(CheckoutButton, { intentHandle: result.intentHandle });
|
|
178
175
|
return { button, quote };
|
|
179
176
|
} catch (e: unknown) {
|
|
180
177
|
throw OnramperError.from(e);
|
|
@@ -5,6 +5,12 @@ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-nativ
|
|
|
5
5
|
// UIHostingController. iOS-only (Android is a platformUnsupported stub).
|
|
6
6
|
export interface OnramperCheckoutButtonProps extends HybridViewProps {
|
|
7
7
|
intentHandle: string;
|
|
8
|
+
/**
|
|
9
|
+
* Called with the hosted SwiftUI content's height (points) whenever it changes —
|
|
10
|
+
* e.g. when ToS text appears under the Buy button. React Native can't measure
|
|
11
|
+
* the SwiftUI content itself, so the JS wrapper applies this as `height`.
|
|
12
|
+
*/
|
|
13
|
+
onContentHeightChange?: (height: number) => void;
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
export interface OnramperCheckoutButtonMethods extends HybridViewMethods {}
|