peachsim 0.1.2242 → 0.1.2243

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 (88) hide show
  1. package/cli/commands/flow.ts +4 -0
  2. package/cli/commands/inspect/settling.ts +7 -2
  3. package/dist-lib/agent-daemon-client.cjs +1 -1
  4. package/dist-lib/agent-events.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +1 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/bundle-channel.cjs +90 -11
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +1 -1
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +1 -1
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +1 -1
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +1 -1
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/config.mjs +1 -1
  26. package/dist-lib/detox/index.cjs +8 -3
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/expo-swift-bundle.cjs +89 -10
  29. package/dist-lib/expo-swift-metadata.cjs +1 -1
  30. package/dist-lib/expo-swift-metadata.mjs +1 -1
  31. package/dist-lib/home-paths.cjs +1 -1
  32. package/dist-lib/host/bridge-host.cjs +97 -23
  33. package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
  34. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  35. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  36. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  37. package/dist-lib/host/websocket-proxy.cjs +1 -1
  38. package/dist-lib/index.cjs +10 -5
  39. package/dist-lib/jump-to-source-babel.cjs +1 -1
  40. package/dist-lib/jump-to-source-native.cjs +1 -1
  41. package/dist-lib/kotlin-host.cjs +1 -1
  42. package/dist-lib/menu.cjs +1 -1
  43. package/dist-lib/menu.mjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  46. package/dist-lib/metro-production-bundle.cjs +1 -1
  47. package/dist-lib/metro-production-bundle.mjs +1 -1
  48. package/dist-lib/metro.cjs +3 -3
  49. package/dist-lib/native-app-identity-project.cjs +2 -2
  50. package/dist-lib/native-app-identity-project.mjs +2 -2
  51. package/dist-lib/native-app-identity.cjs +1 -1
  52. package/dist-lib/native-app-identity.mjs +1 -1
  53. package/dist-lib/native-firebase-metadata.cjs +1 -1
  54. package/dist-lib/native-firebase-metadata.mjs +1 -1
  55. package/dist-lib/pdfium-raster.cjs +1 -1
  56. package/dist-lib/pdfium-raster.mjs +1 -1
  57. package/dist-lib/plist.cjs +1 -1
  58. package/dist-lib/plist.mjs +1 -1
  59. package/dist-lib/profiles.cjs +1 -1
  60. package/dist-lib/public-brand.cjs +1 -1
  61. package/dist-lib/public-origins-lib-esm.json +24 -24
  62. package/dist-lib/public-origins-lib.json +53 -53
  63. package/dist-lib/react-native-host-modules.cjs +1 -1
  64. package/dist-lib/react-native-host-modules.mjs +1 -1
  65. package/dist-lib/reap-browser.cjs +1 -1
  66. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  67. package/dist-lib/sdk.cjs +8 -3
  68. package/dist-lib/sdk.mjs +8 -3
  69. package/dist-lib/skills.cjs +104 -25
  70. package/dist-lib/swift-compile.cjs +4 -3
  71. package/dist-lib/swift-compile.mjs +4 -3
  72. package/dist-lib/swift-package.cjs +1 -1
  73. package/dist-lib/swift-package.mjs +1 -1
  74. package/dist-lib/swift-submit.cjs +2 -2
  75. package/dist-lib/swift-submit.mjs +2 -2
  76. package/dist-lib/swift-toolchain.cjs +1 -1
  77. package/dist-lib/swift.cjs +1 -1
  78. package/dist-lib/vite-swift.cjs +482 -402
  79. package/dist-lib/vite.cjs +3 -3
  80. package/dist-lib/worklet-executable.cjs +1 -1
  81. package/dist-lib/worklet-executable.mjs +1 -1
  82. package/kotlin/sdk.tar.gz +0 -0
  83. package/package.json +1 -1
  84. package/src/host/bridge-host.ts +12 -13
  85. package/src/native-static-libraries.ts +82 -1
  86. package/src/swift-standins.ts +11 -4
  87. package/src/swift-submit.ts +3 -1
  88. package/src/swift-wasm-prune.ts +23 -0
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2242 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2243 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -3228,7 +3228,7 @@ function readIosSdkTree(root) {
3228
3228
 
3229
3229
  // src/swift-standin-digest.ts
3230
3230
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
3231
- var STANDIN_SOURCE_DIGEST = true ? "ae85ffec56f52b5fc73fd9519b221f33abfd4b67aec6d9c5695044b4b6b6ab32" : standinSourceDigest();
3231
+ var STANDIN_SOURCE_DIGEST = true ? "9d24428078636d005cc1401363f5f50704e049f52802b0493da7eea674470942" : standinSourceDigest();
3232
3232
 
3233
3233
  // src/expo-native-workspace.ts
3234
3234
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
@@ -6790,7 +6790,7 @@ var FOUNDATION_IMPLICIT_MODULES = [
6790
6790
  var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
6791
6791
  (module2) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module2}"`
6792
6792
  ).join("");
