peachsim 0.1.2609 → 0.1.2611

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 (149) hide show
  1. package/cli/commands/perf-native.ts +120 -6
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/attached-projects.cjs +1 -1
  5. package/dist-lib/auth/shared-session.cjs +1 -1
  6. package/dist-lib/backend-origin.cjs +1 -1
  7. package/dist-lib/beta.cjs +1 -1
  8. package/dist-lib/beta.mjs +2 -2
  9. package/dist-lib/bridge-constants.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.mjs +5 -5
  12. package/dist-lib/bridge-contract.cjs +1 -1
  13. package/dist-lib/bridge-contract.mjs +3 -3
  14. package/dist-lib/bundle-channel.cjs +60541 -60228
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +3 -3
  17. package/dist-lib/cloud-contract.cjs +1 -1
  18. package/dist-lib/cloud-contract.mjs +3 -3
  19. package/dist-lib/cloud-test-args.cjs +1 -1
  20. package/dist-lib/cloud-test-args.mjs +2 -2
  21. package/dist-lib/cloud.cjs +1 -1
  22. package/dist-lib/cloud.mjs +7 -7
  23. package/dist-lib/config.cjs +1 -1
  24. package/dist-lib/config.mjs +5 -5
  25. package/dist-lib/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/esm-chunks/{acorn-P6Q3SN6U.mjs → acorn-BKODFARF.mjs} +3 -3
  28. package/dist-lib/esm-chunks/{chunk-5V7JOQMI.mjs → chunk-3JA6XLP4.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-4HCHYS5S.mjs → chunk-45CENTIY.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-FIUWBFDV.mjs → chunk-4C3LKD3A.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-MF7HNQ5K.mjs → chunk-4CJMDUKF.mjs} +1490 -3950
  32. package/dist-lib/esm-chunks/{chunk-L4ATOCRX.mjs → chunk-52XQJZ6O.mjs} +3 -3
  33. package/dist-lib/esm-chunks/{chunk-DN4RY4ZO.mjs → chunk-7L5LUPZA.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-VHBBOWKT.mjs → chunk-A6GNAMLP.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-3MJN4KBR.mjs → chunk-C4BW35N7.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-UMKSCALR.mjs → chunk-CAFNSCPD.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-LSNKOL3L.mjs → chunk-CWLKT7TD.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-3LX34QVB.mjs → chunk-FWUDTM5Y.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-PKXGC5OZ.mjs → chunk-H2JPB73X.mjs} +1 -1
  40. package/dist-lib/esm-chunks/chunk-HWMD7II5.mjs +322 -0
  41. package/dist-lib/esm-chunks/{chunk-GJZ2ROIK.mjs → chunk-J6N5KKMZ.mjs} +14 -12
  42. package/dist-lib/esm-chunks/{chunk-7JYSTMRO.mjs → chunk-JWA5AIJM.mjs} +1 -1
  43. package/dist-lib/esm-chunks/chunk-KOT7HREP.mjs +2655 -0
  44. package/dist-lib/esm-chunks/{chunk-2UJG76LY.mjs → chunk-LDV2MZFL.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-62CUUMJF.mjs → chunk-LNZNCA7M.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-T554RY2B.mjs → chunk-NUISME6Y.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-IHK4FK5A.mjs → chunk-SFDNE5S2.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-CJLXAXGU.mjs → chunk-SKW2UNWS.mjs} +17 -328
  49. package/dist-lib/esm-chunks/{chunk-ZUBTL7EH.mjs → chunk-SNMPI3I2.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-D44BCQPZ.mjs → chunk-XSRZQWH5.mjs} +34 -28
  51. package/dist-lib/esm-chunks/{chunk-FOM5H3FB.mjs → chunk-YFSTB4CX.mjs} +4 -4
  52. package/dist-lib/esm-chunks/{metro-layout-parser-7VIYXTX3.mjs → metro-layout-parser-BMN3E2RD.mjs} +3 -3
  53. package/dist-lib/esm-chunks/{swift-package-prebuilt-GNRGNGKJ.mjs → swift-package-prebuilt-VMBB763C.mjs} +14 -11
  54. package/dist-lib/esm-chunks/{swift-sdk-app-module-QMYD4WKD.mjs → swift-sdk-app-module-SJ6OZAVA.mjs} +16 -14
  55. package/dist-lib/esm-chunks/{swift-sdk-image-LUAWELUR.mjs → swift-sdk-image-U53EKCZW.mjs} +16 -14
  56. package/dist-lib/esm-chunks/{swift-sdk-image-producer-A4Y2EYPV.mjs → swift-sdk-image-producer-TQQ33C3G.mjs} +8 -6
  57. package/dist-lib/expo-swift-bundle.cjs +42532 -42219
  58. package/dist-lib/expo-swift-metadata.cjs +1 -1
  59. package/dist-lib/expo-swift-metadata.mjs +7 -7
  60. package/dist-lib/home-paths.cjs +1 -1
  61. package/dist-lib/host/bridge-host.cjs +43727 -43251
  62. package/dist-lib/host/fetch-proxy-handler.cjs +670 -645
  63. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  64. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  65. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  66. package/dist-lib/host/websocket-proxy.cjs +1 -1
  67. package/dist-lib/index.cjs +1 -1
  68. package/dist-lib/kotlin-host.cjs +1 -1
  69. package/dist-lib/menu.cjs +1 -1
  70. package/dist-lib/menu.mjs +3 -3
  71. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  72. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  73. package/dist-lib/metro-production-bundle.cjs +1 -1
  74. package/dist-lib/metro-production-bundle.mjs +4 -4
  75. package/dist-lib/native-app-identity-project.cjs +1499 -2889
  76. package/dist-lib/native-app-identity-project.mjs +317 -339
  77. package/dist-lib/native-app-identity.cjs +1 -1
  78. package/dist-lib/native-app-identity.mjs +6 -6
  79. package/dist-lib/native-firebase-metadata.cjs +1 -1
  80. package/dist-lib/native-firebase-metadata.mjs +3 -3
  81. package/dist-lib/pdfium-raster.cjs +1 -1
  82. package/dist-lib/pdfium-raster.mjs +2 -2
  83. package/dist-lib/plist.cjs +1 -1
  84. package/dist-lib/plist.mjs +3 -3
  85. package/dist-lib/profiles.cjs +1 -1
  86. package/dist-lib/public-brand.cjs +1 -1
  87. package/dist-lib/public-origins-lib-esm.json +166 -154
  88. package/dist-lib/public-origins-lib.json +141 -198
  89. package/dist-lib/react-native-host-modules.cjs +1 -1
  90. package/dist-lib/react-native-host-modules.mjs +2 -2
  91. package/dist-lib/reap-browser.cjs +1 -1
  92. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  93. package/dist-lib/sdk.cjs +1 -1
  94. package/dist-lib/sdk.mjs +8 -8
  95. package/dist-lib/skills.cjs +38917 -38441
  96. package/dist-lib/swift-compile.cjs +12239 -12121
  97. package/dist-lib/swift-compile.mjs +36 -33
  98. package/dist-lib/swift-package.cjs +1 -1
  99. package/dist-lib/swift-package.mjs +3 -3
  100. package/dist-lib/swift-submit.cjs +1 -1
  101. package/dist-lib/swift-submit.mjs +6 -6
  102. package/dist-lib/swift-svg-raster.cjs +1 -1
  103. package/dist-lib/swift-svg-raster.mjs +2 -2
  104. package/dist-lib/swift-toolchain.cjs +1 -1
  105. package/dist-lib/swift.cjs +1 -1
  106. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  108. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  109. package/dist-lib/vendor/acorn.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/stream-json.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase.cjs +1 -1
  117. package/dist-lib/vendor/terser.cjs +1 -1
  118. package/dist-lib/vendor/valibot.cjs +1 -1
  119. package/dist-lib/vendor/ws.cjs +1 -1
  120. package/dist-lib/vendor/zod.cjs +1 -1
  121. package/dist-lib/worklet-executable.cjs +1 -1
  122. package/dist-lib/worklet-executable.mjs +3 -3
  123. package/package.json +1 -1
  124. package/src/binaryen.lock.json +3 -3
  125. package/src/genrule-archives.ts +5 -2
  126. package/src/gitignore.ts +8 -3
  127. package/src/kotlin-library-sources.ts +320 -0
  128. package/src/native-framework-compiler.ts +1 -1
  129. package/src/native-static-libraries.ts +2 -3
  130. package/src/native-swift-slices.ts +1 -1
  131. package/src/nitro-dependencies.ts +3 -7
  132. package/src/one-native-controls-package.ts +165 -11
  133. package/src/oneNativeControlsContract.ts +1 -0
  134. package/src/rive-runtime-dependencies.ts +1 -2
  135. package/src/swift-compile.ts +165 -1796
  136. package/src/swift-compiler-digest.ts +2 -0
  137. package/src/swift-distribution.ts +39 -15
  138. package/src/swift-objc-compile.ts +194 -32
  139. package/src/swift-package-manifest.ts +6 -29
  140. package/src/swift-packages.ts +6 -14
  141. package/src/swift-sdk-surface.ts +1811 -0
  142. package/src/swift-standin-digest.ts +28 -5
  143. package/src/swift-standins.ts +16 -19
  144. package/src/swift-wasm-archive.ts +200 -0
  145. package/src/swift-wasm-prune.ts +3 -93
  146. package/src/swift-wasm64-native-source.ts +4 -2
  147. package/src/swiftWasm64ConfigContract.ts +10 -0
  148. package/src/wasm-optimize.ts +18 -14
  149. package/src/xcode-project.ts +2 -4
