fix: migrate away from deprecated `TurboReactPackage` (#3430)

This commit is contained in:
Tommy Nguyen 2024-11-27 11:35:14 +01:00 коммит произвёл GitHub
Родитель e6ff3a43f0
Коммит dd56196b7c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 40 добавлений и 35 удалений

Просмотреть файл

@ -0,0 +1,8 @@
---
"@react-native-webapis/battery-status": minor
"@react-native-webapis/web-storage": minor
"@rnx-kit/react-native-test-app-msal": major
---
Migrate away from deprecated `TurboReactPackage`. This is a requirement for
supporting 0.77 and above.

Просмотреть файл

@ -1,30 +1,28 @@
package org.reactnativewebapis.batterystatus
import com.facebook.react.TurboReactPackage
import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
class BatteryStatusPackage : TurboReactPackage() {
override fun getModule(name: String?, reactContext: ReactApplicationContext?): NativeModule {
return when (name) {
class BatteryStatusPackage : BaseReactPackage() {
override fun getModule(name: String?, reactContext: ReactApplicationContext?): NativeModule =
when (name) {
BatteryStatusModule.NAME -> BatteryStatusModule(reactContext)
else -> throw IllegalArgumentException("No module named '$name'")
}
}
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
ReactModuleInfoProvider {
val info = ReactModuleInfo(
BatteryStatusModule.NAME,
BatteryStatusModule::class.java.name,
false,
false,
false,
false,
false
)
mapOf(info.name() to info).toMutableMap()
}
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
val info = ReactModuleInfo(
BatteryStatusModule.NAME,
BatteryStatusModule::class.java.name,
false,
false,
false,
false,
false
)
mapOf(info.name() to info).toMutableMap()
}
}

Просмотреть файл

@ -35,7 +35,7 @@
},
"peerDependencies": {
"react": ">=18.2.0",
"react-native": ">=0.71.0-0"
"react-native": ">=0.74.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",

Просмотреть файл

@ -1,18 +1,17 @@
package org.reactnativewebapis.webstorage
import com.facebook.react.TurboReactPackage
import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
class WebStoragePackage : TurboReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule {
return when (name) {
class WebStoragePackage : BaseReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule =
when (name) {
WebStorageModule.NAME -> WebStorageModule(reactContext)
else -> throw IllegalArgumentException("No module named '$name'")
}
}
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
val info = ReactModuleInfo(

Просмотреть файл

@ -35,11 +35,11 @@
"lint:kt": "ktlint --relative 'android/src/**/*.kt'"
},
"peerDependencies": {
"@callstack/react-native-visionos": ">=0.73",
"@callstack/react-native-visionos": ">=0.74",
"react": ">=18.2.0",
"react-native": ">=0.72",
"react-native-macos": ">=0.72",
"react-native-windows": ">=0.72"
"react-native": ">=0.74",
"react-native-macos": ">=0.74",
"react-native-windows": ">=0.74"
},
"peerDependenciesMeta": {
"@callstack/react-native-visionos": {

Просмотреть файл

@ -1,11 +1,11 @@
package com.microsoft.reacttestapp.msal
import com.facebook.react.TurboReactPackage
import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfoProvider
class MsalPackage : TurboReactPackage() {
class MsalPackage : BaseReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule {
val info = ReactNativeAuthModuleProvider.info()
?: throw IllegalArgumentException("No modules were ever registered")

Просмотреть файл

@ -3274,7 +3274,7 @@ __metadata:
typescript: "npm:^5.0.0"
peerDependencies:
react: ">=18.2.0"
react-native: ">=0.71.0-0"
react-native: ">=0.74.0"
languageName: unknown
linkType: soft
@ -3296,11 +3296,11 @@ __metadata:
react-native-windows: "npm:^0.75.0"
typescript: "npm:^5.0.0"
peerDependencies:
"@callstack/react-native-visionos": ">=0.73"
"@callstack/react-native-visionos": ">=0.74"
react: ">=18.2.0"
react-native: ">=0.72"
react-native-macos: ">=0.72"
react-native-windows: ">=0.72"
react-native: ">=0.74"
react-native-macos: ">=0.74"
react-native-windows: ">=0.74"
peerDependenciesMeta:
"@callstack/react-native-visionos":
optional: true