peachsim 0.1.1655 → 0.1.1660

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 (237) hide show
  1. package/cli/app-config.ts +4 -0
  2. package/cli/app-stubs.ts +43 -6
  3. package/cli/commands/inspect/shared.ts +5 -2
  4. package/cli/commands/inspect/url.ts +2 -1
  5. package/cli/commands/screenshot.ts +5 -5
  6. package/cli/commands/state.ts +9 -6
  7. package/cli/outbound-endpoints.ts +9 -1
  8. package/cli/output-redaction.ts +49 -0
  9. package/detox/index.ts +0 -1
  10. package/dist-lib/agent-daemon-client.cjs +1 -1
  11. package/dist-lib/agent-events.cjs +1 -1
  12. package/dist-lib/attached-projects.cjs +1 -1
  13. package/dist-lib/auth/shared-session.cjs +1 -1
  14. package/dist-lib/backend-origin.cjs +1 -1
  15. package/dist-lib/beta.cjs +1 -1
  16. package/dist-lib/beta.mjs +1 -1
  17. package/dist-lib/bridge-constants.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.mjs +1 -1
  20. package/dist-lib/bridge-contract.cjs +1 -1
  21. package/dist-lib/bridge-contract.mjs +1 -1
  22. package/dist-lib/bundle-channel.cjs +12772 -1132
  23. package/dist-lib/capture-contract.cjs +1 -1
  24. package/dist-lib/capture-contract.mjs +1 -1
  25. package/dist-lib/cloud-contract.cjs +1 -1
  26. package/dist-lib/cloud-contract.mjs +1 -1
  27. package/dist-lib/cloud-test-args.cjs +1 -1
  28. package/dist-lib/cloud-test-args.mjs +1 -1
  29. package/dist-lib/cloud.cjs +1 -1
  30. package/dist-lib/cloud.mjs +1 -1
  31. package/dist-lib/config.cjs +29 -5
  32. package/dist-lib/config.mjs +29 -5
  33. package/dist-lib/detox/index.cjs +19 -6
  34. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  35. package/dist-lib/expo-swift-bundle.cjs +10411 -73
  36. package/dist-lib/expo-swift-metadata.cjs +1 -1
  37. package/dist-lib/expo-swift-metadata.mjs +1 -1
  38. package/dist-lib/home-paths.cjs +1 -1
  39. package/dist-lib/host/bridge-host.cjs +11220 -670
  40. package/dist-lib/host/fetch-proxy-handler.cjs +260 -197
  41. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  42. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  43. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  44. package/dist-lib/host/websocket-proxy.cjs +1 -1
  45. package/dist-lib/index.cjs +653 -338
  46. package/dist-lib/jump-to-source-babel.cjs +1 -1
  47. package/dist-lib/jump-to-source-native.cjs +1 -1
  48. package/dist-lib/kotlin-host.cjs +443 -312
  49. package/dist-lib/menu.cjs +1 -1
  50. package/dist-lib/menu.mjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  52. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  53. package/dist-lib/metro-production-bundle.cjs +1 -1
  54. package/dist-lib/metro-production-bundle.mjs +1 -1
  55. package/dist-lib/metro.cjs +548 -163
  56. package/dist-lib/native-app-identity-project.cjs +179 -33
  57. package/dist-lib/native-app-identity-project.mjs +179 -33
  58. package/dist-lib/native-app-identity.cjs +1 -1
  59. package/dist-lib/native-app-identity.mjs +1 -1
  60. package/dist-lib/native-firebase-metadata.cjs +1 -1
  61. package/dist-lib/native-firebase-metadata.mjs +1 -1
  62. package/dist-lib/plist.cjs +1 -1
  63. package/dist-lib/plist.mjs +1 -1
  64. package/dist-lib/profiles.cjs +1 -1
  65. package/dist-lib/public-brand.cjs +1 -1
  66. package/dist-lib/public-origins-lib-esm.json +23 -23
  67. package/dist-lib/public-origins-lib.json +96 -63
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  71. package/dist-lib/sdk.cjs +1 -1
  72. package/dist-lib/sdk.mjs +1 -1
  73. package/dist-lib/skills.cjs +12193 -1448
  74. package/dist-lib/swift-compile.cjs +10348 -172
  75. package/dist-lib/swift-compile.mjs +10348 -172
  76. package/dist-lib/swift-package.cjs +1 -1
  77. package/dist-lib/swift-package.mjs +1 -1
  78. package/dist-lib/swift-submit.cjs +1 -1
  79. package/dist-lib/swift-submit.mjs +1 -1
  80. package/dist-lib/swift-toolchain.cjs +1 -1
  81. package/dist-lib/swift.cjs +1 -1
  82. package/dist-lib/vite-swift.cjs +10411 -73
  83. package/dist-lib/vite.cjs +149 -163
  84. package/dist-lib/worklet-executable.cjs +1 -1
  85. package/dist-lib/worklet-executable.mjs +1 -1
  86. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +2 -0
  87. package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +14 -0
  88. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +8 -0
  89. package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -0
  90. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +21 -0
  91. package/dist-types/packages/peach-engine/src/render-worker/gesture-seam-protocol.d.ts +2 -1
  92. package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +1 -1
  93. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -0
  94. package/dist-types/packages/peach-globals/src/index.d.ts +34 -0
  95. package/kotlin/README.md +38 -23
  96. package/kotlin/sdk.tar.gz +0 -0
  97. package/package.json +2 -12
  98. package/runtime-companion.json +1 -1
  99. package/src/bundleGlobalFooter.ts +0 -2
  100. package/src/config.ts +54 -2
  101. package/src/configured-bundle-producer.ts +7 -1
  102. package/src/host/fetch-proxy-handler.ts +14 -50
  103. package/src/host/rolldown-bundle-forward.ts +71 -0
  104. package/src/installed-package-versions.ts +54 -2
  105. package/src/kotlin-host.ts +138 -285
  106. package/src/kotlin-module.ts +4 -7
  107. package/src/kotlin-sdk.ts +81 -0
  108. package/src/kotlin-toolchain.ts +152 -0
  109. package/src/kotlin-view-models.ts +1 -1
  110. package/src/kotlinSdkContract.ts +113 -0
  111. package/src/nitro-adapter.lock.json +3 -3
  112. package/src/nitro-bundle.ts +18 -4
  113. package/src/nitro-compile.ts +5 -1
  114. package/src/nitro-source.ts +112 -28
  115. package/src/nitroContract.ts +16 -4
  116. package/src/stub-pattern-matcher.ts +4 -0
  117. package/src/swift-compile.ts +44 -14
  118. package/src/swift-host.ts +2 -1
  119. package/src/swift-objc-compile.ts +117 -4
  120. package/src/swift-objc-sdk.ts +10215 -59
  121. package/src/swift-objc-standin.ts +5 -2
  122. package/src/vite-plugin-one.ts +73 -134
  123. package/src/worker-system-chunks.ts +14 -4
  124. package/src/xcode-project.ts +261 -34
  125. package/kotlin/AndroidViewSources/android/content/Context.kt +0 -22
  126. package/kotlin/AndroidViewSources/android/content/res/Configuration.kt +0 -25
  127. package/kotlin/AndroidViewSources/android/content/res/Resources.kt +0 -72
  128. package/kotlin/AndroidViewSources/android/graphics/Canvas.kt +0 -22
  129. package/kotlin/AndroidViewSources/android/graphics/Color.kt +0 -13
  130. package/kotlin/AndroidViewSources/android/graphics/Paint.kt +0 -18
  131. package/kotlin/AndroidViewSources/android/util/DisplayMetrics.kt +0 -12
  132. package/kotlin/AndroidViewSources/android/view/View.kt +0 -211
  133. package/kotlin/AndroidViewSources/android/widget/FrameLayout.kt +0 -61
  134. package/kotlin/AndroidViewSources/android/widget/LinearLayout.kt +0 -49
  135. package/kotlin/AndroidViewSources/dev/peach/app/JavaFormat.kt +0 -272
  136. package/kotlin/AppSources/android/app/Activity.kt +0 -174
  137. package/kotlin/AppSources/android/app/Application.kt +0 -11
  138. package/kotlin/AppSources/android/app/UiModeManager.kt +0 -9
  139. package/kotlin/AppSources/android/content/Intent.kt +0 -16
  140. package/kotlin/AppSources/android/os/Bundle.kt +0 -11
  141. package/kotlin/AppSources/android/util/SuperNotCalledException.kt +0 -3
  142. package/kotlin/AppSources/android/view/Window.kt +0 -182
  143. package/kotlin/AppSources/android/view/WindowInsets.kt +0 -9
  144. package/kotlin/AppSources/android/view/WindowInsetsController.kt +0 -17
  145. package/kotlin/AppSources/android/view/WindowManager.kt +0 -16
  146. package/kotlin/AppSources/android/window/BackEvent.kt +0 -24
  147. package/kotlin/AppSources/android/window/OnBackAnimationCallback.kt +0 -7
  148. package/kotlin/AppSources/android/window/OnBackInvokedDispatcher.kt +0 -84
  149. package/kotlin/AppSources/androidx/activity/ActivityFlags.kt +0 -9
  150. package/kotlin/AppSources/androidx/activity/ActivityViewModelLazy.kt +0 -21
  151. package/kotlin/AppSources/androidx/activity/BackEventCompat.kt +0 -43
  152. package/kotlin/AppSources/androidx/activity/ComponentActivity.kt +0 -122
  153. package/kotlin/AppSources/androidx/activity/EdgeToEdge.kt +0 -75
  154. package/kotlin/AppSources/androidx/activity/ExperimentalActivityApi.kt +0 -6
  155. package/kotlin/AppSources/androidx/activity/OnBackPressedCallback.kt +0 -69
  156. package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +0 -144
  157. package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcherOwner.kt +0 -7
  158. package/kotlin/AppSources/androidx/activity/compose/BackHandler.kt +0 -86
  159. package/kotlin/AppSources/androidx/activity/compose/ComponentActivity.kt +0 -29
  160. package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerCompat.kt +0 -38
  161. package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerDispatcherCompat.kt +0 -27
  162. package/kotlin/AppSources/androidx/compose/foundation/layout/WindowInsets.kt +0 -15
  163. package/kotlin/AppSources/androidx/compose/ui/platform/AndroidCompositionLocals.kt +0 -27
  164. package/kotlin/AppSources/androidx/compose/ui/platform/ComposeView.kt +0 -68
  165. package/kotlin/AppSources/androidx/compose/ui/res/ColorResources.kt +0 -16
  166. package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +0 -70
  167. package/kotlin/AppSources/androidx/compose/ui/res/StringResources.kt +0 -38
  168. package/kotlin/AppSources/androidx/core/view/WindowCompat.kt +0 -32
  169. package/kotlin/AppSources/androidx/lifecycle/AndroidViewModel.kt +0 -10
  170. package/kotlin/AppSources/dev/peach/app/PeachApp.kt +0 -388
  171. package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +0 -102
  172. package/kotlin/AppSources/dev/peach/app/PeachWindowHost.kt +0 -14
  173. package/kotlin/CompilerSources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +0 -1
  174. package/kotlin/CompilerSources/PeachJniIncoming.kt +0 -243
  175. package/kotlin/CompilerSources/PeachJniPlugin.kt +0 -116
  176. package/kotlin/ComposeSources/PeachComposeHost.kt +0 -724
  177. package/kotlin/ComposeSources/PeachMagnifier.kt +0 -185
  178. package/kotlin/ComposeSources/PeachSemantics.kt +0 -127
  179. package/kotlin/ExpoComposeSources/PeachAndroidView.kt +0 -103
  180. package/kotlin/ExpoComposeSources/PeachExpoViewMount.kt +0 -24
  181. package/kotlin/ExpoComposeSources/dev/peach/expo/PeachExpoCompose.kt +0 -28
  182. package/kotlin/ExpoComposeSources/expo/modules/kotlin/views/ExpoComposeView.kt +0 -70
  183. package/kotlin/ExpoSources/dev/peach/expo/PeachExpoRuntime.kt +0 -516
  184. package/kotlin/ExpoSources/dev/peach/expo/PeachExpoTypes.kt +0 -173
  185. package/kotlin/ExpoSources/expo/modules/kotlin/AppContext.kt +0 -20
  186. package/kotlin/ExpoSources/expo/modules/kotlin/Promise.kt +0 -19
  187. package/kotlin/ExpoSources/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +0 -198
  188. package/kotlin/ExpoSources/expo/modules/kotlin/exception/CodedException.kt +0 -126
  189. package/kotlin/ExpoSources/expo/modules/kotlin/functions/Functions.kt +0 -132
  190. package/kotlin/ExpoSources/expo/modules/kotlin/jni/JavaScriptTypedArray.kt +0 -81
  191. package/kotlin/ExpoSources/expo/modules/kotlin/modules/Module.kt +0 -98
  192. package/kotlin/ExpoSources/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +0 -236
  193. package/kotlin/ExpoSources/expo/modules/kotlin/records/Record.kt +0 -12
  194. package/kotlin/ExpoSources/expo/modules/kotlin/runtime/Runtime.kt +0 -9
  195. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObject.kt +0 -50
  196. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +0 -57
  197. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedRef.kt +0 -19
  198. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/ConcreteTypedArrays.kt +0 -158
  199. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/GenericTypedArray.kt +0 -8
  200. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArray.kt +0 -29
  201. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArrayIterator.kt +0 -9
  202. package/kotlin/ExpoSources/expo/modules/kotlin/types/AnyType.kt +0 -155
  203. package/kotlin/ExpoSources/expo/modules/kotlin/types/Either.kt +0 -91
  204. package/kotlin/ExpoSources/expo/modules/kotlin/types/Enumerable.kt +0 -6
  205. package/kotlin/ExpoSources/expo/modules/kotlin/viewevent/ViewEvent.kt +0 -68
  206. package/kotlin/ExpoSources/expo/modules/kotlin/views/ExpoView.kt +0 -20
  207. package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +0 -72
  208. package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewProps.kt +0 -36
  209. package/kotlin/JniPlatformSources/androidx/annotation/CallSuper.kt +0 -5
  210. package/kotlin/JniPlatformSources/com/facebook/proguard/annotations/DoNotStrip.kt +0 -5
  211. package/kotlin/JniPlatformSources/dalvik/annotation/optimization/FastNative.kt +0 -5
  212. package/kotlin/JniPlatformSources/kotlin/Synchronized.kt +0 -6
  213. package/kotlin/JniPlatformSources/kotlin/jvm/JvmField.kt +0 -5
  214. package/kotlin/JniPlatformSources/kotlin/jvm/JvmStatic.kt +0 -5
  215. package/kotlin/JniSources/com/facebook/jni/HybridData.kt +0 -66
  216. package/kotlin/JniSources/dev/peach/jni/IncomingBindings.kt +0 -157
  217. package/kotlin/JniSources/dev/peach/jni/NativeBindings.kt +0 -77
  218. package/kotlin/JniTransportSources/dev/peach/jni/integration/JniTransport.kt +0 -89
  219. package/kotlin/Sources/android/os/Build.kt +0 -17
  220. package/kotlin/Sources/android/os/Handler.kt +0 -35
  221. package/kotlin/Sources/android/os/Looper.kt +0 -17
  222. package/kotlin/Sources/android/os/MessageQueue.kt +0 -56
  223. package/kotlin/Sources/android/os/SystemClock.kt +0 -14
  224. package/kotlin/Sources/android/util/Log.kt +0 -64
  225. package/kotlin/Sources/androidx/annotation/DrawableRes.kt +0 -14
  226. package/kotlin/Sources/androidx/annotation/Keep.kt +0 -4
  227. package/kotlin/Sources/dev/onejs/one/OneNativeSourceDispatch.kt +0 -7
  228. package/kotlin/Sources/dev/onejs/one/OneNativeSourceViewDispatch.kt +0 -13
  229. package/kotlin/Sources/dev/onejs/one/source/OneModule.kt +0 -4
  230. package/kotlin/Sources/java/lang/Runnable.kt +0 -6
  231. package/kotlin/Sources/java/security/MessageDigest.kt +0 -114
  232. package/kotlin/Sources/java/util/IllegalFormatCodePointException.kt +0 -10
  233. package/kotlin/Sources/java/util/IllegalFormatException.kt +0 -5
  234. package/kotlin/Sources/kotlin/text/StringFormat.kt +0 -9
  235. package/kotlin/Sources/org/json/JSON.kt +0 -307
  236. package/kotlin/tools/abi-classes.main.kts +0 -41
  237. package/kotlin/tools/expo-types.main.kts +0 -127
