peachsim 0.1.2438 → 0.1.2440

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 (183) hide show
  1. package/README.md +30 -98
  2. package/cli/app-catalog.ts +4 -73
  3. package/cli/catalog/content.ts +1 -1
  4. package/cli/cloud-box-artifact.ts +26 -39
  5. package/cli/cloud-client.ts +69 -117
  6. package/cli/cloud-session.ts +2 -9
  7. package/cli/commands/box.ts +6 -6
  8. package/cli/commands/control.ts +4 -11
  9. package/cli/commands/flow.ts +5 -9
  10. package/cli/commands/kotlin.ts +2 -1
  11. package/cli/commands/platform.ts +21 -39
  12. package/cli/commands/record-three.ts +1 -1
  13. package/cli/commands/shell-url.ts +29 -23
  14. package/cli/dev-build-freshness.ts +4 -3
  15. package/cli/native-input.ts +2 -2
  16. package/cli/outbound-endpoints.ts +20 -45
  17. package/cli/remote-project-bundle.ts +8 -14
  18. package/cli/remote-simulators.ts +1 -1
  19. package/cli/send-to-box.ts +2 -1
  20. package/detox/jest-preset.cjs +1 -1
  21. package/detox/jest-transform.cjs +40 -2
  22. package/dist-lib/agent-daemon-client.cjs +34 -24
  23. package/dist-lib/agent-events.cjs +1 -1
  24. package/dist-lib/attached-projects.cjs +19 -17
  25. package/dist-lib/auth/shared-session.cjs +18 -16
  26. package/dist-lib/backend-origin.cjs +1 -1
  27. package/dist-lib/beta.cjs +1 -1
  28. package/dist-lib/beta.mjs +2 -1
  29. package/dist-lib/bridge-constants.cjs +1 -1
  30. package/dist-lib/bridge-contract-input.cjs +1 -1
  31. package/dist-lib/bridge-contract-input.mjs +20 -583
  32. package/dist-lib/bridge-contract.cjs +1 -1
  33. package/dist-lib/bridge-contract.mjs +17 -99
  34. package/dist-lib/bundle-channel.cjs +8743 -5562
  35. package/dist-lib/capture-contract.cjs +1 -1
  36. package/dist-lib/capture-contract.mjs +13 -363
  37. package/dist-lib/cloud-contract.cjs +1 -1
  38. package/dist-lib/cloud-contract.mjs +34 -155
  39. package/dist-lib/cloud-test-args.cjs +1 -1
  40. package/dist-lib/cloud-test-args.mjs +2 -1
  41. package/dist-lib/cloud.cjs +1 -1
  42. package/dist-lib/cloud.mjs +26 -155
  43. package/dist-lib/config.cjs +1 -4
  44. package/dist-lib/config.mjs +11 -30
  45. package/dist-lib/detox/index.cjs +2554 -230
  46. package/dist-lib/detox/jest-preset.cjs +1 -1
  47. package/dist-lib/detox/jest-transform.cjs +40 -2
  48. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  49. package/dist-lib/esm-chunks/acorn-B27MTHKJ.mjs +50 -0
  50. package/dist-lib/esm-chunks/chunk-4U7IGWPB.mjs +42 -0
  51. package/dist-lib/esm-chunks/chunk-5CZQZKYU.mjs +10 -0
  52. package/dist-lib/esm-chunks/chunk-6HFWZJ6C.mjs +115 -0
  53. package/dist-lib/esm-chunks/chunk-6JGALQD5.mjs +12 -0
  54. package/dist-lib/esm-chunks/chunk-ADE23YGG.mjs +30 -0
  55. package/dist-lib/esm-chunks/chunk-D4Z36DQQ.mjs +186 -0
  56. package/dist-lib/esm-chunks/chunk-EATI62W3.mjs +188 -0
  57. package/dist-lib/esm-chunks/chunk-H6QIEJRC.mjs +10992 -0
  58. package/dist-lib/esm-chunks/chunk-HIK3VREC.mjs +1353 -0
  59. package/dist-lib/esm-chunks/chunk-HP7DHONL.mjs +598 -0
  60. package/dist-lib/esm-chunks/chunk-PRZI3CFF.mjs +5719 -0
  61. package/dist-lib/esm-chunks/chunk-QECVPSP3.mjs +10 -0
  62. package/dist-lib/esm-chunks/chunk-R5FNLCBO.mjs +17 -0
  63. package/dist-lib/esm-chunks/chunk-RVMUQQWC.mjs +664 -0
  64. package/dist-lib/esm-chunks/chunk-SJFNKW3W.mjs +57 -0
  65. package/dist-lib/esm-chunks/chunk-WQISIGIX.mjs +10 -0
  66. package/dist-lib/esm-chunks/chunk-X6UKJ5AX.mjs +375 -0
  67. package/dist-lib/esm-chunks/chunk-ZXNBC3PZ.mjs +18959 -0
  68. package/dist-lib/esm-chunks/metro-layout-parser-ZOI5PO4E.mjs +58 -0
  69. package/dist-lib/expo-swift-bundle.cjs +7881 -4717
  70. package/dist-lib/expo-swift-metadata.cjs +1 -1
  71. package/dist-lib/expo-swift-metadata.mjs +16 -165
  72. package/dist-lib/home-paths.cjs +1 -1
  73. package/dist-lib/host/bridge-host.cjs +15685 -11414
  74. package/dist-lib/host/fetch-proxy-handler.cjs +3928 -343
  75. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  76. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -1
  77. package/dist-lib/host/replacement-module-handler.cjs +4 -4
  78. package/dist-lib/host/websocket-proxy.cjs +1 -1
  79. package/dist-lib/index.cjs +9145 -32150
  80. package/dist-lib/jump-to-source-babel.cjs +1 -1
  81. package/dist-lib/jump-to-source-native.cjs +2 -2
  82. package/dist-lib/kotlin-host.cjs +260 -253
  83. package/dist-lib/menu.cjs +1 -1
  84. package/dist-lib/menu.mjs +5 -13
  85. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  86. package/dist-lib/metro-fingerprint-registry.mjs +5 -6
  87. package/dist-lib/metro-production-bundle.cjs +22 -3
  88. package/dist-lib/metro-production-bundle.mjs +26 -92
  89. package/dist-lib/native-app-identity-project.cjs +664 -452
  90. package/dist-lib/native-app-identity-project.mjs +509 -2318
  91. package/dist-lib/native-app-identity.cjs +1 -1
  92. package/dist-lib/native-app-identity.mjs +27 -1340
  93. package/dist-lib/native-firebase-metadata.cjs +1 -1
  94. package/dist-lib/native-firebase-metadata.mjs +5 -18
  95. package/dist-lib/pdfium-raster.cjs +1 -1
  96. package/dist-lib/pdfium-raster.mjs +2 -1
  97. package/dist-lib/plist.cjs +2 -2
  98. package/dist-lib/plist.mjs +5 -7
  99. package/dist-lib/profiles.cjs +2 -1
  100. package/dist-lib/public-brand.cjs +1 -1
  101. package/dist-lib/public-origins-lib-esm.json +246 -187
  102. package/dist-lib/public-origins-lib-static.json +1 -1
  103. package/dist-lib/public-origins-lib.json +1059 -1238
  104. package/dist-lib/react-native-host-modules.cjs +1 -1
  105. package/dist-lib/react-native-host-modules.mjs +2 -1
  106. package/dist-lib/reap-browser.cjs +18 -7
  107. package/dist-lib/scripts/dev-server-scanner.cjs +6 -230
  108. package/dist-lib/sdk.cjs +1 -1
  109. package/dist-lib/sdk.mjs +22 -78
  110. package/dist-lib/skills.cjs +21694 -17393
  111. package/dist-lib/swift-compile.cjs +1355 -1322
  112. package/dist-lib/swift-compile.mjs +68 -19013
  113. package/dist-lib/swift-package.cjs +1 -1
  114. package/dist-lib/swift-package.mjs +35 -630
  115. package/dist-lib/swift-submit.cjs +1 -1
  116. package/dist-lib/swift-submit.mjs +9 -24
  117. package/dist-lib/swift-toolchain.cjs +1 -1
  118. package/dist-lib/swift.cjs +1 -1
  119. package/dist-lib/vendor/@peculiar/x509.cjs +18061 -0
  120. package/dist-lib/vendor/acorn.cjs +5699 -0
  121. package/dist-lib/vendor/bplist-parser.cjs +1589 -0
  122. package/dist-lib/vendor/ignore.cjs +455 -0
  123. package/dist-lib/vendor/magic-string.cjs +1693 -0
  124. package/dist-lib/vendor/plist.cjs +10978 -0
  125. package/dist-lib/vendor/smol-toml.cjs +768 -0
  126. package/dist-lib/vendor/stream-json.cjs +1997 -0
  127. package/dist-lib/vendor/sucrase/dist/index.js.cjs +23593 -0
  128. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +15750 -0
  129. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +11316 -0
  130. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +482 -0
  131. package/dist-lib/vendor/sucrase.cjs +23593 -0
  132. package/dist-lib/vendor/terser.cjs +36874 -0
  133. package/dist-lib/vendor/valibot.cjs +6253 -0
  134. package/dist-lib/vendor/zod.cjs +23262 -0
  135. package/dist-lib/worklet-executable.cjs +3 -3
  136. package/dist-lib/worklet-executable.mjs +11 -16
  137. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +4 -0
  138. package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
  139. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
  140. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +9 -0
  141. package/kotlin/fork/NOTICE +3 -0
  142. package/kotlin/sdk.tar.gz +0 -0
  143. package/kotlin/toolchain.json +6 -6
  144. package/package.json +17 -121
  145. package/runtime-companion.json +1 -1
  146. package/scripts/dev-server-scanner.ts +13 -223
  147. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDateComponentsFormatter.h +1 -1
  148. package/src/android-autolinking.ts +2 -2
  149. package/src/bundle-channel.mjs +3 -15
  150. package/src/cloud-contract.ts +3 -4
  151. package/src/config.ts +0 -5
  152. package/src/host/bridge-host.ts +21 -1
  153. package/src/host/server-scan-handler.ts +1 -9
  154. package/src/index.ts +0 -2
  155. package/src/kotlin-host.ts +1 -2
  156. package/src/kotlinDiscoveryContract.ts +1 -0
  157. package/src/metro-production-bundle.ts +28 -6
  158. package/src/native-seam-manifest.ts +0 -13
  159. package/src/native-slices.ts +1 -1
  160. package/src/one-native-app-catalog.ts +8 -27
  161. package/src/one-native-app-config.ts +95 -0
  162. package/src/one-native-source.ts +250 -0
  163. package/src/one-widget-metadata.ts +45 -126
  164. package/src/oneWidgetContract.ts +80 -117
  165. package/src/serverDiscoveryContract.ts +0 -1
  166. package/src/simulator-route.ts +8 -0
  167. package/src/swift-compile.ts +13 -7
  168. package/src/swift-host.ts +2 -0
  169. package/src/swift-package-manifest.ts +13 -8
  170. package/src/vite-plugin.ts +2 -2
  171. package/src/xcode-project.ts +1 -1
  172. package/dist-lib/metro.cjs +0 -27984
  173. package/dist-lib/vite-swift.cjs +0 -43376
  174. package/dist-lib/vite.cjs +0 -21456
  175. package/src/androidAutolinkingContract.ts +0 -48
  176. package/src/androidRootModuleContract.ts +0 -39
  177. package/src/dev-server-open.ts +0 -92
  178. package/src/metro-plugin.ts +0 -578
  179. package/src/one-widget-discovery.ts +0 -23
  180. package/src/swift-vite-lifetime.ts +0 -42
  181. package/src/vite-plugin-one.ts +0 -746
  182. package/src/vite-plugin-swift.ts +0 -225
  183. package/src/vite.d.ts +0 -10
