peachsim 0.1.1635 → 0.1.1641

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 (142) hide show
  1. package/README.md +10 -1
  2. package/cli/app-config.ts +14 -5
  3. package/cli/app-stubs.ts +96 -22
  4. package/cli/bridge-flow-runner.ts +2 -2
  5. package/cli/cloud-client.ts +60 -40
  6. package/cli/cloud-session.ts +16 -0
  7. package/cli/commands/assert.ts +17 -4
  8. package/cli/commands/box.ts +33 -19
  9. package/cli/commands/doctor.ts +37 -20
  10. package/cli/commands/flow.ts +1 -1
  11. package/cli/commands/inspect/actions.ts +3 -2
  12. package/cli/commands/inspect/core.ts +0 -8
  13. package/cli/commands/inspect/shared.ts +9 -4
  14. package/cli/commands/inspect.ts +65 -61
  15. package/cli/commands/platform.ts +2 -1
  16. package/cli/commands/preview.ts +1 -1
  17. package/cli/commands/record.ts +154 -68
  18. package/cli/commands/swift.ts +18 -4
  19. package/cli/commands/three-mode.ts +4 -38
  20. package/cli/commands/upload.ts +55 -49
  21. package/cli/drivers/playwright-sim-host.ts +65 -42
  22. package/cli/flow-live-status.ts +0 -2
  23. package/cli/main.ts +2 -2
  24. package/cli/outbound-endpoints.ts +7 -5
  25. package/cli/pause-aware-timeout.ts +4 -0
  26. package/cli/ws-bridge.ts +19 -16
  27. package/detox/attempt-events.cjs +99 -6
  28. package/detox/attempt-events.d.cts +7 -0
  29. package/detox/expectations.ts +7 -3
  30. package/detox/index.ts +259 -139
  31. package/detox/jest-environment.cjs +5 -1
  32. package/detox/motion-change.cjs +170 -21
  33. package/detox/motion-change.d.cts +32 -0
  34. package/detox/navigation-lifecycle.ts +35 -3
  35. package/dist-lib/agent-daemon-client.cjs +1 -1
  36. package/dist-lib/agent-events.cjs +1 -1
  37. package/dist-lib/attached-projects.cjs +1 -1
  38. package/dist-lib/auth/shared-session.cjs +1 -1
  39. package/dist-lib/backend-origin.cjs +17 -7
  40. package/dist-lib/beta.cjs +1 -1
  41. package/dist-lib/beta.mjs +1 -1
  42. package/dist-lib/bridge-constants.cjs +1 -1
  43. package/dist-lib/bridge-contract-input.cjs +1 -1
  44. package/dist-lib/bridge-contract-input.mjs +1 -1
  45. package/dist-lib/bridge-contract.cjs +1 -1
  46. package/dist-lib/bridge-contract.mjs +1 -1
  47. package/dist-lib/bundle-channel.cjs +5014 -2268
  48. package/dist-lib/capture-contract.cjs +1 -1
  49. package/dist-lib/capture-contract.mjs +1 -1
  50. package/dist-lib/cloud-contract.cjs +1 -1
  51. package/dist-lib/cloud-contract.mjs +1 -1
  52. package/dist-lib/cloud-test-args.cjs +1 -1
  53. package/dist-lib/cloud-test-args.mjs +1 -1
  54. package/dist-lib/cloud.cjs +1 -1
  55. package/dist-lib/cloud.mjs +1 -1
  56. package/dist-lib/config.cjs +1 -1
  57. package/dist-lib/config.mjs +1 -1
  58. package/dist-lib/detox/index.cjs +1036 -166
  59. package/dist-lib/detox/jest-environment.cjs +5 -1
  60. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  61. package/dist-lib/expo-swift-bundle.cjs +4613 -1963
  62. package/dist-lib/expo-swift-metadata.cjs +9 -7
  63. package/dist-lib/expo-swift-metadata.mjs +9 -7
  64. package/dist-lib/home-paths.cjs +1 -1
  65. package/dist-lib/host/bridge-host.cjs +58072 -16400
  66. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  67. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  68. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  69. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  70. package/dist-lib/host/websocket-proxy.cjs +1 -1
  71. package/dist-lib/index.cjs +2790 -143
  72. package/dist-lib/jump-to-source-babel.cjs +1 -1
  73. package/dist-lib/jump-to-source-native.cjs +1 -1
  74. package/dist-lib/kotlin-host.cjs +1 -1
  75. package/dist-lib/menu.cjs +1 -1
  76. package/dist-lib/menu.mjs +1 -1
  77. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  78. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  79. package/dist-lib/metro-production-bundle.cjs +1 -1
  80. package/dist-lib/metro-production-bundle.mjs +1 -1
  81. package/dist-lib/metro.cjs +2579 -95
  82. package/dist-lib/native-app-identity-project.cjs +243 -53
  83. package/dist-lib/native-app-identity-project.mjs +243 -53
  84. package/dist-lib/native-app-identity.cjs +29 -30
  85. package/dist-lib/native-app-identity.mjs +29 -30
  86. package/dist-lib/native-firebase-metadata.cjs +1 -1
  87. package/dist-lib/native-firebase-metadata.mjs +1 -1
  88. package/dist-lib/plist.cjs +1 -1
  89. package/dist-lib/plist.mjs +1 -1
  90. package/dist-lib/profiles.cjs +1 -1
  91. package/dist-lib/public-brand.cjs +1 -1
  92. package/dist-lib/react-native-host-modules.cjs +2 -2
  93. package/dist-lib/react-native-host-modules.mjs +2 -2
  94. package/dist-lib/scripts/dev-server-scanner.cjs +8 -6
  95. package/dist-lib/sdk.cjs +4 -3
  96. package/dist-lib/sdk.mjs +4 -3
  97. package/dist-lib/skills.cjs +66475 -23097
  98. package/dist-lib/swift-compile.cjs +452 -260
  99. package/dist-lib/swift-compile.mjs +451 -252
  100. package/dist-lib/swift-package.cjs +1 -1
  101. package/dist-lib/swift-package.mjs +1 -1
  102. package/dist-lib/swift-submit.cjs +14 -7
  103. package/dist-lib/swift-submit.mjs +14 -7
  104. package/dist-lib/swift-toolchain.cjs +316 -41
  105. package/dist-lib/swift.cjs +1 -1
  106. package/dist-lib/vite-swift.cjs +8188 -5636
  107. package/dist-lib/vite.cjs +2857 -12
  108. package/dist-lib/worklet-executable.cjs +14 -2
  109. package/dist-lib/worklet-executable.mjs +14 -2
  110. package/package.json +1 -1
  111. package/src/backend-origin.ts +21 -6
  112. package/src/expo-swift-host.ts +5 -2
  113. package/src/expoKotlinContract.ts +4 -7
  114. package/src/expoSwiftContract.ts +4 -6
  115. package/src/host/staged-host-files.ts +9 -0
  116. package/src/native-app-identity-project.ts +1 -4
  117. package/src/native-app-identity.ts +1 -4
  118. package/src/nativeAppIconContract.ts +1 -4
  119. package/src/output-lock-stdio.ts +36 -0
  120. package/src/react-native-bridge-modules.ts +106 -78
  121. package/src/react-native-host-modules.ts +4 -1
  122. package/src/settings-bundle.ts +1 -4
  123. package/src/swift-compile.ts +224 -139
  124. package/src/swift-distribution.lock.json +23 -12
  125. package/src/swift-distribution.ts +103 -4
  126. package/src/swift-host.ts +95 -30
  127. package/src/swift-icu.ts +16 -10
  128. package/src/swift-objc-compile.ts +547 -0
  129. package/src/swift-objc-metadata.ts +204 -0
  130. package/src/swift-objc-sdk.ts +883 -19
  131. package/src/swift-objc-standin.ts +126 -14
  132. package/src/swift-package-manifest.ts +42 -1
  133. package/src/swift-packages.ts +35 -21
  134. package/src/swift-root-lock.ts +153 -0
  135. package/src/swift-standin-emit.ts +40 -7
  136. package/src/swift-standins.ts +404 -138
  137. package/src/swift-submit.ts +18 -7
  138. package/src/swift-toolchain.ts +378 -46
  139. package/src/swiftContract.ts +12 -0
  140. package/src/worker-system-chunks.ts +11 -12
  141. package/src/worklet-executable.ts +19 -1
  142. package/src/xcode-project.ts +280 -33
