peachsim 0.1.2433 → 0.1.2435

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 (97) hide show
  1. package/cli/app-project.ts +5 -0
  2. package/cli/commands/box.ts +3 -0
  3. package/cli/commands/control.ts +14 -6
  4. package/cli/commands/platform.ts +3 -3
  5. package/cli/commands/stream.ts +8 -1
  6. package/dist-lib/agent-daemon-client.cjs +1 -1
  7. package/dist-lib/agent-events.cjs +1 -1
  8. package/dist-lib/attached-projects.cjs +1 -1
  9. package/dist-lib/auth/shared-session.cjs +1 -1
  10. package/dist-lib/backend-origin.cjs +1 -1
  11. package/dist-lib/beta.cjs +1 -1
  12. package/dist-lib/beta.mjs +1 -1
  13. package/dist-lib/bridge-constants.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.mjs +1 -1
  16. package/dist-lib/bridge-contract.cjs +1 -1
  17. package/dist-lib/bridge-contract.mjs +1 -1
  18. package/dist-lib/bundle-channel.cjs +109 -38
  19. package/dist-lib/capture-contract.cjs +1 -1
  20. package/dist-lib/capture-contract.mjs +1 -1
  21. package/dist-lib/cloud-contract.cjs +1 -1
  22. package/dist-lib/cloud-contract.mjs +1 -1
  23. package/dist-lib/cloud-test-args.cjs +1 -1
  24. package/dist-lib/cloud-test-args.mjs +1 -1
  25. package/dist-lib/cloud.cjs +1 -1
  26. package/dist-lib/cloud.mjs +1 -1
  27. package/dist-lib/config.cjs +1 -1
  28. package/dist-lib/config.mjs +1 -1
  29. package/dist-lib/detox/index.cjs +1 -1
  30. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  31. package/dist-lib/expo-swift-bundle.cjs +99 -28
  32. package/dist-lib/expo-swift-metadata.cjs +1 -1
  33. package/dist-lib/expo-swift-metadata.mjs +1 -1
  34. package/dist-lib/home-paths.cjs +1 -1
  35. package/dist-lib/host/bridge-host.cjs +100 -29
  36. package/dist-lib/host/fetch-proxy-handler.cjs +4 -3
  37. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  38. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  39. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  40. package/dist-lib/host/websocket-proxy.cjs +1 -1
  41. package/dist-lib/index.cjs +15 -6
  42. package/dist-lib/jump-to-source-babel.cjs +1 -1
  43. package/dist-lib/jump-to-source-native.cjs +1 -1
  44. package/dist-lib/kotlin-host.cjs +1 -1
  45. package/dist-lib/menu.cjs +1 -1
  46. package/dist-lib/menu.mjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  49. package/dist-lib/metro-production-bundle.cjs +1 -1
  50. package/dist-lib/metro-production-bundle.mjs +1 -1
  51. package/dist-lib/metro.cjs +15 -6
  52. package/dist-lib/native-app-identity-project.cjs +13 -5
  53. package/dist-lib/native-app-identity-project.mjs +13 -5
  54. package/dist-lib/native-app-identity.cjs +1 -1
  55. package/dist-lib/native-app-identity.mjs +1 -1
  56. package/dist-lib/native-firebase-metadata.cjs +1 -1
  57. package/dist-lib/native-firebase-metadata.mjs +1 -1
  58. package/dist-lib/pdfium-raster.cjs +1 -1
  59. package/dist-lib/pdfium-raster.mjs +1 -1
  60. package/dist-lib/plist.cjs +1 -1
  61. package/dist-lib/plist.mjs +1 -1
  62. package/dist-lib/profiles.cjs +1 -1
  63. package/dist-lib/public-brand.cjs +1 -1
  64. package/dist-lib/public-origins-lib-esm.json +25 -25
  65. package/dist-lib/public-origins-lib.json +56 -56
  66. package/dist-lib/react-native-host-modules.cjs +1 -1
  67. package/dist-lib/react-native-host-modules.mjs +1 -1
  68. package/dist-lib/reap-browser.cjs +1 -1
  69. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  70. package/dist-lib/sdk.cjs +1 -1
  71. package/dist-lib/sdk.mjs +1 -1
  72. package/dist-lib/skills.cjs +122 -39
  73. package/dist-lib/swift-compile.cjs +78 -25
  74. package/dist-lib/swift-compile.mjs +78 -25
  75. package/dist-lib/swift-package.cjs +1 -1
  76. package/dist-lib/swift-package.mjs +1 -1
  77. package/dist-lib/swift-submit.cjs +1 -1
  78. package/dist-lib/swift-submit.mjs +1 -1
  79. package/dist-lib/swift-toolchain.cjs +1 -1
  80. package/dist-lib/swift.cjs +1 -1
  81. package/dist-lib/vite-swift.cjs +101 -31
  82. package/dist-lib/vite.cjs +4 -3
  83. package/dist-lib/worklet-executable.cjs +1 -1
  84. package/dist-lib/worklet-executable.mjs +1 -1
  85. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  86. package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +2 -2
  87. package/kotlin/sdk.tar.gz +0 -0
  88. package/package.json +1 -1
  89. package/src/bazel-project.ts +11 -3
  90. package/src/react-native-coverage/native-typescript-parser.ts +29 -1
  91. package/src/swift-compile.ts +49 -5
  92. package/src/swift-guest-image-ledger.ts +15 -12
  93. package/src/swift-guest-link.ts +13 -2
  94. package/src/swift-guest-source-inputs.ts +5 -1
  95. package/src/swift-host.ts +12 -0
  96. package/src/swift-submit.ts +2 -0
  97. package/src/swift-wasm-prune.ts +8 -3
