peachsim 0.1.1655 → 0.1.1659

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 (235) 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/dist-lib/agent-daemon-client.cjs +1 -1
  10. package/dist-lib/agent-events.cjs +1 -1
  11. package/dist-lib/attached-projects.cjs +1 -1
  12. package/dist-lib/auth/shared-session.cjs +1 -1
  13. package/dist-lib/backend-origin.cjs +1 -1
  14. package/dist-lib/beta.cjs +1 -1
  15. package/dist-lib/beta.mjs +1 -1
  16. package/dist-lib/bridge-constants.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.mjs +1 -1
  19. package/dist-lib/bridge-contract.cjs +1 -1
  20. package/dist-lib/bridge-contract.mjs +1 -1
  21. package/dist-lib/bundle-channel.cjs +11251 -1123
  22. package/dist-lib/capture-contract.cjs +1 -1
  23. package/dist-lib/capture-contract.mjs +1 -1
  24. package/dist-lib/cloud-contract.cjs +1 -1
  25. package/dist-lib/cloud-contract.mjs +1 -1
  26. package/dist-lib/cloud-test-args.cjs +1 -1
  27. package/dist-lib/cloud-test-args.mjs +1 -1
  28. package/dist-lib/cloud.cjs +1 -1
  29. package/dist-lib/cloud.mjs +1 -1
  30. package/dist-lib/config.cjs +29 -5
  31. package/dist-lib/config.mjs +29 -5
  32. package/dist-lib/detox/index.cjs +19 -5
  33. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  34. package/dist-lib/expo-swift-bundle.cjs +8960 -134
  35. package/dist-lib/expo-swift-metadata.cjs +1 -1
  36. package/dist-lib/expo-swift-metadata.mjs +1 -1
  37. package/dist-lib/home-paths.cjs +1 -1
  38. package/dist-lib/host/bridge-host.cjs +9769 -731
  39. package/dist-lib/host/fetch-proxy-handler.cjs +260 -197
  40. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  41. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  42. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  43. package/dist-lib/host/websocket-proxy.cjs +1 -1
  44. package/dist-lib/index.cjs +653 -338
  45. package/dist-lib/jump-to-source-babel.cjs +1 -1
  46. package/dist-lib/jump-to-source-native.cjs +1 -1
  47. package/dist-lib/kotlin-host.cjs +443 -312
  48. package/dist-lib/menu.cjs +1 -1
  49. package/dist-lib/menu.mjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  52. package/dist-lib/metro-production-bundle.cjs +1 -1
  53. package/dist-lib/metro-production-bundle.mjs +1 -1
  54. package/dist-lib/metro.cjs +548 -163
  55. package/dist-lib/native-app-identity-project.cjs +179 -33
  56. package/dist-lib/native-app-identity-project.mjs +179 -33
  57. package/dist-lib/native-app-identity.cjs +1 -1
  58. package/dist-lib/native-app-identity.mjs +1 -1
  59. package/dist-lib/native-firebase-metadata.cjs +1 -1
  60. package/dist-lib/native-firebase-metadata.mjs +1 -1
  61. package/dist-lib/plist.cjs +1 -1
  62. package/dist-lib/plist.mjs +1 -1
  63. package/dist-lib/profiles.cjs +1 -1
  64. package/dist-lib/public-brand.cjs +1 -1
  65. package/dist-lib/public-origins-lib-esm.json +23 -23
  66. package/dist-lib/public-origins-lib.json +96 -63
  67. package/dist-lib/react-native-host-modules.cjs +1 -1
  68. package/dist-lib/react-native-host-modules.mjs +1 -1
  69. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  70. package/dist-lib/sdk.cjs +1 -1
  71. package/dist-lib/sdk.mjs +1 -1
  72. package/dist-lib/skills.cjs +10651 -1418
  73. package/dist-lib/swift-compile.cjs +8802 -138
  74. package/dist-lib/swift-compile.mjs +8802 -138
  75. package/dist-lib/swift-package.cjs +1 -1
  76. package/dist-lib/swift-package.mjs +1 -1
  77. package/dist-lib/swift-submit.cjs +1 -1
  78. package/dist-lib/swift-submit.mjs +1 -1
  79. package/dist-lib/swift-toolchain.cjs +1 -1
  80. package/dist-lib/swift.cjs +1 -1
  81. package/dist-lib/vite-swift.cjs +8960 -134
  82. package/dist-lib/vite.cjs +149 -163
  83. package/dist-lib/worklet-executable.cjs +1 -1
  84. package/dist-lib/worklet-executable.mjs +1 -1
  85. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +1 -0
  86. package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +14 -0
  87. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +8 -0
  88. package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -0
  89. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +21 -0
  90. package/dist-types/packages/peach-engine/src/render-worker/gesture-seam-protocol.d.ts +2 -1
  91. package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +1 -1
  92. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -0
  93. package/dist-types/packages/peach-globals/src/index.d.ts +25 -0
  94. package/kotlin/README.md +38 -23
  95. package/kotlin/sdk.tar.gz +0 -0
  96. package/package.json +2 -12
  97. package/runtime-companion.json +1 -1
  98. package/src/bundleGlobalFooter.ts +0 -2
  99. package/src/config.ts +54 -2
  100. package/src/configured-bundle-producer.ts +7 -1
  101. package/src/host/fetch-proxy-handler.ts +14 -50
  102. package/src/host/rolldown-bundle-forward.ts +71 -0
  103. package/src/installed-package-versions.ts +54 -2
  104. package/src/kotlin-host.ts +138 -285
  105. package/src/kotlin-module.ts +4 -7
  106. package/src/kotlin-sdk.ts +81 -0
  107. package/src/kotlin-toolchain.ts +152 -0
  108. package/src/kotlin-view-models.ts +1 -1
  109. package/src/kotlinSdkContract.ts +113 -0
  110. package/src/nitro-adapter.lock.json +3 -3
  111. package/src/nitro-bundle.ts +18 -4
  112. package/src/nitro-compile.ts +5 -1
  113. package/src/nitro-source.ts +112 -28
  114. package/src/nitroContract.ts +16 -4
  115. package/src/swift-compile.ts +12 -3
  116. package/src/swift-host.ts +2 -1
  117. package/src/swift-objc-compile.ts +117 -4
  118. package/src/swift-objc-sdk.ts +8792 -135
  119. package/src/swift-objc-standin.ts +1 -0
  120. package/src/vite-plugin-one.ts +73 -134
  121. package/src/worker-system-chunks.ts +14 -4
  122. package/src/xcode-project.ts +261 -34
  123. package/kotlin/AndroidViewSources/android/content/Context.kt +0 -22
  124. package/kotlin/AndroidViewSources/android/content/res/Configuration.kt +0 -25
  125. package/kotlin/AndroidViewSources/android/content/res/Resources.kt +0 -72
  126. package/kotlin/AndroidViewSources/android/graphics/Canvas.kt +0 -22
  127. package/kotlin/AndroidViewSources/android/graphics/Color.kt +0 -13
  128. package/kotlin/AndroidViewSources/android/graphics/Paint.kt +0 -18
  129. package/kotlin/AndroidViewSources/android/util/DisplayMetrics.kt +0 -12
  130. package/kotlin/AndroidViewSources/android/view/View.kt +0 -211
  131. package/kotlin/AndroidViewSources/android/widget/FrameLayout.kt +0 -61
  132. package/kotlin/AndroidViewSources/android/widget/LinearLayout.kt +0 -49
  133. package/kotlin/AndroidViewSources/dev/peach/app/JavaFormat.kt +0 -272
  134. package/kotlin/AppSources/android/app/Activity.kt +0 -174
  135. package/kotlin/AppSources/android/app/Application.kt +0 -11
  136. package/kotlin/AppSources/android/app/UiModeManager.kt +0 -9
  137. package/kotlin/AppSources/android/content/Intent.kt +0 -16
  138. package/kotlin/AppSources/android/os/Bundle.kt +0 -11
  139. package/kotlin/AppSources/android/util/SuperNotCalledException.kt +0 -3
  140. package/kotlin/AppSources/android/view/Window.kt +0 -182
  141. package/kotlin/AppSources/android/view/WindowInsets.kt +0 -9
  142. package/kotlin/AppSources/android/view/WindowInsetsController.kt +0 -17
  143. package/kotlin/AppSources/android/view/WindowManager.kt +0 -16
  144. package/kotlin/AppSources/android/window/BackEvent.kt +0 -24
  145. package/kotlin/AppSources/android/window/OnBackAnimationCallback.kt +0 -7
  146. package/kotlin/AppSources/android/window/OnBackInvokedDispatcher.kt +0 -84
  147. package/kotlin/AppSources/androidx/activity/ActivityFlags.kt +0 -9
  148. package/kotlin/AppSources/androidx/activity/ActivityViewModelLazy.kt +0 -21
  149. package/kotlin/AppSources/androidx/activity/BackEventCompat.kt +0 -43
  150. package/kotlin/AppSources/androidx/activity/ComponentActivity.kt +0 -122
  151. package/kotlin/AppSources/androidx/activity/EdgeToEdge.kt +0 -75
  152. package/kotlin/AppSources/androidx/activity/ExperimentalActivityApi.kt +0 -6
  153. package/kotlin/AppSources/androidx/activity/OnBackPressedCallback.kt +0 -69
  154. package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +0 -144
  155. package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcherOwner.kt +0 -7
  156. package/kotlin/AppSources/androidx/activity/compose/BackHandler.kt +0 -86
  157. package/kotlin/AppSources/androidx/activity/compose/ComponentActivity.kt +0 -29
  158. package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerCompat.kt +0 -38
  159. package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerDispatcherCompat.kt +0 -27
  160. package/kotlin/AppSources/androidx/compose/foundation/layout/WindowInsets.kt +0 -15
  161. package/kotlin/AppSources/androidx/compose/ui/platform/AndroidCompositionLocals.kt +0 -27
  162. package/kotlin/AppSources/androidx/compose/ui/platform/ComposeView.kt +0 -68
  163. package/kotlin/AppSources/androidx/compose/ui/res/ColorResources.kt +0 -16
  164. package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +0 -70
  165. package/kotlin/AppSources/androidx/compose/ui/res/StringResources.kt +0 -38
  166. package/kotlin/AppSources/androidx/core/view/WindowCompat.kt +0 -32
  167. package/kotlin/AppSources/androidx/lifecycle/AndroidViewModel.kt +0 -10
  168. package/kotlin/AppSources/dev/peach/app/PeachApp.kt +0 -388
  169. package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +0 -102
  170. package/kotlin/AppSources/dev/peach/app/PeachWindowHost.kt +0 -14
  171. package/kotlin/CompilerSources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +0 -1
  172. package/kotlin/CompilerSources/PeachJniIncoming.kt +0 -243
  173. package/kotlin/CompilerSources/PeachJniPlugin.kt +0 -116
  174. package/kotlin/ComposeSources/PeachComposeHost.kt +0 -724
  175. package/kotlin/ComposeSources/PeachMagnifier.kt +0 -185
  176. package/kotlin/ComposeSources/PeachSemantics.kt +0 -127
  177. package/kotlin/ExpoComposeSources/PeachAndroidView.kt +0 -103
  178. package/kotlin/ExpoComposeSources/PeachExpoViewMount.kt +0 -24
  179. package/kotlin/ExpoComposeSources/dev/peach/expo/PeachExpoCompose.kt +0 -28
  180. package/kotlin/ExpoComposeSources/expo/modules/kotlin/views/ExpoComposeView.kt +0 -70
  181. package/kotlin/ExpoSources/dev/peach/expo/PeachExpoRuntime.kt +0 -516
  182. package/kotlin/ExpoSources/dev/peach/expo/PeachExpoTypes.kt +0 -173
  183. package/kotlin/ExpoSources/expo/modules/kotlin/AppContext.kt +0 -20
  184. package/kotlin/ExpoSources/expo/modules/kotlin/Promise.kt +0 -19
  185. package/kotlin/ExpoSources/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +0 -198
  186. package/kotlin/ExpoSources/expo/modules/kotlin/exception/CodedException.kt +0 -126
  187. package/kotlin/ExpoSources/expo/modules/kotlin/functions/Functions.kt +0 -132
  188. package/kotlin/ExpoSources/expo/modules/kotlin/jni/JavaScriptTypedArray.kt +0 -81
  189. package/kotlin/ExpoSources/expo/modules/kotlin/modules/Module.kt +0 -98
  190. package/kotlin/ExpoSources/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +0 -236
  191. package/kotlin/ExpoSources/expo/modules/kotlin/records/Record.kt +0 -12
  192. package/kotlin/ExpoSources/expo/modules/kotlin/runtime/Runtime.kt +0 -9
  193. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObject.kt +0 -50
  194. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +0 -57
  195. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedRef.kt +0 -19
  196. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/ConcreteTypedArrays.kt +0 -158
  197. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/GenericTypedArray.kt +0 -8
  198. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArray.kt +0 -29
  199. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArrayIterator.kt +0 -9
  200. package/kotlin/ExpoSources/expo/modules/kotlin/types/AnyType.kt +0 -155
  201. package/kotlin/ExpoSources/expo/modules/kotlin/types/Either.kt +0 -91
  202. package/kotlin/ExpoSources/expo/modules/kotlin/types/Enumerable.kt +0 -6
  203. package/kotlin/ExpoSources/expo/modules/kotlin/viewevent/ViewEvent.kt +0 -68
  204. package/kotlin/ExpoSources/expo/modules/kotlin/views/ExpoView.kt +0 -20
  205. package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +0 -72
  206. package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewProps.kt +0 -36
  207. package/kotlin/JniPlatformSources/androidx/annotation/CallSuper.kt +0 -5
  208. package/kotlin/JniPlatformSources/com/facebook/proguard/annotations/DoNotStrip.kt +0 -5
  209. package/kotlin/JniPlatformSources/dalvik/annotation/optimization/FastNative.kt +0 -5
  210. package/kotlin/JniPlatformSources/kotlin/Synchronized.kt +0 -6
  211. package/kotlin/JniPlatformSources/kotlin/jvm/JvmField.kt +0 -5
  212. package/kotlin/JniPlatformSources/kotlin/jvm/JvmStatic.kt +0 -5
  213. package/kotlin/JniSources/com/facebook/jni/HybridData.kt +0 -66
  214. package/kotlin/JniSources/dev/peach/jni/IncomingBindings.kt +0 -157
  215. package/kotlin/JniSources/dev/peach/jni/NativeBindings.kt +0 -77
  216. package/kotlin/JniTransportSources/dev/peach/jni/integration/JniTransport.kt +0 -89
  217. package/kotlin/Sources/android/os/Build.kt +0 -17
  218. package/kotlin/Sources/android/os/Handler.kt +0 -35
  219. package/kotlin/Sources/android/os/Looper.kt +0 -17
  220. package/kotlin/Sources/android/os/MessageQueue.kt +0 -56
  221. package/kotlin/Sources/android/os/SystemClock.kt +0 -14
  222. package/kotlin/Sources/android/util/Log.kt +0 -64
  223. package/kotlin/Sources/androidx/annotation/DrawableRes.kt +0 -14
  224. package/kotlin/Sources/androidx/annotation/Keep.kt +0 -4
  225. package/kotlin/Sources/dev/onejs/one/OneNativeSourceDispatch.kt +0 -7
  226. package/kotlin/Sources/dev/onejs/one/OneNativeSourceViewDispatch.kt +0 -13
  227. package/kotlin/Sources/dev/onejs/one/source/OneModule.kt +0 -4
  228. package/kotlin/Sources/java/lang/Runnable.kt +0 -6
  229. package/kotlin/Sources/java/security/MessageDigest.kt +0 -114
  230. package/kotlin/Sources/java/util/IllegalFormatCodePointException.kt +0 -10
  231. package/kotlin/Sources/java/util/IllegalFormatException.kt +0 -5
  232. package/kotlin/Sources/kotlin/text/StringFormat.kt +0 -9
  233. package/kotlin/Sources/org/json/JSON.kt +0 -307
  234. package/kotlin/tools/abi-classes.main.kts +0 -41
  235. package/kotlin/tools/expo-types.main.kts +0 -127