6793
- var compilerSourceDigest = true ? "6ff3c88ff95ee93cffc6e832c96753820df284d9d2d9a99d405e2cb6be86ed65" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
6793
+ var compilerSourceDigest = true ? "b60df189803fef5c8b8fd902ae0a694ffbefe056af8f5fc06f707750dc97f09b" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
6794
6794
  var CORE_FOUNDATION_HANDLE_IMPORTS = [
6795
6795
  "CFAllocator",
6796
6796
  "CFArray",
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2242 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2243 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2242 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2243 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/worklet-executable.ts
4
4
  import { parse } from "acorn";
package/kotlin/sdk.tar.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.2242",
3
+ "version": "0.1.2243",
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",
@@ -2036,6 +2036,11 @@ export class SootSimBridgeHost {
2036
2036
  )
2037
2037
  }
2038
2038
 
2039
+ private cliHasPendingCommand(ws: WebSocket): boolean {
2040
+ for (const entry of this.cliBySentId.values()) if (entry.ws === ws) return true
2041
+ return false
2042
+ }
2043
+
2039
2044
  private sweepIdleCliClients() {
2040
2045
  const now = Date.now()
2041
2046
  let swept = false
@@ -2044,16 +2049,8 @@ export class SootSimBridgeHost {
2044
2049
  if (now - lastCommand < SootSimBridgeHost.CLI_IDLE_TIMEOUT_MS) continue
2045
2050
  // a long-running forwarded command (e.g. a multi-minute path-traced
2046
2051
  // three-mode render) is still activity: sweeping its socket while the
2047
- // sim is working kills the render with "idle timeout". only sweep
2048
- // sockets with no in-flight command awaiting a sim response.
2049
- let hasPendingCommand = false
2050
- for (const entry of this.cliBySentId.values()) {
2051
- if (entry.ws === ws) {
2052
- hasPendingCommand = true
2053
- break
2054
- }
2055
- }
2056
- if (hasPendingCommand) continue
2052
+ // sim is working kills the render with "idle timeout".
2053
+ if (this.cliHasPendingCommand(ws)) continue
2057
2054
  this.cliSimBySocket.delete(ws)
2058
2055
  this.cliLastCommandAt.delete(ws)
2059
2056
  for (const [sentId, entry] of this.cliBySentId) {
@@ -2479,10 +2476,12 @@ export class SootSimBridgeHost {
2479
2476
  const otherKey = this.cliIdentityKeyBySocket.get(cliWs)
2480
2477
  if (otherKey && otherKey !== cliIdentityKey) {
2481
2478
  this.cliSimBySocket.delete(cliWs)
2482
- try {
2483
- cliWs.close(1000, 'lease claimed by another cli')
2484
- } catch {}
2485
2479
  bootedCount++
2480
+ // a command already forwarded may have changed the sim; closing its
2481
+ // socket would drop that result. it loses the lease either way, so
2482
+ // its next write is refused.
2483
+ if (this.cliHasPendingCommand(cliWs)) continue
2484
+ cliWs.close(1000, 'lease claimed by another cli')
2486
2485
  }
2487
2486
  }
2488
2487
  }
@@ -8,6 +8,7 @@ import { cacheDir as peachCacheDir } from './home-paths'
8
8
  import { fetchNativeEntry, nativeEntryKey } from './native-prebuilt'
9
9
  import { swiftDistributionAt } from './swift-compile'
10
10
  import { swiftModuleToolchain } from './swift-distribution'
11
+ import { localizeDefinedWasmSymbols } from './swift-wasm-prune'
11
12
  import { simulatorNativeLibrary } from './swift-xcframework'
12
13
 
13
14
  // nonmodular frameworks expose C++ declarations through header search paths.
@@ -59,6 +60,7 @@ export const NATIVE_STATIC_LIBRARY_RECIPES = [
59
60
  },
60
61
  {
61
62
  name: 'anydoc_mobile',
63
+ runtime: 'rust',
62
64
  nativeSha256: '03b721dd9e98ec2767f7952aa65cde57d0c33d7ec80c9aaf7ab5ba77e055a25c',
63
65
  upstream: 'e41ad6375fd80b64c4183d1a3f901d1f640a7953',
64
66
  recipe: 'c180538533a79fe1c8babda204170806abe80dd4a546689dcc34c109c9fbfcfc',
@@ -66,6 +68,7 @@ export const NATIVE_STATIC_LIBRARY_RECIPES = [
66
68
  },
67
69
  {
68
70
  name: 'ratex_ffi',
71
+ runtime: 'rust',
69
72
  nativeSha256: '8c41abcd8dd4e562e65cf5b88467a3493089c359d0863360dc65a5b88149e837',
70
73
  upstream: 'a4296fa21cd40a56543602511bcf417014f4fee7cf5e1eaab58e0ac9610e3f63',
71
74
  // the unchanged source build, pinned Rust release and committed Cargo.lock.
@@ -74,6 +77,7 @@ export const NATIVE_STATIC_LIBRARY_RECIPES = [
74
77
  },
75
78
  {
76
79
  name: 'ratex_ffi_0_1_14',
80
+ runtime: 'rust',
77
81
  nativeSha256: 'bdd2bf679fcc981d98d36733b3bd083225a7397bb82bbd462c89088c6e0580a8',
78
82
  upstream: '2da907eb5dfcb464c7eef3b4c657fbdee144e3c6633e81efb1e56dcf1c76e01b',
79
83
  recipe: '537054295b8230548b3959b38459af2606cae69b226e37f6a2e0c227a8ad3cb1',
@@ -245,7 +249,84 @@ export function nativeStaticLibrary(
245
249
  throw new Error(
246
250
  `${file}: native WebAssembly archive ${entry.name}/${entry.key} is not built for this compiler and SDK`,
247
251
  )
248
- return path.join(dir, recipe.archive)
252
+ const archive = path.join(dir, recipe.archive)
253
+ return 'runtime' in recipe ? rustStaticLibrary(archive, moduleRoot) : archive
254
+ }
255
+
256
+ function isRustSymbol(name: string, demangled: string): boolean {
257
+ return (
258
+ ((name.startsWith('_R') || /^_ZN.*17h[0-9a-f]{16}E$/.test(name)) &&
259
+ demangled !== name) ||
260
+ name === 'rust_eh_personality' ||
261
+ name === '__getrandom_v03_custom'
262
+ )
263
+ }
264
+
265
+ export function rustStaticLibrary(file: string, moduleRoot: string): string {
266
+ const toolchain = swiftModuleToolchain(moduleRoot)
267
+ const key = createHash('sha256')
268
+ .update('rust-c-abi-v2\0')
269
+ .update(toolchain.release)
270
+ .update('\0')
271
+ .update(fs.readFileSync(file))
272
+ .digest('hex')
273
+ const directory = path.join(peachCacheDir(), 'native-archives', key)
274
+ const archive = path.join(directory, 'library.a')
275
+ if (fs.existsSync(archive)) return archive
276
+ const flags = ['--no-sort', '--extern-only', '--defined-only', '--format=just-symbols']
277
+ const options = { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 } satisfies Parameters<
278
+ typeof execFileSync
279
+ >[2]
280
+ const symbols = (input: string) => {
281
+ const raw = execFileSync(
282
+ path.join(toolchain.toolchainBin, 'llvm-nm'),
283
+ [...flags, input],
284
+ options,
285
+ )
286
+ .trim()
287
+ .split('\n')
288
+ const demangled = execFileSync(
289
+ path.join(toolchain.toolchainBin, 'llvm-nm'),
290
+ [...flags, '--demangle', input],
291
+ options,
292
+ )
293
+ .trim()
294
+ .split('\n')
295
+ if (raw.length !== demangled.length)
296
+ throw new Error(`${file}: Rust symbol table changed during intake`)
297
+ return raw.map((name, index) => ({ name, demangled: demangled[index]! }))
298
+ }
299
+ if (!symbols(file).some(({ name, demangled }) => isRustSymbol(name, demangled)))
300
+ return file
301
+ fs.mkdirSync(directory, { recursive: true })
302
+ const stage = fs.mkdtempSync(path.join(directory, 'build-'))
303
+ try {
304
+ const object = path.join(stage, 'library.o')
305
+ execFileSync(path.join(toolchain.toolchainBin, 'wasm-ld'), [
306
+ '-mwasm64',
307
+ '-r',
308
+ '--whole-archive',
309
+ file,
310
+ '--no-whole-archive',
311
+ '-o',
312
+ object,
313
+ ])
314
+ const names = new Set(
315
+ symbols(object)
316
+ .filter(
317
+ ({ name, demangled }) =>
318
+ isRustSymbol(name, demangled) || name.startsWith('anon.'),
319
+ )
320
+ .map(({ name }) => name),
321
+ )
322
+ fs.writeFileSync(object, localizeDefinedWasmSymbols(fs.readFileSync(object), names))
323
+ const output = path.join(stage, 'library.a')
324
+ execFileSync(path.join(toolchain.toolchainBin, 'llvm-ar'), ['rcsD', output, object])
325
+ fs.renameSync(output, archive)
326
+ } finally {
327
+ fs.rmSync(stage, { recursive: true, force: true })
328
+ }
329
+ return archive
249
330
  }
250
331
 
251
332
  /** keep a pod's ordered archive members in the one library its target transports. */
@@ -18,7 +18,11 @@ import { cacheDir as peachCacheDir } from './home-paths'
18
18
  import { isRecord } from './is-record'
19
19
  import { fetchNativeEntry, nativeEntryKey } from './native-prebuilt'
20
20
  import { nativeSliceEntry, NATIVE_SLICE_RECIPES } from './native-slices'
21
- import { nativeStaticLibrary, nativeStaticLibraryRecipe } from './native-static-libraries'
21
+ import {
22
+ nativeStaticLibrary,
23
+ nativeStaticLibraryRecipe,
24
+ rustStaticLibrary,
25
+ } from './native-static-libraries'
22
26
  import { nativeSwiftSlice } from './native-swift-slices'
23
27
  import { tryAcquireNumberedLock } from './numbered-lock'
24
28
  import { outputLockStdio } from './output-lock-stdio'
@@ -2354,7 +2358,8 @@ export function standinLibrary(
2354
2358
  throw new Error(
2355
2359
  `${path.relative(searchRoot, supplied)} holds no single static library${library ? ` named ${library}` : ''}`,
2356
2360
  )
2357
- return path.join(supplied, chosen)
2361
+ if (!toolchain) throw new Error('supplied native libraries need the Swift SDK')
2362
+ return rustStaticLibrary(path.join(supplied, chosen), toolchain.moduleRoot)
2358
2363
  }
2359
2364
  if (native && toolchain && fs.existsSync(native.file)) {
2360
2365
  const recipe = nativeStaticLibraryRecipe(fs.readFileSync(native.file))
@@ -2379,8 +2384,10 @@ export function standinLibrary(
2379
2384
  if (!toolchain) throw new Error('Rust native libraries need the Swift SDK')
2380
2385
  const entry = rustCrateEntry(manifest, library, toolchain.moduleRoot, searchRoot)
2381
2386
  const prebuilt = fetchNativeEntry('rust', entry.name, entry.key)
2382
- if (prebuilt) return path.join(prebuilt, library)
2383
- return buildRustCrate(manifest, library, searchRoot, toolchain.moduleRoot, entry)
2387
+ const archive = prebuilt
2388
+ ? path.join(prebuilt, library)
2389
+ : buildRustCrate(manifest, library, searchRoot, toolchain.moduleRoot, entry)
2390
+ return rustStaticLibrary(archive, toolchain.moduleRoot)
2384
2391
  }
2385
2392
 
2386
2393
  /** compiles a crate with the same rust standard library as registry archives. */
@@ -149,7 +149,9 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
149
149
  // 70: full Objective-C forwarding uses exact typed IMPs (`peach.imp_forwarder_mint`).
150
150
  // 71: UIImage pixels register once through `peach.bitmap_register` and
151
151
  // `peach.bitmap_release`; trees name them `peach-bitmap:<id>`.
152
- export const SWIFT_HOST_ABI = 71
152
+ // 72: a refresh may answer `{"$patch":[node]}`, nodes that replace the same
153
+ // ids in the last tree.
154
+ export const SWIFT_HOST_ABI = 72
153
155
 
154
156
  export interface SwiftImageUpload {
155
157
  /** the raster file picked for the asset (has the extension). */
@@ -365,6 +365,7 @@ function parseWasmObjectBytes(
365
365
  file: string,
366
366
  buf: Uint8Array,
367
367
  isDist: boolean,
368
+ symbolFlagOffsets?: number[],
368
369
  ): ParsedObject {
369
370
  let pos = 8
370
371
  let numImportFuncs = 0
@@ -525,6 +526,7 @@ function parseWasmObjectBytes(
525
526
  let cur = p2
526
527
  for (let i = 0; i < cnt; i++) {
527
528
  const kind = buf[cur++]!
529
+ if (symbolFlagOffsets) symbolFlagOffsets[i] = cur
528
530
  const [fl, c2] = readULEB(buf, cur)
529
531
  cur = c2
530
532
  symKind[i] = kind
@@ -803,6 +805,27 @@ function parseWasmObjectCached(
803
805
  return parsed
804
806
  }
805
807
 
808
+ export function localizeDefinedWasmSymbols(
809
+ bytes: Uint8Array,
810
+ names: ReadonlySet<string>,
811
+ ): Uint8Array {
812
+ const offsets: number[] = []
813
+ const object = parseWasmObjectBytes('', bytes, false, offsets)
814
+ const output = Uint8Array.from(bytes)
815
+ let changed = 0
816
+ for (let index = 0; index < object.symNames.length; index++) {
817
+ if (!names.has(object.symNames[index]!)) continue
818
+ if ((object.symFlags[index]! & 3) === 2) continue
819
+ if (object.symFlags[index]! & 0x10)
820
+ throw new Error('cannot localize an undefined symbol')
821
+ const offset = offsets[index]!
822
+ output[offset] = (output[offset]! & ~0x23) | 0x02
823
+ changed++
824
+ }
825
+ if (changed !== names.size) throw new Error('Wasm symbols to localize were not defined')
826
+ return output
827
+ }
828
+
806
829
  /** Original undefined symbols from a selected Wasm object. */
807
830
  export function guestWasmUndefinedSymbols(bytes: Uint8Array): string[] {
808
831
  return guestWasmSymbols(bytes).undefined