react-native-tvos 0.72.4-0rc0 → 0.72.5-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.
- package/Libraries/Components/Pressable/Pressable.js +11 -5
- package/Libraries/Components/ScrollView/ScrollView.d.ts +7 -0
- package/Libraries/Components/ScrollView/ScrollView.js +8 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +1 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +1 -0
- package/Libraries/Components/ScrollView/ScrollViewViewConfig.js +1 -0
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/README-core.md +147 -0
- package/README.md +32 -39
- package/React/Base/RCTBundleURLProvider.h +33 -2
- package/React/Base/RCTBundleURLProvider.mm +78 -15
- package/React/Base/RCTVersion.m +2 -2
- package/React/CoreModules/RCTTiming.mm +5 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +4 -0
- package/React/Fabric/RCTThirdPartyFabricComponentsProvider.h +29 -0
- package/React/Fabric/RCTThirdPartyFabricComponentsProvider.mm +29 -0
- package/React/Views/ScrollView/RCTScrollView.h +1 -0
- package/React/Views/ScrollView/RCTScrollView.m +12 -0
- package/React/Views/ScrollView/RCTScrollViewManager.m +1 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/hermes-engine/build.gradle +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java +4 -0
- package/ReactAndroid/src/main/jni/CMakeLists.txt +5 -0
- package/ReactCommon/React-Fabric.podspec +1 -1
- package/ReactCommon/ReactCommon.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/jsc/JSCRuntime.cpp +10 -0
- package/ReactCommon/react/debug/React-debug.podspec +1 -1
- package/ReactCommon/react/nativemodule/core/platform/ios/React-NativeModulesApple.podspec +1 -1
- package/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec +1 -1
- package/ReactCommon/react/renderer/components/rncore/ComponentDescriptors.h +29 -0
- package/ReactCommon/react/renderer/components/rncore/EventEmitters.cpp +111 -0
- package/ReactCommon/react/renderer/components/rncore/EventEmitters.h +186 -0
- package/ReactCommon/react/renderer/components/rncore/Props.cpp +157 -0
- package/ReactCommon/react/renderer/components/rncore/Props.h +395 -0
- package/ReactCommon/react/renderer/components/rncore/RCTComponentViewHelpers.h +257 -0
- package/ReactCommon/react/renderer/components/rncore/ShadowNodes.cpp +26 -0
- package/ReactCommon/react/renderer/components/rncore/ShadowNodes.h +111 -0
- package/ReactCommon/react/renderer/components/rncore/States.cpp +18 -0
- package/ReactCommon/react/renderer/components/rncore/States.h +141 -0
- package/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.cpp +15 -1
- package/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.h +1 -0
- package/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp +2 -0
- package/ReactCommon/react/renderer/core/RawPropsParser.cpp +1 -0
- package/ReactCommon/react/renderer/core/RawPropsPrimitives.h +4 -4
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
- package/ReactCommon/react/renderer/imagemanager/platform/ios/React-ImageManager.podspec +1 -1
- package/ReactCommon/react/renderer/runtimescheduler/React-runtimescheduler.podspec +1 -1
- package/ReactCommon/react/utils/React-utils.podspec +1 -1
- package/package.json +7 -6
- package/scripts/cocoapods/helpers.rb +16 -0
- package/scripts/cocoapods/utils.rb +98 -8
- package/scripts/react_native_pods.rb +6 -2
- package/sdks/.hermesversion +1 -1
- package/sdks/hermes-engine/utils/build-apple-framework.sh +8 -1
- package/sdks/hermes-engine/utils/build-hermes-xcode.sh +8 -0
- package/sdks/hermesc/osx-bin/hermesc +0 -0
- package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
- package/template/ios/HelloWorld.xcodeproj/project.pbxproj +95 -13
- package/template/package.json +5 -4
- package/types/index.d.ts +1 -0
- package/types/public/ReactNativeTVTypes.d.ts +192 -0
- package/scripts/cocoapods/__tests__/codegen-test.rb +0 -242
- package/scripts/cocoapods/__tests__/codegen_utils-test.rb +0 -602
- package/scripts/cocoapods/__tests__/fabric-test.rb +0 -68
- package/scripts/cocoapods/__tests__/flipper-test.rb +0 -161
- package/scripts/cocoapods/__tests__/jsengine-test.rb +0 -130
- package/scripts/cocoapods/__tests__/local_podspec_patch-test.rb +0 -167
- package/scripts/cocoapods/__tests__/new_architecture-test.rb +0 -303
- package/scripts/cocoapods/__tests__/test_utils/CodegenScriptPhaseExtractorMock.rb +0 -21
- package/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb +0 -108
- package/scripts/cocoapods/__tests__/test_utils/DirMock.rb +0 -72
- package/scripts/cocoapods/__tests__/test_utils/EnvironmentMock.rb +0 -21
- package/scripts/cocoapods/__tests__/test_utils/FileMock.rb +0 -113
- package/scripts/cocoapods/__tests__/test_utils/FileUtilsMock.rb +0 -40
- package/scripts/cocoapods/__tests__/test_utils/FinderMock.rb +0 -28
- package/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb +0 -222
- package/scripts/cocoapods/__tests__/test_utils/LocalPodspecPatchMock.rb +0 -14
- package/scripts/cocoapods/__tests__/test_utils/Open3Mock.rb +0 -43
- package/scripts/cocoapods/__tests__/test_utils/PathnameMock.rb +0 -42
- package/scripts/cocoapods/__tests__/test_utils/PodMock.rb +0 -144
- package/scripts/cocoapods/__tests__/test_utils/SpecMock.rb +0 -30
- package/scripts/cocoapods/__tests__/test_utils/SysctlCheckerMock.rb +0 -21
- package/scripts/cocoapods/__tests__/test_utils/TargetDefinitionMock.rb +0 -12
- package/scripts/cocoapods/__tests__/test_utils/podSpy.rb +0 -39
- package/scripts/cocoapods/__tests__/test_utils/systemUtils.rb +0 -14
- package/scripts/cocoapods/__tests__/utils-test.rb +0 -766
- package/scripts/codegen/__test_fixtures__/fixtures.js +0 -132
- package/scripts/codegen/__tests__/generate-artifacts-executor-test.js +0 -500
- package/scripts/codegen/__tests__/generate-specs-cli-executor-test.js +0 -88
|
@@ -1,602 +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 "json"
|
|
8
|
-
require_relative "../codegen_utils.rb"
|
|
9
|
-
require_relative "./test_utils/FileMock.rb"
|
|
10
|
-
require_relative "./test_utils/DirMock.rb"
|
|
11
|
-
require_relative "./test_utils/PodMock.rb"
|
|
12
|
-
require_relative "./test_utils/PathnameMock.rb"
|
|
13
|
-
require_relative "./test_utils/FinderMock.rb"
|
|
14
|
-
require_relative "./test_utils/CodegenUtilsMock.rb"
|
|
15
|
-
require_relative "./test_utils/CodegenScriptPhaseExtractorMock.rb"
|
|
16
|
-
require_relative "./test_utils/FileUtilsMock.rb"
|
|
17
|
-
|
|
18
|
-
# mocking the min_ios_version_supported function
|
|
19
|
-
# as it is not possible to require the original react_native_pod
|
|
20
|
-
# without incurring in circular deps
|
|
21
|
-
# TODO: move `min_ios_version_supported` to utils.rb
|
|
22
|
-
def min_ios_version_supported
|
|
23
|
-
return '12.4'
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
class CodegenUtilsTests < Test::Unit::TestCase
|
|
27
|
-
:base_path
|
|
28
|
-
|
|
29
|
-
def setup
|
|
30
|
-
CodegenUtils.set_react_codegen_discovery_done(false)
|
|
31
|
-
CodegenUtils.set_react_codegen_podspec_generated(false)
|
|
32
|
-
Pod::Config.reset()
|
|
33
|
-
@base_path = "~/app/ios"
|
|
34
|
-
Pathname.pwd!(@base_path)
|
|
35
|
-
Pod::Config.instance.installation_root.relative_path_from = @base_path
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def teardown
|
|
39
|
-
FileUtils::FileUtilsStorage.reset()
|
|
40
|
-
Finder.reset()
|
|
41
|
-
Pathname.reset()
|
|
42
|
-
Pod::UI.reset()
|
|
43
|
-
Pod::Executable.reset()
|
|
44
|
-
FileMock.reset()
|
|
45
|
-
DirMock.reset()
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# ================================== #
|
|
49
|
-
# Test - GenerateReactCodegenPodspec #
|
|
50
|
-
# ================================== #
|
|
51
|
-
|
|
52
|
-
def testGenerateReactCodegenPodspec_whenItHasBeenAlreadyGenerated_doesNothing
|
|
53
|
-
# Arrange
|
|
54
|
-
spec = { :name => "Test Podspec" }
|
|
55
|
-
codegen_output_dir = "build"
|
|
56
|
-
CodegenUtils.set_react_codegen_podspec_generated(true)
|
|
57
|
-
|
|
58
|
-
# Act
|
|
59
|
-
CodegenUtils.new().generate_react_codegen_podspec!(spec, codegen_output_dir, file_manager: FileMock)
|
|
60
|
-
|
|
61
|
-
# Assert
|
|
62
|
-
assert_equal(Pod::UI.collected_messages, ["[Codegen] Skipping React-Codegen podspec generation."])
|
|
63
|
-
assert_equal(Pathname.pwd_invocation_count, 0)
|
|
64
|
-
assert_equal(Pod::Executable.executed_commands, [])
|
|
65
|
-
assert_equal(Pod::Config.instance.installation_root.relative_path_from_invocation_count, 0)
|
|
66
|
-
assert_true(CodegenUtils.react_codegen_podspec_generated)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def testGenerateReactCodegenPodspec_whenItHasNotBeenAlreadyGenerated_generatesIt
|
|
70
|
-
# Arrange
|
|
71
|
-
spec = { :name => "Test Podspec" }
|
|
72
|
-
codegen_output_dir = "build"
|
|
73
|
-
|
|
74
|
-
# Act
|
|
75
|
-
CodegenUtils.new().generate_react_codegen_podspec!(spec, codegen_output_dir, file_manager: FileMock)
|
|
76
|
-
|
|
77
|
-
# Assert
|
|
78
|
-
assert_equal(Pathname.pwd_invocation_count, 1)
|
|
79
|
-
assert_equal(Pod::Config.instance.installation_root.relative_path_from_invocation_count, 1)
|
|
80
|
-
assert_equal(Pod::Executable.executed_commands, [{ "command" => 'mkdir', "arguments" => ["-p", "~/app/ios/build"]}])
|
|
81
|
-
assert_equal(Pod::UI.collected_messages, ["[Codegen] Generating ~/app/ios/build/React-Codegen.podspec.json"])
|
|
82
|
-
assert_equal(FileMock.open_files_with_mode["~/app/ios/build/React-Codegen.podspec.json"], 'w')
|
|
83
|
-
assert_equal(FileMock.open_files[0].collected_write, ['{"name":"Test Podspec"}'])
|
|
84
|
-
assert_equal(FileMock.open_files[0].fsync_invocation_count, 1)
|
|
85
|
-
|
|
86
|
-
assert_true(CodegenUtils.react_codegen_podspec_generated)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# ========================== #
|
|
90
|
-
# Test - GetReactCodegenSpec #
|
|
91
|
-
# ========================== #
|
|
92
|
-
|
|
93
|
-
def testGetReactCodegenSpec_whenFabricDisabledAndNoScriptPhases_generatesAPodspec
|
|
94
|
-
# Arrange
|
|
95
|
-
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')
|
|
96
|
-
|
|
97
|
-
# Act
|
|
98
|
-
podspec = CodegenUtils.new().get_react_codegen_spec(
|
|
99
|
-
'package.json',
|
|
100
|
-
:fabric_enabled => false,
|
|
101
|
-
:hermes_enabled => true,
|
|
102
|
-
:script_phases => nil,
|
|
103
|
-
:file_manager => FileMock
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
# Assert
|
|
107
|
-
assert_equal(podspec, get_podspec_no_fabric_no_script())
|
|
108
|
-
assert_equal(Pod::UI.collected_messages, [])
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec
|
|
112
|
-
# Arrange
|
|
113
|
-
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')
|
|
114
|
-
|
|
115
|
-
# Act
|
|
116
|
-
podspec = CodegenUtils.new().get_react_codegen_spec(
|
|
117
|
-
'package.json',
|
|
118
|
-
:fabric_enabled => true,
|
|
119
|
-
:hermes_enabled => true,
|
|
120
|
-
:script_phases => "echo Test Script Phase",
|
|
121
|
-
:file_manager => FileMock
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
# Assert
|
|
125
|
-
assert_equal(podspec, get_podspec_fabric_and_script_phases("echo Test Script Phase"))
|
|
126
|
-
assert_equal(Pod::UI.collected_messages, ["[Codegen] Adding script_phases to React-Codegen."])
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def testGetReactCodegenSpec_whenUseFrameworksAndNewArch_generatesAPodspec
|
|
130
|
-
# Arrange
|
|
131
|
-
ENV["USE_FRAMEWORKS"] = "static"
|
|
132
|
-
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')
|
|
133
|
-
|
|
134
|
-
# Act
|
|
135
|
-
podspec = CodegenUtils.new().get_react_codegen_spec(
|
|
136
|
-
'package.json',
|
|
137
|
-
:fabric_enabled => true,
|
|
138
|
-
:hermes_enabled => true,
|
|
139
|
-
:script_phases => nil,
|
|
140
|
-
:file_manager => FileMock
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
# Assert
|
|
144
|
-
assert_equal(podspec, get_podspec_when_use_frameworks())
|
|
145
|
-
assert_equal(Pod::UI.collected_messages, [])
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
# =============================== #
|
|
149
|
-
# Test - GetCodegenConfigFromFile #
|
|
150
|
-
# =============================== #
|
|
151
|
-
|
|
152
|
-
def testGetCodegenConfigFromFile_whenFileDoesNotExists_returnEmpty
|
|
153
|
-
# Arrange
|
|
154
|
-
|
|
155
|
-
# Act
|
|
156
|
-
codegen = CodegenUtils.new().get_codegen_config_from_file('package.json', 'codegenConfig', file_manager: FileMock)
|
|
157
|
-
|
|
158
|
-
# Assert
|
|
159
|
-
assert_equal(codegen, {})
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def testGetCodegenConfigFromFile_whenFileExistsButHasNoKey_returnEmpty
|
|
163
|
-
# Arrange
|
|
164
|
-
FileMock.mocked_existing_files(['package.json'])
|
|
165
|
-
FileMock.files_to_read('package.json' => '{ "codegenConfig": {}}')
|
|
166
|
-
|
|
167
|
-
# Act
|
|
168
|
-
codegen = CodegenUtils.new().get_codegen_config_from_file('package.json', 'codegen', file_manager: FileMock)
|
|
169
|
-
|
|
170
|
-
# Assert
|
|
171
|
-
assert_equal(codegen, {})
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def testGetCodegenConfigFromFile_whenFileExistsAndHasKey_returnObject
|
|
175
|
-
# Arrange
|
|
176
|
-
FileMock.mocked_existing_files(['package.json'])
|
|
177
|
-
FileMock.files_to_read('package.json' => '{ "codegenConfig": {"name": "MySpec"}}')
|
|
178
|
-
|
|
179
|
-
# Act
|
|
180
|
-
codegen = CodegenUtils.new().get_codegen_config_from_file('package.json', 'codegenConfig', file_manager: FileMock )
|
|
181
|
-
|
|
182
|
-
# Assert
|
|
183
|
-
assert_equal(codegen, { "name" => "MySpec"})
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
# ======================= #
|
|
187
|
-
# Test - GetListOfJSSpecs #
|
|
188
|
-
# ======================= #
|
|
189
|
-
def testGetListOfJSSpecs_whenUsesLibraries_returnAListOfFiles
|
|
190
|
-
# Arrange
|
|
191
|
-
app_codegen_config = {
|
|
192
|
-
'libraries' => [
|
|
193
|
-
{
|
|
194
|
-
'name' => 'First Lib',
|
|
195
|
-
'jsSrcsDir' => './firstlib/js'
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
'name' => 'Second Lib',
|
|
199
|
-
'jsSrcsDir' => './secondlib/js'
|
|
200
|
-
},
|
|
201
|
-
]
|
|
202
|
-
}
|
|
203
|
-
app_path = "~/MyApp/"
|
|
204
|
-
Finder.set_files_for_paths({
|
|
205
|
-
'~/MyApp/./firstlib/js' => ["MyFabricComponent1NativeComponent.js", "MyFabricComponent2NativeComponent.js"],
|
|
206
|
-
'~/MyApp/./secondlib/js' => ["NativeModule1.js", "NativeModule2.js"],
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
# Act
|
|
210
|
-
files = CodegenUtils.new().get_list_of_js_specs(app_codegen_config, app_path, file_manager: FileMock)
|
|
211
|
-
|
|
212
|
-
# Assert
|
|
213
|
-
assert_equal(Pod::UI.collected_warns , ["[Deprecated] You are using the old `libraries` array to list all your codegen.\\nThis method will be removed in the future.\\nUpdate your `package.json` with a single object."])
|
|
214
|
-
assert_equal(Finder.captured_paths, ['~/MyApp/./firstlib/js', '~/MyApp/./secondlib/js'])
|
|
215
|
-
assert_equal(files, [
|
|
216
|
-
"${PODS_ROOT}/../MyFabricComponent1NativeComponent.js",
|
|
217
|
-
"${PODS_ROOT}/../MyFabricComponent2NativeComponent.js",
|
|
218
|
-
"${PODS_ROOT}/../NativeModule1.js",
|
|
219
|
-
"${PODS_ROOT}/../NativeModule2.js",
|
|
220
|
-
])
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
def testGetListOfJSSpecs_whenDoesNotUsesLibraries_returnAListOfFiles
|
|
224
|
-
# Arrange
|
|
225
|
-
app_codegen_config = {
|
|
226
|
-
'name' => 'First Lib',
|
|
227
|
-
'jsSrcsDir' => './js'
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
app_path = "~/MyApp/"
|
|
231
|
-
Finder.set_files_for_paths({
|
|
232
|
-
'~/MyApp/./js' => ["MyFabricComponent1NativeComponent.js", "NativeModule1.js"],
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
# Act
|
|
236
|
-
files = CodegenUtils.new().get_list_of_js_specs(app_codegen_config, app_path, file_manager: FileMock)
|
|
237
|
-
|
|
238
|
-
# Assert
|
|
239
|
-
assert_equal(Pod::UI.collected_warns , [])
|
|
240
|
-
assert_equal(Finder.captured_paths, ['~/MyApp/./js'])
|
|
241
|
-
assert_equal(files, [
|
|
242
|
-
"${PODS_ROOT}/../MyFabricComponent1NativeComponent.js",
|
|
243
|
-
"${PODS_ROOT}/../NativeModule1.js",
|
|
244
|
-
])
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
# ================================== #
|
|
248
|
-
# Test - GetReactCodegenScriptPhases #
|
|
249
|
-
# ================================== #
|
|
250
|
-
|
|
251
|
-
def testGetReactCodegenScriptPhases_whenAppPathNotDefined_abort
|
|
252
|
-
# Arrange
|
|
253
|
-
|
|
254
|
-
# Act
|
|
255
|
-
assert_raises() {
|
|
256
|
-
CodegenUtils.new().get_react_codegen_script_phases(nil, file_manager: FileMock)
|
|
257
|
-
}
|
|
258
|
-
# Assert
|
|
259
|
-
assert_equal(Pod::UI.collected_warns, ["[Codegen] error: app_path is required to use codegen discovery."])
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
def testGetReactCodegenScriptPhases_returnTheScriptObject
|
|
263
|
-
# Arrange
|
|
264
|
-
app_path = "~/MyApp"
|
|
265
|
-
input_files = ["${PODS_ROOT}/../MyFabricComponent1NativeComponent.js", "${PODS_ROOT}/../NativeModule1.js"]
|
|
266
|
-
computed_script = "echo ScriptPhases"
|
|
267
|
-
codegen_config = { "name" => "MyCodegenModule", "jsSrcsDir" => "./js"}
|
|
268
|
-
codegen_utils_mock = CodegenUtilsMock.new(:js_spec_list => input_files, :codegen_config => codegen_config)
|
|
269
|
-
script_phase_extractor_mock = CodegenScriptPhaseExtractorMock.new(computed_script)
|
|
270
|
-
|
|
271
|
-
# Act
|
|
272
|
-
|
|
273
|
-
scripts = CodegenUtils.new().get_react_codegen_script_phases(
|
|
274
|
-
app_path,
|
|
275
|
-
:codegen_utils => codegen_utils_mock,
|
|
276
|
-
:script_phase_extractor => script_phase_extractor_mock,
|
|
277
|
-
:file_manager => FileMock
|
|
278
|
-
)
|
|
279
|
-
|
|
280
|
-
# Assert
|
|
281
|
-
assert_equal(codegen_utils_mock.get_codegen_config_from_file_params, [{
|
|
282
|
-
"config_key" => "codegenConfig",
|
|
283
|
-
"config_path" => "~/MyApp/package.json"
|
|
284
|
-
}])
|
|
285
|
-
assert_equal(codegen_utils_mock.get_list_of_js_specs_params, [{
|
|
286
|
-
"app_codegen_config" => {"jsSrcsDir"=>"./js", "name"=>"MyCodegenModule"},
|
|
287
|
-
"app_path" => "~/MyApp"
|
|
288
|
-
}])
|
|
289
|
-
assert_equal(script_phase_extractor_mock.extract_script_phase_params, [{
|
|
290
|
-
fabric_enabled: false,
|
|
291
|
-
react_native_path: "../node_modules/react-native",
|
|
292
|
-
relative_app_root: "~/MyApp",
|
|
293
|
-
relative_config_file_dir: ""
|
|
294
|
-
}])
|
|
295
|
-
assert_equal(scripts, {
|
|
296
|
-
'name': 'Generate Specs',
|
|
297
|
-
'execution_position': :before_compile,
|
|
298
|
-
'input_files' => input_files,
|
|
299
|
-
'show_env_vars_in_log': true,
|
|
300
|
-
'output_files': ["${DERIVED_FILE_DIR}/react-codegen.log"],
|
|
301
|
-
'script': computed_script
|
|
302
|
-
})
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
# ================================ #
|
|
306
|
-
# Test - UseReactCodegenDiscovery! #
|
|
307
|
-
# ================================ #
|
|
308
|
-
|
|
309
|
-
def testUseReactCodegenDiscovery_whenCodegenDisabled_doNothing
|
|
310
|
-
# Arrange
|
|
311
|
-
|
|
312
|
-
# Act
|
|
313
|
-
CodegenUtils.new().use_react_native_codegen_discovery!(true, nil, file_manager: FileMock)
|
|
314
|
-
|
|
315
|
-
# Assert
|
|
316
|
-
assert_false(CodegenUtils.react_codegen_discovery_done())
|
|
317
|
-
assert_equal(Pod::UI.collected_messages, [])
|
|
318
|
-
assert_equal(Pod::UI.collected_warns, [])
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
def testUseReactCodegenDiscovery_whenDiscoveryDone_doNothing
|
|
322
|
-
# Arrange
|
|
323
|
-
CodegenUtils.set_react_codegen_discovery_done(true)
|
|
324
|
-
|
|
325
|
-
# Act
|
|
326
|
-
CodegenUtils.new().use_react_native_codegen_discovery!(false, nil, file_manager: FileMock)
|
|
327
|
-
|
|
328
|
-
# Assert
|
|
329
|
-
assert_true(CodegenUtils.react_codegen_discovery_done())
|
|
330
|
-
assert_equal(Pod::UI.collected_messages, ["[Codegen] Skipping use_react_native_codegen_discovery."])
|
|
331
|
-
assert_equal(Pod::UI.collected_warns, [])
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
def testUseReactCodegenDiscovery_whenAppPathUndefined_abort
|
|
335
|
-
# Arrange
|
|
336
|
-
|
|
337
|
-
# Act
|
|
338
|
-
assert_raises(){
|
|
339
|
-
CodegenUtils.new().use_react_native_codegen_discovery!(false, nil, file_manager: FileMock)
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
# Assert
|
|
343
|
-
assert_false(CodegenUtils.react_codegen_discovery_done())
|
|
344
|
-
assert_equal(Pod::UI.collected_messages, [])
|
|
345
|
-
assert_equal(Pod::UI.collected_warns, [
|
|
346
|
-
'[Codegen] Error: app_path is required for use_react_native_codegen_discovery.',
|
|
347
|
-
'[Codegen] If you are calling use_react_native_codegen_discovery! in your Podfile, please remove the call and pass `app_path` and/or `config_file_dir` to `use_react_native!`.'
|
|
348
|
-
])
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
def testUseReactCodegenDiscovery_whenParametersAreGood_executeCodegen
|
|
352
|
-
# Arrange
|
|
353
|
-
app_path = "~/app"
|
|
354
|
-
computed_script = "echo TestScript"
|
|
355
|
-
codegen_spec = {"name" => "React-Codegen"}
|
|
356
|
-
|
|
357
|
-
codegen_utils_mock = CodegenUtilsMock.new(
|
|
358
|
-
:react_codegen_script_phases => computed_script,
|
|
359
|
-
:react_codegen_spec => codegen_spec
|
|
360
|
-
)
|
|
361
|
-
|
|
362
|
-
# Act
|
|
363
|
-
CodegenUtils.new().use_react_native_codegen_discovery!(
|
|
364
|
-
false,
|
|
365
|
-
app_path,
|
|
366
|
-
:codegen_utils => codegen_utils_mock,
|
|
367
|
-
:file_manager => FileMock
|
|
368
|
-
)
|
|
369
|
-
|
|
370
|
-
# Assert
|
|
371
|
-
assert_true(CodegenUtils.react_codegen_discovery_done())
|
|
372
|
-
assert_equal(Pod::UI.collected_warns, [
|
|
373
|
-
'[Codegen] warn: using experimental new codegen integration'
|
|
374
|
-
])
|
|
375
|
-
assert_equal(codegen_utils_mock.get_react_codegen_script_phases_params, [{
|
|
376
|
-
:app_path => app_path,
|
|
377
|
-
:config_file_dir => "",
|
|
378
|
-
:config_key => "codegenConfig",
|
|
379
|
-
:fabric_enabled => false,
|
|
380
|
-
:react_native_path => "../node_modules/react-native"}
|
|
381
|
-
])
|
|
382
|
-
assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [{
|
|
383
|
-
:fabric_enabled => false,
|
|
384
|
-
:folly_version=>"2021.07.22.00",
|
|
385
|
-
:package_json_file => "#{app_path}/ios/../node_modules/react-native/package.json",
|
|
386
|
-
:script_phases => "echo TestScript"
|
|
387
|
-
}])
|
|
388
|
-
assert_equal(codegen_utils_mock.generate_react_codegen_spec_params, [{
|
|
389
|
-
:codegen_output_dir=>"build/generated/ios",
|
|
390
|
-
:react_codegen_spec=>{"name"=>"React-Codegen"}
|
|
391
|
-
}])
|
|
392
|
-
assert_equal(Pod::Executable.executed_commands, [
|
|
393
|
-
{
|
|
394
|
-
"command" => "node",
|
|
395
|
-
"arguments"=> ["~/app/ios/../node_modules/react-native/scripts/generate-codegen-artifacts.js",
|
|
396
|
-
"-p", "~/app",
|
|
397
|
-
"-o", Pod::Config.instance.installation_root,
|
|
398
|
-
"-e", "false",
|
|
399
|
-
"-c", ""]
|
|
400
|
-
}
|
|
401
|
-
])
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
# ============================= #
|
|
405
|
-
# Test - CleanUpCodegenFolder #
|
|
406
|
-
# ============================= #
|
|
407
|
-
|
|
408
|
-
def testCleanUpCodegenFolder_whenCleanupDone_doNothing
|
|
409
|
-
# Arrange
|
|
410
|
-
CodegenUtils.set_cleanup_done(true)
|
|
411
|
-
codegen_dir = "build/generated/ios"
|
|
412
|
-
ios_folder = '.'
|
|
413
|
-
rn_path = '../node_modules/react-native'
|
|
414
|
-
|
|
415
|
-
# Act
|
|
416
|
-
CodegenUtils.clean_up_build_folder(rn_path, @base_path, ios_folder, codegen_dir, dir_manager: DirMock, file_manager: FileMock)
|
|
417
|
-
|
|
418
|
-
# Assert
|
|
419
|
-
assert_equal(FileUtils::FileUtilsStorage.rmrf_invocation_count, 0)
|
|
420
|
-
assert_equal(FileUtils::FileUtilsStorage.rmrf_paths, [])
|
|
421
|
-
assert_equal(CodegenUtils.cleanup_done(), true)
|
|
422
|
-
end
|
|
423
|
-
|
|
424
|
-
def testCleanUpCodegenFolder_whenFolderDoesNotExists_markAsCleanupDone
|
|
425
|
-
# Arrange
|
|
426
|
-
CodegenUtils.set_cleanup_done(false)
|
|
427
|
-
codegen_dir = "build/generated/ios"
|
|
428
|
-
ios_folder = '.'
|
|
429
|
-
rn_path = '../node_modules/react-native'
|
|
430
|
-
|
|
431
|
-
# Act
|
|
432
|
-
CodegenUtils.clean_up_build_folder(rn_path, @base_path, ios_folder, codegen_dir, dir_manager: DirMock, file_manager: FileMock)
|
|
433
|
-
|
|
434
|
-
# Assert
|
|
435
|
-
assert_equal(FileUtils::FileUtilsStorage.rmrf_invocation_count, 0)
|
|
436
|
-
assert_equal(FileUtils::FileUtilsStorage.rmrf_paths, [])
|
|
437
|
-
assert_equal(DirMock.glob_invocation, [])
|
|
438
|
-
assert_equal(CodegenUtils.cleanup_done(), true)
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
def testCleanUpCodegenFolder_whenFolderExists_deleteItAndSetCleanupDone
|
|
442
|
-
# Arrange
|
|
443
|
-
CodegenUtils.set_cleanup_done(false)
|
|
444
|
-
codegen_dir = "build/generated/ios"
|
|
445
|
-
ios_folder = '.'
|
|
446
|
-
codegen_path = "#{@base_path}/./#{codegen_dir}"
|
|
447
|
-
globs = [
|
|
448
|
-
"/MyModuleSpecs/MyModule.h",
|
|
449
|
-
"#{codegen_path}/MyModuleSpecs/MyModule.mm",
|
|
450
|
-
"#{codegen_path}/react/components/MyComponent/ShadowNode.h",
|
|
451
|
-
"#{codegen_path}/react/components/MyComponent/ShadowNode.mm",
|
|
452
|
-
]
|
|
453
|
-
rn_path = '../node_modules/react-native'
|
|
454
|
-
|
|
455
|
-
DirMock.mocked_existing_dirs(codegen_path)
|
|
456
|
-
DirMock.mocked_existing_globs(globs, "#{codegen_path}/*")
|
|
457
|
-
|
|
458
|
-
# Act
|
|
459
|
-
CodegenUtils.clean_up_build_folder(rn_path, @base_path, ios_folder, codegen_dir, dir_manager: DirMock, file_manager: FileMock)
|
|
460
|
-
|
|
461
|
-
# Assert
|
|
462
|
-
assert_equal(DirMock.exist_invocation_params, [codegen_path, codegen_path])
|
|
463
|
-
assert_equal(DirMock.glob_invocation, ["#{codegen_path}/*", "#{codegen_path}/*"])
|
|
464
|
-
assert_equal(FileUtils::FileUtilsStorage.rmrf_invocation_count, 3)
|
|
465
|
-
assert_equal(FileUtils::FileUtilsStorage.rmrf_paths, [
|
|
466
|
-
globs,
|
|
467
|
-
"#{rn_path}/React/Fabric/RCTThirdPartyFabricComponentsProvider.h",
|
|
468
|
-
"#{rn_path}/React/Fabric/RCTThirdPartyFabricComponentsProvider.mm",
|
|
469
|
-
])
|
|
470
|
-
assert_equal(CodegenUtils.cleanup_done(), true)
|
|
471
|
-
end
|
|
472
|
-
|
|
473
|
-
# ===================================== #
|
|
474
|
-
# Test - Assert Codegen Folder Is Empty #
|
|
475
|
-
# ===================================== #
|
|
476
|
-
|
|
477
|
-
def test_assertCodegenFolderIsEmpty_whenItDoesNotExists_doesNotAbort
|
|
478
|
-
# Arrange
|
|
479
|
-
codegen_dir = "build/generated/ios"
|
|
480
|
-
codegen_path = "#{@base_path}/./#{codegen_dir}"
|
|
481
|
-
ios_folder = '.'
|
|
482
|
-
|
|
483
|
-
# Act
|
|
484
|
-
CodegenUtils.assert_codegen_folder_is_empty(@base_path, ios_folder, codegen_dir, dir_manager: DirMock, file_manager: FileMock)
|
|
485
|
-
|
|
486
|
-
# Assert
|
|
487
|
-
assert_equal(Pod::UI.collected_warns, [])
|
|
488
|
-
end
|
|
489
|
-
|
|
490
|
-
def test_assertCodegenFolderIsEmpty_whenItExistsAndIsEmpty_doesNotAbort
|
|
491
|
-
# Arrange
|
|
492
|
-
codegen_dir = "build/generated/ios"
|
|
493
|
-
codegen_path = "#{@base_path}/./#{codegen_dir}"
|
|
494
|
-
ios_folder = '.'
|
|
495
|
-
DirMock.mocked_existing_dirs(codegen_path)
|
|
496
|
-
DirMock.mocked_existing_globs([], "#{codegen_path}/*")
|
|
497
|
-
|
|
498
|
-
# Act
|
|
499
|
-
CodegenUtils.assert_codegen_folder_is_empty(@base_path, ios_folder, codegen_dir, dir_manager: DirMock, file_manager: FileMock)
|
|
500
|
-
|
|
501
|
-
# Assert
|
|
502
|
-
assert_equal(Pod::UI.collected_warns, [])
|
|
503
|
-
end
|
|
504
|
-
|
|
505
|
-
def test_assertCodegenFolderIsEmpty_whenItIsNotEmpty_itAborts
|
|
506
|
-
# Arrange
|
|
507
|
-
codegen_dir = "build/generated/ios"
|
|
508
|
-
codegen_path = "#{@base_path}/./#{codegen_dir}"
|
|
509
|
-
ios_folder = '.'
|
|
510
|
-
DirMock.mocked_existing_dirs(codegen_path)
|
|
511
|
-
DirMock.mocked_existing_globs(["#{codegen_path}/MyModuleSpecs/MyModule.mm",], "#{codegen_path}/*")
|
|
512
|
-
|
|
513
|
-
# Act
|
|
514
|
-
assert_raises() {
|
|
515
|
-
CodegenUtils.assert_codegen_folder_is_empty(@base_path, ios_folder, codegen_dir, dir_manager: DirMock, file_manager: FileMock)
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
# Assert
|
|
519
|
-
assert_equal(Pod::UI.collected_warns, [
|
|
520
|
-
"Unable to remove the content of ~/app/ios/./build/generated/ios folder. Please run rm -rf ~/app/ios/./build/generated/ios and try again."
|
|
521
|
-
])
|
|
522
|
-
end
|
|
523
|
-
|
|
524
|
-
private
|
|
525
|
-
|
|
526
|
-
def get_podspec_no_fabric_no_script
|
|
527
|
-
spec = {
|
|
528
|
-
'name' => "React-Codegen",
|
|
529
|
-
'version' => "99.98.97",
|
|
530
|
-
'summary' => 'Temp pod for generated files for React Native',
|
|
531
|
-
'homepage' => 'https://facebook.com/',
|
|
532
|
-
'license' => 'Unlicense',
|
|
533
|
-
'authors' => 'Facebook',
|
|
534
|
-
'compiler_flags' => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation -Wno-nullability-completeness -std=c++17",
|
|
535
|
-
'source' => { :git => '' },
|
|
536
|
-
'header_mappings_dir' => './',
|
|
537
|
-
'platforms' => {
|
|
538
|
-
'ios' => '12.4',
|
|
539
|
-
},
|
|
540
|
-
'source_files' => "**/*.{h,mm,cpp}",
|
|
541
|
-
'pod_target_xcconfig' => {
|
|
542
|
-
"FRAMEWORK_SEARCH_PATHS" => [],
|
|
543
|
-
"HEADER_SEARCH_PATHS" =>
|
|
544
|
-
[
|
|
545
|
-
"\"$(PODS_ROOT)/boost\"",
|
|
546
|
-
"\"$(PODS_ROOT)/RCT-Folly\"",
|
|
547
|
-
"\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"",
|
|
548
|
-
"\"$(PODS_ROOT)/Headers/Private/React-Fabric\"",
|
|
549
|
-
"\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"",
|
|
550
|
-
].join(' ')
|
|
551
|
-
},
|
|
552
|
-
'dependencies': {
|
|
553
|
-
"DoubleConversion": [],
|
|
554
|
-
"FBReactNativeSpec": [],
|
|
555
|
-
"RCT-Folly": [],
|
|
556
|
-
"RCTRequired": [],
|
|
557
|
-
"RCTTypeSafety": [],
|
|
558
|
-
"React-Core": [],
|
|
559
|
-
"React-jsi": [],
|
|
560
|
-
"React-jsiexecutor": [],
|
|
561
|
-
"React-rncore": [],
|
|
562
|
-
"ReactCommon/turbomodule/bridging": [],
|
|
563
|
-
"ReactCommon/turbomodule/core": [],
|
|
564
|
-
"hermes-engine": [],
|
|
565
|
-
"glog": [],
|
|
566
|
-
'React-NativeModulesApple': [],
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
end
|
|
570
|
-
|
|
571
|
-
def get_podspec_fabric_and_script_phases(script_phases)
|
|
572
|
-
specs = get_podspec_no_fabric_no_script()
|
|
573
|
-
|
|
574
|
-
specs[:dependencies].merge!({
|
|
575
|
-
'React-graphics': [],
|
|
576
|
-
'React-rncore': [],
|
|
577
|
-
'React-Fabric': [],
|
|
578
|
-
'React-utils': [],
|
|
579
|
-
'React-debug': [],
|
|
580
|
-
})
|
|
581
|
-
|
|
582
|
-
specs[:'script_phases'] = script_phases
|
|
583
|
-
|
|
584
|
-
return specs
|
|
585
|
-
end
|
|
586
|
-
|
|
587
|
-
def get_podspec_when_use_frameworks
|
|
588
|
-
specs = get_podspec_no_fabric_no_script()
|
|
589
|
-
|
|
590
|
-
specs["pod_target_xcconfig"]["FRAMEWORK_SEARCH_PATHS"].concat([])
|
|
591
|
-
specs["pod_target_xcconfig"]["HEADER_SEARCH_PATHS"].concat(" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-Fabric/React_Fabric.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios\" \"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-RCTFabric/RCTFabric.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers\"")
|
|
592
|
-
|
|
593
|
-
specs[:dependencies].merge!({
|
|
594
|
-
'React-graphics': [],
|
|
595
|
-
'React-Fabric': [],
|
|
596
|
-
'React-utils': [],
|
|
597
|
-
'React-debug': [],
|
|
598
|
-
})
|
|
599
|
-
|
|
600
|
-
return specs
|
|
601
|
-
end
|
|
602
|
-
end
|
|
@@ -1,68 +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 "../fabric.rb"
|
|
8
|
-
require_relative "../utils.rb"
|
|
9
|
-
require_relative "./test_utils/podSpy.rb"
|
|
10
|
-
|
|
11
|
-
class FabricTest < Test::Unit::TestCase
|
|
12
|
-
|
|
13
|
-
def setup
|
|
14
|
-
podSpy_cleanUp()
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def teardown
|
|
18
|
-
podSpy_cleanUp()
|
|
19
|
-
ENV['RCT_NEW_ARCH_ENABLED'] = "0"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# ================== #
|
|
23
|
-
# TEST - setupFabric #
|
|
24
|
-
# ================== #
|
|
25
|
-
def test_setupFabric_whenNewArchDisabled_installsPods
|
|
26
|
-
# Arrange
|
|
27
|
-
prefix = "../.."
|
|
28
|
-
|
|
29
|
-
# Act
|
|
30
|
-
setup_fabric!(:react_native_path => prefix)
|
|
31
|
-
|
|
32
|
-
# Assert
|
|
33
|
-
check_installed_pods(prefix)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_setupFabric_whenNewArchEnabled_installPods
|
|
37
|
-
# Arrange
|
|
38
|
-
prefix = "../.."
|
|
39
|
-
ENV['RCT_NEW_ARCH_ENABLED'] = "1"
|
|
40
|
-
|
|
41
|
-
# Act
|
|
42
|
-
setup_fabric!(:react_native_path => prefix, new_arch_enabled: true)
|
|
43
|
-
|
|
44
|
-
# Assert
|
|
45
|
-
check_installed_pods(prefix)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def check_installed_pods(prefix)
|
|
49
|
-
assert_equal($podInvocationCount, 5)
|
|
50
|
-
|
|
51
|
-
check_pod("React-Fabric", :path => "#{prefix}/ReactCommon")
|
|
52
|
-
check_pod("React-graphics", :path => "#{prefix}/ReactCommon/react/renderer/graphics")
|
|
53
|
-
check_pod("React-RCTFabric", :path => "#{prefix}/React", :modular_headers => true)
|
|
54
|
-
check_pod("RCT-Folly/Fabric", :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec")
|
|
55
|
-
check_pod("React-ImageManager", :path => "#{prefix}/ReactCommon/react/renderer/imagemanager/platform/ios")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def check_pod(name, path: nil, modular_headers: nil, podspec: nil)
|
|
59
|
-
params = $podInvocation[name]
|
|
60
|
-
expected_params = {}
|
|
61
|
-
|
|
62
|
-
if path != nil then expected_params[:path] = path end
|
|
63
|
-
if modular_headers != nil then expected_params[:modular_headers] = modular_headers end
|
|
64
|
-
if podspec != nil then expected_params[:podspec] = podspec end
|
|
65
|
-
|
|
66
|
-
assert_equal(params, expected_params)
|
|
67
|
-
end
|
|
68
|
-
end
|