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
package/kotlin/README.md CHANGED
@@ -26,29 +26,43 @@ traffic in `scripts/debug/peach-swift-lazy-network.sh`.
26
26
  `java.security.MessageDigest` for SHA-256, the `%02x` Byte formatter,
27
27
  `androidx.annotation.Keep`, `dev.onejs.one.OneNativeSourceDispatch` and
28
28
  `dev.onejs.one.source.OneModule`. Kotlin/Wasm has no implicit `java.lang`
29
- import, so app sources import `java.lang.Runnable` explicitly. `AppSources/`
30
- adds the activity, window and Compose actuals only pure Kotlin apps compile.
29
+ import, so app sources import `java.lang.Runnable` explicitly. `ComposeSources/` holds the shared view host and back-dispatch contracts.
30
+ `AppSources/` adds the activity and window implementation only pure Kotlin apps link.
31
31
  - `ExpoSources/`: the expo-modules-core Kotlin DSL port and `PeachExpoRuntime`
32
32
  that local Expo Android modules compile against. Owner spec:
33
33
  [`specs/peach-kotlin-expo-modules.md`](../../../specs/peach-kotlin-expo-modules.md).
34
- - `CompilerSources/`: the native member compiler plugin and its JVM service
35
- registration. The shared host compiles it into a classes directory cached by
36
- the pinned compiler and every plugin source byte. Completed directories publish
37
- atomically under `~/.peach/kotlin/compiler-plugins/`; all Kotlin entry paths
38
- load that plugin. `JniPlatformSources/` and `JniSources/` supply the shared
39
- platform declarations and native invocation runtime for imported modules,
40
- pure Kotlin apps and Expo modules.
41
- Incoming JNI lookup has stable method and field IDs, declaration-backed private
42
- and virtual calls, actual constructors and backing-field access. Native static
43
- companion calls preserve the enclosing JVM owner and null receiver. The
34
+ - `CompilerSources/`: the native member compiler plugin and JVM service
35
+ registration. Release producers compile it to `plugin.jar`; clients load that
36
+ jar without compiling or receiving plugin source. `ToolSources/` builds
37
+ `tools.jar` for the existing Expo type scan and ViewModel ABI scan.
38
+ `JniPlatformSources/` and `JniSources/` supply platform declarations and the
39
+ native invocation runtime. Incoming JNI lookup retains stable IDs, private
40
+ and virtual calls, constructors and backing fields. Native static companion
41
+ calls preserve the enclosing JVM owner and null receiver. The
44
42
  [binding contract](../../../docs/research/peach/kotlin-native-bindings.md)
45
- owns the APIs, holder lifetime and unsupported forms.
43
+ owns APIs, holder lifetime and unsupported forms.
46
44
 
47
- App artifact hashes include compiler and library pins, plugin sources, platform
48
- and runtime sources, app sources and generated glue. The host compiles byte
49
- snapshots of the hashed app, platform and plugin inputs, preserving their
50
- original paths in compiler diagnostics. A cached artifact needs no compiler
51
- process; another app reuses the compiled plugin without rebuilding it.
45
+ `packages/peachsim/scripts/build-kotlin-sdk.ts` builds `sdk.tar.gz` from private
46
+ sources and the pinned compiler. It contains only compiled JVM jars, Wasm KLIB
47
+ profiles and an exact binary manifest. The profiles match module, JNI, Compose
48
+ view, Expo and pure-app source sets. The app compiler links one profile and
49
+ compiles only guest sources and generated glue. Generated initialization
50
+ registers SDK bindings before app bindings and supplies app-owned view dispatch
51
+ and resources explicitly. Internal JNI names retain their original JVM module
52
+ identity when SDK code moves into a library. SDK module names remain distinct
53
+ from the guest app module. Exact final property/method forwarding aliases share
54
+ one JNI registration; conflicting implementations fail compilation.
55
+
56
+ The compiler plugin resolves the guest's `kotlin.jvm.JvmStatic`, `JvmField` and `JvmName`
57
+ imports to the SDK's compiled platform annotations. Each guest gets local
58
+ compiler aliases to that single definition, retaining the annotation targets
59
+ and binary retention without duplicating annotation classes across libraries.
60
+
61
+ The manifest binds compiler, source-input digest, binary names, sizes and SHA256
62
+ hashes. Archive installs verify that exact flat inventory and atomically publish
63
+ under a content-addressed cache. Matching artifact keys reuse compiled output;
64
+ SDK keys bind all producer and SDK source bytes. Client artifact keys bind the
65
+ SDK archive, selected profile, toolchain/language pins, guest sources and glue.
52
66
 
