peachsim 0.1.1692 → 0.1.1700

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 (245) hide show
  1. package/cli/bridge-flow-runner.ts +61 -39
  2. package/cli/commands/agent-wrapper.ts +21 -10
  3. package/cli/commands/control.ts +27 -7
  4. package/cli/commands/coverage.ts +1 -1
  5. package/cli/commands/detect.ts +17 -4
  6. package/cli/commands/maestro-compare.ts +25 -99
  7. package/cli/help-core.ts +3 -4
  8. package/cli/maestro-compare.ts +172 -4
  9. package/cli/outbound-endpoints.ts +2 -10
  10. package/detox/index.ts +15 -0
  11. package/detox/launch-permissions.ts +169 -0
  12. package/dist-lib/agent-daemon-client.cjs +2 -2
  13. package/dist-lib/agent-events.cjs +2 -2
  14. package/dist-lib/attached-projects.cjs +2 -2
  15. package/dist-lib/auth/shared-session.cjs +2 -2
  16. package/dist-lib/backend-origin.cjs +2 -2
  17. package/dist-lib/beta.cjs +2 -2
  18. package/dist-lib/beta.mjs +1 -1
  19. package/dist-lib/bridge-constants.cjs +2 -2
  20. package/dist-lib/bridge-contract-input.cjs +2 -2
  21. package/dist-lib/bridge-contract-input.mjs +1 -1
  22. package/dist-lib/bridge-contract.cjs +2 -2
  23. package/dist-lib/bridge-contract.mjs +1 -1
  24. package/dist-lib/bundle-channel.cjs +18273 -15925
  25. package/dist-lib/capture-contract.cjs +2 -2
  26. package/dist-lib/capture-contract.mjs +1 -1
  27. package/dist-lib/cloud-contract.cjs +2 -2
  28. package/dist-lib/cloud-contract.mjs +1 -1
  29. package/dist-lib/cloud-test-args.cjs +2 -2
  30. package/dist-lib/cloud-test-args.mjs +1 -1
  31. package/dist-lib/cloud.cjs +2 -2
  32. package/dist-lib/cloud.mjs +1 -1
  33. package/dist-lib/config.cjs +2 -2
  34. package/dist-lib/config.mjs +1 -1
  35. package/dist-lib/detox/index.cjs +104 -3
  36. package/dist-lib/dev-bundle-resolution.cjs +208 -44
  37. package/dist-lib/expo-swift-bundle.cjs +2349 -1778
  38. package/dist-lib/expo-swift-metadata.cjs +2 -2
  39. package/dist-lib/expo-swift-metadata.mjs +1 -1
  40. package/dist-lib/home-paths.cjs +2 -2
  41. package/dist-lib/host/bridge-host.cjs +7885 -3334
  42. package/dist-lib/host/fetch-proxy-handler.cjs +331 -39
  43. package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
  44. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  45. package/dist-lib/host/replacement-module-handler.cjs +2 -2
  46. package/dist-lib/host/websocket-proxy.cjs +2 -2
  47. package/dist-lib/index.cjs +297 -77
  48. package/dist-lib/jump-to-source-babel.cjs +2 -2
  49. package/dist-lib/jump-to-source-native.cjs +2 -2
  50. package/dist-lib/kotlin-host.cjs +2 -2
  51. package/dist-lib/menu.cjs +2 -2
  52. package/dist-lib/menu.mjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.cjs +2 -2
  54. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  55. package/dist-lib/metro-production-bundle.cjs +2 -2
  56. package/dist-lib/metro-production-bundle.mjs +1 -1
  57. package/dist-lib/metro.cjs +294 -74
  58. package/dist-lib/native-app-identity-project.cjs +48 -37
  59. package/dist-lib/native-app-identity-project.mjs +47 -36
  60. package/dist-lib/native-app-identity.cjs +2 -2
  61. package/dist-lib/native-app-identity.mjs +1 -1
  62. package/dist-lib/native-firebase-metadata.cjs +2 -2
  63. package/dist-lib/native-firebase-metadata.mjs +1 -1
  64. package/dist-lib/plist.cjs +2 -2
  65. package/dist-lib/plist.mjs +1 -1
  66. package/dist-lib/profiles.cjs +2 -2
  67. package/dist-lib/public-brand.cjs +2 -2
  68. package/dist-lib/public-origins-lib-esm.json +24 -23
  69. package/dist-lib/public-origins-lib.json +199 -79
  70. package/dist-lib/react-native-host-modules.cjs +2 -2
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/reap-browser.cjs +2 -2
  73. package/dist-lib/scripts/dev-server-scanner.cjs +206 -31
  74. package/dist-lib/sdk.cjs +2 -2
  75. package/dist-lib/sdk.mjs +1 -1
  76. package/dist-lib/skills.cjs +19600 -15992
  77. package/dist-lib/swift-compile.cjs +640 -402
  78. package/dist-lib/swift-compile.mjs +595 -357
  79. package/dist-lib/swift-package.cjs +24 -20
  80. package/dist-lib/swift-package.mjs +23 -19
  81. package/dist-lib/swift-submit.cjs +2 -2
  82. package/dist-lib/swift-submit.mjs +1 -1
  83. package/dist-lib/swift-toolchain.cjs +31 -4
  84. package/dist-lib/swift.cjs +2 -2
  85. package/dist-lib/vite-swift.cjs +1559 -1208
  86. package/dist-lib/vite.cjs +251 -42
  87. package/dist-lib/worklet-executable.cjs +2 -2
  88. package/dist-lib/worklet-executable.mjs +1 -1
  89. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +1 -1
  90. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  91. package/dist-types/packages/peach-engine/src/engine/scroll-pan-contacts.d.ts +3 -1
  92. package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +7 -0
  93. package/dist-types/packages/peach-engine/src/engine/types.d.ts +2 -1
  94. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
  95. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  96. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +1 -0
  97. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +17 -0
  98. package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +2 -1
  99. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +3 -0
  100. package/dist-types/packages/peach-globals/src/cameraBridgeContract.d.ts +1 -0
  101. package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +1 -0
  102. package/dist-types/packages/peach-globals/src/shellHostBridgeContract.d.ts +3 -0
  103. package/dist-types/packages/peach-kit/src/materials/types.d.ts +1 -0
  104. package/package.json +1 -1
  105. package/runtime-companion.json +1 -1
  106. package/scripts/dev-server-scanner.ts +4 -0
  107. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Alpha.h +2282 -0
  108. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/BasicImageTypes.h +55 -0
  109. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Conversion.h +10551 -6
  110. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Convolution.h +4236 -3
  111. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Geometry.h +827 -8
  112. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Histogram.h +1369 -0
  113. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Morphology.h +1243 -0
  114. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Transform.h +1747 -0
  115. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage.h +291 -2
  116. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_CVUtilities.h +1283 -0
  117. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Types.h +811 -91
  118. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Utilities.h +1342 -25
  119. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns.h +2738 -0
  120. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_constants.h +1685 -0
  121. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_graph.h +913 -0
  122. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_structures.h +1917 -0
  123. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/LinearAlgebra.h +23 -0
  124. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/arithmetic.h +209 -0
  125. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/base.h +104 -0
  126. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/linear_systems.h +77 -0
  127. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/matrix.h +554 -0
  128. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/norms.h +58 -0
  129. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/object.h +186 -0
  130. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/splat.h +86 -0
  131. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/vector.h +364 -0
  132. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Integration.h +195 -0
  133. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Quadrature.h +44 -0
  134. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/BLAS.h +2330 -0
  135. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/Types.h +123 -0
  136. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Solve.h +8339 -0
  137. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementation.h +520 -0
  138. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementationTyped.h +1893 -0
  139. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Sparse.h +10 -0
  140. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/blas_new.h +1098 -0
  141. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas.h +859 -0
  142. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas_new.h +1134 -0
  143. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h +10555 -0
  144. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h +695 -0
  145. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack.h +38526 -0
  146. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_types.h +60 -0
  147. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_version.h +20 -0
  148. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/thread_api.h +50 -0
  149. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBasicOps.h +1218 -0
  150. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBigNum.h +1458 -0
  151. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP.h +10377 -0
  152. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP_translate.h +167 -0
  153. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vForce.h +1243 -0
  154. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLib.h +114 -0
  155. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLibTypes.h +146 -0
  156. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vectorOps.h +1106 -0
  157. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vfp.h +294 -0
  158. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h +25 -1
  159. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h +673 -0
  160. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFAvailability.h +232 -0
  161. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h +827 -0
  162. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCalendar.h +121 -0
  163. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCharacterSet.h +387 -0
  164. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFData.h +79 -0
  165. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDate.h +122 -0
  166. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDictionary.h +674 -0
  167. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFError.h +182 -0
  168. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFLocale.h +213 -0
  169. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNotificationCenter.h +82 -0
  170. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNumber.h +129 -0
  171. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFSet.h +491 -0
  172. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +883 -2
  173. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFTimeZone.h +98 -0
  174. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +11 -229
  175. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -6
  176. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +2 -1
  177. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +1 -0
  178. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecBase.h +906 -3
  179. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecCertificate.h +613 -0
  180. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecItem.h +1284 -29
  181. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecPolicy.h +441 -0
  182. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecTrust.h +845 -0
  183. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/Security.h +4 -0
  184. package/sdk/ios/usr/include/AvailabilityMacros.h +3985 -0
  185. package/sdk/ios/usr/include/copyfile.h +143 -0
  186. package/sdk/ios/usr/include/malloc/_malloc.h +143 -0
  187. package/sdk/ios/usr/include/malloc/_malloc_type.h +153 -0
  188. package/sdk/ios/usr/include/malloc/_platform.h +80 -0
  189. package/sdk/ios/usr/include/malloc/_ptrcheck.h +43 -0
  190. package/sdk/ios/usr/include/malloc/malloc.h +768 -0
  191. package/sdk/ios/usr/include/os/availability.h +168 -6
  192. package/sdk/ios/usr/include/os/base.h +351 -0
  193. package/sdk/ios/usr/include/os/clock.h +18 -0
  194. package/sdk/ios/usr/include/os/lock.h +232 -10
  195. package/sdk/ios/usr/include/os/log.h +521 -38
  196. package/sdk/ios/usr/include/os/object.h +320 -3
  197. package/sdk/ios/usr/include/os/trace.h +492 -0
  198. package/sdk/ios/usr/include/os/trace_base.h +167 -0
  199. package/sdk/ios/usr/include/os/workgroup.h +37 -0
  200. package/sdk/ios/usr/include/os/workgroup_base.h +91 -0
  201. package/sdk/ios/usr/include/os/workgroup_interval.h +156 -0
  202. package/sdk/ios/usr/include/os/workgroup_object.h +359 -0
  203. package/sdk/ios/usr/include/os/workgroup_parallel.h +76 -0
  204. package/sdk/ios/usr/include/sys/cdefs.h +38 -0
  205. package/sdk/ios/wasm/include/unistd.h +3 -0
  206. package/skills/contrast/SKILL.md +3 -0
  207. package/src/codex-client.ts +11 -6
  208. package/src/dev-bundle-resolution.ts +124 -48
  209. package/src/expo-native-workspace.ts +176 -0
  210. package/src/expo-swift-host.ts +161 -26
  211. package/src/expo-swift-ready.ts +14 -28
  212. package/src/expoSwiftContract.ts +4 -1
  213. package/src/generated/swift-c-predefines.json +68 -12
  214. package/src/host/bridge-host.ts +5 -0
  215. package/src/installed-package-versions.ts +14 -1
  216. package/src/metro-project-root.ts +44 -33
  217. package/src/native-app-identity-project.ts +1 -0
  218. package/src/nitro-adapter.lock.json +916 -10
  219. package/src/nitro-adapter.ts +33 -24
  220. package/src/nitro-bundle.ts +108 -22
  221. package/src/nitro-compile.ts +32 -5
  222. package/src/nitro-source.ts +13 -3
  223. package/src/nitroAdapterContract.ts +100 -20
  224. package/src/node-http-fetch.ts +116 -0
  225. package/src/packageVersionsContract.ts +46 -0
  226. package/src/serverDiscoveryContract.ts +1 -0
  227. package/src/settingsContract.ts +0 -30
  228. package/src/swift-binary-modules.ts +20 -5
  229. package/src/swift-compile.ts +168 -48
  230. package/src/swift-coverage/xcode-assets.ts +4 -3
  231. package/src/swift-host.ts +14 -3
  232. package/src/swift-objc-compile.ts +32 -5
  233. package/src/swift-objc-metadata.ts +2 -2
  234. package/src/swift-objc-platform.ts +2 -2
  235. package/src/swift-objc-standin.ts +43 -13
  236. package/src/swift-package.ts +33 -26
  237. package/src/swift-source-pods.ts +126 -41
  238. package/src/swift-standin-digest.ts +77 -0
  239. package/src/swift-standin-emit.ts +40 -4
  240. package/src/swift-standins.ts +68 -19
  241. package/src/swift-toolchain.ts +38 -0
  242. package/src/swiftContract.ts +8 -0
  243. package/src/vite-plugin.ts +0 -10
  244. package/src/xcode-project.ts +62 -42
  245. package/src/settings-flags.ts +0 -107
