react-native-tvos 0.72.4-0rc1 → 0.72.6-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/Libraries/Core/ReactNativeVersion.js +2 -2
  2. package/Libraries/vendor/emitter/EventEmitter.js +3 -1
  3. package/README-core.md +147 -0
  4. package/README.md +4 -3
  5. package/React/Base/RCTBundleURLProvider.h +33 -2
  6. package/React/Base/RCTBundleURLProvider.mm +78 -15
  7. package/React/Base/RCTVersion.m +2 -2
  8. package/React/CoreModules/RCTTiming.mm +5 -0
  9. package/ReactAndroid/gradle.properties +1 -1
  10. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +2 -2
  11. package/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java +5 -0
  12. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java +4 -0
  13. package/ReactAndroid/src/main/jni/CMakeLists.txt +5 -0
  14. package/ReactCommon/React-Fabric.podspec +1 -1
  15. package/ReactCommon/ReactCommon.podspec +1 -1
  16. package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
  17. package/ReactCommon/jsc/JSCRuntime.cpp +10 -0
  18. package/ReactCommon/react/debug/React-debug.podspec +1 -1
  19. package/ReactCommon/react/nativemodule/core/platform/ios/React-NativeModulesApple.podspec +1 -1
  20. package/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec +1 -1
  21. package/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp +2 -0
  22. package/ReactCommon/react/renderer/core/RawPropsParser.cpp +1 -0
  23. package/ReactCommon/react/renderer/core/RawPropsPrimitives.h +4 -4
  24. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
  25. package/ReactCommon/react/renderer/imagemanager/platform/ios/React-ImageManager.podspec +1 -1
  26. package/ReactCommon/react/renderer/runtimescheduler/React-runtimescheduler.podspec +1 -1
  27. package/ReactCommon/react/utils/React-utils.podspec +1 -1
  28. package/package.json +8 -7
  29. package/scripts/cocoapods/helpers.rb +16 -0
  30. package/scripts/cocoapods/utils.rb +104 -8
  31. package/scripts/react_native_pods.rb +6 -2
  32. package/sdks/hermes-engine/utils/build-apple-framework.sh +8 -1
  33. package/sdks/hermes-engine/utils/build-hermes-xcode.sh +8 -0
  34. package/sdks/hermesc/linux64-bin/hermesc +0 -0
  35. package/sdks/hermesc/osx-bin/hermesc +0 -0
  36. package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
  37. package/template/Gemfile +2 -1
  38. package/template/ios/HelloWorld.xcodeproj/project.pbxproj +95 -13
  39. package/template/package.json +2 -2
  40. package/types/index.d.ts +1 -0
  41. package/types/public/ReactNativeTVTypes.d.ts +192 -0
  42. package/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java +0 -98
  43. package/scripts/cocoapods/__tests__/codegen-test.rb +0 -242
  44. package/scripts/cocoapods/__tests__/codegen_utils-test.rb +0 -602
  45. package/scripts/cocoapods/__tests__/fabric-test.rb +0 -68
  46. package/scripts/cocoapods/__tests__/flipper-test.rb +0 -161
  47. package/scripts/cocoapods/__tests__/jsengine-test.rb +0 -130
  48. package/scripts/cocoapods/__tests__/local_podspec_patch-test.rb +0 -167
  49. package/scripts/cocoapods/__tests__/new_architecture-test.rb +0 -303
  50. package/scripts/cocoapods/__tests__/test_utils/CodegenScriptPhaseExtractorMock.rb +0 -21
  51. package/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb +0 -108
  52. package/scripts/cocoapods/__tests__/test_utils/DirMock.rb +0 -72
  53. package/scripts/cocoapods/__tests__/test_utils/EnvironmentMock.rb +0 -21
  54. package/scripts/cocoapods/__tests__/test_utils/FileMock.rb +0 -113
  55. package/scripts/cocoapods/__tests__/test_utils/FileUtilsMock.rb +0 -40
  56. package/scripts/cocoapods/__tests__/test_utils/FinderMock.rb +0 -28
  57. package/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb +0 -222
  58. package/scripts/cocoapods/__tests__/test_utils/LocalPodspecPatchMock.rb +0 -14
  59. package/scripts/cocoapods/__tests__/test_utils/Open3Mock.rb +0 -43
  60. package/scripts/cocoapods/__tests__/test_utils/PathnameMock.rb +0 -42
  61. package/scripts/cocoapods/__tests__/test_utils/PodMock.rb +0 -144
  62. package/scripts/cocoapods/__tests__/test_utils/SpecMock.rb +0 -30
  63. package/scripts/cocoapods/__tests__/test_utils/SysctlCheckerMock.rb +0 -21
  64. package/scripts/cocoapods/__tests__/test_utils/TargetDefinitionMock.rb +0 -12
  65. package/scripts/cocoapods/__tests__/test_utils/podSpy.rb +0 -39
  66. package/scripts/cocoapods/__tests__/test_utils/systemUtils.rb +0 -14
  67. package/scripts/cocoapods/__tests__/utils-test.rb +0 -766
  68. package/scripts/codegen/__test_fixtures__/fixtures.js +0 -132
  69. package/scripts/codegen/__tests__/generate-artifacts-executor-test.js +0 -500
  70. package/scripts/codegen/__tests__/generate-specs-cli-executor-test.js +0 -88