53
67
  The dev server compiles every `.kt` source of the app, One's glue for each and
54
68
  a generated entry into one Kotlin/Wasm module, held to the Kotlin language
@@ -73,8 +87,9 @@ browser worker with no document, after official Skiko initializes. This proves
73
87
  runtime behavior, with no Compose UI or Android pixel grade. UI fixtures still
74
88
  use the paired Compose oracle.
75
89
 
76
- The npm package publishes the `*Sources/` directories, `tools/` and
77
- `toolchain.json` required by client compilation, plus this documentation and
78
- the fork licenses and notices. `fork/` patches, pins and producer scripts,
79
- and development fixtures remain in private Git. The package smoke check rejects
80
- these build inputs in actual npm payloads, including a supplied tarball.
90
+ The npm package publishes `sdk.tar.gz`, `toolchain.json`, this documentation
91
+ and fork licenses and notices. The standalone embeds those same binary SDK and
92
+ toolchain bytes. Raw Kotlin SDK sources, compiler sources, JVM tool sources,
93
+ fork recipes and development fixtures remain in private Git. The package smoke
94
+ check verifies the compiled archive and rejects raw SDK inputs in actual npm
95
+ payloads, including a supplied tarball.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.1655",
3
+ "version": "0.1.1660",
4
4
  "description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -317,17 +317,7 @@
317
317
  "runtime-companion.json",
318
318
  "src/",
319
319
  "cli/",
320
- "kotlin/AndroidViewSources/",
321
- "kotlin/AppSources/",
322
- "kotlin/CompilerSources/",
323
- "kotlin/ComposeSources/",
324
- "kotlin/ExpoComposeSources/",
325
- "kotlin/ExpoSources/",
326
- "kotlin/JniPlatformSources/",
327
- "kotlin/JniSources/",
328
- "kotlin/JniTransportSources/",
329
- "kotlin/Sources/",
330
- "kotlin/tools/",
320
+ "kotlin/sdk.tar.gz",
331
321
  "kotlin/toolchain.json",
332
322
  "kotlin/README.md",
333
323
  "kotlin/fork/LICENSE",
@@ -1 +1 @@
1
- {"abi":1,"sha256":"6f6a55398d832d1703346a258bf9f81bf78fded8cf5d83cdf51e5e15ccd7a1ce","file":"node/cli-6f6a55398d832d1703346a258bf9f81bf78fded8cf5d83cdf51e5e15ccd7a1ce.cjs"}
1
+ {"abi":1,"sha256":"a0c90fd4b5bf7e03f5705f9f4eba0fa945d8fc7834bfc5505f6e1cf6244d0931","file":"node/cli-a0c90fd4b5bf7e03f5705f9f4eba0fa945d8fc7834bfc5505f6e1cf6244d0931.cjs"}
@@ -68,8 +68,6 @@ export function readBundleGlobalFooter(source: string, name: string): unknown {
68
68
  }
69
69
 
70
70
  // transport metadata is parsed before evaluation and has no guest JS effect.
