peachsim 0.1.2487 → 0.1.2489

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 (137) hide show
  1. package/cli/commands/control.ts +1 -0
  2. package/cli/commands/shell-url.ts +12 -6
  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 +2 -2
  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 +5 -5
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +3 -3
  15. package/dist-lib/bundle-channel.cjs +167 -167
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +3 -3
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +3 -3
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +2 -2
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +7 -7
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/config.mjs +5 -5
  26. package/dist-lib/detox/index.cjs +1 -1
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/esm-chunks/{acorn-MHBKEX4S.mjs → acorn-46P725QB.mjs} +3 -3
  29. package/dist-lib/esm-chunks/{chunk-RUTCB73U.mjs → chunk-2ZAKSUG3.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-HE7EAGQL.mjs → chunk-5F5TV3M5.mjs} +4 -4
  31. package/dist-lib/esm-chunks/{chunk-2ZLORBLV.mjs → chunk-75IXYYPA.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-RCU5GHCK.mjs → chunk-CB2MREW2.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-J2F3WW7E.mjs → chunk-E7Z6E4VM.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-WM3ZQJPN.mjs → chunk-FMR76G4M.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-N77R5GZV.mjs → chunk-FNFDX5OA.mjs} +2 -2
  36. package/dist-lib/esm-chunks/{chunk-OXWMTMC4.mjs → chunk-FXOLLJ7N.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-QXT6KHA4.mjs → chunk-G4KFSINI.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-X2P3BLT5.mjs → chunk-HO4COZOG.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-OZIZZTJU.mjs → chunk-K3NXHJBV.mjs} +12 -12
  40. package/dist-lib/esm-chunks/{chunk-WBFRHLQG.mjs → chunk-KFJJOPLU.mjs} +5 -5
  41. package/dist-lib/esm-chunks/{chunk-NM27TWXD.mjs → chunk-MOGXM5NJ.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-FQLC3QU7.mjs → chunk-NN6KHA6F.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-VTJKZ25F.mjs → chunk-PWLDSFLP.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-RCXANTR3.mjs → chunk-QR4AFBNL.mjs} +5 -5
  45. package/dist-lib/esm-chunks/{chunk-VNI6WHVI.mjs → chunk-ST7BG6HB.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-23DLL3LB.mjs → chunk-T53UQ6V7.mjs} +3 -3
  47. package/dist-lib/esm-chunks/{chunk-2BZEUT66.mjs → chunk-XYRP56S5.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-KF6HW3YA.mjs → chunk-YH2VVDO2.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-4WGIAUCS.mjs → chunk-ZGCWGHEX.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{metro-layout-parser-5W4FZUHK.mjs → metro-layout-parser-FPL6XENQ.mjs} +3 -3
  51. package/dist-lib/esm-chunks/{swift-package-prebuilt-KJQO5GSC.mjs → swift-package-prebuilt-FYUAWFYO.mjs} +10 -10
  52. package/dist-lib/esm-chunks/{swift-sdk-app-module-JM6D76SD.mjs → swift-sdk-app-module-RVHNFMEY.mjs} +13 -13
  53. package/dist-lib/esm-chunks/{swift-sdk-image-JUXW737Q.mjs → swift-sdk-image-JHQ6DP5G.mjs} +13 -13
  54. package/dist-lib/esm-chunks/{swift-sdk-image-producer-X55F2PAV.mjs → swift-sdk-image-producer-XQ5W4ONP.mjs} +4 -4
  55. package/dist-lib/expo-swift-bundle.cjs +99 -99
  56. package/dist-lib/expo-swift-metadata.cjs +1 -1
  57. package/dist-lib/expo-swift-metadata.mjs +7 -7
  58. package/dist-lib/home-paths.cjs +1 -1
  59. package/dist-lib/host/bridge-host.cjs +972 -760
  60. package/dist-lib/host/fetch-proxy-handler.cjs +42 -42
  61. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  62. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  63. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  64. package/dist-lib/host/websocket-proxy.cjs +1 -1
  65. package/dist-lib/index.cjs +1 -1
  66. package/dist-lib/kotlin-host.cjs +1 -1
  67. package/dist-lib/menu.cjs +1 -1
  68. package/dist-lib/menu.mjs +3 -3
  69. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  70. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  71. package/dist-lib/metro-production-bundle.cjs +1 -1
  72. package/dist-lib/metro-production-bundle.mjs +4 -4
  73. package/dist-lib/native-app-identity-project.cjs +1 -1
  74. package/dist-lib/native-app-identity-project.mjs +15 -15
  75. package/dist-lib/native-app-identity.cjs +1 -1
  76. package/dist-lib/native-app-identity.mjs +6 -6
  77. package/dist-lib/native-firebase-metadata.cjs +1 -1
  78. package/dist-lib/native-firebase-metadata.mjs +3 -3
  79. package/dist-lib/pdfium-raster.cjs +1 -1
  80. package/dist-lib/pdfium-raster.mjs +2 -2
  81. package/dist-lib/plist.cjs +1 -1
  82. package/dist-lib/plist.mjs +3 -3
  83. package/dist-lib/profiles.cjs +1 -1
  84. package/dist-lib/public-brand.cjs +1 -1
  85. package/dist-lib/public-origins-lib-esm.json +79 -79
  86. package/dist-lib/public-origins-lib.json +74 -72
  87. package/dist-lib/react-native-host-modules.cjs +1 -1
  88. package/dist-lib/react-native-host-modules.mjs +2 -2
  89. package/dist-lib/reap-browser.cjs +1 -1
  90. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  91. package/dist-lib/sdk.cjs +1 -1
  92. package/dist-lib/sdk.mjs +7 -7
  93. package/dist-lib/skills.cjs +1421 -1324
  94. package/dist-lib/swift-compile.cjs +1 -1
  95. package/dist-lib/swift-compile.mjs +10 -10
  96. package/dist-lib/swift-package.cjs +1 -1
  97. package/dist-lib/swift-package.mjs +3 -3
  98. package/dist-lib/swift-submit.cjs +1 -1
  99. package/dist-lib/swift-submit.mjs +5 -5
  100. package/dist-lib/swift-svg-raster.cjs +1 -1
  101. package/dist-lib/swift-svg-raster.mjs +2 -2
  102. package/dist-lib/swift-toolchain.cjs +1 -1
  103. package/dist-lib/swift.cjs +1 -1
  104. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  107. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  110. package/dist-lib/vendor/ignore.cjs +1 -1
  111. package/dist-lib/vendor/magic-string.cjs +1 -1
  112. package/dist-lib/vendor/plist.cjs +1 -1
  113. package/dist-lib/vendor/smol-toml.cjs +1 -1
  114. package/dist-lib/vendor/stream-json.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  119. package/dist-lib/vendor/sucrase.cjs +1 -1
  120. package/dist-lib/vendor/terser.cjs +1 -1
  121. package/dist-lib/vendor/valibot.cjs +1 -1
  122. package/dist-lib/vendor/ws.cjs +1 -1
  123. package/dist-lib/vendor/zod.cjs +1 -1
  124. package/dist-lib/worklet-executable.cjs +1 -1
  125. package/dist-lib/worklet-executable.mjs +3 -3
  126. package/dist-types/packages/peach-engine/core-abi/style/style-schema.d.ts +5 -0
  127. package/dist-types/packages/peach-engine/src/render-worker/canvaskit-webgpu.d.ts +2 -2
  128. package/dist-types/packages/peach-engine/src/render-worker/compositor-gpu.d.ts +1 -1
  129. package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +1 -1
  130. package/dist-types/packages/peach-engine/src/render-worker/webgpu-wire-server.d.ts +2 -0
  131. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +4 -0
  132. package/package.json +1 -1
  133. package/src/expo-native-prebuilt.ts +16 -25
  134. package/src/host/bridge-host.ts +8 -0
  135. package/src/managed-expo-identity.ts +110 -0
  136. package/src/native-preparation.ts +8 -2
  137. package/src/nativePreparationContract.ts +1 -0
@@ -0,0 +1,110 @@
1
+ import { createHash } from 'node:crypto'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import { isLoopbackHost } from './backend-origin'
5
+ import { getCliVersion } from './cli-version'
6
+ import { isManagedExpoApp, managedExpoNativeAppIdentity } from './expo-native-prebuilt'
7
+ import { stageHostDerivedBytes } from './host/staged-host-files'
8
+ import { createNativeAppIdentityHeader } from './native-app-identity'
9
+ import { NativeAppTargetSelectionError } from './native-app-identity-project'
10
+ import { nativeInputRevision } from './native-preparation'
11
+ import { MANAGED_EXPO_INPUTS_ROUTE } from './nativePreparationContract'
12
+ import { nodeHttpFetch } from './node-http-fetch'
13
+ import { getRuntimePlatformAdapter } from './runtimePlatformContract.ts'
14
+ import type { IncomingMessage, ServerResponse } from 'node:http'
15
+
16
+ const revisionType = 'application/vnd.peach.native-input-revision'
17
+
18
+ async function prepareIdentity(root: string, iosTarget?: string) {
19
+ try {
20
+ const identity = await managedExpoNativeAppIdentity(root, iosTarget)
21
+ return identity && createNativeAppIdentityHeader(identity)
22
+ } catch (error) {
23
+ if (error instanceof NativeAppTargetSelectionError) return null
24
+ throw error
25
+ }
26
+ }
27
+
28
+ export async function readManagedExpoIdentity(
29
+ root: string,
30
+ platform: 'ios' | 'android',
31
+ iosTarget: string | undefined,
32
+ bridgeOrigin: string | undefined,
33
+ ): Promise<string | null> {
34
+ if (!getRuntimePlatformAdapter(platform).isIOS || !isManagedExpoApp(root)) return null
35
+ if (bridgeOrigin) {
36
+ const url = new URL(MANAGED_EXPO_INPUTS_ROUTE, bridgeOrigin)
37
+ url.searchParams.set('root', root)
38
+ const response = await nodeHttpFetch(url.href)
39
+ if (response.ok && response.headers.get('content-type') === revisionType) {
40
+ // the CLI owns the environment for config plugins, including when a
41
+ // separate service started the daemon. only the digest indexes the cache.
42
+ const environment = createHash('sha256')
43
+ .update(JSON.stringify(Object.entries(process.env).sort()))
44
+ .digest('hex')
45
+ const inputs = Buffer.from(
46
+ JSON.stringify([
47
+ await response.text(),
48
+ root,
49
+ iosTarget,
50
+ getCliVersion(),
51
+ environment,
52
+ ]),
53
+ )
54
+ const staged = await stageHostDerivedBytes(
55
+ inputs,
56
+ 'managed-expo-identity-1',
57
+ bridgeOrigin,
58
+ '.txt',
59
+ async () => Buffer.from((await prepareIdentity(root, iosTarget)) ?? ''),
60
+ )
61
+ const identity = await nodeHttpFetch(staged)
62
+ if (!identity.ok)
63
+ throw new Error(`Managed Expo identity answered ${identity.status}`)
64
+ return (await identity.text()) || null
65
+ }
66
+ // an older bridge has no revision route.
67
+ if (!response.ok && response.status !== 404) throw new Error(await response.text())
68
+ await response.body?.cancel()
69
+ }
70
+ return prepareIdentity(root, iosTarget)
71
+ }
72
+
73
+ export function handleManagedExpoInputs(
74
+ req: IncomingMessage,
75
+ res: ServerResponse,
76
+ url: URL,
77
+ ) {
78
+ const remote = req.socket.remoteAddress?.replace(/^::ffff:/, '')
79
+ if (
80
+ !remote ||
81
+ !isLoopbackHost(remote) ||
82
+ req.headers.origin ||
83
+ req.headers['sec-fetch-mode']
84
+ ) {
85
+ res.writeHead(403)
86
+ res.end('Managed Expo identity requires a local CLI client')
87
+ return
88
+ }
89
+ if (req.method !== 'GET') {
90
+ res.writeHead(405)
91
+ res.end('GET required')
92
+ return
93
+ }
94
+ const source = url.searchParams.get('root')
95
+ if (!source || !path.isAbsolute(source)) {
96
+ res.writeHead(400)
97
+ res.end('Missing absolute app root')
98
+ return
99
+ }
100
+ const root = fs.realpathSync(source)
101
+ const revision = nativeInputRevision(root)
102
+ res.setHeader('Cache-Control', 'no-store')
103
+ if (!revision) {
104
+ res.writeHead(204)
105
+ res.end()
106
+ return
107
+ }
108
+ res.writeHead(200, { 'Content-Type': revisionType })
109
+ res.end(revision)
110
+ }
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from 'node:crypto'
1
2
  import fs from 'node:fs'
2
3
  import path from 'node:path'
3
4
  import { clearTimeout, setTimeout } from 'node:timers'
@@ -11,7 +12,7 @@ import { findWorkspaceRoot } from './workspace-root'
11
12
  const setTimeoutNode: (fn: () => void, ms: number) => NodeJS.Timeout = setTimeout
12
13
  const RETENTION_MS = 30 * 60 * 1000
13
14
 
14
- type NativeInputs = { expiry: NodeJS.Timeout }
15
+ type NativeInputs = { expiry: NodeJS.Timeout; revision: string }
15
16
  type Preparation<T> = { result: Promise<T>; ready?: { value: T } }
16
17
  const watchedInputs = new Map<string, NativeInputs>()
17
18
 
@@ -43,7 +44,7 @@ function watchNativeInputs(root: string): NativeInputs | undefined {
43
44
  clearTimeout(expiry)
44
45
  for (const watcher of watchers) watcher.close()
45
46
  }
46
- const inputs = { expiry }
47
+ const inputs = { expiry, revision: randomUUID() }
47
48
  const watch = (directory: string, recursive: boolean, name?: string) => {
48
49
  const watcher = fs.watch(
49
50
  directory,
@@ -88,6 +89,11 @@ function watchNativeInputs(root: string): NativeInputs | undefined {
88
89
  return inputs
89
90
  }
90
91
 
92
+ export function nativeInputRevision(root: string): string | undefined {
93
+ const inputs = watchNativeInputs(root)
94
+ if (inputs) return JSON.stringify([inputs.revision, resolveActiveRuntimeRoot()])
95
+ }
96
+
91
97
  // an open can reuse preparation from the current workspace. its token hands
92
98
  // that same result to the first tenant request, even if the workspace changes.
93
99
  export class NativePreparation<T> {
@@ -1,3 +1,4 @@
1
1
  // the cli and tenant use the same open token to hand off native preparation.
2
2
  export const NATIVE_PREPARE_QUERY_PARAM = 'prepare'
3
3
  export const NATIVE_PREPARED_QUERY_PARAM = 'prepared'
4
+ export const MANAGED_EXPO_INPUTS_ROUTE = '/__peach/managed-expo-inputs'