Skip to content

Commit 01be71e

Browse files
Remove New Arch interop checks - New Arch only (#456)
### What changes are you making? Following on from the introduction of turbo specs in #449 this PR removes the existing fabric conditionals leaving only the new architecture enabled going forwards --- ### PR Checklist > [!IMPORTANT] > > - [ ] I've added tests to support my implementation > - [ ] I have read and agree with the [Contribution Guidelines](https://github.com/shopify/checkout-sheet-kit-react-native/blob/main/.github/CONTRIBUTING.md). > - [ ] I have read and agree with the [Code of Conduct](https://github.com/shopify/checkout-sheet-kit-react-native/blob/main/.github/CODE_OF_CONDUCT.md). > - [ ] I've updated the [README](https://github.com/shopify/checkout-sheet-kit-react-native). > > _Releasing a new version of the kit?_ > > - [ ] I have bumped the version number in the [`package.json` file](https://github.com/Shopify/checkout-sheet-kit-react-native/blob/main/modules/%40shopify/checkout-sheet-kit/package.json#L4). --- > [!TIP] > See the [Contributing documentation](https://github.com/shopify/checkout-sheet-kit-react-native/blob/main/.github/CONTRIBUTING.md#releasing-a-new-version) for instructions on how to publish a new version of the library.
1 parent 790dcfc commit 01be71e

27 files changed

Lines changed: 366 additions & 408 deletions

__mocks__/react-native.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ const ShopifyCheckoutSheetKit = {
5454
present: jest.fn(),
5555
dismiss: jest.fn(),
5656
invalidateCache: jest.fn(),
57-
getConfig: jest.fn(async () => exampleConfig),
57+
getConfig: jest.fn(() => exampleConfig),
5858
setConfig: jest.fn(),
5959
addEventListener: jest.fn(),
6060
removeEventListeners: jest.fn(),
6161
initiateGeolocationRequest: jest.fn(),
62-
configureAcceleratedCheckouts: jest.fn(),
63-
isAcceleratedCheckoutAvailable: jest.fn(),
62+
configureAcceleratedCheckouts: jest.fn(() => true),
63+
isAcceleratedCheckoutAvailable: jest.fn(() => true),
64+
isApplePayAvailable: jest.fn(() => true),
6465
addListener: jest.fn(),
6566
removeListeners: jest.fn(),
6667
};

modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ require "json"
22

33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
44

5-
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6-
7-
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
8-
95
Pod::Spec.new do |s|
106
s.name = "RNShopifyCheckoutSheetKit"
117
s.version = package["version"]
@@ -19,29 +15,9 @@ Pod::Spec.new do |s|
1915

2016
s.source_files = "ios/*.{h,m,mm,swift}"
2117

22-
s.dependency "React-Core"
23-
s.dependency "ShopifyCheckoutSheetKit", "~> 3.8.0"
24-
s.dependency "ShopifyCheckoutSheetKit/AcceleratedCheckouts", "~> 3.8.0"
25-
26-
if fabric_enabled
27-
# Use React Native's helper if available, otherwise add dependencies directly
28-
if defined?(install_modules_dependencies)
29-
install_modules_dependencies(s)
30-
else
31-
# Fallback: manually specify dependencies for New Architecture
32-
s.dependency "React-Codegen"
33-
s.dependency "RCT-Folly", :modular_headers => true
34-
s.dependency "RCTRequired"
35-
s.dependency "RCTTypeSafety"
36-
s.dependency "ReactCommon/turbomodule/core"
37-
end
38-
39-
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
18+
s.dependency "React-Core"
19+
s.dependency "ShopifyCheckoutSheetKit", "~> 3.8.0"
20+
s.dependency "ShopifyCheckoutSheetKit/AcceleratedCheckouts", "~> 3.8.0"
4021

41-
s.pod_target_xcconfig = {
42-
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
43-
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
44-
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
45-
}
46-
end
22+
install_modules_dependencies(s)
4723
end

modules/@shopify/checkout-sheet-kit/android/build.gradle

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ buildscript {
99
}
1010
}
1111

12-
def isNewArchitectureEnabled() {
13-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
14-
}
15-
1612
apply plugin: "com.android.library"
17-
18-
if (isNewArchitectureEnabled()) {
19-
apply plugin: "com.facebook.react"
20-
}
13+
apply plugin: "com.facebook.react"
2114

2215
def getExtOrIntegerDefault(name) {
2316
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties[name]).toInteger()

modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ of this software and associated documentation files (the "Software"), to deal
2929
import androidx.annotation.NonNull;
3030
import com.facebook.react.bridge.Promise;
3131
import com.facebook.react.bridge.ReactApplicationContext;
32-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
3332
import com.facebook.react.bridge.ReactMethod;
3433
import com.facebook.react.bridge.Arguments;
34+
import com.facebook.react.bridge.ReadableArray;
3535
import com.facebook.react.bridge.ReadableMap;
3636
import com.facebook.react.bridge.WritableMap;
37+
import com.shopify.checkoutsheetkit.NativeShopifyCheckoutSheetKitSpec;
3738
import com.shopify.checkoutsheetkit.*;
3839

