peachsim 0.1.825 → 0.1.826

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 (83) hide show
  1. package/cli/commands/record.ts +33 -14
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/agent-identity.cjs +1 -1
  5. package/dist-lib/agent-sessions.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/bundle-channel.cjs +1 -1
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +1 -1
  19. package/dist-lib/cli-constants.cjs +1 -1
  20. package/dist-lib/cloud-contract.cjs +1 -1
  21. package/dist-lib/cloud-contract.mjs +1 -1
  22. package/dist-lib/cloud-test-args.cjs +1 -1
  23. package/dist-lib/cloud-test-args.mjs +1 -1
  24. package/dist-lib/cloud.cjs +1 -1
  25. package/dist-lib/cloud.mjs +1 -1
  26. package/dist-lib/config.cjs +1 -1
  27. package/dist-lib/detox/index.cjs +1 -1
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/expo-swift-bundle.cjs +1 -1
  30. package/dist-lib/expo-swift-metadata.cjs +1 -1
  31. package/dist-lib/expo-swift-metadata.mjs +1 -1
  32. package/dist-lib/home-paths.cjs +9 -1
  33. package/dist-lib/host/bridge-host.cjs +265 -219
  34. package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +2 -2
  39. package/dist-lib/index.cjs +1 -1
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +1 -1
  50. package/dist-lib/native-app-identity.cjs +1 -1
  51. package/dist-lib/native-app-identity.mjs +1 -1
  52. package/dist-lib/native-firebase-metadata.cjs +1 -1
  53. package/dist-lib/native-firebase-metadata.mjs +1 -1
  54. package/dist-lib/plist.cjs +1 -1
  55. package/dist-lib/plist.mjs +1 -1
  56. package/dist-lib/profiles.cjs +1 -1
  57. package/dist-lib/public-brand.cjs +1 -1
  58. package/dist-lib/react-native-host-modules.cjs +1 -1
  59. package/dist-lib/react-native-host-modules.mjs +1 -1
  60. package/dist-lib/render-mode.cjs +1 -1
  61. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  62. package/dist-lib/sdk.cjs +1 -1
  63. package/dist-lib/sdk.mjs +1 -1
  64. package/dist-lib/skills.cjs +504 -456
  65. package/dist-lib/swift-compile.cjs +1 -1
  66. package/dist-lib/swift-compile.mjs +1 -1
  67. package/dist-lib/swift-package.cjs +1 -1
  68. package/dist-lib/swift-package.mjs +1 -1
  69. package/dist-lib/swift-submit.cjs +1 -1
  70. package/dist-lib/swift-submit.mjs +1 -1
  71. package/dist-lib/swift-toolchain.cjs +1 -1
  72. package/dist-lib/swift.cjs +1 -1
  73. package/dist-lib/vite-swift.cjs +1 -1
  74. package/dist-lib/vite.cjs +1 -1
  75. package/dist-lib/worklet-executable.cjs +1 -1
  76. package/dist-lib/worklet-executable.mjs +1 -1
  77. package/package.json +1 -1
  78. package/scripts/dev-server-scanner.ts +4 -1
  79. package/src/home-paths.ts +8 -0
  80. package/src/host/bridge-host.ts +4 -1
  81. package/src/host/fetch-proxy-handler.ts +5 -1
  82. package/src/host/fetch-proxy-transport.ts +76 -18
  83. package/src/host/websocket-proxy.ts +3 -1
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import { execFile as execFile2, execFileSync } from "node:child_process";
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/swift-package.ts
4
4
  function isSwiftManifestFile(file) {
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/swift-submit.ts
4
4
  var SWIFT_COMPILE_PATH = "/api/swift-compile";
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.825 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.826 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/worklet-executable.ts
4
4
  import { parse } from "acorn";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.825",
3
+ "version": "0.1.826",
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",
@@ -385,9 +385,12 @@ async function listListeners(): Promise<ListeningProcessScan> {
385
385
 
386
386
  // lsof layout: COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
387
387
  // NAME looks like "*:8081" or "127.0.0.1:8081" for a LISTEN line.
388
+ // -a -c limits the descriptor walk to node and bun; without it every dev
389
+ // server's scan reads every process's descriptors, and polled tabs made
390
+ // lsof most of a builder's filesystem calls.
388
391
  try {
389
392
  const { stdout } = await execGuarded(
390
- `lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'`,
393
+ `lsof -a -c node -c bun -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'`,
391
394
  LISTING_TIMEOUT_MS,
392
395
  )
393
396
  const seen = new Map<number, number>()
package/src/home-paths.ts CHANGED
@@ -19,6 +19,9 @@
19
19
  // │ └── peach-runtime-<version>.tar.gz
20
20
  // ├── daemon.json lockfile: pid, ports, active runtime, heartbeat
21
21
  // ├── dev-bridges/ live Vite dev bridge records, keyed by bound port
22
+ // ├── fetch-transport/ the http/2 image transport's tls identity and port,
23
+ // │ keyed by bridge port, so a restarted bridge answers
24
+ // │ at the origin and certificate live sims were given
22
25
  // ├── runtime-upgraded.json one-shot notice written by the daemon's
23
26
  // │ background updater, consumed (printed + deleted)
24
27
  // │ by the next interactive CLI run
@@ -37,6 +40,7 @@ export const PEACH_HOME_ENV = 'PEACH_HOME'
37
40
  export const ACTIVE_RUNTIME_FILE = 'active'
38
41
  export const DAEMON_LOCKFILE = 'daemon.json'
39
42
  export const DEV_BRIDGES_DIR = 'dev-bridges'
43
+ export const FETCH_TRANSPORT_DIR = 'fetch-transport'
40
44
  export const CONFIG_FILE = 'config.json'
41
45
  export const CLI_UPDATE_FILE = 'cli-update.json'
42
46
  export const DAEMON_HEARTBEAT_STALE_MS = 30_000
@@ -188,6 +192,10 @@ export function devBridgesDir(): string {
188
192
  return path.join(rnxHomeDir(), DEV_BRIDGES_DIR)
189
193
  }
190
194
 
195
+ export function fetchTransportIdentityPath(bridgePort: number): string {
196
+ return path.join(rnxHomeDir(), FETCH_TRANSPORT_DIR, `${bridgePort}.json`)
197
+ }
198
+
191
199
  export function devBridgeLockfilePath(bridgePort: number): string {
192
200
  if (!Number.isInteger(bridgePort) || bridgePort <= 0) {
193
201
  throw new Error(`invalid development bridge port: ${bridgePort}`)
@@ -32,6 +32,7 @@ import {
32
32
  writeRuntimeUpgradeNotice,
33
33
  writeSharedConfig,
34
34
  cameraFixturesDir,
35
+ fetchTransportIdentityPath,
35
36
  rnxHomeDir,
36
37
  type DaemonLockfile,
37
38
  type DevBridgeLockfile,
@@ -516,7 +517,9 @@ export class SootSimBridgeHost {
516
517
  )
517
518
  }
518
519
  try {
519
- this.fetchProxyTransport = await startFetchProxyTransport()
520
+ this.fetchProxyTransport = await startFetchProxyTransport(
521
+ fetchTransportIdentityPath(boundPort),
522
+ )
520
523
  } catch (error) {
521
524
  await this.close()
522
525
  throw error
@@ -233,7 +233,11 @@ export async function handleFetchProxyRequest(
233
233
  const abort = () => proxyReq.destroy(new Error('fetch proxy client disconnected'))
234
234
  req.once('aborted', abort)
235
235
  proxyReq.once('close', () => req.off('aborted', abort))
236
- proxyReq.once('error', reject)
236
+ // listen for the request's whole life, never once: how many 'error'
237
+ // events one destroy(err) emits depends on the runtime (node 25 emits
238
+ // the abort twice when it lands while a pooled socket is being handed
239
+ // over), and an unheard second one crashes the host
240
+ proxyReq.on('error', reject)
237
241
  if (nextBody === undefined) proxyReq.end()
238
242
  else proxyReq.end(nextBody)
239
243
  })
@@ -1,5 +1,7 @@
1
1
  import { createHash, randomBytes } from 'node:crypto'
2
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
2
3
  import { createSecureServer, type ServerHttp2Session } from 'node:http2'
4
+ import path from 'node:path'
3
5
  import { SubjectAlternativeNameExtension, X509CertificateGenerator } from '@peculiar/x509'
4
6
  import {
5
7
  handleFetchProxyRequest,
@@ -8,9 +10,37 @@ import {
8
10
  rejectUntrustedBridgeOrigin,
9
11
  } from './fetch-proxy-handler.ts'
10
12
 
11
- // image bytes use multiplexed tls streams. the websocket control server keeps
12
- // its own listener, so image backpressure cannot consume its connection slots.
13
- export async function startFetchProxyTransport() {
13
+ type FetchTransportIdentity = { key: string; cert: string; spki: string; port: number }
14
+
15
+ function readIdentity(identityPath: string): FetchTransportIdentity | null {
16
+ let parsed: unknown
17
+ try {
18
+ parsed = JSON.parse(readFileSync(identityPath, 'utf8'))
19
+ } catch {
20
+ return null
21
+ }
22
+ if (!parsed || typeof parsed !== 'object') return null
23
+ const key = Reflect.get(parsed, 'key')
24
+ const cert = Reflect.get(parsed, 'cert')
25
+ const spki = Reflect.get(parsed, 'spki')
26
+ const port = Reflect.get(parsed, 'port')
27
+ if (
28
+ typeof key !== 'string' ||
29
+ typeof cert !== 'string' ||
30
+ typeof spki !== 'string' ||
31
+ typeof port !== 'number'
32
+ ) {
33
+ return null
34
+ }
35
+ return { key, cert, spki, port }
36
+ }
37
+
38
+ function writeIdentity(identityPath: string, identity: FetchTransportIdentity) {
39
+ mkdirSync(path.dirname(identityPath), { recursive: true })
40
+ writeFileSync(identityPath, JSON.stringify(identity), { mode: 0o600 })
41
+ }
42
+
43
+ async function createIdentity(): Promise<Omit<FetchTransportIdentity, 'port'>> {
14
44
  const algorithm = { name: 'ECDSA', namedCurve: 'P-256', hash: 'SHA-256' }
15
45
  const keys = await crypto.subtle.generateKey(algorithm, true, ['sign', 'verify'])
16
46
  const certificate = await X509CertificateGenerator.createSelfSigned(
@@ -28,17 +58,34 @@ export async function startFetchProxyTransport() {
28
58
  crypto,
29
59
  )
30
60
  const privateKey = Buffer.from(await crypto.subtle.exportKey('pkcs8', keys.privateKey))
31
- const spki = createHash('sha256')
32
- .update(Buffer.from(await crypto.subtle.exportKey('spki', keys.publicKey)))
33
- .digest('base64')
61
+ return {
62
+ cert: certificate.toString('pem'),
63
+ key: `-----BEGIN PRIVATE KEY-----\n${privateKey
64
+ .toString('base64')
65
+ .match(/.{1,64}/g)
66
+ ?.join('\n')}\n-----END PRIVATE KEY-----\n`,
67
+ spki: createHash('sha256')
68
+ .update(Buffer.from(await crypto.subtle.exportKey('spki', keys.publicKey)))
69
+ .digest('base64'),
70
+ }
71
+ }
72
+
73
+ // image bytes use multiplexed tls streams. the websocket control server keeps
74
+ // its own listener, so image backpressure cannot consume its connection slots.
75
+ //
76
+ // a live sim carries this transport's origin in its page url and chrome trusts
77
+ // only the certificate key it was launched with, so the identity (key and
78
+ // port) persists per bridge port: a bridge restarted after a crash answers at
79
+ // the same origin with the same key, and the sim's bundle, asset and image
80
+ // fetches keep working without reopening it. a port another process took
81
+ // since gets a fresh one, which only sims opened from then on can reach.
82
+ export async function startFetchProxyTransport(identityPath: string) {
83
+ const identity = readIdentity(identityPath) ?? { ...(await createIdentity()), port: 0 }
34
84
  const sessions = new Set<ServerHttp2Session>()
35
85
  const server = createSecureServer(
36
86
  {
37
- cert: certificate.toString('pem'),
38
- key: `-----BEGIN PRIVATE KEY-----\n${privateKey
39
- .toString('base64')
40
- .match(/.{1,64}/g)
41
- ?.join('\n')}\n-----END PRIVATE KEY-----\n`,
87
+ cert: identity.cert,
88
+ key: identity.key,
42
89
  settings: { maxConcurrentStreams: 256 },
43
90
  },
44
91
  (req, res) => {
@@ -58,18 +105,29 @@ export async function startFetchProxyTransport() {
58
105
  session.once('close', () => sessions.delete(session))
59
106
  session.on('error', () => session.destroy())
60
107
  })
61
- await new Promise<void>((resolve, reject) => {
62
- server.once('error', reject)
63
- server.listen(0, '127.0.0.1', () => {
64
- server.off('error', reject)
65
- resolve()
108
+ const listen = (port: number) =>
109
+ new Promise<void>((resolve, reject) => {
110
+ server.once('error', reject)
111
+ server.listen(port, '127.0.0.1', () => {
112
+ server.off('error', reject)
113
+ resolve()
114
+ })
66
115
  })
67
- })
116
+ try {
117
+ await listen(identity.port)
118
+ } catch (error) {
119
+ const taken = error instanceof Error && Reflect.get(error, 'code') === 'EADDRINUSE'
120
+ if (identity.port === 0 || !taken) throw error
121
+ await listen(0)
122
+ }
68
123
  const address = server.address()
69
124
  if (!address || typeof address === 'string')
70
125
  throw new Error('fetch proxy has no address')
126
+ if (address.port !== identity.port) {
127
+ writeIdentity(identityPath, { ...identity, port: address.port })
128
+ }
71
129
  return {
72
- descriptor: { origin: `https://127.0.0.1:${address.port}`, spki },
130
+ descriptor: { origin: `https://127.0.0.1:${address.port}`, spki: identity.spki },
73
131
  async close() {
74
132
  for (const session of sessions) session.destroy()
75
133
  await new Promise<void>((resolve) => server.close(() => resolve()))
@@ -257,7 +257,9 @@ export function handleWebSocketProxyUpgrade(
257
257
  response.resume()
258
258
  fail(502, 'upstream websocket rejected upgrade')
259
259
  })
260
- upstreamRequest.once('error', () => {
260
+ // every error, never once: a destroy() can emit more than one (see
261
+ // fetch-proxy-handler.ts), and an unheard one crashes the host
262
+ upstreamRequest.on('error', () => {
261
263
  fail(502, 'upstream websocket error')
262
264
  })
263
265
  upstreamRequest.once('upgrade', (response, upstreamSocket, upstreamHead) => {