peachsim 0.1.759 → 0.1.761

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 (78) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/agent-identity.cjs +1 -1
  4. package/dist-lib/agent-sessions.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/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cli-constants.cjs +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/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/home-paths.cjs +1 -1
  28. package/dist-lib/host/bridge-host.cjs +888 -735
  29. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  30. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  32. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  33. package/dist-lib/host/websocket-proxy.cjs +1 -1
  34. package/dist-lib/index.cjs +37 -220
  35. package/dist-lib/jump-to-source-babel.cjs +1 -1
  36. package/dist-lib/jump-to-source-native.cjs +1 -1
  37. package/dist-lib/kotlin-host.cjs +1 -1
  38. package/dist-lib/menu.cjs +1 -1
  39. package/dist-lib/menu.mjs +1 -1
  40. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  42. package/dist-lib/metro-production-bundle.cjs +1 -1
  43. package/dist-lib/metro-production-bundle.mjs +1 -1
  44. package/dist-lib/metro.cjs +37 -220
  45. package/dist-lib/native-app-identity.cjs +1 -1
  46. package/dist-lib/native-app-identity.mjs +1 -1
  47. package/dist-lib/native-firebase-metadata.cjs +1 -1
  48. package/dist-lib/native-firebase-metadata.mjs +1 -1
  49. package/dist-lib/plist.cjs +1 -1
  50. package/dist-lib/plist.mjs +1 -1
  51. package/dist-lib/profiles.cjs +1 -1
  52. package/dist-lib/public-brand.cjs +1 -1
  53. package/dist-lib/react-native-host-modules.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.mjs +1 -1
  55. package/dist-lib/render-mode.cjs +1 -1
  56. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  57. package/dist-lib/sdk.cjs +1 -1
  58. package/dist-lib/sdk.mjs +1 -1
  59. package/dist-lib/skills.cjs +1185 -1026
  60. package/dist-lib/swift-compile.cjs +66 -8
  61. package/dist-lib/swift-compile.mjs +66 -8
  62. package/dist-lib/swift-package.cjs +1 -110
  63. package/dist-lib/swift-package.mjs +1 -109
  64. package/dist-lib/swift-submit.cjs +1 -1
  65. package/dist-lib/swift-submit.mjs +1 -1
  66. package/dist-lib/swift-toolchain.cjs +1 -1
  67. package/dist-lib/swift.cjs +1 -1
  68. package/dist-lib/vite-swift.cjs +672 -519
  69. package/dist-lib/vite.cjs +1 -1
  70. package/package.json +1 -1
  71. package/src/native-seam-manifest.ts +8 -0
  72. package/src/swift-compile.ts +102 -12
  73. package/src/swift-host.ts +64 -64
  74. package/src/swift-package-manifest.ts +307 -0
  75. package/src/swift-package.ts +2 -135
  76. package/src/swift-packages.ts +341 -0
  77. package/src/xcode-project.ts +57 -70
  78. package/src/swift-remote-packages.ts +0 -255
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.759 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.761 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.759",
3
+ "version": "0.1.761",
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",
@@ -130,6 +130,14 @@ export const NATIVE_SEAM_MANIFEST: NativeSeamEntry[] = [
130
130
  notes:
131
131
  'iOS BGTaskScheduler / Android WorkManager TurboModule — no real scheduler in browser; acknowledge registrations, never fire periodic events',
132
132
  },
133
+ {
134
+ pkg: 'expo',
135
+ // winter imports this relatively during Expo.fx, before bundle globals.
136
+ // use the same browser-backed native boundary as guest registry imports.
137
+ seamBasenames: ['FormData'],
138
+ target: path.resolve(HERE, '../../peach-compat/src/stubs/expo-winter-formdata.ts'),
139
+ notes: 'winter FormData installation on the browser-native networking boundary',
140
+ },
133
141
  {
134
142
  pkg: 'expo-apple-authentication',
135
143
  // src/ExpoAppleAuthenticationButton.ts is the package's native-view
@@ -275,19 +275,108 @@ const OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES)
275
275
  const SWIFT_IMPORT =