@@ -82,7 +82,7 @@ function readString(bytes: Uint8Array, position: number): [string, number] {
82
82
  const [length, start] = readNumber(bytes, position)
83
83
  if (start + length > bytes.length) throw new Error('invalid wasm string')
84
84
  return [
85
- Buffer.from(bytes.subarray(start, start + length)).toString('utf8'),
85
+ Buffer.from(bytes.buffer, bytes.byteOffset + start, length).toString('utf8'),
86
86
  start + length,
87
87
  ]
88
88
  }
@@ -128,7 +128,7 @@ function rewriteObject(
128
128
  bytes: Uint8Array,
129
129
  names: Pick<ReadonlyMap<string, string>, 'get' | 'has'>,
130
130
  callerAlias: string,
131
- binding: (name: string) => string | undefined,
131
+ binding: ((name: string) => string | undefined) | undefined,
132
132
  instrumentDynamicLookups: boolean,
133
133
  preserveCanonical: ReadonlySet<string>,
134
134
  ): {
@@ -140,7 +140,9 @@ function rewriteObject(
140
140
  } {
141
141
  if (Buffer.from(bytes.subarray(0, 8)).toString('hex') !== '0061736d01000000')
142
142
  throw new Error('expected wasm object')
143
- const sections: Buffer[] = [Buffer.from(bytes.subarray(0, 8))]
143
+ const sections: Buffer[] | undefined = binding
144
+ ? [Buffer.from(bytes.subarray(0, 8))]
145
+ : undefined
144
146
  const types: FunctionType[] = []
145
147
  const functionTypes: number[] = []
146
148
  const definitions: ObjectDefinition[] = []
@@ -154,8 +156,9 @@ function rewriteObject(
154
156
  const [size, start] = readNumber(bytes, position)
155
157
  const end = start + size
156
158
  if (end > bytes.length) throw new Error('invalid wasm section')
157
- let section = Buffer.from(bytes.subarray(start, end))
158
159
  position = end
160
+ if (!sections && id > 3) continue
161
+ let section = Buffer.from(bytes.buffer, bytes.byteOffset + start, size)
159
162
  let offset = 0
160
163
  const number = (): number => {
161
164
  const [value, next] = readNumber(section, offset)
@@ -183,7 +186,7 @@ function rewriteObject(
183
186
  }
184
187
  } else if (id === 2) {
185
188
  const count = number()
186
- const imports: Buffer[] = [encodeNumber(count)]
189
+ const imports: Buffer[] | undefined = sections ? [encodeNumber(count)] : undefined
187
190
  for (let i = 0; i < count; i++) {
188
191
  const module = string()
189
192
  const name = string()
@@ -232,7 +235,7 @@ function rewriteObject(
232
235
  }
233
236
  if (isDlsym) usesDlsym = true
234
237
  if (isDlerror) usesDlerror = true
235
- imports.push(
238
+ imports?.push(
236
239
  encodedString(module),
237
240
  encodedString(
238
241
  isDlsym
@@ -240,7 +243,7 @@ function rewriteObject(
240
243
  : isDlerror
241
244
  ? '__peach_dlerror'
242
245
  : module === 'env' && name !== 'dlsym' && name !== 'dlerror'
243
- ? (binding(name) ?? name)
246
+ ? (binding?.(name) ?? name)
244
247
  : name,
245
248
  ),
246
249
  Buffer.from([kind]),
@@ -248,7 +251,7 @@ function rewriteObject(
248
251
  )
249
252
  }
250
253
  if (offset !== section.length) throw new Error('invalid wasm import section')
251
- section = Buffer.concat(imports)
254
+ if (imports) section = Buffer.concat(imports)
252
255
  } else if (id === 3) {
253
256
  const count = number()
254
257
  for (let i = 0; i < count; i++) functionTypes.push(number())
@@ -354,7 +357,7 @@ function rewriteObject(
354
357
  flags & 16 &&
355
358
  name !== 'dlsym' &&
356
359
  name !== 'dlerror' &&
357
- binding(name) !== undefined
360
+ binding?.(name) !== undefined
358
361
  ) {
359
362
  entries.push(
360
363
  section.subarray(begin, nameStart),
@@ -432,10 +435,10 @@ function rewriteObject(
432
435
  section = Buffer.concat(parts)
433
436
  }
434
437
  }
435
- sections.push(Buffer.from([id]), encodeNumber(section.length), section)
438
+ sections?.push(Buffer.from([id]), encodeNumber(section.length), section)
436
439
  }
437
440
  return {
438
- bytes: Buffer.concat(sections),
441
+ bytes: sections ? Buffer.concat(sections) : bytes,
439
442
  definitions,
440
443
  functionImports,
441
444
  usesDlsym,
@@ -500,7 +503,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
500
503
  object.bytes,
501
504
  aliases,
502
505
  `__peach_dlsym_caller_${image.id}`,
503
- () => undefined,
506
+ undefined,
504
507
  object.instrumentDynamicLookups,
505
508
  new Set(),
506
509
  )
@@ -1164,7 +1164,12 @@ export function verifyGuestSymbolScopes(options: {
1164
1164
  continue
1165
1165
  if (!scope.includes(provider)) {
1166
1166
  const candidates = options.definitionObjects.get(symbol) ?? new Set<string>()
1167
- const providers = [...record.providers.keys()]
1167
+ const traced = [...record.providers.keys()]
1168
+ // the one strong definition a link traces wins over weak fallbacks beside it
1169
+ const strongTraced = traced.filter(
1170
+ (definer) => !options.weakDefinitions.get(definer)?.has(symbol),
1171
+ )
1172
+ const providers = strongTraced.length === 1 ? strongTraced : traced
1168
1173
  // a weak import binds only inside the image's own dependency scope, so
1169
1174
  // a provider outside it leaves the import absent, as in dyld.
1170
1175
  if (
@@ -1180,9 +1185,15 @@ export function verifyGuestSymbolScopes(options: {
1180
1185
  [...candidates].every((definer) =>
1181
1186
  options.weakDefinitions.get(definer)?.has(symbol),
1182
1187
  )
1188
+ const strongCandidates = [...candidates].filter(
1189
+ (definer) => !options.weakDefinitions.get(definer)?.has(symbol),
1190
+ )
1191
+ const soleCandidate =
1192
+ candidates.size === 1 ||
1193
+ (strongCandidates.length === 1 && strongCandidates[0] === providers[0])
1183
1194
  if (
1184
1195
  !equivalentCopies &&
1185
- (candidates.size !== 1 ||
1196
+ (!soleCandidate ||
1186
1197
  providers.length !== 1 ||
1187
1198
  !candidates.has(providers[0]!) ||
1188
1199
  !(
@@ -2,6 +2,7 @@ import { execFileSync } from 'node:child_process'
2
2
  import { createHash } from 'node:crypto'
3
3
  import { mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'
4
4
  import path from 'node:path'
5
+ import { PEACH_FORKED_SCRIPT_ENV } from './forked-script-contract'
5
6
  import { libraryArchiveTarget, type GuestSourceArtifact } from './swift-guest-source-plan'
6
7
  import { frameworkRuntimeProductId } from './swift-runtime-products'
7
8
  import type { SwiftSourceLinkGraph } from './swiftContract'
@@ -161,10 +162,13 @@ export function sourceGuestClangLinkOptions(options: {
161
162
  plan,
162
163
  JSON.stringify(replays.map(({ compiler, args }) => [compiler, ...args])),
163
164
  )
164
- execFileSync(process.execPath, ['-e', PARALLEL_REPLAY], {
165
+ const script = path.join(options.directory, 'clang-link-replay.cjs')
166
+ writeFileSync(script, PARALLEL_REPLAY)
167
+ execFileSync(process.execPath, [script], {
165
168
  stdio: 'inherit',
166
169
  env: {
167
170
  ...process.env,
171
+ [PEACH_FORKED_SCRIPT_ENV]: '1',
168
172
  PEACH_CLANG_REPLAYS: plan,
169
173
  PEACH_CLANG_JOBS: String(options.jobs),
170
174
  },
package/src/swift-host.ts CHANGED
@@ -2807,6 +2807,7 @@ interface SwiftPackageSnapshot {
2807
2807
  packageFiles?: SwiftPackageFiles
2808
2808
  projectFiles?: Record<string, string>
2809
2809
  packageGuestImports?: string[]
2810
+ packageHostMacros?: string[]
2810
2811
  files: Record<string, string>
2811
2812
  nativeTargets?: SwiftNativeTarget[]
2812
2813
  sourceLinkGraph?: SwiftSourceLinkGraph
@@ -2922,6 +2923,15 @@ function packageSnapshot(
2922
2923
  ...(Object.keys(packageFiles).length > 0
2923
2924
  ? {
2924
2925
  packageFiles,
2926
+ packageHostMacros: [
2927
+ ...new Set(
2928
+ (layout?.packages.nativePackages ?? []).flatMap(({ manifest }) =>
2929
+ [...manifest.targets.values()]
2930
+ .filter((target) => target.type === 'macro')
2931
+ .map((target) => swiftTargetModuleName(target.name)),
2932
+ ),
2933
+ ),
2934
+ ].sort(),
2925
2935
  packageGuestImports: [
2926
2936
  ...new Set(
2927
2937
  (layout?.packages.nativePackages ?? []).flatMap(
@@ -3014,6 +3024,7 @@ function snapshotCompileInput(snapshot: SwiftPackageSnapshot): SwiftCompileInput
3014
3024
  ? {
3015
3025
  packageFiles: snapshot.packageFiles,
3016
3026
  packageGuestImports: snapshot.packageGuestImports,
3027
+ packageHostMacros: snapshot.packageHostMacros,
3017
3028
  }
3018
3029
  : {}),
3019
3030
  ...(snapshot.projectFiles ? { projectFiles: snapshot.projectFiles } : {}),
@@ -3410,6 +3421,7 @@ async function compileRemote(
3410
3421
  ? {
3411
3422
  packageFiles: snapshot.packageFiles,
3412
3423
  packageGuestImports: snapshot.packageGuestImports,
3424
+ packageHostMacros: snapshot.packageHostMacros,
3413
3425
  }
3414
3426
  : {}),
3415
3427
  ...(snapshot.nativeTargets ? { nativeTargets: snapshot.nativeTargets } : {}),
@@ -283,6 +283,7 @@ export type SwiftCompileSubmit = (work: {
283
283
  files: Record<string, string>
284
284
  packageFiles?: SwiftPackageFiles
285
285
  packageGuestImports?: string[]
286
+ packageHostMacros?: string[]
286
287
  nativeTargets?: SwiftNativeTarget[]
287
288
  sourceLinkGraph?: SwiftSourceLinkGraph
288
289
  headerAliases?: SwiftHeaderAliases
@@ -459,6 +460,7 @@ export async function compileSwiftProject(
459
460
  files: Record<string, string>
460
461
  packageFiles?: SwiftPackageFiles
461
462
  packageGuestImports?: string[]
463
+ packageHostMacros?: string[]
462
464
  nativeTargets?: SwiftNativeTarget[]
463
465
  sourceLinkGraph?: SwiftSourceLinkGraph
464
466
  headerAliases?: SwiftHeaderAliases
@@ -2129,9 +2129,14 @@ export function pruneSwiftWasmLink(
2129
2129
  const def = definedGlobalSyms.get(symName)
2130
2130
  if (def) activateSymbolInObj(def.obj, def.symIdx)
2131
2131
  }
2132
- // the image ledger's generated lookup wrappers call the loader runtime, a
2133
- // reference the pruner cannot see before the ledger exists.
2134
- for (const symName of ['__peach_dlsym_from_image', '__peach_dlerror']) {
2132
+ // the image ledger's generated lookup wrappers call the loader runtime, and a
2133
+ // guest link's image tables reference the providers that read them:
2134
+ // references the pruner cannot see before the ledger exists.
2135
+ for (const symName of [
2136
+ '__peach_dlsym_from_image',
2137
+ '__peach_dlerror',
2138
+ ...(link ? ['_dyld_register_func_for_add_image'] : []),
2139
+ ]) {
2135
2140
  const provider = lazyProviders.get(symName)?.[0]
2136
2141
  if (provider) extractObject(provider)
2137
2142
  const def = definedGlobalSyms.get(symName)