Skip to content

Commit

Permalink
3.1.0 (#131)
Browse files Browse the repository at this point in the history
* Upgrade swift dependency, add support for invalidate function

* Upgrade Android dependency, add support for invalidate function

* Minor bump

* Add changelog entry

* Add test for invalidate
  • Loading branch information
markmur authored Oct 25, 2024
1 parent f5e67e5 commit 1c47bd6
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 15 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion modules/@shopify/checkout-sheet-kit/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 8 additions & 0 deletions modules/@shopify/checkout-sheet-kit/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface Context {
preload: (checkoutUrl: string) => void;
present: (checkoutUrl: string) => void;
dismiss: () => void;
invalidate: () => void;
version: Maybe<string>;
}

Expand All @@ -54,6 +55,7 @@ const ShopifyCheckoutSheetContext = React.createContext<Context>({
getConfig: async () => undefined,
preload: noop,
present: noop,
invalidate: noop,
dismiss: noop,
version: undefined,
});
Expand Down Expand Up @@ -95,6 +97,10 @@ export function ShopifyCheckoutSheetProvider({
}
}, []);

const invalidate = useCallback(() => {
instance.current?.invalidate();
}, []);

const dismiss = useCallback(() => {
instance.current?.dismiss();
}, []);
Expand All @@ -115,6 +121,7 @@ export function ShopifyCheckoutSheetProvider({
getConfig,
preload,
present,
invalidate,
removeEventListeners,
version: instance.current?.version,
};
Expand All @@ -126,6 +133,7 @@ export function ShopifyCheckoutSheetProvider({
setConfig,
preload,
present,
invalidate,
]);

return (
Expand Down
5 changes: 5 additions & 0 deletions modules/@shopify/checkout-sheet-kit/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 4 additions & 0 deletions modules/@shopify/checkout-sheet-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class ShopifyCheckoutSheet implements ShopifyCheckoutSheetKit {
RNShopifyCheckoutSheetKit.dismiss();
}

public invalidate(): void {
RNShopifyCheckoutSheetKit.invalidateCache();
}

public preload(checkoutUrl: string): void {
RNShopifyCheckoutSheetKit.preload(checkoutUrl);
}
Expand Down
11 changes: 11 additions & 0 deletions modules/@shopify/checkout-sheet-kit/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion sample/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 6 additions & 10 deletions sample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

0 comments on commit 1c47bd6

Please sign in to comment.