peachsim 0.1.2243 → 0.1.2246

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 (108) hide show
  1. package/cli/binary-sidecar.ts +89 -0
  2. package/cli/bridge-flow-runner.ts +9 -8
  3. package/cli/cloud-client.ts +2 -0
  4. package/cli/commands/control.ts +16 -0
  5. package/cli/commands/device.ts +1 -1
  6. package/cli/commands/flow.ts +2 -2
  7. package/cli/commands/inspect/core.ts +0 -20
  8. package/cli/commands/inspect/settling.ts +10 -1
  9. package/cli/commands/inspect.ts +5 -5
  10. package/cli/commands/preview.ts +12 -5
  11. package/cli/commands/shell-boolean-mode.ts +1 -1
  12. package/cli/commands/slides.ts +1 -1
  13. package/dist-lib/agent-daemon-client.cjs +1 -1
  14. package/dist-lib/agent-events.cjs +1 -1
  15. package/dist-lib/attached-projects.cjs +1 -1
  16. package/dist-lib/auth/shared-session.cjs +1 -1
  17. package/dist-lib/backend-origin.cjs +1 -1
  18. package/dist-lib/beta.cjs +1 -1
  19. package/dist-lib/beta.mjs +1 -1
  20. package/dist-lib/bridge-constants.cjs +1 -1
  21. package/dist-lib/bridge-contract-input.cjs +1 -1
  22. package/dist-lib/bridge-contract-input.mjs +1 -1
  23. package/dist-lib/bridge-contract.cjs +1 -1
  24. package/dist-lib/bridge-contract.mjs +1 -1
  25. package/dist-lib/bundle-channel.cjs +72 -17
  26. package/dist-lib/capture-contract.cjs +1 -1
  27. package/dist-lib/capture-contract.mjs +1 -1
  28. package/dist-lib/cloud-contract.cjs +1 -1
  29. package/dist-lib/cloud-contract.mjs +1 -1
  30. package/dist-lib/cloud-test-args.cjs +1 -1
  31. package/dist-lib/cloud-test-args.mjs +1 -1
  32. package/dist-lib/cloud.cjs +1 -1
  33. package/dist-lib/cloud.mjs +1 -1
  34. package/dist-lib/config.cjs +1 -1
  35. package/dist-lib/config.mjs +1 -1
  36. package/dist-lib/detox/index.cjs +11 -4
  37. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  38. package/dist-lib/expo-swift-bundle.cjs +71 -16
  39. package/dist-lib/expo-swift-metadata.cjs +1 -1
  40. package/dist-lib/expo-swift-metadata.mjs +1 -1
  41. package/dist-lib/home-paths.cjs +1 -1
  42. package/dist-lib/host/bridge-host.cjs +92 -18
  43. package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
  44. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  45. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  46. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  47. package/dist-lib/host/websocket-proxy.cjs +1 -1
  48. package/dist-lib/index.cjs +13 -6
  49. package/dist-lib/jump-to-source-babel.cjs +1 -1
  50. package/dist-lib/jump-to-source-native.cjs +1 -1
  51. package/dist-lib/kotlin-host.cjs +1 -1
  52. package/dist-lib/menu.cjs +11 -2
  53. package/dist-lib/menu.mjs +11 -2
  54. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  55. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  56. package/dist-lib/metro-production-bundle.cjs +1 -1
  57. package/dist-lib/metro-production-bundle.mjs +1 -1
  58. package/dist-lib/metro.cjs +3 -3
  59. package/dist-lib/native-app-identity-project.cjs +2 -2
  60. package/dist-lib/native-app-identity-project.mjs +2 -2
  61. package/dist-lib/native-app-identity.cjs +1 -1
  62. package/dist-lib/native-app-identity.mjs +1 -1
  63. package/dist-lib/native-firebase-metadata.cjs +1 -1
  64. package/dist-lib/native-firebase-metadata.mjs +1 -1
  65. package/dist-lib/pdfium-raster.cjs +1 -1
  66. package/dist-lib/pdfium-raster.mjs +1 -1
  67. package/dist-lib/plist.cjs +1 -1
  68. package/dist-lib/plist.mjs +1 -1
  69. package/dist-lib/profiles.cjs +1 -1
  70. package/dist-lib/public-brand.cjs +1 -1
  71. package/dist-lib/public-origins-lib-esm.json +24 -24
  72. package/dist-lib/public-origins-lib.json +55 -53
  73. package/dist-lib/react-native-host-modules.cjs +1 -1
  74. package/dist-lib/react-native-host-modules.mjs +1 -1
  75. package/dist-lib/reap-browser.cjs +1 -1
  76. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  77. package/dist-lib/sdk.cjs +11 -23
  78. package/dist-lib/sdk.mjs +11 -21
  79. package/dist-lib/skills.cjs +946 -750
  80. package/dist-lib/swift-compile.cjs +65 -10
  81. package/dist-lib/swift-compile.mjs +65 -10
  82. package/dist-lib/swift-package.cjs +1 -1
  83. package/dist-lib/swift-package.mjs +1 -1
  84. package/dist-lib/swift-submit.cjs +1 -1
  85. package/dist-lib/swift-submit.mjs +1 -1
  86. package/dist-lib/swift-toolchain.cjs +1 -1
  87. package/dist-lib/swift.cjs +1 -1
  88. package/dist-lib/vite-swift.cjs +70 -15
  89. package/dist-lib/vite.cjs +3 -3
  90. package/dist-lib/worklet-executable.cjs +1 -1
  91. package/dist-lib/worklet-executable.mjs +1 -1
  92. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
  93. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +1 -0
  94. package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -1
  95. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  96. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
  97. package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -0
  98. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +8 -1
  99. package/dist-types/packages/peach-engine/src/render-worker/image-pixel-contract.d.ts +4 -0
  100. package/dist-types/packages/peach-engine/src/render-worker/resilient-frame-clock.d.ts +1 -0
  101. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -1
  102. package/kotlin/sdk.tar.gz +0 -0
  103. package/package.json +1 -1
  104. package/src/binarySidecarContract.ts +45 -0
  105. package/src/menu.ts +14 -0
  106. package/src/swift-guest-image-ledger.ts +74 -7
  107. package/src/swift-guest-link.ts +3 -1
  108. package/src/swift-host.ts +6 -7