3940
import java.util.HashMap;
4041
import java.util.Map;
4142
import java.util.Objects;
4243

43-
public class ShopifyCheckoutSheetKitModule extends ReactContextBaseJavaModule {
44-
private static final String MODULE_NAME = "ShopifyCheckoutSheetKit";
44+
public class ShopifyCheckoutSheetKitModule extends NativeShopifyCheckoutSheetKitSpec {
4545

4646
public static Configuration checkoutConfig = new Configuration();
4747

@@ -62,14 +62,8 @@ public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) {
6262
});
6363
}
6464

65-
@NonNull
6665
@Override
67-
public String getName() {
68-
return MODULE_NAME;
69-
}
70-
71-
@Override
72-
public Map<String, Object> getConstants() {
66+
protected Map<String, Object> getTypedExportedConstants() {
7367
final Map<String, Object> constants = new HashMap<>();
7468
constants.put("version", ShopifyCheckoutSheetKit.version);
7569
return constants;
@@ -81,7 +75,7 @@ public void addListener(String eventName) {
8175
}
8276

8377
@ReactMethod
84-
public void removeListeners(Integer count) {
78+
public void removeListeners(double count) {
8579
// No-op but required for RN to register module
8680
}
8781

@@ -119,15 +113,15 @@ public void invalidateCache() {
119113
ShopifyCheckoutSheetKit.invalidate();
120114
}
121115

122-
@ReactMethod
123-
public void getConfig(Promise promise) {
116+
@ReactMethod(isBlockingSynchronousMethod = true)
117+
public WritableMap getConfig() {
124118
WritableMap resultConfig = Arguments.createMap();
125119

126120
resultConfig.putBoolean("preloading", checkoutConfig.getPreloading().getEnabled());
127121
resultConfig.putString("colorScheme", colorSchemeToString(checkoutConfig.getColorScheme()));
128122
resultConfig.putString("logLevel", logLevelToString(checkoutConfig.getLogLevel()));
129123

130-
promise.resolve(resultConfig);
124+
return resultConfig;
131125
}
132126

133127
@ReactMethod
@@ -171,8 +165,34 @@ public void setConfig(ReadableMap config) {
171165
});
172166
}
173167

168+
@ReactMethod(isBlockingSynchronousMethod = true)
169+
public boolean configureAcceleratedCheckouts(
170+
String storefrontDomain,
171+
String storefrontAccessToken,
172+
String customerEmail,
173+
String customerPhoneNumber,
174+
String customerAccessToken,
175+
String applePayMerchantIdentifier,
176+
ReadableArray applyPayContactFields,
177+
ReadableArray supportedShippingCountries) {
178+
// Accelerated checkouts not supported on Android
179+
return false;
180+
}
181+
182+
@ReactMethod(isBlockingSynchronousMethod = true)
183+
public boolean isAcceleratedCheckoutAvailable() {
184+
// Accelerated checkouts not supported on Android
185+
return false;
186+
}
187+
188+
@ReactMethod(isBlockingSynchronousMethod = true)
189+
public boolean isApplePayAvailable() {
190+
// Apple Pay not available on Android
191+
return false;
192+
}
193+
174194
@ReactMethod
175-
public void initiateGeolocationRequest(Boolean allow) {
195+
public void initiateGeolocationRequest(boolean allow) {
176196
if (checkoutEventProcessor != null) {
177197
checkoutEventProcessor.invokeGeolocationCallback(allow);
178198
}

modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitPackage.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,52 @@ of this software and associated documentation files (the "Software"), to deal
2424
package com.shopify.reactnative.checkoutsheetkit;
2525

2626
import androidx.annotation.NonNull;
27+
import androidx.annotation.Nullable;
2728

28-
import com.facebook.react.ReactPackage;
29+
import com.facebook.react.TurboReactPackage;
2930
import com.facebook.react.bridge.NativeModule;
3031
import com.facebook.react.bridge.ReactApplicationContext;
32+
import com.facebook.react.module.model.ReactModuleInfo;
33+
import com.facebook.react.module.model.ReactModuleInfoProvider;
3134
import com.facebook.react.uimanager.ViewManager;
3235

33-
import java.util.ArrayList;
3436
import java.util.Collections;
37+
import java.util.HashMap;
3538
import java.util.List;
39+
import java.util.Map;
3640

37-
public class ShopifyCheckoutSheetKitPackage implements ReactPackage {
41+
public class ShopifyCheckoutSheetKitPackage extends TurboReactPackage {
3842

3943
@NonNull
4044
@Override
4145
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
4246
return Collections.emptyList();
4347
}
4448

45-
@NonNull
49+
@Nullable
4650
@Override
47-
public List<NativeModule> createNativeModules(
48-
@NonNull ReactApplicationContext reactContext) {
49-
List<NativeModule> modules = new ArrayList<>();
50-
51-
modules.add(new ShopifyCheckoutSheetKitModule(reactContext));
52-
53-
return modules;
51+
public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
52+
if (name.equals(ShopifyCheckoutSheetKitModule.NAME)) {
53+
return new ShopifyCheckoutSheetKitModule(reactContext);
54+
}
55+
return null;
5456
}
5557

58+
@Override
59+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
60+
return () -> {
61+
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
62+
moduleInfos.put(
63+
ShopifyCheckoutSheetKitModule.NAME,
64+
new ReactModuleInfo(
65+
ShopifyCheckoutSheetKitModule.NAME,
66+
ShopifyCheckoutSheetKitModule.NAME,
67+
false, // canOverrideExistingModule
68+
false, // needsEagerInit
69+
false, // isCxxModule
70+
true // isTurboModule
71+
));
72+
return moduleInfos;
73+
};
74+
}
5675
}

modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,42 @@ of this software and associated documentation files (the "Software"), to deal
2424

2525
#import <React/RCTBridgeModule.h>
2626
#import <React/RCTViewManager.h>
27+
#import <RNShopifyCheckoutSheetKitSpec/RNShopifyCheckoutSheetKitSpec.h>
28+
29+
// Registers the Swift module class (ShopifyCheckoutSheetKit.swift) with the RN
30+
// runtime under the name 'RCTShopifyCheckoutSheetKit', extending the codegen
31+
// base class so TurboModule dispatch can find it.
32+
//
33+
// Method declarations (`RCT_EXTERN_METHOD`) are intentionally absent for most
34+
// methods: the codegen-generated `NativeShopifyCheckoutSheetKitSpecJSI` invokes
35+
// each method via its `@objc` selector directly (see ShopifyCheckoutSheetKit.swift).
36+
// `setConfig` is declared so ObjCTurboModule sees the Swift selector's
37+
// NSDictionary argument and does not apply codegen's C++ struct conversion before
38+
// invoking Swift.
39+
@interface RCT_EXTERN_MODULE (RCTShopifyCheckoutSheetKit, NativeShopifyCheckoutSheetKitSpecBase)
40+
41+
RCT_EXTERN_METHOD(setConfig:(NSDictionary *)configuration)
2742

28-
@interface RCT_EXTERN_MODULE (RCTShopifyCheckoutSheetKit, NSObject)
29-
30-
/**
31-
* Present checkout
32-
*/
33-
RCT_EXTERN_METHOD(present : (NSString*)checkoutURLString);
34-
35-
/**
36-
* Preload checkout
37-
*/
38-
RCT_EXTERN_METHOD(preload : (NSString*)checkoutURLString);
39-
40-
/**
41-
* Dismiss checkout
42-
*/
43-
RCT_EXTERN_METHOD(dismiss);
44-
45-
/**
46-
* Invalidate preload cache
47-
*/
48-
RCT_EXTERN_METHOD(invalidateCache);
49-
50-
/**
51-
* Set configuration for checkout
52-
*/
53-
RCT_EXTERN_METHOD(setConfig : (NSDictionary*)configuration);
54-
55-
/**
56-
* Return configuration for checkout
57-
*/
58-
RCT_EXTERN_METHOD(getConfig : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject)
59-
60-
/**
61-
* Configure AcceleratedCheckouts
62-
*/
63-
RCT_EXTERN_METHOD(configureAcceleratedCheckouts : (NSString*)storefrontDomain storefrontAccessToken : (
64-
NSString*)storefrontAccessToken customerEmail : (NSString*)customerEmail customerPhoneNumber : (NSString*)
65-
customerPhoneNumber customerAccessToken : (NSString*)customerAccessToken applePayMerchantIdentifier : (NSString*)
66-
applePayMerchantIdentifier applyPayContactFields : (NSArray*)applyPayContactFields supportedShippingCountries : (NSArray*)supportedShippingCountries resolve : (
67-
RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject);
68-
69-
/**
70-
* Check if accelerated checkout is available
71-
*/
72-
RCT_EXTERN_METHOD(
73-
isAcceleratedCheckoutAvailable : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject);
43+
@end
7444

75-
/**
76-
* Check if Apple Pay is available
77-
*/
78-
RCT_EXTERN_METHOD(isApplePayAvailable : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject);
45+
// TurboModule registration. `RCTModuleProviders` (generated by codegen from
46+
// `package.json → codegenConfig.ios.modulesProvider`) looks up classes that
47+
// `respondsToSelector:@selector(getTurboModule:)`. Without this category,
48+
// our Swift class would not appear in the providers map and JS calls would
49+
// fall back to the legacy bridge — which has no methods declared here and
50+
// no sync support.
51+
@interface RCTShopifyCheckoutSheetKit (TurboModule) <RCTTurboModule>
52+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
53+
(const facebook::react::ObjCTurboModule::InitParams &)params;
54+
@end
7955

56+
@implementation RCTShopifyCheckoutSheetKit (TurboModule)
57+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
58+
(const facebook::react::ObjCTurboModule::InitParams &)params
59+
{
60+
return std::make_shared<facebook::react::NativeShopifyCheckoutSheetKitSpecJSI>(
61+
params);
62+
}
8063
@end
8164

8265
/**

0 commit comments

Comments
 (0)