@@ -0,0 +1,204 @@
1
+ import { spawnSync } from 'node:child_process'
2
+ import { createHash } from 'node:crypto'
3
+ import fs from 'node:fs'
4
+ import path from 'node:path'
5
+ import { IOS_SDK_HEADERS } from './swift-objc-sdk'
6
+ import { IOS_SDK_ID, materializeObjcSdk } from './swift-objc-standin'
7
+ import { swiftEnvironment } from './swift-toolchain'
8
+ import type { SwiftObjCPeerClass } from './swiftContract'
9
+
10
+ export class ObjcPeerMetadataError extends Error {
11
+ constructor(
12
+ message: string,
13
+ readonly files: string[],
14
+ readonly reusable: boolean,
15
+ ) {
16
+ super(message)
17
+ }
18
+ }
19
+
20
+ export function validateObjcPeerClasses(
21
+ classes: readonly SwiftObjCPeerClass[],
22
+ ): Set<string> {
23
+ const names = new Set<string>()
24
+ for (const peer of classes) {
25
+ if (!/^[A-Za-z_]\w*$/.test(peer.name) || names.has(peer.name))
26
+ throw new Error(`invalid or duplicate Objective-C metadata class: ${peer.name}`)
27
+ names.add(peer.name)
28
+ const header = /^(\w+)\/([\w./-]+\.h)$/.exec(peer.header)
29
+ if (
30
+ !header ||
31
+ header[2]!.split('/').some((part) => part === '..' || part === '.') ||
32
+ !Object.hasOwn(
33
+ IOS_SDK_HEADERS,
34
+ `System/Library/Frameworks/${header[1]}.framework/Headers/${header[2]}`,
35
+ )
36
+ )
37
+ throw new Error(`Objective-C peer header is outside the shared SDK: ${peer.header}`)
38
+ }
39
+ if (names.size === 0) throw new Error('Objective-C metadata requires peer classes')
40
+ return names
41
+ }
42
+
43
+ /** emits class metadata and its startup registration; adapters own every method. */
44
+ export function compileObjcPeerMetadata(args: {
45
+ classes: readonly SwiftObjCPeerClass[]
46
+ work: string
47
+ headerCache: string
48
+ toolchainBin: string
49
+ sysroot: string
50
+ minimum: number
51
+ descriptor?: number
52
+ }): { object: string; registration: string; files: string[] } {
53
+ const names = validateObjcPeerClasses(args.classes)
54
+ const headers = materializeObjcSdk(args.headerCache)
55
+ const source = path.join(args.work, 'peer-metadata.m')
56
+ const object = path.join(args.work, 'peer-metadata.o')
57
+ const log = path.join(args.work, 'peer-metadata.log')
58
+ const receipt = path.join(args.work, 'peer-metadata.json')
59
+ const registration = path.join(args.work, 'peer-registration.swift')
60
+ fs.writeFileSync(
61
+ registration,
62
+ [
63
+ 'import PeachObjC',
64
+ ...[...new Set(args.classes.map((peer) => peer.header.split('/')[0]!))].map(
65
+ (module) => `import ${module}`,
66
+ ),
67
+ '@_cdecl("_peach_objc_register_peers")',
68
+ 'public func _peachRegisterObjcPeers() {',
69
+ ...[...args.classes]
70
+ .sort(
71
+ (left, right) =>
72
+ Number(right.name === 'NSObject') - Number(left.name === 'NSObject'),
73
+ )
74
+ .map(
75
+ (peer) =>
76
+ ` _objcRegisterPeerClass(\`${peer.name}\`.self, nativeName: "${peer.name}")`,
77
+ ),
78
+ '}',
79
+ '',
80
+ ].join('\n'),
81
+ )
82
+ fs.writeFileSync(
83
+ source,
84
+ [
85
+ ...[...new Set(args.classes.map((peer) => peer.header))].map(
86
+ (header) => `#import <${header}>`,
87
+ ),
88
+ ...args.classes.map((peer) => `@implementation ${peer.name}\n@end`),
89
+ 'extern void _peach_objc_register_peers(void);',
90
+ '__attribute__((constructor)) static void peach_register_objc_peers(void) {',
91
+ ' _peach_objc_register_peers();',
92
+ '}',
93
+ '',
94
+ ].join('\n'),
95
+ )
96
+ const command = [
97
+ '--target=wasm32-unknown-wasip1',
98
+ `--sysroot=${args.sysroot}`,
99
+ '-fwasm-exceptions',
100
+ '-fexceptions',
101
+ '-D_WASI_EMULATED_SIGNAL',
102
+ '-D_WASI_EMULATED_MMAN',
103
+ `-D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=${args.minimum}`,
104
+ `-D__IPHONE_OS_VERSION_MIN_REQUIRED=${args.minimum}`,
105
+ '-fobjc-runtime=gnustep-2.2',
106
+ '-fobjc-exceptions',
107
+ '-fobjc-arc',
108
+ '-fblocks',
109
+ // empty implementations must not synthesize framework getters or storage.
110
+ '-Xclang',
111
+ '-disable-objc-default-synthesize-properties',
112
+ '-Werror=objc-root-class',
113
+ '-F',
114
+ path.join(headers, 'System/Library/Frameworks'),
115
+ '-idirafter',
116
+ path.join(headers, 'usr/include'),
117
+ '-Os',
118
+ '-c',
119
+ source,
120
+ '-o',
121
+ object,
122
+ ]
123
+ const compiler = path.join(args.toolchainBin, 'clang')
124
+ const result = spawnSync(compiler, command, {
125
+ cwd: args.work,
126
+ env: swiftEnvironment(),
127
+ encoding: 'utf8',
128
+ stdio: [
129
+ 'ignore',
130
+ 'pipe',
131
+ 'pipe',
132
+ ...(args.descriptor === undefined ? [] : [args.descriptor]),
133
+ ],
134
+ timeout: 120_000,
135
+ maxBuffer: 16 * 1024 * 1024,
136
+ })
137
+ fs.writeFileSync(
138
+ log,
139
+ `${result.stdout ?? ''}${result.stderr ?? ''}${result.error?.message ?? ''}`,
140
+ )
141
+ const digest = (file: string) =>
142
+ createHash('sha256').update(fs.readFileSync(file)).digest('hex')
143
+ fs.writeFileSync(
144
+ receipt,
145
+ JSON.stringify(
146
+ {
147
+ classes: args.classes,
148
+ declarations: IOS_SDK_ID,
149
+ compiler: digest(compiler),
150
+ command,
151
+ source: digest(source),
152
+ status: result.status,
153
+ signal: result.signal,
154
+ error: result.error?.message,
155
+ ...(result.status === 0 && !result.error ? { object: digest(object) } : {}),
156
+ },
157
+ null,
158
+ 2,
159
+ ),
160
+ )
161
+ const files = [source, registration, log, receipt]
162
+ if (result.error || result.status !== 0)
163
+ throw new ObjcPeerMetadataError(
164
+ `Objective-C peer metadata compilation failed: ${log}`,
165
+ files,
166
+ !result.error && !result.signal && result.status !== null,
167
+ )
168
+ files.push(object)
169
+ const symbols = spawnSync(
170
+ path.join(args.toolchainBin, 'llvm-nm'),
171
+ ['--format=posix', object],
172
+ {
173
+ encoding: 'utf8',
174
+ env: swiftEnvironment(),
175
+ timeout: 120_000,
176
+ maxBuffer: 16 * 1024 * 1024,
177
+ },
178
+ )
179
+ fs.appendFileSync(
180
+ log,
181
+ `${symbols.stdout ?? ''}${symbols.stderr ?? ''}${symbols.error?.message ?? ''}`,
182
+ )
183
+ if (symbols.error || symbols.status !== 0)
184
+ throw new ObjcPeerMetadataError(
185
+ `could not inspect Objective-C peer metadata: ${log}`,
186
+ files,
187
+ !symbols.error && !symbols.signal && symbols.status !== null,
188
+ )
189
+ const emitted = [...symbols.stdout.matchAll(/^\._OBJC_CLASS_(\w+) [^U] /gm)].map(
190
+ (match) => match[1]!,
191
+ )
192
+ if (
193
+ emitted.length !== names.size ||
194
+ !emitted.every((name) => names.has(name)) ||
195
+ /^\._OBJC_CLASS_\w+ U(?: |$)/m.test(symbols.stdout) ||
196
+ /^_[ic]_\w+/m.test(symbols.stdout)
197
+ )
198
+ throw new ObjcPeerMetadataError(
199
+ `Objective-C peer metadata contains unexpected classes or methods: ${receipt}`,
200
+ files,
201
+ true,
202
+ )
203
+ return { object, registration, files }
204
+ }