@@ -0,0 +1,192 @@
1
+ import React from 'react';
2
+ import { ViewProps, ScrollViewProps } from 'react-native';
3
+
4
+ declare module 'react-native' {
5
+ interface ViewProps {
6
+ /**
7
+ * TV next focus down (see documentation for the View component).
8
+ */
9
+ nextFocusDown?: number,
10
+
11
+ /**
12
+ * TV next focus forward (see documentation for the View component).
13
+ *
14
+ * @platform android
15
+ */
16
+ nextFocusForward?: number,
17
+
18
+ /**
19
+ * TV next focus left (see documentation for the View component).
20
+ */
21
+ nextFocusLeft?: number,
22
+
23
+ /**
24
+ * TV next focus right (see documentation for the View component).
25
+ */
26
+ nextFocusRight?: number,
27
+
28
+ /**
29
+ * TV next focus up (see documentation for the View component).
30
+ */
31
+ nextFocusUp?: number,
32
+ }
33
+
34
+ export interface NativeMethods {
35
+ requestTVFocus(): void;
36
+ }
37
+
38
+ export const useTVEventHandler: (handleEvent: (event: HWEvent) => void) => void;
39
+
40
+ export const TVEventControl: {
41
+ enableTVMenuKey(): void;
42
+ disableTVMenuKey(): void;
43
+ enableTVPanGesture(): void;
44
+ disableTVPanGesture(): void;
45
+ enableGestureHandlersCancelTouches(): void;
46
+ disableGestureHandlersCancelTouches(): void;
47
+ };
48
+
49
+ export type HWEvent = {
50
+ eventType: 'up' | 'down' | 'right' | 'left' | 'longUp' | 'longDown' | 'longRight' | 'longLeft' | 'blur' | 'focus' | 'pan' | string;
51
+ eventKeyAction?: -1 | 1 | 0 | number;
52
+ tag?: number;
53
+ body?: {
54
+ state: "Began" | "Changed" | "Ended",
55
+ x: number,
56
+ y: number,
57
+ velocityx: number,
58
+ velocityy: number
59
+ }
60
+ };
61
+
62
+ export class TVEventHandler {
63
+ enable<T extends React.Component<unknown>>(
64
+ component?: T,
65
+ callback?: (component: T, data: HWEvent) => void
66
+ ): void;
67
+ disable(): void;
68
+ }
69
+
70
+ export interface FocusGuideProps extends ViewProps {
71
+ /**
72
+ * If the view should be "visible". display "flex" if visible, otherwise "none".
73
+ * Defaults to true
74
+ */
75
+ enabled?: boolean;
76
+ /**
77
+ * Array of `Component`s to register as destinations with `UIFocusGuide`
78
+ */
79
+ destinations?: (null | number | React.Component<any, any> | React.ComponentClass<any>)[];
80
+ /**
81
+ * If true, `TVFocusGuide` will automatically manage focus for you.
82
+ * It will redirect the focus to the first focusable child on the first visit.
83
+ * It also remembers the last focused child and redirects the focus
84
+ * to it on the subsequent visits.
85
+ *
86
+ * `destinations` prop takes precedence over this prop when used together.
87
+ *
88
+ * @default false
89
+ */
90
+ autoFocus?: boolean;
91
+ /**
92
+ * Enables focus trapping for the focus guide (see README).
93
+ */
94
+ trapFocusUp?: boolean;
95
+ /**
96
+ * Enables focus trapping for the focus guide (see README).
97
+ */
98
+ trapFocusDown?: boolean;
99
+ /**
100
+ * Enables focus trapping for the focus guide (see README).
101
+ */
102
+ trapFocusLeft?: boolean;
103
+ /**
104
+ * Enables focus trapping for the focus guide (see README).
105
+ */
106
+ trapFocusRight?: boolean;
107
+ /**
108
+ * @deprecated Don't use it, no longer necessary.
109
+ */
110
+ safePadding?: 'both' | 'vertical' | 'horizontal' | null;
111
+ }
112
+
113
+ export type FocusGuideMethods = {
114
+ setDestinations: (
115
+ destinations: (React.ElementRef<HostComponent<unknown>> | null | undefined)[],
116
+ ) => void;
117
+ }
118
+
119
+ /**
120
+ * This component provides support for Apple's `UIFocusGuide` API,
121
+ * to help ensure that focusable controls can be navigated to,
122
+ * even if they are not directly in line with other controls on both tvOS and Android.
123
+ * An example is provided in `RNTester` that shows different ways of using this component.
124
+ * https://github.com/react-native-tvos/react-native-tvos/blob/tvos-v0.69.8/packages/rn-tester/js/examples/TVFocusGuide/TVFocusGuideAutoFocusExample.js
125
+ */
126
+ export const TVFocusGuideView: React.ForwardRefExoticComponent<FocusGuideProps & React.RefAttributes<View & FocusGuideMethods>>;
127
+ export interface TVTextScrollViewProps extends ScrollViewProps {
128
+ /**
129
+ * The duration of the scroll animation when a swipe is detected.
130
+ * Default value is 0.3 s
131
+ */
132
+ scrollDuration?: number;
133
+ /**
134
+ * Scrolling distance when a swipe is detected
135
+ * Default value is half the visible height (vertical scroller)
136
+ * or width (horizontal scroller)
137
+ */
138
+ pageSize?: number;
139
+ /**
140
+ * If true, will scroll to start when focus moves out past the beginning
141
+ * of the scroller
142
+ * Defaults to true
143
+ */
144
+ snapToStart?: boolean;
145
+ /**
146
+ * If true, will scroll to end when focus moves out past the end of the
147
+ * scroller
148
+ * Defaults to true
149
+ */
150
+ snapToEnd?: boolean;
151
+ /**
152
+ * Called when the scroller comes into focus (e.g. for highlighting)
153
+ */
154
+ onFocus?(evt: HWEvent): void;
155
+ /**
156
+ * Called when the scroller goes out of focus
157
+ */
158
+ onBlur?(evt: HWEvent): void;
159
+ }
160
+
161
+ export class TVTextScrollView extends React.Component<TVTextScrollViewProps> {}
162
+
163
+ export interface PressableStateCallbackType {
164
+ readonly focused: boolean;
165
+ }
166
+
167
+ export interface TouchableWithoutFeedbackPropsIOS {
168
+ /**
169
+ * *(Apple TV only)* TV preferred focus (see documentation for the View component).
170
+ *
171
+ * @platform ios
172
+ */
173
+ hasTVPreferredFocus?: boolean;
174
+
175
+ /**
176
+ * *(Apple TV only)* Object with properties to control Apple TV parallax effects.
177
+ *
178
+ * enabled: If true, parallax effects are enabled. Defaults to true.
179
+ * shiftDistanceX: Defaults to 2.0.
180
+ * shiftDistanceY: Defaults to 2.0.
181
+ * tiltAngle: Defaults to 0.05.
182
+ * magnification: Defaults to 1.0.
183
+ * pressMagnification: Defaults to 1.0.
184
+ * pressDuration: Defaults to 0.3.
185
+ * pressDelay: Defaults to 0.0.
186
+ *
187
+ * @platform ios
188
+ */
189
+ tvParallaxProperties?: TVParallaxProperties;
190
+ }
191
+
192
+ }
@@ -1,98 +0,0 @@
1
- /*
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- package com.facebook.react;
9
-
10
- import android.view.KeyEvent;
11
- import android.view.View;
12
- import com.facebook.react.bridge.WritableMap;
13
- import com.facebook.react.bridge.WritableNativeMap;
14
- import com.facebook.react.common.MapBuilder;
15
- import java.util.Map;
16
-
17
- /** Responsible for dispatching events specific for hardware inputs. */
18
- public class ReactAndroidHWInputDeviceHelper {
19
-
20
- /**
21
- * Contains a mapping between handled KeyEvents and the corresponding navigation event that should
22
- * be fired when the KeyEvent is received.
23
- */
24
- private static final Map<Integer, String> KEY_EVENTS_ACTIONS =
25
- MapBuilder.<Integer, String>builder()
26
- .put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
27
- .put(KeyEvent.KEYCODE_ENTER, "select")
28
- .put(KeyEvent.KEYCODE_SPACE, "select")
29
- .put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause")
30
- .put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind")
31
- .put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward")
32
- .put(KeyEvent.KEYCODE_MEDIA_STOP, "stop")
33
- .put(KeyEvent.KEYCODE_MEDIA_NEXT, "next")
34
- .put(KeyEvent.KEYCODE_MEDIA_PREVIOUS, "previous")
35
- .put(KeyEvent.KEYCODE_DPAD_UP, "up")
36
- .put(KeyEvent.KEYCODE_DPAD_RIGHT, "right")
37
- .put(KeyEvent.KEYCODE_DPAD_DOWN, "down")
38
- .put(KeyEvent.KEYCODE_DPAD_LEFT, "left")
39
- .put(KeyEvent.KEYCODE_INFO, "info")
40
- .put(KeyEvent.KEYCODE_MENU, "menu")
41
- .build();
42
-
43
- /**
44
- * We keep a reference to the last focused view id so that we can send it as a target for key
45
- * events and be able to send a blur event when focus changes.
46
- */
47
- private int mLastFocusedViewId = View.NO_ID;
48
-
49
- private final ReactRootView mReactRootView;
50
-
51
- ReactAndroidHWInputDeviceHelper(ReactRootView mReactRootView) {
52
- this.mReactRootView = mReactRootView;
53
- }
54
-
55
- /** Called from {@link ReactRootView}. This is the main place the key events are handled. */
56
- public void handleKeyEvent(KeyEvent ev) {
57
- int eventKeyCode = ev.getKeyCode();
58
- int eventKeyAction = ev.getAction();
59
- if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN)
60
- && KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
61
- dispatchEvent(KEY_EVENTS_ACTIONS.get(eventKeyCode), mLastFocusedViewId, eventKeyAction);
62
- }
63
- }
64
-
65
- /** Called from {@link ReactRootView} when focused view changes. */
66
- public void onFocusChanged(View newFocusedView) {
67
- if (mLastFocusedViewId == newFocusedView.getId()) {
68
- return;
69
- }
70
- if (mLastFocusedViewId != View.NO_ID) {
71
- dispatchEvent("blur", mLastFocusedViewId);
72
- }
73
- mLastFocusedViewId = newFocusedView.getId();
74
- dispatchEvent("focus", newFocusedView.getId());
75
- }
76
-
77
- /** Called from {@link ReactRootView} when the whole view hierarchy looses focus. */
78
- public void clearFocus() {
79
- if (mLastFocusedViewId != View.NO_ID) {
80
- dispatchEvent("blur", mLastFocusedViewId);
81
- }
82
- mLastFocusedViewId = View.NO_ID;
83
- }
84
-
85
- private void dispatchEvent(String eventType, int targetViewId) {
86
- dispatchEvent(eventType, targetViewId, -1);
87
- }
88
-
89
- private void dispatchEvent(String eventType, int targetViewId, int eventKeyAction) {
90
- WritableMap event = new WritableNativeMap();
91
- event.putString("eventType", eventType);
92
- event.putInt("eventKeyAction", eventKeyAction);
93
- if (targetViewId != View.NO_ID) {
94
- event.putInt("tag", targetViewId);
95
- }
96
- mReactRootView.sendEvent("onHWKeyEvent", event);
97
- }
98
- }
@@ -1,242 +0,0 @@
1
- # Copyright (c) Meta Platforms, Inc. and affiliates.
2
- #
3
- # This source code is licensed under the MIT license found in the
4
- # LICENSE file in the root directory of this source tree.
5
-
6
- require "test/unit"
7
- require_relative "../codegen.rb"
8
- require_relative "./test_utils/PodMock.rb"
9
- require_relative "./test_utils/PathnameMock.rb"
10
- require_relative "./test_utils/FileMock.rb"
11
- require_relative "./test_utils/DirMock.rb"
12
- require_relative "./test_utils/systemUtils.rb"
13
- require_relative "./test_utils/CodegenUtilsMock.rb"
14
-
15
- class CodegenTests < Test::Unit::TestCase
16
- :third_party_provider_header
17
- :third_party_provider_implementation
18
- :base_path
19
- :prefix
20
- :tmp_schema_list_file
21
-
22
- def setup
23
- Pod::Config.reset()
24
-
25
- @prefix = "../.."
26
- @third_party_provider_header = "RCTThirdPartyFabricComponentsProvider.h"
27
- @third_party_provider_implementation = "RCTThirdPartyFabricComponentsProvider.mm"
28
- @base_path = "~/app/ios"
29
- @tmp_schema_list_file = "tmpSchemaList.txt"
30
- Pathname.pwd!(@base_path)
31
- Pod::Config.instance.installation_root.relative_path_from = @base_path
32
- end
33
-
34
- def teardown
35
- system_reset_commands()
36
- Pod::UI.reset()
37
- Pod::Executable.reset()
38
- Pathname.reset()
39
- FileMock.reset()
40
- DirMock.reset()
41
- end
42
-
43
- # ============================================== #
44
- # Test - setup_fabric #
45
- # ============================================== #
46
- def testCheckAndGenerateEmptyThirdPartyProvider_whenFileAlreadyExists_doNothing()
47
-
48
- # Arrange
49
- FileMock.mocked_existing_files([
50
- @prefix + "/React/Fabric/" + @third_party_provider_header,
51
- @prefix + "/React/Fabric/" + @third_party_provider_implementation,
52
- ])
53
-
54
- # Act
55
- checkAndGenerateEmptyThirdPartyProvider!(@prefix, false, dir_manager: DirMock, file_manager: FileMock)
56
-
57
- # Assert
58
- assert_equal(Pathname.pwd_invocation_count, 1)
59
- assert_equal(Pod::Config.instance.installation_root.relative_path_from_invocation_count, 1)
60
- assert_equal(FileMock.exist_invocation_params, [
61
- @prefix + "/React/Fabric/" + @third_party_provider_header,
62
- @prefix + "/React/Fabric/" + @third_party_provider_implementation,
63
- ])
64
- assert_equal(DirMock.exist_invocation_params, [])
65
- assert_equal(Pod::UI.collected_messages, [])
66
- assert_equal($collected_commands, [])
67
- assert_equal(FileMock.open_files.length, 0)
68
- assert_equal(Pod::Executable.executed_commands.length, 0)
69
- end
70
-
71
- def testCheckAndGenerateEmptyThirdPartyProvider_whenHeaderMissingAndCodegenMissing_raiseError()
72
-
73
- # Arrange
74
- FileMock.mocked_existing_files([
75
- @base_path + "/build/" + @third_party_provider_implementation,
76
- ])
77
-
78
- # Act
79
- assert_raise {
80
- checkAndGenerateEmptyThirdPartyProvider!(@prefix, false, dir_manager: DirMock, file_manager: FileMock)
81
- }
82
-
83
- # Assert
84
- assert_equal(Pathname.pwd_invocation_count, 1)
85
- assert_equal(Pod::Config.instance.installation_root.relative_path_from_invocation_count, 1)
86
- assert_equal(FileMock.exist_invocation_params, [
87
- @prefix + "/React/Fabric/" + @third_party_provider_header
88
- ])
89
- assert_equal(DirMock.exist_invocation_params, [
90
- @base_path + "/"+ @prefix + "/../react-native-codegen",
91
- @base_path + "/"+ @prefix + "/../@react-native/codegen",
92
- ])
93
- assert_equal(Pod::UI.collected_messages, [])
94
- assert_equal($collected_commands, [])
95
- assert_equal(FileMock.open_files.length, 0)
96
- assert_equal(Pod::Executable.executed_commands.length, 0)
97
- end
98
-
99
- def testCheckAndGenerateEmptyThirdPartyProvider_whenImplementationMissingAndCodegenrepoExists_dontBuildCodegen()
100
-
101
- # Arrange
102
- FileMock.mocked_existing_files([
103
- @prefix + "/React/Fabric/" + @third_party_provider_header,
104
- @prefix + "/React/Fabric/tmpSchemaList.txt"
105
- ])
106
-
107
- DirMock.mocked_existing_dirs([
108
- @base_path + "/"+ @prefix + "/../react-native-codegen",
109
- @base_path + "/"+ @prefix + "/../react-native-codegen/lib"
110
- ])
111
-
112
- # Act
113
- checkAndGenerateEmptyThirdPartyProvider!(@prefix, false, dir_manager: DirMock, file_manager: FileMock)
114
-
115
- # Assert
116
- assert_equal(Pathname.pwd_invocation_count, 1)
117
- assert_equal(Pod::Config.instance.installation_root.relative_path_from_invocation_count, 1)
118
- assert_equal(FileMock.exist_invocation_params, [
119
- @prefix + "/React/Fabric/" + @third_party_provider_header,
120
- @prefix + "/React/Fabric/" + @third_party_provider_implementation,
121
- @prefix + "/React/Fabric/tmpSchemaList.txt",
122
- ])
123
- assert_equal(DirMock.exist_invocation_params, [
124
- @base_path + "/"+ @prefix + "/../react-native-codegen",
125
- @base_path + "/"+ @prefix + "/../react-native-codegen/lib",
126
- ])
127
- assert_equal(Pod::UI.collected_messages, ["[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider"])
128
- assert_equal($collected_commands, [])
129
- assert_equal(FileMock.open_invocation_count, 1)
130
- assert_equal(FileMock.open_files_with_mode[@prefix + "/React/Fabric/tmpSchemaList.txt"], 'w')
131
- assert_equal(FileMock.open_files[0].collected_write, ["[]"])
132
- assert_equal(FileMock.open_files[0].fsync_invocation_count, 1)
133
- assert_equal(Pod::Executable.executed_commands[0], {
134
- "command" => "node",
135
- "arguments" => [
136
- @base_path + "/" + @prefix + "/scripts/generate-provider-cli.js",
137
- "--platform", 'ios',
138
- "--schemaListPath", @prefix + "/React/Fabric/tmpSchemaList.txt",
139
- "--outputDir", @prefix + "/React/Fabric"
140
- ]
141
- })
142
- assert_equal(FileMock.delete_invocation_count, 1)
143
- assert_equal(FileMock.deleted_files, [ @prefix + "/React/Fabric/tmpSchemaList.txt"])
144
- end
145
-
146
- def testCheckAndGenerateEmptyThirdPartyProvider_whenBothMissing_buildCodegen()
147
- # Arrange
148
- codegen_cli_path = @base_path + "/" + @prefix + "/../@react-native/codegen"
149
- DirMock.mocked_existing_dirs([
150
- codegen_cli_path,
151
- ])
152
- # Act
153
- checkAndGenerateEmptyThirdPartyProvider!(@prefix, false, dir_manager: DirMock, file_manager: FileMock)
154
-
155
- # Assert
156
- assert_equal(Pathname.pwd_invocation_count, 1)
157
- assert_equal(Pod::Config.instance.installation_root.relative_path_from_invocation_count, 1)
158
- assert_equal(FileMock.exist_invocation_params, [
159
- @prefix + "/React/Fabric/" + @third_party_provider_header,
160
- @prefix + "/React/Fabric/" + @tmp_schema_list_file
161
- ])
162
- assert_equal(DirMock.exist_invocation_params, [
163
- @base_path + "/" + @prefix + "/../react-native-codegen",
164
- codegen_cli_path,
165
- codegen_cli_path + "/lib",
166
- ])
167
- assert_equal(Pod::UI.collected_messages, [
168
- "[Codegen] building #{codegen_cli_path}.",
169
- "[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider"
170
- ])
171
- assert_equal($collected_commands, ["~/app/ios/../../../@react-native/codegen/scripts/oss/build.sh"])
172
- assert_equal(FileMock.open_files[0].collected_write, ["[]"])
173
- assert_equal(FileMock.open_files[0].fsync_invocation_count, 1)
174
- assert_equal(Pod::Executable.executed_commands[0], {
175
- "command" => "node",
176
- "arguments" => [
177
- @base_path + "/" + @prefix + "/scripts/generate-provider-cli.js",
178
- "--platform", 'ios',
179
- "--schemaListPath", @prefix + "/React/Fabric/" + @tmp_schema_list_file,
180
- "--outputDir", @prefix + "/React/Fabric"
181
- ]
182
- })
183
- end
184
-
185
- # ================= #
186
- # Test - RunCodegen #
187
- # ================= #
188
- def testRunCodegen_whenNewArchEnabled_runsCodegen
189
- # Arrange
190
- app_path = "~/app"
191
- config_file = ""
192
- codegen_utils_mock = CodegenUtilsMock.new()
193
-
194
- # Act
195
- run_codegen!(app_path, config_file, :new_arch_enabled => true, :codegen_utils => codegen_utils_mock)
196
-
197
- # Assert
198
- assert_equal(codegen_utils_mock.use_react_native_codegen_discovery_params, [{
199
- :app_path=>"~/app",
200
- :codegen_disabled=>false,
201
- :codegen_output_dir=>"build/generated/ios",
202
- :config_file_dir=>"",
203
- :fabric_enabled=>false,
204
- :folly_version=>"2021.07.22.00",
205
- :react_native_path=>"../node_modules/react-native"
206
- }])
207
- assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [])
208
- assert_equal(codegen_utils_mock.generate_react_codegen_spec_params, [])
209
- end
210
-
211
- def testRunCodegen_whenNewArchDisabled_runsCodegen
212
- # Arrange
213
- app_path = "~/app"
214
- config_file = ""
215
- package_json_file = "~/app/package.json"
216
- codegen_specs = { "name" => "React-Codegen" }
217
- codegen_utils_mock = CodegenUtilsMock.new(:react_codegen_spec => codegen_specs)
218
-
219
- # Act
220
- run_codegen!(
221
- app_path,
222
- config_file,
223
- :new_arch_enabled => false,
224
- :fabric_enabled => true,
225
- :package_json_file => package_json_file,
226
- :codegen_utils => codegen_utils_mock)
227
-
228
- # Assert
229
- assert_equal(codegen_utils_mock.use_react_native_codegen_discovery_params, [])
230
- assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [{
231
- :fabric_enabled => true,
232
- :folly_version=>"2021.07.22.00",
233
- :package_json_file => "~/app/package.json",
234
- :script_phases => nil
235
- }])
236
- assert_equal(codegen_utils_mock.generate_react_codegen_spec_params, [{
237
- :codegen_output_dir=>"build/generated/ios",
238
- :react_codegen_spec=>{"name"=>"React-Codegen"}
239
- }])
240
-
241
- end
242
- end