@@ -1209,6 +1209,7 @@ export interface CompositorStats {
1209
1209
  };
1210
1210
  webViewCaptureSettled?: boolean;
1211
1211
  }
1212
+ export type CompositorPixelReads = 'frame' | 'composite';
1212
1213
  export interface PromotedLayerOffer {
1213
1214
  key: string;
1214
1215
  surfaceId: CompositorSurfaceId;
@@ -1345,6 +1346,7 @@ export type CompositorHostToWorker = {
1345
1346
  format?: PresentedFrameCaptureFormat;
1346
1347
  suppressText?: SootSimCaptureOptions['suppressText'];
1347
1348
  captureFilter?: SootSimCaptureOptions['captureFilter'];
1349
+ reads?: CompositorPixelReads;
1348
1350
  } | ({
1349
1351
  type: 'dump';
1350
1352
  requestId: number;
@@ -1438,6 +1440,7 @@ export type CompositorHostToWorker = {
1438
1440
  } | {
1439
1441
  type: 'renderActivitySubscription';
1440
1442
  active: boolean;
1443
+ holds: boolean;
1441
1444
  } | {
1442
1445
  type: 'ambientGlow';
1443
1446
  active: boolean;
@@ -1534,6 +1537,10 @@ export type ShellToCompositorMessage = {
1534
1537
  } | {
1535
1538
  type: 'foldMotion';
1536
1539
  active: boolean;
1540
+ } | {
1541
+ type: 'treeFence';
1542
+ } | {
1543
+ type: 'treeSettled';
1537
1544
  } | EngineResourceResponse | WireSurfaceUpdate | {
1538
1545
  type: 'shellInbox';
1539
1546
  buffer: SharedArrayBuffer;
@@ -1801,7 +1808,7 @@ export type ShellToCompositorMessage = {
1801
1808
  port: MessagePort;
1802
1809
  };
1803
1810
  export type ShellCompositorInboxMessage = Extract<ShellToCompositorMessage, WireSurfaceUpdate | {
1804
- type: 'appMotion' | 'retireAnimatedDrivenStyle' | 'animatedPresentation' | 'animatedPresentationChanged' | 'clearAnimatedPresentation' | 'screenTransitionDrive' | 'screenTransitionCancel';
1811
+ type: 'appMotion' | 'retireAnimatedDrivenStyle' | 'animatedPresentation' | 'animatedPresentationChanged' | 'clearAnimatedPresentation' | 'screenTransitionDrive' | 'screenTransitionCancel' | 'treeFence' | 'treeSettled';
1805
1812
  }>;
1806
1813
  export declare function isShellCompositorInboxMessage(message: ShellToCompositorMessage): message is ShellCompositorInboxMessage;
1807
1814
  export type CompositorWorkerToHost = {
@@ -6,6 +6,10 @@ export type ImagePixelRequest = {
6
6
  readonly width: number;
7
7
  readonly height: number;
8
8
  } | null;
9
+ readonly urgent: boolean;
10
+ } | {
11
+ readonly kind: 'raise';
12
+ readonly id: number;
9
13
  } | {
10
14
  readonly kind: 'cancel';
11
15
  readonly id: number;
@@ -19,5 +19,6 @@ export interface ResilientFrameClock {
19
19
  resetStats(): void;
20
20
  dispose(): void;
21
21
  nextDisplayAfter(t: number): number | null;
22
+ displayIntervalMs(): number | null;
22
23
  }
23
24
  export declare function createResilientFrameClock(options: ResilientFrameClockOptions): ResilientFrameClock;
@@ -149,7 +149,7 @@ export interface BottomTabBarProps {
149
149
  barBacked?: boolean;
150
150
  bottomAccessory?: BottomTabAccessoryRenderer;
151
151
  accessoryOnly?: boolean;
152
- bottomAccessorySizing?: 'fill';
152
+ bottomAccessorySizing?: 'fill' | 'swiftuiSlot';
153
153
  onBottomInsetChange?: (inset: number) => void;
154
154
  isMinimized?: boolean;
155
155
  minimizeState?: TabBarMinimizeState;
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.2243",
3
+ "version": "0.1.2246",
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",
@@ -0,0 +1,45 @@
1
+ import {
2
+ type PackageVersions,
3
+ readPackageVersions,
4
+ } from '@peach/globals/package-versions'
5
+
6
+ // a binary we build carries the plain javascript its hermes bytecode was
7
+ // compiled from, so `peach open` runs the same graph the device does. it sits
8
+ // in the app bundle on ios and under the apk's assets on android, beside the
9
+ // manifest naming the native package versions peach's stubs read.
10
+ export const PEACH_SIDECAR_DIR = 'peach'
11
+ export const PEACH_SIDECAR_BUNDLE = 'main.js.br'
12
+ export const PEACH_SIDECAR_MANIFEST = 'app.json'
13
+ // android resources are recompiled into the apk, so the sidecar keeps the
14
+ // assets-dest copy; an ios app bundle holds metro's assets as they were.
15
+ export const PEACH_SIDECAR_ASSETS = 'assets'
16
+
17
+ export type PeachSidecarManifest = {
18
+ format: 1
19
+ platform: 'ios' | 'android'
20
+ // sha256 of the decompressed bundle
21
+ bundleSha256: string
22
+ nativePackages: PackageVersions
23
+ }
24
+
25
+ export function readPeachSidecarManifest(value: unknown): PeachSidecarManifest {
26
+ if (
27
+ typeof value !== 'object' ||
28
+ value === null ||
29
+ !('format' in value) ||
30
+ value.format !== 1 ||
31
+ !('platform' in value) ||
32
+ (value.platform !== 'ios' && value.platform !== 'android') ||
33
+ !('bundleSha256' in value) ||
34
+ typeof value.bundleSha256 !== 'string' ||
35
+ !/^[a-f0-9]{64}$/.test(value.bundleSha256) ||
36
+ !('nativePackages' in value)
37
+ )
38
+ throw new Error('invalid peach sidecar manifest')
39
+ return {
40
+ format: 1,
41
+ platform: value.platform,
42
+ bundleSha256: value.bundleSha256,
43
+ nativePackages: readPackageVersions(value.nativePackages),
44
+ }
45
+ }
package/src/menu.ts CHANGED
@@ -88,6 +88,9 @@ export interface SootSimMenuState {
88
88
  canRotate: boolean
89
89
  // the way each rotate press turns the body, where the surface knows its stance
90
90
  rotateTurns?: Record<SootSimTurn, SootSimTurn>
91
+ // the hosted simulator this window watches, when the link that opened it
92
+ // named one. it has a page on the site, which File offers to open.
93
+ remoteSimulator: string | null
91
94
  }
92
95
 
93
96
  export interface SootSimMenuDeviceChoice {
@@ -214,6 +217,16 @@ function fileMenu(
214
217
  state: SootSimMenuState,
215
218
  deviceChoices: readonly SootSimMenuDeviceChoice[],
216
219
  ): SootSimMenuDef {
220
+ const remoteSimulator: SootSimMenuItemDef[] = state.remoteSimulator
221
+ ? [
222
+ { type: 'separator' },
223
+ {
224
+ label: 'Open in Browser',
225
+ action: 'open-remote-simulator',
226
+ hiddenIn: 'browser',
227
+ },
228
+ ]
229
+ : []
217
230
  return {
218
231
  label: 'File',
219
232
  notMinimal: true,
@@ -256,6 +269,7 @@ function fileMenu(
256
269
  label: 'Send to Box',
257
270
  action: 'send-to-box',
258
271
  },
272
+ ...remoteSimulator,
259
273
  ],
260
274
  }
261
275
  }
@@ -133,6 +133,7 @@ function rewriteObject(
133
133
  ): {
134
134
  readonly bytes: Uint8Array
135
135
  readonly definitions: readonly ObjectDefinition[]
136
+ readonly functionImports: ReadonlyMap<string, FunctionType>
136
137
  readonly usesDlsym: boolean
137
138
  readonly usedSymbols: readonly string[]
138
139
  } {
@@ -142,6 +143,7 @@ function rewriteObject(
142
143
  const types: FunctionType[] = []
143
144
  const functionTypes: number[] = []
144
145
  const definitions: ObjectDefinition[] = []
146
+ const functionImports = new Map<string, FunctionType>()
145
147
  let usesDlsym = false
146
148
  let usesDlerror = false
147
149
  const usedSymbols = new Set<string>()
@@ -213,6 +215,11 @@ function rewriteObject(
213
215
  const isDlerror =
214
216
  instrumentDynamicLookups && module === 'env' && name === 'dlerror' && kind === 0
215
217
  if (module === 'env' && names.has(name)) usedSymbols.add(name)
218
+ if (module === 'env' && kind === 0 && names.has(name)) {
219
+ const type = types[functionType]
220
+ if (!type) throw new Error(`missing import type for ${name}`)
221
+ functionImports.set(name, type)
222
+ }
216
223
  if (isDlsym || isDlerror) {
217
224
  const type = types[functionType]
218
225
  const expected = isDlsym ? '126,126:126' : ':126'
@@ -395,6 +402,7 @@ function rewriteObject(
395
402
  return {
396
403
  bytes: Buffer.concat(sections),
397
404
  definitions,
405
+ functionImports,
398
406
  usesDlsym,
399
407
  usedSymbols: [...usedSymbols],
400
408
  }
@@ -429,6 +437,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
429
437
  object: GuestImageObject
430
438
  aliases: Map<string, string>
431
439
  usedSymbols: readonly string[]
440
+ functionImports: ReadonlyMap<string, FunctionType>
432
441
  }[] = []
433
442
  const callersUsingDlsym = new Set<number>()
434
443
  for (const image of input.images) {
@@ -452,7 +461,13 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
452
461
  new Set(),
453
462
  )
454
463
  if (rewritten.usesDlsym) callersUsingDlsym.add(image.id)
455
- units.push({ image: image.id, object, aliases, usedSymbols: rewritten.usedSymbols })
464
+ units.push({
465
+ image: image.id,
466
+ object,
467
+ aliases,
468
+ usedSymbols: rewritten.usedSymbols,
469
+ functionImports: rewritten.functionImports,
470
+ })
456
471
  for (const symbol of rewritten.definitions) {
457
472
  if (symbol.type && symbol.type.results.length > 1)
458
473
  throw new Error(`multiple results for ${symbol.name}`)
@@ -563,9 +578,43 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
563
578
  bindings.set(binding.symbol, matches[0]!.alias)
564
579
  startup.set(binding.object, bindings)
565
580
  }
566
- const objects = units.map(({ image, object, aliases }) => {
581
+ const resultWrappers = new Map<
582
+ string,
583
+ { symbol: string; image: number; provider: GuestImageDefinition }
584
+ >()
585
+ const definitionsByAlias = new Map<string, GuestImageDefinition>()
586
+ for (const definition of definitions) {
587
+ const previous = definitionsByAlias.get(definition.alias)
588
+ if (!previous || (previous.weak && !definition.weak))
589
+ definitionsByAlias.set(definition.alias, definition)
590
+ }
591
+ const objects = units.map(({ image, object, aliases, functionImports }) => {
567
592
  const bindings = new Map(bindingsByImage.get(image)!)
568
593
  for (const [name, alias] of startup.get(object.path) ?? []) bindings.set(name, alias)
594
+ for (const [name, type] of functionImports) {
595
+ const alias = bindings.get(name)
596
+ const provider = alias === undefined ? undefined : definitionsByAlias.get(alias)
597
+ if (
598
+ !provider ||
599
+ provider.kind !== 'function' ||
600
+ provider.result !== 'i32' ||
601
+ type.results.length !== 1 ||
602
+ type.results[0] !== 0x7e ||
603
+ type.parameters.map(llvmType).join(',') !== provider.parameters.join(',')
604
+ )
605
+ continue
606
+ const key = `${image}:${provider.alias}`
607
+ let wrapper = resultWrappers.get(key)
608
+ if (!wrapper) {
609
+ wrapper = {
610
+ symbol: `__peach_integer_result_${image}_${resultWrappers.size}`,
611
+ image,
612
+ provider,
613
+ }
614
+ resultWrappers.set(key, wrapper)
615
+ }
616
+ bindings.set(name, wrapper.symbol)
617
+ }
569
618
  return {
570
619
  path: object.path,
571
620
  instrumentDynamicLookups: object.instrumentDynamicLookups,
@@ -601,13 +650,28 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
601
650
  'target triple = "wasm64-unknown-wasip1"',
602
651
  `@.names = private constant [${nameSize} x i8] c"${nameContents}"`,
603
652
  ]
604
- for (const definition of exported.values()) {
653
+ const declarations = new Map(exported)
654
+ for (const { provider } of resultWrappers.values())
655
+ declarations.set(provider.alias, provider)
656
+ for (const definition of declarations.values()) {
605
657
  if (definition.kind === 'function')
606
658
  ir.push(
607
659
  `declare ${definition.result} @${definition.alias}(${definition.parameters.join(', ')})`,
608
660
  )
609
661
  else ir.push(`@${definition.alias} = external global i8`)
610
662
  }
663
+ // arm64 writes to w0 clear x0's upper word, including a c enum returned
664
+ // through an objective-c declaration whose underlying type is NSInteger.
665
+ for (const { symbol, provider } of resultWrappers.values()) {
666
+ const parameters = provider.parameters.map((type, index) => `${type} %arg${index}`)
667
+ ir.push(
668
+ `define i64 @${symbol}(${parameters.join(', ')}) {`,
669
+ ` %word = call i32 @${provider.alias}(${parameters.join(', ')})`,
670
+ ' %result = zext i32 %word to i64',
671
+ ' ret i64 %result',
672
+ '}',
673
+ )
674
+ }
611
675
  ir.push(`@__peach_dyld_symbols = constant [${exported.size} x { ptr, i32, ptr }] [`)
612
676
  ir.push(
613
677
  [...exported.values()]
@@ -652,10 +716,13 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
652
716
  callers: input.callers,
653
717
  definitions,
654
718
  objects,
655
- callerWrappers: [...callersUsingDlsym].map((image) => ({
656
- symbol: `__peach_dlsym_caller_${image}`,
657
- image,
658
- })),
719
+ callerWrappers: [
720
+ ...[...callersUsingDlsym].map((image) => ({
721
+ symbol: `__peach_dlsym_caller_${image}`,
722
+ image,
723
+ })),
724
+ ...[...resultWrappers.values()].map(({ symbol, image }) => ({ symbol, image })),
725
+ ],
659
726
  llvmIR: ir.join('\n') + '\n',
660
727
  }
661
728
  }
@@ -444,7 +444,9 @@ export function linkGuestImages(
444
444
  return { selected, ledger }
445
445
  }
446
446
  let prepared = prepare(false)
447
- const provider = prepared.ledger.callerWrappers.length > 0
447
+ const provider = prepared.ledger.callerWrappers.some(({ symbol }) =>
448
+ symbol.startsWith('__peach_dlsym_caller_'),
449
+ )
448
450
  // a generated caller wrapper introduces this provider reference. include it
449
451
  // in discovery before deciding which archive members the ledger owns.
450
452
  if (provider) prepared = prepare(true)
package/src/swift-host.ts CHANGED
@@ -2636,6 +2636,11 @@ function packageSnapshot(
2636
2636
  entry: string,
2637
2637
  moduleRoot?: string,
2638
2638
  ): SwiftPackageSnapshot {
2639
+ moduleRoot ??=
2640
+ xcodeProjects().get(project.packagePath)?.moduleRoot ??
2641
+ linkedModuleRoots(project.packagePath).find((root) =>
2642
+ fs.existsSync(path.join(root, 'toolchain.json')),
2643
+ )
2639
2644
  const layout = xcodeLayout(project.packagePath)
2640
2645
  const pin = moduleRoot
2641
2646
  ? (swiftDistributionAt(moduleRoot) ??
@@ -3304,13 +3309,7 @@ function scopedArtifact(
3304
3309
  .finally(() => signal.removeEventListener('abort', stop))
3305
3310
  })
3306
3311
  }
3307
- const snapshotRoot =
3308
- moduleRoot ??
3309
- xcodeProjects().get(project.packagePath)?.moduleRoot ??
3310
- linkedModuleRoots(project.packagePath).find((root) =>
3311
- fs.existsSync(path.join(root, 'toolchain.json')),
3312
- )
3313
- const snapshot = packageSnapshot(project, entry, snapshotRoot)
3312
+ const snapshot = packageSnapshot(project, entry, moduleRoot)
3314
3313
  // a save that changed only view builder literals keeps the running bytes
3315
3314
  const compiled = project.artifact?.compiled
3316
3315
  if (