Skip to content

Commit 57268c5

Browse files
nbondancameta-codesync[bot]
authored andcommitted
Update ktfmt component on FBS:master
Reviewed By: cortinico Differential Revision: D96922887 fbshipit-source-id: 357f51f07c3bff9e517e0e7466dc5dfe4028a98a
1 parent 56908a7 commit 57268c5

11 files changed

Lines changed: 135 additions & 144 deletions

File tree

packages/react-native/ReactAndroid/build.gradle.kts

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,10 @@ val preparePrefab by
292292
outputDir.set(prefabHeadersDir)
293293
}
294294

295-
val createNativeDepsDirectories by
296-
tasks.registering {
297-
downloadsDir.mkdirs()
298-
thirdPartyNdkDir.mkdirs()
299-
}
295+
val createNativeDepsDirectories by tasks.registering {
296+
downloadsDir.mkdirs()
297+
thirdPartyNdkDir.mkdirs()
298+
}
300299

301300
val downloadBoostDest = File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz")
302301
val downloadBoost by
@@ -437,23 +436,21 @@ val prepareGlog by
437436
}
438437

439438
// Tasks used by Fantom to download the Native 3p dependencies used.
440-
val prepareNative3pDependencies by
441-
tasks.registering {
442-
dependsOn(
443-
prepareBoost,
444-
prepareDoubleConversion,
445-
prepareFastFloat,
446-
prepareFmt,
447-
prepareFolly,
448-
prepareGlog,
449-
)
450-
}
439+
val prepareNative3pDependencies by tasks.registering {
440+
dependsOn(
441+
prepareBoost,
442+
prepareDoubleConversion,
443+
prepareFastFloat,
444+
prepareFmt,
445+
prepareFolly,
446+
prepareGlog,
447+
)
448+
}
451449

452-
val prepareKotlinBuildScriptModel by
453-
tasks.registering {
454-
// This task is run when Gradle Sync is running.
455-
// We create it here so we can let it depend on preBuild inside the android{}
456-
}
450+
val prepareKotlinBuildScriptModel by tasks.registering {
451+
// This task is run when Gradle Sync is running.
452+
// We create it here so we can let it depend on preBuild inside the android{}
453+
}
457454

458455
// As ReactAndroid builds from source, the codegen needs to be built before it can be invoked.
459456
// This is not the case for users of React Native, as we ship a compiled version of the codegen.

packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,20 @@ val hermesBuildOutputFileTree =
8181
fileTree(hermesBuildDir.toString())
8282
.include("**/*.cmake", "**/*.marks", "**/compiler_depends.ts", "**/Makefile", "**/link.txt")
8383

84-
val hermesVersionProvider: Provider<String> =
85-
providers.provider {
86-
var hermesVersion = if (hermesV1Enabled) "250829098.0.0-stable" else "main"
87-
val hermesVersionFile =
88-
File(
89-
reactNativeRootDir,
90-
if (hermesV1Enabled) "sdks/.hermesv1version" else "sdks/.hermesversion",
91-
)
84+
val hermesVersionProvider: Provider<String> = providers.provider {
85+
var hermesVersion = if (hermesV1Enabled) "250829098.0.0-stable" else "main"
86+
val hermesVersionFile =
87+
File(
88+
reactNativeRootDir,
89+
if (hermesV1Enabled) "sdks/.hermesv1version" else "sdks/.hermesversion",
90+
)
9291

93-
if (hermesVersionFile.exists()) {
94-
hermesVersion = hermesVersionFile.readText()
95-
}
92+
if (hermesVersionFile.exists()) {
93+
hermesVersion = hermesVersionFile.readText()
94+
}
9695

97-
hermesVersion
98-
}
96+
hermesVersion
97+
}
9998

10099
val ndkBuildJobs = Runtime.getRuntime().availableProcessors().toString()
101100
val prefabHeadersDir = File("$buildDir/prefab-headers")

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/FrameTimingsObserver.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,15 @@ internal class FrameTimingsObserver(
9797
}
9898
}
9999

100-
private val frameMetricsListener =
101-
Window.OnFrameMetricsAvailableListener { _, frameMetrics, _ ->
102-
// Guard against calls after stop()
103-
if (!isTracing) {
104-
return@OnFrameMetricsAvailableListener
105-
}
106-
val beginTimestamp = frameMetrics.getMetric(FrameMetrics.VSYNC_TIMESTAMP)
107-
val endTimestamp = beginTimestamp + frameMetrics.getMetric(FrameMetrics.TOTAL_DURATION)
108-
emitFrameTiming(beginTimestamp, endTimestamp)
109-
}
100+
private val frameMetricsListener = Window.OnFrameMetricsAvailableListener { _, frameMetrics, _ ->
101+
// Guard against calls after stop()
102+
if (!isTracing) {
103+
return@OnFrameMetricsAvailableListener
104+
}
105+
val beginTimestamp = frameMetrics.getMetric(FrameMetrics.VSYNC_TIMESTAMP)
106+
val endTimestamp = beginTimestamp + frameMetrics.getMetric(FrameMetrics.TOTAL_DURATION)
107+
emitFrameTiming(beginTimestamp, endTimestamp)
108+
}
110109

