From 909b8829efac98d1d37d0a4d06c769142c3491a8 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Wed, 25 Mar 2026 09:54:29 +0000 Subject: [PATCH 01/12] chore: bump dev.yml to iOS 26.2 From d66e1d508fb1de54c6593a92536b013515f20a66 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Wed, 25 Mar 2026 11:31:29 +0000 Subject: [PATCH 02/12] Add TurboModule specs and codegen components to prepare RN new-arch migration Prepare codebase for React Native new-architecture (TurboModules/codegen) by adding JS specs, codegen native components, and test mocks. What changed and why: - Added a TurboModule spec (NativeShopifyCheckoutSheetKit) and a codegen native component spec (RCTAcceleratedCheckoutButtonsNativeComponent) to declare the native API surface and typed component props. This moves JS to consume the new-arch API surface via TurboModuleRegistry and codegenNativeComponent instead of using NativeModules/requireNativeComponent directly. - Updated AcceleratedCheckoutButtons to import codegenNativeComponent and use the generated native component type instead of requireNativeComponent. - Added codegenConfig to the package.json to configure codegen generation for this module. - Added Jest mocks for codegenNativeComponent and extended the react-native manual mock to provide TurboModuleRegistry.getEnforcing, getConstants, and event listener helpers so unit tests run against the new-arch surface. - Added a moduleNameMapper entry to jest.config.js so tests resolve the codegenNativeComponent import to the new mock. - Updated a linking test to assert TurboModuleRegistry behavior (throws when module not present) rather than the old NativeModules linking error. - Adjusted runtime usage to read version via getConstants() and cast getConfig() return types for better typing with the spec. Context and next steps: - These changes are groundwork only: they enable the JS-side migration to the RN new architecture and allow tests to run against the new-arch signatures. - Native implementations (iOS/Android) still need corresponding TurboModule and codegen native component implementations, and we must decide on compatibility strategy (clean break vs dual support). Dual support will add duplication (parallel native hooks, bridging shims) and phased rollout; a clean break requires coordinating release timelines for hosts consuming this module. - Suggested next phases: (1) implement native TurboModule & codegen components on each platform, (2) add migration shims to continue supporting old NativeModules if dual-mode required, (3) integration testing & performance validation, (4) cutover and remove old-arch shims when safe. This commit prepares the repository for the migration and makes future work (native bindings and compatibility strategy) easier to implement and test. --- __mocks__/codegenNativeComponent.ts | 11 +++ __mocks__/react-native.ts | 11 +++ jest.config.js | 4 + .../@shopify/checkout-sheet-kit/package.json | 8 ++ .../components/AcceleratedCheckoutButtons.tsx | 5 +- .../@shopify/checkout-sheet-kit/src/index.ts | 22 ++---- .../specs/NativeShopifyCheckoutSheetKit.ts | 78 +++++++++++++++++++ ...celeratedCheckoutButtonsNativeComponent.ts | 69 ++++++++++++++++ .../checkout-sheet-kit/tests/linking.test.ts | 27 +++---- 9 files changed, 198 insertions(+), 37 deletions(-) create mode 100644 __mocks__/codegenNativeComponent.ts create mode 100644 modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts create mode 100644 modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts diff --git a/__mocks__/codegenNativeComponent.ts b/__mocks__/codegenNativeComponent.ts new file mode 100644 index 00000000..56bc43de --- /dev/null +++ b/__mocks__/codegenNativeComponent.ts @@ -0,0 +1,11 @@ +const React = require('react'); + +const codegenNativeComponent = (_name: string) => { + return (props: any) => + React.createElement('View', { + ...props, + testID: props?.testID ?? 'accelerated-checkout-buttons', + }); +}; + +export default codegenNativeComponent; diff --git a/__mocks__/react-native.ts b/__mocks__/react-native.ts index 34cb204a..6dd8d395 100644 --- a/__mocks__/react-native.ts +++ b/__mocks__/react-native.ts @@ -47,6 +47,7 @@ const exampleConfig = {preloading: true}; const ShopifyCheckoutSheetKit = { version: '0.7.0', + getConstants: jest.fn(() => ({version: '0.7.0'})), preload: jest.fn(), present: jest.fn(), dismiss: jest.fn(), @@ -58,6 +59,8 @@ const ShopifyCheckoutSheetKit = { initiateGeolocationRequest: jest.fn(), configureAcceleratedCheckouts: jest.fn(), isAcceleratedCheckoutAvailable: jest.fn(), + addListener: jest.fn(), + removeListeners: jest.fn(), }; // CommonJS export for Jest manual mock resolution @@ -68,6 +71,14 @@ module.exports = { }, NativeEventEmitter: jest.fn(() => createMockEmitter()), requireNativeComponent, + TurboModuleRegistry: { + getEnforcing: jest.fn((name: string) => { + if (name === 'ShopifyCheckoutSheetKit') { + return ShopifyCheckoutSheetKit; + } + return null; + }), + }, NativeModules: { ShopifyCheckoutSheetKit: { ...ShopifyCheckoutSheetKit, diff --git a/jest.config.js b/jest.config.js index 6763de59..d43f8497 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,6 +3,10 @@ module.exports = { modulePathIgnorePatterns: ['modules/@shopify/checkout-sheet-kit/lib'], modulePaths: ['/sample/node_modules'], setupFiles: ['/jest.setup.ts'], + moduleNameMapper: { + 'react-native/Libraries/Utilities/codegenNativeComponent': + '/__mocks__/codegenNativeComponent.ts', + }, transform: { '\\.[jt]sx?$': 'babel-jest', }, diff --git a/modules/@shopify/checkout-sheet-kit/package.json b/modules/@shopify/checkout-sheet-kit/package.json index 3ddaf0de..da6bd81f 100644 --- a/modules/@shopify/checkout-sheet-kit/package.json +++ b/modules/@shopify/checkout-sheet-kit/package.json @@ -54,6 +54,14 @@ "react-native-builder-bob": "^0.23.2", "typescript": "^5.9.2" }, + "codegenConfig": { + "name": "RNShopifyCheckoutSheetKitSpec", + "type": "all", + "jsSrcsDir": "src/specs", + "android": { + "javaPackageName": "com.shopify.checkoutsheetkit" + } + }, "react-native-builder-bob": { "source": "src", "output": "lib", diff --git a/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx b/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx index ab8971f7..b4972610 100644 --- a/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx +++ b/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO */ import React, {useCallback, useMemo, useState} from 'react'; -import {requireNativeComponent, Platform} from 'react-native'; +import {Platform} from 'react-native'; import type {ViewStyle} from 'react-native'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import type { AcceleratedCheckoutWallet, CheckoutCompletedEvent, @@ -178,7 +179,7 @@ interface NativeAcceleratedCheckoutButtonsProps { } const RCTAcceleratedCheckoutButtons = - requireNativeComponent( + codegenNativeComponent( 'RCTAcceleratedCheckoutButtons', ); diff --git a/modules/@shopify/checkout-sheet-kit/src/index.ts b/modules/@shopify/checkout-sheet-kit/src/index.ts index 41bf2a5c..5e5bc8f1 100644 --- a/modules/@shopify/checkout-sheet-kit/src/index.ts +++ b/modules/@shopify/checkout-sheet-kit/src/index.ts @@ -21,17 +21,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { - NativeModules, - NativeEventEmitter, - PermissionsAndroid, - Platform, -} from 'react-native'; +import {NativeEventEmitter, PermissionsAndroid, Platform} from 'react-native'; import type { EmitterSubscription, EventSubscription, PermissionStatus, } from 'react-native'; +import RNShopifyCheckoutSheetKit from './specs/NativeShopifyCheckoutSheetKit'; import {ShopifyCheckoutSheetProvider, useShopifyCheckoutSheet} from './context'; import {ApplePayContactField, ColorScheme, LogLevel} from './index.d'; import type { @@ -64,15 +60,6 @@ import type { RenderStateChangeEvent, } from './components/AcceleratedCheckoutButtons'; -const RNShopifyCheckoutSheetKit = NativeModules.ShopifyCheckoutSheetKit; - -if (!('ShopifyCheckoutSheetKit' in NativeModules)) { - throw new Error(` - "@shopify/checkout-sheet-kit" is not correctly linked. - - If you are building for iOS, make sure to run "pod install" first and restart the metro server.`); -} - const defaultFeatures: Features = { handleGeolocationRequests: true, }; @@ -114,7 +101,8 @@ class ShopifyCheckoutSheet implements ShopifyCheckoutSheetKit { } } - public readonly version: string = RNShopifyCheckoutSheetKit.version; + public readonly version: string = + RNShopifyCheckoutSheetKit.getConstants().version; /** * Dismisses the currently displayed checkout sheet @@ -151,7 +139,7 @@ class ShopifyCheckoutSheet implements ShopifyCheckoutSheetKit { * @returns Promise containing the current Configuration */ public async getConfig(): Promise { - return RNShopifyCheckoutSheetKit.getConfig(); + return RNShopifyCheckoutSheetKit.getConfig() as Promise; } /** diff --git a/modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts b/modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts new file mode 100644 index 00000000..84928eaa --- /dev/null +++ b/modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts @@ -0,0 +1,78 @@ +import type {TurboModule} from 'react-native'; +import {TurboModuleRegistry} from 'react-native'; + +type IosColorsSpec = { + tintColor?: string; + backgroundColor?: string; + closeButtonColor?: string; +}; + +type AndroidColorsBaseSpec = { + progressIndicator?: string; + backgroundColor?: string; + headerBackgroundColor?: string; + headerTextColor?: string; + closeButtonColor?: string; +}; + +type AndroidColorsSpec = { + progressIndicator?: string; + backgroundColor?: string; + headerBackgroundColor?: string; + headerTextColor?: string; + closeButtonColor?: string; + light?: AndroidColorsBaseSpec; + dark?: AndroidColorsBaseSpec; +}; + +type ColorsSpec = { + ios?: IosColorsSpec; + android?: AndroidColorsSpec; +}; + +type ConfigurationSpec = { + preloading?: boolean; + title?: string; + colorScheme?: string; + logLevel?: string; + colors?: ColorsSpec; +}; + +type ConfigurationResultSpec = { + preloading: boolean; + colorScheme: string; + logLevel: string; + title?: string; + tintColor?: string; + backgroundColor?: string; + closeButtonColor?: string; +}; + +export interface Spec extends TurboModule { + present(checkoutUrl: string): void; + preload(checkoutUrl: string): void; + dismiss(): void; + invalidateCache(): void; + setConfig(configuration: ConfigurationSpec): void; + getConfig(): Promise; + configureAcceleratedCheckouts( + storefrontDomain: string, + storefrontAccessToken: string, + customerEmail: string | null, + customerPhoneNumber: string | null, + customerAccessToken: string | null, + applePayMerchantIdentifier: string | null, + applyPayContactFields: string[], + supportedShippingCountries: string[], + ): Promise; + isAcceleratedCheckoutAvailable(): Promise; + isApplePayAvailable(): Promise; + initiateGeolocationRequest(allow: boolean): void; + addListener(eventName: string): void; + removeListeners(count: number): void; + getConstants(): {version: string}; +} + +export default TurboModuleRegistry.getEnforcing( + 'ShopifyCheckoutSheetKit', +); diff --git a/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts new file mode 100644 index 00000000..f2b43574 --- /dev/null +++ b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts @@ -0,0 +1,69 @@ +import type {ViewProps} from 'react-native'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; +import type { + BubblingEventHandler, + DirectEventHandler, + Double, + Float, +} from 'react-native/Libraries/Types/CodegenTypes'; + +type FailEvent = Readonly<{ + __typename: string; + message: string; + code?: string; + recoverable?: boolean; +}>; + +type CompleteEvent = Readonly<{ + orderDetails: { + id: string; + cart: { + token: string; + lines: ReadonlyArray< + Readonly<{ + title: string; + quantity: Double; + merchandiseId?: string; + productId?: string; + }> + >; + }; + email?: string; + phone?: string; + }; +}>; + +type RenderStateChangeEvent = Readonly<{ + state: string; + reason?: string; +}>; + +type ClickLinkEvent = Readonly<{url: string}>; +type SizeChangeEvent = Readonly<{height: Double}>; + +type CheckoutIdentifierSpec = Readonly<{ + cartId?: string; + variantId?: string; + quantity?: Double; +}>; + +interface NativeProps extends ViewProps { + checkoutIdentifier: CheckoutIdentifierSpec; + cornerRadius?: Float; + wallets?: ReadonlyArray; + applePayLabel?: string; + onFail?: BubblingEventHandler; + onComplete?: BubblingEventHandler; + onCancel?: BubblingEventHandler; + onRenderStateChange?: BubblingEventHandler; + onWebPixelEvent?: BubblingEventHandler>; + onClickLink?: BubblingEventHandler; + onSizeChange?: DirectEventHandler; + onShouldRecoverFromError?: DirectEventHandler< + Readonly<{recoverable: boolean}> + >; +} + +export default codegenNativeComponent( + 'RCTAcceleratedCheckoutButtons', +); diff --git a/modules/@shopify/checkout-sheet-kit/tests/linking.test.ts b/modules/@shopify/checkout-sheet-kit/tests/linking.test.ts index b2587f05..f83795f8 100644 --- a/modules/@shopify/checkout-sheet-kit/tests/linking.test.ts +++ b/modules/@shopify/checkout-sheet-kit/tests/linking.test.ts @@ -1,31 +1,22 @@ -/** - * Test for native module linking error - */ - -// Mock NativeModules without ShopifyCheckoutSheetKit jest.mock('react-native', () => ({ - NativeModules: { - // Intentionally empty to trigger linking error - }, + NativeModules: {}, NativeEventEmitter: jest.fn(), Platform: { OS: 'ios', }, - requireNativeComponent: jest.fn().mockImplementation(() => { - const mockComponent = (props: any) => { - // Use React.createElement with plain object instead - const mockReact = jest.requireActual('react'); - return mockReact.createElement('View', props); - }; - return mockComponent; - }), + TurboModuleRegistry: { + getEnforcing: jest.fn((name: string) => { + throw new Error( + `TurboModuleRegistry.getEnforcing(...): '${name}' could not be found.`, + ); + }), + }, })); describe('Native Module Linking', () => { it('throws error when native module is not linked', () => { expect(() => { - // This will trigger the linking check require('../src/index'); - }).toThrow('@shopify/checkout-sheet-kit" is not correctly linked.'); + }).toThrow('ShopifyCheckoutSheetKit'); }); }); From f52c3f70ec18a1e6dd7b43879a7bc073c4c71839 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 26 Mar 2026 10:50:46 +0000 Subject: [PATCH 03/12] Remove cart from orderDetails type and simplify sample RN scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduce the surface area and simplify startup scripts to prepare for the React Native new-arch migration. - Narrow CompleteEvent.orderDetails to a readonly object containing only id, email and phone (remove nested cart/lines). This reduces the amount of complex data being passed through the bridge and simplifies the typings for the accelerated checkout UI component and its native/JS contract. Note: this is a breaking API/type change for any consumers that relied on the cart payload — update callers accordingly. - Simplify sample/package.json scripts by removing hard-coded simulator selection for ios/start. This makes the sample project scripts more portable across developer machines and CI and avoids simulator name mismatches during iteration. These changes are intended to lower duplication and complexity while we plan the phased migration to the new RN architecture (fewer/cleaner native<->JS contracts makes a cleaner transition). --- ...CTAcceleratedCheckoutButtonsNativeComponent.ts | 15 ++------------- sample/package.json | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts index f2b43574..1698e802 100644 --- a/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts +++ b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts @@ -15,22 +15,11 @@ type FailEvent = Readonly<{ }>; type CompleteEvent = Readonly<{ - orderDetails: { + orderDetails: Readonly<{ id: string; - cart: { - token: string; - lines: ReadonlyArray< - Readonly<{ - title: string; - quantity: Double; - merchandiseId?: string; - productId?: string; - }> - >; - }; email?: string; phone?: string; - }; + }>; }>; type RenderStateChangeEvent = Readonly<{ diff --git a/sample/package.json b/sample/package.json index 3c70b08d..206396f1 100644 --- a/sample/package.json +++ b/sample/package.json @@ -10,8 +10,8 @@ "release:android": "sh ./scripts/release_android", "build:ios": "sh ./scripts/build_ios", "lint": "yarn typecheck && eslint .", - "ios": "react-native run-ios --simulator 'iPhone 15 Pro'", - "start": "react-native start -- --simulator 'iPhone 15 Pro' --reset-cache", + "ios": "react-native run-ios", + "start": "react-native start -- --reset-cache", "typecheck": "tsc --noEmit", "test:ios": "sh ./scripts/test_ios", "test:android": "sh ./scripts/test_android" From b6cd3e1bc1e22b41bb91eb38c8ac2bbc0b08a013 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 26 Mar 2026 12:04:28 +0000 Subject: [PATCH 04/12] Add native spec files to support React Native new-arch migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add TypeScript spec stubs and package snapshot entries to prepare for React Native’s new architecture. These changes introduce spec files for the native module/native component surface (with MIT license headers) and update the package snapshot so the generated commonjs/module/typescript artifacts and type declarations are tracked. This is a preparatory change to enable codegen/TurboModule and native component integration as part of the larger new-arch migration. No runtime behavior is changed here — this just lays the groundwork for the phased migration to the new RN architecture and packaging of the generated artifacts. --- .../checkout-sheet-kit/package.snapshot.json | 16 ++++++++++++- .../specs/NativeShopifyCheckoutSheetKit.ts | 23 +++++++++++++++++++ ...celeratedCheckoutButtonsNativeComponent.ts | 23 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/modules/@shopify/checkout-sheet-kit/package.snapshot.json b/modules/@shopify/checkout-sheet-kit/package.snapshot.json index 782ccbaa..8cddcc9f 100644 --- a/modules/@shopify/checkout-sheet-kit/package.snapshot.json +++ b/modules/@shopify/checkout-sheet-kit/package.snapshot.json @@ -30,6 +30,10 @@ "lib/commonjs/index.js.map", "lib/commonjs/pixels.d.js", "lib/commonjs/pixels.d.js.map", + "lib/commonjs/specs/NativeShopifyCheckoutSheetKit.js", + "lib/commonjs/specs/NativeShopifyCheckoutSheetKit.js.map", + "lib/commonjs/specs/RCTAcceleratedCheckoutButtonsNativeComponent.js", + "lib/commonjs/specs/RCTAcceleratedCheckoutButtonsNativeComponent.js.map", "lib/module/components/AcceleratedCheckoutButtons.js", "lib/module/components/AcceleratedCheckoutButtons.js.map", "lib/module/context.js", @@ -44,12 +48,20 @@ "lib/module/index.js.map", "lib/module/pixels.d.js", "lib/module/pixels.d.js.map", + "lib/module/specs/NativeShopifyCheckoutSheetKit.js", + "lib/module/specs/NativeShopifyCheckoutSheetKit.js.map", + "lib/module/specs/RCTAcceleratedCheckoutButtonsNativeComponent.js", + "lib/module/specs/RCTAcceleratedCheckoutButtonsNativeComponent.js.map", "lib/typescript/src/components/AcceleratedCheckoutButtons.d.ts", "lib/typescript/src/components/AcceleratedCheckoutButtons.d.ts.map", "lib/typescript/src/context.d.ts", "lib/typescript/src/context.d.ts.map", "lib/typescript/src/index.d.ts", "lib/typescript/src/index.d.ts.map", + "lib/typescript/src/specs/NativeShopifyCheckoutSheetKit.d.ts", + "lib/typescript/src/specs/NativeShopifyCheckoutSheetKit.d.ts.map", + "lib/typescript/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.d.ts", + "lib/typescript/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.d.ts.map", "package.json", "src/components/AcceleratedCheckoutButtons.tsx", "src/context.tsx", @@ -57,5 +69,7 @@ "src/events.d.ts", "src/index.d.ts", "src/index.ts", - "src/pixels.d.ts" + "src/pixels.d.ts", + "src/specs/NativeShopifyCheckoutSheetKit.ts", + "src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts" ] diff --git a/modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts b/modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts index 84928eaa..89855ea5 100644 --- a/modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts +++ b/modules/@shopify/checkout-sheet-kit/src/specs/NativeShopifyCheckoutSheetKit.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright 2023 - Present, Shopify Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + import type {TurboModule} from 'react-native'; import {TurboModuleRegistry} from 'react-native'; diff --git a/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts index 1698e802..b5d62ff8 100644 --- a/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts +++ b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts @@ -1,3 +1,26 @@ +/* +MIT License + +Copyright 2023 - Present, Shopify Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + import type {ViewProps} from 'react-native'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import type { From 34648694259a3710b08a39eb68127e6ef743eba7 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 26 Mar 2026 12:29:11 +0000 Subject: [PATCH 05/12] Make npm upgrade non-fatal in CI setup for broken macOS runners The macOS runner's pre-installed npm has a corrupted promise-retry module, causing `npm install -g npm@11` to fail. Since all CI jobs use yarn (not npm), this step is non-critical. Emit a warning annotation and continue instead of failing the job. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 7fb7163e..98e2d80d 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -12,7 +12,7 @@ runs: # TODO: Can be removed once node-version is 24 as this will be the minimum - name: Install npm 11 - run: npm install -g npm@11 + run: npm install -g npm@11 || echo "::warning::npm upgrade failed — not required for yarn-based CI" shell: bash - name: Cache turbo build setup From 0ce385fcb817ebaa78927b7865c27f404023ccb3 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 26 Mar 2026 12:36:59 +0000 Subject: [PATCH 06/12] Add plugin repositories to Android settings.gradle for resilient dependency resolution The Gradle foojay-resolver-convention plugin needs gson from Maven Central, which intermittently returns 403. Adding explicit pluginManagement repositories (gradlePluginPortal, google, mavenCentral) provides fallback mirrors. Co-Authored-By: Claude Opus 4.6 (1M context) --- sample/android/settings.gradle | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sample/android/settings.gradle b/sample/android/settings.gradle index f49ac411..53360013 100644 --- a/sample/android/settings.gradle +++ b/sample/android/settings.gradle @@ -1,4 +1,11 @@ -pluginManagement { includeBuild("../../node_modules/@react-native/gradle-plugin") } +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } + includeBuild("../../node_modules/@react-native/gradle-plugin") +} plugins { id("com.facebook.react.settings") } extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() } From 99f048045c2a8d5d56d2ff2c51a7a1d99bc2a782 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 26 Mar 2026 17:53:04 +0000 Subject: [PATCH 07/12] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 98e2d80d..4b0f3111 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -12,7 +12,7 @@ runs: # TODO: Can be removed once node-version is 24 as this will be the minimum - name: Install npm 11 - run: npm install -g npm@11 || echo "::warning::npm upgrade failed — not required for yarn-based CI" + run: npm install -g npm@11" shell: bash - name: Cache turbo build setup From c8b838f185b1750ece851ccc57bc023cc4cf5820 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 26 Mar 2026 17:53:46 +0000 Subject: [PATCH 08/12] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 4b0f3111..7fb7163e 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -12,7 +12,7 @@ runs: # TODO: Can be removed once node-version is 24 as this will be the minimum - name: Install npm 11 - run: npm install -g npm@11" + run: npm install -g npm@11 shell: bash - name: Cache turbo build setup From 17436a90012b5fa743360536bf4bb0ef25d47e9d Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 26 Mar 2026 18:00:55 +0000 Subject: [PATCH 09/12] Make npm upgrade non-fatal in CI setup for broken macOS runners The macOS runner's pre-installed npm has a corrupted promise-retry module, causing `npm install -g npm@11` to fail. Since all CI jobs use yarn (not npm), this step is non-critical. Emit a warning annotation and continue instead of failing the job. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 7fb7163e..98e2d80d 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -12,7 +12,7 @@ runs: # TODO: Can be removed once node-version is 24 as this will be the minimum - name: Install npm 11 - run: npm install -g npm@11 + run: npm install -g npm@11 || echo "::warning::npm upgrade failed — not required for yarn-based CI" shell: bash - name: Cache turbo build setup From 60a509b6c07d2596d2b5825e9ec54ed0ed71cd7c Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Mon, 30 Mar 2026 13:56:32 +0100 Subject: [PATCH 10/12] revert npm upgrade --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 98e2d80d..7fb7163e 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -12,7 +12,7 @@ runs: # TODO: Can be removed once node-version is 24 as this will be the minimum - name: Install npm 11 - run: npm install -g npm@11 || echo "::warning::npm upgrade failed — not required for yarn-based CI" + run: npm install -g npm@11 shell: bash - name: Cache turbo build setup From 75de4181f725104e3fb3537e277bfe8ec9bdc636 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Thu, 16 Apr 2026 17:20:42 +0100 Subject: [PATCH 11/12] test: migrate tests to use TurboModuleRegistry Update test references from NativeModules.ShopifyCheckoutSheetKit to TurboModuleRegistry.getEnforcing to match the production code path established by this PR. Remove stale event emitter cleanup that was specific to the old NativeModules mock shape. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../checkout-sheet-kit/tests/index.test.ts | 90 +++++++++---------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/modules/@shopify/checkout-sheet-kit/tests/index.test.ts b/modules/@shopify/checkout-sheet-kit/tests/index.test.ts index 450f925c..da69755e 100644 --- a/modules/@shopify/checkout-sheet-kit/tests/index.test.ts +++ b/modules/@shopify/checkout-sheet-kit/tests/index.test.ts @@ -20,7 +20,11 @@ import { type AcceleratedCheckoutConfiguration, } from '../src'; import type {ApplePayContactField} from '../src/index.d'; -import {NativeModules, PermissionsAndroid, Platform} from 'react-native'; +import {TurboModuleRegistry, PermissionsAndroid, Platform} from 'react-native'; + +const NativeModule = TurboModuleRegistry.getEnforcing( + 'ShopifyCheckoutSheetKit', +) as any; const checkoutUrl = 'https://shopify.com/checkout'; const config: Configuration = { @@ -64,13 +68,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventEmitter = ShopifyCheckoutSheet.eventEmitter; afterEach(() => { - NativeModules.ShopifyCheckoutSheetKit.setConfig.mockReset(); - NativeModules.ShopifyCheckoutSheetKit.eventEmitter.addListener.mockClear(); - NativeModules.ShopifyCheckoutSheetKit.eventEmitter.removeAllListeners.mockClear(); - - // Clear mock listeners - NativeModules._listeners = []; - + NativeModule.setConfig.mockReset(); jest.clearAllMocks(); }); @@ -78,14 +76,14 @@ describe('ShopifyCheckoutSheetKit', () => { it('calls `setConfig` with the specified config on instantiation', () => { new ShopifyCheckoutSheet(config); expect( - NativeModules.ShopifyCheckoutSheetKit.setConfig, + NativeModule.setConfig, ).toHaveBeenCalledWith(config); }); it('does not call `setConfig` if no config was specified on instantiation', () => { new ShopifyCheckoutSheet(); expect( - NativeModules.ShopifyCheckoutSheetKit.setConfig, + NativeModule.setConfig, ).not.toHaveBeenCalled(); }); }); @@ -95,10 +93,10 @@ describe('ShopifyCheckoutSheetKit', () => { const instance = new ShopifyCheckoutSheet(); instance.setConfig(config); expect( - NativeModules.ShopifyCheckoutSheetKit.setConfig, + NativeModule.setConfig, ).toHaveBeenCalledTimes(1); expect( - NativeModules.ShopifyCheckoutSheetKit.setConfig, + NativeModule.setConfig, ).toHaveBeenCalledWith(config); }); @@ -110,7 +108,7 @@ describe('ShopifyCheckoutSheetKit', () => { }; instance.setConfig(configWithLogLevel); expect( - NativeModules.ShopifyCheckoutSheetKit.setConfig, + NativeModule.setConfig, ).toHaveBeenCalledWith(configWithLogLevel); }); }); @@ -120,10 +118,10 @@ describe('ShopifyCheckoutSheetKit', () => { const instance = new ShopifyCheckoutSheet(); instance.preload(checkoutUrl); expect( - NativeModules.ShopifyCheckoutSheetKit.preload, + NativeModule.preload, ).toHaveBeenCalledTimes(1); expect( - NativeModules.ShopifyCheckoutSheetKit.preload, + NativeModule.preload, ).toHaveBeenCalledWith(checkoutUrl); }); }); @@ -133,7 +131,7 @@ describe('ShopifyCheckoutSheetKit', () => { const instance = new ShopifyCheckoutSheet(); instance.invalidate(); expect( - NativeModules.ShopifyCheckoutSheetKit.invalidateCache, + NativeModule.invalidateCache, ).toHaveBeenCalledTimes(1); }); }); @@ -143,10 +141,10 @@ describe('ShopifyCheckoutSheetKit', () => { const instance = new ShopifyCheckoutSheet(); instance.present(checkoutUrl); expect( - NativeModules.ShopifyCheckoutSheetKit.present, + NativeModule.present, ).toHaveBeenCalledTimes(1); expect( - NativeModules.ShopifyCheckoutSheetKit.present, + NativeModule.present, ).toHaveBeenCalledWith(checkoutUrl); }); }); @@ -156,7 +154,7 @@ describe('ShopifyCheckoutSheetKit', () => { const instance = new ShopifyCheckoutSheet(); instance.dismiss(); expect( - NativeModules.ShopifyCheckoutSheetKit.dismiss, + NativeModule.dismiss, ).toHaveBeenCalledTimes(1); }); }); @@ -168,7 +166,7 @@ describe('ShopifyCheckoutSheetKit', () => { preloading: true, }); expect( - NativeModules.ShopifyCheckoutSheetKit.getConfig, + NativeModule.getConfig, ).toHaveBeenCalledTimes(1); }); }); @@ -191,7 +189,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'pixel'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -214,7 +212,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'pixel'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -242,7 +240,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'pixel'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -271,7 +269,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'pixel'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -295,7 +293,7 @@ describe('ShopifyCheckoutSheetKit', () => { throw new Error('Callback error'); }); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -325,7 +323,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'completed'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -345,7 +343,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'completed'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -363,7 +361,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'completed'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -436,7 +434,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'error'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -459,7 +457,7 @@ describe('ShopifyCheckoutSheetKit', () => { const eventName = 'error'; const callback = jest.fn(); instance.addEventListener(eventName, callback); - NativeModules.ShopifyCheckoutSheetKit.addEventListener( + NativeModule.addEventListener( eventName, callback, ); @@ -553,7 +551,7 @@ describe('ShopifyCheckoutSheetKit', () => { 'android.permission.ACCESS_FINE_LOCATION', ]); expect( - NativeModules.ShopifyCheckoutSheetKit.initiateGeolocationRequest, + NativeModule.initiateGeolocationRequest, ).toHaveBeenCalledWith(true); }); @@ -578,7 +576,7 @@ describe('ShopifyCheckoutSheetKit', () => { 'android.permission.ACCESS_FINE_LOCATION', ]); expect( - NativeModules.ShopifyCheckoutSheetKit.initiateGeolocationRequest, + NativeModule.initiateGeolocationRequest, ).toHaveBeenCalledWith(false); }); @@ -623,7 +621,7 @@ describe('ShopifyCheckoutSheetKit', () => { await emitGeolocationRequest(); expect( - NativeModules.ShopifyCheckoutSheetKit.initiateGeolocationRequest, + NativeModule.initiateGeolocationRequest, ).not.toHaveBeenCalled(); }); @@ -722,14 +720,14 @@ describe('ShopifyCheckoutSheetKit', () => { beforeEach(() => { Platform.OS = 'ios'; Platform.Version = '17.0'; - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts.mockReset(); - NativeModules.ShopifyCheckoutSheetKit.isAcceleratedCheckoutAvailable.mockReset(); + NativeModule.configureAcceleratedCheckouts.mockReset(); + NativeModule.isAcceleratedCheckoutAvailable.mockReset(); }); describe('configureAcceleratedCheckouts', () => { it('calls native configureAcceleratedCheckouts with correct parameters on iOS', async () => { const instance = new ShopifyCheckoutSheet(); - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts.mockResolvedValue( + NativeModule.configureAcceleratedCheckouts.mockResolvedValue( true, ); @@ -738,7 +736,7 @@ describe('ShopifyCheckoutSheetKit', () => { expect(result).toBe(true); expect( - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts, + NativeModule.configureAcceleratedCheckouts, ).toHaveBeenCalledWith( 'test-shop.myshopify.com', 'shpat_test_token', @@ -757,14 +755,14 @@ describe('ShopifyCheckoutSheetKit', () => { storefrontDomain: 'test-shop.myshopify.com', storefrontAccessToken: 'shpat_test_token', }; - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts.mockResolvedValue( + NativeModule.configureAcceleratedCheckouts.mockResolvedValue( true, ); await instance.configureAcceleratedCheckouts(minimalConfig); expect( - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts, + NativeModule.configureAcceleratedCheckouts, ).toHaveBeenCalledWith( 'test-shop.myshopify.com', 'shpat_test_token', @@ -786,7 +784,7 @@ describe('ShopifyCheckoutSheetKit', () => { expect(result).toBe(false); expect( - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts, + NativeModule.configureAcceleratedCheckouts, ).not.toHaveBeenCalled(); }); @@ -881,7 +879,7 @@ describe('ShopifyCheckoutSheetKit', () => { storefrontDomain: 'test-shop.myshopify.com', storefrontAccessToken: 'shpat_test_token', }; - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts.mockResolvedValue( + NativeModule.configureAcceleratedCheckouts.mockResolvedValue( true, ); @@ -930,7 +928,7 @@ describe('ShopifyCheckoutSheetKit', () => { }); expect( - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts, + NativeModule.configureAcceleratedCheckouts, ).toHaveBeenCalledWith( 'test-shop.myshopify.com', 'shpat_test_token', @@ -958,7 +956,7 @@ describe('ShopifyCheckoutSheetKit', () => { }); expect( - NativeModules.ShopifyCheckoutSheetKit.configureAcceleratedCheckouts, + NativeModule.configureAcceleratedCheckouts, ).toHaveBeenCalledWith( 'test-shop.myshopify.com', 'shpat_test_token', @@ -975,7 +973,7 @@ describe('ShopifyCheckoutSheetKit', () => { describe('isAcceleratedCheckoutAvailable', () => { it('calls native isAcceleratedCheckoutAvailable on iOS', async () => { const instance = new ShopifyCheckoutSheet(); - NativeModules.ShopifyCheckoutSheetKit.isAcceleratedCheckoutAvailable.mockResolvedValue( + NativeModule.isAcceleratedCheckoutAvailable.mockResolvedValue( true, ); @@ -983,7 +981,7 @@ describe('ShopifyCheckoutSheetKit', () => { expect(result).toBe(true); expect( - NativeModules.ShopifyCheckoutSheetKit.isAcceleratedCheckoutAvailable, + NativeModule.isAcceleratedCheckoutAvailable, ).toHaveBeenCalledTimes(1); }); @@ -995,7 +993,7 @@ describe('ShopifyCheckoutSheetKit', () => { expect(result).toBe(false); expect( - NativeModules.ShopifyCheckoutSheetKit.isAcceleratedCheckoutAvailable, + NativeModule.isAcceleratedCheckoutAvailable, ).not.toHaveBeenCalled(); }); }); From c99a63816c7d6ea05b529786500e568d834a5d56 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Fri, 17 Apr 2026 09:54:35 +0100 Subject: [PATCH 12/12] fix(lint): use top-level codegenNativeComponent import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the deprecated deep import `react-native/Libraries/Utilities/codegenNativeComponent` with the top-level named import now exported from `react-native`. The `react-native/Libraries/Types/CodegenTypes` import is preserved because codegen's AST parser matches those type names statically — it can't follow namespace or alias indirection. Suppressed the lint warning on that one line with a note explaining why. Also simplifies the jest setup: `codegenNativeComponent` is now mocked alongside the rest of `react-native` in `__mocks__/react-native.ts`, so the separate `__mocks__/codegenNativeComponent.ts` file and its `moduleNameMapper` entry in `jest.config.js` are no longer needed. Co-Authored-By: Claude Opus 4.6 (1M context) --- __mocks__/codegenNativeComponent.ts | 11 ----------- __mocks__/react-native.ts | 3 +++ jest.config.js | 4 ---- .../src/components/AcceleratedCheckoutButtons.tsx | 3 +-- .../RCTAcceleratedCheckoutButtonsNativeComponent.ts | 4 ++-- 5 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 __mocks__/codegenNativeComponent.ts diff --git a/__mocks__/codegenNativeComponent.ts b/__mocks__/codegenNativeComponent.ts deleted file mode 100644 index 56bc43de..00000000 --- a/__mocks__/codegenNativeComponent.ts +++ /dev/null @@ -1,11 +0,0 @@ -const React = require('react'); - -const codegenNativeComponent = (_name: string) => { - return (props: any) => - React.createElement('View', { - ...props, - testID: props?.testID ?? 'accelerated-checkout-buttons', - }); -}; - -export default codegenNativeComponent; diff --git a/__mocks__/react-native.ts b/__mocks__/react-native.ts index 6dd8d395..69210799 100644 --- a/__mocks__/react-native.ts +++ b/__mocks__/react-native.ts @@ -39,6 +39,8 @@ const requireNativeComponent = (..._args: any[]) => { }); }; +const codegenNativeComponent = requireNativeComponent; + const StyleSheet = { flatten: jest.fn(style => style), }; @@ -71,6 +73,7 @@ module.exports = { }, NativeEventEmitter: jest.fn(() => createMockEmitter()), requireNativeComponent, + codegenNativeComponent, TurboModuleRegistry: { getEnforcing: jest.fn((name: string) => { if (name === 'ShopifyCheckoutSheetKit') { diff --git a/jest.config.js b/jest.config.js index d43f8497..6763de59 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,10 +3,6 @@ module.exports = { modulePathIgnorePatterns: ['modules/@shopify/checkout-sheet-kit/lib'], modulePaths: ['/sample/node_modules'], setupFiles: ['/jest.setup.ts'], - moduleNameMapper: { - 'react-native/Libraries/Utilities/codegenNativeComponent': - '/__mocks__/codegenNativeComponent.ts', - }, transform: { '\\.[jt]sx?$': 'babel-jest', }, diff --git a/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx b/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx index b4972610..c52ad100 100644 --- a/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx +++ b/modules/@shopify/checkout-sheet-kit/src/components/AcceleratedCheckoutButtons.tsx @@ -22,9 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO */ import React, {useCallback, useMemo, useState} from 'react'; -import {Platform} from 'react-native'; +import {codegenNativeComponent, Platform} from 'react-native'; import type {ViewStyle} from 'react-native'; -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import type { AcceleratedCheckoutWallet, CheckoutCompletedEvent, diff --git a/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts index b5d62ff8..9af49d0d 100644 --- a/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts +++ b/modules/@shopify/checkout-sheet-kit/src/specs/RCTAcceleratedCheckoutButtonsNativeComponent.ts @@ -21,13 +21,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import type {ViewProps} from 'react-native'; -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; +import {codegenNativeComponent, type ViewProps} from 'react-native'; import type { BubblingEventHandler, DirectEventHandler, Double, Float, + // eslint-disable-next-line @react-native/no-deep-imports -- codegen parser requires these type names to be imported directly (not via aliases) so it can match them statically during AST traversal } from 'react-native/Libraries/Types/CodegenTypes'; type FailEvent = Readonly<{