@@ -1,211 +0,0 @@
1
- package android.view
2
-
3
- import android.content.Context
4
- import android.content.res.Resources
5
- import android.graphics.Canvas
6
-
7
- open class View(val context: Context) {
8
- val resources: Resources get() = context.resources
9
- var parent: ViewGroup? = null
10
- internal set
11
- var layoutParams: ViewGroup.LayoutParams? = null
12
- internal var attachedWindow: Any? = null
13
-
14
- var left: Int = 0
15
- private set
16
- var top: Int = 0
17
- private set
18
- var right: Int = 0
19
- private set
20
- var bottom: Int = 0
21
- private set
22
- val width: Int get() = right - left
23
- val height: Int get() = bottom - top
24
- var measuredWidth: Int = 0
25
- private set
26
- var measuredHeight: Int = 0
27
- private set
28
- var minimumWidth: Int = 0
29
- var minimumHeight: Int = 0
30
- var paddingLeft: Int = 0
31
- private set
32
- var paddingTop: Int = 0
33
- private set
34
- var paddingRight: Int = 0
35
- private set
36
- var paddingBottom: Int = 0
37
- private set
38
- var isLayoutRequested: Boolean = true
39
- private set
40
- val isLaidOut: Boolean get() = laidOut
41
- private var laidOut = false
42
- private var skipDraw = false
43
- private var backgroundColor: Int = 0
44
- internal var invalidateHost: ((Boolean) -> Unit)? = null
45
-
46
- open fun invalidate() {
47
- invalidateHost?.invoke(false) ?: parent?.invalidate()
48
- }
49
-
50
- open fun requestLayout() {
51
- isLayoutRequested = true
52
- parent?.requestLayout() ?: invalidateHost?.invoke(true)
53
- }
54
-
55
- open fun forceLayout() { isLayoutRequested = true }
56
-
57
- fun setWillNotDraw(willNotDraw: Boolean) { skipDraw = willNotDraw }
58
- fun willNotDraw(): Boolean = skipDraw
59
- fun setBackgroundColor(color: Int) { backgroundColor = color; invalidate() }
60
- fun setPadding(left: Int, top: Int, right: Int, bottom: Int) {
61
- paddingLeft = left; paddingTop = top; paddingRight = right; paddingBottom = bottom
62
- requestLayout()
63
- }
64
-
65
- fun measure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
66
- onMeasure(widthMeasureSpec, heightMeasureSpec)
67
- }
68
-
69
- protected open fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
70
- setMeasuredDimension(getDefaultSize(minimumWidth, widthMeasureSpec), getDefaultSize(minimumHeight, heightMeasureSpec))
71
- }
72
-
73
- protected fun setMeasuredDimension(width: Int, height: Int) {
74
- measuredWidth = width; measuredHeight = height
75
- }
76
-
77
- fun layout(l: Int, t: Int, r: Int, b: Int) {
78
- val oldWidth = width
79
- val oldHeight = height
80
- val changed = left != l || top != t || right != r || bottom != b
81
- left = l; top = t; right = r; bottom = b
82
- if (oldWidth != width || oldHeight != height) onSizeChanged(width, height, oldWidth, oldHeight)
83
- if (changed || isLayoutRequested) onLayout(changed, l, t, r, b)
84
- isLayoutRequested = false
85
- laidOut = true
86
- }
87
-
88
- protected open fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {}
89
- protected open fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {}
90
- protected open fun onDraw(canvas: Canvas) {}
91
- protected open fun dispatchDraw(canvas: Canvas) {}
92
-
93
- open fun draw(canvas: Canvas) {
94
- if (backgroundColor != 0) canvas.drawColor(backgroundColor)
95
- if (!skipDraw) onDraw(canvas)
96
- dispatchDraw(canvas)
97
- }
98
-
99
- object MeasureSpec {
100
- const val UNSPECIFIED = 0
101
- const val EXACTLY = 0x40000000
102
- const val AT_MOST = -0x80000000
103
- fun makeMeasureSpec(size: Int, mode: Int): Int = (size and 0x3fffffff) or mode
104
- fun getMode(spec: Int): Int = spec and -0x40000000
105
- fun getSize(spec: Int): Int = spec and 0x3fffffff
106
- }
107
-
108
- companion object {
109
- fun getDefaultSize(size: Int, measureSpec: Int): Int =
110
- if (MeasureSpec.getMode(measureSpec) == MeasureSpec.UNSPECIFIED) size else MeasureSpec.getSize(measureSpec)
111
-
112
- fun resolveSize(size: Int, measureSpec: Int): Int = when (MeasureSpec.getMode(measureSpec)) {
113
- MeasureSpec.EXACTLY -> MeasureSpec.getSize(measureSpec)
114
- MeasureSpec.AT_MOST -> minOf(size, MeasureSpec.getSize(measureSpec))
115
- else -> size
116
- }
117
- }
118
-
119
- val isAttachedToWindow: Boolean get() = attachedWindow != null
120
-
121
- // view root dispatches attach through the tree once the window is added
122
- internal open fun dispatchAttachedToWindow(window: Any) {
123
- attachedWindow = window
124
- onAttachedToWindow()
125
- }
126
-
127
- internal open fun dispatchDetachedFromWindow() {
128
- onDetachedFromWindow()
129
- attachedWindow = null
130
- }
131
-
132
- protected open fun onAttachedToWindow() {}
133
- protected open fun onDetachedFromWindow() {}
134
- }
135
-
136
- open class ViewGroup(context: Context) : View(context) {
137
- open class LayoutParams(val width: Int, val height: Int) {
138
- companion object {
139
- const val MATCH_PARENT = -1
140
- const val WRAP_CONTENT = -2
141
- }
142
- }
143
-
144
- init { setWillNotDraw(true) }
145
-
146
- private val children = mutableListOf<View>()
147
-
148
- val childCount: Int get() = children.size
149
- fun getChildAt(index: Int): View? = children.getOrNull(index)
150
-
151
- protected open fun generateDefaultLayoutParams(): LayoutParams =
152
- LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
153
-
154
- fun addView(child: View, params: LayoutParams) {
155
- child.layoutParams = params
156
- addView(child)
157
- }
158
-
159
- open fun addView(child: View) {
160
- check(child.parent == null) {
161
- "The specified child already has a parent. You must call removeView() on the child's parent first."
162
- }
163
- if (child.layoutParams == null) child.layoutParams = generateDefaultLayoutParams()
164
- children += child
165
- child.parent = this
166
- attachedWindow?.let { child.dispatchAttachedToWindow(it) }
167
- requestLayout()
168
- }
169
-
170
- fun removeAllViews() {
171
- for (child in children) {
172
- if (child.isAttachedToWindow) child.dispatchDetachedFromWindow()
173
- child.parent = null
174
- }
175
- children.clear()
176
- requestLayout()
177
- }
178
-
179
- override fun dispatchDraw(canvas: Canvas) {
180
- for (child in children) {
181
- val checkpoint = canvas.save()
182
- canvas.translate(child.left.toFloat(), child.top.toFloat())
183
- canvas.clipRect(0f, 0f, child.width.toFloat(), child.height.toFloat())
184
- child.draw(canvas)
185
- canvas.restoreToCount(checkpoint)
186
- }
187
- }
188
-
189
- override fun dispatchAttachedToWindow(window: Any) {
190
- super.dispatchAttachedToWindow(window)
191
- for (child in children.toList()) child.dispatchAttachedToWindow(window)
192
- }
193
-
194
- override fun dispatchDetachedFromWindow() {
195
- for (child in children.toList()) child.dispatchDetachedFromWindow()
196
- super.dispatchDetachedFromWindow()
197
- }
198
-
199
- companion object {
200
- fun getChildMeasureSpec(spec: Int, padding: Int, childDimension: Int): Int {
201
- if (childDimension >= 0) return MeasureSpec.makeMeasureSpec(childDimension, MeasureSpec.EXACTLY)
202
- val mode = MeasureSpec.getMode(spec)
203
- val size = (MeasureSpec.getSize(spec) - padding).coerceAtLeast(0)
204
- return MeasureSpec.makeMeasureSpec(if (mode == MeasureSpec.UNSPECIFIED) 0 else size, when {
205
- mode == MeasureSpec.UNSPECIFIED -> MeasureSpec.UNSPECIFIED
206
- childDimension == LayoutParams.MATCH_PARENT && mode == MeasureSpec.EXACTLY -> MeasureSpec.EXACTLY
207
- else -> MeasureSpec.AT_MOST
208
- })
209
- }
210
- }
211
- }
@@ -1,61 +0,0 @@
1
- package android.widget
2
-
3
- import android.content.Context
4
- import android.view.View
5
- import android.view.ViewGroup
6
-
7
- open class FrameLayout(context: Context) : ViewGroup(context) {
8
- private val matchParentChildren = mutableListOf<View>()
9
-
10
- override fun generateDefaultLayoutParams(): LayoutParams =
11
- LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
12
-
13
- override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
14
- val horizontalPadding = paddingLeft + paddingRight
15
- val verticalPadding = paddingTop + paddingBottom
16
- val measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY ||
17
- MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY
18
- matchParentChildren.clear()
19
- var maxWidth = 0
20
- var maxHeight = 0
21
- for (index in 0 until childCount) {
22
- val child = checkNotNull(getChildAt(index))
23
- val params = checkNotNull(child.layoutParams)
24
- child.measure(
25
- getChildMeasureSpec(widthMeasureSpec, horizontalPadding, params.width),
26
- getChildMeasureSpec(heightMeasureSpec, verticalPadding, params.height),
27
- )
28
- maxWidth = maxOf(maxWidth, child.measuredWidth)
29
- maxHeight = maxOf(maxHeight, child.measuredHeight)
30
- if (measureMatchParentChildren &&
31
- (params.width == LayoutParams.MATCH_PARENT || params.height == LayoutParams.MATCH_PARENT)) {
32
- matchParentChildren += child
33
- }
34
- }
35
- setMeasuredDimension(
36
- View.resolveSize(maxOf(minimumWidth, maxWidth + horizontalPadding), widthMeasureSpec),
37
- View.resolveSize(maxOf(minimumHeight, maxHeight + verticalPadding), heightMeasureSpec),
38
- )
39
- // android repeats measurement only when multiple children match the parent.
40
- if (matchParentChildren.size > 1) {
41
- for (child in matchParentChildren) {
42
- val params = checkNotNull(child.layoutParams)
43
- child.measure(
44
- if (params.width == LayoutParams.MATCH_PARENT)
45
- MeasureSpec.makeMeasureSpec((measuredWidth - horizontalPadding).coerceAtLeast(0), MeasureSpec.EXACTLY)
46
- else getChildMeasureSpec(widthMeasureSpec, horizontalPadding, params.width),
47
- if (params.height == LayoutParams.MATCH_PARENT)
48
- MeasureSpec.makeMeasureSpec((measuredHeight - verticalPadding).coerceAtLeast(0), MeasureSpec.EXACTLY)
49
- else getChildMeasureSpec(heightMeasureSpec, verticalPadding, params.height),
50
- )
51
- }
52
- }
53
- }
54
-
55
- override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
56
- for (index in 0 until childCount) {
57
- val child = checkNotNull(getChildAt(index))
58
- child.layout(paddingLeft, paddingTop, paddingLeft + child.measuredWidth, paddingTop + child.measuredHeight)
59
- }
60
- }
61
- }
@@ -1,49 +0,0 @@
1
- package android.widget
2
-
3
- import android.content.Context
4
- import android.view.View
5
- import android.view.ViewGroup
6
-
7
- open class LinearLayout(context: Context) : ViewGroup(context) {
8
- var orientation: Int = HORIZONTAL
9
- set(value) { field = value; requestLayout() }
10
-
11
- override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
12
- var usedWidth = 0
13
- var usedHeight = 0
14
- for (index in 0 until childCount) {
15
- val child = checkNotNull(getChildAt(index))
16
- val params = child.layoutParams
17
- child.measure(
18
- getChildMeasureSpec(widthMeasureSpec, paddingLeft + paddingRight + if (orientation == HORIZONTAL) usedWidth else 0, params?.width ?: LayoutParams.WRAP_CONTENT),
19
- getChildMeasureSpec(heightMeasureSpec, paddingTop + paddingBottom + if (orientation == VERTICAL) usedHeight else 0, params?.height ?: LayoutParams.WRAP_CONTENT),
20
- )
21
- if (orientation == VERTICAL) {
22
- usedHeight += child.measuredHeight
23
- usedWidth = maxOf(usedWidth, child.measuredWidth)
24
- } else {
25
- usedWidth += child.measuredWidth
26
- usedHeight = maxOf(usedHeight, child.measuredHeight)
27
- }
28
- }
29
- setMeasuredDimension(
30
- View.resolveSize(maxOf(minimumWidth, usedWidth + paddingLeft + paddingRight), widthMeasureSpec),
31
- View.resolveSize(maxOf(minimumHeight, usedHeight + paddingTop + paddingBottom), heightMeasureSpec),
32
- )
33
- }
34
-
35
- override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
36
- var x = paddingLeft
37
- var y = paddingTop
38
- for (index in 0 until childCount) {
39
- val child = checkNotNull(getChildAt(index))
40
- child.layout(x, y, x + child.measuredWidth, y + child.measuredHeight)
41
- if (orientation == VERTICAL) y += child.measuredHeight else x += child.measuredWidth
42
- }
43
- }
44
-
45
- companion object {
46
- const val HORIZONTAL = 0
47
- const val VERTICAL = 1
48
- }
49
- }
@@ -1,272 +0,0 @@
1
- package dev.peach.app
2
-
3
- import java.util.IllegalFormatCodePointException
4
-
5
- // java.util.Formatter as String.format(locale, format, args) runs it on the
6
- // device, which Resources.getString(id, args) calls: the general, character,
7
- // integral and decimal float conversions with their flags, width, precision
8
- // and argument indexes, digits and separators in the locale's symbols. a
9
- // conversion outside those (scientific, hex float, date) is rejected by name.
10
-
11
- private val SPECIFIER = Regex("%(\\d+\\$)?([-#+ 0,(<]*)(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])")
12
-
13
- private class Symbols(val zero: Char, val decimal: String, val group: String)
14
-
15
- // one part of the locale's number format, as ICU's decimal format symbols
16
- // give it (Intl reads the same CLDR data)
17
- private fun numberPart(locale: String, value: Double, type: String): String =
18
- js("(new Intl.NumberFormat(locale || undefined, { useGrouping: true }).formatToParts(value).find((part) => part.type === type) || { value: '' }).value")
19
-
20
- private fun symbols(locale: String) = Symbols(
21
- zero = numberPart(locale, 0.0, "integer").single(),
22
- decimal = numberPart(locale, 1.5, "decimal"),
23
- group = numberPart(locale, 1234567.0, "group"),
24
- )
25
-
26
- private class Spec(val flags: String, val width: Int, val precision: Int, val text: String) {
27
- fun has(flag: Char) = flag in flags
28
- }
29
-
30
- internal fun javaFormat(locale: String, format: String, args: Array<out Any?>): String {
31
- val out = StringBuilder()
32
- var ordinary = 0
33
- var last = -1
34
- var index = 0
35
- while (index < format.length) {
36
- val percent = format.indexOf('%', index)
37
- if (percent == -1) {
38
- out.append(format, index, format.length)
39
- break
40
- }
41
- out.append(format, index, percent)
42
- val match = SPECIFIER.matchAt(format, percent)
43
- ?: throw IllegalArgumentException(
44
- "Conversion = '${format.getOrNull(percent + 1) ?: '%'}'",
45
- )
46
- index = match.range.last + 1
47
- val (position, flags, width, precision, time, conversion) = match.destructured
48
- if (time.isNotEmpty())
49
- throw UnsupportedOperationException("peach kotlin: date conversion ${match.value} is not supported")
50
- val spec = Spec(
51
- flags,
52
- width.toIntOrNull() ?: -1,
53
- precision.drop(1).toIntOrNull() ?: -1,
54
- match.value,
55
- )
56
- val c = conversion.single()
57
- if (c == '%') {
58
- out.append(justify(spec, "%"))
59
- continue
60
- }
61
- if (c == 'n') {
62
- out.append('\n')
63
- continue
64
- }
65
- val argument = when {
66
- spec.has('<') -> last
67
- position.isNotEmpty() -> position.dropLast(1).toInt() - 1
68
- else -> ordinary++
69
- }
70
- if (argument !in args.indices) throw IllegalArgumentException("Format specifier '${match.value}'")
71
- last = argument
72
- out.append(convert(c, args[argument], spec, locale))
73
- }
74
- return out.toString()
75
- }
76
-
77
- private fun justify(spec: Spec, value: String): String {
78
- if (spec.width <= value.length) return value
79
- val pad = " ".repeat(spec.width - value.length)
80
- return if (spec.has('-')) value + pad else pad + value
81
- }
82
-
83
- private fun typeName(value: Any?): String = when (value) {
84
- is String -> "java.lang.String"
85
- is Int -> "java.lang.Integer"
86
- is Long -> "java.lang.Long"
87
- is Short -> "java.lang.Short"
88
- is Byte -> "java.lang.Byte"
89
- is Double -> "java.lang.Double"
90
- is Float -> "java.lang.Float"
91
- is Boolean -> "java.lang.Boolean"
92
- is Char -> "java.lang.Character"
93
- else -> value?.let { it::class.simpleName } ?: "null"
94
- }
95
-
96
- private fun mismatch(c: Char, value: Any?): Nothing =
97
- throw IllegalArgumentException("$c != ${typeName(value)}")
98
-
99
- private fun convert(c: Char, value: Any?, spec: Spec, locale: String): String = when (c) {
100
- 'b', 'B' -> {
101
- val text = when (value) {
102
- null -> "false"
103
- is Boolean -> value.toString()
104
- else -> "true"
105
- }
106
- justify(spec, precise(spec, if (c == 'B') text.uppercase() else text))
107
- }
108
- 's', 'S' -> {
109
- val text = precise(spec, value.toString())
110
- justify(spec, if (c == 'S') upper(text, locale) else text)
111
- }
112
- 'c', 'C' -> {
113
- val text = when (value) {
114
- null -> "null"
115
- is Char -> value.toString()
116
- is Int -> codePoint(value)
117
- is Byte -> codePoint(value.toInt())
118
- is Short -> codePoint(value.toInt())
119
- else -> mismatch(c, value)
120
- }
121
- justify(spec, if (c == 'C') upper(text, locale) else text)
122
- }
123
- 'd' -> when (value) {
124
- null -> justify(spec, "null")
125
- is Int -> decimal(spec, value.toString(), symbols(locale))
126
- is Long -> decimal(spec, value.toString(), symbols(locale))
127
- is Short -> decimal(spec, value.toString(), symbols(locale))
128
- is Byte -> decimal(spec, value.toString(), symbols(locale))
129
- else -> mismatch(c, value)
130
- }
131
- 'x', 'X', 'o' -> {
132
- val radix = if (c == 'o') 8 else 16
133
- val digits = when (value) {
134
- null -> null
135
- is Int -> value.toUInt().toString(radix)
136
- is Long -> value.toULong().toString(radix)
137
- is Short -> (value.toInt() and 0xffff).toString(radix)
138
- is Byte -> (value.toInt() and 0xff).toString(radix)
139
- else -> mismatch(c, value)
140
- }
141
- if (digits == null) justify(spec, "null")
142
- else {
143
- val prefix = if (spec.has('#')) (if (radix == 16) "0x" else "0") else ""
144
- var body = digits
145
- if (spec.has('0')) body = body.padStart(spec.width - prefix.length, '0')
146
- val text = prefix + body
147
- justify(spec, if (c == 'X') text.uppercase() else text)
148
- }
149
- }
150
- 'f' -> when (value) {
151
- null -> justify(spec, "null")
152
- is Double -> fixed(spec, value, symbols(locale))
153
- is Float -> fixed(spec, value.toDouble(), symbols(locale))
154
- else -> mismatch(c, value)
155
- }
156
- else -> throw UnsupportedOperationException("peach kotlin: conversion ${spec.text} is not supported")
157
- }
158
-
159
- private fun codePoint(value: Int): String {
160
- if (value < 0 || value > 0x10ffff)
161
- throw IllegalFormatCodePointException(value)
162
- if (value < 0x10000) return value.toChar().toString()
163
- val offset = value - 0x10000
164
- return charArrayOf((0xd800 + (offset shr 10)).toChar(), (0xdc00 + (offset and 0x3ff)).toChar()).concatToString()
165
- }
166
-
167
- // Formatter uppercases %S and %C in the format locale, as ICU's case
168
- // mapping gives it (toLocaleUpperCase reads the same CLDR data)
169
- private fun upper(text: String, locale: String): String =
170
- js("text.toLocaleUpperCase(locale || undefined)")
171
-
172
- private fun precise(spec: Spec, text: String) =
173
- if (spec.precision >= 0 && spec.precision < text.length) text.take(spec.precision) else text
174
-
175
- // Formatter.print(long): the sign, then the localized magnitude zero padded
176
- // to the width, then the closing parenthesis, then the justification
177
- private fun decimal(spec: Spec, value: String, symbols: Symbols): String {
178
- val negative = value.startsWith('-')
179
- return signed(spec, negative, value.removePrefix("-"), symbols)
180
- }
181
-
182
- private fun signed(spec: Spec, negative: Boolean, magnitude: String, symbols: Symbols): String {
183
- val out = StringBuilder()
184
- if (negative) out.append(if (spec.has('(')) '(' else '-')
185
- else if (spec.has('+')) out.append('+')
186
- else if (spec.has(' ')) out.append(' ')
187
- val width = if (spec.width != -1 && negative && spec.has('(')) spec.width - 1 else spec.width
188
- localized(out, magnitude, spec, width, symbols)
189
- if (negative && spec.has('(')) out.append(')')
190
- return justify(spec, out.toString())
191
- }
192
-
193
- // Formatter.localizedMagnitude: each digit in the locale's digits, grouped
194
- // by three with the ',' flag, the decimal separator in place of the point,
195
- // and zero padding inserted after the sign
196
- private fun localized(out: StringBuilder, value: String, spec: Spec, width: Int, symbols: Symbols) {
197
- val begin = out.length
198
- val dot = value.indexOf('.').let { if (it == -1) value.length else it }
199
- var group = spec.has(',')
200
- for (index in value.indices) {
201
- if (index == dot) {
202
- out.append(symbols.decimal)
203
- group = false
204
- continue
205
- }
206
- out.append(symbols.zero + (value[index] - '0'))
207
- if (group && index != dot - 1 && (dot - index) % 3 == 1) out.append(symbols.group)
208
- }
209
- if (width != -1 && spec.has('0')) while (out.length < width) out.insert(begin, symbols.zero)
210
- }
211
-
212
- // Formatter.print(double) for %f: the shortest decimal digits of the value,
213
- // rounded half up to the precision, as FormattedFloatingDecimal does
214
- private fun fixed(spec: Spec, value: Double, symbols: Symbols): String {
215
- if (value.isNaN()) return justify(spec, "NaN")
216
- val negative = value < 0.0 || (value == 0.0 && 1.0 / value < 0.0)
217
- if (value.isInfinite()) {
218
- val text = if (negative) (if (spec.has('(')) "(Infinity)" else "-Infinity")
219
- else if (spec.has('+')) "+Infinity" else if (spec.has(' ')) " Infinity" else "Infinity"
220
- return justify(spec, text)
221
- }
222
- val precision = if (spec.precision == -1) 6 else spec.precision
223
- var magnitude = roundHalfUp(shortestDigits(kotlin.math.abs(value)), precision)
224
- if (precision == 0 && spec.has('#')) magnitude += "."
225
- return signed(spec, negative, magnitude, symbols)
226
- }
227
-
228
- // the shortest round trip decimal of a finite non negative double as plain
229
- // digits and a point, the digits Double.toString prints
230
- private fun shortestDigits(value: Double): String {
231
- val text = value.toString()
232
- val exponentAt = text.indexOfFirst { it == 'e' || it == 'E' }
233
- if (exponentAt == -1) return text
234
- val mantissa = text.substring(0, exponentAt)
235
- val exponent = text.substring(exponentAt + 1).toInt()
236
- val point = mantissa.indexOf('.').let { if (it == -1) mantissa.length else it }
237
- val digits = mantissa.replace(".", "")
238
- val shifted = point + exponent
239
- return when {
240
- shifted <= 0 -> "0." + "0".repeat(-shifted) + digits
241
- shifted >= digits.length -> digits + "0".repeat(shifted - digits.length)
242
- else -> digits.substring(0, shifted) + "." + digits.substring(shifted)
243
- }
244
- }
245
-
246
- private fun roundHalfUp(decimal: String, precision: Int): String {
247
- val point = decimal.indexOf('.')
248
- val whole = if (point == -1) decimal else decimal.substring(0, point)
249
- val fraction = if (point == -1) "" else decimal.substring(point + 1)
250
- if (fraction.length <= precision) {
251
- val padded = fraction.padEnd(precision, '0')
252
- return if (precision == 0) whole else "$whole.$padded"
253
- }
254
- val kept = (whole + fraction.substring(0, precision)).toCharArray()
255
- if (fraction[precision] >= '5') {
256
- var carry = true
257
- var index = kept.size - 1
258
- while (carry && index >= 0) {
259
- if (kept[index] == '9') kept[index] = '0'
260
- else {
261
- kept[index] = kept[index] + 1
262
- carry = false
263
- }
264
- index--
265
- }
266
- val digits = (if (carry) "1" else "") + kept.concatToString()
267
- val wholeLength = digits.length - precision
268
- return if (precision == 0) digits else digits.substring(0, wholeLength) + "." + digits.substring(wholeLength)
269
- }
270
- val digits = kept.concatToString()
271
- return if (precision == 0) digits else digits.substring(0, whole.length) + "." + digits.substring(whole.length)
272
- }