peachsim 0.1.2403 → 0.1.2405

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/detox.ts +16 -3
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/attached-projects.cjs +1 -1
  5. package/dist-lib/auth/shared-session.cjs +1 -1
  6. package/dist-lib/backend-origin.cjs +1 -1
  7. package/dist-lib/beta.cjs +1 -1
  8. package/dist-lib/beta.mjs +1 -1
  9. package/dist-lib/bridge-constants.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.mjs +1 -1
  12. package/dist-lib/bridge-contract.cjs +1 -1
  13. package/dist-lib/bridge-contract.mjs +1 -1
  14. package/dist-lib/bundle-channel.cjs +2 -2
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cloud-contract.cjs +1 -1
  18. package/dist-lib/cloud-contract.mjs +1 -1
  19. package/dist-lib/cloud-test-args.cjs +1 -1
  20. package/dist-lib/cloud-test-args.mjs +1 -1
  21. package/dist-lib/cloud.cjs +81 -21
  22. package/dist-lib/cloud.mjs +81 -21
  23. package/dist-lib/config.cjs +1 -1
  24. package/dist-lib/config.mjs +1 -1
  25. package/dist-lib/detox/index.cjs +2 -2
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/expo-swift-bundle.cjs +1 -1
  28. package/dist-lib/expo-swift-metadata.cjs +1 -1
  29. package/dist-lib/expo-swift-metadata.mjs +1 -1
  30. package/dist-lib/home-paths.cjs +1 -1
  31. package/dist-lib/host/bridge-host.cjs +2 -2
  32. package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
  33. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  34. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  35. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  36. package/dist-lib/host/websocket-proxy.cjs +1 -1
  37. package/dist-lib/index.cjs +2 -2
  38. package/dist-lib/jump-to-source-babel.cjs +1 -1
  39. package/dist-lib/jump-to-source-native.cjs +1 -1
  40. package/dist-lib/kotlin-host.cjs +1 -1
  41. package/dist-lib/menu.cjs +1 -1
  42. package/dist-lib/menu.mjs +1 -1
  43. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  45. package/dist-lib/metro-production-bundle.cjs +1 -1
  46. package/dist-lib/metro-production-bundle.mjs +1 -1
  47. package/dist-lib/metro.cjs +2 -2
  48. package/dist-lib/native-app-identity-project.cjs +1 -1
  49. package/dist-lib/native-app-identity-project.mjs +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/pdfium-raster.cjs +1 -1
  55. package/dist-lib/pdfium-raster.mjs +1 -1
  56. package/dist-lib/plist.cjs +1 -1
  57. package/dist-lib/plist.mjs +1 -1
  58. package/dist-lib/profiles.cjs +1 -1
  59. package/dist-lib/public-brand.cjs +1 -1
  60. package/dist-lib/public-origins-lib-esm.json +24 -24
  61. package/dist-lib/public-origins-lib.json +53 -53
  62. package/dist-lib/react-native-host-modules.cjs +1 -1
  63. package/dist-lib/react-native-host-modules.mjs +1 -1
  64. package/dist-lib/reap-browser.cjs +1 -1
  65. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  66. package/dist-lib/sdk.cjs +1 -1
  67. package/dist-lib/sdk.mjs +1 -1
  68. package/dist-lib/skills.cjs +2 -2
  69. package/dist-lib/swift-compile.cjs +1 -1
  70. package/dist-lib/swift-compile.mjs +1 -1
  71. package/dist-lib/swift-package.cjs +1 -1
  72. package/dist-lib/swift-package.mjs +1 -1
  73. package/dist-lib/swift-submit.cjs +1 -1
  74. package/dist-lib/swift-submit.mjs +1 -1
  75. package/dist-lib/swift-toolchain.cjs +1 -1
  76. package/dist-lib/swift.cjs +1 -1
  77. package/dist-lib/vite-swift.cjs +1 -1
  78. package/dist-lib/vite.cjs +2 -2
  79. package/dist-lib/worklet-executable.cjs +1 -1
  80. package/dist-lib/worklet-executable.mjs +1 -1
  81. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +1 -0
  82. package/dist-types/packages/peach-engine/src/observability/diagnostics-sample.d.ts +10 -0
  83. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +3 -2
  84. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -0
  85. package/dist-types/packages/peach-engine/src/sootsim-event.d.ts +2 -0
  86. package/package.json +1 -1
  87. package/runtime-companion.json +1 -1
  88. package/src/cloud.ts +90 -22
@@ -7,6 +7,7 @@ import type { EngineMemoryCounts } from '../engine/memory-counts.d.ts';
7
7
  import type { ShellControlEvent } from '../engine/shell-owned-values.d.ts';