71
- export const ROLLDOWN_INVENTORY_HEADER = 'X-Peach-Rolldown-Inventory'
72
-
73
71
  export function readBundleMetadataFooter(source: string, name: string): unknown {
74
72
  return readFooter(source, `// peach.${name}=`, '', name)
75
73
  }
package/src/config.ts CHANGED
@@ -42,6 +42,41 @@ export type NativeViewResolution = 'noop' | { file: string } | NativeViewSource
42
42
  // them.
43
43
  export type NativeStub = string
44
44
 
45
+ // what answers one Nitro HybridObject name: 'unsupported' (this Peach build
46
+ // registers no constructor) or a file whose default export is the factory for
47
+ // the object. 'noop' would invent a native object (specs/peach-app-stubs.md).
48
+ export type HybridObjectAnswer = 'unsupported' | { file: string }
49
+
50
+ function isHybridObjectAnswer(answer: unknown): answer is HybridObjectAnswer {
51
+ return (
52
+ answer === 'unsupported' ||
53
+ (isRecord(answer) && typeof answer.file === 'string' && answer.file.length > 0)
54
+ )
55
+ }
56
+
57
+ function isHybridObjects(value: unknown): value is Record<string, HybridObjectAnswer> {
58
+ return (
59
+ isRecord(value) &&
60
+ Object.entries(value).every(
61
+ ([name, answer]) => name.length > 0 && isHybridObjectAnswer(answer),
62
+ )
63
+ )
64
+ }
65
+
66
+ // a package answers 'unsupported' or the path of a factory file
67
+ function isPackageHybridObjects(value: unknown): value is Record<string, string> {
68
+ return (
69
+ isRecord(value) &&
70
+ Object.entries(value).every(
71
+ ([name, answer]) =>
72
+ name.length > 0 &&
73
+ typeof answer === 'string' &&
74
+ answer.length > 0 &&
75
+ answer !== 'noop',
76
+ )
77
+ )
78
+ }
79
+
45
80
  // the stubs for one package's native side, keyed by the names its JavaScript
46
81
  // asks for. a whole-package 'noop' answers every name the installed package
47
82
  // requests. the same shape is a published stub package's `peach` field
@@ -51,6 +86,7 @@ export type PackageStubs =
51
86
  | {
52
87
  modules?: Record<string, NativeStub>
53
88
  views?: Record<string, NativeStub | NativeViewSource>
89
+ hybridObjects?: Record<string, string>
54
90
  }
55
91
 
56
92
  export function isPackageStubs(value: unknown): value is PackageStubs {
@@ -67,7 +103,8 @@ export function isPackageStubs(value: unknown): value is PackageStubs {
67
103
  Object.values(value.views).every(
68
104
  (stub) =>
69
105
  (typeof stub === 'string' && stub.length > 0) || isNativeViewSource(stub),
70
- )))
106
+ ))) &&
107
+ (value.hybridObjects === undefined || isPackageHybridObjects(value.hybridObjects))
71
108
  )
72
109
  }
73
110
 
@@ -86,6 +123,7 @@ export interface PeachConfig<Settings extends Record<string, any> = Record<strin
86
123
  turboModules?: Record<string, NativeModuleResolution>
87
124
  nativeModules?: Record<string, NativeModuleResolution>
88
125
  nativeViews?: Record<string, NativeViewResolution>
126
+ nativeHybridObjects?: Record<string, HybridObjectAnswer>
89
127
  env?: Record<string, string>
90
128
  // generic per-sim network rewrites for the guest app's runtime fetches.
91
129
  // `remap` keys/values are `host:port` (or bare `host`) — a tenant fetch whose