@@ -0,0 +1,320 @@
1
+ import { spawn, type StdioOptions } from 'node:child_process'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import { isRecord } from './is-record'
5
+ import { kotlinToolCommand, runKotlinTool } from './kotlin-toolchain'
6
+ import type { KotlinToolchainInstallation } from './kotlinSdkContract'
7
+
8
+ function runCompiler(
9
+ file: string,
10
+ args: readonly string[],
11
+ options: { stdio: StdioOptions; env?: NodeJS.ProcessEnv },
12
+ operation: string,
13
+ ): Promise<void> {
14
+ return new Promise((resolve, reject) => {
15
+ const child = spawn(file, args, options)
16
+ child.once('error', reject)
17
+ child.once('close', (code, signal) => {
18
+ if (code === 0) resolve()
19
+ else reject(new Error(operation + ' stopped with ' + (code ?? signal)))
20
+ })
21
+ })
22
+ }
23
+
24
+ export type KotlinLibrarySource =
25
+ | { kind: 'files'; java: readonly string[]; kotlin: readonly string[] }
26
+ | { kind: 'resources'; archive: string }
27
+
28
+ function kotlinFragmentFlags(
29
+ filename: string,
30
+ kotlinSources: readonly string[],
31
+ translatedSources: readonly string[],
32
+ ): string[] {
33
+ const input: unknown = JSON.parse(fs.readFileSync(filename, 'utf8'))
34
+ if (!Array.isArray(input) || !input.length)
35
+ throw new Error('Kotlin fragments must be a nonempty array')
36
+ const fragments = input.map(
37
+ (
38
+ fragment: unknown,
39
+ ): {
40
+ name: string
41
+ sources: string[]
42
+ refines: string[]
43
+ java: boolean
44
+ } => {
45
+ if (
46
+ !isRecord(fragment) ||
47
+ typeof fragment.name !== 'string' ||
48
+ !/^[a-zA-Z][a-zA-Z0-9_]*$/.test(fragment.name) ||
49
+ !Array.isArray(fragment.sources) ||
50
+ !fragment.sources.every((source: unknown) => typeof source === 'string') ||
51
+ !Array.isArray(fragment.refines) ||
52
+ !fragment.refines.every((parent: unknown) => typeof parent === 'string') ||
53
+ (fragment.java !== undefined && typeof fragment.java !== 'boolean')
54
+ )
55
+ throw new Error(
56
+ 'Each Kotlin fragment needs a name, source paths and refined fragments',
57
+ )
58
+ return {
59
+ name: fragment.name,
60
+ sources: fragment.sources.map((source: string) => path.resolve(source)),
61
+ refines: fragment.refines,
62
+ java: fragment.java === true,
63
+ }
64
+ },
65
+ )
66
+ const names = new Set(fragments.map(({ name }) => name))
67
+ const refined = new Set(fragments.flatMap(({ refines }) => refines))
68
+ const [platform, ...otherPlatforms] = [...names].filter((name) => !refined.has(name))
69
+ const javaFragments = fragments.filter(({ java }) => java)
70
+ if (
71
+ names.size !== fragments.length ||
72
+ [...refined].some((name) => !names.has(name)) ||
73
+ !platform ||
74
+ otherPlatforms.length ||
75
+ javaFragments.length > 1
76
+ )
77
+ throw new Error(
78
+ 'Kotlin fragments need unique names, known parents, one platform fragment and at most one Java source fragment',
79
+ )
80
+ const sources = fragments.flatMap(({ sources }) => sources)
81
+ const selected = new Set(kotlinSources)
82
+ if (
83
+ sources.length !== selected.size ||
84
+ new Set(sources).size !== sources.length ||
85
+ sources.some((source) => !selected.has(source)) ||
86
+ [...sources, ...translatedSources].some((source) => source.includes(','))
87
+ )
88
+ throw new Error('Each Kotlin library source must belong to exactly one fragment')
89
+ const mappings = fragments.flatMap(({ name, sources }) =>
90
+ sources.map((source) => `${name}:${source}`),
91
+ )
92
+ const javaFragment = javaFragments[0]?.name ?? platform
93
+ mappings.push(...translatedSources.map((source) => `${javaFragment}:${source}`))
94
+ const edges = fragments.flatMap(({ name, refines }) =>
95
+ refines.map((parent) => `${name}:${parent}`),
96
+ )
97
+ return [
98
+ '-Xmulti-platform',
99
+ `-Xfragments=${[...names].join(',')}`,
100
+ ...(edges.length ? [`-Xfragment-refines=${edges.join(',')}`] : []),
101
+ `-Xfragment-sources=${mappings.join(',')}`,
102
+ ]
103
+ }
104
+
105
+ export async function compileKotlinLibrarySources(input: {
106
+ ready: KotlinToolchainInstallation
107
+ sdkRoot: string
108
+ libraries: readonly string[]
109
+ source: KotlinLibrarySource
110
+ javaClasspath: readonly string[]
111
+ kotlinJvmAbi?: string
112
+ dependencyJvmAbi?: string
113
+ release: string
114
+ processorPath?: string
115
+ kotlinLanguage?: string
116
+ kotlinOptIns?: readonly string[]
117
+ commonSources?: readonly string[]
118
+ kotlinFragments?: string
119
+ dependencies: readonly string[]
120
+ output: string
121
+ }): Promise<void> {
122
+ const output = path.resolve(input.output)
123
+ const name = path.basename(output, '.klib')
124
+ if (
125
+ !name ||
126
+ !output.endsWith('.klib') ||
127
+ (input.source.kind === 'files' &&
128
+ !input.source.java.length &&
129
+ !input.source.kotlin.length)
130
+ )
131
+ throw new Error('Android library compilation requires sources and a KLIB output')
132
+ const { ready, sdkRoot, libraries } = input
133
+ const parent = path.dirname(output)
134
+ fs.mkdirSync(parent, { recursive: true })
135
+ const work = fs.mkdtempSync(path.join(parent, '.android-library-'))
136
+ try {
137
+ const compileLibraries = [...libraries, ...input.dependencies]
138
+ let javaSources: readonly string[]
139
+ if (input.source.kind === 'resources') {
140
+ const generated = path.join(work, 'resources')
141
+ await runKotlinTool(
142
+ ready,
143
+ sdkRoot,
144
+ 'dev.peach.tools.platform.AndroidResourceClassesKt',
145
+ [path.resolve(input.source.archive), generated],
146
+ )
147
+ javaSources = fs
148
+ .readdirSync(generated, { recursive: true, encoding: 'utf8' })
149
+ .filter((file) => file.endsWith('.java'))
150
+ .sort()
151
+ .map((file) => path.join(generated, file))
152
+ } else {
153
+ javaSources = input.source.java
154
+ }
155
+ const kotlinSources =
156
+ input.source.kind === 'files'
157
+ ? input.source.kotlin.map((file) => path.resolve(file))
158
+ : []
159
+ const commonSources = (input.commonSources ?? []).map((file) => path.resolve(file))
160
+ if (commonSources.length && input.kotlinFragments)
161
+ throw new Error('Choose common sources or a Kotlin fragment graph')
162
+ if (commonSources.some((file) => file.includes(',') || !kotlinSources.includes(file)))
163
+ throw new Error('Common Kotlin sources must be included in the library source list')
164
+ const kotlinJvmAbi = input.kotlinJvmAbi && path.resolve(input.kotlinJvmAbi)
165
+ if (
166
+ kotlinJvmAbi &&
167
+ (!javaSources.length ||
168
+ !kotlinSources.length ||
169
+ !kotlinJvmAbi.endsWith('.jar') ||
170
+ !input.javaClasspath.some((file) => path.resolve(file) === kotlinJvmAbi))
171
+ )
172
+ throw new Error(
173
+ 'The Kotlin JVM ABI must be a JAR on the mixed library’s Java classpath',
174
+ )
175
+ const dependencyAbiFlags: string[] = []
176
+ if (input.dependencyJvmAbi) {
177
+ const dependencyPaths = new Set(
178
+ input.dependencies.map((file) => path.resolve(file)),
179
+ )
180
+ const classpathPaths = new Set(
181
+ input.javaClasspath.map((file) => path.resolve(file)),
182
+ )
183
+ const value: unknown = JSON.parse(fs.readFileSync(input.dependencyJvmAbi, 'utf8'))
184
+ if (!Array.isArray(value) || !value.length || !javaSources.length)
185
+ throw new Error(
186
+ 'Dependency JVM ABIs require Java sources and a nonempty array of KLIB/JAR pairs',
187
+ )
188
+ for (const pair of value) {
189
+ if (
190
+ !isRecord(pair) ||
191
+ typeof pair.klib !== 'string' ||
192
+ typeof pair.jar !== 'string'
193
+ )
194
+ throw new Error('Each dependency JVM ABI requires a klib and a jar path')
195
+ const klib = path.resolve(pair.klib)
196
+ const jar = path.resolve(pair.jar)
197
+ if (
198
+ !klib.endsWith('.klib') ||
199
+ !dependencyPaths.has(klib) ||
200
+ !jar.endsWith('.jar') ||
201
+ !classpathPaths.has(jar) ||
202
+ jar === kotlinJvmAbi
203
+ )
204
+ throw new Error(
205
+ 'Dependency JVM ABI pairs must refer to a dependency KLIB and its Java classpath JAR',
206
+ )
207
+ dependencyAbiFlags.push('--dependency-jvm-abi', klib, jar)
208
+ }
209
+ }
210
+ let translatedSources: string[] = []
211
+ if (javaSources.length) {
212
+ const platform = path.join(work, 'platform.txt')
213
+ const members = kotlinToolCommand(
214
+ ready,
215
+ sdkRoot,
216
+ 'dev.peach.tools.platform.KlibClassesKt',
217
+ [
218
+ ...compileLibraries.map((file) => path.resolve(file)),
219
+ ...(kotlinJvmAbi ? ['--same-library-jvm-abi', kotlinJvmAbi] : []),
220
+ ...dependencyAbiFlags,
221
+ ],
222
+ )
223
+ const fd = fs.openSync(platform, 'w')
224
+ try {
225
+ await runCompiler(
226
+ members.file,
227
+ members.args,
228
+ { stdio: ['ignore', fd, 'inherit'] },
229
+ 'Android library ' + name + ' metadata read',
230
+ )
231
+ } finally {
232
+ fs.closeSync(fd)
233
+ }
234
+ const sourceList = path.join(work, 'sources.txt')
235
+ fs.writeFileSync(
236
+ sourceList,
237
+ javaSources.map((file) => path.resolve(file)).join('\n'),
238
+ )
239
+ const translated = path.join(work, 'translated')
240
+ const diagnostics = await runKotlinTool(
241
+ ready,
242
+ sdkRoot,
243
+ 'dev.peach.tools.java.JavaTranslatorKt',
244
+ [
245
+ '--target',
246
+ 'wasm',
247
+ '--release',
248
+ input.release,
249
+ '--classpath',
250
+ input.javaClasspath.map((file) => path.resolve(file)).join(path.delimiter),
251
+ '--platform',
252
+ platform,
253
+ ...(input.processorPath ? ['--processorpath', input.processorPath] : []),
254
+ '--out',
255
+ translated,
256
+ `@${sourceList}`,
257
+ ],
258
+ )
259
+ if (/^refuses /m.test(diagnostics))
260
+ throw new Error(
261
+ `Android library ${name} requires unsupported platform members:\n${diagnostics.trimEnd()}`,
262
+ )
263
+ translatedSources = input.kotlinFragments
264
+ ? fs
265
+ .readdirSync(translated, { recursive: true, encoding: 'utf8' })
266
+ .filter((file) => file.endsWith('.kt'))
267
+ .sort()
268
+ .map((file) => path.join(translated, file))
269
+ : [translated]
270
+ }
271
+ const multiplatform = input.kotlinFragments
272
+ ? kotlinFragmentFlags(input.kotlinFragments, kotlinSources, translatedSources)
273
+ : commonSources.length
274
+ ? ['-Xmulti-platform', `-Xcommon-sources=${commonSources.join(',')}`]
275
+ : []
276
+ const language = input.kotlinLanguage ?? '2.1'
277
+ const raw = path.join(work, 'raw')
278
+ await runCompiler(
279
+ ready.kotlinc,
280
+ [
281
+ '-J-Xmx4g',
282
+ '-Xwasm-target=js',
283
+ '-nowarn',
284
+ `-Xplugin=${path.join(sdkRoot, 'plugin.jar')}`,
285
+ '-P',
286
+ 'plugin:dev.peach.jni:android=true',
287
+ '-language-version',
288
+ language,
289
+ '-api-version',
290
+ language,
291
+ ...(input.kotlinOptIns ?? []).map((marker) => `-opt-in=${marker}`),
292
+ ...multiplatform,
293
+ '-libraries',
294
+ compileLibraries.join(path.delimiter),
295
+ '-ir-output-dir',
296
+ raw,
297
+ '-ir-output-name',
298
+ name,
299
+ ...kotlinSources,
300
+ ...translatedSources,
301
+ ],
302
+ { stdio: 'inherit', env: { ...process.env, JAVA_HOME: ready.javaHome } },
303
+ 'Android library ' + name + ' compilation',
304
+ )
305
+ const compiled = path.join(raw, `${name}.klib`)
306
+ if (!javaSources.length) {
307
+ fs.renameSync(compiled, output)
308
+ return
309
+ }
310
+ const normalized = path.join(work, 'normalized.klib')
311
+ await runKotlinTool(ready, sdkRoot, 'dev.peach.tools.platform.JavaPlatformTypesKt', [
312
+ compiled,
313
+ normalized,
314
+ '--java-classes',
315
+ ])
316
+ fs.renameSync(normalized, output)
317
+ } finally {
318
+ fs.rmSync(work, { recursive: true, force: true })
319
+ }
320
+ }
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto'
2
2
  import fs from 'node:fs'