111110
private fun emitFrameTiming(beginTimestamp: Long, endTimestamp: Long) {
112111
val frameId = frameCounter++

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayView.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ internal class PerfMonitorOverlayView(
142142
val dialog =
143143
createAnchoredDialog(dpToPx(12f), dpToPx(12f)).apply { setContentView(containerLayout) }
144144
dialog.window?.apply {
145-
attributes =
146-
attributes?.apply { flags = flags or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE }
145+
attributes = attributes?.apply {
146+
flags = flags or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
147+
}
147148
}
148149

149150
return dialog
@@ -158,14 +159,13 @@ internal class PerfMonitorOverlayView(
158159
setCancelable(false)
159160
}
160161
dialog.window?.apply {
161-
attributes =
162-
attributes?.apply {
163-
width = WindowManager.LayoutParams.WRAP_CONTENT
164-
height = WindowManager.LayoutParams.WRAP_CONTENT
165-
gravity = Gravity.TOP or Gravity.END
166-
x = offsetX.toInt()
167-
y = offsetY.toInt()
168-
}
162+
attributes = attributes?.apply {
163+
width = WindowManager.LayoutParams.WRAP_CONTENT
164+
height = WindowManager.LayoutParams.WRAP_CONTENT
165+
gravity = Gravity.TOP or Gravity.END
166+
x = offsetX.toInt()
167+
y = offsetY.toInt()
168+
}
169169
}
170170
dialog.window?.decorView?.let { decorView ->
171171
ViewCompat.setOnApplyWindowInsetsListener(decorView) { view, windowInsets ->

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.kt

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,27 @@ public class ReactChoreographer private constructor(choreographerProvider: Chore
4444
private var totalCallbacks = 0
4545
@GuardedBy("callbackQueues") private var hasPostedCallback = false
4646

47-
private val frameCallback =
48-
Choreographer.FrameCallback { frameTimeNanos ->
49-
synchronized(callbackQueues) {
50-
// Callbacks run once and are then automatically removed, the callback will
51-
// be posted again from postFrameCallback
52-
hasPostedCallback = false
53-
for (i in callbackQueues.indices) {
54-
val callbackQueue = callbackQueues[i]
55-
val initialLength = callbackQueue.size
56-
for (callback in 0 until initialLength) {
57-
val frameCallback = callbackQueue.pollFirst()
58-
if (frameCallback != null) {
59-
frameCallback.doFrame(frameTimeNanos)
60-
totalCallbacks--
61-
} else {
62-
FLog.e(ReactConstants.TAG, "Tried to execute non-existent frame callback")
63-
}
64-
}
47+
private val frameCallback = Choreographer.FrameCallback { frameTimeNanos ->
48+
synchronized(callbackQueues) {
49+
// Callbacks run once and are then automatically removed, the callback will
50+
// be posted again from postFrameCallback
51+
hasPostedCallback = false
52+
for (i in callbackQueues.indices) {
53+
val callbackQueue = callbackQueues[i]
54+
val initialLength = callbackQueue.size
55+
for (callback in 0 until initialLength) {
56+
val frameCallback = callbackQueue.pollFirst()
57+
if (frameCallback != null) {
58+
frameCallback.doFrame(frameTimeNanos)
59+
totalCallbacks--
60+
} else {
61+
FLog.e(ReactConstants.TAG, "Tried to execute non-existent frame callback")
6562
}
66-
maybeRemoveFrameCallback()
6763
}
6864
}
65+
maybeRemoveFrameCallback()
66+
}
67+
}
6968

7069
init {
7170
UiThreadUtil.runOnUiThread { choreographer = choreographerProvider.getChoreographer() }
@@ -138,6 +137,8 @@ public class ReactChoreographer private constructor(choreographerProvider: Chore
138137

139138
@VisibleForTesting
140139
internal fun overrideInstanceForTest(instance: ReactChoreographer?): ReactChoreographer? =
141-
choreographer.also { choreographer = instance }
140+
choreographer.also {
141+
choreographer = instance
142+
}
142143
}
143144
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -989,11 +989,10 @@ public class ReactHostImpl(
989989
jsBundleLoader.onSuccess(
990990
{ task ->
991991
val bundleLoader = checkNotNull(task.getResult())
992-
val reactContext =
993-
bridgelessReactContextRef.getOrCreate {
994-
stateTracker.enterState(method, "Creating BridgelessReactContext")
995-
BridgelessReactContext(context, this)
996-
}
992+
val reactContext = bridgelessReactContextRef.getOrCreate {
993+
stateTracker.enterState(method, "Creating BridgelessReactContext")
994+
BridgelessReactContext(context, this)
995+
}
997996
reactContext.jsExceptionHandler = devSupportManager
998997

999998
stateTracker.enterState(method, "Creating ReactInstance")

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ internal object ReactRootViewTagGenerator {
1717

1818
@JvmStatic
1919
@Synchronized
20-
fun getNextRootViewTag(): Int =
21-
nextRootViewTag.also { nextRootViewTag += ROOT_VIEW_TAG_INCREMENT }
20+
fun getNextRootViewTag(): Int = nextRootViewTag.also {
21+
nextRootViewTag += ROOT_VIEW_TAG_INCREMENT
22+
}
2223
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,18 @@ internal class InsetBoxShadowDrawable(
9292
bounds.right - (computedBorderInsets?.right ?: 0f),
9393
bounds.bottom - (computedBorderInsets?.bottom ?: 0f),
9494
)
95-
val paddingBoxRadii =
96-
computedBorderRadii?.let {
97-
floatArrayOf(
98-
innerRadius(it.topLeft.horizontal, computedBorderInsets?.left),
99-
innerRadius(it.topLeft.vertical, computedBorderInsets?.top),
100-
innerRadius(it.topRight.horizontal, computedBorderInsets?.right),
101-
innerRadius(it.topRight.vertical, computedBorderInsets?.top),
102-
innerRadius(it.bottomRight.horizontal, computedBorderInsets?.right),
103-
innerRadius(it.bottomRight.vertical, computedBorderInsets?.bottom),
104-
innerRadius(it.bottomLeft.horizontal, computedBorderInsets?.left),
105-
innerRadius(it.bottomLeft.vertical, computedBorderInsets?.bottom),
106-
)
107-
}
95+
val paddingBoxRadii = computedBorderRadii?.let {
96+
floatArrayOf(
97+
innerRadius(it.topLeft.horizontal, computedBorderInsets?.left),
98+
innerRadius(it.topLeft.vertical, computedBorderInsets?.top),
99+
innerRadius(it.topRight.horizontal, computedBorderInsets?.right),
100+
innerRadius(it.topRight.vertical, computedBorderInsets?.top),
101+
innerRadius(it.bottomRight.horizontal, computedBorderInsets?.right),
102+
innerRadius(it.bottomRight.vertical, computedBorderInsets?.bottom),
103+
innerRadius(it.bottomLeft.horizontal, computedBorderInsets?.left),
104+
innerRadius(it.bottomLeft.vertical, computedBorderInsets?.bottom),
105+
)
106+
}
108107

109108
val x = offsetX.dpToPx()
110109
val y = offsetY.dpToPx()

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,14 @@ internal object TouchesHelper {
132132
}
133133

134134
for (touchData in changedTouches) {
135-
val eventData =
136-
touchData?.let { td ->
137-
val ed = td.copy()
138-
val changedTouchesArray = getWritableArray(/* copyObjects */ true, changedTouches)
139-
val touchesArray = getWritableArray(/* copyObjects */ true, touches)
140-
ed.putArray(CHANGED_TOUCHES_KEY, changedTouchesArray)
141-
ed.putArray(TOUCHES_KEY, touchesArray)
142-
ed
143-
}
135+
val eventData = touchData?.let { td ->
136+
val ed = td.copy()
137+
val changedTouchesArray = getWritableArray(/* copyObjects */ true, changedTouches)
138+
val touchesArray = getWritableArray(/* copyObjects */ true, touches)
139+
ed.putArray(CHANGED_TOUCHES_KEY, changedTouchesArray)
140+
ed.putArray(TOUCHES_KEY, touchesArray)
141+
ed
142+
}
144143

145144
eventEmitter.receiveEvent(
146145
event.surfaceId,

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,17 @@ public open class ReactViewManager : ReactClippingViewManager<ReactViewGroup>()
326326

327327
@ReactProp(name = "nativeBackgroundAndroid")
328328
public open fun setNativeBackground(view: ReactViewGroup, background: ReadableMap?) {
329-
val bg =
330-
background?.let { ReactDrawableHelper.createDrawableFromJSDescription(view.context, it) }
329+
val bg = background?.let {
330+
ReactDrawableHelper.createDrawableFromJSDescription(view.context, it)
331+
}
331332
BackgroundStyleApplicator.setFeedbackUnderlay(view, bg)
332333
}
333334

334335
@ReactProp(name = "nativeForegroundAndroid")
335336
public open fun setNativeForeground(view: ReactViewGroup, foreground: ReadableMap?) {
336-
view.foreground =
337-
foreground?.let { ReactDrawableHelper.createDrawableFromJSDescription(view.context, it) }
337+
view.foreground = foreground?.let {
338+
ReactDrawableHelper.createDrawableFromJSDescription(view.context, it)
339+
}
338340
}
339341

340342
@ReactProp(name = ViewProps.NEEDS_OFFSCREEN_ALPHA_COMPOSITING)

0 commit comments

Comments
 (0)