@@ -1,185 +0,0 @@
1
- @file:OptIn(androidx.compose.ui.InternalComposeUiApi::class)
2
-
3
- import androidx.compose.foundation.PlatformMagnifier
4
- import androidx.compose.foundation.PlatformMagnifierFactory
5
- import androidx.compose.ui.geometry.Offset
6
- import androidx.compose.ui.geometry.isSpecified
7
- import androidx.compose.ui.platform.PlatformWindowInsets
8
- import androidx.compose.ui.unit.Density
9
- import androidx.compose.ui.unit.Dp
10
- import androidx.compose.ui.unit.DpSize
11
- import androidx.compose.ui.unit.IntSize
12
- import kotlin.math.floor
13
- import kotlin.math.roundToInt
14
- import org.jetbrains.skia.Canvas
15
- import org.jetbrains.skia.Color
16
- import org.jetbrains.skia.FilterMipmap
17
- import org.jetbrains.skia.FilterMode
18
- import org.jetbrains.skia.MipmapMode
19
- import org.jetbrains.skia.Paint
20
- import org.jetbrains.skia.PathBuilder
21
- import org.jetbrains.skia.Picture
22
- import org.jetbrains.skia.PictureRecorder
23
- import org.jetbrains.skia.Point3
24
- import org.jetbrains.skia.RRect
25
- import org.jetbrains.skia.Rect
26
- import org.jetbrains.skia.ShadowUtils
27
- import org.jetbrains.skia.Surface
28
- import org.jetbrains.skia.impl.use
29
-
30
- // android api 37: frameworks/base 94b4c163b7dfe5ce3607f7bb8456f9573f7de57d,
31
- // Magnifier.java, Widget.Magnifier, default_magnifier_* and config_dialogCornerRadius.
32
- // the androidx api 29 adapter uses the old constructor for text and Builder otherwise.
33
- internal class PeachMagnifierFactory(
34
- private val insets: PlatformWindowInsets,
35
- private val invalidate: () -> Unit,
36
- ) : PlatformMagnifierFactory, AutoCloseable {
37
- override val canUpdateZoom = true
38
- private val shown = linkedSetOf<Magnifier>()
39
- private var closed = false
40
- val hasOverlays: Boolean get() = shown.isNotEmpty()
41
-
42
- override fun create(
43
- useTextDefault: Boolean,
44
- size: DpSize,
45
- cornerRadius: Dp,
46
- elevation: Dp,
47
- clippingEnabled: Boolean,
48
- density: Density,
49
- initialZoom: Float,
50
- ): PlatformMagnifier {
51
- check(!closed)
52
- // TypedValue.complexToDimensionPixelSize rounds away from zero at a half pixel.
53
- fun pixels(dp: Float): Int {
54
- val value = dp * density.density
55
- return (if (value >= 0f) value + 0.5f else value - 0.5f).toInt()
56
- }
57
- val width = if (useTextDefault || size == DpSize.Unspecified) pixels(100f)
58
- else with(density) { size.width.toPx() }.roundToInt()
59
- val height = if (useTextDefault || size == DpSize.Unspecified) pixels(48f)
60
- else with(density) { size.height.toPx() }.roundToInt()
61
- val radius = if (useTextDefault) 28f * density.density
62
- else if (cornerRadius.value.isNaN()) 2f * density.density
63
- else with(density) { cornerRadius.toPx() }
64
- val z = if (useTextDefault || elevation.value.isNaN()) 4f * density.density
65
- else with(density) { elevation.toPx() }
66
- val zoom = if (useTextDefault || initialZoom.isNaN()) 1.25f else initialZoom
67
- require(width > 0 && height > 0 && radius >= 0f && z >= 0f && zoom > 0f)
68
- return Magnifier(IntSize(width, height), radius, z, density.density,
69
- useTextDefault || clippingEnabled, pixels(-42f), useTextDefault, zoom)
70
- }
71
-
72
- // base contains only compose content. no instance can retain or sample the final picture.
73
- fun compose(base: Picture, viewport: IntSize): Picture {
74
- val recorder = PictureRecorder()
75
- try {
76
- val canvas = recorder.beginRecording(Rect.makeWH(
77
- viewport.width.coerceAtLeast(1).toFloat(), viewport.height.coerceAtLeast(1).toFloat(),
78
- ))
79
- canvas.drawPicture(base)
80
- shown.toList().forEach { it.draw(canvas, base, viewport) }
81
- return recorder.finishRecordingAsPicture()
82
- } finally { recorder.close() }
83
- }
84
-
85
- override fun close() {
86
- closed = true
87
- shown.clear()
88
- }
89
-
90
- private inner class Magnifier(
91
- override val size: IntSize,
92
- private val radius: Float,
93
- private val elevation: Float,
94
- private val density: Float,
95
- private val clipping: Boolean,
96
- private val defaultOffsetY: Int,
97
- private val textDefault: Boolean,
98
- private var zoom: Float,
99
- ) : PlatformMagnifier {
100
- private var source = Offset.Unspecified
101
- private var center = Offset.Unspecified
102
-
103
- override fun updateContent() {
104
- if (!closed && this in shown) invalidate()
105
- }
106
-
107
- override fun update(sourceCenter: Offset, magnifierCenter: Offset, zoom: Float) {
108
- if (closed) return
109
- if (!zoom.isNaN()) {
110
- require(zoom > 0f)
111
- this.zoom = zoom
112
- }
113
- source = sourceCenter
114
- center = magnifierCenter
115
- shown.add(this)
116
- invalidate()
117
- }
118
-
119
- override fun dismiss() {
120
- if (shown.remove(this)) invalidate()
121
- }
122
-
123
- fun draw(canvas: Canvas, base: Picture, viewport: IntSize) {
124
- val sourceWidth = (size.width / zoom).roundToInt()
125
- val sourceHeight = (size.height / zoom).roundToInt()
126
- // PixelCopy fails and dismisses when the requested source exceeds its surface.
127
- if (sourceWidth <= 0 || sourceHeight <= 0 || sourceWidth > viewport.width ||
128
- sourceHeight > viewport.height || !source.isSpecified) {
129
- dismiss()
130
- return
131
- }
132
- // java Math.round, integer halves and max/min order match Magnifier.java.
133
- fun round(value: Float) = floor(value + 0.5f).toInt()
134
- val sourceX = maxOf(sourceWidth / 2, minOf(round(source.x), viewport.width - sourceWidth / 2)) - sourceWidth / 2
135
- val sourceY = maxOf(sourceHeight / 2, minOf(round(source.y), viewport.height - sourceHeight / 2)) - sourceHeight / 2
136
- val requested = if (center.isSpecified) center else Offset(source.x, source.y + defaultOffsetY)
137
- var x = round(requested.x) - size.width / 2
138
- var y = round(requested.y) - size.height / 2
139
- if (clipping) {
140
- x = maxOf(insets.systemBars.left, minOf(viewport.width - insets.systemBars.right - size.width, x))
141
- y = maxOf(insets.systemBars.top, minOf(viewport.height - insets.systemBars.bottom - size.height, y))
142
- }
143
- val window = RRect.makeXYWH(x.toFloat(), y.toFloat(), size.width.toFloat(), size.height.toFloat(), radius)
144
- // SimpleRenderer lights the popup from display space, not from its moving origin.
145
- if (elevation > 0f) {
146
- val saved = canvas.save()
147
- try {
148
- // InternalPopupWindow allocates this much surface space for its shadow.
149
- val padding = (1.05f * elevation).toInt()
150
- canvas.clipRect(Rect.makeXYWH((x - padding).toFloat(), (y - padding).toFloat(),
151
- (size.width + 2 * padding).toFloat(), (size.height + 2 * padding).toFloat()))
152
- PathBuilder().use { builder ->
153
- builder.addRRect(window)
154
- builder.detach().use { outline ->
155
- val zRatio = minOf(viewport.width, viewport.height) / (450f * density)
156
- ShadowUtils.drawShadow(canvas, outline, Point3(0f, 0f, elevation),
157
- Point3(viewport.width / 2f, 0f, 500f * density * (zRatio + 2f) / 3f),
158
- 800f * density, 0x09000000, 0x30000000, false, false)
159
- }
160
- }
161
- } finally { canvas.restoreToCount(saved) }
162
- }
163
- // copy at physical pixel resolution before linear bitmap scaling, as PixelCopy does.
164
- Surface.makeRasterN32Premul(sourceWidth, sourceHeight).use { surface ->
165
- surface.canvas.clear(Color.TRANSPARENT)
166
- surface.canvas.translate(-sourceX.toFloat(), -sourceY.toFloat())
167
- surface.canvas.drawPicture(base)
168
- surface.makeImageSnapshot().use { image ->
169
- val saved = canvas.save()
170
- try {
171
- canvas.clipRRect(window, true)
172
- Paint().use { paint ->
173
- canvas.drawImageRect(image, Rect.makeWH(sourceWidth.toFloat(), sourceHeight.toFloat()),
174
- window, FilterMipmap(FilterMode.LINEAR, MipmapMode.NONE), paint, true)
175
- if (textDefault) {
176
- paint.color = 0x0effffff
177
- canvas.drawRRect(window, paint)
178
- }
179
- }
180
- } finally { canvas.restoreToCount(saved) }
181
- }
182
- }
183
- }
184
- }
185
- }
@@ -1,127 +0,0 @@
1
- // the accessibility delegate's internal reads (replacedChildren, isFake,
2
- // unmergedConfig, isHidden, getAllUncoveredSemanticsNodesToIntObjectMap) are
3
- // common compose code that ships in the web build; android reaches them from
4
- // inside the module, so this file reads the same functions rather than a copy
5
- @file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
6
-
7
- import androidx.compose.ui.semantics.AdjustedSemanticsNode
8
- import androidx.compose.ui.semantics.Role
9
- import androidx.compose.ui.semantics.SemanticsActions
10
- import androidx.compose.ui.semantics.SemanticsNode
11
- import androidx.compose.ui.semantics.SemanticsOwner
12
- import androidx.compose.ui.semantics.SemanticsProperties
13
- import androidx.compose.ui.semantics.getAllUncoveredSemanticsNodesToIntObjectMap
14
- import androidx.compose.ui.semantics.getOrNull
15
- import androidx.compose.ui.semantics.isHidden
16
- import androidx.compose.ui.state.ToggleableState
17
- import org.json.JSONArray
18
- import org.json.JSONObject
19
-
20
- // AndroidComposeViewAccessibilityDelegateCompat's virtual view tree for one
21
- // owner, as uiautomator reads it: the nodes the uncovered map keeps, each at
22
- // its adjusted bounds in root pixels, linked through replacedChildren, with
23
- // the properties populateAccessibilityNodeInfoProperties sets. the root is
24
- // the host view's own node
25
- internal fun accessibilityNodes(owner: SemanticsOwner, out: JSONArray) {
26
- val root = owner.unmergedRootSemanticsNode
27
- val nodes = owner.getAllUncoveredSemanticsNodesToIntObjectMap(root.id) { it.isAccessibilityIgnoredLink }
28
- fun emit(node: SemanticsNode, parent: Int?) {
29
- val adjusted = nodes[node.id] ?: return
30
- out.put(nodeInfo(node, adjusted, parent))
31
- node.replacedChildren.forEach { if (nodes.containsKey(it.id)) emit(it, node.id) }
32
- }
33
- emit(root, null)
34
- }
35
-
36
- private val SemanticsNode.isAccessibilityIgnoredLink: Boolean
37
- get() = config.contains(SemanticsProperties.LinkTestMarker)
38
-
39
- // SemanticsUtils.android.kt's toLegacyClassName
40
- private fun Role.legacyClassName(): String? = when (this) {
41
- Role.Button -> "android.widget.Button"
42
- Role.Checkbox -> "android.widget.CheckBox"
43
- Role.RadioButton -> "android.widget.RadioButton"
44
- Role.Image -> "android.widget.ImageView"
45
- Role.DropdownList -> "android.widget.Spinner"
46
- Role.ValuePicker -> "android.widget.NumberPicker"
47
- else -> null
48
- }
49
-
50
- private val SemanticsNode.isUnmergedLeafNode: Boolean
51
- get() {
52
- if (isFake) return false
53
- replacedChildren.forEach { if (!it.isAccessibilityIgnoredLink) return false }
54
- // the closest layout ancestor carrying a merging semantics
55
- // configuration is the closest merging semantics parent
56
- var parent = parent
57
- while (parent != null) {
58
- if (parent.unmergedConfig.isMergingSemanticsOfDescendants) return false
59
- parent = parent.parent
60
- }
61
- return true
62
- }
63
-
64
- private fun nodeInfo(node: SemanticsNode, adjusted: AdjustedSemanticsNode, parent: Int?): JSONObject {
65
- val config = node.unmergedConfig
66
- val role = config.getOrNull(SemanticsProperties.Role)
67
- // the text class first, so a role's class wins over it
68
- var className = "android.view.View"
69
- if (config.contains(SemanticsProperties.EditableText)) className = "android.widget.EditText"
70
- if (config.contains(SemanticsProperties.Text)) className = "android.widget.TextView"
71
- if (role != null && role != Role.Tab && role != Role.Switch && (node.isFake || node.replacedChildren.isEmpty())) {
72
- val legacy = role.legacyClassName()
73
- if (legacy != null && (role != Role.Image || node.isUnmergedLeafNode || config.isMergingSemanticsOfDescendants)) {
74
- className = legacy
75
- }
76
- }
77
- // the delegate sets range and scroll classes after the role's
78
- if (config.contains(SemanticsProperties.ProgressBarRangeInfo)) {
79
- className =
80
- if (config.contains(SemanticsActions.SetProgress)) "android.widget.SeekBar"
81
- else "android.widget.ProgressBar"
82
- }
83
- // CollectionInfo.android.kt's hasCollectionInfo, on the merged config
84
- val collection = node.config.contains(SemanticsProperties.CollectionInfo) ||
85
- node.config.contains(SemanticsProperties.SelectableGroup)
86
- if (config.contains(SemanticsActions.ScrollBy) && !collection) {
87
- if (config.contains(SemanticsProperties.HorizontalScrollAxisRange)) {
88
- className = "android.widget.HorizontalScrollView"
89
- }
90
- if (config.contains(SemanticsProperties.VerticalScrollAxisRange)) {
91
- className = "android.widget.ScrollView"
92
- }
93
- }
94
- val text = config.getOrNull(SemanticsProperties.EditableText)?.text
95
- ?: config.getOrNull(SemanticsProperties.Text)?.firstOrNull()?.text
96
- val description =
97
- if (!config.isMergingSemanticsOfDescendants || node.replacedChildren.isEmpty())
98
- config.getOrNull(SemanticsProperties.ContentDescription)?.firstOrNull()
99
- else null
100
- val selected = config.getOrNull(SemanticsProperties.Selected)
101
- // a tab reports selected; any other role reports selected as checked
102
- val checked = when (config.getOrNull(SemanticsProperties.ToggleableState)) {
103
- ToggleableState.On -> true
104
- ToggleableState.Off -> false
105
- else -> if (role != Role.Tab) selected else null
106
- }
107
- val clickable = config.getOrNull(SemanticsActions.OnClick) != null &&
108
- !((role == Role.Tab || role == Role.RadioButton) && selected == true)
109
- val bounds = adjusted.adjustedBounds
110
- return JSONObject()
111
- .put("id", node.id)
112
- .put("parent", parent ?: JSONObject.NULL)
113
- .put("className", className)
114
- .put("role", role?.toString() ?: JSONObject.NULL)
115
- .put("text", text ?: JSONObject.NULL)
116
- .put("contentDescription", description ?: JSONObject.NULL)
117
- .put("testTag", config.getOrNull(SemanticsProperties.TestTag) ?: JSONObject.NULL)
118
- .put("clickable", clickable)
119
- .put("longClickable", config.getOrNull(SemanticsActions.OnLongClick) != null)
120
- .put("focusable", config.contains(SemanticsProperties.Focused))
121
- .put("focused", config.getOrNull(SemanticsProperties.Focused) == true)
122
- .put("enabled", !node.config.contains(SemanticsProperties.Disabled))
123
- .put("checked", checked ?: JSONObject.NULL)
124
- .put("selected", if (role == Role.Tab) selected ?: false else false)
125
- .put("visible", !(node.isHidden || adjusted.isInMergingHiddenSubtree))
126
- .put("bounds", JSONArray().put(bounds.left).put(bounds.top).put(bounds.right).put(bounds.bottom))
127
- }
@@ -1,103 +0,0 @@
1
- import android.graphics.Canvas
2
- import android.graphics.Paint as AndroidPaint
3
- import android.graphics.ViewCanvas
4
- import android.view.View
5
- import androidx.compose.runtime.Composable
6
- import androidx.compose.runtime.DisposableEffect
7
- import androidx.compose.runtime.getValue
8
- import androidx.compose.runtime.mutableIntStateOf
9
- import androidx.compose.runtime.remember
10
- import androidx.compose.runtime.setValue
11
- import androidx.compose.ui.Modifier
12
- import androidx.compose.foundation.layout.fillMaxSize
13
- import androidx.compose.ui.draw.drawWithContent
14
- import androidx.compose.ui.graphics.drawscope.clipRect
15
- import androidx.compose.ui.graphics.nativeCanvas
16
- import androidx.compose.ui.layout.Layout
17
- import androidx.compose.ui.unit.constrainWidth
18
- import androidx.compose.ui.unit.constrainHeight
19
- import org.jetbrains.skia.Paint
20
- import org.jetbrains.skia.PaintMode
21
- import org.jetbrains.skia.Rect
22
-
23
- // the Android view tree draws into the same Skia picture as a compose view.
24
- // invalidation schedules drawing; requestLayout also schedules measurement.
25
- @Composable
26
- internal fun PeachAndroidView(view: View) {
27
- var drawRevision by remember(view) { mutableIntStateOf(0) }
28
- var layoutRevision by remember(view) { mutableIntStateOf(0) }
29
- DisposableEffect(view) {
30
- view.invalidateHost = { layout ->
31
- drawRevision++
32
- if (layout) layoutRevision++
33
- }
34
- view.dispatchAttachedToWindow(Any())
35
- onDispose {
36
- view.dispatchDetachedFromWindow()
37
- view.invalidateHost = null
38
- }
39
- }
40
- Layout(content = {}, modifier = Modifier.fillMaxSize().drawWithContent {
41
- drawRevision
42
- clipRect {
43
- val native = drawContext.canvas.nativeCanvas
44
- view.draw(Canvas(object : ViewCanvas {
45
- private var offsetX = 0f
46
- private var offsetY = 0f
47
- private var clip = Rect.makeWH(view.width.toFloat(), view.height.toFloat())
48
- private val saves = mutableMapOf<Int, Triple<Float, Float, Rect>>()
49
- override fun drawColor(color: Int) {
50
- val paint = Paint()
51
- try { paint.color = color; native.drawPaint(paint) } finally { paint.close() }
52
- }
53
- override fun drawCircle(cx: Float, cy: Float, radius: Float, paint: AndroidPaint) {
54
- val nativePaint = Paint()
55
- try {
56
- nativePaint.color = paint.color
57
- nativePaint.mode = when (paint.style) {
58
- AndroidPaint.Style.FILL -> PaintMode.FILL
59
- AndroidPaint.Style.STROKE -> PaintMode.STROKE
60
- AndroidPaint.Style.FILL_AND_STROKE -> PaintMode.STROKE_AND_FILL
61
- }
62
- nativePaint.strokeWidth = paint.strokeWidth
63
- nativePaint.isAntiAlias = paint.isAntiAlias
64
- native.drawCircle(cx, cy, radius, nativePaint)
65
- } finally { nativePaint.close() }
66
- }
67
- override fun save(): Int {
68
- val count = native.save()
69
- saves[count] = Triple(offsetX, offsetY, clip)
70
- return count
71
- }
72
- override fun restoreToCount(count: Int) {
73
- native.restoreToCount(count)
74
- val state = checkNotNull(saves[count])
75
- offsetX = state.first; offsetY = state.second; clip = state.third
76
- saves.keys.filter { it >= count }.forEach { saves.remove(it) }
77
- }
78
- override fun translate(dx: Float, dy: Float) {
79
- offsetX += dx; offsetY += dy
80
- native.translate(dx, dy)
81
- }
82
- override fun clipRect(left: Float, top: Float, right: Float, bottom: Float): Boolean {
83
- native.clipRect(Rect.makeLTRB(left, top, right, bottom))
84
- clip = Rect.makeLTRB(maxOf(clip.left, left + offsetX), maxOf(clip.top, top + offsetY),
85
- minOf(clip.right, right + offsetX), minOf(clip.bottom, bottom + offsetY))
86
- return clip.left < clip.right && clip.top < clip.bottom
87
- }
88
- }))
89
- }
90
- }) { _, constraints ->
91
- layoutRevision
92
- fun spec(min: Int, max: Int, bounded: Boolean): Int = when {
93
- min == max -> View.MeasureSpec.makeMeasureSpec(max, View.MeasureSpec.EXACTLY)
94
- bounded -> View.MeasureSpec.makeMeasureSpec(max, View.MeasureSpec.AT_MOST)
95
- else -> View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
96
- }
97
- view.measure(spec(constraints.minWidth, constraints.maxWidth, constraints.hasBoundedWidth),
98
- spec(constraints.minHeight, constraints.maxHeight, constraints.hasBoundedHeight))
99
- val width = constraints.constrainWidth(view.measuredWidth)
100
- val height = constraints.constrainHeight(view.measuredHeight)
101
- layout(width, height) { view.layout(0, 0, width, height) }
102
- }
103
- }
@@ -1,24 +0,0 @@
1
- @file:OptIn(kotlin.js.ExperimentalJsExport::class, androidx.compose.ui.ExperimentalComposeUiApi::class, androidx.compose.ui.InternalComposeUiApi::class)
2
-
3
- import dev.peach.expo.PeachExpoRuntime
4
- import expo.modules.kotlin.views.ExpoComposeView
5
- import org.json.JSONObject
6
-
7
- // one mounted Expo view as the native scene the tenant presents. the
8
- // view already exists: its first props created it
9
- @JsExport
10
- fun peachExpoViewMount(id: String, density: Float, fontScale: Float, locale: String, night: Boolean,
11
- font: String, invalidate: (Boolean) -> Unit): String {
12
- try {
13
- val view = PeachExpoRuntime.mountedView(id)
14
- if (view is ExpoComposeView<*>) view.validateHostingAncestor()
15
- preparePeachDevice(locale)
16
- val mount = PeachComposeMount(density, fontScale, locale, robotoFamily(font), invalidate, night)
17
- mount.setContent {
18
- if (view is ExpoComposeView<*>) view.HostedContent() else PeachAndroidView(view)
19
- }
20
- return JSONObject().put("ok", true).put("id", addMount(mount)).toString()
21
- } catch (error: Throwable) {
22
- return JSONObject().put("ok", false).put("code", "E_EXPO_VIEW").put("error", "Expo view $id: ${error.message}").toString()
23
- }
24
- }
@@ -1,28 +0,0 @@
1
- @file:Suppress("UNCHECKED_CAST")
2
-
3
- package dev.peach.expo
4
-
5
- import android.view.View
6
- import androidx.compose.runtime.MutableState
7
- import expo.modules.kotlin.exception.PropSetException
8
- import expo.modules.kotlin.exception.exceptionDecorator
9
- import expo.modules.kotlin.types.AnyType
10
- import expo.modules.kotlin.types.toAnyType
11
- import expo.modules.kotlin.views.AnyViewProp
12
- import expo.modules.kotlin.views.ExpoComposeView
13
-
14
- // a compose view's MutableState prop: a new value replaces the state's, as
15
- // ComposeViewProp sets it, so the content recomposes
16
- class ComposeStateProp(name: String, type: AnyType, private val write: (Any, Any?) -> Unit) : AnyViewProp(name, type) {
17
- override fun set(prop: Any?, onView: View) {
18
- exceptionDecorator({ PropSetException(name, onView::class, it) }) {
19
- val props = (onView as ExpoComposeView<*>).props ?: return
20
- write(props, type.convert(prop))
21
- }
22
- }
23
- }
24
-
25
- object PeachExpoCompose {
26
- inline fun <P : Any, reified T> prop(name: String, noinline state: (P) -> MutableState<T>): AnyViewProp =
27
- ComposeStateProp(name, toAnyType<T>()) { props, value -> state(props as P).value = value as T }
28
- }
@@ -1,70 +0,0 @@
1
- package expo.modules.kotlin.views
2
-
3
- import android.content.Context
4
- import android.util.Log
5
- import androidx.compose.runtime.Composable
6
- import expo.modules.kotlin.AppContext
7
- import expo.modules.kotlin.exception.CodedException
8
- import expo.modules.kotlin.viewevent.ViewEvent
9
-
10
- // a scope passed through the compose view hierarchy
11
- interface ComposableScope
12
-
13
- private object EmptyComposableScope : ComposableScope
14
-
15
- fun ComposableScope(): ComposableScope = EmptyComposableScope
16
-
17
- inline fun <T : ComposableScope> T.withIf(condition: Boolean, block: T.() -> T): T =
18
- if (condition) block() else this
19
-
20
- // a marker for the classes that carry a compose view's props
21
- interface ComposeProps
22
-
23
- @Target(AnnotationTarget.CLASS)
24
- @Retention(AnnotationRetention.BINARY)
25
- annotation class OptimizedComposeProps
26
-
27
- // the name for the global event dispatcher
28
- internal const val GLOBAL_EVENT_NAME = "onGlobalEvent"
29
-
30
- // a compose view. one with a hosting view composes its own content in a
31
- // ComposeView, which Peach presents as one compose scene; one without renders
32
- // only inside a compose parent, which Peach has no React Native children for
33
- // yet, so it stays hidden and logs the missing host, as upstream does when its
34
- // parent is not a compose view
35
- abstract class ExpoComposeView<T : ComposeProps>(
36
- context: Context,
37
- appContext: AppContext,
38
- private val withHostingView: Boolean = false,
39
- ) : ExpoView(context, appContext) {
40
- open val props: T? = null
41
-
42
- private val globalEvent by lazy { ViewEvent<Pair<String, Map<String, Any?>>>(GLOBAL_EVENT_NAME, this, null) }
43
-
44
- val globalEventDispatcher: (String, Map<String, Any?>) -> Unit = { name, params ->
45
- globalEvent.invoke(Pair(name, params))
46
- }
47
-
48
- @Composable
49
- abstract fun ComposableScope.Content()
50
-
51
- override val shouldUseAndroidLayout = withHostingView
52
-
53
- @Composable
54
- internal fun HostedContent() {
55
- if (withHostingView) with(ComposableScope()) { Content() }
56
- }
57
-
58
- internal fun validateHostingAncestor() {
59
- if (withHostingView) return
60
- Log.e("ExpoComposeView", "", MissingHostException(this::class.simpleName ?: "ExpoComposeView"))
61
- }
62
- }
63
-
64
- internal class MissingHostException(componentName: String) :
65
- CodedException(
66
- "A Jetpack Compose view \"$componentName\" must be rendered as a direct child of a <Host> component. " +
67
- "Wrap your component with `<Host>` from '@expo/ui/jetpack-compose'. " +
68
- "Note that inserting another `<View>` (or any non-Compose ViewGroup) between `<Host>` and this " +
69
- "component breaks the Compose composition boundary and will still trigger this error."
70
- )