package/README.md CHANGED
@@ -34,8 +34,6 @@ What this workspace gives you:
34
34
  - the standalone `peach` CLI source and binary build, which provides the primary
35
35
  debugging and automation surface (inspect the UI tree, tap elements, capture
36
36
  flows, screenshot, record, run agents)
37
- - `peachsim/vite` and `peachsim/metro` — bundler plugins that serve the installed
38
- engine runtime from your own dev server
39
37
  - `peachsim/jump-to-source-babel` — an optional Babel plugin that annotates JSX
40
38
  with source locations so inspect mode can open the selected element in your
41
39
  editor
@@ -55,7 +53,7 @@ repo plan pass.
55
53
 
56
54
  | standalone `peach` executable | `peachsim` npm package | private engine runtime |
57
55
  | --- | --- | --- |
58
- | CLI commands and bridge client | Vite and Metro plugins | CanvasKit renderer and Yoga layout |
56
+ | CLI commands and bridge client | config types and the Vite Swift plugin | CanvasKit renderer and Yoga layout |
59
57
  | bridge daemon host | SDK and bridge contracts | iOS/Android shell chrome, home grid, app switcher |
60
58
  | runtime, browser, and desktop launchers | Detox driver and Jest preset | Electron shell and wasm |
61
59
  | Maestro, screenshots, recording, skills | native-resolution helpers and skills registry | the actual pixels |