@@ -13,7 +13,6 @@ import { execFileSync, spawnSync } from 'node:child_process'
13
13
  import { createHash } from 'node:crypto'
14
14
  import fs from 'node:fs'
15
15
  import path from 'node:path'
16
- import { getCliVersion } from './cli-version'
17
16
  import { cacheDir as peachCacheDir, swiftPackageCacheOptions } from './home-paths'
18
17
  import { isRecord } from './is-record'
19
18
  import { outputLockStdio } from './output-lock-stdio'
@@ -30,7 +29,6 @@ import {
30
29
  import {
31
30
  IOS_SDK_ID,
32
31
  NATIVE_GRAPH_ID,
33
- OBJC_IMPORT_VERSION,
34
32
  WASI_EMULATION,
35
33
  WASI_EMULATION_FLAGS,
36
34
  nativeInterfaceView,
@@ -39,8 +37,8 @@ import {
39
37
  type ObjcSurface,
40
38
  } from './swift-objc-standin'
41
39
  import { moduleMapName, swiftTargetModuleName } from './swift-package'
40
+ import { STANDIN_SOURCE_DIGEST, standinSourceDigest } from './swift-standin-digest'
42
41
  import {
43
- STANDIN_EMIT_VERSION,
44
42
  STANDIN_IMPORTS,
45
43
  emitSwiftStandin,
46
44
  type SymbolGraph,
@@ -431,6 +429,12 @@ function peachModuleDirs(toolchain: Toolchain, imports: string[]): string[] {
431
429
  '-Xswiftc',
432
430
  library,
433
431
  ]),
432
+ ...plugins.executables.flatMap((plugin) => [
433
+ '-Xswiftc',
434
+ '-load-plugin-executable',
435
+ '-Xswiftc',
436
+ `${plugin}#ExpoModulesMacros`,
437
+ ]),
434
438
  ],
435
439
  moduleRoot,
436
440
  )
