From cf0968e5487b1778b1f5d7dc0e466d8a5cf5009f Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Thu, 24 Oct 2024 15:47:35 -0400 Subject: [PATCH] Upgrade swift dependency, add support for invalidate function --- .../RNShopifyCheckoutSheetKit.podspec | 2 +- .../ios/ShopifyCheckoutSheetKit.mm | 3 +++ .../ios/ShopifyCheckoutSheetKit.swift | 4 ++++ .../@shopify/checkout-sheet-kit/src/context.tsx | 8 ++++++++ .../@shopify/checkout-sheet-kit/src/index.d.ts | 5 +++++ modules/@shopify/checkout-sheet-kit/src/index.ts | 4 ++++ package.json | 2 +- sample/ios/Podfile | 2 +- sample/ios/Podfile.lock | 16 ++++++---------- 9 files changed, 33 insertions(+), 13 deletions(-) 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/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..eb2a720 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/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/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/ios/Podfile b/sample/ios/Podfile index bbca599..55d3951 100644 --- a/sample/ios/Podfile +++ b/sample/ios/Podfile @@ -55,6 +55,6 @@ target 'ReactNative' do end end -pod 'SwiftLint' +# pod 'SwiftLint' pod "RNShopifyCheckoutSheetKit", :path => "../../modules/@shopify/checkout-sheet-kit" diff --git a/sample/ios/Podfile.lock b/sample/ios/Podfile.lock index 27eeb0e..5d1dc42 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.0.4): - 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: a1d74986116e1303d7809681310b66c1dfd9c503 RNVectorIcons: 50ea777efffdd991a22e968aa312d75da7ff46c3 - ShopifyCheckoutSheetKit: 1753e9a06df41ca567ace784719fd43cff89b872 + ShopifyCheckoutSheetKit: fe309799b18b8d554f28c3f075d6d57d4811c9ab SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d - SwiftLint: c5fa0b7eece474d43d2178b581a1242a16267347 Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372 -PODFILE CHECKSUM: 9efd19a381198fb46f36acf3d269233039fb9dc5 +PODFILE CHECKSUM: 4a9ceecdcfb54884b51163a7e4438cd49c73c8d9 COCOAPODS: 1.15.2