@@ -98,9 +96,7 @@ graph TD
98
96
  TENANTW["tenant worker (guest RN app tree)"]
99
97
  end
100
98
  subgraph build["build-time plugins (src/)"]
101
- VITEONE["peachsim/vite = vite-plugin-one.ts (serve runtime at /__peachsim/)"]
102
99
  VITERN["sootsim() = vite-plugin.ts (RN resolver + native stubs)"]
103
- METRO["peachsim/metro = metro-plugin.ts"]
104
100
  COMPAT["@sootsim/compat stub-manifest (native seams)"]
105
101
  ENGINESHIM["sootsim-engine react-native shim"]
106
102
  end
@@ -143,7 +139,6 @@ graph TD
143
139
  DRIVERS -->|"open sim page URL"| SHELLW
144
140
  SHELLW -->|"NativeUIRequest"| TENANTW
145
141
  VITEONE -->|"serve /__peachsim/ from"| RTDIR
146
- METRO -->|"serve /__peachsim/ from"| RTDIR
147
142
  VITEONE -.->|"launch electron app"| SHELLW
148
143
  VITERN -->|"alias react-native"| ENGINESHIM
149
144
  VITERN -->|"alias native pkgs"| COMPAT
@@ -269,22 +264,13 @@ page run three workers: the **shell worker** owns device and native state, the
269
264
  worker** runs the guest RN tree and sends native-UI requests to the shell. The