3
3
  import path from 'node:path'
4
4
  import * as v from 'valibot'
5
- import { swiftDistributionAt, swiftSdkPaths } from './swift-compile'
5
+ import { swiftDistributionAt, swiftSdkPaths } from './swift-sdk-surface'
6
6
  import {
7
7
  SWIFT_FRAMEWORK_PRODUCT_FILE,
8
8
  SWIFT_SDK_PRODUCT_FILE,
@@ -6,10 +6,9 @@ import fs from 'node:fs'
6
6
  import path from 'node:path'
7
7
  import { cacheDir as peachCacheDir } from './home-paths'
8
8
  import { fetchNativeEntry, nativeEntryCache, nativeEntryKey } from './native-prebuilt'
9
- import { swiftDistributionAt } from './swift-compile'
10
- import { swiftModuleToolchain } from './swift-distribution'
9
+ import { swiftDistributionAt, swiftModuleToolchain } from './swift-sdk-surface'
11
10
  import { privateSwiftDistributionRoot, sourceSwiftCheckout } from './swift-toolchain'
12
- import { localizeDefinedWasmSymbols, readArMembers } from './swift-wasm-prune'
11
+ import { localizeDefinedWasmSymbols, readArMembers } from './swift-wasm-archive'
13
12
  import { simulatorNativeLibrary } from './swift-xcframework'
14
13
 
15
14
  // nonmodular frameworks expose C++ declarations through header search paths.
@@ -13,7 +13,7 @@ import {
13
13
  swiftDistributionAt,
14
14
  swiftInterfaceDeclarations,
15
15
  withoutSwiftDeclarations,
16
- } from './swift-compile'
16
+ } from './swift-sdk-surface'
17
17
  import {
18
18
  privateSwiftDistributionRoot,
19
19
  sourceSwiftCheckout,
@@ -8,6 +8,7 @@ import { isRecord } from './is-record'
8
8
  import { fetchVerified } from './kotlin-toolchain'
9
9
  import { readPackageFile } from './swift-source-file'
10
10
  import { MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
11
+ import { DOUBLE_CONVERSION_WASM64_BACKPORT as DOUBLE_CONVERSION_BACKPORT } from './swiftWasm64ConfigContract'
11
12
  import type { Download } from './kotlinSdkContract'
12
13
 
13
14
  const run = promisify(execFile)
@@ -42,13 +43,8 @@ export interface NativeBackport {
42
43
 
43
44
  // the approved wasm target-recognition backport follows the SDK to wasm64
44
45
  // (specs/peach/engine/unistyles-native-boundary.md).
45
- export const DOUBLE_CONVERSION_WASM64_BACKPORT: NativeBackport = {
46
- upstreamCommit: '8857767d5b2f5a035321e3712e8cd0008840ba6b',
47
- originalSha256: 'b495b11f7b61693486894f747add5b454894b8b3ca41aa1610d370ba16407ab7',
48
- derivedSha256: 'd8e40c283479c1d8682646a65a869ed42c68b6dc3fb27e502aed5291d7dd223c',
49
- before: ' defined(__AARCH64EL__)\n',
50
- after: ' defined(__AARCH64EL__) || defined(__wasm64__)\n',
51
- }
46
+ export const DOUBLE_CONVERSION_WASM64_BACKPORT: NativeBackport =
47
+ DOUBLE_CONVERSION_BACKPORT
52
48
 
53
49
  export interface NitroDependencyHeader {
54
50
  /** the header's path under the dependency, as the archive holds it. */
@@ -8,6 +8,7 @@ import { fileURLToPath } from 'node:url'
8
8
  import { swiftGuestControls } from '../../peach-globals/build/one-swift-control-source'
9
9
  import { oneSDKHost, oneSDKModule, oneSDKTransport } from './one-sdk/source'
10
10
  import {
11
+ ONE_NATIVE_CONTROLS_CONTAINER_VIEWS,
11
12
  ONE_NATIVE_CONTROLS_CONTRACT,
12
13
  ONE_NATIVE_CONTROLS_TAB_VIEW,
13
14
  ONE_NATIVE_CONTROLS_NAVIGATION_SPLIT_VIEW,
@@ -209,6 +210,35 @@ private final class DeferredControl {
209
210
  }
210
211
  }
211
212
 
213
+ private final class ControlSyncState {
214
+ private static let states = NSMapTable<NSNumber, ControlSyncState>.strongToWeakObjects()
215
+ let id: Int32
216
+ private var revision: Int
217
+
218
+ private init(value: NSObject, revision: Int) {
219
+ self.id = OneNativeSyncRegistry.create(value)
220
+ self.revision = revision
221
+ }
222
+
223
+ deinit { OneNativeSyncRegistry.destroy(id) }
224
+
225
+ static func receive(_ hostID: Int, value: NSObject, revision: Int) -> ControlSyncState {
226
+ let key = NSNumber(value: hostID)
227
+ if let state = states.object(forKey: key) {
228
+ if revision > state.revision {
229
+ state.revision = revision
230
+ if OneNativeSyncRegistry.get(state.id)?.isEqual(value) != true {
231
+ OneNativeSyncRegistry.set(state.id, value: value)
232
+ }
233
+ }
234
+ return state
235
+ }
236
+ let state = ControlSyncState(value: value, revision: revision)
237
+ states.setObject(state, forKey: key)
238
+ return state
239
+ }
240
+ }
241
+
212
242
  private class ControlComposition {
213
243
  private static let reconciledContainers: Set<String> = [
214
244
  "OneNativeLazyVStack", "OneNativeLazyHStack", "OneNativeLazyVGrid", "OneNativeLazyHGrid",
@@ -219,13 +249,17 @@ private class ControlComposition {
219
249
  var specs: [String: Spec] = [:]
220
250
  var children: [String: [UIView]] = [:]
221
251
  var slots: [String: UIView] = [:]
252
+ var syncStates: [String: ControlSyncState] = [:]
253
+ var scrollRequestSequences: [String: Int] = [:]
222
254
  var emit: ((String, String) -> Void)?
223
255
  private var leafMeasure: UIHostingController<AnyView>?
224
256
  private var measuredRoot: NSDictionary?
225
257
  private var intrinsicWidth: CGFloat?
226
258
 
227
- func send(_ id: String, _ event: String, _ fields: Spec) {
228
- let payload = try! JSONSerialization.data(withJSONObject: [id, event, fields])
259
+ func send(_ id: String, _ event: String, _ fields: Spec, syncStateID: Int? = nil) {
260
+ var args: [Any] = [id, event, fields]
261
+ if let syncStateID { args.append(syncStateID) }
262
+ let payload = try! JSONSerialization.data(withJSONObject: args)
229
263
  emit?("dispatch", String(decoding: payload, as: UTF8.self))
230
264
  }
231
265
 
@@ -313,12 +347,54 @@ private class ControlComposition {
313
347
  view = slot
314
348
  default:
315
349
  guard let mount = guestControls[control] else { preconditionFailure("unsupported One control \\(control)") }
316
- view = mount(views[id], spec, specs[id], style) { [weak self] event, fields in self?.send(id, event, fields) }
317
- specs[id] = spec
350
+ let previous = specs[id]
351
+ if let existing = views[id], let previous, (previous as NSDictionary).isEqual(to: spec) {
352
+ view = existing
353
+ } else {
354
+ var guestSpec = spec
355
+ var syncStateID: Int?
356
+ if let hostID = spec["syncStateId"] as? Int, hostID != 0,
357
+ let snapshot = spec["syncState"] as? Spec,
358
+ let value = snapshot["value"] as? NSObject,
359
+ let revision = snapshot["revision"] as? Int {
360
+ let state = ControlSyncState.receive(hostID, value: value, revision: revision)
361
+ syncStates[id] = state
362
+ guestSpec["syncStateId"] = Int(state.id)
363
+ guestSpec["value"] = OneNativeSyncRegistry.get(state.id)
364
+ syncStateID = hostID
365
+ } else {
366
+ syncStates.removeValue(forKey: id)
367
+ guestSpec.removeValue(forKey: "syncStateId")
368
+ }
369
+ view = mount(views[id], guestSpec, previous, style) { [weak self] event, fields, sync in
370
+ self?.send(id, event, fields, syncStateID: sync ? syncStateID : nil)
371
+ }
372
+ specs[id] = spec
373
+ }
318
374
  }
319
375
  views[id] = view
376
+ if let host = node["contentHost"] as? String {
377
+ let slot = slots[id] ?? UIView(frame: .zero)
378
+ slot._peachReactContentHost = host
379
+ let layout: (CGRect) -> Void = { [weak self] frame in
380
+ self?.send(id, "onNativeLayout", ["x": frame.minX, "y": frame.minY, "width": frame.width, "height": frame.height])
381
+ }
382
+ if let sheet = view as? OneNativeSheetView {
383
+ if slots[id] == nil { sheet.mountContent(slot, onLayout: layout) }
384
+ sheet.setMeasuredHeight(spec["measuredHeight"] as? CGFloat ?? 0)
385
+ }
386
+ if let popover = view as? OneNativePopoverView {
387
+ if slots[id] == nil { popover.mountContent(slot, onLayout: layout) }
388
+ let measured = spec["contentSize"] as? Spec
389
+ popover.setMeasuredSize(CGSize(
390
+ width: measured?["width"] as? CGFloat ?? 0,
391
+ height: measured?["height"] as? CGFloat ?? 0
392
+ ))
393
+ }
394
+ slots[id] = slot
395
+ }
320
396
  if let container = view as? OneNativeContainerView {
321
- container.configureSwiftStyle(style)
397
+ if !(container is OneNativePopoverView) { container.configureSwiftStyle(style) }
322
398
  container.onSwiftStyleEvent = visit
323
399
  let nodes = node["children"] as? [Spec] ?? []
324
400
  if Self.reconciledContainers.contains(control) {
@@ -344,6 +420,22 @@ private class ControlComposition {
344
420
  } else if let container = view as? OneGuestIncrementalContainer {
345
421
  placeIncrementally(node, id: id, visited: &visited, remove: container.removeChild, insert: container.insertChild)
346
422
  }
423
+ if let reader = view as? OneNativeScrollViewReaderView,
424
+ let requests = spec["scrollRequests"] as? [Spec], !requests.isEmpty {
425
+ let previous = scrollRequestSequences[id] ?? 0
426
+ var latest = previous
427
+ for request in requests {
428
+ let sequence = request["sequence"] as! Int
429
+ if sequence <= latest { continue }
430
+ reader.scrollTo(request["id"] as! String, hasAnchor: request["hasAnchor"] as! Bool,
431
+ anchorX: request["x"] as! Double, anchorY: request["y"] as! Double)
432
+ latest = sequence
433
+ }
434
+ if latest != previous {
435
+ scrollRequestSequences[id] = latest
436
+ send(id, "scrollRequestsConsumed", ["sequence": latest])
437
+ }
438
+ }
347
439
  return view
348
440
  }
349
441
 
@@ -377,26 +469,42 @@ private class ControlComposition {
377
469
  for (id, view) in views where !visited.contains(id) {
378
470
  if let container = view as? OneNativeContainerView { container.reset() }
379
471
  if let container = view as? OneGuestIncrementalContainer { container.reset() }
472
+ if let sheet = view as? OneNativeSheetView {
473
+ if let slot = slots[id] { sheet.unmountContent(slot) }
474
+ sheet.reset()
475
+ }
476
+ if let alert = view as? OneNativeAlertView { alert.reset() }
380
477
  views.removeValue(forKey: id)
381
478
  specs.removeValue(forKey: id)
382
479
  children.removeValue(forKey: id)
383
480
  slots.removeValue(forKey: id)
481
+ syncStates.removeValue(forKey: id)
482
+ scrollRequestSequences.removeValue(forKey: id)
384
483
  }
385
484
  }
386
485
  }
387
486
 
388
487
  private struct ControlBridge: UIViewRepresentable {
389
488
  let root: Spec
489
+ let source: String
390
490
  let emit: (String, String) -> Void
391
491
  let measureWidth: Bool
392
492
 
393
- func makeCoordinator() -> ControlComposition { ControlComposition() }
493
+ final class Coordinator: ControlComposition {
494
+ var source: String?
495
+ }
496
+
497
+ func makeCoordinator() -> Coordinator { Coordinator() }
394
498
 
395
499
  func makeUIView(context: Context) -> UIView { UIView(frame: .zero) }
396
500
 
501
+ // the composition is a function of the props alone; a render of the root
502
+ // for state below it reconfigures nothing
397
503
  func updateUIView(_ host: UIView, context: Context) {
398
504
  let state = context.coordinator
399
505
  state.emit = emit
506
+ guard state.source != source else { return }
507
+ state.source = source
400
508
  var visited = Set<String>()
401
509
  let control = state.render(root, visited: &visited)
402
510
  if measureWidth { state.measureLeafWidth(control, root: root) }
@@ -409,7 +517,7 @@ private struct ControlBridge: UIViewRepresentable {
409
517
  state.prune(keeping: visited)
410
518
  }
411
519
 
412
- static func dismantleUIView(_ host: UIView, coordinator: ControlComposition) {
520
+ static func dismantleUIView(_ host: UIView, coordinator: Coordinator) {
413
521
  host.subviews.forEach { $0.removeFromSuperview() }
414
522
  coordinator.prune(keeping: [])
415
523
  coordinator.emit = nil
@@ -785,6 +893,23 @@ private func frameFields(_ frame: CGRect) -> Spec {
785
893
  ["x": frame.minX, "y": frame.minY, "width": frame.width, "height": frame.height]
786
894
  }
787
895
 
896
+ // every render of a root rebuilds its typed view from the props text it
897
+ // mounted, so each distinct text parses once while the cache stays in budget
898
+ @MainActor private var parsedProps: [String: Spec] = [:]
899
+ @MainActor private var parsedPropsBytes = 0
900
+
901
+ @MainActor private func controlProps(_ text: String) -> Spec {
902
+ if let spec = parsedProps[text] { return spec }
903
+ if parsedPropsBytes + text.utf8.count > 16 << 20 {
904
+ parsedProps.removeAll()
905
+ parsedPropsBytes = 0
906
+ }
907
+ let spec = try! JSONSerialization.jsonObject(with: Data(text.utf8)) as! Spec
908
+ parsedProps[text] = spec
909
+ parsedPropsBytes += text.utf8.count
910
+ return spec
911
+ }
912
+
788
913
  @_expose(wasm, "peach_register_views")
789
914
  @_cdecl("peach_register_views")
790
915
  @MainActor public func peach_register_views() {
@@ -793,7 +918,7 @@ private func frameFields(_ frame: CGRect) -> Spec {
793
918
  contract == "${ONE_NATIVE_CONTROLS_CONTRACT}",
794
919
  "unexpected compiled One control request \\(view) / \\(contract)"
795
920
  )
796
- let spec = try! JSONSerialization.jsonObject(with: Data(props.utf8)) as! Spec
921
+ let spec = controlProps(props)
797
922
  switch view {
798
923
  case "${ONE_NATIVE_CONTROLS_NAVIGATION_STACK_VIEW}":
799
924
  return AnyView(NavigationStackBridge(spec: spec, emit: emit)
@@ -809,7 +934,7 @@ private func frameFields(_ frame: CGRect) -> Spec {
809
934
  default:
810
935
  let root = spec["root"] as! Spec
811
936
  precondition((root["spec"] as? Spec)?["control"] as? String == view)
812
- let bridge = ControlBridge(root: root, emit: emit, measureWidth: spec["measureWidth"] as? Bool == true)
937
+ let bridge = ControlBridge(root: root, source: props, emit: emit, measureWidth: spec["measureWidth"] as? Bool == true)
813
938
  .frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity)
814
939
  let height = (spec["height"] as? Double).map { CGFloat($0) }
815
940
  return AnyView(bridge.frame(height: height))
@@ -1013,10 +1138,39 @@ export async function oneNativeControlsPackage(
1013
1138
  'OneNativeText',
1014
1139
  'OneNativeImage',
1015
1140
  ...ONE_NATIVE_CONTROLS_VISUAL_VIEWS,
1016
- 'OneNativeHStack',
1141
+ 'OneNativeChart',
1017
1142
  'OneNativeProgressView',
1143
+ 'OneNativeGauge',
1144
+ 'OneNativeCanvas',
1145
+ ...ONE_NATIVE_CONTROLS_CONTAINER_VIEWS,
1146
+ 'OneNativeSection',
1147
+ 'OneNativeLabeledContent',
1148
+ 'OneNativeDisclosureGroup',
1149
+ 'OneNativePicker',
1150
+ 'OneNativeToggle',
1151
+ 'OneNativeTextField',
1152
+ 'OneNativeSecureField',
1153
+ 'OneNativeTextEditor',
1154
+ 'OneNativeSlider',
1155
+ 'OneNativeStepper',
1156
+ 'OneNativeDatePicker',
1157
+ 'OneNativeColorPicker',
1158
+ 'OneNativeMultiDatePicker',
1159
+ 'OneNativeSwipeActions',
1160
+ 'OneNativeSwipeActionsActions',
1161
+ 'OneNativeOverlay',
1162
+ 'OneNativeOverlayContent',
1018
1163
  'OneNativeSpacer',
1019
- 'OneNativeVStack',
1164
+ 'OneNativeRectangle',
1165
+ 'OneNativeRoundedRectangle',
1166
+ 'OneNativeCapsule',
1167
+ 'OneNativeEmptyView',
1168
+ 'OneNativeLazyVGrid',
1169
+ 'OneNativeLazyHGrid',
1170
+ 'OneNativeContentUnavailableView',
1171
+ 'OneNativeSheet',
1172
+ 'OneNativePopover',
1173
+ 'OneNativeAlert',
1020
1174
  ],
1021
1175
  linkedGroups,
1022
1176
  )
@@ -1,4 +1,5 @@
1
1
  export {
2
+ ONE_NATIVE_CONTROLS_CONTAINER_VIEWS,
2
3
  ONE_NATIVE_CONTROLS_CONTRACT,
3
4
  ONE_NATIVE_CONTROLS_NAVIGATION_SPLIT_VIEW,
4
5
  ONE_NATIVE_CONTROLS_NAVIGATION_STACK_VIEW,
@@ -6,10 +6,9 @@ import path from 'node:path'
6
6
  import { setTimeout as sleep } from 'node:timers/promises'
7
7
  import { cacheDir } from './home-paths'
8
8
  import { tryAcquireNumberedLock } from './numbered-lock'
9
- import { swiftSdkPaths } from './swift-compile'
10
- import { swiftModuleToolchain } from './swift-distribution'
11
9
  import { swiftObjCRuntimeFlags } from './swift-objc-runtime'
12
10
  import { objcSdkIntakeFlags } from './swift-objc-standin'
11
+ import { swiftModuleToolchain, swiftSdkPaths } from './swift-sdk-surface'
13
12
  import { SWIFT_WASM_TRIPLE, wasmThreadFlags } from './swiftTargetContract'
14
13
 
15
14
  const RECIPE = 'rive-runtime-sim-2'