first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

22
node_modules/expo-constants/android/build.gradle generated vendored Normal file
View File

@@ -0,0 +1,22 @@
plugins {
id 'com.android.library'
id 'expo-module-gradle-plugin'
}
apply from: "../scripts/get-app-config-android.gradle"
group = 'host.exp.exponent'
version = '55.0.7'
expoModule {
// We can't prebuild the module because we need to apply `get-app-config-android.gradle` script.
canBePublished false
}
android {
namespace "expo.modules.constants"
defaultConfig {
versionCode 33
versionName "55.0.7"
}
}

View File

@@ -0,0 +1,3 @@
<manifest>
</manifest>

View File

@@ -0,0 +1,21 @@
// Copyright 2015-present 650 Industries. All rights reserved.
package expo.modules.constants
import expo.modules.interfaces.constants.ConstantsInterface
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
class ConstantsModule : Module() {
override fun definition() = ModuleDefinition {
Name("ExponentConstants")
Constants {
return@Constants appContext.service<ConstantsInterface>()?.constants ?: emptyMap()
}
AsyncFunction<String?>("getWebViewUserAgentAsync") {
return@AsyncFunction System.getProperty("http.agent")
}
}
}

View File

@@ -0,0 +1,99 @@
package expo.modules.constants
import android.content.Context
import android.os.Build
import android.util.Log
import expo.modules.interfaces.constants.ConstantsInterface
import expo.modules.kotlin.services.ServiceInterface
import java.io.FileNotFoundException
import java.util.UUID
private val TAG = ConstantsService::class.java.simpleName
private const val CONFIG_FILE_NAME = "app.config"
@ServiceInterface(ConstantsInterface::class)
open class ConstantsService(private val context: Context) : ConstantsInterface {
var statusBarHeightInternal = context
.resources
.getIdentifier("status_bar_height", "dimen", "android")
.takeIf { it > 0 }
?.let { (context.resources::getDimensionPixelSize)(it) }
?.let { pixels -> convertPixelsToDp(pixels.toFloat(), context) }
?: 0
private val sessionId = UUID.randomUUID().toString()
enum class ExecutionEnvironment(val string: String) {
BARE("bare"),
STANDALONE("standalone"),
STORE_CLIENT("storeClient")
}
override val constants: Map<String, Any?>
get() = mapOf(
"sessionId" to sessionId,
"executionEnvironment" to ExecutionEnvironment.BARE.string,
"statusBarHeight" to statusBarHeightInternal,
"deviceName" to deviceName,
"systemFonts" to systemFonts,
"systemVersion" to systemVersion,
"manifest" to appConfig,
"platform" to mapOf<String, Map<String, Any>>("android" to emptyMap())
)
// Just use package name in vanilla React Native apps.
override val appScopeKey: String?
get() = context.packageName
override val deviceName: String
get() = Build.MODEL
override val statusBarHeight: Int
get() = statusBarHeightInternal
override val systemVersion: String
get() = Build.VERSION.RELEASE
// From https://github.com/dabit3/react-native-fonts
override val systemFonts: List<String>
get() = listOf(
"normal",
"notoserif",
"sans-serif",
"sans-serif-light",
"sans-serif-thin",
"sans-serif-condensed",
"sans-serif-medium",
"serif",
"Roboto",
"monospace"
)
private val appConfig: String?
get() {
try {
return context
.assets
.open(CONFIG_FILE_NAME)
.use { input ->
input
.bufferedReader(charset = Charsets.UTF_8)
.use { it.readText() }
}
} catch (_: FileNotFoundException) {
// do nothing, expected in managed apps
} catch (e: Exception) {
Log.e(TAG, "Error reading embedded app config", e)
}
return null
}
companion object {
private fun convertPixelsToDp(px: Float, context: Context): Int {
val resources = context.resources
val metrics = resources.displayMetrics
val dp = px / (metrics.densityDpi / 160f)
return dp.toInt()
}
}
}