276
276
  /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/
277
277
 
278
+ // a compilation condition as the wasm compile sees it after the source
279
+ // rewrite below: `os(iOS)` and `os(WASI)` hold, other platforms do not,
280
+ // `canImport` holds for an available module. what the scan cannot know
281
+ // (custom flags, swift versions, features) is undefined, three-valued
282
+ // through `!`, `&&` and `||`.
283
+ function swiftCondition(
284
+ text: string,
285
+ available: ReadonlySet<string>,
286
+ ): boolean | undefined {
287
+ const tokens = text.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? []
288
+ let index = 0
289
+ const atom = (): boolean | undefined => {
290
+ const token = tokens[index++]
291
+ if (token === '!') {
292
+ const value = atom()
293
+ return value === undefined ? undefined : !value
294
+ }
295
+ if (token === '(') {
296
+ const value = either()
297
+ index++
298
+ return value
299
+ }
300
+ if (token === 'true') return true
301
+ if (token === 'false') return false
302
+ const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? '')
303
+ if (!call) return undefined
304
+ const [, name, argument] = call
305
+ if (name === 'os') return argument === 'iOS' || argument === 'WASI'
306
+ if (name === 'canImport') return available.has(argument!)
307
+ if (name === 'targetEnvironment') return false
308
+ if (name === 'arch') return argument === 'wasm32'
309
+ return undefined
310
+ }
311
+ const both = (): boolean | undefined => {
312
+ let value = atom()
313
+ while (tokens[index] === '&&') {
314
+ index++
315
+ const next = atom()
316
+ value = value === false || next === false ? false : value && next ? true : undefined
317
+ }
318
+ return value
319
+ }
320
+ const either = (): boolean | undefined => {
321
+ let value = both()
322
+ while (tokens[index] === '||') {
323
+ index++
324
+ const next = both()
325
+ value =
326
+ value === true || next === true
327
+ ? true
328
+ : value === false && next === false
329
+ ? false
330
+ : undefined
331
+ }
332
+ return value
333
+ }
334
+ return either()
335
+ }
336
+
278
337
  /**
279
- * the modules a source imports, in order. `unconditional` keeps only imports
280
- * outside every `#if`: a conditional one may compile out (`os(macOS)`,
281
- * `canImport`), so only an unconditional import is certainly required.
338
+ * the modules a source imports, in order. with `available`, only imports the
339
+ * wasm compile certainly reaches: those outside every `#if`, or in a branch
340
+ * whose condition holds there, `os(iOS)` included since the compile rewrites
341
+ * it to true. a branch the scan cannot decide may compile out, so its
342
+ * imports stay out of the list.
282
343
  */