@@ -707,8 +711,14 @@ function graphStandin(
707
711
  function functionDeclarations(
708
712
  ast: unknown,
709
713
  headers: ReadonlySet<string>,
710
- ): { name: string; file: string; begin: number; end: number }[] {
711
- const found: { name: string; file: string; begin: number; end: number }[] = []
714
+ ): { name: string; file: string; begin: number; end: number; parameterless: boolean }[] {
715
+ const found: {
716
+ name: string
717
+ file: string
718
+ begin: number
719
+ end: number
720
+ parameterless: boolean
721
+ }[] = []
712
722
  let file = ''
713
723
  const note = (location: unknown) => {
714
724
  if (!location || typeof location !== 'object') return
@@ -747,6 +757,9 @@ function functionDeclarations(
747
757
  inner.some((child) => Reflect.get(child, 'kind') === 'CompoundStmt')
748
758
  )
749
759
  continue
760
+ const parameterless =
761
+ !Array.isArray(inner) ||
762
+ !inner.some((child) => Reflect.get(child, 'kind') === 'ParmVarDecl')
750
763
  const range = Reflect.get(decl, 'range')
751
764
  const offset = (end: 'begin' | 'end') => {
752
765
  const at = Reflect.get(range, end)
@@ -758,11 +771,21 @@ function functionDeclarations(
758
771
  file: declFile,
759
772
  begin: offset('begin'),
760
773
  end: offset('end'),
774
+ parameterless,
761
775
  })
762
776
  }
763
777
  return found
764
778
  }
765
779
 
780
+ // clang's c17 mode marks `foo()` with `"no-prototype"`, while swift's clang
781
+ // importer lowers it as a 0-arg non-vararg wasm declaration that trips llvm's
782
+ // WebAssemblyAddMissingPrototypes pass; `(void)` gives both a prototype.
783
+ function withVoidPrototype(text: string, name: string, parameterless: boolean): string {
784
+ if (!parameterless) return text
785
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
786
+ return text.replace(new RegExp(`\\b(${escaped}\\s*)\\(\\s*\\)`), '$1(void)')
787
+ }
788
+
766
789
  // the opener matching the closer at `close`, scanning left.
767
790
  function matchOpen(text: string, close: number): number {
768
791
  const open = text[close] === ')' ? '(' : '['
@@ -909,28 +932,54 @@ function cStandin(
909
932
  }
910
933
  const seen = new Set<string>()
911
934
  const definitions: string[] = []
935
+ const patches = new Map<string, { begin: number; end: number; text: string }[]>()
912
936
  for (const group of groups.values()) {
913
937
  const first = group[0]!
914
- const text = bytes.get(byPath.get(first.file)!)!
938
+ const file = byPath.get(first.file)!
939
+ const text = bytes.get(file)!
915
940
  const close = text.indexOf(';', first.end)
916
- if (close < 0)
917
- throw new Error(`${first.name} has no declaration end in ${byPath.get(first.file)}`)
941
+ if (close < 0) throw new Error(`${first.name} has no declaration end in ${file}`)
918
942
  const statement = text.subarray(first.begin, close).toString('utf8')
943
+ let patched = statement
944
+ for (const declaration of group)
945
+ patched = withVoidPrototype(patched, declaration.name, declaration.parameterless)
946
+ if (patched !== statement) {
947
+ const list = patches.get(file) ?? []
948
+ list.push({ begin: first.begin, end: close, text: patched })
949
+ patches.set(file, list)
950
+ }
919
951
  const declarators =
920
952
  group.length === 1
921
- ? [statement]
953
+ ? [patched]
922
954
  : splitDeclarators(
923
- statement,
955
+ patched,
924
956
  group.map((declaration) => declaration.name),
925
957
  )
926
958
  group.forEach((declaration, index) => {
927
959
  if (seen.has(declaration.name)) return
928
960
  seen.add(declaration.name)
961
+ const signature = withVoidPrototype(
962
+ declarators[index]!.trim(),
963
+ declaration.name,
964
+ declaration.parameterless,
965
+ )
929
966
  definitions.push(
930
- `${declarators[index]!.trim()} {\n peach_standin_trap("${declaration.name}");\n}\n`,
967
+ `${signature} {\n peach_standin_trap("${declaration.name}");\n}\n`,
931
968
  )
932
969
  })
933
970
  }
971
+ for (const [file, list] of patches) {
972
+ let buffer = bytes.get(file)!
973
+ for (const patch of list.sort((left, right) => right.begin - left.begin))
974
+ buffer = Buffer.concat([
975
+ buffer.subarray(0, patch.begin),
976
+ Buffer.from(patch.text, 'utf8'),
977
+ buffer.subarray(patch.end),
978
+ ])
979
+ const updated = buffer.toString('utf8')
980
+ texts.set(file, updated)
981
+ fs.writeFileSync(path.join(include, file), updated)
982
+ }
934
983
  const sdk = JSON.stringify(`${binary.target} (${binary.source})`)
935
984
  const source = [
936
985
  `// generated by peach from ${surface.module}'s headers: ${binary.target} ships`,
@@ -1340,27 +1389,27 @@ function readStandinResults(
1340
1389
  const built = new Map<string, SwiftStandin[] | string>()
1341
1390
 
1342
1391
  /** what stand-ins are generated from besides the surfaces' files: the
1343
- * toolchain, peach's modules and distribution, the emitter, and each
1344
- * artifact's contents. the host's memo and the stand-in cache both key on
1345
- * it, so either notices a changed input. */
1392
+ * toolchain, peach's modules and distribution, the emitter and importer
1393
+ * sources, and each artifact's contents. the host's memo and the stand-in
1394
+ * cache both key on it, so either notices a changed input. */
1346
1395
  export function standinGenerationInputs(
1347
1396
  binaries: readonly SwiftPackageBinary[],
1348
1397
  toolchain: Pick<Toolchain, 'moduleRoot' | 'release'>,
1349
1398
  behavior: SwiftStandinBehaviors = {},
1399
+ sourceDir?: string,
1350
1400
  ): string {
1351
1401
  const { moduleRoot, release } = toolchain
1352
1402
  const sdk = swiftModuleSdk(moduleRoot)
1403
+ const digest =
1404
+ sourceDir === undefined ? STANDIN_SOURCE_DIGEST : standinSourceDigest(sourceDir)
1353
1405
  const parts = [
1354
- 'standin/v11',
1406
+ 'standin/v13',
1355
1407
  release,
1356
1408
  sdk.wasmSdkId,
1357
1409
  sdk.wasmSdkChecksum,
1358
1410
  swiftModuleDigest(moduleRoot).toString('hex'),
1359
- `emit/${STANDIN_EMIT_VERSION}`,
1411
+ `sources/${digest}`,
1360
1412
  `ios-sdk/${IOS_SDK_ID}`,
1361
- `objc-import/${OBJC_IMPORT_VERSION}`,
1362
- // a released cli can change the emitter without anyone bumping the constant
1363
- `cli/${getCliVersion()}`,
1364
1413
  ]
1365
1414
  const modules = new Set(
1366
1415
  binaries.flatMap((binary) => {
@@ -124,6 +124,44 @@ export function swiftToolchainBin(release: string): string {
124
124
  )
125
125
  }
126
126
 
127
+ /** the linker file name {@link writeSwiftAutolinkLinker} writes in a build directory. */
128
+ export const SWIFT_AUTOLINK_LINKER = '.peach-wasm-ld'
129
+
130
+ /**
131
+ * clang's wasm link driver for swift: swift-autolink-extract emits one
132
+ * -l<lib> per object, so a large link carries thousands of copies of each
133
+ * library and wasm-ld reloads the archives every time (29 to 35GiB and 40s
134
+ * for a 42MB output). the linker written here keeps the first copy of each
135
+ * -l flag in clang's response file and runs the toolchain's wasm-ld, which
136
+ * links the same bytes in about 1GiB. callers pass its path to clang with
137
+ * `-Xclang-linker -fuse-ld=<path>`.
138
+ */
139
+ export function writeSwiftAutolinkLinker(
140
+ directory: string,
141
+ toolchainBin: string,
142
+ ): string {
143
+ const linker = path.join(directory, SWIFT_AUTOLINK_LINKER)
144
+ const script = `#!/bin/sh
145
+ set -eu
146
+ for arg in "$@"; do
147
+ case $arg in
148
+ @*)
149
+ rsp=\${arg#@}
150
+ awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
151
+ mv "$rsp.dedup" "$rsp"
152
+ ;;
153
+ esac
154
+ done
155
+ exec ${JSON.stringify(path.join(toolchainBin, 'wasm-ld'))} "$@"
156
+ `
157
+ if (fs.existsSync(linker) && fs.readFileSync(linker, 'utf8') === script) return linker
158
+ fs.mkdirSync(directory, { recursive: true })
159
+ const next = `${linker}.${process.pid}`
160
+ fs.writeFileSync(next, script, { mode: 0o755 })
161
+ fs.renameSync(next, linker)
162
+ return linker
163
+ }
164
+
127
165
  // home-paths.ts's rnxHomeDir, repeated because this file imports node builtins only.
128
166
  function peachHome(): string {
129
167
  const override = process.env.PEACH_HOME
@@ -115,6 +115,12 @@ export interface SwiftNativeTarget {
115
115
  deploymentTarget: string | null
116
116
  headers: string[]
117
117
  publicHeaders: string[]
118
+ /**
119
+ * whether the public headers also occupy the flat Module/Header.h namespace
120
+ * an xcode product publishes. a swiftpm target exposes them only from its
121
+ * public headers directory, keeping their relative paths.
122
+ */
123
+ flattensPublicHeaders: boolean
118
124
  bridgingHeader: string | null
119
125
  prefixHeader: string | null
120
126
  headerSearchPaths: string[]
@@ -189,6 +195,8 @@ export function swiftNativeTargetsRefusal(value: unknown): string | null {
189
195
  return at('deploymentTarget')
190
196
  if (!paths(field('headers'))) return at('headers')
191
197
  if (!paths(field('publicHeaders'))) return at('publicHeaders')
198
+ if (typeof field('flattensPublicHeaders') !== 'boolean')
199
+ return at('flattensPublicHeaders')
192
200
  if (!nullablePath('bridgingHeader')) return at('bridgingHeader')
193
201
  if (!nullablePath('prefixHeader')) return at('prefixHeader')
194
202
  if (
@@ -16,7 +16,6 @@ import { fileURLToPath, pathToFileURL } from 'url'
16
16
  import { parseSync } from 'oxc-parser'
17
17
  import { minifySync, transformSync } from 'rolldown/utils'
18
18
  import { type Plugin, transformWithOxc } from 'vite'
19
- import { resolveOneNativeBackend } from '../../contrast-bundler/src/oneFramework.ts'
20
19
  import { transformFlowSource } from '../../peach-compat/src/flow-strip.ts'
21
20
  import { getCliRuntime } from './cli-runtime.ts'
22
21
  import {
@@ -1655,13 +1654,6 @@ function sootsimConfigPlugin(
1655
1654
  return nativeLibraryStub ? { id: nativeLibraryStub } : null
1656
1655
  },
1657
1656
  },
1658
- {
1659
- name: 'peach-one-native-backend',
1660
- resolveId(source: string, importer: string | undefined) {
1661
- const backend = resolveOneNativeBackend(source, importer)
1662
- return backend ? { id: backend } : null
1663
- },
1664
- },
1665
1657
  {
1666
1658
  name: 'sootsim-published-browser-internals',
1667
1659
  resolveId(source: string, importer: string | undefined) {
@@ -2199,8 +2191,6 @@ function metroNativeResolve(isAppSource: (p: string) => boolean): Plugin {
2199
2191
  filter: { id: /^\./ },
2200
2192
  handler(source, importer) {
2201
2193
  if (!importer) return null
2202
- const oneBackend = resolveOneNativeBackend(source, importer)
2203
- if (oneBackend) return oneBackend
2204
2194
  if (!importer.includes('node_modules') && !isAppSource(importer)) return null
2205
2195
  if (platformExts.some((ext) => source.endsWith(ext))) return null
2206
2196
 
@@ -533,12 +533,16 @@ function targetSettings(
533
533
 
534
534
  // a list-typed build setting's items: whitespace separates them, and quotes
535
535
  // or a backslash keep whitespace inside one.
536
+ // xcode splits a list setting into words as a shell does: whitespace ends a
537
+ // word, and a quoted part joins its neighbors (`-fmodule-map-file="$(DIR)/x"`).
536
538
  function settingList(value: string): string[] {
537
539
  const items: string[] = []
538
- for (const [, quoted, plain] of value.matchAll(
539
- /"((?:\\.|[^"\\])*)"|((?:\\.|[^\s"])+)/g,
540
- ))
541
- items.push((quoted ?? plain!).replace(/\\(.)/g, '$1'))
540
+ for (const [word] of value.matchAll(/(?:"(?:\\.|[^"\\])*"|\\.|[^\s"\\])+/g))
541
+ items.push(
542
+ word.replace(/"((?:\\.|[^"\\])*)"|\\(.)/g, (_, quoted?: string, escaped?: string) =>
543
+ quoted !== undefined ? quoted.replace(/\\(.)/g, '$1') : escaped!,
544
+ ),
545
+ )
542
546
  return items
543
547
  }
544
548
 
@@ -664,6 +668,15 @@ function targetMembers(
664
668
  const headers = new Set<string>()
665
669
  const resources = new Set<string>()
666
670
  const scriptForOutput = new Map<string, string>()
671
+ const declaredInfoPlist = settings('INFOPLIST_FILE')
672
+ const infoPlistOutput = declaredInfoPlist
673
+ ? path.resolve(project.projectDir, declaredInfoPlist)
674
+ : null
675
+ // a build-generated info plist is read after its phase runs, even when no
676
+ // sources are required; swift sources only when they are.
677
+ const isPreparedOutput = (file: string) =>
678
+ file === infoPlistOutput ||
679
+ (options.requireSources !== false && file.endsWith('.swift'))
667
680
  for (const phaseId of list(target.buildPhases)) {
668
681
  const phase = project.object(phaseId)
669
682
  if (phase?.isa !== 'PBXShellScriptBuildPhase') continue
@@ -697,13 +710,9 @@ function targetMembers(
697
710
  ...fileLists.get('INPUT')!.flatMap((item) => [item.file, ...item.entries]),
698
711
  ...fileLists.get('OUTPUT')!.map((item) => item.file),
699
712
  ]
700
- if (allOutputs.some((file) => file.endsWith('.swift')))
713
+ if (allOutputs.some((file) => file.endsWith('.swift') || file === infoPlistOutput))
701
714
  for (const file of inputFiles) if (fs.existsSync(file)) projectInputs.add(file)
702
- if (
703
- options.prepareGeneratedSources &&
704
- options.requireSources !== false &&
705
- allOutputs.some((file) => file.endsWith('.swift'))
706
- ) {
715
+ if (options.prepareGeneratedSources && allOutputs.some(isPreparedOutput)) {
707
716
  const phaseDir = path.join(settings('TARGET_TEMP_DIR'), `Script-${phaseId}`)
708
717
  for (const lists of fileLists.values())
709
718
  for (const { file } of lists)
@@ -781,11 +790,11 @@ function targetMembers(
781
790
  ? `${error.message}\n${'stdout' in error ? String(error.stdout) : ''}${'stderr' in error ? String(error.stderr) : ''}`
782
791
  : String(error)
783
792
  throw new Error(
784
- `${targetName}: Run Script "${script}" failed preparing generated Swift sources:\n${output}`,
793
+ `${targetName}: Run Script "${script}" failed preparing generated outputs:\n${output}`,
785
794
  )
786
795
  }
787
796
  const missing = allOutputs.filter(
788
- (file) => file.endsWith('.swift') && !fs.existsSync(file),
797
+ (file) => isPreparedOutput(file) && !fs.existsSync(file),
789
798
  )
790
799
  if (missing.length > 0)
791
800
  throw new Error(
@@ -1236,15 +1245,11 @@ export function readXcodeAppTarget(
1236
1245
  if (cached) return cached
1237
1246
  const entries = new Map<string, string>()
1238
1247
  for (const ref of projectTargets(project)) {
1239
- const framework = FRAMEWORK_PRODUCTS.has(str(ref.target.productType) ?? '')
1240
- const product = framework ? productName(ref) : ''
1248
+ const product = productName(ref)
1241
1249
  for (const { file, visibility } of headerPhase(ref)) {
1242
1250
  const name = path.basename(file)
1243
1251
  if (!entries.has(name))
1244
- entries.set(
1245
- name,
1246
- framework && visibility !== 'Project' ? `${product}/${name}` : file,
1247
- )
1252
+ entries.set(name, visibility !== 'Project' ? `${product}/${name}` : file)
1248
1253
  }
1249
1254
  }
1250
1255
  for (const id of Object.keys(project.objects)) {
@@ -1382,24 +1387,11 @@ export function readXcodeAppTarget(
1382
1387
  // the header search xcode generates that peach does not model refuses
1383
1388
  // here, before any unit compiles without it.
1384
1389
  if (native && building) {
1385
- const generatedHeaders = list(ref.target.buildPhases).flatMap((phaseId) => {
1386
- const phase = ref.project.object(phaseId)
1387
- return phase?.isa === 'PBXShellScriptBuildPhase'
1388
- ? list(phase.outputPaths).filter((output) => HEADER_FILE.test(output))
1389
- : []
1390
- })
1391
- if (generatedHeaders.length > 0 || list(ref.target.buildRules).length > 0)
1390
+ // declared run-script outputs do not populate xcode's generated-files
1391
+ // header map; build rules can, and remain unsupported.
1392
+ if (list(ref.target.buildRules).length > 0)
1392
1393
  throw new Error(
1393
- `${name}: Xcode's generated-files header map, which lists headers its build rules and Run Script phases generate (${generatedHeaders.join(', ') || 'build rules'}), is not modeled`,
1394
- )
1395
- const nonFramework = projectTargets(ref.project).find(
1396
- (other) =>
1397
- !FRAMEWORK_PRODUCTS.has(str(other.target.productType) ?? '') &&
1398
- headerPhase(other).length > 0,
1399
- )
1400
- if (nonFramework && settings('USE_HEADERMAP') !== 'NO')
1401
- throw new Error(
1402
- `${name}: Xcode's all-non-framework-target-headers map, which lists the headers of ${str(nonFramework.target.name) ?? nonFramework.id}, is not modeled`,
1394
+ `${name}: Xcode's generated-files header map for build rules is not modeled`,
1403
1395
  )
1404
1396
  if (
1405
1397
  settings('ALWAYS_SEARCH_USER_PATHS') === 'YES' &&
@@ -1415,17 +1407,41 @@ export function readXcodeAppTarget(
1415
1407
  const ownHeaders = new Map<string, string>()
1416
1408
  for (const { file, visibility } of headerFiles) {
1417
1409
  const name = path.basename(file)
1418
- const published = framework && visibility !== 'Project'
1410
+ const published = visibility !== 'Project'
1419
1411
  if (!ownHeaders.has(name))
1420
1412
  ownHeaders.set(name, published ? `${product}/${name}` : file)
1421
- if (framework && !published && !ownHeaders.has(`${product}/${name}`))
1413
+ if (!published && !ownHeaders.has(`${product}/${name}`))
1422
1414
  ownHeaders.set(`${product}/${name}`, file)
1423
1415
  }
1416
+ const nonFrameworkHeaders = new Map<string, string>()
1417
+ for (const other of projectTargets(ref.project)) {
1418
+ if (FRAMEWORK_PRODUCTS.has(str(other.target.productType) ?? '')) continue
1419
+ const otherProduct = productName(other)
1420
+ for (const { file, visibility } of headerPhase(other)) {
1421
+ if (visibility === 'Project') continue
1422
+ const key = `${otherProduct}/${path.basename(file)}`
1423
+ if (!nonFrameworkHeaders.has(key)) nonFrameworkHeaders.set(key, file)
1424
+ }
1425
+ }
1424
1426
  const wrapper = path.join(settings('BUILT_PRODUCTS_DIR'), `${product}.framework`)
1425
1427
  const moduleMap =
1426
- settings('DEFINES_MODULE') === 'YES' && settings('MODULEMAP_FILE')
1428
+ (settings('DEFINES_MODULE') === 'YES' || !framework) && settings('MODULEMAP_FILE')
1427
1429
  ? absolute(settings('MODULEMAP_FILE'))
1428
1430
  : null
1431
+ const podHeaders =
1432
+ !framework &&
1433
+ isPodsProject(ref.project.xcodeproj) &&
1434
+ moduleMap &&
1435
+ path
1436
+ .relative(path.join(ref.project.projectDir, 'Headers', 'Public'), moduleMap)
1437
+ .split(path.sep)[0] !== '..' &&
1438
+ fs.existsSync(moduleMap)
1439
+ ? fs.readdirSync(path.dirname(moduleMap)).flatMap((entry) => {
1440
+ if (!/\.(h|hh|hpp|hxx|modulemap)$/.test(entry)) return []
1441
+ const file = path.join(path.dirname(moduleMap), entry)
1442
+ return fs.existsSync(file) ? [file] : []
1443
+ })
1444
+ : []
1429
1445
  const fileFlags: Record<string, string[]> = {}
1430
1446
  for (const phaseId of list(ref.target.buildPhases)) {
1431
1447
  const phase = ref.project.object(phaseId)
@@ -1466,9 +1482,12 @@ export function readXcodeAppTarget(
1466
1482
  ...(native
1467
1483
  ? {
1468
1484
  objc: {
1469
- publicHeaders: headerFiles.flatMap(({ file, visibility }) =>
1470
- visibility === 'Public' ? [file] : [],
1471
- ),
1485
+ publicHeaders: [
1486
+ ...headerFiles.flatMap(({ file, visibility }) =>
1487
+ visibility === 'Public' ? [file] : [],
1488
+ ),
1489
+ ...podHeaders.filter((file) => HEADER_FILE.test(file)),
1490
+ ],
1472
1491
  headers: [
1473
1492
  ...new Set([
1474
1493
  ...headers,
@@ -1538,6 +1557,7 @@ export function readXcodeAppTarget(
1538
1557
  ? []
1539
1558
  : [
1540
1559
  { flag: '-I', entries: [...ownHeaders] },
1560
+ { flag: '-I', entries: [...nonFrameworkHeaders] },
1541
1561
  {
1542
1562
  flag: '-iquote',
1543
1563
  entries: projectHeaderMap(ref.project),
@@ -1563,7 +1583,7 @@ export function readXcodeAppTarget(
1563
1583
  ? [[path.join(wrapper, 'Modules', 'module.modulemap'), moduleMap]]
1564
1584
  : []),
1565
1585
  ])
1566
- : {},
1586
+ : Object.fromEntries(podHeaders.map((file) => [file, file])),
1567
1587
  },
1568
1588
  }
1569
1589
  : {}),
@@ -1,107 +0,0 @@
1
- // auto-generate CLI flag definitions from the settings schema
2
-
3
- import {
4
- settingsSchema,
5
- isSettingKey,
6
- type SettingKey,
7
- type SettingsValues,
8
- } from './settingsContract.ts'
9
-
10
- export interface FlagDef {
11
- name: string // --flag-name
12
- short?: string // -f
13
- key: SettingKey
14
- type: 'string' | 'number' | 'boolean'
15
- description: string
16
- options?: readonly string[]
17
- default: any
18
- }
19
-
20
- // build flag definitions from schema — only settings with cliFlag defined
21
- const _flags: FlagDef[] = []
22
- for (const [key, def] of Object.entries(settingsSchema)) {
23
- if (!def.cliFlag || !isSettingKey(key)) continue
24
- _flags.push({
25
- name: `--${def.cliFlag}`,
26
- short: def.cliFlagShort ? `-${def.cliFlagShort}` : undefined,
27
- key,
28
- type: def.type === 'enum' ? 'string' : def.type,
29
- description: def.description,
30
- options: def.options,
31
- default: def.default,
32
- })
33
- }
34
-
35
- export const cliFlags: readonly FlagDef[] = _flags
36
-
37
- /** parse CLI args and extract settings overrides */
38
- export function parseSettingsFlags(args: string[]): {
39
- settings: Partial<SettingsValues>
40
- remaining: string[]
41
- } {
42
- const settings: Record<string, any> = {}
43
- const remaining: string[] = []
44
- let i = 0
45
-
46
- while (i < args.length) {
47
- const arg = args[i]
48
-
49
- // stop at -- separator
50
- if (arg === '--') {
51
- remaining.push(...args.slice(i))
52
- break
53
- }
54
-
55
- const flag = cliFlags.find((f) => f.name === arg || f.short === arg)
56
- if (flag) {
57
- if (flag.type === 'boolean') {
58
- settings[flag.key] = true
59
- i++
60
- } else {
61
- const val = args[i + 1]
62
- if (val === undefined) {
63
- remaining.push(arg)
64
- i++
65
- continue
66
- }
67
- if (flag.type === 'number') {
68
- const num = Number(val)
69
- if (Number.isNaN(num)) {
70
- remaining.push(arg, val)
71
- i += 2
72
- continue
73
- }
74
- settings[flag.key] = num
75
- } else {
76
- // validate enum values
77
- if (flag.options && !flag.options.includes(val)) {
78
- console.error(
79
- ` warning: invalid value "${val}" for ${arg} (expected: ${flag.options.join('|')})`,
80
- )
81
- i += 2
82
- continue
83
- }
84
- settings[flag.key] = val
85
- }
86
- i += 2
87
- }
88
- } else {
89
- remaining.push(arg)
90
- i++
91
- }
92
- }
93
-
94
- return { settings, remaining }
95
- }
96
-
97
- /** format flag list for --help output */
98
- export function formatFlagHelp(): string {
99
- const lines: string[] = []
100
- for (const flag of cliFlags) {
101
- const nameStr = flag.short ? `${flag.short}, ${flag.name}` : ` ${flag.name}`
102
- const optStr = flag.options ? ` [${flag.options.join('|')}]` : ''
103
- const defStr = flag.default !== undefined ? ` (default: ${flag.default})` : ''
104
- lines.push(` ${nameStr.padEnd(24)}${flag.description}${optStr}${defStr}`)
105
- }
106
- return lines.join('\n')
107
- }