8
8
  import type { AuxShellActivity } from '../ios/aux-home-scene.d.ts';
9
9
  import type { NativePreviewBundle } from '../native-preview-bundle.d.ts';
10
+ import type { DiagnosticsSample } from '../observability/diagnostics-sample.d.ts';
10
11
  import type { PreviewBundleStripCapture } from '../preview/bundle-variantContract.d.ts';
11
12
  import type { PreviewRoomGrant } from '../preview/preview-room-contract.d.ts';
12
13
  import type { RemoteEngineClientConfig } from '../remote-stream/client-config.d.ts';
@@ -183,6 +184,9 @@ export type HostToWorker = {
183
184
  } | {
184
185
  type: 'setPrefersDark';
185
186
  prefersDark: boolean;
187
+ } | {
188
+ type: 'remoteDiagnosticsRequest';
189
+ enabled: boolean;
186
190
  } | {
187
191
  type: 'appFontsRegistered';
188
192
  requestId: number;
@@ -670,6 +674,9 @@ export type WorkerToHost = {
670
674
  } | {
671
675
  type: 'agentAction';
672
676
  detail: SootSimAgentActionDetail;
677
+ } | {
678
+ type: 'remoteDiagnostics';
679
+ sample: DiagnosticsSample;
673
680
  } | ({
674
681
  type: 'authRequest';
675
682
  requestId: number;
@@ -25,6 +25,8 @@ export interface SootsimEventMap extends SharedSootsimEventMap {
25
25
  'sootsim:remoteDisplay': {
26
26
  connected: boolean;
27
27
  };
28
+ 'sootsim:remoteDiagnosticsRequest': boolean;
29
+ 'sootsim:remoteDiagnostics': import('./observability/diagnostics-sample.d.ts').DiagnosticsSample;
28
30
  'sootsim:compositorAdapter': {
29
31
  isFallbackAdapter: boolean;
30
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.2403",
3
+ "version": "0.1.2405",
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",
@@ -1 +1 @@
1
- {"abi":1,"sha256":"0c8fd2e718b1b95d6f7a99350e741823ac5d885c7bc97aa3062ae81603bc987d","file":"node/cli-0c8fd2e718b1b95d6f7a99350e741823ac5d885c7bc97aa3062ae81603bc987d.cjs"}
1
+ {"abi":1,"sha256":"7e162f525497b8964ff8f7274ce8219416ec01ac8fc6986a80d2df90a54c71c4","file":"node/cli-7e162f525497b8964ff8f7274ce8219416ec01ac8fc6986a80d2df90a54c71c4.cjs"}
package/src/cloud.ts CHANGED
@@ -68,6 +68,8 @@ export interface CreateRemoteSimulatorInput {
68
68
  origin?: string
69
69
  device?: string
70
70
  sha256?: string
71
+ name?: string
72
+ timeoutMs?: number
71
73
  }
72
74
 
73
75
  // attach to a simulator another process created. the token is the full
@@ -546,7 +548,7 @@ export class RemoteSimulator {
546
548
  return parsed.result
547
549
  }
548
550
 
549
- async confirm(): Promise<RnxCloudClaim> {
551
+ async confirm(options?: { timeoutMs?: number }): Promise<RnxCloudClaim> {
550
552
  if (!this.session.claim) {
551
553
  throw new Error('this simulator was attached with connect() and holds no claim')
552
554
  }
@@ -561,6 +563,7 @@ export class RemoteSimulator {
561
563
  },
562
564
  body: JSON.stringify({ claimId }),
563
565
  },
566
+ options,
564
567
  )
565
568
  const text = await response.text()
566
569
  if (!response.ok) throw responseError(response.status, text)
@@ -578,11 +581,51 @@ export class RemoteSimulator {
578
581
  return claim
579
582
  }
580
583
 
581
- async close(): Promise<void> {
582
- // the create path tears down the box it made. a connected simulator never
583
- // learned its box, so it stops its own simulator instead; a scoped token
584
- // is refused there, which is the service telling the holder it may drive
585
- // but never delete.
584
+ async createInBox(options: {
585
+ authorization: string
586
+ device: string
587
+ timeoutMs?: number
588
+ }): Promise<RemoteSimulator> {
589
+ const { artifact, boxId, boxToken, origin, scopes } = this.session
590
+ if (!boxId || !boxToken) throw new Error('this simulator does not own a box')
591
+ const response = await fetchWithCloudRetry(
592
+ `${origin}/v1/boxes/${encodeURIComponent(boxId)}/simulators`,
593
+ {
594
+ method: 'POST',
595
+ headers: {
596
+ authorization: `Bearer ${boxToken}`,
597
+ 'x-rnx-account-authorization': options.authorization,
598
+ 'content-type': 'application/json',
599
+ },
600
+ body: JSON.stringify({
601
+ device: options.device,
602
+ artifactSha256: artifact.id.slice(7),
603
+ }),
604
+ },
605
+ options,
606
+ )
607
+ const body = await response.text()
608
+ if (!response.ok) throw responseError(response.status, body)
609
+ const parsed: unknown = JSON.parse(body)
610
+ if (!isRecord(parsed) || parsed.boxId !== boxId) {
611
+ throw new Error('Peach Cloud create returned an invalid box id')
612
+ }
613
+ const created = readSimulatorCreate(parsed.simulator, artifact.id, artifact.bytes)
614
+ const simulator = new RemoteSimulator({
615
+ origin,
616
+ boxId: null,
617
+ boxToken: null,
618
+ simId: created.simId,
619
+ simulatorToken: created.token,
620
+ claim: created.claim,
621
+ artifact: created.artifact,
622
+ scopes,
623
+ })
624
+ return confirmNewSimulator(simulator, options)
625
+ }
626
+
627
+ async close(options?: { timeoutMs?: number }): Promise<void> {
628
+ // only the simulator that created a box owns its lifetime.
586
629
  const target =
587
630
  this.session.boxId !== null && this.session.boxToken !== null
588
631
  ? {
@@ -593,10 +636,11 @@ export class RemoteSimulator {
593
636
  url: `${this.session.origin}/v1/sims/${encodeURIComponent(this.session.simId)}`,
594
637
  authorization: `Bearer ${this.session.simulatorToken}`,
595
638
  }
596
- const response = await fetchWithCloudRetry(target.url, {
597
- method: 'DELETE',
598
- headers: { authorization: target.authorization },
599
- })
639
+ const response = await fetchWithCloudRetry(
640
+ target.url,
641
+ { method: 'DELETE', headers: { authorization: target.authorization } },
642
+ options,
643
+ )
600
644
  const text = await response.text()
601
645
  if (!response.ok && response.status !== 404) {
602
646
  throw responseError(response.status, text)
@@ -624,18 +668,23 @@ export async function createRemoteSimulator(
624
668
  const device = input.device?.trim() || DEFAULT_DEVICE
625
669
  let response: Response
626
670
  try {
627
- response = await fetchWithCloudRetry(`${origin}/v1/boxes`, {
628
- method: 'POST',
629
- headers: {
630
- authorization: input.authorization,
631
- 'content-type': 'application/javascript',
632
- 'x-rnx-box-size': 'nano',
633
- 'x-rnx-artifact-sha256': sha256,
634
- 'x-rnx-platform': 'ios',
635
- 'x-rnx-device': device,
671
+ response = await fetchWithCloudRetry(
672
+ `${origin}/v1/boxes`,
673
+ {
674
+ method: 'POST',
675
+ headers: {
676
+ authorization: input.authorization,
677
+ 'content-type': 'application/javascript',
678
+ 'x-rnx-box-size': 'nano',
679
+ 'x-rnx-artifact-sha256': sha256,
680
+ 'x-rnx-platform': 'ios',
681
+ 'x-rnx-device': device,
682
+ ...(input.name ? { 'x-rnx-box-name': input.name } : {}),
683
+ },
684
+ body: copyArrayBuffer(input.artifact),
636
685
  },
637
- body: copyArrayBuffer(input.artifact),
638
- })
686
+ input,
687
+ )
639
688
  } catch (error) {
640
689
  throw new Error(
641
690
  `could not reach Peach Cloud at ${origin}: ${
@@ -662,7 +711,26 @@ export async function createRemoteSimulator(
662
711
  artifact: created.receipt.artifact,
663
712
  scopes: RNX_CLOUD_TOKEN_SCOPES,
664
713
  })
665
- await simulator.confirm()
714
+ return confirmNewSimulator(simulator, input)
715
+ }
716
+
717
+ async function confirmNewSimulator(
718
+ simulator: RemoteSimulator,
719
+ options: { timeoutMs?: number },
720
+ ): Promise<RemoteSimulator> {
721
+ try {
722
+ await simulator.confirm(options)
723
+ } catch (error) {
724
+ try {
725
+ await simulator.close(options)
726
+ } catch (cleanupError) {
727
+ throw new AggregateError(
728
+ [error, cleanupError],
729
+ 'unconfirmed simulator cleanup failed',
730
+ )
731
+ }
732
+ throw error
733
+ }
666
734
  return simulator
667
735
  }
668
736