270
265
  bridge always addresses the **shell worker**, never an undifferentiated sim.
271
266
 
272
- **Two distinct plugin families** round it out, and they must not be conflated:
273
-
274
- - The published **`peachsim/vite`** (`src/vite-plugin-one.ts`, `peachPlugin`)
275
- and **`peachsim/metro`** plugins do one thing: serve the installed runtime at
276
- `/__peachsim/` so an app's own dev server can host the sim shell. The Vite plugin accepts an
277
- opt-in `open` option that launches a named Electron window when the dev server
278
- starts (skipped when `CI` or `PEACH_NO_OPEN` is set). It preserves shell query
279
- parameters and explicit `bundle` values. A nonempty `demoApp` selects shell
280
- content without adding a guest bundle; other launches receive the default
281
- One bundle at the request's HTTP/1 Host or HTTP/2 authority.
282
- - The internal **`sootsim()`** plugin (`src/vite-plugin.ts`) is a separate, much
283
- larger RN-resolution / native-stub plugin: it aliases `react-native` to the
284
- engine shim and native packages to `@sootsim/compat` stubs, applies worklets
285
- transforms, and is the one that instantiates `SootSimBridgeHost` inside its
286
- own dev server. It is used to build the engine/shell and to load external RN
287
- apps — it is **not** the published `peachsim/vite` export.
267
+ Apps need no bundler plugin. The bridge host serves the shell, replacement
268
+ modules and native compiles, and the CLI reads versions and native identity
269
+ from the app project. The internal **`sootsim()`** plugin (`src/vite-plugin.ts`)
270
+ is an RN-resolution / native-stub plugin: it aliases `react-native` to the
271
+ engine shim and native packages to `@sootsim/compat` stubs, applies worklets
272
+ transforms, and instantiates `SootSimBridgeHost` inside its own dev server. It
273
+ builds the engine and shell and loads external RN apps; it is not published.
288
274
 
289
275
  Preview uploads retain one response snapshot in the simulator and transfer
290
276
  its base64 bodies in bounded slices, including authenticated API responses.