283
- export function swiftImportNames(contents: string, unconditional = false): string[] {
344
+ export function swiftImportNames(
345
+ contents: string,
346
+ available?: ReadonlySet<string>,
347
+ ): string[] {
284
348
  const names: string[] = []
285
- let depth = 0
349
+ // per open `#if`: whether its current branch is active, and whether an
350
+ // earlier branch was taken (or may have been)
351
+ const frames: { active: boolean | undefined; taken: boolean | undefined }[] = []
286
352
  for (const line of contents.split('\n')) {
287
- const directive = /^\s*#(if|endif)\b/.exec(line)?.[1]
288
- if (directive === 'if') depth++
289
- else if (directive === 'endif') depth = Math.max(0, depth - 1)
290
- if (unconditional && depth > 0) continue
353
+ const directive = /^\s*#(if|elseif|else|endif)\b(.*)$/.exec(line)
354
+ if (directive && available) {
355
+ const [, kind, rest] = directive
356
+ const condition = (rest ?? '').replace(/\/\/.*$/, '').trim()
357
+ if (kind === 'if') {
358
+ const active = swiftCondition(condition, available)
359
+ frames.push({ active, taken: active })
360
+ } else if (kind === 'endif') frames.pop()
361
+ else if (frames.length > 0) {
362
+ const frame = frames[frames.length - 1]!
363
+ const holds = kind === 'else' ? true : swiftCondition(condition, available)
364
+ frame.active =
365
+ frame.taken === true
366
+ ? false
367
+ : frame.taken === false
368
+ ? holds
369
+ : holds && undefined
370
+ frame.taken =
371
+ frame.taken === true || holds === true
372
+ ? true
373
+ : frame.taken === false
374
+ ? holds
375
+ : undefined
376
+ }
377
+ continue
378
+ }
379
+ if (available && frames.some((frame) => frame.active !== true)) continue
291
380
  const name = SWIFT_IMPORT.exec(line)?.[1]
292
381
  if (name) names.push(name)
293
382
  }
@@ -346,8 +435,9 @@ export function swiftAvailableModules(
346
435
  }
347
436
 
348
437
  /**
349
- * the modules the sources import outside any `#if` that nothing available
350
- * provides, each with the files importing it. the compiler stops at the first
438
+ * the modules the sources certainly import (swiftImportNames with
439
+ * `available`) that nothing available provides, each with the files
440
+ * importing it. the compiler stops at the first
351
441
  * missing module; this names all of them at once.
352
442
  */
353
443
  export function missingSwiftModules(
@@ -357,7 +447,7 @@ export function missingSwiftModules(
357
447
  const missing = new Map<string, string[]>()
358
448
  for (const [file, contents] of Object.entries(files)) {
359
449
  if (!file.endsWith('.swift') || file === 'Package.swift') continue
360
- for (const name of new Set(swiftImportNames(contents, true))) {
450
+ for (const name of new Set(swiftImportNames(contents, available))) {
361
451
  if (available.has(name)) continue
362
452
  missing.set(name, [...(missing.get(name) ?? []), file])
363
453
  }
package/src/swift-host.ts CHANGED
@@ -24,12 +24,12 @@ import {
24
24
  swiftApplicationEntry,
25
25
  } from './swift-compile'
26
26
  import { swiftDistributionRoot, swiftModuleToolchain } from './swift-distribution'
27
- import { swiftImplicitResourcePaths, swiftManifestTargets } from './swift-package'
27
+ import { swiftImplicitResourcePaths, type SwiftPackageTarget } from './swift-package'
28
28
  import {
29
29
  REMOTE_CHECKOUTS,
30
- resolveRemotePackages,
31
- type RemotePackages,
32
- } from './swift-remote-packages'
30
+ resolveSwiftPackages,
31
+ type SwiftPackages,
32
+ } from './swift-packages'
33
33
  import {
34
34
  MAX_SWIFT_COMPILE_FILES,
35
35
  MAX_SWIFT_COMPILE_SOURCE_BYTES,
@@ -181,7 +181,7 @@ interface XcodeProjectEntry {
181
181
  target?: string
182
182
  /** peach's own modules: a remote product named one links it, never its source. */
183
183
  provided: ReadonlySet<string> | null
184
- remote?: { key: string; packages: RemotePackages }
184
+ packages?: { key: string; packages: SwiftPackages }
185
185
  }
186
186
 
187
187
  const xcodeProjects = new Map<string, XcodeProjectEntry>()
@@ -207,26 +207,32 @@ export function openXcodeProject(
207
207
  return root
208
208
  }
209
209
 
210
- // remote packages resolve once per set of linked products and pins.
211
- function remotePackages(entry: XcodeProjectEntry, app: XcodeAppTarget): RemotePackages {
212
- if (!entry.provided) return { targets: [], unavailable: new Map() }
210
+ // packages resolve once per set of linked products, pins and local manifests.
211
+ function swiftPackages(entry: XcodeProjectEntry, app: XcodeAppTarget): SwiftPackages {
212
+ const stamp = (file: string | null) =>
213
+ file && fs.existsSync(file) ? fs.statSync(file).mtimeMs : 0
213
214
  const key = JSON.stringify([
214
- app.remoteProducts,
215
+ app.linkedProducts,
215
216
  app.packageResolved,
216
- app.packageResolved ? fs.statSync(app.packageResolved).mtimeMs : 0,
217
+ stamp(app.packageResolved),
218
+ app.localPackageDirs.map((dir) => stamp(path.join(dir, 'Package.swift'))),
219
+ app.linkedProducts.map(({ source }) =>
220
+ source.kind === 'local' ? stamp(path.join(source.dir, 'Package.swift')) : 0,
221
+ ),
217
222
  ])
218
- if (entry.remote?.key !== key) {
219
- entry.remote = {
223
+ if (entry.packages?.key !== key) {
224
+ entry.packages = {
220
225
  key,
221
- packages: resolveRemotePackages(
222
- app.rootDir,
223
- app.packageResolved,
224
- app.remoteProducts,
225
- entry.provided,
226
- ),
226
+ packages: resolveSwiftPackages({
227
+ rootDir: app.rootDir,
228
+ resolved: app.packageResolved,
229
+ products: app.linkedProducts,
230
+ localDirs: app.localPackageDirs,
231
+ provided: entry.provided,
232
+ }),
227
233
  }
228
234
  }
229
- return entry.remote.packages
235
+ return entry.packages.packages
230
236
  }
231
237
 
232
238
  // the app target's sources compile as one executable target under this
@@ -252,10 +258,9 @@ function xcodeInputKey(layout: XcodeLayout, file: string, relative: string): str
252
258
 
253
259
  interface XcodeLayout {
254
260
  app: XcodeAppTarget
255
- /** the local and remote package targets the app links, with project-relative paths. */
256
- targets: ReturnType<typeof swiftManifestTargets>
257
- /** remote products that cannot compile, with why. */
258
- unavailable: RemotePackages['unavailable']
261
+ /** framework and package targets, with root-relative paths and the nested target directories they exclude. */
262
+ targets: (SwiftPackageTarget & { exclude: string[] })[]
263
+ packages: SwiftPackages
259
264
  /** the input directory each app and framework source compiles under. */
260
265
  targetDirs: Map<string, string>
261
266
  files: string[]
@@ -281,56 +286,50 @@ function xcodeLayout(root: string): XcodeLayout | null {
281
286
  path: dir,
282
287
  executable: false,
283
288
  resources: false,
289
+ exclude: [],
284
290
  languageMode: framework.languageMode,
285
291
  mainActorIsolation: framework.mainActorIsolation,
286
292
  })
287
293
  }
288
- for (const dir of app.localPackages) {
289
- const manifestFile = path.join(dir, 'Package.swift')
290
- files.add(manifestFile)
291
- const manifest = fs.readFileSync(manifestFile, 'utf8')
292
- const prefix = path.relative(root, dir).split(path.sep).join(path.posix.sep)
293
- // only target directories: a package at a repository's root holds the
294
- // whole app beside its sources
295
- const declared = swiftManifestTargets(manifest).filter((target) => !target.executable)
296
- const all = declared.flatMap((target) =>
297
- sourceTreeFiles(path.join(dir, target.path), root).map((file) =>
298
- path.relative(dir, file).split(path.sep).join(path.posix.sep),
299
- ),
294
+ const packages = swiftPackages(registered, app)
295
+ for (const target of packages.targets) {
296
+ const relative = path.relative(
297
+ target.remote ? path.join(root, REMOTE_CHECKOUTS) : root,
298
+ target.dir,
300
299
  )
301
- for (const target of swiftManifestTargets(manifest, all)) {
302
- if (target.executable) continue
303
- targets.push({ ...target, path: path.posix.join(prefix, target.path) })
304
- for (const relative of all) {
305
- if (relative.startsWith(`${target.path}/`)) files.add(path.join(dir, relative))
306
- }
307
- }
308
- }
309
- const remote = remotePackages(registered, app)
310
- for (const target of remote.targets) {
300
+ if (
301
+ relative === '..' ||
302
+ relative.startsWith(`..${path.sep}`) ||
303
+ path.isAbsolute(relative)
304
+ )
305
+ throw new Error(`swift input escapes the selected package: ${target.dir}`)
306
+ const posix = relative.split(path.sep).join(path.posix.sep)
311
307
  targets.push({
312
308
  ...target,
313
- path: path.posix.join(
314
- XCODE_PACKAGES_DIR,
315
- path
316
- .relative(path.join(root, REMOTE_CHECKOUTS), target.dir)
317
- .split(path.sep)
318
- .join(path.posix.sep),
319
- ),
309
+ path: target.remote ? path.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
310
+ exclude: [],
320
311
  })
312
+ if (!target.remote) files.add(path.join(target.packageDir, 'Package.swift'))
321
313
  for (const file of target.files) files.add(file)
322
314
  }
315
+ // swiftpm assigns a file to one target: a target directory nested in
316
+ // another's is that one's exclusion
317
+ for (const target of targets) {
318
+ target.exclude = targets
319
+ .filter((other) => other.path.startsWith(`${target.path}/`))
320
+ .map((other) => other.path.slice(target.path.length + 1))
321
+ }
323
322
  return {
324
323
  app,
325
324
  targets,
326
- unavailable: remote.unavailable,
325
+ packages,
327
326
  targetDirs,
328
327
  files: [...files].sort(),
329
328
  }
330
329
  }
331
330
 
332
331
  // the manifest the compile reads for an xcode app: the app target and each
333
- // linked local package target, in the forms swiftManifestTargets scans.
332
+ // framework and package target, in the forms swiftManifestTargets scans.
334
333
  function xcodeManifest(layout: XcodeLayout): string {
335
334
  const settings = (mode: number, mainActor: boolean) =>
336
335
  `swiftSettings: [.swiftLanguageMode(.v${mode})${mainActor ? ', .defaultIsolation(MainActor.self)' : ''}]`
@@ -341,7 +340,7 @@ function xcodeManifest(layout: XcodeLayout): string {
341
340
  ` .executableTarget(name: "${layout.app.moduleName}", path: "${XCODE_APP_DIR}", ${settings(layout.app.languageMode, layout.app.mainActorIsolation)}),`,
342
341
  ...layout.targets.map(
343
342
  (target) =>
344
- ` .target(name: "${target.name}", path: "${target.path}", ${target.resources ? 'resources: [], ' : ''}${settings(target.languageMode, target.mainActorIsolation)}),`,
343
+ ` .target(name: "${target.name}", path: "${target.path}", ${target.exclude.length > 0 ? `exclude: ${JSON.stringify(target.exclude)}, ` : ''}${target.resources ? 'resources: [], ' : ''}${settings(target.languageMode, target.mainActorIsolation)}),`,
345
344
  ),
346
345
  '])',
347
346
  '',
@@ -941,19 +940,20 @@ function missingModulesMessage(
941
940
  missing: Map<string, string[]>,
942
941
  ): string {
943
942
  const layout = xcodeLayout(packagePath)
944
- const remote = new Map(
945
- (layout?.app.remoteProducts ?? []).map((entry) => [
946
- entry.product,
947
- entry.repositoryURL,
948
- ]),
949
- )
943
+ const gaps = new Map([
944
+ ...(layout?.app.binaryFrameworks ?? []).map(
945
+ (name) =>
946
+ [name, { source: 'the project', reason: 'a vendored binary framework' }] as const,
947
+ ),
948
+ ...(layout?.packages.modules ?? []),
949
+ ...(layout?.packages.unavailable ?? []),
950
+ ])
950
951
  const width = Math.max(...[...missing.keys()].map((name) => name.length))
951
952
  return [
952
953
  `Peach does not provide ${missing.size} module${missing.size === 1 ? '' : 's'} this app imports:`,
953
954
  ...[...missing].map(([name, files]) => {
954
- const source = remote.get(name)
955
- const reason = layout?.unavailable.get(name)?.reason
956
- return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? '' : 's'}${source ? `, package ${source}` : ''}${reason ? ` (${reason})` : ''}`
955
+ const gap = gaps.get(name)
956
+ return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? '' : 's'}${gap ? `, ${gap.source.includes('://') ? `package ${gap.source}` : gap.source.startsWith('/') ? `package ${path.relative(packagePath, gap.source) || '.'}` : gap.source} (${gap.reason})` : ''}`
957
957
  }),
958
958
  ].join('\n')
959
959
  }