diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aaac3f..8c897e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## 3.1.0 - October 25, 2024 + +Upgrades Swift dependency to +[3.1.1](https://github.com/Shopify/checkout-sheet-kit-swift/releases/tag/3.1.1) +and Android to +[3.2.0](https://github.com/Shopify/checkout-sheet-kit-android/releases/tag/3.2.0). + +### Updates + +#### Both platforms + +- New `invalidate()` function to manually clear the preload cache +- Prevent recovery flow for multipass URLs containing one-time tokens +- Open deep links externally + +#### iOS + +- Ignore cancelled redirects, add OS debug logging + +### Android + +- Implement `onShowFileChooser`, calling delegate +- Ensure no existing parent is present before adding to container + ## 3.0.4 - October 14, 2024 - Fixes type imports/exports when `verbatimModuleSyntax` TS rule is enabled diff --git a/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec b/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec index 3180a86..63b407d 100644 --- a/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec +++ b/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.source_files = "ios/*.{h,m,mm,swift}" s.dependency "React-Core" - s.dependency "ShopifyCheckoutSheetKit", "~> 3.0.4" + s.dependency "ShopifyCheckoutSheetKit", "~> 3.1.1" if fabric_enabled install_modules_dependencies(s) diff --git a/modules/@shopify/checkout-sheet-kit/android/gradle.properties b/modules/@shopify/checkout-sheet-kit/android/gradle.properties index c4f65c7..9191da2 100644 --- a/modules/@shopify/checkout-sheet-kit/android/gradle.properties +++ b/modules/@shopify/checkout-sheet-kit/android/gradle.properties @@ -5,4 +5,4 @@ ndkVersion=23.1.7779620 buildToolsVersion = "33.0.0" # Version of Shopify Checkout SDK to use with React Native -SHOPIFY_CHECKOUT_SDK_VERSION=3.0.4 +SHOPIFY_CHECKOUT_SDK_VERSION=3.2.0 diff --git a/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java b/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java index 1304492..ef594da 100644 --- a/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java +++ b/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java @@ -112,6 +112,11 @@ public void preload(String checkoutURL) { } } + @ReactMethod + public void invalidateCache() { + ShopifyCheckoutSheetKit.invalidate(); + } + private ColorScheme getColorScheme(String colorScheme) { switch (colorScheme) { case "web_default": diff --git a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm index c225ecd..ab37bb6 100644 --- a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm +++ b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm @@ -34,6 +34,9 @@ @interface RCT_EXTERN_MODULE(RCTShopifyCheckoutSheetKit, NSObject) /// Dismiss checkout RCT_EXTERN_METHOD(dismiss); +/// Invalidate preload cache +RCT_EXTERN_METHOD(invalidateCache); + /// Set configuration for checkout RCT_EXTERN_METHOD(setConfig:(NSDictionary *)configuration); diff --git a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift index 1f6d57d..340f313 100644 --- a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift +++ b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift @@ -182,6 +182,10 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate { } } + @objc func invalidateCache() { + ShopifyCheckoutSheetKit.invalidate() + } + @objc func present(_ checkoutURL: String) { DispatchQueue.main.async { if let url = URL(string: checkoutURL), let viewController = self.getCurrentViewController() { diff --git a/modules/@shopify/checkout-sheet-kit/package.json b/modules/@shopify/checkout-sheet-kit/package.json index b3e8f57..ceae859 100644 --- a/modules/@shopify/checkout-sheet-kit/package.json +++ b/modules/@shopify/checkout-sheet-kit/package.json @@ -1,7 +1,7 @@ { "name": "@shopify/checkout-sheet-kit", "license": "MIT", - "version": "3.0.4", + "version": "3.1.0", "main": "lib/commonjs/index.js", "types": "src/index.ts", "source": "src/index.ts", diff --git a/modules/@shopify/checkout-sheet-kit/src/context.tsx b/modules/@shopify/checkout-sheet-kit/src/context.tsx index 0e4df07..e57ee92 100644 --- a/modules/@shopify/checkout-sheet-kit/src/context.tsx +++ b/modules/@shopify/checkout-sheet-kit/src/context.tsx @@ -42,6 +42,7 @@ interface Context { preload: (checkoutUrl: string) => void; present: (checkoutUrl: string) => void; dismiss: () => void; + invalidate: () => void; version: Maybe; } @@ -54,6 +55,7 @@ const ShopifyCheckoutSheetContext = React.createContext({ getConfig: async () => undefined, preload: noop, present: noop, + invalidate: noop, dismiss: noop, version: undefined, }); @@ -95,6 +97,10 @@ export function ShopifyCheckoutSheetProvider({ } }, []); + const invalidate = useCallback(() => { + instance.current?.invalidate(); + }, []); + const dismiss = useCallback(() => { instance.current?.dismiss(); }, []); @@ -115,6 +121,7 @@ export function ShopifyCheckoutSheetProvider({ getConfig, preload, present, + invalidate, removeEventListeners, version: instance.current?.version, }; @@ -126,6 +133,7 @@ export function ShopifyCheckoutSheetProvider({ setConfig, preload, present, + invalidate, ]); return ( diff --git a/modules/@shopify/checkout-sheet-kit/src/index.d.ts b/modules/@shopify/checkout-sheet-kit/src/index.d.ts index 0fb7b5e..122d2e1 100644 --- a/modules/@shopify/checkout-sheet-kit/src/index.d.ts +++ b/modules/@shopify/checkout-sheet-kit/src/index.d.ts @@ -176,6 +176,11 @@ export interface ShopifyCheckoutSheetKit { * Preload the checkout for faster presentation. */ preload(checkoutURL: string): void; + + /** + * Invalidate preload cache. + */ + invalidate(): void; /** * Present the checkout. */ diff --git a/modules/@shopify/checkout-sheet-kit/src/index.ts b/modules/@shopify/checkout-sheet-kit/src/index.ts index 0f87002..0416d05 100644 --- a/modules/@shopify/checkout-sheet-kit/src/index.ts +++ b/modules/@shopify/checkout-sheet-kit/src/index.ts @@ -71,6 +71,10 @@ class ShopifyCheckoutSheet implements ShopifyCheckoutSheetKit { RNShopifyCheckoutSheetKit.dismiss(); } + public invalidate(): void { + RNShopifyCheckoutSheetKit.invalidateCache(); + } + public preload(checkoutUrl: string): void { RNShopifyCheckoutSheetKit.preload(checkoutUrl); } diff --git a/modules/@shopify/checkout-sheet-kit/tests/index.test.ts b/modules/@shopify/checkout-sheet-kit/tests/index.test.ts index ef4c271..f1b8b26 100644 --- a/modules/@shopify/checkout-sheet-kit/tests/index.test.ts +++ b/modules/@shopify/checkout-sheet-kit/tests/index.test.ts @@ -48,6 +48,7 @@ jest.mock('react-native', () => { version: '0.7.0', preload: jest.fn(), present: jest.fn(), + invalidateCache: jest.fn(), getConfig: jest.fn(async () => exampleConfig), setConfig: jest.fn(), addEventListener: jest.fn(), @@ -123,6 +124,16 @@ describe('ShopifyCheckoutSheetKit', () => { }); }); + describe('invalidate', () => { + it('calls `invalidateCache`', () => { + const instance = new ShopifyCheckoutSheet(); + instance.invalidate(); + expect( + NativeModules.ShopifyCheckoutSheetKit.invalidateCache, + ).toHaveBeenCalledTimes(1); + }); + }); + describe('present', () => { it('calls `present` with a checkout URL', () => { const instance = new ShopifyCheckoutSheet(); diff --git a/package.json b/package.json index 07a2d68..668b99f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "clean": "watchman watch-del .", "sample": "yarn workspace sample", "module": "yarn workspace @shopify/checkout-sheet-kit", - "pod-install": "(cd sample/ios && bundle exec pod repo update && NO_FLIPPER=1 bundle exec pod install --repo-update)", + "pod-install": "(cd sample/ios && bundle install && bundle exec pod repo update && bundle exec pod cache clean --all && NO_FLIPPER=1 bundle exec pod install --repo-update)", "snapshot": "./scripts/create_snapshot", "compare-snapshot": "./scripts/compare_snapshot", "turbo": "turbo", diff --git a/sample/android/gradle.properties b/sample/android/gradle.properties index 0d5b673..ed354e3 100644 --- a/sample/android/gradle.properties +++ b/sample/android/gradle.properties @@ -41,4 +41,4 @@ newArchEnabled=false hermesEnabled=true # Note: only used here for testing -SHOPIFY_CHECKOUT_SDK_VERSION=3.0.4 +SHOPIFY_CHECKOUT_SDK_VERSION=3.2.0 diff --git a/sample/ios/Podfile.lock b/sample/ios/Podfile.lock index 27eeb0e..07ff12e 100644 --- a/sample/ios/Podfile.lock +++ b/sample/ios/Podfile.lock @@ -1235,9 +1235,9 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNShopifyCheckoutSheetKit (3.0.3): + - RNShopifyCheckoutSheetKit (3.1.0): - React-Core - - ShopifyCheckoutSheetKit (~> 3.0.4) + - ShopifyCheckoutSheetKit (~> 3.1.1) - RNVectorIcons (10.0.3): - DoubleConversion - glog @@ -1259,9 +1259,8 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - ShopifyCheckoutSheetKit (3.0.4) + - ShopifyCheckoutSheetKit (3.1.1) - SocketRocket (0.7.0) - - SwiftLint (0.56.1) - Yoga (0.0.0) DEPENDENCIES: @@ -1328,14 +1327,12 @@ DEPENDENCIES: - RNScreens (from `../node_modules/react-native-screens`) - "RNShopifyCheckoutSheetKit (from `../../modules/@shopify/checkout-sheet-kit`)" - RNVectorIcons (from `../node_modules/react-native-vector-icons`) - - SwiftLint - Yoga (from `../../node_modules/react-native/ReactCommon/yoga`) SPEC REPOS: trunk: - ShopifyCheckoutSheetKit - SocketRocket - - SwiftLint EXTERNAL SOURCES: boost: @@ -1524,13 +1521,12 @@ SPEC CHECKSUMS: RNGestureHandler: 9b113eb9b7a4cbe66e1dbf4d9914281863ee0703 RNReanimated: d534e0114e2c3e7011550a78ecf2d0b431435a60 RNScreens: 23dad53fc9db1da2c93e647ae33fd7ce2bd49d60 - RNShopifyCheckoutSheetKit: 3d386855d029ba2a06fa537c9bf1f9057bbc4f6a + RNShopifyCheckoutSheetKit: 3d854ed7fe1bc96eab4718819ee79d33488066bc RNVectorIcons: 50ea777efffdd991a22e968aa312d75da7ff46c3 - ShopifyCheckoutSheetKit: 1753e9a06df41ca567ace784719fd43cff89b872 + ShopifyCheckoutSheetKit: fe309799b18b8d554f28c3f075d6d57d4811c9ab SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d - SwiftLint: c5fa0b7eece474d43d2178b581a1242a16267347 Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372 -PODFILE CHECKSUM: 9efd19a381198fb46f36acf3d269233039fb9dc5 +PODFILE CHECKSUM: 4a9ceecdcfb54884b51163a7e4438cd49c73c8d9 COCOAPODS: 1.15.2