@@ -313,8 +299,7 @@ therefore runs before assertions in each flow.
313
299
  | host proxies + dev-server scan | Host-side helpers so a cross-origin tenant worker can reach local dev servers and same-origin APIs: `/__server-scan` discovers running metro/expo/vxrn/one servers; fetch + websocket proxies relay guest-app network through the daemon. An optional network policy authorizes each of those hops before it transmits ([Network policy](#network-policy)). | `src/host/fetch-proxy-handler.ts`, `src/host/websocket-proxy.ts`, `src/host/network-policy.ts`, `src/host/network-policy-proxy.ts`, `src/host/websocket-frame-guard.ts`, `scripts/dev-server-scanner.ts`, `src/dev-bundle-resolution.ts` |
314
300
  | runtime delivery + Peach home | Versioned engine runtime management. The shared machinery owns manifest fetch, sha256 verification, channels, and auto-update. Peach binds it to `https://contrast.dev` and `~/.peach/runtimes/<version>`. A repo can select `runtimeVersion` without changing the machine default. | `src/runtime-delivery.ts`, `packages/contrast-runtime-delivery/`, `src/home-paths.ts`, `src/runtime-assets.ts` |
315
301
  | standalone CLI delivery | Cached stable-version checks, bounded interactive notices, and verified atomic executable replacement. | `cli/cli-update.ts`, `cli/commands/upgrade.ts`, `cli/commands/version.ts`, `src/cli-version.ts` |
316
- | `peachsim/vite` + `peachsim/metro` (runtime serving) | Published bundler plugins. Both serve the installed engine runtime at `/__peachsim/` from `~/.peach/runtimes/<version>` so an app's own dev server can host the sim shell; the Vite plugin can opt into a named Electron window. | `src/vite-plugin-one.ts`, `src/metro-plugin.ts`, `src/runtime-assets.ts` |
317
- | `sootsim()` vite resolver plugin (internal) | The large RN-resolution / native-stub vite plugin: aliases `react-native` to the engine shim, native packages to `@sootsim/compat` stubs, and applies worklets/babel transforms. Distinct from the published `peachsim/vite` export. | `src/vite-plugin.ts`, `src/worklets-babel.ts`, `packages/peach-globals/src/guest-modules/stub-manifest.ts` |
302
+ | `sootsim()` vite resolver plugin (internal) | The large RN-resolution / native-stub vite plugin: aliases `react-native` to the engine shim, native packages to `@sootsim/compat` stubs, and applies worklets/babel transforms. Not published. | `src/vite-plugin.ts`, `src/worklets-babel.ts`, `packages/peach-globals/src/guest-modules/stub-manifest.ts` |
318
303
  | skills registry | Peach agent skills (`peach-setup`, `peach-debug`, `peach-test`, `peach-visual`, and the generated `contrast` index) installable with `peach skill`. | `skills/*.md`, `src/skills/registry.ts`, `src/skills/types.ts` |
319
304
 
320
305
  ## Getting started
@@ -584,86 +569,33 @@ the complete per-step result. Reusable file-based flows stay in Maestro YAML.
584
569
  peach do tap email --then type user@example.com --then tap submit
585
570
  ```
586
571
 
587
- ## Bundler plugins (`peachsim/vite` and `peachsim/metro`)
588
-
589
- The Vite plugin serves the installed Peach runtime from your existing dev server.
590
-
591
- ```ts
592
- // vite.config.ts
593
- import { peachPlugin } from 'peachsim/vite'
594
-
595
- export default {
596
- plugins: [peachPlugin({ open: { appName: 'My App' } })],
597
- }
598
- ```
599
-
600
- ```js
601
- // metro.config.js
602
- const { getDefaultConfig } = require('expo/metro-config')
603
- const { withPeach } = require('peachsim/metro')
604
-
605
- const config = getDefaultConfig(__dirname)
606
-
607
- module.exports = withPeach(config)
608
- ```
609
-
610
- Peach works directly with regular, unannotated Metro production JavaScript bundles
611
- out of the box. It identifies modules by matching package graph fingerprints
612
- against a separately updated, integrity-checked registry. Hermes bytecode is not
613
- a supported input; pass Peach the JavaScript bundle produced before Hermes
614
- compilation.
615
-
616
- If an app has unusual dependencies or fingerprint inference fails, you can
617
- optionally wrap your Metro configuration with `withPeach(config)`. It enables
618
- two integrations:
619
-
620
- 1. **Deterministic module identity:** appends Metro's exact module identity map
621
- as a trailing `globalThis.__sootsimModulePaths = { ... }` footer to every
622
- bundle. Resolution, transforms, minification, and source maps stay the app's
623
- own, so the annotated bundle is the exact bundle you ship: the footer assigns
624
- one unused global on a device, and Hermes drops it during bytecode compilation.
625
- 2. **In-browser dev shell:** serves the Peach simulator shell at `/__peachsim/` on
626
- the Metro dev server.
627
-
628
- Native app identity also travels in the bundle. Android permissions come only
629
- from a completed app manifest merger output. A sole output under
630
- `android/<module>/build/intermediates/merged_manifests/` is selected automatically;
631
- select one explicitly when multiple variants exist:
632
-
633
- ```js
634
- module.exports = withPeach(config, {
635
- androidMergedManifest:
636
- 'android/app/build/intermediates/merged_manifests/debug/processDebugManifest/AndroidManifest.xml',
637
- })
638
- ```
639
-
640
- Without resolved merged output, Android permissions contain only the explicit
641
- Expo `android.permissions` set minus `android.blockedPermissions`. Defaults,
642
- plugins and linked library additions require completed merged output. See the
572
+ ## Metro bundles
573
+
574
+ Apps need no Metro plugin or config change. `peach open`, `peach ios` and
575
+ `peach android` read the app project and stamp what the engine needs on the
576
+ page URL: package versions, native app identity, Firebase config, and the
577
+ Android autolinked packages and root module.
578
+
579
+ Peach works directly with regular, unannotated Metro production JavaScript
580
+ bundles. It identifies modules by matching package graph fingerprints against a
581
+ separately updated, integrity-checked registry. Hermes bytecode is not a
582
+ supported input; pass Peach the JavaScript bundle produced before Hermes
583
+ compilation. Development bundles carry their module names in Metro's own
584
+ registrations.
585
+
586
+ Android permissions come only from a completed app manifest merger output.
587
+ Peach uses the sole output under
588
+ `android/<module>/build/intermediates/merged_manifests/`. With none or several,
589
+ Android permissions contain only the explicit Expo `android.permissions` set
590
+ minus `android.blockedPermissions`; defaults, plugins and linked library
591
+ additions require a single completed merged output. See the
643
592
  [native identity contract](../../specs/peach/engine/native-app-identity.md).
644
593
 
645
- The URL helpers request ordinary Metro graphs: `dev=false&minify=true` for
646
- production and `dev=true&minify=false` for development.
647
-
648
594
  Metro registration readers retain the original factory bytes and module IDs.
649
595
  Empty dependencies may be an empty array, an omitted production argument, or a
650
596
  null development argument before the module name. Identity validation and
651
597
  fingerprinting treat each as zero dependencies and reject malformed arguments.
652
598
 
653
- ```js
654
- const {
655
- toPeachProductionBundleUrl,
656
- toPeachDevelopmentBundleUrl,
657
- } = require('peachsim/metro')
658
-
659
- const productionUrl = toPeachProductionBundleUrl(
660
- 'http://localhost:8081/index.bundle?platform=ios',
661
- )
662
- const developmentUrl = toPeachDevelopmentBundleUrl(
663
- 'http://localhost:8081/index.bundle?platform=ios',
664
- )
665
- ```
666
-
667
599
  ## Coming from Detox
668
600
 
669
601
  Peach ships a drop-in Detox driver. Existing Detox test files
@@ -940,5 +872,5 @@ bun run build:cli-binary
940
872
  The output is `dist-bin/peach-<platform>-<arch>`. `dist-cli/bin.js` remains a
941
873
  repository build artifact for tests and internal tooling and is not published
942
874
  as an npm executable. Library exports build to `dist-lib/` (consumed via the
943
- `exports` map: `.`, `./vite`, `./metro`, `./sdk`, `./skills`, `./detox`, and the
875
+ `exports` map: `.`, `./config`, `./sdk`, `./skills`, `./detox`, and the
944
876
  host/agent helpers). `bun run pack:smoke` validates the publishable tarball.
@@ -1,9 +1,5 @@
1
- import { execFile } from 'node:child_process'
2
1
  import fs from 'node:fs'
3
- import { createRequire } from 'node:module'
4
2
  import path from 'node:path'
5
- import { pathToFileURL } from 'node:url'
6
- import { promisify } from 'node:util'
7
3
  import {
8
4
  enumerateBundleColors,
9
5
  enumerateBundleImages,
@@ -14,11 +10,7 @@ import {
14
10
  prepareExpoNativeProject,
15
11
  } from '../src/expo-native-workspace'
16
12
  import { stageHostFile } from '../src/host/staged-host-files'
17
- import {
18
- ONE_NATIVE_APP_CATALOG_ROUTE,
19
- parseOneNativeAppCatalog,
20
- readOneNativeAppCatalog,
21
- } from '../src/one-native-app-catalog'
13
+ import { readOneNativeAppCatalog } from '../src/one-native-app-catalog'
22
14
  import { findExpoAppConfig } from './app-project'
23
15
  import type { AppCatalog } from '#peach-cli-contract/engine/app-catalog-wire'
24
16
  import type { OneNativeAppCatalog } from '../src/one-native-app-catalog'
@@ -174,71 +166,10 @@ export function oneDeclaredAppCatalog(
174
166
  return catalog
175
167
  }
176
168
 
177
- // a running dev server reports the declaration from its evaluated config. a
178
- // server busy with its first bundle build answers late, so `peach open` asks
179
- // before it requests the bundle.
180
- export async function fetchOneNativeAppCatalogDeclaration(
181
- metroOrigin: string,
182
- ): Promise<OneNativeAppCatalog | null> {
183
- const response = await fetch(`${metroOrigin}${ONE_NATIVE_APP_CATALOG_ROUTE}`, {
184
- signal: AbortSignal.timeout(1500),
185
- }).catch(() => null)
186
- if (
187
- !response?.ok ||
188
- !(response.headers.get('content-type') ?? '').toLowerCase().includes('json')
189
- )
190
- return null
191
- return parseOneNativeAppCatalog(await response.json().catch(() => null))
192
- }
193
-
194
- export async function discoverOneNativeAppCatalog(
195
- metroOrigin: string,
196
- assetOrigin: string,
197
- ): Promise<AppCatalog | null> {
198
- const declared = await fetchOneNativeAppCatalogDeclaration(metroOrigin)
199
- return declared ? oneDeclaredAppCatalog(declared, assetOrigin) : null
200
- }
201
-
202
- export async function discoverProjectOneNativeAppCatalog(
169
+ export function discoverProjectOneNativeAppCatalog(
203
170
  projectRoot: string,
204
171
  assetOrigin: string,
205
- ): Promise<AppCatalog | null> {
206
- const declared = await readProjectOneNativeAppCatalog(projectRoot, process.env, 'node')
172
+ ): AppCatalog | null {
173
+ const declared = readOneNativeAppCatalog(projectRoot)
207
174
  return declared ? oneDeclaredAppCatalog(declared, assetOrigin) : null
208
175
  }
209
-
210
- // a production bundle has no dev server: evaluate the app's vite config with
211
- // One's own loader, the one `one prebuild` reads native.app through.
212
- export async function readProjectOneNativeAppCatalog(
213
- projectRoot: string,
214
- env: NodeJS.ProcessEnv,
215
- runtimeExecutable: string,
216
- ): Promise<OneNativeAppCatalog | null> {
217
- let onePackage: string
218
- try {
219
- onePackage = createRequire(path.join(projectRoot, 'package.json')).resolve(
220
- 'one/package.json',
221
- )
222
- } catch {
223
- return null
224
- }
225
- const loader = pathToFileURL(
226
- path.join(path.dirname(onePackage), 'dist/esm/vite/loadConfig.mjs'),
227
- ).href
228
- const { stdout } = await promisify(execFile)(
229
- runtimeExecutable,
230
- [
231
- '--input-type=module',
232
- '-e',
233
- `const { loadUserOneOptions } = await import(process.argv[1])
234
- const { oneOptions } = await loadUserOneOptions('build', true)
235
- const app = typeof oneOptions?.native === 'object' ? oneOptions.native.app : undefined
236
- process.stdout.write('\\n' + JSON.stringify({ app }) + '\\n')
237
- process.exit(0)`,
238
- loader,
239
- ],
240
- { cwd: projectRoot, env, maxBuffer: 64 * 1024 * 1024 },
241
- )
242
- const json = stdout.split('\n').findLast((line) => line.startsWith('{"app"'))
243
- return readOneNativeAppCatalog(json ? JSON.parse(json) : null, projectRoot)
244
- }
@@ -153,7 +153,7 @@ peach ios --remote .
153
153
 
154
154
  Peach builds the app with the app's own bundler, compiles its Expo modules, Nitro modules and C++ TurboModules on your Mac, and ships them with the bundle. Your Metro config needs no changes. Remote Android simulators do not load compiled Kotlin modules yet.
155
155
 
156
- A prebuilt bundle also works. Build it with \`expo export:embed\` or \`react-native bundle\` through \`withPeach(config)\` from \`peachsim/metro\`, which records your installed package versions, then pass the file. Peach compiles the native modules of the app folder above the bundle, or of \`--native-project <app-dir>\`:
156
+ A prebuilt bundle also works. Build it with \`expo export:embed\` or \`react-native bundle\`, then pass the file. Peach reads the installed package versions and compiles the native modules of the app folder above the bundle, or of \`--native-project <app-dir>\`:
157
157
 
158
158
  \`\`\`sh
159
159
  npx expo export:embed --platform ios --dev false --bundle-output dist/main.js --assets-dest dist
@@ -2,19 +2,25 @@
2
2
  // its compiled native modules beside it. it compiles on the cli's machine, so
3
3
  // it lives apart from cloud-client, which the box worker itself bundles.
4
4
  import { createHash } from 'node:crypto'
5
- import { existsSync, readFileSync } from 'node:fs'
6
- import { dirname, join, resolve } from 'node:path'
7
5
  import { prebuiltNativeAssetUrl } from '@peach/box/template'
8
- import { readPackageVersionsFooter } from '@peach/globals/package-versions'
6
+ import {
7
+ insertAndroidAutolinkingFooter,
8
+ readAndroidAutolinkingFooter,
9
+ } from '@peach/globals/android-autolinking'
10
+ import {
11
+ insertAndroidRootModuleFooter,
12
+ readAndroidRootModuleFooter,
13
+ } from '@peach/globals/android-root-module'
14
+ import { collectAndroidAutolinkedPackages } from '../src/android-autolinking'
15
+ import { readAndroidLauncherRootModuleName } from '../src/android-root-module'
9
16
  import { getCliRuntime } from '../src/cli-runtime.ts'
10
- import { isRecord } from '../src/is-record'
11
17
  import { detectBundleModeFromText } from '../src/metro-production-bundle.ts'
12
18
  import {
13
19
  buildNativeBundles,
14
20
  insertNativeBundleFooters,
15
21
  nativeBundleAssets,
16
22
  } from '../src/native-bundles'
17
- import { embedBundleAssets, isRemoteBundleInput } from './cloud-client.ts'
23
+ import { embedBundleAssets } from './cloud-client.ts'
18
24
  import { buildRemoteProjectBundle } from './remote-project-bundle'
19
25
  import type { RemotePlatform } from './cloud-session.ts'
20
26
 
@@ -34,27 +40,6 @@ export interface CloudBoxArtifactProduction {
34
40
  warnings: string[]
35
41
  }
36
42
 
37
- // the app a local bundle was built from: the nearest directory above it whose
38
- // package.json depends on react-native, as `expo export:embed` and
39
- // `react-native bundle` write into the project.
40
- function bundleAppProject(bundlePath: string): string | null {
41
- if (isRemoteBundleInput(bundlePath)) return null
42
- for (let dir = dirname(resolve(bundlePath)); ; dir = dirname(dir)) {
43
- const manifest = join(dir, 'package.json')
44
- if (existsSync(manifest)) {
45
- const json: unknown = JSON.parse(readFileSync(manifest, 'utf8'))
46
- if (
47
- isRecord(json) &&
48
- [json.dependencies, json.devDependencies].some(
49
- (dependencies) => isRecord(dependencies) && 'react-native' in dependencies,
50
- )
51
- )
52
- return dir
53
- }
54
- if (dirname(dir) === dir) return null
55
- }
56
- }
57
-
58
43
  /**
59
44
  * prepares a prebuilt bundle for a Box: the Metro assets beside the bundle
60
45
  * travel inside it, because the box page boots these bytes with no server of
@@ -77,28 +62,18 @@ export async function produceCloudBoxArtifact(
77
62
  : await buildRemoteProjectBundle(input.projectDir, platform, input.buildDir)
78
63
  const assetsDirectory =
79
64
  typeof input === 'string' ? options.assetsDirectory : input.buildDir
80
- const prepared = await embedBundleAssets(
65
+ return embedBundleAssets(
81
66
  bundlePath,
82
67
  'peach box create',
83
68
  assetsDirectory ? 'require-assets' : 'allow-placeholders',
84
69
  assetsDirectory,
85
70
  options.assetServer,
71
+ typeof input === 'string' ? options.nativeProjectDir : input.projectDir,
86
72
  )
87
- if (!readPackageVersionsFooter(prepared.source)?.['react-native']) {
88
- throw new Error(
89
- 'remote simulator bundle is missing __peachPackageVersions with the installed react-native version. Wrap your project Metro config with withPeach from peachsim/metro, then rebuild the bundle before running peach ios --remote or peach android --remote.',
90
- )
91
- }
92
- return prepared
93
73
  })()
94
74
  const nativePreparation = (async () => {
95
- if (typeof input === 'string') await preparation
96
75
  const nativeProject =
97
- typeof input !== 'string'
98
- ? input.projectDir
99
- : options.nativeProjectDir
100
- ? resolve(options.nativeProjectDir)
101
- : bundleAppProject(input)
76
+ typeof input === 'string' ? (await preparation).project : input.projectDir
102
77
  const natives = nativeProject
103
78
  ? await buildNativeBundles(nativeProject, platform, async () =>
104
79
  (await detectBundleModeFromText((await preparation).source)) === 'production'
@@ -125,6 +100,18 @@ export async function produceCloudBoxArtifact(
125
100
  )
126
101
  }
127
102
  let code = prepared.code
103
+ // the box page has no cli beside it, so the app's Android linking travels
104
+ // in the bundle.
105
+ if (nativeProject && platform === 'android') {
106
+ if (readAndroidAutolinkingFooter(code) === null)
107
+ code = insertAndroidAutolinkingFooter(
108
+ code,
109
+ await collectAndroidAutolinkedPackages(nativeProject),
110
+ )
111
+ const root = readAndroidLauncherRootModuleName(nativeProject)
112
+ if (root !== undefined && readAndroidRootModuleFooter(code) === null)
113
+ code = insertAndroidRootModuleFooter(code, root)
114
+ }
128
115
  const nativeAssets: CloudBoxNativeAsset[] = []
129
116
  if (natives) {
130
117
  // a Kotlin module imports its loader and wasm by relative url, which the