@@ -117,7 +155,13 @@ export const PEACH_CONFIG_QUERY_PARAM = 'peachConfig'
117
155
  export function collectConfiguredFileModules(config?: PeachConfig): string[] {
118
156
  return [
119
157
  ...new Set(
120
- ['modules', 'turboModules', 'nativeModules', 'nativeViews'].flatMap((key) => {
158
+ [
159
+ 'modules',
160
+ 'turboModules',
161
+ 'nativeModules',
162
+ 'nativeViews',
163
+ 'nativeHybridObjects',
164
+ ].flatMap((key) => {
121
165
  const entries: unknown = config && Reflect.get(config, key)
122
166
  if (!isRecord(entries)) return []
123
167
  return Object.values(entries).flatMap((entry) =>
@@ -151,6 +195,7 @@ export function isPeachConfig<Settings extends Record<string, any> = Record<stri
151
195
  'turboModules',
152
196
  'nativeModules',
153
197
  'nativeViews',
198
+ 'nativeHybridObjects',
154
199
  'env',
155
200
  'network',
156
201
  'settings',
@@ -160,6 +205,8 @@ export function isPeachConfig<Settings extends Record<string, any> = Record<stri
160
205
  (value.packages === undefined ||
161
206
  (isRecord(value.packages) &&
162
207
  Object.values(value.packages).every(isPackageStubs))) &&
208
+ (value.nativeHybridObjects === undefined ||
209
+ isHybridObjects(value.nativeHybridObjects)) &&
163
210
  (value.nativeViews === undefined ||
164
211
  (isRecord(value.nativeViews) &&
165
212
  Object.values(value.nativeViews).every(
@@ -249,6 +296,7 @@ export function hasPeachConfig<
249
296
  hasOwnKeys(config.turboModules as Record<string, unknown> | undefined) ||
250
297
  hasOwnKeys(config.nativeModules as Record<string, unknown> | undefined) ||
251
298
  hasOwnKeys(config.nativeViews) ||
299
+ hasOwnKeys(config.nativeHybridObjects) ||
252
300
  hasOwnKeys(config.env as Record<string, unknown> | undefined) ||
253
301
  hasOwnKeys(config.network?.remap as Record<string, unknown> | undefined) ||
254
302
  hasOwnKeys(config.settings as Record<string, unknown> | undefined) ||
@@ -278,6 +326,10 @@ export function mergePeachConfig<
278
326
  ...(override.nativeModules || {}),
279
327
  },
280
328
  nativeViews: { ...(base.nativeViews || {}), ...(override.nativeViews || {}) },
329
+ nativeHybridObjects: {
330
+ ...(base.nativeHybridObjects || {}),
331
+ ...(override.nativeHybridObjects || {}),
332
+ },
281
333
  env: { ...(base.env || {}), ...(override.env || {}) },
282
334
  network: {
283
335
  remap: { ...(base.network?.remap || {}), ...(override.network?.remap || {}) },
@@ -61,7 +61,13 @@ export async function produceConfiguredBundle(
61
61
  )
62
62
  return id
63
63
  }
64
- for (const key of ['modules', 'turboModules', 'nativeModules', 'nativeViews']) {
64
+ for (const key of [
65
+ 'modules',
66
+ 'turboModules',
67
+ 'nativeModules',
68
+ 'nativeViews',
69
+ 'nativeHybridObjects',
70
+ ]) {
65
71
  const entries: unknown = Reflect.get(packagedConfig, key)
66
72
  if (!entries || typeof entries !== 'object') continue
67
73
  for (const resolution of Object.values(entries)) {
@@ -27,15 +27,12 @@
27
27
  import http, { type IncomingMessage, type ServerResponse } from 'http'
28
28
  import https from 'https'
29
29
  import { Http2ServerRequest, type Http2ServerResponse } from 'node:http2'
30
- import { Readable } from 'stream'
31
30
  import { finished, pipeline } from 'stream/promises'
32
31
  import {
33
32
  isLoopbackHost,
34
33
  isTrustedBridgeRequest,
35
34
  normalizeHostname,
36
35
  } from '../backend-origin.ts'
37
- import { ROLLDOWN_INVENTORY_HEADER } from '../bundleGlobalFooter.ts'
38
- import { getCliRuntime } from '../cli-runtime.ts'
39
36
  import { PACKAGE_VERSIONS_HEADER } from '../packageVersionsContract'
40
37
  import { readDevServerPackageVersions } from './dev-server-package-versions.ts'
41
38
  import {
@@ -52,6 +49,7 @@ import {
52
49
  resolveRedirectUrl,
53
50
  } from './fetch-proxy-overrides.ts'
54
51
  import { projectLoopbackPort } from './loopback-ports.ts'
52
+ import { forwardRolldownBundleResponse } from './rolldown-bundle-forward.ts'
55
53
 
56
54
  type FetchProxyRequest = IncomingMessage | Http2ServerRequest
57
55
  type FetchProxyResponse = ServerResponse | Http2ServerResponse
@@ -221,6 +219,15 @@ export async function handleFetchProxyRequest(
221
219
  return
222
220
  }
223
221
 
222
+ // the project's installed versions are read while the server builds the
223
+ // bundle, so a bundle that records none does not wait on the read after it.
224
+ const packageVersionsRead =
225
+ isBundleProxyRequestUrl(req.url) && req.method === 'GET'
226
+ ? readDevServerPackageVersions(upstreamUrl)
227
+ : null
228
+ // a read the response never awaits must not surface as an unhandled rejection
229
+ packageVersionsRead?.catch(() => {})
230
+
224
231
  await proxyUpstream(req, res, upstreamUrl, params.has(FETCH_PROXY_FAILURE_PARAM), {
225
232
  requestHeaders: (target) => buildFetchProxyHeaders(req.headers, target),
226
233
  respond: async (upstream, setCookies) => {
@@ -247,25 +254,14 @@ export async function handleFetchProxyRequest(
247
254
  }
248
255
  // a bundle whose server records no install gets the one its project holds
249
256
  if (
250
- isBundleProxyRequestUrl(req.url) &&
251
- req.method === 'GET' &&
257
+ packageVersionsRead &&
252
258
  upstream.statusCode === 200 &&
253
259
  !res.hasHeader(PACKAGE_VERSIONS_HEADER)
254
260
  ) {
255
- const packageVersions = await readDevServerPackageVersions(upstreamUrl)
261
+ const packageVersions = await packageVersionsRead
256
262
  if (packageVersions)
257
263
  res.setHeader(PACKAGE_VERSIONS_HEADER, JSON.stringify(packageVersions))
258
264
  }
259
- if (
260
- isBundleProxyRequestUrl(req.url) &&
261
- req.method === 'GET' &&
262
- upstream.statusCode === 200 &&
263
- upstreamUrl.pathname.endsWith('.bundle') &&
264
- upstream.headers['x-peach-rolldown-inventory'] !== '1'
265
- ) {
266
- res.setHeader(ROLLDOWN_INVENTORY_HEADER, '1')
267
- res.removeHeader('content-length')
268
- }
269
265
  applyFetchProxyCors(req, res)
270
266
  if (setCookies.length > 0)
271
267
  res.setHeader('x-sootsim-set-cookie', setCookies.join(', '))
@@ -511,41 +507,9 @@ async function proxyUpstream(
511
507
  isBundleProxyRequestUrl(req.url) &&
512
508
  method === 'GET' &&
513
509
  status === 200 &&
514
- targetUrl.pathname.endsWith('.bundle') &&
515
- proxyRes.headers['x-peach-rolldown-inventory'] !== '1'
510
+ targetUrl.pathname.endsWith('.bundle')
516
511
  ) {
517
- const contentType =
518
- typeof proxyRes.headers['content-type'] === 'string'
519
- ? proxyRes.headers['content-type']
520
- : ''
521
- const inventory = getCliRuntime().rolldown_bundle_inventory
522
- res.removeHeader('content-length')
523
- // metro's multipart build progress has to reach the client while the
524
- // build runs, so everything before the bundle part's body streams through
525
- // as it arrives and only the bundle itself waits for its inventory
526
- const annotate = async function* () {
527
- const decoder = new TextDecoder()
528
- let payload = ''
529
- let sent = 0
530
- let bundleStarted = false
531
- for await (const chunk of proxyRes) {
532
- payload += decoder.decode(chunk, { stream: true })
533
- if (bundleStarted) continue
534
- const releasable = inventory.releasableMultipartPrefix(payload, contentType)
535
- bundleStarted = releasable.bundleStarted
536
- if (releasable.length > sent) {
537
- yield Buffer.from(payload.slice(sent, releasable.length), 'utf8')
538
- sent = releasable.length
539
- }
540
- }
541
- payload += decoder.decode()
542
- const annotated = await inventory.attachRolldownBundleHttpPayload(
543
- payload,
544
- contentType,
545
- )
546
- yield Buffer.from(annotated.slice(sent), 'utf8')
547
- }
548
- await pipeline(Readable.from(annotate(), { objectMode: false }), res)
512
+ await forwardRolldownBundleResponse(proxyRes, res)
549
513
  return
550
514
  }
551
515
  await pipeline(proxyRes, res)
@@ -0,0 +1,71 @@
1
+ import { Readable } from 'stream'
2
+ import { pipeline } from 'stream/promises'
3
+ import { getCliRuntime } from '../cli-runtime.ts'
4
+ import type { IncomingMessage, ServerResponse } from 'http'
5
+ import type { Http2ServerResponse } from 'node:http2'
6
+
7
+ // marks a response this forwarder already produced, so a second hop (the
8
+ // bundle proxy in front of the vite plugin's route) passes it through instead
9
+ // of buffering and hashing it again. the tenant still verifies the footer.
10
+ export const ROLLDOWN_INVENTORY_HEADER = 'x-peach-rolldown-inventory'
11
+
12
+ // a peach-run dev server answers a 200 .bundle GET with the precomputed
13
+ // rolldown inventory the tenant verifies. the bundle proxy and the vite
14
+ // plugin's own .bundle route both forward the dev server's response through
15
+ // here. metro and other non-rolldown bundles pass through unchanged, and so do
16
+ // bundles a producer already annotated. metro's multipart build progress
17
+ // reaches the client while the build runs; only the bundle part waits for its
18
+ // inventory. a failed attach answers with metro's error shape, so the sim
19
+ // reports the cause instead of a bundle without inventory.
20
+ export async function forwardRolldownBundleResponse(
21
+ upstream: IncomingMessage,
22
+ res: ServerResponse | Http2ServerResponse,
23
+ ): Promise<void> {
24
+ res.setHeader(ROLLDOWN_INVENTORY_HEADER, '1')
25
+ if (upstream.headers[ROLLDOWN_INVENTORY_HEADER] === '1') {
26
+ await pipeline(upstream, res)
27
+ return
28
+ }
29
+ const contentType =
30
+ typeof upstream.headers['content-type'] === 'string'
31
+ ? upstream.headers['content-type']
32
+ : ''
33
+ const inventory = getCliRuntime().rolldown_bundle_inventory
34
+ res.removeHeader('content-length')
35
+ const annotate = async function* () {
36
+ const decoder = new TextDecoder()
37
+ let payload = ''
38
+ let sent = 0
39
+ let bundleStarted = false
40
+ for await (const chunk of upstream) {
41
+ payload += decoder.decode(chunk, { stream: true })
42
+ if (bundleStarted) continue
43
+ const releasable = inventory.releasableMultipartPrefix(payload, contentType)
44
+ bundleStarted = releasable.bundleStarted
45
+ if (releasable.length > sent) {
46
+ yield Buffer.from(payload.slice(sent, releasable.length), 'utf8')
47
+ sent = releasable.length
48
+ }
49
+ }
50
+ payload += decoder.decode()
51
+ let annotated: string
52
+ try {
53
+ annotated = await inventory.attachRolldownBundleHttpPayload(payload, contentType)
54
+ } catch (error) {
55
+ const message = `could not attach the rolldown bundle inventory: ${
56
+ error instanceof Error ? error.message : String(error)
57
+ }`
58
+ console.error(`[peach] ${message}`)
59
+ if (contentType.toLowerCase().includes('multipart/mixed')) {
60
+ yield Buffer.from(inventory.multipartFailurePart(contentType, message), 'utf8')
61
+ return
62
+ }
63
+ res.statusCode = 500
64
+ res.setHeader('content-type', 'application/json')
65
+ yield Buffer.from(JSON.stringify({ message }), 'utf8')
66
+ return
67
+ }
68
+ yield Buffer.from(annotated.slice(sent), 'utf8')
69
+ }
70
+ await pipeline(Readable.from(annotate(), { objectMode: false }), res)
71
+ }
@@ -203,8 +203,60 @@ export function readInstalledNativePackageVersions(projectRoot: string): Package
203
203
  return runSync(nativePackageVersionsWalk(projectRoot))
204
204
  }
205
205
 
206
- export function readInstalledNativePackageVersionsAsync(
206
+ // what an install rewrites: the app and workspace manifests, the lockfiles, the
207
+ // package managers' install records and each node_modules directory itself,
208
+ // which changes whenever a package is added, removed or replaced. a long-lived
209
+ // server keys its last scan on these, so a warm bundle skips the walk.
210
+ const INSTALL_RECORD_FILES = [
211
+ 'package.json',
212
+ 'bun.lock',
213
+ 'bun.lockb',
214
+ 'package-lock.json',
215
+ 'yarn.lock',
216
+ 'pnpm-lock.yaml',
217
+ 'node_modules',
218
+ 'node_modules/.package-lock.json',
219
+ 'node_modules/.yarn-integrity',
220
+ 'node_modules/.modules.yaml',
221
+ ]
222
+
223
+ async function installFingerprint(projectRoot: string): Promise<string> {
224
+ const appRoot = await fs.promises.realpath(projectRoot)
225
+ const targets: string[] = []
226
+ for (let dir = appRoot; ; ) {
227
+ if (path.basename(dir) !== 'node_modules')
228
+ for (const file of INSTALL_RECORD_FILES) targets.push(path.join(dir, file))
229
+ const parent = path.dirname(dir)
230
+ if (parent === dir) break
231
+ dir = parent
232
+ }
233
+ const stats = await Promise.all(
234
+ targets.map((target) =>
235
+ fs.promises.stat(target).then(
236
+ (stat) => `${stat.ino}:${stat.size}:${stat.mtimeMs}`,
237
+ () => '',
238
+ ),
239
+ ),
240
+ )
241
+ return `${appRoot}\n${stats.join('\n')}`
242
+ }
243
+
244
+ const scans = new Map<
245
+ string,
246
+ { fingerprint: string; versions: Promise<PackageVersions> }
247
+ >()
248
+
249
+ export async function readInstalledNativePackageVersionsAsync(
207
250
  projectRoot: string,
208
251
  ): Promise<PackageVersions> {
209
- return runAsync(nativePackageVersionsWalk(projectRoot))
252
+ const fingerprint = await installFingerprint(projectRoot)
253
+ const cached = scans.get(projectRoot)
254
+ if (cached?.fingerprint === fingerprint) return cached.versions
255
+ const versions = runAsync(nativePackageVersionsWalk(projectRoot))
256
+ scans.set(projectRoot, { fingerprint, versions })
257
+ // a failed scan is not kept for the next request to inherit
258
+ versions.catch(() => {
259
+ if (scans.get(projectRoot)?.versions === versions) scans.delete(projectRoot)
260
+ })
261
+ return versions
210
262
  }